@jsonstudio/rcc 0.89.1205 → 0.89.1348

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 (332) hide show
  1. package/README.md +17 -0
  2. package/configsamples/config.json +426 -0
  3. package/configsamples/config.reference.json +58 -0
  4. package/configsamples/provider/crs/config.v1.json +46 -0
  5. package/configsamples/provider/glm/config.v1.json +81 -0
  6. package/configsamples/provider/glm-anthropic/config.v1.json +45 -0
  7. package/configsamples/provider/iflow/config.v1.json +74 -0
  8. package/configsamples/provider/kimi/config.v1.json +41 -0
  9. package/configsamples/provider/lmstudio/config.v1.json +101 -0
  10. package/configsamples/provider/mimo/config.v1.json +35 -0
  11. package/configsamples/provider/modelscope/config.v1.json +96 -0
  12. package/configsamples/provider/qwen/config.v1.json +38 -0
  13. package/configsamples/provider/tab/config.v1.json +50 -0
  14. package/configsamples/provider/tabglm/config.v1.json +49 -0
  15. package/dist/build-info.js +2 -2
  16. package/dist/cli/commands/code.js +12 -6
  17. package/dist/cli/commands/code.js.map +1 -1
  18. package/dist/cli/commands/config.d.ts +2 -1
  19. package/dist/cli/commands/config.js +74 -103
  20. package/dist/cli/commands/config.js.map +1 -1
  21. package/dist/cli/commands/examples.js +6 -6
  22. package/dist/cli/commands/examples.js.map +1 -1
  23. package/dist/cli/commands/init.d.ts +28 -0
  24. package/dist/cli/commands/init.js +91 -0
  25. package/dist/cli/commands/init.js.map +1 -0
  26. package/dist/cli/commands/port.js +10 -2
  27. package/dist/cli/commands/port.js.map +1 -1
  28. package/dist/cli/commands/restart.js +5 -2
  29. package/dist/cli/commands/restart.js.map +1 -1
  30. package/dist/cli/commands/start.js +25 -22
  31. package/dist/cli/commands/start.js.map +1 -1
  32. package/dist/cli/commands/status.js +1 -0
  33. package/dist/cli/commands/status.js.map +1 -1
  34. package/dist/cli/commands/stop.js +1 -0
  35. package/dist/cli/commands/stop.js.map +1 -1
  36. package/dist/cli/config/bundled-docs.d.ts +20 -0
  37. package/dist/cli/config/bundled-docs.js +91 -0
  38. package/dist/cli/config/bundled-docs.js.map +1 -0
  39. package/dist/cli/config/init-config.d.ts +36 -0
  40. package/dist/cli/config/init-config.js +180 -0
  41. package/dist/cli/config/init-config.js.map +1 -0
  42. package/dist/cli/config/init-provider-catalog.d.ts +8 -0
  43. package/dist/cli/config/init-provider-catalog.js +187 -0
  44. package/dist/cli/config/init-provider-catalog.js.map +1 -0
  45. package/dist/cli/register/init-command.d.ts +3 -0
  46. package/dist/cli/register/init-command.js +5 -0
  47. package/dist/cli/register/init-command.js.map +1 -0
  48. package/dist/cli.js +28 -3
  49. package/dist/cli.js.map +1 -1
  50. package/dist/client/gemini-cli/gemini-cli-protocol-client.js +1 -1
  51. package/dist/client/gemini-cli/gemini-cli-protocol-client.js.map +1 -1
  52. package/dist/config/risk-control-config.d.ts +94 -0
  53. package/dist/config/risk-control-config.js +196 -0
  54. package/dist/config/risk-control-config.js.map +1 -0
  55. package/dist/constants/index.d.ts +6 -0
  56. package/dist/constants/index.js +13 -0
  57. package/dist/constants/index.js.map +1 -1
  58. package/dist/docs/daemon-admin-ui.html +2113 -190
  59. package/dist/index.js +0 -1
  60. package/dist/index.js.map +1 -1
  61. package/dist/manager/modules/health/index.d.ts +1 -1
  62. package/dist/manager/modules/quota/antigravity-quota-manager.d.ts +70 -0
  63. package/dist/manager/modules/quota/antigravity-quota-manager.js +442 -0
  64. package/dist/manager/modules/quota/antigravity-quota-manager.js.map +1 -0
  65. package/dist/manager/modules/quota/index.d.ts +3 -127
  66. package/dist/manager/modules/quota/index.js +2 -1093
  67. package/dist/manager/modules/quota/index.js.map +1 -1
  68. package/dist/manager/modules/quota/provider-key-normalization.d.ts +3 -0
  69. package/dist/manager/modules/quota/provider-key-normalization.js +155 -0
  70. package/dist/manager/modules/quota/provider-key-normalization.js.map +1 -0
  71. package/dist/manager/modules/quota/provider-quota-daemon.cooldown.d.ts +9 -0
  72. package/dist/manager/modules/quota/provider-quota-daemon.cooldown.js +115 -0
  73. package/dist/manager/modules/quota/provider-quota-daemon.cooldown.js.map +1 -0
  74. package/dist/manager/modules/quota/provider-quota-daemon.d.ts +77 -0
  75. package/dist/manager/modules/quota/provider-quota-daemon.events.d.ts +12 -0
  76. package/dist/manager/modules/quota/provider-quota-daemon.events.js +237 -0
  77. package/dist/manager/modules/quota/provider-quota-daemon.events.js.map +1 -0
  78. package/dist/manager/modules/quota/provider-quota-daemon.js +404 -0
  79. package/dist/manager/modules/quota/provider-quota-daemon.js.map +1 -0
  80. package/dist/manager/modules/quota/provider-quota-daemon.model-backoff.d.ts +11 -0
  81. package/dist/manager/modules/quota/provider-quota-daemon.model-backoff.js +189 -0
  82. package/dist/manager/modules/quota/provider-quota-daemon.model-backoff.js.map +1 -0
  83. package/dist/manager/modules/quota/provider-quota-daemon.snapshot.d.ts +8 -0
  84. package/dist/manager/modules/quota/provider-quota-daemon.snapshot.js +96 -0
  85. package/dist/manager/modules/quota/provider-quota-daemon.snapshot.js.map +1 -0
  86. package/dist/manager/modules/quota/provider-quota-daemon.view.d.ts +19 -0
  87. package/dist/manager/modules/quota/provider-quota-daemon.view.js +37 -0
  88. package/dist/manager/modules/quota/provider-quota-daemon.view.js.map +1 -0
  89. package/dist/manager/modules/routing/index.d.ts +1 -0
  90. package/dist/manager/modules/routing/index.js +11 -25
  91. package/dist/manager/modules/routing/index.js.map +1 -1
  92. package/dist/manager/quota/provider-quota-center.d.ts +2 -0
  93. package/dist/manager/quota/provider-quota-center.js +80 -82
  94. package/dist/manager/quota/provider-quota-center.js.map +1 -1
  95. package/dist/modules/llmswitch/bridge.d.ts +16 -18
  96. package/dist/modules/llmswitch/bridge.js +293 -94
  97. package/dist/modules/llmswitch/bridge.js.map +1 -1
  98. package/dist/modules/llmswitch/core-loader.d.ts +4 -2
  99. package/dist/modules/llmswitch/core-loader.js +32 -20
  100. package/dist/modules/llmswitch/core-loader.js.map +1 -1
  101. package/dist/modules/pipeline/utils/colored-logger.js +3 -2
  102. package/dist/modules/pipeline/utils/colored-logger.js.map +1 -1
  103. package/dist/modules/pipeline/utils/debug-logger.js +1 -1
  104. package/dist/modules/pipeline/utils/debug-logger.js.map +1 -1
  105. package/dist/providers/auth/iflow-cookie-auth.js +0 -2
  106. package/dist/providers/auth/iflow-cookie-auth.js.map +1 -1
  107. package/dist/providers/auth/oauth-lifecycle.js +2 -23
  108. package/dist/providers/auth/oauth-lifecycle.js.map +1 -1
  109. package/dist/providers/core/config/camoufox-launcher.js +35 -4
  110. package/dist/providers/core/config/camoufox-launcher.js.map +1 -1
  111. package/dist/providers/core/runtime/antigravity-quota-client.js +6 -3
  112. package/dist/providers/core/runtime/antigravity-quota-client.js.map +1 -1
  113. package/dist/providers/core/runtime/base-provider.d.ts +2 -2
  114. package/dist/providers/core/runtime/base-provider.js +74 -69
  115. package/dist/providers/core/runtime/base-provider.js.map +1 -1
  116. package/dist/providers/core/runtime/gemini-cli-http-provider.js +6 -4
  117. package/dist/providers/core/runtime/gemini-cli-http-provider.js.map +1 -1
  118. package/dist/providers/core/runtime/http-request-executor.js +2 -2
  119. package/dist/providers/core/runtime/http-request-executor.js.map +1 -1
  120. package/dist/providers/core/runtime/http-transport-provider.d.ts +14 -0
  121. package/dist/providers/core/runtime/http-transport-provider.js +111 -5
  122. package/dist/providers/core/runtime/http-transport-provider.js.map +1 -1
  123. package/dist/providers/core/runtime/provider-error-classifier.js +10 -0
  124. package/dist/providers/core/runtime/provider-error-classifier.js.map +1 -1
  125. package/dist/providers/core/runtime/provider-factory.js +7 -5
  126. package/dist/providers/core/runtime/provider-factory.js.map +1 -1
  127. package/dist/providers/core/runtime/provider-runtime-metadata.d.ts +6 -0
  128. package/dist/providers/core/runtime/provider-runtime-metadata.js.map +1 -1
  129. package/dist/providers/core/runtime/responses-provider.d.ts +1 -7
  130. package/dist/providers/core/runtime/responses-provider.js +12 -93
  131. package/dist/providers/core/runtime/responses-provider.js.map +1 -1
  132. package/dist/providers/core/strategies/oauth-auth-code-flow.js +12 -8
  133. package/dist/providers/core/strategies/oauth-auth-code-flow.js.map +1 -1
  134. package/dist/providers/core/utils/http-client.js +16 -3
  135. package/dist/providers/core/utils/http-client.js.map +1 -1
  136. package/dist/providers/core/utils/provider-error-logger.d.ts +1 -1
  137. package/dist/providers/core/utils/provider-error-reporter.d.ts +3 -1
  138. package/dist/providers/core/utils/provider-error-reporter.js +3 -0
  139. package/dist/providers/core/utils/provider-error-reporter.js.map +1 -1
  140. package/dist/providers/core/utils/snapshot-writer.js +1 -4
  141. package/dist/providers/core/utils/snapshot-writer.js.map +1 -1
  142. package/dist/providers/mock/mock-provider-runtime.js +57 -27
  143. package/dist/providers/mock/mock-provider-runtime.js.map +1 -1
  144. package/dist/scripts/camoufox/launch-auth.mjs +193 -58
  145. package/dist/server/handlers/handler-utils.js +3 -2
  146. package/dist/server/handlers/handler-utils.js.map +1 -1
  147. package/dist/server/runtime/http-server/daemon-admin/auth-handler.d.ts +2 -0
  148. package/dist/server/runtime/http-server/daemon-admin/auth-handler.js +103 -0
  149. package/dist/server/runtime/http-server/daemon-admin/auth-handler.js.map +1 -0
  150. package/dist/server/runtime/http-server/daemon-admin/auth-session.d.ts +5 -0
  151. package/dist/server/runtime/http-server/daemon-admin/auth-session.js +77 -0
  152. package/dist/server/runtime/http-server/daemon-admin/auth-session.js.map +1 -0
  153. package/dist/server/runtime/http-server/daemon-admin/auth-store.d.ts +18 -0
  154. package/dist/server/runtime/http-server/daemon-admin/auth-store.js +89 -0
  155. package/dist/server/runtime/http-server/daemon-admin/auth-store.js.map +1 -0
  156. package/dist/server/runtime/http-server/daemon-admin/credentials-handler.js +1 -2
  157. package/dist/server/runtime/http-server/daemon-admin/credentials-handler.js.map +1 -1
  158. package/dist/server/runtime/http-server/daemon-admin/providers-handler.js +226 -24
  159. package/dist/server/runtime/http-server/daemon-admin/providers-handler.js.map +1 -1
  160. package/dist/server/runtime/http-server/daemon-admin/quota-handler.js +47 -8
  161. package/dist/server/runtime/http-server/daemon-admin/quota-handler.js.map +1 -1
  162. package/dist/server/runtime/http-server/daemon-admin/restart-handler.js +1 -1
  163. package/dist/server/runtime/http-server/daemon-admin/restart-handler.js.map +1 -1
  164. package/dist/server/runtime/http-server/daemon-admin/stats-handler.js +1 -1
  165. package/dist/server/runtime/http-server/daemon-admin/stats-handler.js.map +1 -1
  166. package/dist/server/runtime/http-server/daemon-admin/status-handler.js +68 -4
  167. package/dist/server/runtime/http-server/daemon-admin/status-handler.js.map +1 -1
  168. package/dist/server/runtime/http-server/daemon-admin-routes.d.ts +3 -4
  169. package/dist/server/runtime/http-server/daemon-admin-routes.js +9 -14
  170. package/dist/server/runtime/http-server/daemon-admin-routes.js.map +1 -1
  171. package/dist/server/runtime/http-server/executor-metadata.js +1 -1
  172. package/dist/server/runtime/http-server/executor-metadata.js.map +1 -1
  173. package/dist/server/runtime/http-server/executor-response.js +0 -16
  174. package/dist/server/runtime/http-server/executor-response.js.map +1 -1
  175. package/dist/server/runtime/http-server/hub-shadow-compare.js +110 -34
  176. package/dist/server/runtime/http-server/hub-shadow-compare.js.map +1 -1
  177. package/dist/server/runtime/http-server/index.d.ts +5 -3
  178. package/dist/server/runtime/http-server/index.js +215 -109
  179. package/dist/server/runtime/http-server/index.js.map +1 -1
  180. package/dist/server/runtime/http-server/middleware.js +19 -1
  181. package/dist/server/runtime/http-server/middleware.js.map +1 -1
  182. package/dist/server/runtime/http-server/request-executor.js +10 -19
  183. package/dist/server/runtime/http-server/request-executor.js.map +1 -1
  184. package/dist/server/runtime/http-server/routes.js +8 -2
  185. package/dist/server/runtime/http-server/routes.js.map +1 -1
  186. package/dist/server/runtime/http-server/session-dir.d.ts +2 -0
  187. package/dist/server/runtime/http-server/session-dir.js +59 -0
  188. package/dist/server/runtime/http-server/session-dir.js.map +1 -0
  189. package/dist/server/runtime/http-server/types.d.ts +0 -4
  190. package/dist/server/utils/utf8-chunk-buffer.js +6 -3
  191. package/dist/server/utils/utf8-chunk-buffer.js.map +1 -1
  192. package/dist/server/utils/warmup-storm-tracker.js +1 -1
  193. package/dist/server/utils/warmup-storm-tracker.js.map +1 -1
  194. package/dist/server-factory.d.ts +6 -28
  195. package/dist/server-factory.js +8 -93
  196. package/dist/server-factory.js.map +1 -1
  197. package/dist/token-daemon/index.js +2 -2
  198. package/dist/token-daemon/index.js.map +1 -1
  199. package/dist/token-daemon/provider-registry.js +0 -1
  200. package/dist/token-daemon/provider-registry.js.map +1 -1
  201. package/dist/token-daemon/server-utils.js +8 -9
  202. package/dist/token-daemon/server-utils.js.map +1 -1
  203. package/dist/token-daemon/token-utils.js +1 -1
  204. package/dist/token-daemon/token-utils.js.map +1 -1
  205. package/dist/tools/semantic-replay.js +2 -2
  206. package/dist/tools/semantic-replay.js.map +1 -1
  207. package/dist/tools/stats-request-events.d.ts +1 -1
  208. package/dist/tools/stats-usage.js +6 -3
  209. package/dist/tools/stats-usage.js.map +1 -1
  210. package/dist/utils/llms-engine-shadow.d.ts +19 -0
  211. package/dist/utils/llms-engine-shadow.js +209 -0
  212. package/dist/utils/llms-engine-shadow.js.map +1 -0
  213. package/dist/utils/runtime-versions.js +2 -1
  214. package/dist/utils/runtime-versions.js.map +1 -1
  215. package/docs/ARCHITECTURE.md +402 -0
  216. package/docs/CODEX_AND_CLAUDE_CODE.md +69 -0
  217. package/docs/CONFIG_ARCHITECTURE.md +517 -0
  218. package/docs/ERROR_HANDLING_AUDIT.md +0 -0
  219. package/docs/GCLI2API_PARITY_GAPS.md +98 -0
  220. package/docs/INSTALLATION_AND_QUICKSTART.md +74 -0
  221. package/docs/INSTRUCTION_MARKUP.md +89 -0
  222. package/docs/MODULE_ENHANCEMENT_SYSTEM.md +666 -0
  223. package/docs/PORTS.md +36 -0
  224. package/docs/PROVIDERS_BUILTIN.md +111 -0
  225. package/docs/PROVIDER_TYPES.md +55 -0
  226. package/docs/SERVERTOOL_CLOCK_DESIGN.md +233 -0
  227. package/docs/USAGE_HANDLING_ANALYSIS.md +335 -0
  228. package/docs/USER_CONFIG_PARSER_CHANGES.md +175 -0
  229. package/docs/V3_INBOUND_OUTBOUND_DESIGN.md +86 -0
  230. package/docs/VIRTUAL_ROUTER_PRIORITY_AND_HEALTH.md +125 -0
  231. package/docs/anthropic-request-golden-samples.md +50 -0
  232. package/docs/ccr-alignment-enhancetool.md +105 -0
  233. package/docs/chat-glm-500-analysis.md +79 -0
  234. package/docs/chat-request-golden-samples.md +42 -0
  235. package/docs/chat-semantic-expansion-plan.md +82 -0
  236. package/docs/cli-command-inventory.md +76 -0
  237. package/docs/codex-samples-replay.md +50 -0
  238. package/docs/daemon-admin-api-design.md +350 -0
  239. package/docs/daemon-admin-module-structure.md +169 -0
  240. package/docs/daemon-admin-ui.html +3394 -0
  241. package/docs/debug-system-design.md +734 -0
  242. package/docs/debugging/gemini-sse-root-cause.md +52 -0
  243. package/docs/debugging/sse_encoding_failure_analysis.md +53 -0
  244. package/docs/dry-run/README.md +721 -0
  245. package/docs/error-handling-v2.md +92 -0
  246. package/docs/exec-command-guard-policy.example.v1.json +42 -0
  247. package/docs/fixes/gemini-protocol-mapping.md +57 -0
  248. package/docs/fixes/oauth-portal-timing-fix.md +202 -0
  249. package/docs/fixes/web-search-hop3-fix.md +265 -0
  250. package/docs/glm-api-reference.md +390 -0
  251. package/docs/glm-chat-completions.md +1779 -0
  252. package/docs/glm-history-inline-images.md +44 -0
  253. package/docs/golden-ci-library.md +66 -0
  254. package/docs/lmstudio-dry-run-summary.md +203 -0
  255. package/docs/lmstudio-tool-calling.md +214 -0
  256. package/docs/mapping-tables/anthropic-to-openai.json +290 -0
  257. package/docs/mapping-tables/iflow-to-openai.json +215 -0
  258. package/docs/mapping-tables/openai-passthrough.json +190 -0
  259. package/docs/mapping-tables/openai-to-iflow.json +227 -0
  260. package/docs/monitoring/Design.md +61 -0
  261. package/docs/multi-token-auth-guide.md +66 -0
  262. package/docs/oauth-authentication-guide.md +168 -0
  263. package/docs/oauth-iflow-implementation.md +153 -0
  264. package/docs/pipeline-routing-report.md +209 -0
  265. package/docs/plans/manager-daemon/PLAN.md +86 -0
  266. package/docs/plans/provider-config-v2-plan.md +176 -0
  267. package/docs/plans/provider-runtime-manager-plan.md +209 -0
  268. package/docs/plans/transparent-429-failover.md +89 -0
  269. package/docs/plans/unified-hub-framework-v1.md +245 -0
  270. package/docs/provider-config-v2-ui-design.md +181 -0
  271. package/docs/provider-quota-design.md +129 -0
  272. package/docs/providers/gemini-provider.md +62 -0
  273. package/docs/providers/lmstudio-v2-migration-report.md +102 -0
  274. package/docs/providers/provider-composite-design.md +142 -0
  275. package/docs/providers/provider-composite-testing.md +98 -0
  276. package/docs/providers/provider-type-only-migration.md +111 -0
  277. package/docs/rccx-wasm-migration.md +74 -0
  278. package/docs/refactoring/architecture-comparison-diagram.md +140 -0
  279. package/docs/refactoring/compatibility-v2-architecture-design.md +738 -0
  280. package/docs/refactoring/workflow-compatibility-refactoring-design.md +361 -0
  281. package/docs/reports/routing-classification-report.json +24 -0
  282. package/docs/reports/routing-classification-report.md +18 -0
  283. package/docs/reports/thinking-keywords-report.json +19 -0
  284. package/docs/responses/README.md +156 -0
  285. package/docs/responses-generic-provider.md +86 -0
  286. package/docs/responses-passthrough-provider-design.md +202 -0
  287. package/docs/routing-awrr-health-weighted-round-robin.md +179 -0
  288. package/docs/routing-instructions.md +393 -0
  289. package/docs/stop-message-auto.md +225 -0
  290. package/docs/streaming-flow.html +30 -0
  291. package/docs/streaming-flow.md +182 -0
  292. package/docs/token-daemon-preview.html +490 -0
  293. package/docs/token-refresh-daemon-plan.md +269 -0
  294. package/docs/transformation-tables/Gemini-FinishReason/345/256/214/346/225/264/350/275/254/346/215/242/350/241/250.json +233 -0
  295. package/docs/transformation-tables/README.md +225 -0
  296. package/docs/transformation-tables/claude-code-router-anthropic-to-gemini.json +283 -0
  297. package/docs/transformation-tables/claude-code-router-anthropic-to-openai.json +208 -0
  298. package/docs/transformation-tables/claude-code-router-openai-to-anthropic.json +261 -0
  299. package/docs/transformation-tables/claude-code-router-openai-to-gemini.json +208 -0
  300. package/docs/transformation-tables/claude-code-router-openai-to-lmstudio.json +182 -0
  301. package/docs/transformation-tables/claude-code-router-openai-to-ollama.json +250 -0
  302. package/docs/transformation-tables/claude-code-router-openai-to-textgenwebui.json +295 -0
  303. package/docs/transformation-tables/claude-code-router-provider-conversions.json +193 -0
  304. package/docs/transformation-tables//345/256/214/346/225/264/347/232/204/345/267/245/345/205/267/346/211/247/350/241/214/346/265/201/347/250/213/350/275/254/346/215/242/350/241/250.json +299 -0
  305. package/docs/transformation-tables//345/257/271/350/257/235/345/216/206/345/217/262/347/273/264/346/212/244/345/210/206/346/236/220.md +134 -0
  306. package/docs/transformation-tables//345/267/245/345/205/267/350/260/203/347/224/250/346/250/241/345/274/217/345/210/206/346/236/220.md +158 -0
  307. package/docs/transformation-tables//347/212/266/346/200/201/347/256/241/347/220/206/351/234/200/346/261/202/345/210/206/346/236/220.md +175 -0
  308. package/docs/transformation-tables//351/235/231/346/200/201/350/241/250vs/345/212/250/346/200/201/345/210/206/346/236/220.md +189 -0
  309. package/docs/transformation-tables//351/235/231/346/200/201/350/241/250/345/207/206/347/241/256/346/200/247/350/257/204/344/274/260.md +179 -0
  310. package/docs/transformation-tables//351/235/236/346/265/201/345/274/217/345/234/272/346/231/257/345/210/206/346/236/220.md +189 -0
  311. package/docs/v2-architecture/IMPLEMENTATION-ROADMAP.md +367 -0
  312. package/docs/v2-architecture/OPTIMIZED-DESIGN.md +827 -0
  313. package/docs/v2-architecture/PRERUN-CONNECTION-DESIGN.md +716 -0
  314. package/docs/v2-architecture/README.md +551 -0
  315. package/docs/verification/modelscope-verify.md +59 -0
  316. package/docs/web-search-service-design.md +322 -0
  317. package/package.json +12 -7
  318. package/scripts/camoufox/launch-auth.mjs +193 -58
  319. package/scripts/monitor-diff.mjs +126 -0
  320. package/scripts/pack-mode.mjs +19 -1
  321. package/scripts/pack-rcc.mjs +63 -0
  322. package/scripts/unified-hub-shadow-compare.mjs +33 -13
  323. package/scripts/verify-e2e-toolcall.mjs +115 -26
  324. package/dist/modules/llmswitch/pipeline-registry.d.ts +0 -57
  325. package/dist/modules/llmswitch/pipeline-registry.js +0 -229
  326. package/dist/modules/llmswitch/pipeline-registry.js.map +0 -1
  327. package/dist/server/RouteCodexServer.d.ts +0 -13
  328. package/dist/server/RouteCodexServer.js +0 -25
  329. package/dist/server/RouteCodexServer.js.map +0 -1
  330. package/dist/v2/conversion/hub/snapshot-recorder.d.ts +0 -12
  331. package/dist/v2/conversion/hub/snapshot-recorder.js +0 -22
  332. package/dist/v2/conversion/hub/snapshot-recorder.js.map +0 -1
@@ -0,0 +1,721 @@
1
+ # Dry-Run System Documentation
2
+
3
+ The RouteCodex Dry-Run System is a comprehensive debugging and testing framework that enables detailed analysis of pipeline execution without actual processing. It supports node-level dry-run execution, intelligent input simulation, bidirectional pipeline processing, and advanced error recovery mechanisms.
4
+
5
+ ## 🏗️ Architecture Overview
6
+
7
+ The dry-run system consists of several interconnected components that work together to provide a complete debugging experience:
8
+
9
+ ```
10
+ ┌─────────────────────────────────────────────────────────────────┐
11
+ │ Dry-Run System Architecture │
12
+ ├─────────────────────────────────────────────────────────────────┤
13
+ │ │
14
+ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
15
+ │ │ Pipeline Dry- │ │ Input │ │ Bidirectional │ │
16
+ │ │ Run Executor │ │ Simulator │ │ Pipeline │ │
17
+ │ │ │ │ │ │ │ │
18
+ │ │ • Node-level │ │ • Mock data │ │ • Request & │ │
19
+ │ │ dry-run │ │ generation │ │ response │ │
20
+ │ │ • Pipeline break │ │ • Context │ │ pipelines │ │
21
+ │ │ • Event │ │ propagation │ │ • Driver │ │
22
+ │ │ handling │ │ • Quality │ │ feedback │ │
23
+ │ │ • Mixed modes │ │ assessment │ │ • Real response │ │
24
+ │ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
25
+ │ │
26
+ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
27
+ │ │ Memory │ │ Error │ │ Pipeline │ │
28
+ │ │ Management │ │ Boundaries │ │ Dry-Run │ │
29
+ │ │ │ │ │ │ Framework │ │
30
+ │ │ • Resource │ │ • Multi-level │ │ • Dry-run │ │
31
+ │ │ tracking │ │ error │ │ configs │ │
32
+ │ │ • Auto cleanup │ │ handling │ │ • Validation │ │
33
+ │ │ • Memory │ │ • Recovery │ │ rules │ │
34
+ │ │ monitoring │ │ strategies │ │ • Performance │ │
35
+ │ │ • Cleanup │ │ • Circuit │ │ estimation │ │
36
+ │ │ strategies │ │ breakers │ │ │ │
37
+ │ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
38
+ └─────────────────────────────────────────────────────────────────┘
39
+ ```
40
+
41
+ ## 📁 File Structure
42
+
43
+ ### Core Framework Files
44
+
45
+ | File | Description | Key Features |
46
+ |------|-------------|--------------|
47
+ | **`pipeline-dry-run-framework.ts`** | Core dry-run framework and interfaces | Node-level configurations, validation rules, error simulation |
48
+ | **`dry-run-pipeline-executor.ts`** | Main pipeline execution engine | Node registration, execution order, event handling, mixed modes |
49
+ | **`input-simulator.ts`** | Intelligent input simulation system | Multiple simulation strategies, context propagation, quality assessment |
50
+ | **`bidirectional-pipeline-dry-run.ts`** | Bidirectional pipeline support | Request/response pipelines, driver feedback, real response integration |
51
+ | **`memory-management.ts`** | Memory and resource management | Resource tracking, cleanup strategies, memory monitoring |
52
+ | **`error-boundaries.ts`** | Error handling and recovery | Multi-level error boundaries, circuit breakers, graceful degradation |
53
+ | **`memory-interface.ts`** | Memory management interfaces | Type definitions, resource interfaces, monitoring interfaces |
54
+ | **`pipeline-dry-run-examples.ts`** | Usage examples and demonstrations | Configuration examples, test scenarios, best practices |
55
+
56
+ ### Test Files
57
+
58
+ | File | Description | Test Coverage |
59
+ |------|-------------|---------------|
60
+ | **`test-all-nodes-dry-run.mjs`** | All-nodes dry-run functionality | Input simulation, complete pipeline dry-run |
61
+ | **`test-bidirectional-pipeline-dry-run.mjs`** | Bidirectional pipeline testing | Mixed modes, response sources, feedback analysis |
62
+
63
+ ## 🔧 Core Components
64
+
65
+ ### 1. Pipeline Dry-Run Framework (`pipeline-dry-run-framework.ts`)
66
+
67
+ **Purpose**: Provides the foundation for node-level dry-run execution with "pipeline break" debugging capabilities.
68
+
69
+ **Key Interfaces**:
70
+ - `NodeDryRunConfig`: Configuration for individual node dry-run behavior
71
+ - `NodeDryRunResult`: Standardized result format for dry-run execution
72
+ - `PipelineDryRunResponse`: Comprehensive response format for pipeline dry-run
73
+ - `OutputValidationRule`: Validation rules for expected outputs
74
+
75
+ **Features**:
76
+ - **Node-Level Configuration**: Each pipeline node can be independently configured for dry-run
77
+ - **Multiple Dry-Run Modes**: Output validation, full analysis, error simulation
78
+ - **Validation Rules**: Comprehensive output validation with customizable rules
79
+ - **Error Simulation**: Controlled error simulation for testing error handling
80
+ - **Performance Estimation**: Detailed performance metrics and estimates
81
+ - **Breakpoint Support**: Debug breakpoints for detailed inspection
82
+
83
+ **Usage Example**:
84
+ ```typescript
85
+ import { pipelineDryRunManager, type NodeDryRunConfig } from './src/modules/pipeline/dry-run/pipeline-dry-run-framework.js';
86
+
87
+ const config: NodeDryRunConfig = {
88
+ enabled: true,
89
+ mode: 'full-analysis',
90
+ breakpointBehavior: 'pause',
91
+ verbosity: 'detailed',
92
+ validationRules: [
93
+ {
94
+ id: 'schema-validation',
95
+ type: 'schema',
96
+ condition: { required: ['_metadata'] },
97
+ errorMessage: 'Missing required metadata',
98
+ severity: 'error'
99
+ }
100
+ ]
101
+ };
102
+
103
+ pipelineDryRunManager.configureNodeDryRun('llm-switch', config);
104
+ ```
105
+
106
+ ### 2. Dry-Run Pipeline Executor (`dry-run-pipeline-executor.ts`)
107
+
108
+ **Purpose**: Orchestrates the execution of dry-run pipelines with support for mixed execution modes and intelligent input simulation.
109
+
110
+ **Key Classes**:
111
+ - `DryRunPipelineExecutor`: Main execution engine for dry-run pipelines
112
+ - `PipelineNodeInfo`: Node information and configuration
113
+ - `ExecutionContext`: Complete execution context with metadata
114
+ - `BreakpointEvent`: Event system for debugging and monitoring
115
+
116
+ **Features**:
117
+ - **Mixed Execution Modes**: Support for partial dry-run (some nodes normal, some dry-run)
118
+ - **All-Nodes Dry-Run**: Intelligent handling when all nodes are configured for dry-run
119
+ - **Event System**: Comprehensive event handling for debugging
120
+ - **Execution Plans**: Detailed execution plans with time estimates
121
+ - **Breakpoint Handling**: Configurable breakpoint behavior (continue, pause, terminate)
122
+ - **Performance Tracking**: Real-time performance metrics and statistics
123
+
124
+ **Usage Example**:
125
+ ```typescript
126
+ import { dryRunPipelineExecutor } from './src/modules/pipeline/dry-run/dry-run-pipeline-executor.js';
127
+
128
+ // Register nodes with mixed dry-run configuration
129
+ dryRunPipelineExecutor.registerNodes([
130
+ {
131
+ id: 'llm-switch',
132
+ type: 'llm-switch',
133
+ module: llmSwitchModule,
134
+ isDryRun: true,
135
+ config: { enabled: true, mode: 'full-analysis' }
136
+ },
137
+ {
138
+ id: 'provider',
139
+ type: 'provider',
140
+ module: providerModule,
141
+ isDryRun: false // Normal execution
142
+ }
143
+ ]);
144
+
145
+ // Execute in mixed mode
146
+ const result = await dryRunPipelineExecutor.executePipeline(
147
+ request,
148
+ 'test-pipeline',
149
+ 'mixed'
150
+ );
151
+ ```
152
+
153
+ ### 3. Input Simulator (`input-simulator.ts`)
154
+
155
+ **Purpose**: Solves the "all nodes dry-run" problem by generating intelligent mock input data for pipeline execution.
156
+
157
+ **Key Classes**:
158
+ - `InputSimulator`: Main simulation engine with multiple strategies
159
+ - `InputSimulationConfig`: Configuration for simulation behavior
160
+ - `SimulatedInput`: Result of input simulation with quality metrics
161
+ - `ContextPropagationData`: Data propagation context for pipeline simulation
162
+
163
+ **Simulation Strategies**:
164
+ - **Historical Data**: Uses historical request/response data
165
+ - **Schema Inference**: Generates data based on node schema definitions
166
+ - **Rule-Based**: Uses predefined rules and templates
167
+ - **AI Generation**: AI-powered data generation
168
+ - **Request Propagation**: Propagates original request with modifications
169
+
170
+ **Features**:
171
+ - **Multiple Fallback Strategies**: Automatic strategy selection with fallbacks
172
+ - **Quality Assessment**: Quality scoring and confidence metrics
173
+ - **Context Propagation**: Maintains context across pipeline nodes
174
+ - **Performance Estimation**: Time and memory usage estimates
175
+ - **Historical Learning**: Learns from actual execution data
176
+
177
+ **Usage Example**:
178
+ ```typescript
179
+ import { inputSimulator } from './src/modules/pipeline/dry-run/input-simulator.js';
180
+
181
+ const simulatedInput = await inputSimulator.simulateInput(
182
+ originalRequest,
183
+ 'llm-switch',
184
+ 'llm-switch',
185
+ contextData,
186
+ {
187
+ enabled: true,
188
+ primaryStrategy: 'historical-data',
189
+ fallbackStrategies: ['schema-inference', 'rule-based'],
190
+ qualityRequirement: 'medium'
191
+ }
192
+ );
193
+ ```
194
+
195
+ ### 4. Bidirectional Pipeline Dry-Run (`bidirectional-pipeline-dry-run.ts`)
196
+
197
+ **Purpose**: Extends dry-run capabilities to bidirectional pipelines with request/response processing and driver feedback.
198
+
199
+ **Key Classes**:
200
+ - `BidirectionalPipelineManager`: Manages bidirectional pipeline execution
201
+ - `BidirectionalPipelineConfig`: Configuration for bidirectional behavior
202
+ - `ResponseDryRunConfig**: Response-specific dry-run configuration
203
+ - `DriverFeedbackAnalysis**: Comprehensive feedback analysis
204
+
205
+ **Features**:
206
+ - **Bidirectional Processing**: Separate request and response pipeline handling
207
+ - **Real Response Integration**: Use actual server responses as dry-run input
208
+ - **Driver Feedback**: Performance and quality analysis across pipeline stages
209
+ - **Response Input Sources**: Multiple response data sources (real, simulated, cached)
210
+ - **Transformation Rules**: Configurable response transformation and validation
211
+ - **Performance Analytics**: Detailed performance metrics and optimization suggestions
212
+
213
+ **Response Input Sources**:
214
+ - **Real Response**: Use actual server responses
215
+ - **Simulated Response**: AI-generated mock responses
216
+ - **Cached Response**: Use cached historical responses
217
+
218
+ **Usage Example**:
219
+ ```typescript
220
+ import { bidirectionalPipelineManager } from './src/modules/pipeline/dry-run/bidirectional-pipeline-dry-run.js';
221
+
222
+ const result = await bidirectionalPipelineManager.executeBidirectionalPipeline(
223
+ request,
224
+ 'bidirectional-test',
225
+ realServerResponse
226
+ );
227
+
228
+ console.log('Request result:', result.requestResult);
229
+ console.log('Response result:', result.responseResult);
230
+ console.log('Driver feedback:', result.driverFeedbackAnalysis);
231
+ ```
232
+
233
+ ### 5. Memory Management (`memory-management.ts`)
234
+
235
+ **Purpose**: Provides comprehensive memory management, resource cleanup, and leak prevention for dry-run operations.
236
+
237
+ **Key Classes**:
238
+ - `MemoryManager`: Centralized memory and resource management
239
+ - `ResourceInfo`: Detailed resource tracking information
240
+ - `MemoryStats`: Comprehensive memory usage statistics
241
+ - `CleanupResult**: Results of cleanup operations
242
+
243
+ **Features**:
244
+ - **Resource Tracking**: Automatic registration and tracking of all resources
245
+ - **Multiple Cleanup Strategies**: LRU, LFU, FIFO, TTL, hybrid strategies
246
+ - **Memory Monitoring**: Real-time memory usage monitoring with thresholds
247
+ - **Automatic Cleanup**: Configurable automatic resource cleanup
248
+ - **Performance Optimization**: Memory optimization and leak prevention
249
+ - **Statistics and Reporting**: Detailed memory usage reports and analytics
250
+
251
+ **Cleanup Strategies**:
252
+ - **LRU (Least Recently Used)**: Clean least recently used resources first
253
+ - **LFU (Least Frequently Used)**: Clean least frequently used resources first
254
+ - **FIFO (First In First Out)**: Clean resources in creation order
255
+ - **TTL-Based**: Clean resources based on time-to-live
256
+ - **Size-Based**: Clean largest resources first
257
+ - **Hybrid**: Intelligent combination of multiple strategies
258
+
259
+ **Usage Example**:
260
+ ```typescript
261
+ import { memoryManager, ResourceType } from './src/modules/pipeline/dry-run/memory-management.js';
262
+
263
+ // Register a resource for tracking
264
+ memoryManager.registerResource(
265
+ 'resource-123',
266
+ ResourceType.EXECUTION_CONTEXT,
267
+ resourceData,
268
+ 1024, // Estimated size in bytes
269
+ ['execution', 'dry-run'],
270
+ { pipelineId: 'test-pipeline' }
271
+ );
272
+
273
+ // Get resource with automatic access tracking
274
+ const resource = memoryManager.getResource('resource-123');
275
+
276
+ // Manual cleanup
277
+ const cleanupResult = await memoryManager.cleanup();
278
+ console.log(`Freed ${cleanupResult.freedMemory} bytes`);
279
+ ```
280
+
281
+ ### 6. Error Boundaries (`error-boundaries.ts`)
282
+
283
+ **Purpose**: Provides comprehensive error handling, recovery mechanisms, and fault tolerance for dry-run operations.
284
+
285
+ **Key Classes**:
286
+ - `ErrorBoundaryManager`: Centralized error boundary management
287
+ - `ErrorBoundary`: Individual error boundary for protected operations
288
+ - `SystemError**: Standardized error representation
289
+ - `CircuitBreakerState**: Circuit breaker state management
290
+
291
+ **Features**:
292
+ - **Multi-Level Error Handling**: Global and local error boundaries
293
+ - **Intelligent Recovery Strategies**: Automatic recovery with multiple strategies
294
+ - **Circuit Breaker Pattern**: Prevents cascading failures
295
+ - **Graceful Degradation**: Maintains system availability during errors
296
+ - **Error Isolation**: Contains errors within boundaries
297
+ - **Comprehensive Statistics**: Detailed error tracking and analysis
298
+
299
+ **Recovery Strategies**:
300
+ - **Retry Immediate**: Immediate retry for transient errors
301
+ - **Retry Delayed**: Delayed retry with configurable delays
302
+ - **Retry Exponential**: Exponential backoff for persistent errors
303
+ - **Fallback Primary/Secondary**: Fallback to alternative implementations
304
+ - **Circuit Breaker**: Temporarily stop operations on repeated failures
305
+ - **Graceful Degradation**: Degrade functionality gracefully
306
+ - **Skip Operation**: Skip non-critical operations
307
+ - **Terminate**: Stop operations on critical errors
308
+
309
+ **Usage Example**:
310
+ ```typescript
311
+ import { errorBoundaryManager, defaultErrorBoundaryConfig } from './src/modules/pipeline/dry-run/error-boundaries.js';
312
+
313
+ // Create an error boundary
314
+ const boundary = errorBoundaryManager.createBoundary({
315
+ ...defaultErrorBoundaryConfig,
316
+ boundaryId: 'dry-run-boundary',
317
+ maxRetries: 3,
318
+ enableCircuitBreaker: true,
319
+ enableGracefulDegradation: true
320
+ });
321
+
322
+ // Execute protected operation
323
+ const result = await boundary.execute(
324
+ async () => {
325
+ // Your dry-run operation here
326
+ return await performDryRunOperation();
327
+ },
328
+ async () => {
329
+ // Fallback operation
330
+ return await performFallbackOperation();
331
+ }
332
+ );
333
+ ```
334
+
335
+ ### 7. Memory Interface (`memory-interface.ts`)
336
+
337
+ **Purpose**: Defines comprehensive interfaces for memory management, resource handling, and system monitoring.
338
+
339
+ **Key Interfaces**:
340
+ - `Disposable`: Standard interface for disposable resources
341
+ - `ResourceUsage`: System resource usage information
342
+ - `MemoryEvent`: Memory-related event data
343
+ - `MemoryAnalyzer`: Memory analysis and leak detection
344
+ - `MemoryMonitor`: Real-time memory monitoring
345
+ - `ResourcePool`: Resource pooling interface
346
+
347
+ **Features**:
348
+ - **Type Safety**: Comprehensive TypeScript type definitions
349
+ - **Extensibility**: Well-defined interfaces for extension
350
+ - **Monitoring**: Standardized monitoring capabilities
351
+ - **Analysis**: Memory analysis and leak detection interfaces
352
+ - **Resource Management**: Standardized resource lifecycle management
353
+
354
+ ## 🚀 Usage Patterns
355
+
356
+ ### 1. Basic Node-Level Dry-Run
357
+
358
+ ```typescript
359
+ // Configure individual nodes for dry-run
360
+ pipelineDryRunManager.configureNodesDryRun({
361
+ 'llm-switch': {
362
+ enabled: true,
363
+ mode: 'output-validation',
364
+ breakpointBehavior: 'continue',
365
+ verbosity: 'normal'
366
+ },
367
+ 'compatibility': {
368
+ enabled: true,
369
+ mode: 'full-analysis',
370
+ breakpointBehavior: 'pause',
371
+ verbosity: 'detailed'
372
+ }
373
+ });
374
+
375
+ // Execute with mixed modes
376
+ const result = await dryRunPipelineExecutor.executePipeline(
377
+ request,
378
+ 'test-pipeline',
379
+ 'mixed'
380
+ );
381
+ ```
382
+
383
+ ### 2. All-Nodes Dry-Run with Input Simulation
384
+
385
+ ```typescript
386
+ // Configure all nodes for dry-run
387
+ const allNodesConfig = {
388
+ 'llm-switch': { enabled: true, mode: 'full-analysis' },
389
+ 'compatibility': { enabled: true, mode: 'full-analysis' },
390
+ 'provider': { enabled: true, mode: 'full-analysis' }
391
+ };
392
+
393
+ pipelineDryRunManager.configureNodesDryRun(allNodesConfig);
394
+
395
+ // Execute - input simulator will automatically generate mock data
396
+ const result = await dryRunPipelineExecutor.executePipeline(
397
+ request,
398
+ 'all-nodes-test',
399
+ 'dry-run'
400
+ );
401
+ ```
402
+
403
+ ### 3. Bidirectional Pipeline Dry-Run
404
+
405
+ ```typescript
406
+ // Configure bidirectional pipeline
407
+ const bidirectionalConfig = {
408
+ requestConfig: {
409
+ dryRunMode: 'full',
410
+ nodeConfigs: {
411
+ 'llm-switch': { enabled: true, mode: 'full-analysis' },
412
+ 'compatibility': { enabled: false, mode: 'output-validation' }
413
+ }
414
+ },
415
+ responseConfig: {
416
+ dryRunMode: 'partial',
417
+ responseDryRun: {
418
+ enabled: true,
419
+ inputSource: 'real-response',
420
+ performanceAnalysis: true
421
+ }
422
+ },
423
+ driverFeedback: {
424
+ enabled: true,
425
+ analysisLevel: 'detailed'
426
+ }
427
+ };
428
+
429
+ const result = await bidirectionalPipelineManager.executeBidirectionalPipeline(
430
+ request,
431
+ 'bidirectional-test',
432
+ realServerResponse
433
+ );
434
+ ```
435
+
436
+ ### 4. Memory Management Integration
437
+
438
+ ```typescript
439
+ // Register resources for automatic cleanup
440
+ memoryManager.registerResource(
441
+ 'dry-run-context',
442
+ ResourceType.EXECUTION_CONTEXT,
443
+ contextData,
444
+ 2048,
445
+ ['dry-run', 'execution'],
446
+ { pipelineId: 'test-pipeline' }
447
+ );
448
+
449
+ // Execute with memory monitoring
450
+ const stats = memoryManager.getStats();
451
+ console.log(`Memory usage: ${stats.totalUsage} bytes (${(stats.memoryUsageRatio * 100).toFixed(1)}%)`);
452
+ ```
453
+
454
+ ### 5. Error Boundary Protection
455
+
456
+ ```typescript
457
+ // Create protected execution boundary
458
+ const boundary = errorBoundaryManager.createBoundary({
459
+ boundaryId: 'dry-run-protection',
460
+ maxRetries: 3,
461
+ enableCircuitBreaker: true,
462
+ enableGracefulDegradation: true
463
+ });
464
+
465
+ // Execute with error protection
466
+ const result = await boundary.execute(
467
+ async () => {
468
+ return await performComplexDryRunOperation();
469
+ },
470
+ async () => {
471
+ return await performGracefulFallback();
472
+ }
473
+ );
474
+ ```
475
+
476
+ ## 🧪 Testing
477
+
478
+ ### Running Tests
479
+
480
+ ```bash
481
+ # Test all-nodes dry-run functionality
482
+ node test-all-nodes-dry-run.mjs
483
+
484
+ # Test bidirectional pipeline dry-run
485
+ node test-bidirectional-pipeline-dry-run.mjs
486
+
487
+ # Run with specific configurations
488
+ node test-all-nodes-dry-run.mjs --mode=full-analysis
489
+ node test-bidirectional-pipeline-dry-run.mjs --response-source=real-response
490
+ ```
491
+
492
+ ### Test Coverage
493
+
494
+ The test suite covers:
495
+
496
+ - **All-Nodes Dry-Run**: Input simulation, context propagation, complete pipeline analysis
497
+ - **Mixed Execution Modes**: Partial dry-run with normal execution nodes
498
+ - **Bidirectional Processing**: Request/response pipeline coordination
499
+ - **Response Input Sources**: Real, simulated, and cached response handling
500
+ - **Driver Feedback Analysis**: Performance and quality analytics
501
+ - **Memory Management**: Resource tracking, cleanup strategies, leak prevention
502
+ - **Error Boundaries**: Error handling, recovery mechanisms, circuit breakers
503
+ - **Performance Monitoring**: Memory usage, execution time, resource optimization
504
+
505
+ ## 🔧 Configuration
506
+
507
+ ### Dry-Run Configuration Structure
508
+
509
+ ```json
510
+ {
511
+ "dryRun": {
512
+ "global": {
513
+ "enabled": true,
514
+ "defaultMode": "output-validation",
515
+ "verbosity": "normal",
516
+ "autoCleanup": true
517
+ },
518
+ "nodes": {
519
+ "llm-switch": {
520
+ "enabled": true,
521
+ "mode": "full-analysis",
522
+ "breakpointBehavior": "continue",
523
+ "validationRules": [...],
524
+ "errorSimulation": {...}
525
+ },
526
+ "compatibility": {
527
+ "enabled": false,
528
+ "mode": "output-validation"
529
+ }
530
+ },
531
+ "inputSimulation": {
532
+ "enabled": true,
533
+ "primaryStrategy": "historical-data",
534
+ "fallbackStrategies": ["schema-inference", "rule-based"],
535
+ "qualityRequirement": "medium"
536
+ },
537
+ "memory": {
538
+ "maxMemoryUsage": 536870912,
539
+ "cleanupInterval": 60000,
540
+ "enableMonitoring": true,
541
+ "cleanupStrategy": "hybrid"
542
+ },
543
+ "errorHandling": {
544
+ "maxRetries": 3,
545
+ "enableCircuitBreaker": true,
546
+ "enableGracefulDegradation": true
547
+ }
548
+ }
549
+ }
550
+ ```
551
+
552
+ ## 📊 Monitoring and Analytics
553
+
554
+ ### Memory Usage Monitoring
555
+
556
+ ```typescript
557
+ // Get current memory statistics
558
+ const stats = memoryManager.getStats();
559
+ console.log(`Memory Usage: ${stats.totalUsage} bytes`);
560
+ console.log(`Active Resources: ${stats.activeResources}`);
561
+ console.log(`Cache Hit Rate: ${stats.cacheHitRate}`);
562
+
563
+ // Set up memory monitoring callbacks
564
+ memoryManager.setCallbacks({
565
+ onMemoryWarning: (stats) => {
566
+ console.warn(`Memory usage warning: ${(stats.memoryUsageRatio * 100).toFixed(1)}%`);
567
+ },
568
+ onMemoryCritical: (stats) => {
569
+ console.error(`Memory usage critical: ${(stats.memoryUsageRatio * 100).toFixed(1)}%`);
570
+ }
571
+ });
572
+ ```
573
+
574
+ ### Error Analytics
575
+
576
+ ```typescript
577
+ // Get error statistics
578
+ const errorStats = errorBoundaryManager.getStats();
579
+ console.log(`Total Errors: ${errorStats.totalErrors}`);
580
+ console.log(`Successful Recoveries: ${errorStats.successfulRecoveries}`);
581
+ console.log(`Average Recovery Time: ${errorStats.averageRecoveryTime}ms`);
582
+
583
+ // Get active errors
584
+ const activeErrors = errorBoundaryManager.getActiveErrors();
585
+ ```
586
+
587
+ ### Performance Analytics
588
+
589
+ ```typescript
590
+ // Driver feedback analysis provides detailed performance metrics
591
+ if (result.driverFeedbackAnalysis) {
592
+ const analysis = result.driverFeedbackAnalysis;
593
+ console.log(`Request-Response Correlation: ${analysis.requestResponseCorrelation.similarity}`);
594
+ console.log(`Total Processing Time: ${analysis.performanceAnalysis.totalOverhead}ms`);
595
+ console.log(`Overall Quality Score: ${analysis.qualityAnalysis.overallQuality}`);
596
+ }
597
+ ```
598
+
599
+ ## 🎯 Best Practices
600
+
601
+ ### 1. Configuration Management
602
+ - Use consistent configuration across all dry-run nodes
603
+ - Configure appropriate verbosity levels for different environments
604
+ - Enable memory monitoring in production environments
605
+
606
+ ### 2. Memory Management
607
+ - Always register resources with the memory manager
608
+ - Use appropriate cleanup strategies for your use case
609
+ - Monitor memory usage and set appropriate thresholds
610
+
611
+ ### 3. Error Handling
612
+ - Create appropriate error boundaries for critical operations
613
+ - Configure sensible retry strategies for different error types
614
+ - Enable graceful degradation for non-critical operations
615
+
616
+ ### 4. Performance Optimization
617
+ - Use input simulation for all-nodes dry-run scenarios
618
+ - Leverage caching for frequently used response data
619
+ - Monitor performance metrics and optimize accordingly
620
+
621
+ ### 5. Testing Strategy
622
+ - Test both individual nodes and complete pipelines
623
+ - Validate mixed execution modes thoroughly
624
+ - Test error scenarios and recovery mechanisms
625
+
626
+ ## 🔍 Troubleshooting
627
+
628
+ ### Common Issues
629
+
630
+ **Memory Leaks**
631
+ - Ensure all resources are properly registered with memory manager
632
+ - Check for missing cleanup operations
633
+ - Monitor memory usage trends over time
634
+
635
+ **Slow Performance**
636
+ - Optimize input simulation strategies
637
+ - Use caching for frequently accessed data
638
+ - Adjust cleanup intervals based on load
639
+
640
+ **Error Recovery Failures**
641
+ - Verify error boundary configurations
642
+ - Check fallback operation implementations
643
+ - Monitor circuit breaker states
644
+
645
+ **Input Simulation Issues**
646
+ - Validate simulation strategy configurations
647
+ - Check historical data availability
648
+ - Ensure appropriate fallback strategies are configured
649
+
650
+ ### Debug Tools
651
+
652
+ ```typescript
653
+ // Enable detailed logging
654
+ console.log('Memory Stats:', memoryManager.getStats());
655
+ console.log('Error Stats:', errorBoundaryManager.getStats());
656
+
657
+ // Get detailed resource information
658
+ const resources = memoryManager.getAllResources();
659
+ resources.forEach(resource => {
660
+ console.log(`${resource.id}: ${resource.estimatedSize} bytes`);
661
+ });
662
+
663
+ // Check circuit breaker states
664
+ dryRunPipelineExecutor.getRegisteredNodes().forEach(node => {
665
+ const boundary = errorBoundaryManager.getBoundary(node.id);
666
+ if (boundary) {
667
+ console.log(`${node.id} circuit breaker:`, boundary.getCircuitBreakerState());
668
+ }
669
+ });
670
+ ```
671
+
672
+ ## 📈 Advanced Features
673
+
674
+ ### Custom Simulation Strategies
675
+
676
+ ```typescript
677
+ // Add custom simulation strategy
678
+ inputSimulator.addStrategy('custom-strategy', async (input, context) => {
679
+ // Custom simulation logic
680
+ return {
681
+ source: 'custom',
682
+ data: customGenerateData(input, context),
683
+ quality: 0.9,
684
+ confidence: 0.85,
685
+ strategy: 'custom-strategy',
686
+ metadata: { /* Custom metadata */ }
687
+ };
688
+ });
689
+ ```
690
+
691
+ ### Custom Error Handlers
692
+
693
+ ```typescript
694
+ // Add custom error handlers
695
+ const boundary = errorBoundaryManager.createBoundary({
696
+ ...defaultErrorBoundaryConfig,
697
+ customHandlers: {
698
+ [ErrorType.NETWORK_ERROR]: async (error) => {
699
+ // Custom network error handling
700
+ return await handleNetworkError(error);
701
+ }
702
+ }
703
+ });
704
+ ```
705
+
706
+ ### Custom Recovery Strategies
707
+
708
+ ```typescript
709
+ // Implement custom recovery logic
710
+ const customRecovery = async (error: SystemError) => {
711
+ // Custom recovery logic
712
+ return {
713
+ success: true,
714
+ resolved: true,
715
+ action: 'custom-recovery',
716
+ result: await performCustomRecovery(error)
717
+ };
718
+ };
719
+ ```
720
+
721
+ This comprehensive dry-run system provides powerful debugging and testing capabilities for the RouteCodex pipeline, enabling detailed analysis, performance optimization, and reliable error handling across all execution scenarios.