pi-smart-router 0.1.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 (310) hide show
  1. package/.pi/extensions/smart-router/command-formatters.ts +167 -0
  2. package/.pi/extensions/smart-router/commands.ts +242 -0
  3. package/.pi/extensions/smart-router/dataset-export.ts +142 -0
  4. package/.pi/extensions/smart-router/delegate-stream.ts +105 -0
  5. package/.pi/extensions/smart-router/delegation-runtime.ts +355 -0
  6. package/.pi/extensions/smart-router/extension-setup.ts +115 -0
  7. package/.pi/extensions/smart-router/fleet-bootstrap.ts +244 -0
  8. package/.pi/extensions/smart-router/index.ts +115 -0
  9. package/.pi/extensions/smart-router/package.json +3 -0
  10. package/.pi/extensions/smart-router/pi-model-scope.ts +55 -0
  11. package/.pi/extensions/smart-router/pricing-lifecycle.ts +43 -0
  12. package/.pi/extensions/smart-router/route-and-delegate.ts +562 -0
  13. package/.pi/extensions/smart-router/routing-context.ts +171 -0
  14. package/.pi/extensions/smart-router/routing-outcomes.ts +44 -0
  15. package/.pi/extensions/smart-router/session-lifecycle.ts +140 -0
  16. package/.pi/extensions/smart-router/stream-delegation.ts +75 -0
  17. package/.pi/extensions/smart-router/types.ts +90 -0
  18. package/.pi/extensions/smart-router/utils.ts +58 -0
  19. package/README.md +593 -0
  20. package/bin/pi-smart-router.mjs +79 -0
  21. package/config/.gitkeep +0 -0
  22. package/config/hydra-projection-weights.json.example +1169 -0
  23. package/config/models.yaml.example +58 -0
  24. package/config/p-success-weights.json.example +19 -0
  25. package/config/routing-calibration.json.example +1605 -0
  26. package/config/routing-centroids.json.example +1570 -0
  27. package/config/routing-clusters.yaml.example +41 -0
  28. package/data/contrib/example.json +25 -0
  29. package/dist/api/explain/router-explain.d.ts +47 -0
  30. package/dist/api/explain/router-explain.d.ts.map +1 -0
  31. package/dist/api/explain/router-explain.js +101 -0
  32. package/dist/api/explain/router-explain.js.map +1 -0
  33. package/dist/api/middleware/pi-router-middleware.d.ts +86 -0
  34. package/dist/api/middleware/pi-router-middleware.d.ts.map +1 -0
  35. package/dist/api/middleware/pi-router-middleware.js +83 -0
  36. package/dist/api/middleware/pi-router-middleware.js.map +1 -0
  37. package/dist/cli/smart-router-cli.d.ts +85 -0
  38. package/dist/cli/smart-router-cli.d.ts.map +1 -0
  39. package/dist/cli/smart-router-cli.js +293 -0
  40. package/dist/cli/smart-router-cli.js.map +1 -0
  41. package/dist/config/defaults.d.ts +7 -0
  42. package/dist/config/defaults.d.ts.map +1 -0
  43. package/dist/config/defaults.js +33 -0
  44. package/dist/config/defaults.js.map +1 -0
  45. package/dist/config/models-loader.d.ts +22 -0
  46. package/dist/config/models-loader.d.ts.map +1 -0
  47. package/dist/config/models-loader.js +51 -0
  48. package/dist/config/models-loader.js.map +1 -0
  49. package/dist/config/pi-model-mapper.d.ts +40 -0
  50. package/dist/config/pi-model-mapper.d.ts.map +1 -0
  51. package/dist/config/pi-model-mapper.js +216 -0
  52. package/dist/config/pi-model-mapper.js.map +1 -0
  53. package/dist/config/routing-clusters-loader.d.ts +35 -0
  54. package/dist/config/routing-clusters-loader.d.ts.map +1 -0
  55. package/dist/config/routing-clusters-loader.js +100 -0
  56. package/dist/config/routing-clusters-loader.js.map +1 -0
  57. package/dist/domain/delegation/delegation-context.d.ts +23 -0
  58. package/dist/domain/delegation/delegation-context.d.ts.map +1 -0
  59. package/dist/domain/delegation/delegation-context.js +73 -0
  60. package/dist/domain/delegation/delegation-context.js.map +1 -0
  61. package/dist/domain/delegation/execution-ledger.d.ts +19 -0
  62. package/dist/domain/delegation/execution-ledger.d.ts.map +1 -0
  63. package/dist/domain/delegation/execution-ledger.js +23 -0
  64. package/dist/domain/delegation/execution-ledger.js.map +1 -0
  65. package/dist/domain/delegation/output-headroom.d.ts +39 -0
  66. package/dist/domain/delegation/output-headroom.d.ts.map +1 -0
  67. package/dist/domain/delegation/output-headroom.js +78 -0
  68. package/dist/domain/delegation/output-headroom.js.map +1 -0
  69. package/dist/domain/matching/cluster-matcher.d.ts +69 -0
  70. package/dist/domain/matching/cluster-matcher.d.ts.map +1 -0
  71. package/dist/domain/matching/cluster-matcher.js +294 -0
  72. package/dist/domain/matching/cluster-matcher.js.map +1 -0
  73. package/dist/domain/matching/embedding-provider.d.ts +21 -0
  74. package/dist/domain/matching/embedding-provider.d.ts.map +1 -0
  75. package/dist/domain/matching/embedding-provider.js +42 -0
  76. package/dist/domain/matching/embedding-provider.js.map +1 -0
  77. package/dist/domain/matching/hydra-input.d.ts +18 -0
  78. package/dist/domain/matching/hydra-input.d.ts.map +1 -0
  79. package/dist/domain/matching/hydra-input.js +40 -0
  80. package/dist/domain/matching/hydra-input.js.map +1 -0
  81. package/dist/domain/matching/hydra-matcher.d.ts +103 -0
  82. package/dist/domain/matching/hydra-matcher.d.ts.map +1 -0
  83. package/dist/domain/matching/hydra-matcher.js +275 -0
  84. package/dist/domain/matching/hydra-matcher.js.map +1 -0
  85. package/dist/domain/pinning/cache-economics.d.ts +53 -0
  86. package/dist/domain/pinning/cache-economics.d.ts.map +1 -0
  87. package/dist/domain/pinning/cache-economics.js +72 -0
  88. package/dist/domain/pinning/cache-economics.js.map +1 -0
  89. package/dist/domain/pinning/loop-escalation.d.ts +41 -0
  90. package/dist/domain/pinning/loop-escalation.d.ts.map +1 -0
  91. package/dist/domain/pinning/loop-escalation.js +137 -0
  92. package/dist/domain/pinning/loop-escalation.js.map +1 -0
  93. package/dist/domain/pinning/session-pinner.d.ts +81 -0
  94. package/dist/domain/pinning/session-pinner.d.ts.map +1 -0
  95. package/dist/domain/pinning/session-pinner.js +237 -0
  96. package/dist/domain/pinning/session-pinner.js.map +1 -0
  97. package/dist/domain/pinning/sub-route-policy.d.ts +41 -0
  98. package/dist/domain/pinning/sub-route-policy.d.ts.map +1 -0
  99. package/dist/domain/pinning/sub-route-policy.js +72 -0
  100. package/dist/domain/pinning/sub-route-policy.js.map +1 -0
  101. package/dist/domain/pipeline/router-pipeline.d.ts +180 -0
  102. package/dist/domain/pipeline/router-pipeline.d.ts.map +1 -0
  103. package/dist/domain/pipeline/router-pipeline.js +807 -0
  104. package/dist/domain/pipeline/router-pipeline.js.map +1 -0
  105. package/dist/domain/pipeline/safe-default.d.ts +25 -0
  106. package/dist/domain/pipeline/safe-default.d.ts.map +1 -0
  107. package/dist/domain/pipeline/safe-default.js +41 -0
  108. package/dist/domain/pipeline/safe-default.js.map +1 -0
  109. package/dist/domain/refactor-guardrails.d.ts +48 -0
  110. package/dist/domain/refactor-guardrails.d.ts.map +1 -0
  111. package/dist/domain/refactor-guardrails.js +129 -0
  112. package/dist/domain/refactor-guardrails.js.map +1 -0
  113. package/dist/domain/routing/context-fit.d.ts +53 -0
  114. package/dist/domain/routing/context-fit.d.ts.map +1 -0
  115. package/dist/domain/routing/context-fit.js +142 -0
  116. package/dist/domain/routing/context-fit.js.map +1 -0
  117. package/dist/domain/routing/expected-cost.d.ts +63 -0
  118. package/dist/domain/routing/expected-cost.d.ts.map +1 -0
  119. package/dist/domain/routing/expected-cost.js +177 -0
  120. package/dist/domain/routing/expected-cost.js.map +1 -0
  121. package/dist/domain/routing/p-success-classifier.d.ts +130 -0
  122. package/dist/domain/routing/p-success-classifier.d.ts.map +1 -0
  123. package/dist/domain/routing/p-success-classifier.js +350 -0
  124. package/dist/domain/routing/p-success-classifier.js.map +1 -0
  125. package/dist/domain/routing/tier-features.d.ts +70 -0
  126. package/dist/domain/routing/tier-features.d.ts.map +1 -0
  127. package/dist/domain/routing/tier-features.js +174 -0
  128. package/dist/domain/routing/tier-features.js.map +1 -0
  129. package/dist/domain/routing/tool-history-guard.d.ts +32 -0
  130. package/dist/domain/routing/tool-history-guard.d.ts.map +1 -0
  131. package/dist/domain/routing/tool-history-guard.js +110 -0
  132. package/dist/domain/routing/tool-history-guard.js.map +1 -0
  133. package/dist/domain/scoring/multi-objective.d.ts +48 -0
  134. package/dist/domain/scoring/multi-objective.d.ts.map +1 -0
  135. package/dist/domain/scoring/multi-objective.js +116 -0
  136. package/dist/domain/scoring/multi-objective.js.map +1 -0
  137. package/dist/domain/triage/triage-engine.d.ts +43 -0
  138. package/dist/domain/triage/triage-engine.d.ts.map +1 -0
  139. package/dist/domain/triage/triage-engine.js +317 -0
  140. package/dist/domain/triage/triage-engine.js.map +1 -0
  141. package/dist/domain/triage/turn-envelope.d.ts +17 -0
  142. package/dist/domain/triage/turn-envelope.d.ts.map +1 -0
  143. package/dist/domain/triage/turn-envelope.js +81 -0
  144. package/dist/domain/triage/turn-envelope.js.map +1 -0
  145. package/dist/domain/types/entities.d.ts +303 -0
  146. package/dist/domain/types/entities.d.ts.map +1 -0
  147. package/dist/domain/types/entities.js +6 -0
  148. package/dist/domain/types/entities.js.map +1 -0
  149. package/dist/domain/types/index.d.ts +4 -0
  150. package/dist/domain/types/index.d.ts.map +1 -0
  151. package/dist/domain/types/index.js +2 -0
  152. package/dist/domain/types/index.js.map +1 -0
  153. package/dist/domain/types/schemas.d.ts +346 -0
  154. package/dist/domain/types/schemas.d.ts.map +1 -0
  155. package/dist/domain/types/schemas.js +241 -0
  156. package/dist/domain/types/schemas.js.map +1 -0
  157. package/dist/domain/types/store-port.d.ts +44 -0
  158. package/dist/domain/types/store-port.d.ts.map +1 -0
  159. package/dist/domain/types/store-port.js +6 -0
  160. package/dist/domain/types/store-port.js.map +1 -0
  161. package/dist/index.d.ts +39 -0
  162. package/dist/index.d.ts.map +1 -0
  163. package/dist/index.js +36 -0
  164. package/dist/index.js.map +1 -0
  165. package/dist/infra/gemini-provider.d.ts +28 -0
  166. package/dist/infra/gemini-provider.d.ts.map +1 -0
  167. package/dist/infra/gemini-provider.js +112 -0
  168. package/dist/infra/gemini-provider.js.map +1 -0
  169. package/dist/infra/telemetry.d.ts +51 -0
  170. package/dist/infra/telemetry.d.ts.map +1 -0
  171. package/dist/infra/telemetry.js +100 -0
  172. package/dist/infra/telemetry.js.map +1 -0
  173. package/dist/infrastructure/delegation/provider-error.d.ts +44 -0
  174. package/dist/infrastructure/delegation/provider-error.d.ts.map +1 -0
  175. package/dist/infrastructure/delegation/provider-error.js +179 -0
  176. package/dist/infrastructure/delegation/provider-error.js.map +1 -0
  177. package/dist/infrastructure/gateway/circuit-breaker.d.ts +68 -0
  178. package/dist/infrastructure/gateway/circuit-breaker.d.ts.map +1 -0
  179. package/dist/infrastructure/gateway/circuit-breaker.js +150 -0
  180. package/dist/infrastructure/gateway/circuit-breaker.js.map +1 -0
  181. package/dist/infrastructure/gateway/gateway-dispatch.d.ts +138 -0
  182. package/dist/infrastructure/gateway/gateway-dispatch.d.ts.map +1 -0
  183. package/dist/infrastructure/gateway/gateway-dispatch.js +308 -0
  184. package/dist/infrastructure/gateway/gateway-dispatch.js.map +1 -0
  185. package/dist/infrastructure/hardware/hardware-probe.d.ts +32 -0
  186. package/dist/infrastructure/hardware/hardware-probe.d.ts.map +1 -0
  187. package/dist/infrastructure/hardware/hardware-probe.js +199 -0
  188. package/dist/infrastructure/hardware/hardware-probe.js.map +1 -0
  189. package/dist/infrastructure/local/local-zero-tier.d.ts +47 -0
  190. package/dist/infrastructure/local/local-zero-tier.d.ts.map +1 -0
  191. package/dist/infrastructure/local/local-zero-tier.js +92 -0
  192. package/dist/infrastructure/local/local-zero-tier.js.map +1 -0
  193. package/dist/infrastructure/persistence/memory-store.d.ts +31 -0
  194. package/dist/infrastructure/persistence/memory-store.d.ts.map +1 -0
  195. package/dist/infrastructure/persistence/memory-store.js +87 -0
  196. package/dist/infrastructure/persistence/memory-store.js.map +1 -0
  197. package/dist/infrastructure/persistence/sqlite-store.d.ts +81 -0
  198. package/dist/infrastructure/persistence/sqlite-store.d.ts.map +1 -0
  199. package/dist/infrastructure/persistence/sqlite-store.js +658 -0
  200. package/dist/infrastructure/persistence/sqlite-store.js.map +1 -0
  201. package/dist/infrastructure/pricing/litellm-fetch.d.ts +46 -0
  202. package/dist/infrastructure/pricing/litellm-fetch.d.ts.map +1 -0
  203. package/dist/infrastructure/pricing/litellm-fetch.js +145 -0
  204. package/dist/infrastructure/pricing/litellm-fetch.js.map +1 -0
  205. package/dist/infrastructure/pricing/price-broker.d.ts +56 -0
  206. package/dist/infrastructure/pricing/price-broker.d.ts.map +1 -0
  207. package/dist/infrastructure/pricing/price-broker.js +133 -0
  208. package/dist/infrastructure/pricing/price-broker.js.map +1 -0
  209. package/dist/infrastructure/pricing/pricing-monitor.d.ts +27 -0
  210. package/dist/infrastructure/pricing/pricing-monitor.d.ts.map +1 -0
  211. package/dist/infrastructure/pricing/pricing-monitor.js +46 -0
  212. package/dist/infrastructure/pricing/pricing-monitor.js.map +1 -0
  213. package/dist/infrastructure/telemetry/dataset-limits.d.ts +13 -0
  214. package/dist/infrastructure/telemetry/dataset-limits.d.ts.map +1 -0
  215. package/dist/infrastructure/telemetry/dataset-limits.js +28 -0
  216. package/dist/infrastructure/telemetry/dataset-limits.js.map +1 -0
  217. package/dist/infrastructure/telemetry/dataset-recorder.d.ts +48 -0
  218. package/dist/infrastructure/telemetry/dataset-recorder.d.ts.map +1 -0
  219. package/dist/infrastructure/telemetry/dataset-recorder.js +154 -0
  220. package/dist/infrastructure/telemetry/dataset-recorder.js.map +1 -0
  221. package/dist/infrastructure/telemetry/outcome-limits.d.ts +12 -0
  222. package/dist/infrastructure/telemetry/outcome-limits.d.ts.map +1 -0
  223. package/dist/infrastructure/telemetry/outcome-limits.js +28 -0
  224. package/dist/infrastructure/telemetry/outcome-limits.js.map +1 -0
  225. package/dist/infrastructure/telemetry/outcome-recorder.d.ts +29 -0
  226. package/dist/infrastructure/telemetry/outcome-recorder.d.ts.map +1 -0
  227. package/dist/infrastructure/telemetry/outcome-recorder.js +49 -0
  228. package/dist/infrastructure/telemetry/outcome-recorder.js.map +1 -0
  229. package/dist/infrastructure/telemetry/routing-telemetry.d.ts +115 -0
  230. package/dist/infrastructure/telemetry/routing-telemetry.d.ts.map +1 -0
  231. package/dist/infrastructure/telemetry/routing-telemetry.js +529 -0
  232. package/dist/infrastructure/telemetry/routing-telemetry.js.map +1 -0
  233. package/dist/infrastructure/telemetry/telemetry-limits.d.ts +16 -0
  234. package/dist/infrastructure/telemetry/telemetry-limits.d.ts.map +1 -0
  235. package/dist/infrastructure/telemetry/telemetry-limits.js +35 -0
  236. package/dist/infrastructure/telemetry/telemetry-limits.js.map +1 -0
  237. package/package.json +110 -0
  238. package/skills/router-backlog-orchestrator/SKILL.md +183 -0
  239. package/skills/router-backlog-orchestrator/references/github-router-issue-template.md +78 -0
  240. package/skills/router-backlog-orchestrator/references/packet-from-issue.md +99 -0
  241. package/skills/router-backlog-orchestrator/references/prioritization-rubric.md +65 -0
  242. package/skills/router-backlog-orchestrator/scripts/collect-backlog.sh +44 -0
  243. package/specs/001-build-smart-router/contracts/telemetry-contrib.schema.json +151 -0
  244. package/src/api/explain/.gitkeep +0 -0
  245. package/src/api/explain/router-explain.ts +146 -0
  246. package/src/api/middleware/.gitkeep +0 -0
  247. package/src/api/middleware/pi-router-middleware.ts +169 -0
  248. package/src/cli/smart-router-cli.ts +436 -0
  249. package/src/config/.gitkeep +0 -0
  250. package/src/config/defaults.ts +35 -0
  251. package/src/config/models-loader.ts +68 -0
  252. package/src/config/pi-model-mapper.ts +285 -0
  253. package/src/config/routing-clusters-loader.ts +148 -0
  254. package/src/domain/delegation/delegation-context.ts +111 -0
  255. package/src/domain/delegation/execution-ledger.ts +34 -0
  256. package/src/domain/delegation/output-headroom.ts +131 -0
  257. package/src/domain/matching/.gitkeep +0 -0
  258. package/src/domain/matching/cluster-matcher.ts +474 -0
  259. package/src/domain/matching/embedding-provider.ts +79 -0
  260. package/src/domain/matching/hydra-input.ts +53 -0
  261. package/src/domain/matching/hydra-matcher.ts +454 -0
  262. package/src/domain/pinning/.gitkeep +0 -0
  263. package/src/domain/pinning/cache-economics.ts +128 -0
  264. package/src/domain/pinning/loop-escalation.ts +181 -0
  265. package/src/domain/pinning/session-pinner.ts +388 -0
  266. package/src/domain/pinning/sub-route-policy.ts +119 -0
  267. package/src/domain/pipeline/.gitkeep +0 -0
  268. package/src/domain/pipeline/router-pipeline.ts +1139 -0
  269. package/src/domain/pipeline/safe-default.ts +70 -0
  270. package/src/domain/refactor-guardrails.ts +202 -0
  271. package/src/domain/routing/context-fit.ts +221 -0
  272. package/src/domain/routing/expected-cost.ts +320 -0
  273. package/src/domain/routing/p-success-classifier.ts +511 -0
  274. package/src/domain/routing/tier-features.ts +290 -0
  275. package/src/domain/routing/tool-history-guard.ts +159 -0
  276. package/src/domain/scoring/.gitkeep +0 -0
  277. package/src/domain/scoring/multi-objective.ts +175 -0
  278. package/src/domain/triage/.gitkeep +0 -0
  279. package/src/domain/triage/triage-engine.ts +373 -0
  280. package/src/domain/triage/turn-envelope.ts +104 -0
  281. package/src/domain/types/.gitkeep +0 -0
  282. package/src/domain/types/entities.ts +384 -0
  283. package/src/domain/types/index.ts +41 -0
  284. package/src/domain/types/schemas.ts +289 -0
  285. package/src/domain/types/store-port.ts +59 -0
  286. package/src/index.ts +103 -0
  287. package/src/infra/gemini-provider.ts +142 -0
  288. package/src/infra/telemetry.ts +169 -0
  289. package/src/infrastructure/delegation/provider-error.ts +251 -0
  290. package/src/infrastructure/gateway/.gitkeep +0 -0
  291. package/src/infrastructure/gateway/circuit-breaker.ts +196 -0
  292. package/src/infrastructure/gateway/gateway-dispatch.ts +444 -0
  293. package/src/infrastructure/hardware/.gitkeep +0 -0
  294. package/src/infrastructure/hardware/hardware-probe.ts +276 -0
  295. package/src/infrastructure/local/.gitkeep +0 -0
  296. package/src/infrastructure/local/local-zero-tier.ts +151 -0
  297. package/src/infrastructure/persistence/.gitkeep +0 -0
  298. package/src/infrastructure/persistence/memory-store.ts +122 -0
  299. package/src/infrastructure/persistence/sqlite-store.ts +900 -0
  300. package/src/infrastructure/pricing/.gitkeep +0 -0
  301. package/src/infrastructure/pricing/litellm-fetch.ts +215 -0
  302. package/src/infrastructure/pricing/price-broker.ts +183 -0
  303. package/src/infrastructure/pricing/pricing-monitor.ts +65 -0
  304. package/src/infrastructure/telemetry/.gitkeep +0 -0
  305. package/src/infrastructure/telemetry/dataset-limits.ts +39 -0
  306. package/src/infrastructure/telemetry/dataset-recorder.ts +215 -0
  307. package/src/infrastructure/telemetry/outcome-limits.ts +42 -0
  308. package/src/infrastructure/telemetry/outcome-recorder.ts +118 -0
  309. package/src/infrastructure/telemetry/routing-telemetry.ts +824 -0
  310. package/src/infrastructure/telemetry/telemetry-limits.ts +50 -0
@@ -0,0 +1,346 @@
1
+ /**
2
+ * Zod schemas mirroring JSON-schema contracts and data-model entities.
3
+ *
4
+ * Canonical contract sources:
5
+ * - specs/001-build-smart-router/contracts/routing-request.schema.json
6
+ * - specs/001-build-smart-router/contracts/routing-decision.schema.json
7
+ * - specs/001-build-smart-router/data-model.md
8
+ */
9
+ import { z } from 'zod';
10
+ export declare const TurnTypeSchema: z.ZodEnum<{
11
+ planning: "planning";
12
+ tool_result: "tool_result";
13
+ subagent: "subagent";
14
+ main_loop: "main_loop";
15
+ unknown: "unknown";
16
+ }>;
17
+ export declare const PinReasonSchema: z.ZodEnum<{
18
+ initial: "initial";
19
+ user_forced: "user_forced";
20
+ loop_escalation: "loop_escalation";
21
+ compaction: "compaction";
22
+ cache_economics: "cache_economics";
23
+ context_overflow: "context_overflow";
24
+ }>;
25
+ export declare const TierSchema: z.ZodEnum<{
26
+ "zero-tier": "zero-tier";
27
+ "economical-cloud": "economical-cloud";
28
+ "frontier-cloud": "frontier-cloud";
29
+ }>;
30
+ export declare const RoutingStageSchema: z.ZodEnum<{
31
+ triage: "triage";
32
+ turn_envelope: "turn_envelope";
33
+ session_pin: "session_pin";
34
+ local_zero: "local_zero";
35
+ hydra_match: "hydra_match";
36
+ fallback: "fallback";
37
+ }>;
38
+ export declare const PriceSourceSchema: z.ZodEnum<{
39
+ override: "override";
40
+ registry: "registry";
41
+ yaml_fallback: "yaml_fallback";
42
+ }>;
43
+ export declare const MessageRoleSchema: z.ZodEnum<{
44
+ user: "user";
45
+ assistant: "assistant";
46
+ system: "system";
47
+ tool: "tool";
48
+ }>;
49
+ export declare const MessageSchema: z.ZodObject<{
50
+ role: z.ZodEnum<{
51
+ user: "user";
52
+ assistant: "assistant";
53
+ system: "system";
54
+ tool: "tool";
55
+ }>;
56
+ content: z.ZodString;
57
+ tool_call_id: z.ZodOptional<z.ZodString>;
58
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
59
+ }, z.core.$strip>;
60
+ export declare const RoutingRequestSchema: z.ZodObject<{
61
+ request_id: z.ZodString;
62
+ session_id: z.ZodString;
63
+ prompt_text: z.ZodString;
64
+ messages: z.ZodOptional<z.ZodArray<z.ZodObject<{
65
+ role: z.ZodEnum<{
66
+ user: "user";
67
+ assistant: "assistant";
68
+ system: "system";
69
+ tool: "tool";
70
+ }>;
71
+ content: z.ZodString;
72
+ tool_call_id: z.ZodOptional<z.ZodString>;
73
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
74
+ }, z.core.$strip>>>;
75
+ turn_type: z.ZodOptional<z.ZodEnum<{
76
+ planning: "planning";
77
+ tool_result: "tool_result";
78
+ subagent: "subagent";
79
+ main_loop: "main_loop";
80
+ unknown: "unknown";
81
+ }>>;
82
+ compaction_flag: z.ZodOptional<z.ZodBoolean>;
83
+ force_model_id: z.ZodOptional<z.ZodString>;
84
+ candidate_model_id: z.ZodOptional<z.ZodString>;
85
+ estimated_input_tokens: z.ZodOptional<z.ZodNumber>;
86
+ }, z.core.$strip>;
87
+ export declare const SessionPinSchema: z.ZodObject<{
88
+ session_id: z.ZodString;
89
+ pinned_model_id: z.ZodString;
90
+ pin_reason: z.ZodEnum<{
91
+ initial: "initial";
92
+ user_forced: "user_forced";
93
+ loop_escalation: "loop_escalation";
94
+ compaction: "compaction";
95
+ cache_economics: "cache_economics";
96
+ context_overflow: "context_overflow";
97
+ }>;
98
+ has_ever_switched: z.ZodBoolean;
99
+ consecutive_upstream_errors: z.ZodNumber;
100
+ consecutive_tool_failures: z.ZodNumber;
101
+ last_tool_failure_signature: z.ZodNullable<z.ZodString>;
102
+ created_at: z.ZodString;
103
+ updated_at: z.ZodString;
104
+ }, z.core.$strip>;
105
+ export declare const ModelCapabilitiesSchema: z.ZodObject<{
106
+ reasoning: z.ZodNumber;
107
+ code_gen: z.ZodNumber;
108
+ tool_use: z.ZodNumber;
109
+ }, z.core.$strip>;
110
+ export declare const ModelPerformanceSchema: z.ZodObject<{
111
+ latency_p50_ms: z.ZodOptional<z.ZodNumber>;
112
+ verbosity_factor: z.ZodOptional<z.ZodNumber>;
113
+ cache_friendly: z.ZodOptional<z.ZodBoolean>;
114
+ }, z.core.$strip>;
115
+ export declare const ModelPricingSchema: z.ZodObject<{
116
+ registry_key: z.ZodOptional<z.ZodString>;
117
+ fallback_cost_per_1m: z.ZodNumber;
118
+ }, z.core.$strip>;
119
+ export declare const ModelLimitsSchema: z.ZodObject<{
120
+ max_input_tokens: z.ZodOptional<z.ZodNumber>;
121
+ max_output_tokens: z.ZodOptional<z.ZodNumber>;
122
+ }, z.core.$strip>;
123
+ export declare const ModelProfileSchema: z.ZodObject<{
124
+ id: z.ZodString;
125
+ tier: z.ZodEnum<{
126
+ "zero-tier": "zero-tier";
127
+ "economical-cloud": "economical-cloud";
128
+ "frontier-cloud": "frontier-cloud";
129
+ }>;
130
+ provider: z.ZodString;
131
+ endpoint: z.ZodOptional<z.ZodString>;
132
+ capabilities: z.ZodObject<{
133
+ reasoning: z.ZodNumber;
134
+ code_gen: z.ZodNumber;
135
+ tool_use: z.ZodNumber;
136
+ }, z.core.$strip>;
137
+ performance: z.ZodOptional<z.ZodObject<{
138
+ latency_p50_ms: z.ZodOptional<z.ZodNumber>;
139
+ verbosity_factor: z.ZodOptional<z.ZodNumber>;
140
+ cache_friendly: z.ZodOptional<z.ZodBoolean>;
141
+ }, z.core.$strip>>;
142
+ pricing: z.ZodObject<{
143
+ registry_key: z.ZodOptional<z.ZodString>;
144
+ fallback_cost_per_1m: z.ZodNumber;
145
+ }, z.core.$strip>;
146
+ limits: z.ZodOptional<z.ZodObject<{
147
+ max_input_tokens: z.ZodOptional<z.ZodNumber>;
148
+ max_output_tokens: z.ZodOptional<z.ZodNumber>;
149
+ }, z.core.$strip>>;
150
+ healthy: z.ZodOptional<z.ZodBoolean>;
151
+ }, z.core.$strip>;
152
+ /** Zod-validated model profile — aligned with {@link ModelProfile} in entities.ts. */
153
+ export type ValidatedModelProfile = z.infer<typeof ModelProfileSchema>;
154
+ export declare const CandidateScoreSchema: z.ZodObject<{
155
+ model_id: z.ZodString;
156
+ score: z.ZodNumber;
157
+ shortfall: z.ZodNumber;
158
+ rejected_reason: z.ZodNullable<z.ZodString>;
159
+ }, z.core.$strip>;
160
+ export declare const RoutingDecisionSchema: z.ZodObject<{
161
+ request_id: z.ZodString;
162
+ selected_model_id: z.ZodString;
163
+ tier: z.ZodEnum<{
164
+ "zero-tier": "zero-tier";
165
+ "economical-cloud": "economical-cloud";
166
+ "frontier-cloud": "frontier-cloud";
167
+ }>;
168
+ stage: z.ZodEnum<{
169
+ triage: "triage";
170
+ turn_envelope: "turn_envelope";
171
+ session_pin: "session_pin";
172
+ local_zero: "local_zero";
173
+ hydra_match: "hydra_match";
174
+ fallback: "fallback";
175
+ }>;
176
+ reason_code: z.ZodString;
177
+ candidates: z.ZodOptional<z.ZodArray<z.ZodObject<{
178
+ model_id: z.ZodString;
179
+ score: z.ZodNumber;
180
+ shortfall: z.ZodNumber;
181
+ rejected_reason: z.ZodNullable<z.ZodString>;
182
+ }, z.core.$strip>>>;
183
+ estimated_cost_usd: z.ZodOptional<z.ZodNumber>;
184
+ routing_latency_ms: z.ZodNumber;
185
+ pin_reason: z.ZodNullable<z.ZodEnum<{
186
+ initial: "initial";
187
+ user_forced: "user_forced";
188
+ loop_escalation: "loop_escalation";
189
+ compaction: "compaction";
190
+ cache_economics: "cache_economics";
191
+ context_overflow: "context_overflow";
192
+ }>>;
193
+ }, z.core.$strip>;
194
+ export declare const PriceCatalogSchema: z.ZodObject<{
195
+ registry_snapshot: z.ZodRecord<z.ZodString, z.ZodNumber>;
196
+ registry_limits_snapshot: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
197
+ max_input_tokens: z.ZodOptional<z.ZodNumber>;
198
+ max_output_tokens: z.ZodOptional<z.ZodNumber>;
199
+ }, z.core.$strip>>>;
200
+ user_overrides: z.ZodRecord<z.ZodString, z.ZodNumber>;
201
+ last_updated: z.ZodString;
202
+ source: z.ZodEnum<{
203
+ override: "override";
204
+ registry: "registry";
205
+ yaml_fallback: "yaml_fallback";
206
+ }>;
207
+ }, z.core.$strip>;
208
+ export declare const RoutingTelemetrySchema: z.ZodObject<{
209
+ timestamp: z.ZodString;
210
+ session_id: z.ZodString;
211
+ request_id: z.ZodString;
212
+ turn_type: z.ZodString;
213
+ stage: z.ZodString;
214
+ reason_code: z.ZodString;
215
+ selected_model_id: z.ZodString;
216
+ estimated_cost_usd: z.ZodNumber;
217
+ routing_latency_ms: z.ZodNumber;
218
+ pin_reason: z.ZodNullable<z.ZodString>;
219
+ }, z.core.$strip>;
220
+ export declare const FrugalityConfigSchema: z.ZodObject<{
221
+ lambda_cost: z.ZodNumber;
222
+ lambda_latency: z.ZodNumber;
223
+ lambda_verbosity: z.ZodNumber;
224
+ }, z.core.$strip>;
225
+ export declare const LoopEscalationConfigSchema: z.ZodObject<{
226
+ threshold: z.ZodNumber;
227
+ }, z.core.$strip>;
228
+ export declare const PricingConfigSchema: z.ZodObject<{
229
+ staleness_days: z.ZodNumber;
230
+ }, z.core.$strip>;
231
+ export declare const LocalConfigSchema: z.ZodObject<{
232
+ min_memory_gb_full: z.ZodNumber;
233
+ min_memory_gb_classification: z.ZodNumber;
234
+ battery_threshold_pct: z.ZodNumber;
235
+ }, z.core.$strip>;
236
+ export declare const HydraConfigSchema: z.ZodObject<{
237
+ artifact_cache_path: z.ZodString;
238
+ }, z.core.$strip>;
239
+ export declare const LowIntensityWeightsSchema: z.ZodObject<{
240
+ prompt_shortness: z.ZodNumber;
241
+ token_shortness: z.ZodNumber;
242
+ cyclomatic_low: z.ZodNumber;
243
+ trivial_signal: z.ZodNumber;
244
+ complex_inverse: z.ZodNumber;
245
+ triage_verdict: z.ZodNumber;
246
+ turn_type: z.ZodNumber;
247
+ no_tool_context: z.ZodNumber;
248
+ message_shallow: z.ZodNumber;
249
+ prose_ratio: z.ZodNumber;
250
+ requirement_low: z.ZodNumber;
251
+ cluster_signal: z.ZodNumber;
252
+ }, z.core.$strip>;
253
+ export declare const LowIntensityConfigSchema: z.ZodObject<{
254
+ weights: z.ZodObject<{
255
+ prompt_shortness: z.ZodNumber;
256
+ token_shortness: z.ZodNumber;
257
+ cyclomatic_low: z.ZodNumber;
258
+ trivial_signal: z.ZodNumber;
259
+ complex_inverse: z.ZodNumber;
260
+ triage_verdict: z.ZodNumber;
261
+ turn_type: z.ZodNumber;
262
+ no_tool_context: z.ZodNumber;
263
+ message_shallow: z.ZodNumber;
264
+ prose_ratio: z.ZodNumber;
265
+ requirement_low: z.ZodNumber;
266
+ cluster_signal: z.ZodNumber;
267
+ }, z.core.$strip>;
268
+ high_threshold: z.ZodNumber;
269
+ low_threshold: z.ZodNumber;
270
+ p_success_alpha: z.ZodNumber;
271
+ }, z.core.$strip>;
272
+ export declare const RoutingClustersConfigSchema: z.ZodObject<{
273
+ config_path: z.ZodString;
274
+ }, z.core.$strip>;
275
+ /** Stable snake_case cluster id — used as reason-code suffix (`cluster_${id}`). */
276
+ export declare const RoutingClusterIdSchema: z.ZodString;
277
+ export declare const RoutingClusterSchema: z.ZodObject<{
278
+ id: z.ZodString;
279
+ tier_bias: z.ZodEnum<{
280
+ "zero-tier": "zero-tier";
281
+ "economical-cloud": "economical-cloud";
282
+ "frontier-cloud": "frontier-cloud";
283
+ }>;
284
+ reference_prompts: z.ZodArray<z.ZodString>;
285
+ min_similarity: z.ZodNumber;
286
+ min_margin: z.ZodNumber;
287
+ }, z.core.$strip>;
288
+ export declare const RoutingClustersFileSchema: z.ZodObject<{
289
+ clusters: z.ZodArray<z.ZodObject<{
290
+ id: z.ZodString;
291
+ tier_bias: z.ZodEnum<{
292
+ "zero-tier": "zero-tier";
293
+ "economical-cloud": "economical-cloud";
294
+ "frontier-cloud": "frontier-cloud";
295
+ }>;
296
+ reference_prompts: z.ZodArray<z.ZodString>;
297
+ min_similarity: z.ZodNumber;
298
+ min_margin: z.ZodNumber;
299
+ }, z.core.$strip>>;
300
+ }, z.core.$strip>;
301
+ export declare const OperatorConfigSchema: z.ZodObject<{
302
+ frugality: z.ZodObject<{
303
+ lambda_cost: z.ZodNumber;
304
+ lambda_latency: z.ZodNumber;
305
+ lambda_verbosity: z.ZodNumber;
306
+ }, z.core.$strip>;
307
+ loop_escalation: z.ZodObject<{
308
+ threshold: z.ZodNumber;
309
+ }, z.core.$strip>;
310
+ pricing: z.ZodObject<{
311
+ staleness_days: z.ZodNumber;
312
+ }, z.core.$strip>;
313
+ local: z.ZodObject<{
314
+ min_memory_gb_full: z.ZodNumber;
315
+ min_memory_gb_classification: z.ZodNumber;
316
+ battery_threshold_pct: z.ZodNumber;
317
+ }, z.core.$strip>;
318
+ hydra: z.ZodObject<{
319
+ artifact_cache_path: z.ZodString;
320
+ }, z.core.$strip>;
321
+ low_intensity: z.ZodObject<{
322
+ weights: z.ZodObject<{
323
+ prompt_shortness: z.ZodNumber;
324
+ token_shortness: z.ZodNumber;
325
+ cyclomatic_low: z.ZodNumber;
326
+ trivial_signal: z.ZodNumber;
327
+ complex_inverse: z.ZodNumber;
328
+ triage_verdict: z.ZodNumber;
329
+ turn_type: z.ZodNumber;
330
+ no_tool_context: z.ZodNumber;
331
+ message_shallow: z.ZodNumber;
332
+ prose_ratio: z.ZodNumber;
333
+ requirement_low: z.ZodNumber;
334
+ cluster_signal: z.ZodNumber;
335
+ }, z.core.$strip>;
336
+ high_threshold: z.ZodNumber;
337
+ low_threshold: z.ZodNumber;
338
+ p_success_alpha: z.ZodNumber;
339
+ }, z.core.$strip>;
340
+ routing_clusters: z.ZodOptional<z.ZodObject<{
341
+ config_path: z.ZodString;
342
+ }, z.core.$strip>>;
343
+ }, z.core.$strip>;
344
+ export type OperatorConfig = z.infer<typeof OperatorConfigSchema>;
345
+ export type LowIntensityConfig = z.infer<typeof LowIntensityConfigSchema>;
346
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/domain/types/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,cAAc;;;;;;EAMzB,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;EAO1B,CAAC;AAEH,eAAO,MAAM,UAAU;;;;EAIrB,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;EAO7B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;EAI5B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;EAK5B,CAAC;AAIH,eAAO,MAAM,aAAa;;;;;;;;;;iBAKxB,CAAC;AAIH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;iBAU/B,CAAC;AAIH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;iBAU3B,CAAC;AAIH,eAAO,MAAM,uBAAuB;;;;iBAIlC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;iBAIjC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;iBAG7B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;iBAG5B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAU7B,CAAC;AAEH,sFAAsF;AACtF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAIvE,eAAO,MAAM,oBAAoB;;;;;iBAK/B,CAAC;AAIH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAUhC,CAAC;AAIH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;iBAM7B,CAAC;AAIH,eAAO,MAAM,sBAAsB;;;;;;;;;;;iBAWjC,CAAC;AAIH,eAAO,MAAM,qBAAqB;;;;iBAIhC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;iBAErC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;iBAE9B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;iBAI5B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;iBAE5B,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;iBAapC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;iBAcnC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;iBAEtC,CAAC;AAEH,mFAAmF;AACnF,eAAO,MAAM,sBAAsB,aAGqC,CAAC;AAEzE,eAAO,MAAM,oBAAoB;;;;;;;;;;iBAM/B,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;iBAgBlC,CAAC;AAEL,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQ/B,CAAC;AAIH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
@@ -0,0 +1,241 @@
1
+ /**
2
+ * Zod schemas mirroring JSON-schema contracts and data-model entities.
3
+ *
4
+ * Canonical contract sources:
5
+ * - specs/001-build-smart-router/contracts/routing-request.schema.json
6
+ * - specs/001-build-smart-router/contracts/routing-decision.schema.json
7
+ * - specs/001-build-smart-router/data-model.md
8
+ */
9
+ import { z } from 'zod';
10
+ // ─── Enum schemas ────────────────────────────────────────────────────────────
11
+ export const TurnTypeSchema = z.enum([
12
+ 'planning',
13
+ 'tool_result',
14
+ 'subagent',
15
+ 'main_loop',
16
+ 'unknown',
17
+ ]);
18
+ export const PinReasonSchema = z.enum([
19
+ 'initial',
20
+ 'user_forced',
21
+ 'loop_escalation',
22
+ 'compaction',
23
+ 'cache_economics',
24
+ 'context_overflow',
25
+ ]);
26
+ export const TierSchema = z.enum([
27
+ 'zero-tier',
28
+ 'economical-cloud',
29
+ 'frontier-cloud',
30
+ ]);
31
+ export const RoutingStageSchema = z.enum([
32
+ 'triage',
33
+ 'turn_envelope',
34
+ 'session_pin',
35
+ 'local_zero',
36
+ 'hydra_match',
37
+ 'fallback',
38
+ ]);
39
+ export const PriceSourceSchema = z.enum([
40
+ 'override',
41
+ 'registry',
42
+ 'yaml_fallback',
43
+ ]);
44
+ export const MessageRoleSchema = z.enum([
45
+ 'user',
46
+ 'assistant',
47
+ 'system',
48
+ 'tool',
49
+ ]);
50
+ // ─── Message (contract: routing-request.schema.json) ─────────────────────────
51
+ export const MessageSchema = z.object({
52
+ role: MessageRoleSchema,
53
+ content: z.string(),
54
+ tool_call_id: z.string().optional(),
55
+ tool_calls: z.array(z.unknown()).optional(),
56
+ });
57
+ // ─── RoutingRequest (contract: routing-request.schema.json) ──────────────────
58
+ export const RoutingRequestSchema = z.object({
59
+ request_id: z.string().uuid(),
60
+ session_id: z.string().min(1),
61
+ prompt_text: z.string(),
62
+ messages: z.array(MessageSchema).optional(),
63
+ turn_type: TurnTypeSchema.optional(),
64
+ compaction_flag: z.boolean().optional(),
65
+ force_model_id: z.string().optional(),
66
+ candidate_model_id: z.string().optional(),
67
+ estimated_input_tokens: z.number().int().nonnegative().optional(),
68
+ });
69
+ // ─── SessionPin (data-model.md) ──────────────────────────────────────────────
70
+ export const SessionPinSchema = z.object({
71
+ session_id: z.string(),
72
+ pinned_model_id: z.string(),
73
+ pin_reason: PinReasonSchema,
74
+ has_ever_switched: z.boolean(),
75
+ consecutive_upstream_errors: z.number().int().nonnegative(),
76
+ consecutive_tool_failures: z.number().int().nonnegative(),
77
+ last_tool_failure_signature: z.string().nullable(),
78
+ created_at: z.string().datetime(),
79
+ updated_at: z.string().datetime(),
80
+ });
81
+ // ─── ModelProfile (data-model.md) ────────────────────────────────────────────
82
+ export const ModelCapabilitiesSchema = z.object({
83
+ reasoning: z.number().min(0).max(1),
84
+ code_gen: z.number().min(0).max(1),
85
+ tool_use: z.number().min(0).max(1),
86
+ });
87
+ export const ModelPerformanceSchema = z.object({
88
+ latency_p50_ms: z.number().optional(),
89
+ verbosity_factor: z.number().optional(),
90
+ cache_friendly: z.boolean().optional(),
91
+ });
92
+ export const ModelPricingSchema = z.object({
93
+ registry_key: z.string().optional(),
94
+ fallback_cost_per_1m: z.number(),
95
+ });
96
+ export const ModelLimitsSchema = z.object({
97
+ max_input_tokens: z.number().int().positive().optional(),
98
+ max_output_tokens: z.number().int().positive().optional(),
99
+ });
100
+ export const ModelProfileSchema = z.object({
101
+ id: z.string(),
102
+ tier: TierSchema,
103
+ provider: z.string(),
104
+ endpoint: z.string().optional(),
105
+ capabilities: ModelCapabilitiesSchema,
106
+ performance: ModelPerformanceSchema.optional(),
107
+ pricing: ModelPricingSchema,
108
+ limits: ModelLimitsSchema.optional(),
109
+ healthy: z.boolean().optional(),
110
+ });
111
+ // ─── CandidateScore (contract: routing-decision.schema.json) ─────────────────
112
+ export const CandidateScoreSchema = z.object({
113
+ model_id: z.string(),
114
+ score: z.number(),
115
+ shortfall: z.number(),
116
+ rejected_reason: z.string().nullable(),
117
+ });
118
+ // ─── RoutingDecision (contract: routing-decision.schema.json) ────────────────
119
+ export const RoutingDecisionSchema = z.object({
120
+ request_id: z.string().uuid(),
121
+ selected_model_id: z.string(),
122
+ tier: TierSchema,
123
+ stage: RoutingStageSchema,
124
+ reason_code: z.string(),
125
+ candidates: z.array(CandidateScoreSchema).optional(),
126
+ estimated_cost_usd: z.number().nonnegative().optional(),
127
+ routing_latency_ms: z.number().nonnegative(),
128
+ pin_reason: PinReasonSchema.nullable(),
129
+ });
130
+ // ─── PriceCatalog (data-model.md) ────────────────────────────────────────────
131
+ export const PriceCatalogSchema = z.object({
132
+ registry_snapshot: z.record(z.string(), z.number()),
133
+ registry_limits_snapshot: z.record(z.string(), ModelLimitsSchema).optional(),
134
+ user_overrides: z.record(z.string(), z.number()),
135
+ last_updated: z.string().datetime(),
136
+ source: PriceSourceSchema,
137
+ });
138
+ // ─── RoutingTelemetry (data-model.md) ────────────────────────────────────────
139
+ export const RoutingTelemetrySchema = z.object({
140
+ timestamp: z.string().datetime(),
141
+ session_id: z.string(),
142
+ request_id: z.string(),
143
+ turn_type: z.string(),
144
+ stage: z.string(),
145
+ reason_code: z.string(),
146
+ selected_model_id: z.string(),
147
+ estimated_cost_usd: z.number(),
148
+ routing_latency_ms: z.number(),
149
+ pin_reason: z.string().nullable(),
150
+ });
151
+ // ─── Operator configuration schema (data-model.md § Configuration) ───────────
152
+ export const FrugalityConfigSchema = z.object({
153
+ lambda_cost: z.number().min(0).max(1),
154
+ lambda_latency: z.number().min(0),
155
+ lambda_verbosity: z.number().min(0),
156
+ });
157
+ export const LoopEscalationConfigSchema = z.object({
158
+ threshold: z.number().int().positive(),
159
+ });
160
+ export const PricingConfigSchema = z.object({
161
+ staleness_days: z.number().int().positive(),
162
+ });
163
+ export const LocalConfigSchema = z.object({
164
+ min_memory_gb_full: z.number().positive(),
165
+ min_memory_gb_classification: z.number().positive(),
166
+ battery_threshold_pct: z.number().min(0).max(100),
167
+ });
168
+ export const HydraConfigSchema = z.object({
169
+ artifact_cache_path: z.string(),
170
+ });
171
+ export const LowIntensityWeightsSchema = z.object({
172
+ prompt_shortness: z.number().min(0),
173
+ token_shortness: z.number().min(0),
174
+ cyclomatic_low: z.number().min(0),
175
+ trivial_signal: z.number().min(0),
176
+ complex_inverse: z.number().min(0),
177
+ triage_verdict: z.number().min(0),
178
+ turn_type: z.number().min(0),
179
+ no_tool_context: z.number().min(0),
180
+ message_shallow: z.number().min(0),
181
+ prose_ratio: z.number().min(0),
182
+ requirement_low: z.number().min(0),
183
+ cluster_signal: z.number().min(0),
184
+ });
185
+ export const LowIntensityConfigSchema = z.object({
186
+ weights: LowIntensityWeightsSchema,
187
+ high_threshold: z.number().min(0).max(1),
188
+ low_threshold: z.number().min(0).max(1),
189
+ /** Minimum P_success_cheap to bias toward economical/local tier (SP-105). */
190
+ p_success_alpha: z.number().min(0).max(1),
191
+ }).superRefine((value, ctx) => {
192
+ if (value.high_threshold <= value.low_threshold) {
193
+ ctx.addIssue({
194
+ code: z.ZodIssueCode.custom,
195
+ message: 'high_threshold must be greater than low_threshold',
196
+ path: ['high_threshold'],
197
+ });
198
+ }
199
+ });
200
+ export const RoutingClustersConfigSchema = z.object({
201
+ config_path: z.string().min(1),
202
+ });
203
+ /** Stable snake_case cluster id — used as reason-code suffix (`cluster_${id}`). */
204
+ export const RoutingClusterIdSchema = z
205
+ .string()
206
+ .min(1)
207
+ .regex(/^[a-z][a-z0-9_]*$/, 'Cluster id must be lowercase snake_case');
208
+ export const RoutingClusterSchema = z.object({
209
+ id: RoutingClusterIdSchema,
210
+ tier_bias: TierSchema,
211
+ reference_prompts: z.array(z.string().min(1)).min(1),
212
+ min_similarity: z.number().min(0).max(1),
213
+ min_margin: z.number().min(0).max(1),
214
+ });
215
+ export const RoutingClustersFileSchema = z
216
+ .object({
217
+ clusters: z.array(RoutingClusterSchema).min(1),
218
+ })
219
+ .superRefine((value, ctx) => {
220
+ const seen = new Set();
221
+ for (const [index, cluster] of value.clusters.entries()) {
222
+ if (seen.has(cluster.id)) {
223
+ ctx.addIssue({
224
+ code: z.ZodIssueCode.custom,
225
+ message: `Duplicate cluster id: ${cluster.id}`,
226
+ path: ['clusters', index, 'id'],
227
+ });
228
+ }
229
+ seen.add(cluster.id);
230
+ }
231
+ });
232
+ export const OperatorConfigSchema = z.object({
233
+ frugality: FrugalityConfigSchema,
234
+ loop_escalation: LoopEscalationConfigSchema,
235
+ pricing: PricingConfigSchema,
236
+ local: LocalConfigSchema,
237
+ hydra: HydraConfigSchema,
238
+ low_intensity: LowIntensityConfigSchema,
239
+ routing_clusters: RoutingClustersConfigSchema.optional(),
240
+ });
241
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/domain/types/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gFAAgF;AAEhF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC;IACnC,UAAU;IACV,aAAa;IACb,UAAU;IACV,WAAW;IACX,SAAS;CACV,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC;IACpC,SAAS;IACT,aAAa;IACb,iBAAiB;IACjB,YAAY;IACZ,iBAAiB;IACjB,kBAAkB;CACnB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC;IAC/B,WAAW;IACX,kBAAkB;IAClB,gBAAgB;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,IAAI,CAAC;IACvC,QAAQ;IACR,eAAe;IACf,aAAa;IACb,YAAY;IACZ,aAAa;IACb,UAAU;CACX,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC;IACtC,UAAU;IACV,UAAU;IACV,eAAe;CAChB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC;IACtC,MAAM;IACN,WAAW;IACX,QAAQ;IACR,MAAM;CACP,CAAC,CAAC;AAEH,gFAAgF;AAEhF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,Q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AAoB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CAC/C,CAAC;KACD,WAAW,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAC1B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;QACxD,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;YACzB,GAAG,CAAC,QAAQ,CAAC;gBACX,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM;gBAC3B,OAAO,EAAE,yBAAyB,OAAO,CAAC,EAAE,EAAE;gBAC9C,IAAI,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC;aAChC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACvB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,SAAS,EAAE,qBAAqB;IAChC,eAAe,EAAE,0BAA0B;IAC3C,OAAO,EAAE,mBAAmB;IAC5B,KAAK,EAAE,iBAAiB;IACxB,KAAK,EAAE,iBAAiB;IACxB,aAAa,EAAE,wBAAwB;IACvC,gBAAgB,EAAE,2BAA2B,CAAC,QAAQ,EAAE;CACzD,CAAC,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Persistence port for routing state.
3
+ * Implementations live in infrastructure/ (SQLite, in-memory for tests).
4
+ */
5
+ import type { ModelProfile, PriceCatalog, RoutingDatasetRecord, RoutingOutcomeRecord, RoutingTelemetry, SessionPin } from './entities.js';
6
+ export interface ListTelemetryOptions {
7
+ readonly limit?: number;
8
+ readonly sessionId?: string;
9
+ }
10
+ export interface ListDatasetOptions {
11
+ readonly limit?: number;
12
+ }
13
+ export interface ListOutcomeOptions {
14
+ readonly limit?: number;
15
+ readonly requestId?: string;
16
+ readonly sessionId?: string;
17
+ }
18
+ export interface StorePort {
19
+ /** Retrieve an active session pin, or null if unpinned. */
20
+ getSessionPin(sessionId: string): Promise<SessionPin | null>;
21
+ /** Upsert a session pin (create or replace). */
22
+ putSessionPin(pin: SessionPin): Promise<void>;
23
+ /** Delete a session pin (e.g. on explicit unpin). */
24
+ deleteSessionPin(sessionId: string): Promise<void>;
25
+ /** Load the full model fleet catalog. */
26
+ getModelProfiles(): Promise<readonly ModelProfile[]>;
27
+ /** Load the current price catalog. */
28
+ getPriceCatalog(): Promise<PriceCatalog | null>;
29
+ /** Persist an updated price catalog. */
30
+ putPriceCatalog(catalog: PriceCatalog): Promise<void>;
31
+ /** Append a routing telemetry audit record (sync hot path). */
32
+ appendTelemetry(entry: RoutingTelemetry): void;
33
+ /** List recent telemetry rows, newest first. */
34
+ listTelemetry(options?: ListTelemetryOptions): Promise<readonly RoutingTelemetry[]>;
35
+ /** Append a privacy-safe routing dataset record (sync hot path). */
36
+ appendDatasetRecord(entry: RoutingDatasetRecord): void;
37
+ /** List recent dataset rows, newest first. */
38
+ listDatasetRecords(options?: ListDatasetOptions): Promise<readonly RoutingDatasetRecord[]>;
39
+ /** Append a behavioral outcome label (sync hot path). */
40
+ appendOutcomeRecord(entry: RoutingOutcomeRecord): void;
41
+ /** List recent outcome rows, newest first. */
42
+ listOutcomeRecords(options?: ListOutcomeOptions): Promise<readonly RoutingOutcomeRecord[]>;
43
+ }
44
+ //# sourceMappingURL=store-port.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-port.d.ts","sourceRoot":"","sources":["../../../src/domain/types/store-port.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE1I,MAAM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,EAAE,kBAAkB,GAAG,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC,CAAC;IAE3F,yDAAyD;IACzD,mBAAmB,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAEvD,8CAA8C;IAC9C,kBAAkB,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC,CAAC;CAC5F"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Persistence port for routing state.
3
+ * Implementations live in infrastructure/ (SQLite, in-memory for tests).
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=store-port.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-port.js","sourceRoot":"","sources":["../../../src/domain/types/store-port.ts"],"names":[],"mappings":"AAAA;;;GAGG"}