@defai.digital/contracts 13.0.3

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 (388) hide show
  1. package/LICENSE +214 -0
  2. package/dist/ability/v1/index.d.ts +5 -0
  3. package/dist/ability/v1/index.d.ts.map +1 -0
  4. package/dist/ability/v1/index.js +5 -0
  5. package/dist/ability/v1/index.js.map +1 -0
  6. package/dist/ability/v1/schema.d.ts +288 -0
  7. package/dist/ability/v1/schema.d.ts.map +1 -0
  8. package/dist/ability/v1/schema.js +138 -0
  9. package/dist/ability/v1/schema.js.map +1 -0
  10. package/dist/agent/v1/index.d.ts +8 -0
  11. package/dist/agent/v1/index.d.ts.map +1 -0
  12. package/dist/agent/v1/index.js +31 -0
  13. package/dist/agent/v1/index.js.map +1 -0
  14. package/dist/agent/v1/schema.d.ts +4055 -0
  15. package/dist/agent/v1/schema.d.ts.map +1 -0
  16. package/dist/agent/v1/schema.js +970 -0
  17. package/dist/agent/v1/schema.js.map +1 -0
  18. package/dist/agent/v1/storage-port.d.ts +172 -0
  19. package/dist/agent/v1/storage-port.d.ts.map +1 -0
  20. package/dist/agent/v1/storage-port.js +10 -0
  21. package/dist/agent/v1/storage-port.js.map +1 -0
  22. package/dist/analysis/v1/index.d.ts +7 -0
  23. package/dist/analysis/v1/index.d.ts.map +1 -0
  24. package/dist/analysis/v1/index.js +21 -0
  25. package/dist/analysis/v1/index.js.map +1 -0
  26. package/dist/analysis/v1/schema.d.ts +348 -0
  27. package/dist/analysis/v1/schema.d.ts.map +1 -0
  28. package/dist/analysis/v1/schema.js +252 -0
  29. package/dist/analysis/v1/schema.js.map +1 -0
  30. package/dist/cli/v1/index.d.ts +8 -0
  31. package/dist/cli/v1/index.d.ts.map +1 -0
  32. package/dist/cli/v1/index.js +46 -0
  33. package/dist/cli/v1/index.js.map +1 -0
  34. package/dist/cli/v1/output.d.ts +347 -0
  35. package/dist/cli/v1/output.d.ts.map +1 -0
  36. package/dist/cli/v1/output.js +288 -0
  37. package/dist/cli/v1/output.js.map +1 -0
  38. package/dist/cli/v1/schema.d.ts +494 -0
  39. package/dist/cli/v1/schema.d.ts.map +1 -0
  40. package/dist/cli/v1/schema.js +342 -0
  41. package/dist/cli/v1/schema.js.map +1 -0
  42. package/dist/config/v1/config.d.ts +887 -0
  43. package/dist/config/v1/config.d.ts.map +1 -0
  44. package/dist/config/v1/config.js +348 -0
  45. package/dist/config/v1/config.js.map +1 -0
  46. package/dist/config/v1/errors.d.ts +84 -0
  47. package/dist/config/v1/errors.d.ts.map +1 -0
  48. package/dist/config/v1/errors.js +150 -0
  49. package/dist/config/v1/errors.js.map +1 -0
  50. package/dist/config/v1/events.d.ts +416 -0
  51. package/dist/config/v1/events.d.ts.map +1 -0
  52. package/dist/config/v1/events.js +204 -0
  53. package/dist/config/v1/events.js.map +1 -0
  54. package/dist/config/v1/index.d.ts +11 -0
  55. package/dist/config/v1/index.d.ts.map +1 -0
  56. package/dist/config/v1/index.js +49 -0
  57. package/dist/config/v1/index.js.map +1 -0
  58. package/dist/config/v1/operations.d.ts +293 -0
  59. package/dist/config/v1/operations.d.ts.map +1 -0
  60. package/dist/config/v1/operations.js +172 -0
  61. package/dist/config/v1/operations.js.map +1 -0
  62. package/dist/config/v1/provider-config.d.ts +124 -0
  63. package/dist/config/v1/provider-config.d.ts.map +1 -0
  64. package/dist/config/v1/provider-config.js +123 -0
  65. package/dist/config/v1/provider-config.js.map +1 -0
  66. package/dist/constants.d.ts +292 -0
  67. package/dist/constants.d.ts.map +1 -0
  68. package/dist/constants.js +370 -0
  69. package/dist/constants.js.map +1 -0
  70. package/dist/context/v1/index.d.ts +5 -0
  71. package/dist/context/v1/index.d.ts.map +1 -0
  72. package/dist/context/v1/index.js +13 -0
  73. package/dist/context/v1/index.js.map +1 -0
  74. package/dist/context/v1/schema.d.ts +289 -0
  75. package/dist/context/v1/schema.d.ts.map +1 -0
  76. package/dist/context/v1/schema.js +145 -0
  77. package/dist/context/v1/schema.js.map +1 -0
  78. package/dist/cross-cutting/v1/dead-letter.d.ts +305 -0
  79. package/dist/cross-cutting/v1/dead-letter.d.ts.map +1 -0
  80. package/dist/cross-cutting/v1/dead-letter.js +172 -0
  81. package/dist/cross-cutting/v1/dead-letter.js.map +1 -0
  82. package/dist/cross-cutting/v1/idempotency.d.ts +222 -0
  83. package/dist/cross-cutting/v1/idempotency.d.ts.map +1 -0
  84. package/dist/cross-cutting/v1/idempotency.js +170 -0
  85. package/dist/cross-cutting/v1/idempotency.js.map +1 -0
  86. package/dist/cross-cutting/v1/index.d.ts +14 -0
  87. package/dist/cross-cutting/v1/index.d.ts.map +1 -0
  88. package/dist/cross-cutting/v1/index.js +18 -0
  89. package/dist/cross-cutting/v1/index.js.map +1 -0
  90. package/dist/cross-cutting/v1/retention.d.ts +347 -0
  91. package/dist/cross-cutting/v1/retention.d.ts.map +1 -0
  92. package/dist/cross-cutting/v1/retention.js +178 -0
  93. package/dist/cross-cutting/v1/retention.js.map +1 -0
  94. package/dist/cross-cutting/v1/saga.d.ts +358 -0
  95. package/dist/cross-cutting/v1/saga.d.ts.map +1 -0
  96. package/dist/cross-cutting/v1/saga.js +219 -0
  97. package/dist/cross-cutting/v1/saga.js.map +1 -0
  98. package/dist/design/v1/index.d.ts +5 -0
  99. package/dist/design/v1/index.d.ts.map +1 -0
  100. package/dist/design/v1/index.js +5 -0
  101. package/dist/design/v1/index.js.map +1 -0
  102. package/dist/design/v1/schema.d.ts +748 -0
  103. package/dist/design/v1/schema.d.ts.map +1 -0
  104. package/dist/design/v1/schema.js +316 -0
  105. package/dist/design/v1/schema.js.map +1 -0
  106. package/dist/discussion/v1/index.d.ts +10 -0
  107. package/dist/discussion/v1/index.d.ts.map +1 -0
  108. package/dist/discussion/v1/index.js +21 -0
  109. package/dist/discussion/v1/index.js.map +1 -0
  110. package/dist/discussion/v1/schema.d.ts +1186 -0
  111. package/dist/discussion/v1/schema.d.ts.map +1 -0
  112. package/dist/discussion/v1/schema.js +560 -0
  113. package/dist/discussion/v1/schema.js.map +1 -0
  114. package/dist/file-system/v1/index.d.ts +7 -0
  115. package/dist/file-system/v1/index.d.ts.map +1 -0
  116. package/dist/file-system/v1/index.js +7 -0
  117. package/dist/file-system/v1/index.js.map +1 -0
  118. package/dist/file-system/v1/schema.d.ts +644 -0
  119. package/dist/file-system/v1/schema.d.ts.map +1 -0
  120. package/dist/file-system/v1/schema.js +278 -0
  121. package/dist/file-system/v1/schema.js.map +1 -0
  122. package/dist/guard/v1/index.d.ts +9 -0
  123. package/dist/guard/v1/index.d.ts.map +1 -0
  124. package/dist/guard/v1/index.js +10 -0
  125. package/dist/guard/v1/index.js.map +1 -0
  126. package/dist/guard/v1/schema.d.ts +308 -0
  127. package/dist/guard/v1/schema.d.ts.map +1 -0
  128. package/dist/guard/v1/schema.js +267 -0
  129. package/dist/guard/v1/schema.js.map +1 -0
  130. package/dist/index.d.ts +68 -0
  131. package/dist/index.d.ts.map +1 -0
  132. package/dist/index.js +117 -0
  133. package/dist/index.js.map +1 -0
  134. package/dist/iterate/v1/index.d.ts +5 -0
  135. package/dist/iterate/v1/index.d.ts.map +1 -0
  136. package/dist/iterate/v1/index.js +13 -0
  137. package/dist/iterate/v1/index.js.map +1 -0
  138. package/dist/iterate/v1/schema.d.ts +693 -0
  139. package/dist/iterate/v1/schema.d.ts.map +1 -0
  140. package/dist/iterate/v1/schema.js +244 -0
  141. package/dist/iterate/v1/schema.js.map +1 -0
  142. package/dist/mcp/v1/index.d.ts +8 -0
  143. package/dist/mcp/v1/index.d.ts.map +1 -0
  144. package/dist/mcp/v1/index.js +20 -0
  145. package/dist/mcp/v1/index.js.map +1 -0
  146. package/dist/mcp/v1/prompts/index.d.ts +5 -0
  147. package/dist/mcp/v1/prompts/index.d.ts.map +1 -0
  148. package/dist/mcp/v1/prompts/index.js +5 -0
  149. package/dist/mcp/v1/prompts/index.js.map +1 -0
  150. package/dist/mcp/v1/prompts/schema.d.ts +266 -0
  151. package/dist/mcp/v1/prompts/schema.d.ts.map +1 -0
  152. package/dist/mcp/v1/prompts/schema.js +138 -0
  153. package/dist/mcp/v1/prompts/schema.js.map +1 -0
  154. package/dist/mcp/v1/rate-limit.schema.d.ts +175 -0
  155. package/dist/mcp/v1/rate-limit.schema.d.ts.map +1 -0
  156. package/dist/mcp/v1/rate-limit.schema.js +164 -0
  157. package/dist/mcp/v1/rate-limit.schema.js.map +1 -0
  158. package/dist/mcp/v1/resources/index.d.ts +5 -0
  159. package/dist/mcp/v1/resources/index.d.ts.map +1 -0
  160. package/dist/mcp/v1/resources/index.js +5 -0
  161. package/dist/mcp/v1/resources/index.js.map +1 -0
  162. package/dist/mcp/v1/resources/schema.d.ts +169 -0
  163. package/dist/mcp/v1/resources/schema.d.ts.map +1 -0
  164. package/dist/mcp/v1/resources/schema.js +118 -0
  165. package/dist/mcp/v1/resources/schema.js.map +1 -0
  166. package/dist/mcp/v1/runtime/cache.d.ts +204 -0
  167. package/dist/mcp/v1/runtime/cache.d.ts.map +1 -0
  168. package/dist/mcp/v1/runtime/cache.js +92 -0
  169. package/dist/mcp/v1/runtime/cache.js.map +1 -0
  170. package/dist/mcp/v1/runtime/index.d.ts +5 -0
  171. package/dist/mcp/v1/runtime/index.d.ts.map +1 -0
  172. package/dist/mcp/v1/runtime/index.js +9 -0
  173. package/dist/mcp/v1/runtime/index.js.map +1 -0
  174. package/dist/mcp/v1/runtime/limits.d.ts +113 -0
  175. package/dist/mcp/v1/runtime/limits.d.ts.map +1 -0
  176. package/dist/mcp/v1/runtime/limits.js +95 -0
  177. package/dist/mcp/v1/runtime/limits.js.map +1 -0
  178. package/dist/mcp/v1/runtime/response.d.ts +467 -0
  179. package/dist/mcp/v1/runtime/response.d.ts.map +1 -0
  180. package/dist/mcp/v1/runtime/response.js +130 -0
  181. package/dist/mcp/v1/runtime/response.js.map +1 -0
  182. package/dist/mcp/v1/runtime/timeout.d.ts +116 -0
  183. package/dist/mcp/v1/runtime/timeout.d.ts.map +1 -0
  184. package/dist/mcp/v1/runtime/timeout.js +116 -0
  185. package/dist/mcp/v1/runtime/timeout.js.map +1 -0
  186. package/dist/mcp/v1/schema.d.ts +171 -0
  187. package/dist/mcp/v1/schema.d.ts.map +1 -0
  188. package/dist/mcp/v1/schema.js +97 -0
  189. package/dist/mcp/v1/schema.js.map +1 -0
  190. package/dist/mcp/v1/tools/agent.d.ts +485 -0
  191. package/dist/mcp/v1/tools/agent.d.ts.map +1 -0
  192. package/dist/mcp/v1/tools/agent.js +264 -0
  193. package/dist/mcp/v1/tools/agent.js.map +1 -0
  194. package/dist/mcp/v1/tools/guard.d.ts +243 -0
  195. package/dist/mcp/v1/tools/guard.d.ts.map +1 -0
  196. package/dist/mcp/v1/tools/guard.js +136 -0
  197. package/dist/mcp/v1/tools/guard.js.map +1 -0
  198. package/dist/mcp/v1/tools/index.d.ts +15 -0
  199. package/dist/mcp/v1/tools/index.d.ts.map +1 -0
  200. package/dist/mcp/v1/tools/index.js +22 -0
  201. package/dist/mcp/v1/tools/index.js.map +1 -0
  202. package/dist/mcp/v1/tools/memory.d.ts +569 -0
  203. package/dist/mcp/v1/tools/memory.d.ts.map +1 -0
  204. package/dist/mcp/v1/tools/memory.js +319 -0
  205. package/dist/mcp/v1/tools/memory.js.map +1 -0
  206. package/dist/mcp/v1/tools/session.d.ts +545 -0
  207. package/dist/mcp/v1/tools/session.d.ts.map +1 -0
  208. package/dist/mcp/v1/tools/session.js +309 -0
  209. package/dist/mcp/v1/tools/session.js.map +1 -0
  210. package/dist/mcp/v1/tools/tool-list-schemas.d.ts +354 -0
  211. package/dist/mcp/v1/tools/tool-list-schemas.d.ts.map +1 -0
  212. package/dist/mcp/v1/tools/tool-list-schemas.js +140 -0
  213. package/dist/mcp/v1/tools/tool-list-schemas.js.map +1 -0
  214. package/dist/mcp/v1/tools/trace.d.ts +282 -0
  215. package/dist/mcp/v1/tools/trace.d.ts.map +1 -0
  216. package/dist/mcp/v1/tools/trace.js +94 -0
  217. package/dist/mcp/v1/tools/trace.js.map +1 -0
  218. package/dist/mcp/v1/tools/workflow.d.ts +146 -0
  219. package/dist/mcp/v1/tools/workflow.d.ts.map +1 -0
  220. package/dist/mcp/v1/tools/workflow.js +68 -0
  221. package/dist/mcp/v1/tools/workflow.js.map +1 -0
  222. package/dist/mcp/v1/trace/index.d.ts +5 -0
  223. package/dist/mcp/v1/trace/index.d.ts.map +1 -0
  224. package/dist/mcp/v1/trace/index.js +5 -0
  225. package/dist/mcp/v1/trace/index.js.map +1 -0
  226. package/dist/mcp/v1/trace/tool-trace.d.ts +107 -0
  227. package/dist/mcp/v1/trace/tool-trace.d.ts.map +1 -0
  228. package/dist/mcp/v1/trace/tool-trace.js +91 -0
  229. package/dist/mcp/v1/trace/tool-trace.js.map +1 -0
  230. package/dist/memory/v1/index.d.ts +2 -0
  231. package/dist/memory/v1/index.d.ts.map +1 -0
  232. package/dist/memory/v1/index.js +2 -0
  233. package/dist/memory/v1/index.js.map +1 -0
  234. package/dist/memory/v1/schema.d.ts +188 -0
  235. package/dist/memory/v1/schema.d.ts.map +1 -0
  236. package/dist/memory/v1/schema.js +108 -0
  237. package/dist/memory/v1/schema.js.map +1 -0
  238. package/dist/ml-lifecycle/v1/index.d.ts +12 -0
  239. package/dist/ml-lifecycle/v1/index.d.ts.map +1 -0
  240. package/dist/ml-lifecycle/v1/index.js +12 -0
  241. package/dist/ml-lifecycle/v1/index.js.map +1 -0
  242. package/dist/ml-lifecycle/v1/schema.d.ts +1207 -0
  243. package/dist/ml-lifecycle/v1/schema.d.ts.map +1 -0
  244. package/dist/ml-lifecycle/v1/schema.js +481 -0
  245. package/dist/ml-lifecycle/v1/schema.js.map +1 -0
  246. package/dist/orchestration/v1/index.d.ts +5 -0
  247. package/dist/orchestration/v1/index.d.ts.map +1 -0
  248. package/dist/orchestration/v1/index.js +23 -0
  249. package/dist/orchestration/v1/index.js.map +1 -0
  250. package/dist/orchestration/v1/schema.d.ts +1384 -0
  251. package/dist/orchestration/v1/schema.d.ts.map +1 -0
  252. package/dist/orchestration/v1/schema.js +394 -0
  253. package/dist/orchestration/v1/schema.js.map +1 -0
  254. package/dist/provider/v1/circuit-breaker.d.ts +151 -0
  255. package/dist/provider/v1/circuit-breaker.d.ts.map +1 -0
  256. package/dist/provider/v1/circuit-breaker.js +119 -0
  257. package/dist/provider/v1/circuit-breaker.js.map +1 -0
  258. package/dist/provider/v1/health.d.ts +246 -0
  259. package/dist/provider/v1/health.d.ts.map +1 -0
  260. package/dist/provider/v1/health.js +190 -0
  261. package/dist/provider/v1/health.js.map +1 -0
  262. package/dist/provider/v1/index.d.ts +13 -0
  263. package/dist/provider/v1/index.d.ts.map +1 -0
  264. package/dist/provider/v1/index.js +17 -0
  265. package/dist/provider/v1/index.js.map +1 -0
  266. package/dist/provider/v1/port.d.ts +237 -0
  267. package/dist/provider/v1/port.d.ts.map +1 -0
  268. package/dist/provider/v1/port.js +113 -0
  269. package/dist/provider/v1/port.js.map +1 -0
  270. package/dist/provider/v1/rate-limit.d.ts +214 -0
  271. package/dist/provider/v1/rate-limit.d.ts.map +1 -0
  272. package/dist/provider/v1/rate-limit.js +165 -0
  273. package/dist/provider/v1/rate-limit.js.map +1 -0
  274. package/dist/resilience/v1/circuit-breaker.d.ts +135 -0
  275. package/dist/resilience/v1/circuit-breaker.d.ts.map +1 -0
  276. package/dist/resilience/v1/circuit-breaker.js +105 -0
  277. package/dist/resilience/v1/circuit-breaker.js.map +1 -0
  278. package/dist/resilience/v1/index.d.ts +17 -0
  279. package/dist/resilience/v1/index.d.ts.map +1 -0
  280. package/dist/resilience/v1/index.js +17 -0
  281. package/dist/resilience/v1/index.js.map +1 -0
  282. package/dist/resilience/v1/loop-guard.d.ts +123 -0
  283. package/dist/resilience/v1/loop-guard.d.ts.map +1 -0
  284. package/dist/resilience/v1/loop-guard.js +96 -0
  285. package/dist/resilience/v1/loop-guard.js.map +1 -0
  286. package/dist/resilience/v1/metrics.d.ts +323 -0
  287. package/dist/resilience/v1/metrics.d.ts.map +1 -0
  288. package/dist/resilience/v1/metrics.js +183 -0
  289. package/dist/resilience/v1/metrics.js.map +1 -0
  290. package/dist/resilience/v1/rate-limiter.d.ts +122 -0
  291. package/dist/resilience/v1/rate-limiter.d.ts.map +1 -0
  292. package/dist/resilience/v1/rate-limiter.js +119 -0
  293. package/dist/resilience/v1/rate-limiter.js.map +1 -0
  294. package/dist/resilience/v1/resource-limits.d.ts +146 -0
  295. package/dist/resilience/v1/resource-limits.d.ts.map +1 -0
  296. package/dist/resilience/v1/resource-limits.js +130 -0
  297. package/dist/resilience/v1/resource-limits.js.map +1 -0
  298. package/dist/review/v1/index.d.ts +7 -0
  299. package/dist/review/v1/index.d.ts.map +1 -0
  300. package/dist/review/v1/index.js +23 -0
  301. package/dist/review/v1/index.js.map +1 -0
  302. package/dist/review/v1/schema.d.ts +1284 -0
  303. package/dist/review/v1/schema.d.ts.map +1 -0
  304. package/dist/review/v1/schema.js +423 -0
  305. package/dist/review/v1/schema.js.map +1 -0
  306. package/dist/routing/v1/index.d.ts +2 -0
  307. package/dist/routing/v1/index.d.ts.map +1 -0
  308. package/dist/routing/v1/index.js +2 -0
  309. package/dist/routing/v1/index.js.map +1 -0
  310. package/dist/routing/v1/schema.d.ts +315 -0
  311. package/dist/routing/v1/schema.d.ts.map +1 -0
  312. package/dist/routing/v1/schema.js +103 -0
  313. package/dist/routing/v1/schema.js.map +1 -0
  314. package/dist/scaffold/v1/index.d.ts +7 -0
  315. package/dist/scaffold/v1/index.d.ts.map +1 -0
  316. package/dist/scaffold/v1/index.js +7 -0
  317. package/dist/scaffold/v1/index.js.map +1 -0
  318. package/dist/scaffold/v1/schema.d.ts +351 -0
  319. package/dist/scaffold/v1/schema.d.ts.map +1 -0
  320. package/dist/scaffold/v1/schema.js +238 -0
  321. package/dist/scaffold/v1/schema.js.map +1 -0
  322. package/dist/session/v1/index.d.ts +7 -0
  323. package/dist/session/v1/index.d.ts.map +1 -0
  324. package/dist/session/v1/index.js +23 -0
  325. package/dist/session/v1/index.js.map +1 -0
  326. package/dist/session/v1/schema.d.ts +1156 -0
  327. package/dist/session/v1/schema.d.ts.map +1 -0
  328. package/dist/session/v1/schema.js +315 -0
  329. package/dist/session/v1/schema.js.map +1 -0
  330. package/dist/storage/v1/index.d.ts +9 -0
  331. package/dist/storage/v1/index.d.ts.map +1 -0
  332. package/dist/storage/v1/index.js +21 -0
  333. package/dist/storage/v1/index.js.map +1 -0
  334. package/dist/storage/v1/schema.d.ts +411 -0
  335. package/dist/storage/v1/schema.d.ts.map +1 -0
  336. package/dist/storage/v1/schema.js +167 -0
  337. package/dist/storage/v1/schema.js.map +1 -0
  338. package/dist/telemetry/v1/index.d.ts +5 -0
  339. package/dist/telemetry/v1/index.d.ts.map +1 -0
  340. package/dist/telemetry/v1/index.js +5 -0
  341. package/dist/telemetry/v1/index.js.map +1 -0
  342. package/dist/telemetry/v1/schema.d.ts +747 -0
  343. package/dist/telemetry/v1/schema.d.ts.map +1 -0
  344. package/dist/telemetry/v1/schema.js +300 -0
  345. package/dist/telemetry/v1/schema.js.map +1 -0
  346. package/dist/token-budget/v1/index.d.ts +7 -0
  347. package/dist/token-budget/v1/index.d.ts.map +1 -0
  348. package/dist/token-budget/v1/index.js +25 -0
  349. package/dist/token-budget/v1/index.js.map +1 -0
  350. package/dist/token-budget/v1/schema.d.ts +588 -0
  351. package/dist/token-budget/v1/schema.d.ts.map +1 -0
  352. package/dist/token-budget/v1/schema.js +239 -0
  353. package/dist/token-budget/v1/schema.js.map +1 -0
  354. package/dist/trace/v1/index.d.ts +2 -0
  355. package/dist/trace/v1/index.d.ts.map +1 -0
  356. package/dist/trace/v1/index.js +4 -0
  357. package/dist/trace/v1/index.js.map +1 -0
  358. package/dist/trace/v1/schema.d.ts +531 -0
  359. package/dist/trace/v1/schema.d.ts.map +1 -0
  360. package/dist/trace/v1/schema.js +243 -0
  361. package/dist/trace/v1/schema.js.map +1 -0
  362. package/dist/workflow/v1/index.d.ts +3 -0
  363. package/dist/workflow/v1/index.d.ts.map +1 -0
  364. package/dist/workflow/v1/index.js +8 -0
  365. package/dist/workflow/v1/index.js.map +1 -0
  366. package/dist/workflow/v1/schema.d.ts +267 -0
  367. package/dist/workflow/v1/schema.d.ts.map +1 -0
  368. package/dist/workflow/v1/schema.js +95 -0
  369. package/dist/workflow/v1/schema.js.map +1 -0
  370. package/dist/workflow/v1/step-guard.d.ts +571 -0
  371. package/dist/workflow/v1/step-guard.d.ts.map +1 -0
  372. package/dist/workflow/v1/step-guard.js +305 -0
  373. package/dist/workflow/v1/step-guard.js.map +1 -0
  374. package/dist/workflow-templates/v1/index.d.ts +8 -0
  375. package/dist/workflow-templates/v1/index.d.ts.map +1 -0
  376. package/dist/workflow-templates/v1/index.js +8 -0
  377. package/dist/workflow-templates/v1/index.js.map +1 -0
  378. package/dist/workflow-templates/v1/schema.d.ts +714 -0
  379. package/dist/workflow-templates/v1/schema.d.ts.map +1 -0
  380. package/dist/workflow-templates/v1/schema.js +168 -0
  381. package/dist/workflow-templates/v1/schema.js.map +1 -0
  382. package/package.json +142 -0
  383. package/src/guard/v1/policy.schema.json +56 -0
  384. package/src/mcp/v1/tools.schema.json +108 -0
  385. package/src/memory/v1/event.schema.json +136 -0
  386. package/src/routing/v1/decision.schema.json +155 -0
  387. package/src/trace/v1/event.schema.json +197 -0
  388. package/src/workflow/v1/workflow.schema.json +142 -0
@@ -0,0 +1,347 @@
1
+ /**
2
+ * CLI Output Protocol Contracts v1
3
+ *
4
+ * Contract schemas for CLI output parsing and error classification.
5
+ * These contracts define the expected formats from CLI provider outputs
6
+ * and enable consumer-driven contract testing.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ import { z } from 'zod';
11
+ /**
12
+ * Supported CLI output formats
13
+ *
14
+ * - json: Single JSON object response
15
+ * - stream-json: JSON Lines format (one JSON object per line)
16
+ * - text: Plain text output
17
+ */
18
+ export declare const CLIOutputFormatSchema: z.ZodEnum<["json", "stream-json", "text"]>;
19
+ export type CLIOutputFormat = z.infer<typeof CLIOutputFormatSchema>;
20
+ /**
21
+ * Token usage information
22
+ */
23
+ export declare const TokenUsageSchema: z.ZodObject<{
24
+ inputTokens: z.ZodNumber;
25
+ outputTokens: z.ZodNumber;
26
+ totalTokens: z.ZodNumber;
27
+ }, "strip", z.ZodTypeAny, {
28
+ totalTokens: number;
29
+ outputTokens: number;
30
+ inputTokens: number;
31
+ }, {
32
+ totalTokens: number;
33
+ outputTokens: number;
34
+ inputTokens: number;
35
+ }>;
36
+ export type TokenUsage = z.infer<typeof TokenUsageSchema>;
37
+ /**
38
+ * Result of parsing CLI output
39
+ */
40
+ export declare const ParsedCLIOutputSchema: z.ZodObject<{
41
+ /** Extracted content from the CLI response */
42
+ content: z.ZodString;
43
+ /** Raw metadata from the response (provider-specific) */
44
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
45
+ /** Token usage if available */
46
+ tokenUsage: z.ZodOptional<z.ZodObject<{
47
+ inputTokens: z.ZodNumber;
48
+ outputTokens: z.ZodNumber;
49
+ totalTokens: z.ZodNumber;
50
+ }, "strip", z.ZodTypeAny, {
51
+ totalTokens: number;
52
+ outputTokens: number;
53
+ inputTokens: number;
54
+ }, {
55
+ totalTokens: number;
56
+ outputTokens: number;
57
+ inputTokens: number;
58
+ }>>;
59
+ }, "strip", z.ZodTypeAny, {
60
+ content: string;
61
+ metadata?: Record<string, unknown> | undefined;
62
+ tokenUsage?: {
63
+ totalTokens: number;
64
+ outputTokens: number;
65
+ inputTokens: number;
66
+ } | undefined;
67
+ }, {
68
+ content: string;
69
+ metadata?: Record<string, unknown> | undefined;
70
+ tokenUsage?: {
71
+ totalTokens: number;
72
+ outputTokens: number;
73
+ inputTokens: number;
74
+ } | undefined;
75
+ }>;
76
+ export type ParsedCLIOutput = z.infer<typeof ParsedCLIOutputSchema>;
77
+ /**
78
+ * Error categories for CLI outputs
79
+ *
80
+ * Each category has specific retry/fallback guidance:
81
+ * - authentication: Don't retry, don't fallback (fix credentials)
82
+ * - quota: Don't retry, fallback to different provider
83
+ * - rate_limit: Retry with backoff, don't fallback
84
+ * - validation: Don't retry, don't fallback (fix request)
85
+ * - network: Retry, then fallback
86
+ * - server: Retry, then fallback
87
+ * - timeout: Retry, then fallback
88
+ * - not_found: Don't retry, fallback
89
+ * - configuration: Don't retry, don't fallback (fix config)
90
+ * - unknown: Don't retry, fallback
91
+ */
92
+ export declare const CLIErrorCategorySchema: z.ZodEnum<["authentication", "quota", "rate_limit", "validation", "network", "server", "timeout", "not_found", "configuration", "unknown"]>;
93
+ export type CLIErrorCategory = z.infer<typeof CLIErrorCategorySchema>;
94
+ /**
95
+ * Retry guidance for each error category
96
+ */
97
+ export declare const ERROR_CATEGORY_GUIDANCE: Record<CLIErrorCategory, {
98
+ shouldRetry: boolean;
99
+ shouldFallback: boolean;
100
+ }>;
101
+ /**
102
+ * Classified error with retry/fallback guidance
103
+ */
104
+ export declare const ClassifiedCLIErrorSchema: z.ZodObject<{
105
+ /** Error category */
106
+ category: z.ZodEnum<["authentication", "quota", "rate_limit", "validation", "network", "server", "timeout", "not_found", "configuration", "unknown"]>;
107
+ /** Human-readable error message */
108
+ message: z.ZodString;
109
+ /** Whether to retry the request */
110
+ shouldRetry: z.ZodBoolean;
111
+ /** Whether to fallback to another provider */
112
+ shouldFallback: z.ZodBoolean;
113
+ /** Suggested retry delay in milliseconds */
114
+ retryAfterMs: z.ZodNullable<z.ZodNumber>;
115
+ }, "strip", z.ZodTypeAny, {
116
+ message: string;
117
+ category: "validation" | "unknown" | "timeout" | "rate_limit" | "authentication" | "quota" | "network" | "server" | "not_found" | "configuration";
118
+ retryAfterMs: number | null;
119
+ shouldRetry: boolean;
120
+ shouldFallback: boolean;
121
+ }, {
122
+ message: string;
123
+ category: "validation" | "unknown" | "timeout" | "rate_limit" | "authentication" | "quota" | "network" | "server" | "not_found" | "configuration";
124
+ retryAfterMs: number | null;
125
+ shouldRetry: boolean;
126
+ shouldFallback: boolean;
127
+ }>;
128
+ export type ClassifiedCLIError = z.infer<typeof ClassifiedCLIErrorSchema>;
129
+ /**
130
+ * Raw CLI output structure for test fixtures
131
+ */
132
+ export declare const RawCLIOutputSchema: z.ZodObject<{
133
+ /** stdout from the CLI process */
134
+ stdout: z.ZodString;
135
+ /** stderr from the CLI process */
136
+ stderr: z.ZodDefault<z.ZodString>;
137
+ /** Exit code from the CLI process */
138
+ exitCode: z.ZodDefault<z.ZodNumber>;
139
+ }, "strip", z.ZodTypeAny, {
140
+ stdout: string;
141
+ stderr: string;
142
+ exitCode: number;
143
+ }, {
144
+ stdout: string;
145
+ stderr?: string | undefined;
146
+ exitCode?: number | undefined;
147
+ }>;
148
+ export type RawCLIOutput = z.infer<typeof RawCLIOutputSchema>;
149
+ /**
150
+ * Expected parsing result for test fixtures
151
+ */
152
+ export declare const ExpectedParseResultSchema: z.ZodObject<{
153
+ /** Expected extracted content */
154
+ content: z.ZodString;
155
+ /** Whether this output represents an error */
156
+ isError: z.ZodDefault<z.ZodBoolean>;
157
+ /** Expected error category if isError is true */
158
+ errorCategory: z.ZodOptional<z.ZodEnum<["authentication", "quota", "rate_limit", "validation", "network", "server", "timeout", "not_found", "configuration", "unknown"]>>;
159
+ }, "strip", z.ZodTypeAny, {
160
+ content: string;
161
+ isError: boolean;
162
+ errorCategory?: "validation" | "unknown" | "timeout" | "rate_limit" | "authentication" | "quota" | "network" | "server" | "not_found" | "configuration" | undefined;
163
+ }, {
164
+ content: string;
165
+ isError?: boolean | undefined;
166
+ errorCategory?: "validation" | "unknown" | "timeout" | "rate_limit" | "authentication" | "quota" | "network" | "server" | "not_found" | "configuration" | undefined;
167
+ }>;
168
+ export type ExpectedParseResult = z.infer<typeof ExpectedParseResultSchema>;
169
+ /**
170
+ * CLI output fixture for consumer-driven contract testing
171
+ *
172
+ * Each fixture represents a real or realistic CLI output from a provider,
173
+ * along with the expected parsing result. Tests validate that the
174
+ * output parser correctly extracts content and classifies errors.
175
+ */
176
+ export declare const CLIOutputFixtureSchema: z.ZodObject<{
177
+ /** Provider ID (claude, gemini, codex, qwen, glm, grok) */
178
+ provider: z.ZodString;
179
+ /** Scenario description */
180
+ scenario: z.ZodString;
181
+ /** Output format expected from this provider */
182
+ outputFormat: z.ZodEnum<["json", "stream-json", "text"]>;
183
+ /** When the fixture was captured (ISO 8601 datetime) */
184
+ capturedAt: z.ZodOptional<z.ZodString>;
185
+ /** Version of the CLI that produced this output */
186
+ cliVersion: z.ZodOptional<z.ZodString>;
187
+ /** Raw CLI output */
188
+ rawOutput: z.ZodObject<{
189
+ /** stdout from the CLI process */
190
+ stdout: z.ZodString;
191
+ /** stderr from the CLI process */
192
+ stderr: z.ZodDefault<z.ZodString>;
193
+ /** Exit code from the CLI process */
194
+ exitCode: z.ZodDefault<z.ZodNumber>;
195
+ }, "strip", z.ZodTypeAny, {
196
+ stdout: string;
197
+ stderr: string;
198
+ exitCode: number;
199
+ }, {
200
+ stdout: string;
201
+ stderr?: string | undefined;
202
+ exitCode?: number | undefined;
203
+ }>;
204
+ /** Expected parsing result */
205
+ expected: z.ZodObject<{
206
+ /** Expected extracted content */
207
+ content: z.ZodString;
208
+ /** Whether this output represents an error */
209
+ isError: z.ZodDefault<z.ZodBoolean>;
210
+ /** Expected error category if isError is true */
211
+ errorCategory: z.ZodOptional<z.ZodEnum<["authentication", "quota", "rate_limit", "validation", "network", "server", "timeout", "not_found", "configuration", "unknown"]>>;
212
+ }, "strip", z.ZodTypeAny, {
213
+ content: string;
214
+ isError: boolean;
215
+ errorCategory?: "validation" | "unknown" | "timeout" | "rate_limit" | "authentication" | "quota" | "network" | "server" | "not_found" | "configuration" | undefined;
216
+ }, {
217
+ content: string;
218
+ isError?: boolean | undefined;
219
+ errorCategory?: "validation" | "unknown" | "timeout" | "rate_limit" | "authentication" | "quota" | "network" | "server" | "not_found" | "configuration" | undefined;
220
+ }>;
221
+ }, "strip", z.ZodTypeAny, {
222
+ expected: {
223
+ content: string;
224
+ isError: boolean;
225
+ errorCategory?: "validation" | "unknown" | "timeout" | "rate_limit" | "authentication" | "quota" | "network" | "server" | "not_found" | "configuration" | undefined;
226
+ };
227
+ provider: string;
228
+ outputFormat: "text" | "json" | "stream-json";
229
+ scenario: string;
230
+ rawOutput: {
231
+ stdout: string;
232
+ stderr: string;
233
+ exitCode: number;
234
+ };
235
+ capturedAt?: string | undefined;
236
+ cliVersion?: string | undefined;
237
+ }, {
238
+ expected: {
239
+ content: string;
240
+ isError?: boolean | undefined;
241
+ errorCategory?: "validation" | "unknown" | "timeout" | "rate_limit" | "authentication" | "quota" | "network" | "server" | "not_found" | "configuration" | undefined;
242
+ };
243
+ provider: string;
244
+ outputFormat: "text" | "json" | "stream-json";
245
+ scenario: string;
246
+ rawOutput: {
247
+ stdout: string;
248
+ stderr?: string | undefined;
249
+ exitCode?: number | undefined;
250
+ };
251
+ capturedAt?: string | undefined;
252
+ cliVersion?: string | undefined;
253
+ }>;
254
+ export type CLIOutputFixture = z.infer<typeof CLIOutputFixtureSchema>;
255
+ /**
256
+ * Documented provider output formats
257
+ *
258
+ * This constant documents the expected output structures from each provider.
259
+ * Used for reference when creating test fixtures and validating parsers.
260
+ */
261
+ export declare const PROVIDER_OUTPUT_FORMATS: {
262
+ readonly claude: {
263
+ readonly format: "stream-json";
264
+ readonly description: "JSON Lines with turn events";
265
+ readonly contentExtraction: "content field in content events";
266
+ readonly examples: readonly ["{\"type\":\"turn.started\",...}", "{\"type\":\"content\",\"content\":\"Hello\"}", "{\"type\":\"turn.completed\",\"usage\":{...}}"];
267
+ };
268
+ readonly gemini: {
269
+ readonly format: "stream-json";
270
+ readonly description: "JSON Lines with content events";
271
+ readonly contentExtraction: "content field in response objects";
272
+ readonly examples: readonly ["{\"candidates\":[{\"content\":{\"parts\":[{\"text\":\"Hello\"}]}}]}"];
273
+ };
274
+ readonly codex: {
275
+ readonly format: "stream-json";
276
+ readonly description: "JSON Lines with item.completed events";
277
+ readonly contentExtraction: "item.text or item.agent_message.text in item.completed events";
278
+ readonly examples: readonly ["{\"type\":\"item.completed\",\"item\":{\"type\":\"agent_message\",\"text\":\"Hello\"}}"];
279
+ };
280
+ readonly qwen: {
281
+ readonly format: "text";
282
+ readonly description: "Plain text output";
283
+ readonly contentExtraction: "Raw stdout";
284
+ readonly examples: readonly ["Hello, how can I help you today?"];
285
+ };
286
+ readonly glm: {
287
+ readonly format: "stream-json";
288
+ readonly description: "JSON Lines with role:assistant messages";
289
+ readonly contentExtraction: "content field from assistant role messages";
290
+ readonly examples: readonly ["{\"role\":\"assistant\",\"content\":\"Hello\"}"];
291
+ };
292
+ readonly grok: {
293
+ readonly format: "stream-json";
294
+ readonly description: "JSON Lines with role:assistant messages";
295
+ readonly contentExtraction: "content field from assistant role messages";
296
+ readonly examples: readonly ["{\"role\":\"assistant\",\"content\":\"Hello\"}"];
297
+ };
298
+ };
299
+ export declare const CLIOutputErrorCodes: {
300
+ /** Output could not be parsed */
301
+ readonly PARSE_ERROR: "CLI_OUTPUT_PARSE_ERROR";
302
+ /** Unknown output format */
303
+ readonly UNKNOWN_FORMAT: "CLI_OUTPUT_UNKNOWN_FORMAT";
304
+ /** Empty output received */
305
+ readonly EMPTY_OUTPUT: "CLI_OUTPUT_EMPTY";
306
+ /** Fixture validation failed */
307
+ readonly INVALID_FIXTURE: "CLI_OUTPUT_INVALID_FIXTURE";
308
+ };
309
+ export type CLIOutputErrorCode = (typeof CLIOutputErrorCodes)[keyof typeof CLIOutputErrorCodes];
310
+ /**
311
+ * Validates a CLI output fixture
312
+ */
313
+ export declare function validateCLIOutputFixture(data: unknown): CLIOutputFixture;
314
+ /**
315
+ * Safely validates a CLI output fixture
316
+ */
317
+ export declare function safeValidateCLIOutputFixture(data: unknown): {
318
+ success: true;
319
+ data: CLIOutputFixture;
320
+ } | {
321
+ success: false;
322
+ error: z.ZodError;
323
+ };
324
+ /**
325
+ * Validates a classified CLI error
326
+ */
327
+ export declare function validateClassifiedCLIError(data: unknown): ClassifiedCLIError;
328
+ /**
329
+ * Validates parsed CLI output
330
+ */
331
+ export declare function validateParsedCLIOutput(data: unknown): ParsedCLIOutput;
332
+ /**
333
+ * Creates a CLI output fixture
334
+ */
335
+ export declare function createCLIOutputFixture(provider: string, scenario: string, outputFormat: CLIOutputFormat, rawOutput: RawCLIOutput, expected: ExpectedParseResult): CLIOutputFixture;
336
+ /**
337
+ * Creates a classified CLI error
338
+ */
339
+ export declare function createClassifiedCLIError(category: CLIErrorCategory, message: string, retryAfterMs?: number | null): ClassifiedCLIError;
340
+ /**
341
+ * Gets retry guidance for an error category
342
+ */
343
+ export declare function getErrorCategoryGuidance(category: CLIErrorCategory): {
344
+ shouldRetry: boolean;
345
+ shouldFallback: boolean;
346
+ };
347
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../src/cli/v1/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,4CAA0C,CAAC;AAC7E,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAMpE;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;EAI3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAM1D;;GAEG;AACH,eAAO,MAAM,qBAAqB;IAChC,8CAA8C;;IAG9C,yDAAyD;;IAGzD,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE/B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAMpE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,sBAAsB,6IAWjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC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
+ * CLI Output Protocol Contracts v1
3
+ *
4
+ * Contract schemas for CLI output parsing and error classification.
5
+ * These contracts define the expected formats from CLI provider outputs
6
+ * and enable consumer-driven contract testing.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ import { z } from 'zod';
11
+ // ============================================================================
12
+ // Output Format Types
13
+ // ============================================================================
14
+ /**
15
+ * Supported CLI output formats
16
+ *
17
+ * - json: Single JSON object response
18
+ * - stream-json: JSON Lines format (one JSON object per line)
19
+ * - text: Plain text output
20
+ */
21
+ export const CLIOutputFormatSchema = z.enum(['json', 'stream-json', 'text']);
22
+ // ============================================================================
23
+ // Token Usage
24
+ // ============================================================================
25
+ /**
26
+ * Token usage information
27
+ */
28
+ export const TokenUsageSchema = z.object({
29
+ inputTokens: z.number().int().nonnegative(),
30
+ outputTokens: z.number().int().nonnegative(),
31
+ totalTokens: z.number().int().nonnegative(),
32
+ });
33
+ // ============================================================================
34
+ // Parsed Output
35
+ // ============================================================================
36
+ /**
37
+ * Result of parsing CLI output
38
+ */
39
+ export const ParsedCLIOutputSchema = z.object({
40
+ /** Extracted content from the CLI response */
41
+ content: z.string(),
42
+ /** Raw metadata from the response (provider-specific) */
43
+ metadata: z.record(z.unknown()).optional(),
44
+ /** Token usage if available */
45
+ tokenUsage: TokenUsageSchema.optional(),
46
+ });
47
+ // ============================================================================
48
+ // Error Categories
49
+ // ============================================================================
50
+ /**
51
+ * Error categories for CLI outputs
52
+ *
53
+ * Each category has specific retry/fallback guidance:
54
+ * - authentication: Don't retry, don't fallback (fix credentials)
55
+ * - quota: Don't retry, fallback to different provider
56
+ * - rate_limit: Retry with backoff, don't fallback
57
+ * - validation: Don't retry, don't fallback (fix request)
58
+ * - network: Retry, then fallback
59
+ * - server: Retry, then fallback
60
+ * - timeout: Retry, then fallback
61
+ * - not_found: Don't retry, fallback
62
+ * - configuration: Don't retry, don't fallback (fix config)
63
+ * - unknown: Don't retry, fallback
64
+ */
65
+ export const CLIErrorCategorySchema = z.enum([
66
+ 'authentication',
67
+ 'quota',
68
+ 'rate_limit',
69
+ 'validation',
70
+ 'network',
71
+ 'server',
72
+ 'timeout',
73
+ 'not_found',
74
+ 'configuration',
75
+ 'unknown',
76
+ ]);
77
+ /**
78
+ * Retry guidance for each error category
79
+ */
80
+ export const ERROR_CATEGORY_GUIDANCE = {
81
+ authentication: { shouldRetry: false, shouldFallback: false },
82
+ quota: { shouldRetry: false, shouldFallback: true },
83
+ rate_limit: { shouldRetry: true, shouldFallback: false },
84
+ validation: { shouldRetry: false, shouldFallback: false },
85
+ network: { shouldRetry: true, shouldFallback: true },
86
+ server: { shouldRetry: true, shouldFallback: true },
87
+ timeout: { shouldRetry: true, shouldFallback: true },
88
+ not_found: { shouldRetry: false, shouldFallback: true },
89
+ configuration: { shouldRetry: false, shouldFallback: false },
90
+ unknown: { shouldRetry: false, shouldFallback: true },
91
+ };
92
+ // ============================================================================
93
+ // Classified Error
94
+ // ============================================================================
95
+ /**
96
+ * Classified error with retry/fallback guidance
97
+ */
98
+ export const ClassifiedCLIErrorSchema = z.object({
99
+ /** Error category */
100
+ category: CLIErrorCategorySchema,
101
+ /** Human-readable error message */
102
+ message: z.string(),
103
+ /** Whether to retry the request */
104
+ shouldRetry: z.boolean(),
105
+ /** Whether to fallback to another provider */
106
+ shouldFallback: z.boolean(),
107
+ /** Suggested retry delay in milliseconds */
108
+ retryAfterMs: z.number().nullable(),
109
+ });
110
+ // ============================================================================
111
+ // Test Fixtures (Consumer-Driven Contract Testing)
112
+ // ============================================================================
113
+ /**
114
+ * Raw CLI output structure for test fixtures
115
+ */
116
+ export const RawCLIOutputSchema = z.object({
117
+ /** stdout from the CLI process */
118
+ stdout: z.string(),
119
+ /** stderr from the CLI process */
120
+ stderr: z.string().default(''),
121
+ /** Exit code from the CLI process */
122
+ exitCode: z.number().int().default(0),
123
+ });
124
+ /**
125
+ * Expected parsing result for test fixtures
126
+ */
127
+ export const ExpectedParseResultSchema = z.object({
128
+ /** Expected extracted content */
129
+ content: z.string(),
130
+ /** Whether this output represents an error */
131
+ isError: z.boolean().default(false),
132
+ /** Expected error category if isError is true */
133
+ errorCategory: CLIErrorCategorySchema.optional(),
134
+ });
135
+ /**
136
+ * CLI output fixture for consumer-driven contract testing
137
+ *
138
+ * Each fixture represents a real or realistic CLI output from a provider,
139
+ * along with the expected parsing result. Tests validate that the
140
+ * output parser correctly extracts content and classifies errors.
141
+ */
142
+ export const CLIOutputFixtureSchema = z.object({
143
+ /** Provider ID (claude, gemini, codex, qwen, glm, grok) */
144
+ provider: z.string(),
145
+ /** Scenario description */
146
+ scenario: z.string(),
147
+ /** Output format expected from this provider */
148
+ outputFormat: CLIOutputFormatSchema,
149
+ /** When the fixture was captured (ISO 8601 datetime) */
150
+ capturedAt: z.string().datetime().optional(),
151
+ /** Version of the CLI that produced this output */
152
+ cliVersion: z.string().optional(),
153
+ /** Raw CLI output */
154
+ rawOutput: RawCLIOutputSchema,
155
+ /** Expected parsing result */
156
+ expected: ExpectedParseResultSchema,
157
+ });
158
+ // ============================================================================
159
+ // Provider Output Formats Documentation
160
+ // ============================================================================
161
+ /**
162
+ * Documented provider output formats
163
+ *
164
+ * This constant documents the expected output structures from each provider.
165
+ * Used for reference when creating test fixtures and validating parsers.
166
+ */
167
+ export const PROVIDER_OUTPUT_FORMATS = {
168
+ claude: {
169
+ format: 'stream-json',
170
+ description: 'JSON Lines with turn events',
171
+ contentExtraction: 'content field in content events',
172
+ examples: [
173
+ '{"type":"turn.started",...}',
174
+ '{"type":"content","content":"Hello"}',
175
+ '{"type":"turn.completed","usage":{...}}',
176
+ ],
177
+ },
178
+ gemini: {
179
+ format: 'stream-json',
180
+ description: 'JSON Lines with content events',
181
+ contentExtraction: 'content field in response objects',
182
+ examples: ['{"candidates":[{"content":{"parts":[{"text":"Hello"}]}}]}'],
183
+ },
184
+ codex: {
185
+ format: 'stream-json',
186
+ description: 'JSON Lines with item.completed events',
187
+ contentExtraction: 'item.text or item.agent_message.text in item.completed events',
188
+ examples: ['{"type":"item.completed","item":{"type":"agent_message","text":"Hello"}}'],
189
+ },
190
+ qwen: {
191
+ format: 'text',
192
+ description: 'Plain text output',
193
+ contentExtraction: 'Raw stdout',
194
+ examples: ['Hello, how can I help you today?'],
195
+ },
196
+ glm: {
197
+ format: 'stream-json',
198
+ description: 'JSON Lines with role:assistant messages',
199
+ contentExtraction: 'content field from assistant role messages',
200
+ examples: ['{"role":"assistant","content":"Hello"}'],
201
+ },
202
+ grok: {
203
+ format: 'stream-json',
204
+ description: 'JSON Lines with role:assistant messages',
205
+ contentExtraction: 'content field from assistant role messages',
206
+ examples: ['{"role":"assistant","content":"Hello"}'],
207
+ },
208
+ };
209
+ // ============================================================================
210
+ // Error Codes
211
+ // ============================================================================
212
+ export const CLIOutputErrorCodes = {
213
+ /** Output could not be parsed */
214
+ PARSE_ERROR: 'CLI_OUTPUT_PARSE_ERROR',
215
+ /** Unknown output format */
216
+ UNKNOWN_FORMAT: 'CLI_OUTPUT_UNKNOWN_FORMAT',
217
+ /** Empty output received */
218
+ EMPTY_OUTPUT: 'CLI_OUTPUT_EMPTY',
219
+ /** Fixture validation failed */
220
+ INVALID_FIXTURE: 'CLI_OUTPUT_INVALID_FIXTURE',
221
+ };
222
+ // ============================================================================
223
+ // Validation Functions
224
+ // ============================================================================
225
+ /**
226
+ * Validates a CLI output fixture
227
+ */
228
+ export function validateCLIOutputFixture(data) {
229
+ return CLIOutputFixtureSchema.parse(data);
230
+ }
231
+ /**
232
+ * Safely validates a CLI output fixture
233
+ */
234
+ export function safeValidateCLIOutputFixture(data) {
235
+ const result = CLIOutputFixtureSchema.safeParse(data);
236
+ if (result.success) {
237
+ return { success: true, data: result.data };
238
+ }
239
+ return { success: false, error: result.error };
240
+ }
241
+ /**
242
+ * Validates a classified CLI error
243
+ */
244
+ export function validateClassifiedCLIError(data) {
245
+ return ClassifiedCLIErrorSchema.parse(data);
246
+ }
247
+ /**
248
+ * Validates parsed CLI output
249
+ */
250
+ export function validateParsedCLIOutput(data) {
251
+ return ParsedCLIOutputSchema.parse(data);
252
+ }
253
+ // ============================================================================
254
+ // Factory Functions
255
+ // ============================================================================
256
+ /**
257
+ * Creates a CLI output fixture
258
+ */
259
+ export function createCLIOutputFixture(provider, scenario, outputFormat, rawOutput, expected) {
260
+ return CLIOutputFixtureSchema.parse({
261
+ provider,
262
+ scenario,
263
+ outputFormat,
264
+ rawOutput,
265
+ expected,
266
+ capturedAt: new Date().toISOString(),
267
+ });
268
+ }
269
+ /**
270
+ * Creates a classified CLI error
271
+ */
272
+ export function createClassifiedCLIError(category, message, retryAfterMs = null) {
273
+ const guidance = ERROR_CATEGORY_GUIDANCE[category];
274
+ return {
275
+ category,
276
+ message,
277
+ shouldRetry: guidance.shouldRetry,
278
+ shouldFallback: guidance.shouldFallback,
279
+ retryAfterMs,
280
+ };
281
+ }
282
+ /**
283
+ * Gets retry guidance for an error category
284
+ */
285
+ export function getErrorCategoryGuidance(category) {
286
+ return ERROR_CATEGORY_GUIDANCE[category];
287
+ }
288
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../../../src/cli/v1/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;AAG7E,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IAC3C,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EA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