@vertesia/common 1.5.0-dev.20260722.120446Z → 1.5.0-dev.20260804.124748Z

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 (522) hide show
  1. package/lib/access-control-values.d.ts +98 -0
  2. package/lib/access-control-values.d.ts.map +1 -0
  3. package/lib/access-control-values.js +101 -0
  4. package/lib/access-control-values.js.map +1 -0
  5. package/lib/access-control.d.ts +22 -119
  6. package/lib/access-control.d.ts.map +1 -1
  7. package/lib/access-control.js +6 -78
  8. package/lib/access-control.js.map +1 -1
  9. package/lib/account-values.d.ts +53 -0
  10. package/lib/account-values.d.ts.map +1 -0
  11. package/lib/account-values.js +91 -0
  12. package/lib/account-values.js.map +1 -0
  13. package/lib/analytics.d.ts +12 -38
  14. package/lib/analytics.d.ts.map +1 -1
  15. package/lib/api-schemas/access-control.d.ts +215 -0
  16. package/lib/api-schemas/access-control.d.ts.map +1 -0
  17. package/lib/api-schemas/access-control.js +165 -0
  18. package/lib/api-schemas/access-control.js.map +1 -0
  19. package/lib/api-schemas/account.d.ts +101 -0
  20. package/lib/api-schemas/account.d.ts.map +1 -0
  21. package/lib/api-schemas/account.js +136 -0
  22. package/lib/api-schemas/account.js.map +1 -0
  23. package/lib/api-schemas/adapter.d.ts +80 -0
  24. package/lib/api-schemas/adapter.d.ts.map +1 -0
  25. package/lib/api-schemas/adapter.js +726 -0
  26. package/lib/api-schemas/adapter.js.map +1 -0
  27. package/lib/api-schemas/agent-runs.d.ts +3781 -0
  28. package/lib/api-schemas/agent-runs.d.ts.map +1 -0
  29. package/lib/api-schemas/agent-runs.js +991 -0
  30. package/lib/api-schemas/agent-runs.js.map +1 -0
  31. package/lib/api-schemas/analytics.d.ts +86 -0
  32. package/lib/api-schemas/analytics.d.ts.map +1 -0
  33. package/lib/api-schemas/analytics.js +58 -0
  34. package/lib/api-schemas/analytics.js.map +1 -0
  35. package/lib/api-schemas/apikey.d.ts +231 -0
  36. package/lib/api-schemas/apikey.d.ts.map +1 -0
  37. package/lib/api-schemas/apikey.js +172 -0
  38. package/lib/api-schemas/apikey.js.map +1 -0
  39. package/lib/api-schemas/app-lifecycle.d.ts +1114 -0
  40. package/lib/api-schemas/app-lifecycle.d.ts.map +1 -0
  41. package/lib/api-schemas/app-lifecycle.js +750 -0
  42. package/lib/api-schemas/app-lifecycle.js.map +1 -0
  43. package/lib/api-schemas/app-runtime.d.ts +9056 -0
  44. package/lib/api-schemas/app-runtime.d.ts.map +1 -0
  45. package/lib/api-schemas/app-runtime.js +782 -0
  46. package/lib/api-schemas/app-runtime.js.map +1 -0
  47. package/lib/api-schemas/apps.d.ts +247 -0
  48. package/lib/api-schemas/apps.d.ts.map +1 -0
  49. package/lib/api-schemas/apps.js +366 -0
  50. package/lib/api-schemas/apps.js.map +1 -0
  51. package/lib/api-schemas/audit-trail.d.ts +465 -0
  52. package/lib/api-schemas/audit-trail.d.ts.map +1 -0
  53. package/lib/api-schemas/audit-trail.js +218 -0
  54. package/lib/api-schemas/audit-trail.js.map +1 -0
  55. package/lib/api-schemas/bulk-operation.d.ts +104 -0
  56. package/lib/api-schemas/bulk-operation.d.ts.map +1 -0
  57. package/lib/api-schemas/bulk-operation.js +66 -0
  58. package/lib/api-schemas/bulk-operation.js.map +1 -0
  59. package/lib/api-schemas/commands.d.ts +50 -0
  60. package/lib/api-schemas/commands.d.ts.map +1 -0
  61. package/lib/api-schemas/commands.js +58 -0
  62. package/lib/api-schemas/commands.js.map +1 -0
  63. package/lib/api-schemas/content.d.ts +3561 -0
  64. package/lib/api-schemas/content.d.ts.map +1 -0
  65. package/lib/api-schemas/content.js +842 -0
  66. package/lib/api-schemas/content.js.map +1 -0
  67. package/lib/api-schemas/cost-analytics.d.ts +300 -0
  68. package/lib/api-schemas/cost-analytics.d.ts.map +1 -0
  69. package/lib/api-schemas/cost-analytics.js +218 -0
  70. package/lib/api-schemas/cost-analytics.js.map +1 -0
  71. package/lib/api-schemas/dashboard.d.ts +408 -0
  72. package/lib/api-schemas/dashboard.d.ts.map +1 -0
  73. package/lib/api-schemas/dashboard.js +311 -0
  74. package/lib/api-schemas/dashboard.js.map +1 -0
  75. package/lib/api-schemas/data-store.d.ts +1650 -0
  76. package/lib/api-schemas/data-store.d.ts.map +1 -0
  77. package/lib/api-schemas/data-store.js +504 -0
  78. package/lib/api-schemas/data-store.js.map +1 -0
  79. package/lib/api-schemas/document-processing.d.ts +1501 -0
  80. package/lib/api-schemas/document-processing.d.ts.map +1 -0
  81. package/lib/api-schemas/document-processing.js +312 -0
  82. package/lib/api-schemas/document-processing.js.map +1 -0
  83. package/lib/api-schemas/embeddings.d.ts +184 -0
  84. package/lib/api-schemas/embeddings.d.ts.map +1 -0
  85. package/lib/api-schemas/embeddings.js +102 -0
  86. package/lib/api-schemas/embeddings.js.map +1 -0
  87. package/lib/api-schemas/environment.d.ts +412 -0
  88. package/lib/api-schemas/environment.d.ts.map +1 -0
  89. package/lib/api-schemas/environment.js +170 -0
  90. package/lib/api-schemas/environment.js.map +1 -0
  91. package/lib/api-schemas/events.d.ts +4880 -0
  92. package/lib/api-schemas/events.d.ts.map +1 -0
  93. package/lib/api-schemas/events.js +832 -0
  94. package/lib/api-schemas/events.js.map +1 -0
  95. package/lib/api-schemas/files.d.ts +107 -0
  96. package/lib/api-schemas/files.d.ts.map +1 -0
  97. package/lib/api-schemas/files.js +137 -0
  98. package/lib/api-schemas/files.js.map +1 -0
  99. package/lib/api-schemas/group.d.ts +122 -0
  100. package/lib/api-schemas/group.d.ts.map +1 -0
  101. package/lib/api-schemas/group.js +142 -0
  102. package/lib/api-schemas/group.js.map +1 -0
  103. package/lib/api-schemas/index.d.ts +36 -0
  104. package/lib/api-schemas/index.d.ts.map +1 -0
  105. package/lib/api-schemas/index.js +36 -0
  106. package/lib/api-schemas/index.js.map +1 -0
  107. package/lib/api-schemas/indexing.d.ts +144 -0
  108. package/lib/api-schemas/indexing.d.ts.map +1 -0
  109. package/lib/api-schemas/indexing.js +217 -0
  110. package/lib/api-schemas/indexing.js.map +1 -0
  111. package/lib/api-schemas/integrations.d.ts +269 -0
  112. package/lib/api-schemas/integrations.d.ts.map +1 -0
  113. package/lib/api-schemas/integrations.js +335 -0
  114. package/lib/api-schemas/integrations.js.map +1 -0
  115. package/lib/api-schemas/interaction.d.ts +22454 -0
  116. package/lib/api-schemas/interaction.d.ts.map +1 -0
  117. package/lib/api-schemas/interaction.js +2065 -0
  118. package/lib/api-schemas/interaction.js.map +1 -0
  119. package/lib/api-schemas/invites.d.ts +162 -0
  120. package/lib/api-schemas/invites.d.ts.map +1 -0
  121. package/lib/api-schemas/invites.js +106 -0
  122. package/lib/api-schemas/invites.js.map +1 -0
  123. package/lib/api-schemas/oauth-server.d.ts +415 -0
  124. package/lib/api-schemas/oauth-server.d.ts.map +1 -0
  125. package/lib/api-schemas/oauth-server.js +193 -0
  126. package/lib/api-schemas/oauth-server.js.map +1 -0
  127. package/lib/api-schemas/oauth.d.ts +150 -0
  128. package/lib/api-schemas/oauth.d.ts.map +1 -0
  129. package/lib/api-schemas/oauth.js +148 -0
  130. package/lib/api-schemas/oauth.js.map +1 -0
  131. package/lib/api-schemas/parameters.d.ts +64 -0
  132. package/lib/api-schemas/parameters.d.ts.map +1 -0
  133. package/lib/api-schemas/parameters.js +246 -0
  134. package/lib/api-schemas/parameters.js.map +1 -0
  135. package/lib/api-schemas/process.d.ts +499 -0
  136. package/lib/api-schemas/process.d.ts.map +1 -0
  137. package/lib/api-schemas/process.js +817 -0
  138. package/lib/api-schemas/process.js.map +1 -0
  139. package/lib/api-schemas/project-configuration.d.ts +4900 -0
  140. package/lib/api-schemas/project-configuration.d.ts.map +1 -0
  141. package/lib/api-schemas/project-configuration.js +425 -0
  142. package/lib/api-schemas/project-configuration.js.map +1 -0
  143. package/lib/api-schemas/project.d.ts +7247 -0
  144. package/lib/api-schemas/project.d.ts.map +1 -0
  145. package/lib/api-schemas/project.js +185 -0
  146. package/lib/api-schemas/project.js.map +1 -0
  147. package/lib/api-schemas/prompt.d.ts +70 -0
  148. package/lib/api-schemas/prompt.d.ts.map +1 -0
  149. package/lib/api-schemas/prompt.js +77 -0
  150. package/lib/api-schemas/prompt.js.map +1 -0
  151. package/lib/api-schemas/quota.d.ts +90 -0
  152. package/lib/api-schemas/quota.d.ts.map +1 -0
  153. package/lib/api-schemas/quota.js +95 -0
  154. package/lib/api-schemas/quota.js.map +1 -0
  155. package/lib/api-schemas/registry.d.ts +97458 -0
  156. package/lib/api-schemas/registry.d.ts.map +1 -0
  157. package/lib/api-schemas/registry.js +2586 -0
  158. package/lib/api-schemas/registry.js.map +1 -0
  159. package/lib/api-schemas/schema-primitives.d.ts +5 -0
  160. package/lib/api-schemas/schema-primitives.d.ts.map +1 -0
  161. package/lib/api-schemas/schema-primitives.js +11 -0
  162. package/lib/api-schemas/schema-primitives.js.map +1 -0
  163. package/lib/api-schemas/secrets.d.ts +497 -0
  164. package/lib/api-schemas/secrets.d.ts.map +1 -0
  165. package/lib/api-schemas/secrets.js +298 -0
  166. package/lib/api-schemas/secrets.js.map +1 -0
  167. package/lib/api-schemas/store.d.ts +22140 -0
  168. package/lib/api-schemas/store.d.ts.map +1 -0
  169. package/lib/api-schemas/store.js +557 -0
  170. package/lib/api-schemas/store.js.map +1 -0
  171. package/lib/api-schemas/sts.d.ts +156 -0
  172. package/lib/api-schemas/sts.d.ts.map +1 -0
  173. package/lib/api-schemas/sts.js +96 -0
  174. package/lib/api-schemas/sts.js.map +1 -0
  175. package/lib/api-schemas/task.d.ts +215 -0
  176. package/lib/api-schemas/task.d.ts.map +1 -0
  177. package/lib/api-schemas/task.js +95 -0
  178. package/lib/api-schemas/task.js.map +1 -0
  179. package/lib/api-schemas/tools.d.ts +111 -0
  180. package/lib/api-schemas/tools.d.ts.map +1 -0
  181. package/lib/api-schemas/tools.js +122 -0
  182. package/lib/api-schemas/tools.js.map +1 -0
  183. package/lib/api-schemas/user.d.ts +208 -0
  184. package/lib/api-schemas/user.d.ts.map +1 -0
  185. package/lib/api-schemas/user.js +180 -0
  186. package/lib/api-schemas/user.js.map +1 -0
  187. package/lib/api-schemas/view-execution.d.ts +3163 -0
  188. package/lib/api-schemas/view-execution.d.ts.map +1 -0
  189. package/lib/api-schemas/view-execution.js +172 -0
  190. package/lib/api-schemas/view-execution.js.map +1 -0
  191. package/lib/api-schemas/views.d.ts +5990 -0
  192. package/lib/api-schemas/views.d.ts.map +1 -0
  193. package/lib/api-schemas/views.js +396 -0
  194. package/lib/api-schemas/views.js.map +1 -0
  195. package/lib/api-schemas/workflow-runs.d.ts +2209 -0
  196. package/lib/api-schemas/workflow-runs.d.ts.map +1 -0
  197. package/lib/api-schemas/workflow-runs.js +589 -0
  198. package/lib/api-schemas/workflow-runs.js.map +1 -0
  199. package/lib/apikey-values.d.ts +10 -0
  200. package/lib/apikey-values.d.ts.map +1 -0
  201. package/lib/apikey-values.js +11 -0
  202. package/lib/apikey-values.js.map +1 -0
  203. package/lib/apikey.d.ts +37 -36
  204. package/lib/apikey.d.ts.map +1 -1
  205. package/lib/apikey.js +5 -4
  206. package/lib/apikey.js.map +1 -1
  207. package/lib/apps.d.ts +116 -1121
  208. package/lib/apps.d.ts.map +1 -1
  209. package/lib/apps.js.map +1 -1
  210. package/lib/ask-user.d.ts +8 -1
  211. package/lib/ask-user.d.ts.map +1 -1
  212. package/lib/audit-trail.d.ts +17 -128
  213. package/lib/audit-trail.d.ts.map +1 -1
  214. package/lib/audit-trail.js.map +1 -1
  215. package/lib/browser-credentials.d.ts +11 -106
  216. package/lib/browser-credentials.d.ts.map +1 -1
  217. package/lib/common.d.ts +59 -81
  218. package/lib/common.d.ts.map +1 -1
  219. package/lib/cost-analytics.d.ts +14 -167
  220. package/lib/cost-analytics.d.ts.map +1 -1
  221. package/lib/cost-analytics.js.map +1 -1
  222. package/lib/data-platform.d.ts +122 -786
  223. package/lib/data-platform.d.ts.map +1 -1
  224. package/lib/data-platform.js +41 -61
  225. package/lib/data-platform.js.map +1 -1
  226. package/lib/email.d.ts +5 -17
  227. package/lib/email.d.ts.map +1 -1
  228. package/lib/email.js +0 -3
  229. package/lib/email.js.map +1 -1
  230. package/lib/embeddings.d.ts +14 -56
  231. package/lib/embeddings.d.ts.map +1 -1
  232. package/lib/environment.d.ts +19 -113
  233. package/lib/environment.d.ts.map +1 -1
  234. package/lib/environment.js +3 -0
  235. package/lib/environment.js.map +1 -1
  236. package/lib/facets.d.ts +4 -7
  237. package/lib/facets.d.ts.map +1 -1
  238. package/lib/group.d.ts +33 -39
  239. package/lib/group.d.ts.map +1 -1
  240. package/lib/group.js +0 -1
  241. package/lib/group.js.map +1 -1
  242. package/lib/index.d.ts +7 -0
  243. package/lib/index.d.ts.map +1 -1
  244. package/lib/index.js.map +1 -1
  245. package/lib/integrations.d.ts +20 -108
  246. package/lib/integrations.d.ts.map +1 -1
  247. package/lib/integrations.js.map +1 -1
  248. package/lib/interaction-values.d.ts +11 -0
  249. package/lib/interaction-values.d.ts.map +1 -0
  250. package/lib/interaction-values.js +24 -0
  251. package/lib/interaction-values.js.map +1 -0
  252. package/lib/interaction.d.ts +116 -734
  253. package/lib/interaction.d.ts.map +1 -1
  254. package/lib/interaction.js +56 -12
  255. package/lib/interaction.js.map +1 -1
  256. package/lib/meters.d.ts +11 -7
  257. package/lib/meters.d.ts.map +1 -1
  258. package/lib/meters.js.map +1 -1
  259. package/lib/oauth-server.d.ts +33 -119
  260. package/lib/oauth-server.d.ts.map +1 -1
  261. package/lib/oauth.d.ts +14 -96
  262. package/lib/oauth.d.ts.map +1 -1
  263. package/lib/oauth.js +0 -4
  264. package/lib/oauth.js.map +1 -1
  265. package/lib/payload.d.ts +15 -38
  266. package/lib/payload.d.ts.map +1 -1
  267. package/lib/platform-event.d.ts +49 -462
  268. package/lib/platform-event.d.ts.map +1 -1
  269. package/lib/platform-event.js.map +1 -1
  270. package/lib/principal-context.d.ts +10 -15
  271. package/lib/principal-context.d.ts.map +1 -1
  272. package/lib/project-values.d.ts +24 -0
  273. package/lib/project-values.d.ts.map +1 -0
  274. package/lib/project-values.js +42 -0
  275. package/lib/project-values.js.map +1 -0
  276. package/lib/project.d.ts +55 -503
  277. package/lib/project.d.ts.map +1 -1
  278. package/lib/project.js +6 -76
  279. package/lib/project.js.map +1 -1
  280. package/lib/prompt.d.ts +20 -51
  281. package/lib/prompt.d.ts.map +1 -1
  282. package/lib/prompt.js.map +1 -1
  283. package/lib/query.d.ts +27 -88
  284. package/lib/query.d.ts.map +1 -1
  285. package/lib/rate-limiter.d.ts +19 -70
  286. package/lib/rate-limiter.d.ts.map +1 -1
  287. package/lib/rate-limiter.js +0 -3
  288. package/lib/rate-limiter.js.map +1 -1
  289. package/lib/refs.d.ts +3 -11
  290. package/lib/refs.d.ts.map +1 -1
  291. package/lib/refs.js.map +1 -1
  292. package/lib/roles/types.d.ts +14 -20
  293. package/lib/roles/types.d.ts.map +1 -1
  294. package/lib/roles/types.js +5 -9
  295. package/lib/roles/types.js.map +1 -1
  296. package/lib/runs.d.ts +6 -25
  297. package/lib/runs.d.ts.map +1 -1
  298. package/lib/secrets.d.ts +20 -105
  299. package/lib/secrets.d.ts.map +1 -1
  300. package/lib/store/agent-approval.d.ts +5 -14
  301. package/lib/store/agent-approval.d.ts.map +1 -1
  302. package/lib/store/agent-approval.js.map +1 -1
  303. package/lib/store/agent-run.d.ts +63 -342
  304. package/lib/store/agent-run.d.ts.map +1 -1
  305. package/lib/store/collections.d.ts +11 -63
  306. package/lib/store/collections.d.ts.map +1 -1
  307. package/lib/store/collections.js.map +1 -1
  308. package/lib/store/conversation-state.d.ts +63 -61
  309. package/lib/store/conversation-state.d.ts.map +1 -1
  310. package/lib/store/conversation-state.js +2 -0
  311. package/lib/store/conversation-state.js.map +1 -1
  312. package/lib/store/doc-analyzer.d.ts +9 -32
  313. package/lib/store/doc-analyzer.d.ts.map +1 -1
  314. package/lib/store/dsl-workflow.d.ts +37 -151
  315. package/lib/store/dsl-workflow.d.ts.map +1 -1
  316. package/lib/store/dsl-workflow.js.map +1 -1
  317. package/lib/store/editing-policy-schema.generated.d.ts +3 -0
  318. package/lib/store/editing-policy-schema.generated.d.ts.map +1 -0
  319. package/lib/store/editing-policy-schema.generated.js +28 -0
  320. package/lib/store/editing-policy-schema.generated.js.map +1 -0
  321. package/lib/store/grounded-extraction.d.ts +7 -104
  322. package/lib/store/grounded-extraction.d.ts.map +1 -1
  323. package/lib/store/grounded-extraction.js.map +1 -1
  324. package/lib/store/index.d.ts +2 -0
  325. package/lib/store/index.d.ts.map +1 -1
  326. package/lib/store/index.js +3 -0
  327. package/lib/store/index.js.map +1 -1
  328. package/lib/store/intake-policy-schema.generated.d.ts +3 -0
  329. package/lib/store/intake-policy-schema.generated.d.ts.map +1 -0
  330. package/lib/store/intake-policy-schema.generated.js +1425 -0
  331. package/lib/store/intake-policy-schema.generated.js.map +1 -0
  332. package/lib/store/process-schema.d.ts +80 -0
  333. package/lib/store/process-schema.d.ts.map +1 -1
  334. package/lib/store/process-schema.js +79 -0
  335. package/lib/store/process-schema.js.map +1 -1
  336. package/lib/store/process-validation.d.ts.map +1 -1
  337. package/lib/store/process-validation.js +70 -2
  338. package/lib/store/process-validation.js.map +1 -1
  339. package/lib/store/process.d.ts +36 -125
  340. package/lib/store/process.d.ts.map +1 -1
  341. package/lib/store/process.js.map +1 -1
  342. package/lib/store/rendering.d.ts +9 -64
  343. package/lib/store/rendering.d.ts.map +1 -1
  344. package/lib/store/rendering.js.map +1 -1
  345. package/lib/store/store.d.ts +98 -693
  346. package/lib/store/store.d.ts.map +1 -1
  347. package/lib/store/store.js +4 -443
  348. package/lib/store/store.js.map +1 -1
  349. package/lib/store/task.d.ts +15 -59
  350. package/lib/store/task.d.ts.map +1 -1
  351. package/lib/store/task.js +0 -3
  352. package/lib/store/task.js.map +1 -1
  353. package/lib/store/workflow.d.ts +56 -516
  354. package/lib/store/workflow.d.ts.map +1 -1
  355. package/lib/store/workflow.js +28 -11
  356. package/lib/store/workflow.js.map +1 -1
  357. package/lib/sts-token-types.d.ts +12 -66
  358. package/lib/sts-token-types.d.ts.map +1 -1
  359. package/lib/sts-token-types.js.map +1 -1
  360. package/lib/tools.d.ts +8 -100
  361. package/lib/tools.d.ts.map +1 -1
  362. package/lib/transient-tokens-values.d.ts +11 -0
  363. package/lib/transient-tokens-values.d.ts.map +1 -0
  364. package/lib/transient-tokens-values.js +12 -0
  365. package/lib/transient-tokens-values.js.map +1 -0
  366. package/lib/transient-tokens.d.ts +15 -13
  367. package/lib/transient-tokens.d.ts.map +1 -1
  368. package/lib/transient-tokens.js +5 -5
  369. package/lib/transient-tokens.js.map +1 -1
  370. package/lib/user.d.ts +54 -155
  371. package/lib/user.d.ts.map +1 -1
  372. package/lib/user.js +1 -78
  373. package/lib/user.js.map +1 -1
  374. package/lib/versions.d.ts +24 -1
  375. package/lib/versions.d.ts.map +1 -1
  376. package/lib/versions.js +23 -0
  377. package/lib/versions.js.map +1 -1
  378. package/lib/vertesia-common.js +6 -2
  379. package/lib/vertesia-common.js.map +1 -1
  380. package/lib/views-schema.d.ts +4 -4
  381. package/lib/views.d.ts +56 -312
  382. package/lib/views.d.ts.map +1 -1
  383. package/lib/views.js.map +1 -1
  384. package/package.json +14 -5
  385. package/src/access-control-values.ts +113 -0
  386. package/src/access-control.ts +33 -138
  387. package/src/account-values.ts +95 -0
  388. package/src/agent-resources.test.ts +100 -0
  389. package/src/analytics.ts +18 -42
  390. package/src/api-schemas/access-control.contract.test.ts +209 -0
  391. package/src/api-schemas/access-control.ts +208 -0
  392. package/src/api-schemas/account.contract.test.ts +318 -0
  393. package/src/api-schemas/account.ts +150 -0
  394. package/src/api-schemas/adapter-edge-cases.test.ts +480 -0
  395. package/src/api-schemas/adapter.ts +778 -0
  396. package/src/api-schemas/agent-runs.ts +1081 -0
  397. package/src/api-schemas/analytics.ts +65 -0
  398. package/src/api-schemas/apikey.contract.test.ts +270 -0
  399. package/src/api-schemas/apikey.ts +199 -0
  400. package/src/api-schemas/app-lifecycle.ts +841 -0
  401. package/src/api-schemas/app-runtime.ts +919 -0
  402. package/src/api-schemas/apps.ts +415 -0
  403. package/src/api-schemas/audit-trail.ts +243 -0
  404. package/src/api-schemas/bulk-operation.contract.test.ts +39 -0
  405. package/src/api-schemas/bulk-operation.ts +75 -0
  406. package/src/api-schemas/bundle-isolation.test.ts +80 -0
  407. package/src/api-schemas/commands.contract.test.ts +51 -0
  408. package/src/api-schemas/commands.ts +62 -0
  409. package/src/api-schemas/content.ts +939 -0
  410. package/src/api-schemas/cost-analytics.contract.test.ts +64 -0
  411. package/src/api-schemas/cost-analytics.ts +235 -0
  412. package/src/api-schemas/dashboard.contract.test.ts +127 -0
  413. package/src/api-schemas/dashboard.ts +351 -0
  414. package/src/api-schemas/data-store.contract.test.ts +91 -0
  415. package/src/api-schemas/data-store.ts +571 -0
  416. package/src/api-schemas/document-processing.contract.test.ts +76 -0
  417. package/src/api-schemas/document-processing.ts +344 -0
  418. package/src/api-schemas/embeddings.ts +113 -0
  419. package/src/api-schemas/environment.contract.test.ts +184 -0
  420. package/src/api-schemas/environment.ts +190 -0
  421. package/src/api-schemas/events.ts +921 -0
  422. package/src/api-schemas/files.ts +159 -0
  423. package/src/api-schemas/group.contract.test.ts +205 -0
  424. package/src/api-schemas/group.ts +155 -0
  425. package/src/api-schemas/index.ts +35 -0
  426. package/src/api-schemas/indexing.contract.test.ts +83 -0
  427. package/src/api-schemas/indexing.ts +234 -0
  428. package/src/api-schemas/integrations.ts +369 -0
  429. package/src/api-schemas/interaction.ts +2357 -0
  430. package/src/api-schemas/invites.contract.test.ts +268 -0
  431. package/src/api-schemas/invites.ts +127 -0
  432. package/src/api-schemas/llumiverse.contract.test.ts +108 -0
  433. package/src/api-schemas/oauth-server.ts +219 -0
  434. package/src/api-schemas/oauth.contract.test.ts +118 -0
  435. package/src/api-schemas/oauth.ts +166 -0
  436. package/src/api-schemas/parameters.test.ts +402 -0
  437. package/src/api-schemas/parameters.ts +310 -0
  438. package/src/api-schemas/process.ts +929 -0
  439. package/src/api-schemas/project-configuration.ts +478 -0
  440. package/src/api-schemas/project.contract.test.ts +365 -0
  441. package/src/api-schemas/project.ts +214 -0
  442. package/src/api-schemas/prompt.ts +88 -0
  443. package/src/api-schemas/pruning-limits.test.ts +189 -0
  444. package/src/api-schemas/quota.contract.test.ts +147 -0
  445. package/src/api-schemas/quota.ts +122 -0
  446. package/src/api-schemas/registry-groups.test.ts +91 -0
  447. package/src/api-schemas/registry.ts +3487 -0
  448. package/src/api-schemas/response-pruning.test.ts +260 -0
  449. package/src/api-schemas/schema-primitives.ts +12 -0
  450. package/src/api-schemas/secrets.ts +332 -0
  451. package/src/api-schemas/store.contract.test.ts +450 -0
  452. package/src/api-schemas/store.ts +604 -0
  453. package/src/api-schemas/sts.contract.test.ts +80 -0
  454. package/src/api-schemas/sts.ts +110 -0
  455. package/src/api-schemas/task.ts +104 -0
  456. package/src/api-schemas/tools.ts +140 -0
  457. package/src/api-schemas/user.contract.test.ts +191 -0
  458. package/src/api-schemas/user.ts +204 -0
  459. package/src/api-schemas/view-execution.ts +200 -0
  460. package/src/api-schemas/views.ts +437 -0
  461. package/src/api-schemas/workflow-runs.ts +653 -0
  462. package/src/apikey-values.ts +10 -0
  463. package/src/apikey.ts +49 -40
  464. package/src/apps.ts +249 -1179
  465. package/src/ask-user.ts +9 -1
  466. package/src/audit-trail.ts +45 -137
  467. package/src/browser-credentials.ts +21 -106
  468. package/src/common.ts +67 -78
  469. package/src/cost-analytics.ts +37 -176
  470. package/src/data-platform.ts +205 -776
  471. package/src/email.ts +5 -17
  472. package/src/embeddings.ts +22 -60
  473. package/src/environment.ts +52 -124
  474. package/src/facets.ts +4 -7
  475. package/src/group.ts +38 -42
  476. package/src/index.ts +11 -0
  477. package/src/integrations.ts +39 -129
  478. package/src/interaction-values.ts +23 -0
  479. package/src/interaction.ts +231 -841
  480. package/src/meters.ts +11 -7
  481. package/src/oauth-server.ts +58 -127
  482. package/src/oauth.ts +24 -108
  483. package/src/payload.ts +25 -40
  484. package/src/platform-event.ts +98 -484
  485. package/src/principal-context.ts +11 -15
  486. package/src/project-values.ts +41 -0
  487. package/src/project.ts +116 -588
  488. package/src/prompt.ts +34 -61
  489. package/src/query.ts +34 -93
  490. package/src/rate-limiter.ts +27 -75
  491. package/src/refs.ts +4 -11
  492. package/src/roles/types.ts +20 -20
  493. package/src/runs.ts +11 -24
  494. package/src/secrets.ts +38 -117
  495. package/src/store/agent-approval.ts +9 -14
  496. package/src/store/agent-run.ts +106 -434
  497. package/src/store/collections.ts +21 -63
  498. package/src/store/content-type-editing.test.ts +17 -0
  499. package/src/store/conversation-state.ts +78 -64
  500. package/src/store/doc-analyzer.ts +17 -33
  501. package/src/store/dsl-workflow.ts +62 -158
  502. package/src/store/editing-policy-schema.generated.ts +30 -0
  503. package/src/store/grounded-extraction.ts +13 -104
  504. package/src/store/index.ts +3 -0
  505. package/src/store/intake-policy-schema.generated.ts +1442 -0
  506. package/src/store/process-schema.test.ts +43 -0
  507. package/src/store/process-schema.ts +79 -0
  508. package/src/store/process-validation.test.ts +141 -0
  509. package/src/store/process-validation.ts +82 -2
  510. package/src/store/process.ts +70 -146
  511. package/src/store/rendering.ts +15 -64
  512. package/src/store/store.ts +197 -1182
  513. package/src/store/task.ts +25 -59
  514. package/src/store/workflow.ts +103 -554
  515. package/src/sts-token-types.ts +24 -75
  516. package/src/tools.ts +18 -97
  517. package/src/transient-tokens-values.ts +11 -0
  518. package/src/transient-tokens.ts +16 -13
  519. package/src/user.ts +74 -214
  520. package/src/versions.ts +24 -0
  521. package/src/views-schema.test.ts +9 -1
  522. package/src/views.ts +106 -329
@@ -0,0 +1,2357 @@
1
+ import {
2
+ CompletionResultSchema,
3
+ ExecutionTokenUsageSchema,
4
+ JSONObjectSchema,
5
+ JSONSchemaSchema,
6
+ ModalitiesSchema,
7
+ ModelOptionsSchema,
8
+ PromptRoleSchema,
9
+ StatelessExecutionOptionsSchema,
10
+ ToolDefinitionSchema,
11
+ ToolUseSchema,
12
+ } from '@llumiverse/common/schemas';
13
+ import { z } from 'zod';
14
+ import {
15
+ AgentSearchScope,
16
+ ExecutionRunStatus,
17
+ InteractionStatus,
18
+ ModelSource,
19
+ RunSourceTypes,
20
+ } from '../interaction.js';
21
+ import { PromptSegmentDefType, PromptStatus, TemplateType } from '../prompt.js';
22
+ import { AgentToolApprovalModes } from '../store/agent-approval.js';
23
+ import { LlmCallType } from '../workflow-analytics.js';
24
+ import { ProjectRefSchema } from './apikey.js';
25
+ import { ExecutionEnvironmentRefSchema } from './environment.js';
26
+ import { AccountRefSchema } from './invites.js';
27
+ import { AgentCheckpointConfigurationSchema } from './project-configuration.js';
28
+ import { InteractionExecutionConfigurationSchema, RunDataStorageLevelSchema } from './store.js';
29
+
30
+ /**
31
+ * Interactions, their prompts, and the runs they produce.
32
+ *
33
+ * Declaration order is dependency order — a schema referenced by another is declared before it —
34
+ * which is why this file does not read alphabetically.
35
+ */
36
+
37
+ export const SortOrderSchema = z.enum(['asc', 'desc']).meta({ id: 'SortOrder' });
38
+
39
+ export const ExecutionRunStatusSchema = z.enum(ExecutionRunStatus).meta({ id: 'ExecutionRunStatus' });
40
+
41
+ export const FacetSpecSchema = z
42
+ .strictObject({
43
+ name: z.string(),
44
+ field: z.string(),
45
+ })
46
+ .meta({ id: 'FacetSpec' });
47
+
48
+ export const AsyncCompletionModeSchema = z.enum(['conversation_state', 'text']).meta({ id: 'AsyncCompletionMode' });
49
+
50
+ export const ResultStorageOptionsSchema = z
51
+ .strictObject({
52
+ path: z.string().meta({ description: 'Full storage path for the result (e.g., "pages/doc123/page-1.md")' }),
53
+ })
54
+ .meta({ id: 'ResultStorageOptions', description: 'Options for storing inference results to cloud storage' });
55
+
56
+ export const LlmCallTypeSchema = z
57
+ .enum(LlmCallType)
58
+ .meta({ id: 'LlmCallType', description: 'Types of LLM calls in a conversation' });
59
+
60
+ export const PendingMcpConnectionSchema = z
61
+ .strictObject({
62
+ app_install_id: z
63
+ .string()
64
+ .meta({ description: 'The app installation id owning the collection (used for OAuth operations).' }),
65
+ collection_id: z.string().meta({ description: 'The MCP tool-collection id.' }),
66
+ name: z.string().meta({ description: 'Human-readable label for the server/collection.' }),
67
+ description: z
68
+ .string()
69
+ .meta({ description: 'Manifest description of what the server provides (used for discovery).' })
70
+ .optional(),
71
+ namespace: z.string().meta({ description: 'Tool-name prefix for this collection.' }).optional(),
72
+ })
73
+ .meta({
74
+ id: 'PendingMcpConnection',
75
+ description:
76
+ "An MCP server the user can connect to but hasn't yet (active + accessible, no OAuth token). Built at tool-discovery time and stored on the conversation state so the agent can discover it (by description) and ask the user to connect.",
77
+ });
78
+
79
+ export const ModelSourceSchema = z
80
+ .enum(ModelSource)
81
+ .meta({ id: 'ModelSource', description: 'Source of the resolved model configuration' });
82
+
83
+ export const ResolvedEnvironmentInfoSchema = z
84
+ .strictObject({
85
+ id: z.string(),
86
+ name: z.string(),
87
+ provider: z.string(),
88
+ })
89
+ .meta({ id: 'ResolvedEnvironmentInfo', description: 'Resolved environment information' });
90
+
91
+ // `z.literal(AgentSearchScope.Collection)`, not `z.literal('collection')`: the published component
92
+ // is a `const`, and reading the value off the enum keeps the inferred type the enum member so
93
+ // callers assigning `AgentSearchScope.Collection` still type-check.
94
+ export const AgentSearchScopeSchema = z
95
+ .literal(AgentSearchScope.Collection)
96
+ .meta({ id: 'AgentSearchScope', description: 'Defines the scope for agent search operations.' });
97
+
98
+ export const SkillContextTriggersSchema = z
99
+ .strictObject({
100
+ keywords: z
101
+ .array(z.string())
102
+ .meta({ description: 'Keywords in user input that should trigger this skill' })
103
+ .optional(),
104
+ tool_names: z
105
+ .array(z.string())
106
+ .meta({ description: 'If these tools are being used, suggest this skill' })
107
+ .optional(),
108
+ data_patterns: z
109
+ .array(z.string())
110
+ .meta({ description: 'Regex patterns to match against input data' })
111
+ .optional(),
112
+ })
113
+ .meta({
114
+ id: 'SkillContextTriggers',
115
+ description:
116
+ 'Context triggers for auto-injection of skills. When these conditions match, the skill is automatically injected into the agent context.',
117
+ });
118
+
119
+ export const InteractionStatusSchema = z.enum(InteractionStatus).meta({ id: 'InteractionStatus' });
120
+
121
+ export const InteractiveChannelSchema = z
122
+ .strictObject({
123
+ type: z.literal('interactive'),
124
+ })
125
+ .meta({
126
+ id: 'InteractiveChannel',
127
+ description: 'Interactive (UI chat) channel configuration. Used for real-time chat interface communication.',
128
+ });
129
+
130
+ export const EmailChannelSchema = z
131
+ .strictObject({
132
+ type: z.literal('email'),
133
+ to_email: z.string().meta({ description: 'Email address to send agent messages to' }),
134
+ thread_subject: z
135
+ .string()
136
+ .meta({ description: 'Subject for the email thread (without "Re:" prefix)' })
137
+ .optional(),
138
+ in_reply_to: z
139
+ .string()
140
+ .meta({ description: 'Message ID for In-Reply-To header (most recent message)' })
141
+ .optional(),
142
+ references: z.array(z.string()).meta({ description: 'Chain of message IDs for References header' }).optional(),
143
+ route_key: z
144
+ .string()
145
+ .meta({ description: 'Short routing key for reply emails (8-char alphanumeric, stored in Redis)' })
146
+ .optional(),
147
+ })
148
+ .meta({
149
+ id: 'EmailChannel',
150
+ description: 'Email channel configuration with threading support. Used for email-based agent communication.',
151
+ });
152
+
153
+ export const UsedSkillSchema = z
154
+ .strictObject({
155
+ name: z.string().meta({ description: 'Skill name (e.g., "analyze_data")' }),
156
+ src: z.string().meta({
157
+ description:
158
+ 'Source URL of the skill collection (e.g., "https://tools.vertesia.io/api/skills/data-analysis")',
159
+ }),
160
+ language: z.string().meta({ description: 'Programming language (e.g., "python")' }).optional(),
161
+ packages: z.array(z.string()).meta({ description: 'Required packages (e.g., ["pandas", "numpy"])' }).optional(),
162
+ system_packages: z
163
+ .array(z.string())
164
+ .meta({ description: 'System-level packages to install via sudo apt-get (e.g., ["poppler-utils"])' })
165
+ .optional(),
166
+ })
167
+ .meta({ id: 'UsedSkill', description: 'Skill metadata tracked when a skill is used' });
168
+
169
+ export const ToolReferenceSchema = z
170
+ .strictObject({
171
+ storage_key: z.string(),
172
+ tool_count: z.number(),
173
+ stored_at: z.string(),
174
+ })
175
+ .meta({
176
+ id: 'ToolReference',
177
+ description:
178
+ 'Lightweight tool reference for activity payloads. References tools stored in GCP instead of embedding full tool definitions.',
179
+ });
180
+
181
+ export const ConversationStripOptionsSchema = z
182
+ .strictObject({
183
+ images_after_turns: z
184
+ .number()
185
+ .meta({
186
+ description:
187
+ 'Number of turns to keep images before stripping them.\n- 0: Strip images immediately after each turn\n- N > 0: Keep images for N turns before stripping (default: 5)\n- Infinity: Never strip images',
188
+ })
189
+ .optional(),
190
+ text_max_tokens: z
191
+ .number()
192
+ .meta({
193
+ description:
194
+ 'Maximum tokens for text content before truncation. Text content exceeding this limit will be truncated with a marker. Uses ~4 characters per token estimate.',
195
+ })
196
+ .optional(),
197
+ heartbeats_after_turns: z
198
+ .number()
199
+ .meta({
200
+ description:
201
+ 'Number of turns to keep heartbeat messages before stripping them. Heartbeat messages are periodic workstream status updates wrapped in `<heartbeat>...</heartbeat>` tags that clutter conversation history.\n- 0: Strip heartbeats immediately after each turn\n- 1 (default): Keep only the most recent heartbeat\n- N > 0: Keep heartbeats for N turns before stripping\n- Infinity: Never strip heartbeats',
202
+ })
203
+ .optional(),
204
+ })
205
+ .meta({
206
+ id: 'ConversationStripOptions',
207
+ description:
208
+ 'Configuration for stripping large data from conversation history to prevent JSON serialization issues and reduce storage bloat.',
209
+ });
210
+
211
+ export const PlanTaskSchema = z
212
+ .strictObject({
213
+ id: z.number(),
214
+ goal: z.string(),
215
+ instructions: z.array(z.string()).optional(),
216
+ comment: z.string().optional(),
217
+ status: z.enum(['pending', 'in_progress', 'completed', 'skipped']).optional(),
218
+ })
219
+ .meta({ id: 'PlanTask' });
220
+
221
+ export const WorkflowAncestorSchema = z
222
+ .strictObject({
223
+ run_id: z.string(),
224
+ workflow_id: z.string(),
225
+ run_depth: z.number().meta({ description: 'the depth of nested parent workflows' }),
226
+ })
227
+ .meta({ id: 'WorkflowAncestor' });
228
+
229
+ export const TextArtifactReferenceSchema = z
230
+ .strictObject({
231
+ storage_id: z.string(),
232
+ artifact_path: z.string(),
233
+ display_ref: z.string(),
234
+ sha256: z.string(),
235
+ size_bytes: z.number(),
236
+ content_type: z.string(),
237
+ })
238
+ .meta({
239
+ id: 'TextArtifactReference',
240
+ description: 'Reference to text content externalized to agent artifact storage.',
241
+ });
242
+
243
+ export const AgentResourceActionSchema = z.enum(['created', 'updated', 'deleted']).meta({ id: 'AgentResourceAction' });
244
+
245
+ export const AgentResourceTypeSchema = z
246
+ .enum([
247
+ 'document',
248
+ 'collection',
249
+ 'content_type',
250
+ 'interaction',
251
+ 'prompt',
252
+ 'agent',
253
+ 'workflow',
254
+ 'process',
255
+ 'process_run',
256
+ 'interaction_run',
257
+ 'view',
258
+ ])
259
+ .meta({
260
+ id: 'AgentResourceType',
261
+ description:
262
+ 'The kinds of Vertesia resource an agent tool can report having created, updated, or deleted. Restricted to resources that have a real detail route to navigate to — do not emit a reference for a mutation with no meaningful navigation target. Add new kinds only once their route exists.',
263
+ });
264
+
265
+ export const ToolApprovalGrantSchema = z
266
+ .strictObject({
267
+ key: z.string(),
268
+ tool_name: z.string(),
269
+ target: z.string().optional(),
270
+ granted_at: z.string(),
271
+ })
272
+ .meta({ id: 'ToolApprovalGrant' });
273
+
274
+ // Reads its members off the const array rather than restating them, the way `SupportedProviders`
275
+ // does: `AgentToolApprovalModes` is iterated at runtime, so a second list here would be a copy that
276
+ // compiles.
277
+ export const AgentToolApprovalModeSchema = z.enum(AgentToolApprovalModes).meta({ id: 'AgentToolApprovalMode' });
278
+
279
+ export const ExecutionRunDocRefSchema = z
280
+ .strictObject({
281
+ id: z.string(),
282
+ account: z.string(),
283
+ project: z.string(),
284
+ })
285
+ .meta({ id: 'ExecutionRunDocRef', description: 'The run ref is used to identify a run document in the storage' });
286
+
287
+ export const StreamingOptionsSchema = z
288
+ .strictObject({
289
+ redis_channel: z.string().meta({ description: 'Redis channel to publish streaming chunks to' }),
290
+ workstream_id: z
291
+ .string()
292
+ .meta({ description: 'Optional workstream ID for multi-workstream agents' })
293
+ .optional(),
294
+ })
295
+ .meta({ id: 'StreamingOptions', description: 'Streaming-specific options (only needed when stream=true)' });
296
+
297
+ export const TemplateTypeSchema = z.enum(TemplateType).meta({ id: 'TemplateType' });
298
+
299
+ export const ExecutionRunWorkflowSchema = z
300
+ .strictObject({
301
+ rate_limit_id: z
302
+ .string()
303
+ .meta({
304
+ description:
305
+ 'Stable identifier pairing an interaction rate-limit admission with its completion feedback.',
306
+ })
307
+ .optional(),
308
+ run_id: z.string().meta({
309
+ description:
310
+ 'The Temporal Workflow Run ID related to this Interaction Run.\n\nA Run ID is a globally unique, platform-level identifier for a Workflow Execution.\n\nDeprecated: For agent runs, use the Agent Runs API (`/api/v1/agents`) instead.\nThe AgentRun object provides a stable ID that survives workflow restarts.\nThis field is only relevant for legacy non-agent interaction executions.',
311
+ deprecated: true,
312
+ 'x-deprecated-message':
313
+ 'For agent runs, use the Agent Runs API (`/api/v1/agents`) instead.\nThe AgentRun object provides a stable ID that survives workflow restarts.\nThis field is only relevant for legacy non-agent interaction executions.',
314
+ }),
315
+ workflow_id: z.string().meta({
316
+ description:
317
+ 'The Temporal Workflow ID related to this Interaction Run.\n\nDeprecated: For agent runs, use the Agent Runs API (`/api/v1/agents`) instead.\nThe AgentRun object provides a stable ID that survives workflow restarts.\nThis field is only relevant for legacy non-agent interaction executions.',
318
+ deprecated: true,
319
+ 'x-deprecated-message':
320
+ 'For agent runs, use the Agent Runs API (`/api/v1/agents`) instead.\nThe AgentRun object provides a stable ID that survives workflow restarts.\nThis field is only relevant for legacy non-agent interaction executions.',
321
+ }),
322
+ activity_type: z
323
+ .string()
324
+ .meta({
325
+ description:
326
+ 'The Temporal Activity Type used for executing this Interaction. Undefined if the interaction was not executed as part of a workflow (such as Agent Runner).',
327
+ })
328
+ .optional(),
329
+ })
330
+ .meta({ id: 'ExecutionRunWorkflow' });
331
+
332
+ export const SchemaRefSchema = z
333
+ .strictObject({
334
+ $uri: z.string(),
335
+ })
336
+ .meta({
337
+ id: 'SchemaRef',
338
+ description:
339
+ 'Schema can be stored or specified as a reference to an external schema. We only support "store:" references for now',
340
+ });
341
+
342
+ export const RateLimitRequestResponseSchema = z
343
+ .strictObject({
344
+ delay_ms: z.number(),
345
+ })
346
+ .meta({ id: 'RateLimitRequestResponse' });
347
+
348
+ export const PromptModalitiesSchema = z
349
+ .strictObject({
350
+ hasVideo: z.boolean(),
351
+ hasImage: z.boolean(),
352
+ })
353
+ .meta({ id: 'PromptModalities' });
354
+
355
+ export const PromptStatusSchema = z.enum(PromptStatus).meta({ id: 'PromptStatus' });
356
+
357
+ export const PromptSegmentDefTypeSchema = z.enum(PromptSegmentDefType).meta({ id: 'PromptSegmentDefType' });
358
+
359
+ export const InteractionVisibilitySchema = z.enum(['public', 'private']).meta({ id: 'InteractionVisibility' });
360
+
361
+ export const RunSourceTypesSchema = z.enum(RunSourceTypes).meta({ id: 'RunSourceTypes' });
362
+
363
+ export const InteractionExecutionErrorSchema = z
364
+ .strictObject({
365
+ code: z.string(),
366
+ message: z.string(),
367
+ data: z.unknown().optional(),
368
+ retryable: z.boolean().optional(),
369
+ retry_after_ms: z
370
+ .number()
371
+ .meta({
372
+ description: 'Provider-supplied retry delay preserved across synchronous and async workflow execution.',
373
+ })
374
+ .optional(),
375
+ })
376
+ .meta({ id: 'InteractionExecutionError' });
377
+
378
+ export const NumberValueMapSchema = z.object({}).catchall(z.number()).meta({ id: 'NumberValueMap' });
379
+
380
+ export const InteractionsExportPayloadSchema = z
381
+ .strictObject({
382
+ name: z
383
+ .string()
384
+ .meta({
385
+ description:
386
+ 'The name of the interaction. If not specified all the interactions in the current project will be exported',
387
+ })
388
+ .optional(),
389
+ tags: z.array(z.string()).optional(),
390
+ versions: z.array(z.union([z.number(), z.literal('draft'), z.literal('latest')])).optional(),
391
+ })
392
+ .meta({ id: 'InteractionsExportPayload' });
393
+
394
+ export const PromptTemplateSchema = z
395
+ .strictObject({
396
+ role: PromptRoleSchema,
397
+ content: z.string(),
398
+ content_type: TemplateTypeSchema,
399
+ inputSchema: JSONSchemaSchema.optional(),
400
+ id: z.string(),
401
+ name: z.string(),
402
+ status: PromptStatusSchema,
403
+ version: z.number(),
404
+ // The record this one was derived from. On a published version it is the draft it was
405
+ // published from; on a fork it is the prompt that was forked, and the fork is itself a
406
+ // draft. So `parent` alone does not tell you which kind of record this is — read `status`.
407
+ parent: z.string().optional(),
408
+ description: z.string().optional(),
409
+ // optional test data satisfying the schema
410
+ test_data: JSONObjectSchema.optional(),
411
+ // cache the template output
412
+ script: z.string().optional(),
413
+ project: z.union([z.string(), ProjectRefSchema]),
414
+ tags: z.array(z.string()).optional(),
415
+ // only for drafts — when it was last published
416
+ last_published_at: z.string().meta({ format: 'date-time' }).optional(),
417
+ created_by: z.string(),
418
+ updated_by: z.string(),
419
+ created_at: z.string().meta({ format: 'date-time' }),
420
+ updated_at: z.string().meta({ format: 'date-time' }),
421
+ })
422
+ .meta({ id: 'PromptTemplate' });
423
+
424
+ // The two payloads are projections of `PromptTemplate`, so they are derived from its canonical Zod
425
+ // schema here. Leaving them as TypeScript utility types would give the generator only aliases with
426
+ // no runtime properties to publish.
427
+ const SERVER_OWNED_PROMPT_FIELDS = ['id', 'created_at', 'updated_at', 'created_by', 'updated_by', 'project'] as const;
428
+ const SERVER_OWNED_PROMPT_FIELD_KEYS = Object.fromEntries(
429
+ SERVER_OWNED_PROMPT_FIELDS.map((field) => [field, true as const]),
430
+ ) as Record<(typeof SERVER_OWNED_PROMPT_FIELDS)[number], true>;
431
+
432
+ // Keep the published property order stable. OpenAPI Generator uses it for required Go constructor
433
+ // arguments. Zod's `.pick()` builds the projected shape in mask order, whereas `.omit()` preserves
434
+ // the full response model's order and would change this constructor when that model is reorganized.
435
+ export const PromptTemplateCreatePayloadSchema = PromptTemplateSchema.pick({
436
+ name: true,
437
+ parent: true,
438
+ description: true,
439
+ test_data: true,
440
+ script: true,
441
+ tags: true,
442
+ last_published_at: true,
443
+ role: true,
444
+ content: true,
445
+ content_type: true,
446
+ inputSchema: true,
447
+ }).meta({ id: 'PromptTemplateCreatePayload' });
448
+
449
+ export const PromptTemplateUpdatePayloadSchema = PromptTemplateSchema.omit(SERVER_OWNED_PROMPT_FIELD_KEYS)
450
+ .partial()
451
+ .meta({ id: 'PromptTemplateUpdatePayload' });
452
+
453
+ export const CachePolicySchema = z
454
+ .strictObject({
455
+ type: z.enum(['cache', 'no_cache', 'cache_and_refresh']),
456
+ refresh_probability: z.number(),
457
+ varies_on: z.array(z.string()),
458
+ ttl: z.number(),
459
+ })
460
+ .meta({ id: 'CachePolicy' });
461
+
462
+ export const InteractionPublishPayloadSchema = z
463
+ .strictObject({
464
+ visibility: InteractionVisibilitySchema.optional(),
465
+ tags: z.array(z.string()).optional(),
466
+ })
467
+ .meta({ id: 'InteractionPublishPayload' });
468
+
469
+ export const InteractionForkPayloadSchema = z
470
+ .strictObject({
471
+ keepTags: z.boolean().optional(),
472
+ forkPrompts: z.boolean().optional(),
473
+ targetProject: z.string().optional(),
474
+ })
475
+ .meta({ id: 'InteractionForkPayload' });
476
+
477
+ export const InteractionEndpointQuerySchema = z
478
+ .strictObject({
479
+ limit: z.number().optional(),
480
+ offset: z.number().optional(),
481
+ status: InteractionStatusSchema.optional(),
482
+ visibility: InteractionVisibilitySchema.optional(),
483
+ version: z.number().optional(),
484
+ tags: z.array(z.string()).optional(),
485
+ includes: z
486
+ .array(z.string())
487
+ .meta({
488
+ description:
489
+ 'Filter by interaction endpoint name to include only the specified endpoints\n* If both includes and excludes are specified then only the includes filter will be used.',
490
+ })
491
+ .optional(),
492
+ excludes: z
493
+ .array(z.string())
494
+ .meta({
495
+ description:
496
+ 'Filter by interaction endpoint name to excludes the specified endpoints. If both includes and excludes are specified then only the includes filter will be used.',
497
+ })
498
+ .optional(),
499
+ include_params_schema: z
500
+ .boolean()
501
+ .meta({
502
+ description:
503
+ 'Whether or not to return the parameters schema. The parameters schema is an array of JSON schemas. Each schema is a JSON schema that describes the parameters of an interaction prompt.',
504
+ })
505
+ .optional(),
506
+ include_result_schema: z
507
+ .boolean()
508
+ .meta({ description: 'Whether or not to return the result schema' })
509
+ .optional(),
510
+ is_skill: z
511
+ .boolean()
512
+ .meta({ description: 'When true, filter results to only interactions with is_skill=true.' })
513
+ .optional(),
514
+ })
515
+ .meta({ id: 'InteractionEndpointQuery', description: 'The payload to query the interaction endpoints' });
516
+
517
+ export const ImprovePromptPayloadConfigSchema = z
518
+ .strictObject({
519
+ config: InteractionExecutionConfigurationSchema,
520
+ })
521
+ .meta({ id: 'ImprovePromptPayloadConfig' });
522
+
523
+ export const ImprovePromptPayloadSchema = z
524
+ .strictObject({
525
+ config: InteractionExecutionConfigurationSchema,
526
+ interaction_name: z.string(),
527
+ context: z.string().optional(),
528
+ prompt: z.array(
529
+ z.strictObject({
530
+ name: z.string(),
531
+ content: z.string(),
532
+ }),
533
+ ),
534
+ result_schema: JSONSchemaSchema.optional(),
535
+ })
536
+ .meta({ id: 'ImprovePromptPayload' });
537
+
538
+ export const GeneratedTestDataRecordSchema = z.object({}).catchall(z.unknown()).meta({ id: 'GeneratedTestDataRecord' });
539
+
540
+ export const GeneratedInteractionPromptTemplateSchema = z
541
+ .strictObject({
542
+ role: z.enum(['safety', 'system', 'user']),
543
+ name: z.string(),
544
+ content: z.string(),
545
+ content_type: z.literal('jst'),
546
+ inputSchema: JSONSchemaSchema,
547
+ })
548
+ .meta({ id: 'GeneratedInteractionPromptTemplate' });
549
+
550
+ export const GenerateTestDataPayloadSchema = z
551
+ .strictObject({
552
+ message: z.string().optional(),
553
+ count: z.number().optional(),
554
+ config: InteractionExecutionConfigurationSchema,
555
+ })
556
+ .meta({ id: 'GenerateTestDataPayload' });
557
+
558
+ export const GenerateInteractionPayloadSchema = z
559
+ .strictObject({
560
+ description: z.string(),
561
+ config: InteractionExecutionConfigurationSchema,
562
+ })
563
+ .meta({ id: 'GenerateInteractionPayload' });
564
+
565
+ export const InteractionSearchQuerySchema = z
566
+ .strictObject({
567
+ name: z.string().optional(),
568
+ status: z.array(z.string()).optional(),
569
+ limit: z.number().optional(),
570
+ offset: z.number().optional(),
571
+ prompt: z.string().optional(),
572
+ tags: z.array(z.string()).optional(),
573
+ version: z.string().optional(),
574
+ model: z.string().optional(),
575
+ environment: z.string().optional(),
576
+ is_agent: z.boolean().optional(),
577
+ is_tool: z.boolean().optional(),
578
+ is_skill: z.boolean().optional(),
579
+ is_basic: z.boolean().optional(),
580
+ is_sub_agent: z.boolean().optional(),
581
+ })
582
+ .meta({ id: 'InteractionSearchQuery' });
583
+
584
+ export const AsyncExecutionResultSchema = z
585
+ .strictObject({
586
+ runId: z.string(),
587
+ workflowId: z.string(),
588
+ agentRunId: z.string().optional(),
589
+ })
590
+ .meta({ id: 'AsyncExecutionResult' });
591
+
592
+ // The same `const` as `AgentSearchScope`, published under a second name because the scanner names an
593
+ // indexed access into an enum this way. Reads the value off the enum for the same reason.
594
+ export const AgentSearchScope_CollectionSchema = z
595
+ .literal(AgentSearchScope.Collection)
596
+ .meta({ id: 'AgentSearchScope_Collection', description: 'Search is scoped to a specific collection.' });
597
+
598
+ export const InitialToolCallSchema = z
599
+ .strictObject({
600
+ id: z.string().meta({ description: 'Stable identifier used to make initialization replay-safe.' }),
601
+ tool: z.string().meta({
602
+ description:
603
+ 'Read-only builtin activity tool name. Skills are configured separately through initial_skills.',
604
+ }),
605
+ input: z.looseObject({}).meta({ description: 'Tool input parameters.' }).optional(),
606
+ on_error: z
607
+ .enum(['fail', 'continue'])
608
+ .meta({ description: 'Whether a failed initialization call aborts the conversation start.' })
609
+ .optional(),
610
+ })
611
+ .meta({
612
+ id: 'InitialToolCall',
613
+ description:
614
+ 'A tool invocation executed before the first model turn of a conversation. Results are injected into the initial context so the agent starts with them in hand.',
615
+ });
616
+
617
+ export const ConversationVisibilitySchema = z.enum(['private', 'project']).meta({ id: 'ConversationVisibility' });
618
+
619
+ export const SortOptionSchema = z
620
+ .strictObject({
621
+ field: z
622
+ .string()
623
+ .meta({ description: "Field path to sort by (e.g. 'updated_at', 'name', 'properties.title')" }),
624
+ order: SortOrderSchema.meta({ description: "Sort direction. Defaults to 'desc'." }).optional(),
625
+ })
626
+ .meta({ id: 'SortOption' });
627
+
628
+ export const RunSearchQuerySchema = z
629
+ .strictObject({
630
+ name: z.string().optional(),
631
+ status: ExecutionRunStatusSchema.optional(),
632
+ limit: z.number().optional(),
633
+ offset: z.number().optional(),
634
+ interaction: z.string().optional(),
635
+ environment: z.string().optional(),
636
+ model: z.string().optional(),
637
+ tags: z.array(z.string()).optional(),
638
+ exclude_tags: z
639
+ .array(z.string())
640
+ .meta({
641
+ description:
642
+ 'Tags to exclude. Runs carrying any of these tags are filtered out of the results, counts, and facet buckets. Combined with `tags` (which requires all of the listed tags) as an additional `$nin` constraint on the same field.',
643
+ })
644
+ .optional(),
645
+ query: z.string().optional(),
646
+ default_query_path: z.string().optional(),
647
+ parent: z.array(z.string()).optional(),
648
+ is_root: z.boolean().optional(),
649
+ object: z.string().optional(),
650
+ start: z.string().optional(),
651
+ end: z.string().optional(),
652
+ finish_reason: z.string().optional(),
653
+ created_by: z.string().optional(),
654
+ workflow_run_ids: z.array(z.string()).optional(),
655
+ workflow_ids: z.array(z.string()).optional(),
656
+ run_ids: z.array(z.string()).optional(),
657
+ is_agent: z.boolean().optional(),
658
+ })
659
+ .meta({ id: 'RunSearchQuery' });
660
+
661
+ /**
662
+ * The filters `GET /runs` actually applies.
663
+ *
664
+ * Separate from {@link RunSearchQuerySchema} because the two are different contracts that happened to
665
+ * share a name on this route. `RunSearchQuery` is the structured body of `POST /runs/search`, and
666
+ * publishing it here advertised ten filters this endpoint has never read — `exclude_tags`,
667
+ * `finish_reason`, `created_by`, `start`, `end`, `object`, `query`, `default_query_path`, `run_ids`
668
+ * and `is_agent` — while omitting the `tag` and `workflow_ids` it does read. A generated client
669
+ * following the document got silently unfiltered results.
670
+ *
671
+ * Every multi-valued filter is an array with `form`/`explode` serialization, which is the spelling the
672
+ * OpenAPI compliance rules ask for and what a single `?tag=x` normalizes to. The handler additionally
673
+ * splits each value on commas, so the long-standing `?tag=a,b` spelling keeps working; that is a
674
+ * property of the handler rather than of the document, which cannot express it.
675
+ *
676
+ * `fromDate` and `toDate` are deliberately absent. The SDK sends them and the endpoint has never
677
+ * applied them, so publishing them would restate the same kind of promise this component exists to
678
+ * remove. They are still accepted and ignored, exactly as before.
679
+ */
680
+ export const RunListQuerySchema = z
681
+ .strictObject({
682
+ limit: z.number().int().meta({ description: 'Maximum number of runs to return.' }).optional(),
683
+ offset: z.number().int().meta({ description: 'Number of runs to skip.' }).optional(),
684
+ interaction: z
685
+ .array(z.string())
686
+ .meta({ description: 'Interaction ids, or in-code interaction names, to filter by.' })
687
+ .optional(),
688
+ model: z.array(z.string()).meta({ description: 'Model ids to filter by.' }).optional(),
689
+ environment: z.array(z.string()).meta({ description: 'Environment ids to filter by.' }).optional(),
690
+ status: z.array(ExecutionRunStatusSchema).meta({ description: 'Run statuses to filter by.' }).optional(),
691
+ tag: z.array(z.string()).meta({ description: 'Run tags to filter by.' }).optional(),
692
+ parent: z
693
+ .array(z.string())
694
+ .meta({ description: 'Parent run ids to filter by. Mutually exclusive with `is_root=true`.' })
695
+ .optional(),
696
+ is_root: z
697
+ .boolean()
698
+ .meta({ description: 'Return only runs that have no parent. Mutually exclusive with `parent`.' })
699
+ .optional(),
700
+ workflow_run_ids: z.array(z.string()).meta({ description: 'Temporal workflow run ids.' }).optional(),
701
+ workflow_ids: z.array(z.string()).meta({ description: 'Temporal workflow ids.' }).optional(),
702
+ })
703
+ .meta({ id: 'RunListQuery' });
704
+
705
+ export const StreamingTelemetryContextSchema = z
706
+ .strictObject({
707
+ callType: LlmCallTypeSchema.meta({
708
+ description: 'Type of LLM call: start, resume after user message, or resume after tool results',
709
+ }),
710
+ attemptNumber: z.number().meta({ description: 'Activity retry attempt number' }).optional(),
711
+ inferenceStartTime: z
712
+ .number()
713
+ .meta({ description: 'Timestamp when inference started (for duration calculation)' }),
714
+ })
715
+ .meta({
716
+ id: 'StreamingTelemetryContext',
717
+ description:
718
+ 'Telemetry context for streaming mode. Contains info not available in current_state needed to send LlmCallEvent.',
719
+ });
720
+
721
+ export const ResolvedRuntimeConfigSchema = z
722
+ .strictObject({
723
+ environment: ResolvedEnvironmentInfoSchema,
724
+ model: z.string().optional(),
725
+ model_source: ModelSourceSchema,
726
+ })
727
+ .meta({ id: 'ResolvedRuntimeConfig', description: 'Resolved runtime configuration for an interaction' });
728
+
729
+ export const AgentRunnerOptionsSchema = z
730
+ .strictObject({
731
+ is_agent: z
732
+ .boolean()
733
+ .meta({ description: 'Whether this interaction is an agent (executable in Agent Runner).' })
734
+ .optional(),
735
+ is_tool: z
736
+ .boolean()
737
+ .meta({ description: 'Whether this interaction is available as a tool (sub-agent).' })
738
+ .optional(),
739
+ is_skill: z
740
+ .boolean()
741
+ .meta({
742
+ description:
743
+ "Whether this interaction is a skill (provides instructions without execution). Skills are injected into the agent's context based on context_triggers.",
744
+ })
745
+ .optional(),
746
+ context_triggers: SkillContextTriggersSchema.meta({
747
+ description: 'Context triggers for auto-injection of this skill. Only used when is_skill is true.',
748
+ }).optional(),
749
+ skill_priority: z
750
+ .number()
751
+ .meta({
752
+ description:
753
+ 'Injection priority for skills (higher = more likely to be selected when multiple match). Only used when is_skill is true.',
754
+ })
755
+ .optional(),
756
+ tool_names: z
757
+ .array(z.string())
758
+ .meta({
759
+ description:
760
+ 'Array of default tool names available to this agent. For interactions: defines default tools. For execution payloads: you can use + and - to add or remove from default, if no sign, then list replaces default.',
761
+ })
762
+ .optional(),
763
+ search_scope: AgentSearchScopeSchema.meta({
764
+ description:
765
+ "On which scope should the search be applied by the search_tool. Only supports 'collection' scope or undefined for now.",
766
+ }).optional(),
767
+ collection_id: z
768
+ .string()
769
+ .meta({
770
+ description:
771
+ "The ID of the collection to restrict agent operations to. When specified, the agent's search and retrieval operations are limited to documents within this collection'.",
772
+ })
773
+ .optional(),
774
+ request_template: z
775
+ .string()
776
+ .meta({
777
+ description:
778
+ 'Optional user-facing template for rendering run input as the first conversation entry. Supports {{field_name}}, {{nested.field}}, {{items.0.name}}, and {{json}} placeholders resolved from the run data.',
779
+ })
780
+ .optional(),
781
+ checkpoint: AgentCheckpointConfigurationSchema.meta({
782
+ description:
783
+ "Per-agent context checkpoint configuration. Field-wise it overrides the project's `configuration.agent.checkpoint`; a per-run `checkpoint_tokens` override still wins over both.",
784
+ }).optional(),
785
+ })
786
+ .meta({
787
+ id: 'AgentRunnerOptions',
788
+ description:
789
+ 'Configuration options for Agent Runner functionality. These options control how interactions are exposed and executed in the Agent Runner.',
790
+ });
791
+
792
+ export const UserChannelSchema = z
793
+ .discriminatedUnion('type', [EmailChannelSchema, InteractiveChannelSchema])
794
+ .meta({ id: 'UserChannel' });
795
+
796
+ export const PlanSchema = z
797
+ .strictObject({
798
+ plan: z.array(PlanTaskSchema),
799
+ comment: z.string().optional(),
800
+ })
801
+ .meta({ id: 'Plan' });
802
+
803
+ export const ExternalizedToolInputRefSchema = z
804
+ .strictObject({
805
+ tool_name: z.string(),
806
+ input_path: z.array(z.literal('content')).min(1).max(1),
807
+ ref: TextArtifactReferenceSchema,
808
+ })
809
+ .meta({
810
+ id: 'ExternalizedToolInputRef',
811
+ description:
812
+ 'Sidecar metadata for generated tool input fields that were stored outside model-visible tool_input. Keyed by tool_use.id on ConversationState.',
813
+ });
814
+
815
+ export const AgentResourceReferenceSchema = z
816
+ .strictObject({
817
+ type: AgentResourceTypeSchema,
818
+ id: z.string().meta({ description: 'The resource id used to build its detail route.' }),
819
+ label: z
820
+ .string()
821
+ .meta({ description: 'Human-readable label captured at mutation time (e.g. the document name).' }),
822
+ action: AgentResourceActionSchema,
823
+ revision_id: z
824
+ .string()
825
+ .meta({
826
+ description: 'Set when the mutation produced a new revision, enabling a "view changes" affordance.',
827
+ })
828
+ .optional(),
829
+ })
830
+ .meta({
831
+ id: 'AgentResourceReference',
832
+ description:
833
+ 'A navigable reference to a resource an agent tool mutated. Tools return these as tool-result metadata (see {@link ToolResultMeta.resources } ); the conversation runtime promotes them onto the tool\'s completed lifecycle message so the UI can render deterministic deep links and an end-of-turn "resources changed" summary — independent of any link the model writes in prose.',
834
+ });
835
+
836
+ export const ToolApprovalGrantMapSchema = z
837
+ .object({})
838
+ .catchall(ToolApprovalGrantSchema)
839
+ .meta({ id: 'ToolApprovalGrantMap' });
840
+
841
+ export const InCodePromptSchema = z
842
+ .strictObject({
843
+ role: PromptRoleSchema,
844
+ content: z.string(),
845
+ content_type: TemplateTypeSchema,
846
+ schema: JSONSchemaSchema.optional(),
847
+ name: z
848
+ .string()
849
+ .meta({ description: 'optional name of the prompt segment. Use kebab case for prompt names' })
850
+ .optional(),
851
+ externalId: z
852
+ .string()
853
+ .meta({
854
+ description:
855
+ 'optional reference to an external resource if any. Used internally by the system to synchronize stored prompts with in-code prompts.',
856
+ })
857
+ .optional(),
858
+ })
859
+ .meta({ id: 'InCodePrompt' });
860
+
861
+ export const RateLimitRequestPayloadSchema = z
862
+ .strictObject({
863
+ interaction: z.string(),
864
+ environment_id: z.string().optional(),
865
+ model_id: z.string().optional(),
866
+ workflow_run_id: z
867
+ .string()
868
+ .meta({
869
+ description: 'Deprecated: Use rate_limit_id for admission/completion correlation.',
870
+ deprecated: true,
871
+ 'x-deprecated-message': 'Use rate_limit_id for admission/completion correlation.',
872
+ })
873
+ .optional(),
874
+ rate_limit_id: z
875
+ .string()
876
+ .meta({
877
+ description: 'Stable per-execution admission identifier. Preferred over the legacy workflow_run_id.',
878
+ })
879
+ .optional(),
880
+ modalities: PromptModalitiesSchema.optional(),
881
+ })
882
+ .meta({ id: 'RateLimitRequestPayload' });
883
+
884
+ export const PromptTemplateRefSchema = z
885
+ .strictObject({
886
+ id: z.string(),
887
+ name: z.string(),
888
+ description: z.string().optional(),
889
+ role: PromptRoleSchema,
890
+ version: z.number(),
891
+ status: PromptStatusSchema,
892
+ content_type: TemplateTypeSchema.optional(),
893
+ tags: z.array(z.string()).optional(),
894
+ created_at: z.string().meta({ format: 'date-time' }),
895
+ updated_at: z.string().meta({ format: 'date-time' }),
896
+ })
897
+ .meta({ id: 'PromptTemplateRef' });
898
+
899
+ export const RunSourceSchema = z
900
+ .strictObject({
901
+ type: RunSourceTypesSchema,
902
+ label: z.string(),
903
+ principal_type: z.enum(['user', 'oauth_access', 'group', 'apikey', 'service_account', 'agent', 'schedule']),
904
+ principal_id: z.string(),
905
+ client_ip: z.string(),
906
+ })
907
+ .meta({ id: 'RunSource' });
908
+
909
+ export const PromptSegmentDefSchema = z
910
+ .strictObject({
911
+ id: z.string().optional(),
912
+ type: PromptSegmentDefTypeSchema,
913
+ template: z.union([z.string(), PromptTemplateSchema, PromptTemplateRefSchema]).optional(),
914
+ configuration: z.unknown().optional(),
915
+ })
916
+ .meta({ id: 'PromptSegmentDef' });
917
+
918
+ export const InteractionEndpointSchema = z
919
+ .strictObject({
920
+ id: z.string(),
921
+ name: z.string(),
922
+ endpoint: z.string(),
923
+ description: z.string().optional(),
924
+ status: InteractionStatusSchema,
925
+ visibility: InteractionVisibilitySchema.optional(),
926
+ version: z.number(),
927
+ tags: z.array(z.string()),
928
+ agent_runner_options: AgentRunnerOptionsSchema.optional(),
929
+ output_modality: ModalitiesSchema.meta({
930
+ description: 'Deprecated: This is deprecated. Use CompletionResult.type information instead.',
931
+ deprecated: true,
932
+ 'x-deprecated-message': 'This is deprecated. Use CompletionResult.type information instead.',
933
+ }).optional(),
934
+ result_schema: JSONSchemaSchema.optional(),
935
+ params_schema: JSONSchemaSchema.optional(),
936
+ })
937
+ .meta({ id: 'InteractionEndpoint', description: 'A description of an interaction endpoint.' });
938
+
939
+ export const InteractionCreatePayloadSchema = z
940
+ .strictObject({
941
+ status: InteractionStatusSchema,
942
+ test_data: JSONObjectSchema.optional(),
943
+ interaction_schema: z.union([JSONSchemaSchema, SchemaRefSchema]).optional(),
944
+ cache_policy: CachePolicySchema.optional(),
945
+ prompts: z.array(PromptSegmentDefSchema),
946
+ last_published_at: z.string().meta({ format: 'date-time' }).optional(),
947
+ name: z.string(),
948
+ description: z.string().optional(),
949
+ agent_runner_options: AgentRunnerOptionsSchema.optional(),
950
+ result_schema: z.union([JSONSchemaSchema, SchemaRefSchema]).optional(),
951
+ environment: z.union([z.string(), ExecutionEnvironmentRefSchema]).optional(),
952
+ model: z.string().optional(),
953
+ model_options: ModelOptionsSchema.optional(),
954
+ restriction: RunDataStorageLevelSchema.optional(),
955
+ output_modality: ModalitiesSchema.meta({
956
+ description: 'Deprecated: This is deprecated. Use CompletionResult.type information instead.',
957
+ deprecated: true,
958
+ 'x-deprecated-message': 'This is deprecated. Use CompletionResult.type information instead.',
959
+ }).optional(),
960
+ visibility: InteractionVisibilitySchema.optional(),
961
+ tags: z.array(z.string()).optional(),
962
+ })
963
+ .meta({ id: 'InteractionCreatePayload' });
964
+
965
+ export const InteractionSchema = z
966
+ .strictObject({
967
+ id: z.string(),
968
+ name: z.string(),
969
+ endpoint: z.string(),
970
+ description: z.string().optional(),
971
+ project: z.union([z.string(), ProjectRefSchema]),
972
+ tags: z.array(z.string()),
973
+ agent_runner_options: AgentRunnerOptionsSchema.optional(),
974
+ result_schema: z.union([JSONSchemaSchema, SchemaRefSchema]).optional(),
975
+ environment: z.union([z.string(), ExecutionEnvironmentRefSchema]).optional(),
976
+ model: z.string().optional(),
977
+ model_options: ModelOptionsSchema.optional(),
978
+ restriction: RunDataStorageLevelSchema.optional(),
979
+ output_modality: ModalitiesSchema.meta({
980
+ description: 'Deprecated: This is deprecated. Use CompletionResult.type information instead.',
981
+ deprecated: true,
982
+ 'x-deprecated-message': 'This is deprecated. Use CompletionResult.type information instead.',
983
+ }).optional(),
984
+ status: InteractionStatusSchema,
985
+ parent: z.string().optional(),
986
+ visibility: InteractionVisibilitySchema,
987
+ version: z.number(),
988
+ test_data: JSONObjectSchema.optional(),
989
+ interaction_schema: z.union([JSONSchemaSchema, SchemaRefSchema]).optional(),
990
+ cache_policy: CachePolicySchema.optional(),
991
+ prompts: z.array(PromptSegmentDefSchema),
992
+ last_published_at: z.string().meta({ format: 'date-time' }).optional(),
993
+ created_by: z.string(),
994
+ updated_by: z.string(),
995
+ created_at: z.string().meta({ format: 'date-time' }),
996
+ updated_at: z.string().meta({ format: 'date-time' }),
997
+ })
998
+ .meta({ id: 'Interaction' });
999
+
1000
+ export const GeneratedTestDataRecordArraySchema = z
1001
+ .array(GeneratedTestDataRecordSchema)
1002
+ .meta({ id: 'GeneratedTestDataRecordArray' });
1003
+
1004
+ export const GeneratedInteractionPromptSegmentSchema = z
1005
+ .strictObject({
1006
+ type: z.literal('template'),
1007
+ template: GeneratedInteractionPromptTemplateSchema,
1008
+ })
1009
+ .meta({ id: 'GeneratedInteractionPromptSegment' });
1010
+
1011
+ export const ComputeInteractionFacetPayloadSchema = z
1012
+ .strictObject({
1013
+ facets: z.array(FacetSpecSchema),
1014
+ query: InteractionSearchQuerySchema.optional(),
1015
+ })
1016
+ .meta({ id: 'ComputeInteractionFacetPayload' });
1017
+
1018
+ export const CatalogInteractionRefSchema = z
1019
+ .strictObject({
1020
+ type: z.enum(['sys', 'app', 'stored', 'draft']).meta({ description: 'The type of interaction' }),
1021
+ id: z.string().meta({ description: 'the interaction id that can be used to execute the interaction.' }),
1022
+ name: z.string().meta({
1023
+ description:
1024
+ 'The interaction name which identify the interaction in the provider interaction list. For the stored interactions this is the same as the endpoint property. For other types of interactions this is the local name of the interaction.',
1025
+ }),
1026
+ version: z
1027
+ .number()
1028
+ .meta({
1029
+ description:
1030
+ 'Only applies for stored interactions. The version of the interaction. Undefined for non stored interactions',
1031
+ })
1032
+ .optional(),
1033
+ published: z
1034
+ .boolean()
1035
+ .meta({ description: 'Only applies for stored interactions. Whether the interaction is published or not.' })
1036
+ .optional(),
1037
+ tags: z.array(z.string()).meta({ description: 'The tags associated with the interaction.' }),
1038
+ agent_runner_options: AgentRunnerOptionsSchema.meta({
1039
+ description: 'Agent Runner configuration options.',
1040
+ }).optional(),
1041
+ title: z.string().meta({ description: 'The name of the interaction. For display purposes only.' }),
1042
+ description: z.string().meta({ description: 'Optional description of the interaction.' }).optional(),
1043
+ })
1044
+ .meta({
1045
+ id: 'CatalogInteractionRef',
1046
+ description:
1047
+ 'Reference to an interaction in the catalog. Used in catalog listing. The id is composed of the namespace and the interaction name. Stored interactions can use `oid:` prefix. If no prefix is used it fallback on `oid:`.',
1048
+ });
1049
+
1050
+ export const RunSearchPayloadSchema = z
1051
+ .strictObject({
1052
+ facets: z.array(FacetSpecSchema).optional(),
1053
+ limit_facets: z
1054
+ .boolean()
1055
+ .meta({
1056
+ description:
1057
+ 'If the facets should be limited to the current page of results. Defaults to false. When false, the facets are independent of the search results page.',
1058
+ })
1059
+ .optional(),
1060
+ query: RunSearchQuerySchema.optional(),
1061
+ limit: z.number().optional(),
1062
+ offset: z.number().optional(),
1063
+ select: z.string().optional(),
1064
+ all_revisions: z.boolean().optional(),
1065
+ from_root: z.string().optional(),
1066
+ sort: z
1067
+ .array(SortOptionSchema)
1068
+ .meta({
1069
+ description: 'Sort criteria. Multiple entries enable multi-field sorting (first entry is primary).',
1070
+ })
1071
+ .optional(),
1072
+ aggs: z
1073
+ .looseObject({})
1074
+ .meta({
1075
+ description:
1076
+ 'Arbitrary Elasticsearch aggregation definitions. Ignored when search falls back to MongoDB.',
1077
+ })
1078
+ .optional(),
1079
+ })
1080
+ .meta({ id: 'RunSearchPayload' });
1081
+
1082
+ export const ResolvedInteractionExecutionInfoSchema = z
1083
+ .strictObject({
1084
+ id: z.string().meta({ description: 'The resolved interaction ID' }),
1085
+ name: z.string().meta({ description: 'The interaction endpoint name' }),
1086
+ version: z.number().meta({ description: 'The interaction version number' }),
1087
+ status: InteractionStatusSchema.meta({ description: 'The interaction status (draft or published)' }),
1088
+ tags: z
1089
+ .array(z.string())
1090
+ .meta({ description: 'The interaction tags (can include version tags like "production", "staging")' }),
1091
+ agent_runner_options: AgentRunnerOptionsSchema.meta({
1092
+ description:
1093
+ "Agent runner configuration (tool_names opt-ins, is_agent, is_tool, etc.). Included on resolve so non-UI callers (worker activities) can pick up the interaction's defaults without a second retrieve round-trip — and so in-code interactions (sys:, app:) which have no Mongo document work the same as stored ones.",
1094
+ }).optional(),
1095
+ resolved: ResolvedRuntimeConfigSchema.meta({ description: 'The resolved runtime configuration' }),
1096
+ })
1097
+ .meta({
1098
+ id: 'ResolvedInteractionExecutionInfo',
1099
+ description:
1100
+ 'Resolved execution info for an interaction. Contains the interaction ID, basic metadata, and the resolved runtime configuration (environment, model) that would be used at execution time.',
1101
+ });
1102
+
1103
+ export const ExternalizedToolInputRefsSchema = z
1104
+ .object({})
1105
+ .catchall(z.array(ExternalizedToolInputRefSchema))
1106
+ .meta({ id: 'ExternalizedToolInputRefs' });
1107
+
1108
+ // `looseObject`, and it is load-bearing rather than cosmetic: the description below says "an open
1109
+ // record", the published component omits `additionalProperties` accordingly, and the TypeScript
1110
+ // alias has to say the same thing. A plain `object` emits identically but infers a CLOSED type, so
1111
+ // the one caller passing an MCP `_meta` through would stop compiling against a contract that
1112
+ // explicitly accepts it.
1113
+ export const ToolResultMetaSchema = z
1114
+ .looseObject({
1115
+ resources: z
1116
+ .array(AgentResourceReferenceSchema)
1117
+ .meta({ description: 'Resources this tool created/updated/deleted, surfaced as deep links in the UI.' })
1118
+ .optional(),
1119
+ })
1120
+ .meta({
1121
+ id: 'ToolResultMeta',
1122
+ description:
1123
+ 'Metadata a tool executor may attach to its result. Kept as an open record for forward compatibility while typing the fields the runtime interprets.',
1124
+ });
1125
+
1126
+ export const PromptImprovementResponseSchema = z
1127
+ .strictObject({
1128
+ result: z.array(CompletionResultSchema),
1129
+ })
1130
+ .meta({ id: 'PromptImprovementResponse' });
1131
+
1132
+ export const PromptSegmentRef_PromptTemplateRefSchema = z
1133
+ .strictObject({
1134
+ id: z.string(),
1135
+ type: PromptSegmentDefTypeSchema,
1136
+ template: PromptTemplateRefSchema.optional(),
1137
+ configuration: z.unknown().optional(),
1138
+ })
1139
+ .meta({ id: 'PromptSegmentRef_PromptTemplateRef' });
1140
+
1141
+ export const InteractionUpdatePayloadSchema = z
1142
+ .strictObject({
1143
+ status: InteractionStatusSchema.optional(),
1144
+ parent: z.string().optional(),
1145
+ visibility: InteractionVisibilitySchema.optional(),
1146
+ version: z.number().optional(),
1147
+ test_data: JSONObjectSchema.optional(),
1148
+ interaction_schema: z.union([JSONSchemaSchema, SchemaRefSchema]).optional(),
1149
+ cache_policy: CachePolicySchema.optional(),
1150
+ prompts: z.array(PromptSegmentDefSchema).optional(),
1151
+ last_published_at: z.string().meta({ format: 'date-time' }).optional(),
1152
+ name: z.string().optional(),
1153
+ endpoint: z.string().optional(),
1154
+ description: z.string().optional(),
1155
+ tags: z.array(z.string()).optional(),
1156
+ agent_runner_options: AgentRunnerOptionsSchema.optional(),
1157
+ environment: z.union([z.string(), ExecutionEnvironmentRefSchema]).optional(),
1158
+ model: z.string().optional(),
1159
+ model_options: ModelOptionsSchema.optional(),
1160
+ restriction: RunDataStorageLevelSchema.optional(),
1161
+ output_modality: ModalitiesSchema.meta({
1162
+ description: 'Deprecated: This is deprecated. Use CompletionResult.type information instead.',
1163
+ deprecated: true,
1164
+ 'x-deprecated-message': 'This is deprecated. Use CompletionResult.type information instead.',
1165
+ }).optional(),
1166
+ result_schema: z.union([JSONSchemaSchema, SchemaRefSchema, z.null()]).optional(),
1167
+ })
1168
+ .meta({ id: 'InteractionUpdatePayload' });
1169
+
1170
+ export const InteractionEndpointArraySchema = z
1171
+ .array(InteractionEndpointSchema)
1172
+ .meta({ id: 'InteractionEndpointArray' });
1173
+
1174
+ export const InteractionArraySchema = z.array(InteractionSchema).meta({ id: 'InteractionArray' });
1175
+
1176
+ export const GeneratedInteractionDefinitionSchema = z
1177
+ .strictObject({
1178
+ name: z.string(),
1179
+ description: z.string(),
1180
+ temperature: z.number(),
1181
+ prompts: z.array(GeneratedInteractionPromptSegmentSchema),
1182
+ max_tokens: z.number().optional(),
1183
+ result_schema: JSONSchemaSchema,
1184
+ tags: z.array(z.enum(['generated', 'agent'])),
1185
+ })
1186
+ .meta({ id: 'GeneratedInteractionDefinition' });
1187
+
1188
+ export const CatalogInteractionRefArraySchema = z
1189
+ .array(CatalogInteractionRefSchema)
1190
+ .meta({ id: 'CatalogInteractionRefArray' });
1191
+
1192
+ export const ToolResultSchema = z
1193
+ .strictObject({
1194
+ content: z.string(),
1195
+ content_ref: TextArtifactReferenceSchema.meta({
1196
+ description:
1197
+ 'Reference to text content stored outside Temporal/API payloads. Servers that execute the next model turn should resolve this before constructing the provider prompt.',
1198
+ }).optional(),
1199
+ is_error: z.boolean(),
1200
+ files: z.array(z.string()).optional(),
1201
+ display_message: z
1202
+ .string()
1203
+ .meta({
1204
+ description:
1205
+ 'Optional message to display in the UI instead of the content. Use this when the content is large or technical (e.g., document text) and you want to show a friendly message to the user.',
1206
+ })
1207
+ .optional(),
1208
+ meta: ToolResultMetaSchema.meta({
1209
+ description: 'Can contain metadata returned by the tool executor.',
1210
+ }).optional(),
1211
+ tool_use_id: z.string(),
1212
+ thought_signature: z
1213
+ .string()
1214
+ .meta({
1215
+ description:
1216
+ 'Gemini thinking models require thought_signature to be passed back with tool results. Copy this from the ToolUse.thought_signature that requested this tool call.',
1217
+ })
1218
+ .optional(),
1219
+ })
1220
+ .meta({ id: 'ToolResult' });
1221
+
1222
+ export const InteractionRefSchema = z
1223
+ .strictObject({
1224
+ id: z.string(),
1225
+ name: z.string(),
1226
+ endpoint: z.string(),
1227
+ parent: z.string().optional(),
1228
+ model: z.string().optional(),
1229
+ description: z.string().optional(),
1230
+ status: InteractionStatusSchema,
1231
+ visibility: InteractionVisibilitySchema.optional(),
1232
+ version: z.number(),
1233
+ tags: z.array(z.string()),
1234
+ agent_runner_options: AgentRunnerOptionsSchema.optional(),
1235
+ prompts: z.array(PromptSegmentRef_PromptTemplateRefSchema).optional(),
1236
+ updated_at: z.string().meta({ format: 'date-time' }),
1237
+ })
1238
+ .meta({ id: 'InteractionRef' });
1239
+
1240
+ // An alias component: `ExecutionRunInteraction` publishes as `$ref: InteractionRef`, and the TS
1241
+ // type is the same alias. The description belongs HERE rather than on the one property that uses
1242
+ // it — re-stating an id at a use site is what `toJSONSchema` rejects as a duplicate id, and a clone
1243
+ // carrying only a description loses the id and inlines the whole `InteractionRef` body instead.
1244
+ export const ExecutionRunInteractionSchema = InteractionRefSchema.meta({
1245
+ id: 'ExecutionRunInteraction',
1246
+ description:
1247
+ 'Interaction reference. Stored interactions may be populated as full Interaction documents; in-code interactions are represented as refs whose `id` is the namespaced interaction id.',
1248
+ });
1249
+
1250
+ export const InteractionTagsSchema = z
1251
+ .strictObject({
1252
+ tag: z.string(),
1253
+ count: z.number(),
1254
+ interactions: z.array(InteractionRefSchema),
1255
+ })
1256
+ .meta({ id: 'InteractionTags' });
1257
+
1258
+ export const InteractionRefArraySchema = z.array(InteractionRefSchema).meta({ id: 'InteractionRefArray' });
1259
+
1260
+ // The name picker's shape, and the whole of it. `GET /interactions/names` exists to fill a select box
1261
+ // from a projection of two fields, so it publishes those two rather than an `InteractionRef` whose
1262
+ // other required properties the endpoint deliberately does not read. The document used to claim a
1263
+ // full `Interaction` here, which no caller could rely on and the SDK already contradicted.
1264
+ export const InteractionNameSchema = z
1265
+ .strictObject({
1266
+ id: z.string(),
1267
+ name: z.string(),
1268
+ })
1269
+ .meta({
1270
+ id: 'InteractionName',
1271
+ description: 'An interaction reduced to the fields a name picker needs.',
1272
+ });
1273
+
1274
+ export const InteractionNameArraySchema = z.array(InteractionNameSchema).meta({ id: 'InteractionNameArray' });
1275
+
1276
+ // What `POST /interactions/export` puts in each prompt segment. The export populates its templates
1277
+ // with `inputSchema` alone — it is exporting definitions, not rendering them — so this is a template
1278
+ // id and its input schema rather than the `PromptTemplateRef` the other segment shapes carry.
1279
+ export const ExportedPromptTemplateRefSchema = z
1280
+ .strictObject({
1281
+ id: z.string(),
1282
+ inputSchema: JSONSchemaSchema.optional(),
1283
+ })
1284
+ .meta({
1285
+ id: 'ExportedPromptTemplateRef',
1286
+ description: 'A prompt template reduced to the input schema an export carries.',
1287
+ });
1288
+
1289
+ export const PromptSegmentRef_ExportedPromptTemplateRefSchema = z
1290
+ .strictObject({
1291
+ id: z.string(),
1292
+ type: PromptSegmentDefTypeSchema,
1293
+ template: ExportedPromptTemplateRefSchema.optional(),
1294
+ configuration: z.unknown().optional(),
1295
+ })
1296
+ .meta({ id: 'PromptSegmentRef_ExportedPromptTemplateRef' });
1297
+
1298
+ // The export shape: an `InteractionRef` plus the result schema, with prompt templates reduced as
1299
+ // above. Modelled here rather than derived from the `InteractionRefWithSchema` interface, which is
1300
+ // declared as `Omit<InteractionRef, 'prompts'>` — an `Omit` over a canonical alias that the schema
1301
+ // generator cannot resolve, since the alias publishes as a bare reference with no members to omit.
1302
+ export const InteractionRefWithSchemaSchema = InteractionRefSchema.extend({
1303
+ result_schema: JSONSchemaSchema.optional(),
1304
+ prompts: z.array(PromptSegmentRef_ExportedPromptTemplateRefSchema).optional(),
1305
+ }).meta({
1306
+ id: 'InteractionRefWithSchema',
1307
+ description: 'An interaction reference carrying the schemas an export needs to reconstruct it.',
1308
+ });
1309
+
1310
+ export const InteractionRefWithSchemaArraySchema = z
1311
+ .array(InteractionRefWithSchemaSchema)
1312
+ .meta({ id: 'InteractionRefWithSchemaArray' });
1313
+
1314
+ export const GeneratedInteractionDefinitionArraySchema = z
1315
+ .array(GeneratedInteractionDefinitionSchema)
1316
+ .meta({ id: 'GeneratedInteractionDefinitionArray' });
1317
+
1318
+ export const PendingToolApprovalResultsSchema = z
1319
+ .strictObject({
1320
+ results: z.array(ToolResultSchema),
1321
+ reason: z.enum(['denied', 'denied_with_feedback', 'timeout', 'reviewer_denied']),
1322
+ message: z.string(),
1323
+ created_at: z.string(),
1324
+ })
1325
+ .meta({ id: 'PendingToolApprovalResults' });
1326
+
1327
+ // Self-referential through `parent`, so the reference goes through a getter — the same shape
1328
+ // `JSONSchemaSchema` uses. The explicit annotation is what stops `tsc` reporting the initializer as
1329
+ // implicitly `any`; `z.ZodType` rather than an inferred type because inference cannot bottom out on
1330
+ // a cycle.
1331
+ export const ExecutionRunSchema: z.ZodType = z
1332
+ .strictObject({
1333
+ id: z.string(),
1334
+ get parent() {
1335
+ return z
1336
+ .union([z.string(), ExecutionRunSchema])
1337
+ .meta({
1338
+ description:
1339
+ 'Only used by runs that were created by a virtual run to point toward the virtual run parent',
1340
+ })
1341
+ .optional();
1342
+ },
1343
+ evaluation: z
1344
+ .strictObject({
1345
+ score: z.number().optional(),
1346
+ selected: z.boolean().optional(),
1347
+ scores: NumberValueMapSchema.optional(),
1348
+ })
1349
+ .optional(),
1350
+ result: z.array(CompletionResultSchema),
1351
+ parameters: z.unknown().meta({
1352
+ description:
1353
+ 'The parameters used to create the interaction. If the parameters contains the special property "@memory" it will be used to locate a memory pack and the other properties will be used as the memory pack mapping.',
1354
+ }),
1355
+ tags: z.array(z.string()).optional(),
1356
+ interaction: ExecutionRunInteractionSchema.optional(),
1357
+ environment: ExecutionEnvironmentRefSchema.meta({
1358
+ description: 'Environment reference - populated with full object in API responses',
1359
+ }),
1360
+ modelId: z.string().optional(),
1361
+ result_schema: JSONSchemaSchema.optional(),
1362
+ ttl: z.number(),
1363
+ status: ExecutionRunStatusSchema,
1364
+ finish_reason: z.string().optional(),
1365
+ prompt: z.unknown().optional(),
1366
+ token_use: ExecutionTokenUsageSchema.optional(),
1367
+ chunks: z.number().optional(),
1368
+ execution_time: z.number().optional(),
1369
+ created_at: z.string().meta({ format: 'date-time' }),
1370
+ updated_at: z.string().meta({ format: 'date-time' }),
1371
+ account: AccountRefSchema,
1372
+ project: ProjectRefSchema,
1373
+ config: InteractionExecutionConfigurationSchema,
1374
+ error: InteractionExecutionErrorSchema.optional(),
1375
+ source: RunSourceSchema,
1376
+ output_modality: ModalitiesSchema.meta({
1377
+ description: 'Deprecated: This is deprecated. Use CompletionResult.type information instead.',
1378
+ deprecated: true,
1379
+ 'x-deprecated-message': 'This is deprecated. Use CompletionResult.type information instead.',
1380
+ }).optional(),
1381
+ created_by: z.string(),
1382
+ updated_by: z.string(),
1383
+ workflow: ExecutionRunWorkflowSchema.meta({
1384
+ description:
1385
+ 'The Vertesia Workflow related to this Interaction Run.\n\nThis is only set when the interaction is executed as part of a workflow.',
1386
+ }).optional(),
1387
+ })
1388
+ .meta({ id: 'ExecutionRun' });
1389
+
1390
+ export const InteractionTagsArraySchema = z.array(InteractionTagsSchema).meta({ id: 'InteractionTagsArray' });
1391
+
1392
+ export const InteractionExecutionResultSchema = z
1393
+ .strictObject({
1394
+ id: z.string(),
1395
+ parent: z
1396
+ .union([z.string(), ExecutionRunSchema])
1397
+ .meta({
1398
+ description:
1399
+ 'Only used by runs that were created by a virtual run to point toward the virtual run parent',
1400
+ })
1401
+ .optional(),
1402
+ evaluation: z
1403
+ .strictObject({
1404
+ score: z.number().optional(),
1405
+ selected: z.boolean().optional(),
1406
+ scores: NumberValueMapSchema.optional(),
1407
+ })
1408
+ .optional(),
1409
+ result: z.array(CompletionResultSchema),
1410
+ parameters: z.looseObject({}).meta({
1411
+ description:
1412
+ 'The parameters used to create the interaction. If the parameters contains the special property "@memory" it will be used to locate a memory pack and the other properties will be used as the memory pack mapping.',
1413
+ }),
1414
+ tags: z.array(z.string()).optional(),
1415
+ environment: ExecutionEnvironmentRefSchema.meta({
1416
+ description: 'Environment reference - populated with full object in API responses',
1417
+ }),
1418
+ modelId: z.string().optional(),
1419
+ result_schema: JSONSchemaSchema.optional(),
1420
+ ttl: z.number(),
1421
+ status: ExecutionRunStatusSchema,
1422
+ finish_reason: z.string().optional(),
1423
+ prompt: z.unknown().optional(),
1424
+ token_use: ExecutionTokenUsageSchema.optional(),
1425
+ chunks: z.number().optional(),
1426
+ execution_time: z.number().optional(),
1427
+ created_at: z.string().meta({ format: 'date-time' }),
1428
+ updated_at: z.string().meta({ format: 'date-time' }),
1429
+ config: InteractionExecutionConfigurationSchema,
1430
+ error: InteractionExecutionErrorSchema.optional(),
1431
+ source: RunSourceSchema,
1432
+ output_modality: ModalitiesSchema.meta({
1433
+ description: 'Deprecated: This is deprecated. Use CompletionResult.type information instead.',
1434
+ deprecated: true,
1435
+ 'x-deprecated-message': 'This is deprecated. Use CompletionResult.type information instead.',
1436
+ }).optional(),
1437
+ created_by: z.string(),
1438
+ updated_by: z.string(),
1439
+ workflow: ExecutionRunWorkflowSchema.meta({
1440
+ description:
1441
+ 'The Vertesia Workflow related to this Interaction Run.\n\nThis is only set when the interaction is executed as part of a workflow.',
1442
+ }).optional(),
1443
+ account: z.string(),
1444
+ project: z.string(),
1445
+ interaction: z.string().optional(),
1446
+ tool_use: z.array(ToolUseSchema).optional(),
1447
+ conversation: z.unknown().optional(),
1448
+ options: StatelessExecutionOptionsSchema.optional(),
1449
+ })
1450
+ .meta({ id: 'InteractionExecutionResult' });
1451
+
1452
+ /**
1453
+ * The run-with-result shape as the retrieve endpoints return it.
1454
+ *
1455
+ * One property apart from {@link InteractionExecutionResultSchema}, and it is the one the retrieve
1456
+ * path populates: `GET /runs/{runId}` resolves `interaction` into a full reference, where the create
1457
+ * path leaves the stored id. Publishing both under a single component would mean a string-or-object
1458
+ * union that no generated client can deserialize into one type.
1459
+ *
1460
+ * `account` and `project` stay plain ids in both, because neither path populates them.
1461
+ */
1462
+ export const PopulatedExecutionRunResultSchema = InteractionExecutionResultSchema.extend({
1463
+ interaction: ExecutionRunInteractionSchema.optional(),
1464
+ }).meta({
1465
+ id: 'PopulatedExecutionRunResult',
1466
+ description: 'An execution run with its completion result and its interaction reference populated.',
1467
+ });
1468
+
1469
+ /**
1470
+ * `result` in the shape the pre-`COMPLETION_RESULT_V1` endpoints report it.
1471
+ *
1472
+ * The legacy conversion collapses the `CompletionResult[]` into whichever single value the parts
1473
+ * amount to: the JSON object when the run produced one, the joined text otherwise, and `null` when
1474
+ * the run stored an explicit null. Published as a raw value rather than an object-or-string union,
1475
+ * which is the representation the OpenAPI compliance rules ask for and the only one a generated
1476
+ * client can hold in a single field.
1477
+ *
1478
+ * Both legacy components exist to describe endpoints we intend to remove, not to invite new callers.
1479
+ * Until then the document says what they return: it used to name a component with no `result`
1480
+ * property at all, so a generated client dropped the entire payload of these operations.
1481
+ *
1482
+ * Named for the run rather than after the `LegacyInteractionExecutionResult` interface in
1483
+ * `../interaction.js`, which is generic over its parameter type and so cannot become an alias of
1484
+ * anything inferred here. Two names for one shape is worse than one name that says what it is.
1485
+ */
1486
+ const LEGACY_RESULT = z.unknown().meta({
1487
+ description:
1488
+ 'The completion result collapsed to a single value: the parsed JSON object when the run produced one, the joined text otherwise. Superseded by the `result` array of the current API version.',
1489
+ });
1490
+
1491
+ export const LegacyExecutionRunResultSchema = InteractionExecutionResultSchema.extend({
1492
+ result: LEGACY_RESULT,
1493
+ }).meta({
1494
+ id: 'LegacyExecutionRunResult',
1495
+ description: 'An execution run whose completion result is reported in the pre-versioning format.',
1496
+ });
1497
+
1498
+ export const LegacyPopulatedExecutionRunResultSchema = PopulatedExecutionRunResultSchema.extend({
1499
+ result: LEGACY_RESULT,
1500
+ }).meta({
1501
+ id: 'LegacyPopulatedExecutionRunResult',
1502
+ description:
1503
+ 'A retrieved execution run whose completion result is reported in the pre-versioning format. A run that has no result yet is returned unchanged, so `result` may still hold the current array form.',
1504
+ });
1505
+
1506
+ export const ExecutionRunRefSchema = z
1507
+ .strictObject({
1508
+ id: z.string(),
1509
+ parent: z
1510
+ .union([z.string(), ExecutionRunSchema])
1511
+ .meta({
1512
+ description:
1513
+ 'Only used by runs that were created by a virtual run to point toward the virtual run parent',
1514
+ })
1515
+ .optional(),
1516
+ evaluation: z
1517
+ .strictObject({
1518
+ score: z.number().optional(),
1519
+ selected: z.boolean().optional(),
1520
+ scores: NumberValueMapSchema.optional(),
1521
+ })
1522
+ .optional(),
1523
+ tags: z.array(z.string()).optional(),
1524
+ environment: ExecutionEnvironmentRefSchema.meta({
1525
+ description: 'Environment reference - populated with full object in API responses',
1526
+ }),
1527
+ modelId: z.string().optional(),
1528
+ result_schema: JSONSchemaSchema.optional(),
1529
+ ttl: z.number(),
1530
+ status: ExecutionRunStatusSchema,
1531
+ finish_reason: z.string().optional(),
1532
+ prompt: z.unknown().optional(),
1533
+ token_use: ExecutionTokenUsageSchema.optional(),
1534
+ chunks: z.number().optional(),
1535
+ execution_time: z.number().optional(),
1536
+ created_at: z.string().meta({ format: 'date-time' }),
1537
+ updated_at: z.string().meta({ format: 'date-time' }),
1538
+ account: AccountRefSchema,
1539
+ project: ProjectRefSchema,
1540
+ config: InteractionExecutionConfigurationSchema,
1541
+ error: InteractionExecutionErrorSchema.optional(),
1542
+ source: RunSourceSchema,
1543
+ output_modality: ModalitiesSchema.meta({
1544
+ description: 'Deprecated: This is deprecated. Use CompletionResult.type information instead.',
1545
+ deprecated: true,
1546
+ 'x-deprecated-message': 'This is deprecated. Use CompletionResult.type information instead.',
1547
+ }).optional(),
1548
+ created_by: z.string(),
1549
+ updated_by: z.string(),
1550
+ workflow: ExecutionRunWorkflowSchema.meta({
1551
+ description:
1552
+ 'The Vertesia Workflow related to this Interaction Run.\n\nThis is only set when the interaction is executed as part of a workflow.',
1553
+ }).optional(),
1554
+ interaction: InteractionRefSchema.optional(),
1555
+ })
1556
+ .meta({ id: 'ExecutionRunRef' });
1557
+
1558
+ export const ConversationStateSchema = z
1559
+ .strictObject({
1560
+ run: ExecutionRunDocRefSchema.meta({ description: 'A reference to the run that started the conversation' }),
1561
+ environment: z.string().meta({ description: 'The execution environment with provider info for LLM calls.' }),
1562
+ options: StatelessExecutionOptionsSchema.meta({ description: 'The options to use on the next call.' }),
1563
+ tool_use: z.array(ToolUseSchema).meta({ description: 'The tools to call next.' }).optional(),
1564
+ tool_approval_mode: AgentToolApprovalModeSchema.meta({
1565
+ description: 'Effective side-effecting tool approval mode for this interactive conversation.',
1566
+ }).optional(),
1567
+ tool_approval_grants: ToolApprovalGrantMapSchema.meta({
1568
+ description: 'Run-scoped, exact-target grants created by "allow this action for this run".',
1569
+ }).optional(),
1570
+ pending_tool_approval_results: PendingToolApprovalResultsSchema.meta({
1571
+ description: 'Buffered tool results held while approval denial pauses until the next user message.',
1572
+ }).optional(),
1573
+ latest_user_message: z
1574
+ .string()
1575
+ .meta({ description: 'Compact, redacted latest user intent for reviewer-style system interactions.' })
1576
+ .optional(),
1577
+ tool_input_refs: ExternalizedToolInputRefsSchema.meta({
1578
+ description:
1579
+ 'Transport sidecar for large generated tool input fields.\n\nThese refs are intentionally kept out of tool_use.tool_input so they are not shown to the model. Tool execution hydrates them from artifact storage immediately before activity validation.',
1580
+ }).optional(),
1581
+ output: z.array(CompletionResultSchema).meta({ description: 'The output of the this conversation step' }),
1582
+ token_usage: ExecutionTokenUsageSchema.meta({
1583
+ description: 'The token usage of the this conversation step',
1584
+ }).optional(),
1585
+ parent: WorkflowAncestorSchema.meta({
1586
+ description: "If a sub workflow execution, contains the parent's info",
1587
+ }).optional(),
1588
+ ancestors: z
1589
+ .array(WorkflowAncestorSchema)
1590
+ .meta({ description: 'Full ancestry chain from root to immediate parent (for hierarchical aggregation)' }),
1591
+ task_id: z
1592
+ .string()
1593
+ .meta({ description: 'If part of a larger agentic workflow, task id of this task' })
1594
+ .optional(),
1595
+ plan: PlanSchema.meta({
1596
+ description: 'Stores the most recent plan for reference by plan-related tools',
1597
+ }).optional(),
1598
+ debug: z.boolean().meta({ description: 'Debug mode (more logs and persisted artifacts)' }).optional(),
1599
+ strip_options: ConversationStripOptionsSchema.meta({
1600
+ description:
1601
+ 'Configuration for stripping large data from conversation history. Passed to llumiverse ExecutionOptions.stripImagesAfterTurns.',
1602
+ }).optional(),
1603
+ conversation_artifacts_base_url: z.string().meta({ description: 'Conversation artifacts base url' }).optional(),
1604
+ tool_reference: ToolReferenceSchema.meta({
1605
+ description: 'Reference to tools stored in GCP instead of embedding full tool definitions',
1606
+ }).optional(),
1607
+ active_tool_names: z
1608
+ .array(z.string())
1609
+ .meta({
1610
+ description:
1611
+ 'Names of currently active tools (base + unlocked). Tool definitions loaded from tool_reference.',
1612
+ })
1613
+ .optional(),
1614
+ pinned_tool_names: z
1615
+ .array(z.string())
1616
+ .meta({ description: 'Active tools that should not be evicted by bounded active-tool pruning.' })
1617
+ .optional(),
1618
+ used_skills: z
1619
+ .array(UsedSkillSchema)
1620
+ .meta({
1621
+ description:
1622
+ 'Skills that have been used in this conversation (for auto-syncing scripts and package installation)',
1623
+ })
1624
+ .optional(),
1625
+ streaming_enabled: z
1626
+ .boolean()
1627
+ .meta({ description: 'Whether to stream LLM responses to Redis (cached from project config)' })
1628
+ .optional(),
1629
+ checkpoint_threshold: z
1630
+ .number()
1631
+ .meta({
1632
+ description:
1633
+ "Project-configured checkpoint threshold as a fraction of the model's context window (cached from project.configuration.agent_checkpoint_threshold at conversation start).",
1634
+ })
1635
+ .optional(),
1636
+ checkpoint_tokens: z
1637
+ .number()
1638
+ .meta({
1639
+ description:
1640
+ 'Project-configured checkpoint hard cap in tokens (cached from project.configuration.agent_checkpoint_tokens at conversation start). The workflow resolves the effective threshold from these, the per-run checkpoint_tokens override, and the model-based default.',
1641
+ })
1642
+ .optional(),
1643
+ user_channels: z
1644
+ .array(UserChannelSchema)
1645
+ .meta({
1646
+ description:
1647
+ 'Active communication channels with their current state. Channels can be updated as conversation progresses (e.g., email threading info).',
1648
+ })
1649
+ .optional(),
1650
+ resolvedInteraction: ResolvedInteractionExecutionInfoSchema.meta({
1651
+ description:
1652
+ 'The resolved interaction execution info. Contains interaction ID, name, version, and environment details.',
1653
+ }).optional(),
1654
+ end_conversation: z
1655
+ .strictObject({
1656
+ final_result: z.string().optional(),
1657
+ status: z.enum(['success', 'failure']).optional(),
1658
+ reason: z.string().optional(),
1659
+ })
1660
+ .meta({
1661
+ description:
1662
+ 'End conversation metadata set when end_conversation tool is called. Signals the workflow to terminate gracefully.',
1663
+ })
1664
+ .optional(),
1665
+ unlocked_tools: z
1666
+ .array(z.string())
1667
+ .meta({
1668
+ description:
1669
+ 'Tools that have been unlocked by skills during the conversation. These tools were initially hidden (default: false) but became available when a skill with tools was called.',
1670
+ })
1671
+ .optional(),
1672
+ latest_activity_id: z
1673
+ .string()
1674
+ .meta({
1675
+ description:
1676
+ 'Activity ID from the latest LLM call (for deduplication with streamed content). Set by streamToRedis when completing async activities.',
1677
+ })
1678
+ .optional(),
1679
+ latest_streaming_id: z
1680
+ .string()
1681
+ .meta({
1682
+ description:
1683
+ 'Stable streaming ID from the latest LLM call. Unlike Temporal activity IDs, this is scoped to the concrete workflow run that produced the stream, so it remains safe across continue-as-new.',
1684
+ })
1685
+ .optional(),
1686
+ skill_instructions_delivered: z
1687
+ .array(z.string())
1688
+ .meta({
1689
+ description:
1690
+ 'Names of skills whose full instructions are already present in the live conversation history (i.e. were delivered by a prior `learn_<skill>` call). Used to make skill re-activation idempotent: a repeat call returns a short "already active" acknowledgement instead of re-dumping the instructions.\n\nUnlike `unlocked_tools` (which must survive a checkpoint so tools stay unlocked), this list is reset when a checkpoint compacts the conversation, because the summary no longer carries the skill instructions and the next call must re-deliver them.',
1691
+ })
1692
+ .optional(),
1693
+ initialization_call_ids: z
1694
+ .array(z.string())
1695
+ .meta({ description: 'Stable ids of initialization tool calls completed before the first model turn.' })
1696
+ .optional(),
1697
+ disabled_mcp_collections: z
1698
+ .array(z.string())
1699
+ .meta({
1700
+ description:
1701
+ 'Denylist of MCP tool-collection ids deactivated for this conversation. `undefined`/empty means all installed/connected MCP collections are active. Updated mid-conversation via the MCP config signal; consumed when tools are re-discovered.',
1702
+ })
1703
+ .optional(),
1704
+ pending_mcp_connections: z
1705
+ .array(PendingMcpConnectionSchema)
1706
+ .meta({
1707
+ description:
1708
+ 'MCP servers that are active (not disabled) and accessible to the user but not yet OAuth-connected. Surfaced to the agent (via discover_tools) so it can offer to connect.',
1709
+ })
1710
+ .optional(),
1711
+ active_activity_group_id: z
1712
+ .string()
1713
+ .meta({
1714
+ description:
1715
+ 'Current activity group ID for internal tool-execution progress messages. All updates emitted during one tool-execution cycle should share this ID.',
1716
+ })
1717
+ .optional(),
1718
+ finish_reason: z
1719
+ .string()
1720
+ .meta({ description: 'LLM stop reason from the latest call (e.g., "stop", "length", "tool_use")' })
1721
+ .optional(),
1722
+ agent_run_id: z
1723
+ .string()
1724
+ .meta({
1725
+ description:
1726
+ 'The AgentRun ID (MongoDB _id) that owns this conversation. Used for artifact storage paths: agents/{agent_run_id}/ Undefined for legacy workflows started before the AgentRun system.',
1727
+ })
1728
+ .optional(),
1729
+ launch_id: z
1730
+ .string()
1731
+ .meta({
1732
+ description:
1733
+ 'For workstreams: the launch ID assigned by the parent workflow. When set, artifacts are stored under agents/{agent_run_id}/workstreams/{launch_id}/ to consolidate all artifacts under the parent agent run.',
1734
+ })
1735
+ .optional(),
1736
+ app_version: z
1737
+ .string()
1738
+ .meta({
1739
+ description:
1740
+ 'The exact app version this run is pinned to, derived from the `@version` on the started interaction ref / the `x-vertesia-app-version` header at start. Persisted on the state so it survives resume, and applied to the activity client (`withAppVersion`) so every app-owned ref the run resolves — interactions, types, processes, tools — targets this version instead of the current/promoted one. Undefined → current/promoted. Resolution-time only; never a stored capability-ref version.',
1741
+ })
1742
+ .optional(),
1743
+ })
1744
+ .meta({
1745
+ id: 'ConversationState',
1746
+ description:
1747
+ 'Conversation state passed between workflow activities: the activity-safe, per-turn dynamic subset of a multi-turn agent conversation. Rides every conversation activity payload, so it deliberately excludes anything large or fetchable — the conversation history and tool definitions live in artifact storage (referenced via `tool_reference` / the conversation storage id), and catalog/activation data lives in the workflow-memory {@link ConversationCatalogState } (persisted as catalog.json).',
1748
+ });
1749
+
1750
+ export const UpdateExecutionRunPayloadSchema = z
1751
+ .strictObject({
1752
+ id: z.string().optional(),
1753
+ parent: z
1754
+ .union([z.string(), ExecutionRunSchema])
1755
+ .meta({
1756
+ description:
1757
+ 'Only used by runs that were created by a virtual run to point toward the virtual run parent',
1758
+ })
1759
+ .optional(),
1760
+ evaluation: z
1761
+ .strictObject({
1762
+ score: z.number().optional(),
1763
+ selected: z.boolean().optional(),
1764
+ scores: NumberValueMapSchema.optional(),
1765
+ })
1766
+ .optional(),
1767
+ tags: z.array(z.string()).optional(),
1768
+ environment: ExecutionEnvironmentRefSchema.meta({
1769
+ description: 'Environment reference - populated with full object in API responses',
1770
+ }).optional(),
1771
+ modelId: z.string().optional(),
1772
+ result_schema: JSONSchemaSchema.optional(),
1773
+ ttl: z.number().optional(),
1774
+ status: ExecutionRunStatusSchema.optional(),
1775
+ finish_reason: z.string().optional(),
1776
+ prompt: z.unknown().optional(),
1777
+ token_use: ExecutionTokenUsageSchema.optional(),
1778
+ chunks: z.number().optional(),
1779
+ execution_time: z.number().optional(),
1780
+ created_at: z.string().meta({ format: 'date-time' }).optional(),
1781
+ updated_at: z.string().meta({ format: 'date-time' }).optional(),
1782
+ account: AccountRefSchema.optional(),
1783
+ project: ProjectRefSchema.optional(),
1784
+ config: InteractionExecutionConfigurationSchema.optional(),
1785
+ error: InteractionExecutionErrorSchema.optional(),
1786
+ source: RunSourceSchema.optional(),
1787
+ output_modality: ModalitiesSchema.meta({
1788
+ description: 'Deprecated: This is deprecated. Use CompletionResult.type information instead.',
1789
+ deprecated: true,
1790
+ 'x-deprecated-message': 'This is deprecated. Use CompletionResult.type information instead.',
1791
+ }).optional(),
1792
+ created_by: z.string().optional(),
1793
+ updated_by: z.string().optional(),
1794
+ workflow: ExecutionRunWorkflowSchema.meta({
1795
+ description:
1796
+ 'The Vertesia Workflow related to this Interaction Run.\n\nThis is only set when the interaction is executed as part of a workflow.',
1797
+ }).optional(),
1798
+ interaction: InteractionRefSchema.optional(),
1799
+ })
1800
+ .meta({ id: 'UpdateExecutionRunPayload' });
1801
+
1802
+ export const ExecutionRunRefArraySchema = z.array(ExecutionRunRefSchema).meta({ id: 'ExecutionRunRefArray' });
1803
+
1804
+ export const AsyncCompletionOptionsSchema = z
1805
+ .strictObject({
1806
+ run_id: z.string().meta({ description: 'Workflow run ID for message context' }),
1807
+ stream: z.boolean().meta({ description: 'Whether to stream chunks to Redis' }).optional(),
1808
+ streaming: StreamingOptionsSchema.meta({
1809
+ description: 'Streaming-specific options (required if stream=true)',
1810
+ }).optional(),
1811
+ task_token: z
1812
+ .string()
1813
+ .meta({
1814
+ description:
1815
+ 'Temporal task token for async activity completion (base64url encoded). When provided, the platform completes the activity after execution finishes, allowing the worker to release the activity slot immediately.',
1816
+ })
1817
+ .optional(),
1818
+ activity_id: z
1819
+ .string()
1820
+ .meta({
1821
+ description:
1822
+ 'Activity ID for idempotency metadata when storing conversation. Required when task_token is provided.',
1823
+ })
1824
+ .optional(),
1825
+ current_state: ConversationStateSchema.meta({
1826
+ description:
1827
+ 'Current conversation state to merge with execution result. The platform stores the conversation and completes the activity with merged state. Required when task_token is provided.',
1828
+ }).optional(),
1829
+ heartbeat_interval_ms: z
1830
+ .number()
1831
+ .meta({
1832
+ description:
1833
+ 'Interval in milliseconds for sending heartbeats to Temporal during streaming. When provided, the platform sends periodic heartbeats to keep the activity alive. Recommended: 10000 (10 seconds). Activity heartbeat timeout should be ~3x this value.',
1834
+ })
1835
+ .optional(),
1836
+ telemetry: StreamingTelemetryContextSchema.meta({
1837
+ description:
1838
+ 'Telemetry context for sending LlmCallEvent after streaming completes. The platform uses this to send token usage telemetry since the activity exits before the response is available in async completion mode.',
1839
+ }).optional(),
1840
+ result_storage: ResultStorageOptionsSchema.meta({
1841
+ description:
1842
+ 'Storage options for inference result. When provided, the platform stores the result at the specified path after inference completes (before completing the Temporal activity).',
1843
+ }).optional(),
1844
+ completion_mode: AsyncCompletionModeSchema.meta({
1845
+ description:
1846
+ "Controls the value used to complete the Temporal activity. Defaults to `conversation_state` for agent resume/continuation calls. Use `text` for one-shot helper calls, such as checkpoint summaries, that need the model's text result instead of merged conversation state.",
1847
+ }).optional(),
1848
+ })
1849
+ .meta({ id: 'AsyncCompletionOptions', description: 'Options for async completion and/or streaming LLM responses' });
1850
+
1851
+ export const NamedInteractionExecutionPayloadSchema = z
1852
+ .strictObject({
1853
+ data: z
1854
+ .unknown()
1855
+ .meta({
1856
+ description:
1857
+ 'If a `@memory` property exists on the input data then the value will be used as the value of a memory pack location. and the other properties of the data will contain the memory pack mapping.',
1858
+ })
1859
+ .optional(),
1860
+ config: InteractionExecutionConfigurationSchema.optional(),
1861
+ result_schema: z.union([JSONSchemaSchema, SchemaRefSchema, z.null()]).optional(),
1862
+ stream: z.boolean().optional(),
1863
+ do_validate: z.boolean().optional(),
1864
+ tags: z.array(z.string()).optional(),
1865
+ conversation: z
1866
+ .unknown()
1867
+ .meta({
1868
+ description:
1869
+ 'The conversation state to be used in the execution if any. If the `true` is passed then the conversation will be returned in the result. The true value must be used for the first execution that starts the conversation. If conversation is falsy then no conversation is returned back. For regular executions the conversation is not returned back to save memory.',
1870
+ })
1871
+ .optional(),
1872
+ tool_definitions: z
1873
+ .array(ToolDefinitionSchema)
1874
+ .meta({ description: 'The tools to be used in the execution' })
1875
+ .optional(),
1876
+ workflow: ExecutionRunWorkflowSchema.meta({
1877
+ description: 'The workflow related to this Interaction Run.',
1878
+ }).optional(),
1879
+ prompts: z
1880
+ .array(InCodePromptSchema)
1881
+ .meta({
1882
+ description:
1883
+ 'Only used by ad-hoc interactions which defines the prompt in the execution payload itself These are temporary interactions using "tmp:" suffix.',
1884
+ })
1885
+ .optional(),
1886
+ asyncCompletion: AsyncCompletionOptionsSchema.meta({
1887
+ description:
1888
+ 'Options for async completion and/or streaming LLM response chunks to Redis. Used by agent workflows for async activity completion and real-time streaming.',
1889
+ }).optional(),
1890
+ interaction: z.string().meta({
1891
+ description:
1892
+ 'The interaction name and suffixed by an optional tag or version separated from the name using a @ character If no version/tag part is specified then the latest version is used. Example: ReviewContract, ReviewContract@draft, ReviewContract@1, ReviewContract@some-tag',
1893
+ }),
1894
+ })
1895
+ .meta({ id: 'NamedInteractionExecutionPayload' });
1896
+
1897
+ export const InteractionExecutionPayloadSchema = z
1898
+ .strictObject({
1899
+ data: z
1900
+ .unknown()
1901
+ .meta({
1902
+ description:
1903
+ 'If a `@memory` property exists on the input data then the value will be used as the value of a memory pack location. and the other properties of the data will contain the memory pack mapping.',
1904
+ })
1905
+ .optional(),
1906
+ config: InteractionExecutionConfigurationSchema.optional(),
1907
+ result_schema: z.union([JSONSchemaSchema, SchemaRefSchema, z.null()]).optional(),
1908
+ stream: z.boolean().optional(),
1909
+ do_validate: z.boolean().optional(),
1910
+ tags: z.array(z.string()).optional(),
1911
+ conversation: z
1912
+ .unknown()
1913
+ .meta({
1914
+ description:
1915
+ 'The conversation state to be used in the execution if any. If the `true` is passed then the conversation will be returned in the result. The true value must be used for the first execution that starts the conversation. If conversation is falsy then no conversation is returned back. For regular executions the conversation is not returned back to save memory.',
1916
+ })
1917
+ .optional(),
1918
+ tool_definitions: z
1919
+ .array(ToolDefinitionSchema)
1920
+ .meta({ description: 'The tools to be used in the execution' })
1921
+ .optional(),
1922
+ workflow: ExecutionRunWorkflowSchema.meta({
1923
+ description: 'The workflow related to this Interaction Run.',
1924
+ }).optional(),
1925
+ prompts: z
1926
+ .array(InCodePromptSchema)
1927
+ .meta({
1928
+ description:
1929
+ 'Only used by ad-hoc interactions which defines the prompt in the execution payload itself These are temporary interactions using "tmp:" suffix.',
1930
+ })
1931
+ .optional(),
1932
+ asyncCompletion: AsyncCompletionOptionsSchema.meta({
1933
+ description:
1934
+ 'Options for async completion and/or streaming LLM response chunks to Redis. Used by agent workflows for async activity completion and real-time streaming.',
1935
+ }).optional(),
1936
+ })
1937
+ .meta({ id: 'InteractionExecutionPayload' });
1938
+
1939
+ export const AsyncInteractionExecutionPayloadSchema = z
1940
+ .object({
1941
+ interaction: z.string().meta({
1942
+ description:
1943
+ 'The interaction name and suffixed by an optional tag or version separated from the name using a @ character If no version/tag part is specified then the latest version is used. Example: ReviewContract, ReviewContract@draft, ReviewContract@1, ReviewContract@some-tag',
1944
+ }),
1945
+ data: z
1946
+ .unknown()
1947
+ .meta({
1948
+ description:
1949
+ 'If a `@memory` property exists on the input data then the value will be used as the value of a memory pack location. and the other properties of the data will contain the memory pack mapping.',
1950
+ })
1951
+ .optional(),
1952
+ config: InteractionExecutionConfigurationSchema.optional(),
1953
+ result_schema: z.union([JSONSchemaSchema, SchemaRefSchema, z.null()]).optional(),
1954
+ do_validate: z.boolean().optional(),
1955
+ tags: z.array(z.string()).optional(),
1956
+ conversation: z
1957
+ .unknown()
1958
+ .meta({
1959
+ description:
1960
+ 'The conversation state to be used in the execution if any. If the `true` is passed then the conversation will be returned in the result. The true value must be used for the first execution that starts the conversation. If conversation is falsy then no conversation is returned back. For regular executions the conversation is not returned back to save memory.',
1961
+ })
1962
+ .optional(),
1963
+ workflow: ExecutionRunWorkflowSchema.meta({
1964
+ description: 'The workflow related to this Interaction Run.',
1965
+ }).optional(),
1966
+ prompts: z
1967
+ .array(InCodePromptSchema)
1968
+ .meta({
1969
+ description:
1970
+ 'Only used by ad-hoc interactions which defines the prompt in the execution payload itself These are temporary interactions using "tmp:" suffix.',
1971
+ })
1972
+ .optional(),
1973
+ asyncCompletion: AsyncCompletionOptionsSchema.meta({
1974
+ description:
1975
+ 'Options for async completion and/or streaming LLM response chunks to Redis. Used by agent workflows for async activity completion and real-time streaming.',
1976
+ }).optional(),
1977
+ type: z.literal('interaction'),
1978
+ notify_endpoints: z
1979
+ .array(z.string())
1980
+ .meta({ description: 'An array of endpoint URLs to be notified upon execution' })
1981
+ .optional(),
1982
+ task_queue: z.string().optional(),
1983
+ include_previous_error: z
1984
+ .boolean()
1985
+ .meta({
1986
+ description:
1987
+ 'Only used for non conversation workflows to include the error on next retry. If tools is defined this is not used',
1988
+ })
1989
+ .optional(),
1990
+ })
1991
+ .meta({ id: 'AsyncInteractionExecutionPayload' });
1992
+
1993
+ export const AsyncConversationExecutionPayloadSchema = z
1994
+ .object({
1995
+ interaction: z.string().meta({
1996
+ description:
1997
+ 'The interaction name and suffixed by an optional tag or version separated from the name using a @ character If no version/tag part is specified then the latest version is used. Example: ReviewContract, ReviewContract@draft, ReviewContract@1, ReviewContract@some-tag',
1998
+ }),
1999
+ data: z
2000
+ .unknown()
2001
+ .meta({
2002
+ description:
2003
+ 'If a `@memory` property exists on the input data then the value will be used as the value of a memory pack location. and the other properties of the data will contain the memory pack mapping.',
2004
+ })
2005
+ .optional(),
2006
+ config: InteractionExecutionConfigurationSchema.optional(),
2007
+ result_schema: z.union([JSONSchemaSchema, SchemaRefSchema, z.null()]).optional(),
2008
+ do_validate: z.boolean().optional(),
2009
+ tags: z.array(z.string()).optional(),
2010
+ conversation: z
2011
+ .unknown()
2012
+ .meta({
2013
+ description:
2014
+ 'The conversation state to be used in the execution if any. If the `true` is passed then the conversation will be returned in the result. The true value must be used for the first execution that starts the conversation. If conversation is falsy then no conversation is returned back. For regular executions the conversation is not returned back to save memory.',
2015
+ })
2016
+ .optional(),
2017
+ workflow: ExecutionRunWorkflowSchema.meta({
2018
+ description: 'The workflow related to this Interaction Run.',
2019
+ }).optional(),
2020
+ prompts: z
2021
+ .array(InCodePromptSchema)
2022
+ .meta({
2023
+ description:
2024
+ 'Only used by ad-hoc interactions which defines the prompt in the execution payload itself These are temporary interactions using "tmp:" suffix.',
2025
+ })
2026
+ .optional(),
2027
+ asyncCompletion: AsyncCompletionOptionsSchema.meta({
2028
+ description:
2029
+ 'Options for async completion and/or streaming LLM response chunks to Redis. Used by agent workflows for async activity completion and real-time streaming.',
2030
+ }).optional(),
2031
+ type: z.literal('conversation'),
2032
+ notify_endpoints: z
2033
+ .array(z.string())
2034
+ .meta({ description: 'An array of endpoint URLs to be notified upon execution' })
2035
+ .optional(),
2036
+ task_queue: z.string().optional(),
2037
+ tool_approval_mode: AgentToolApprovalModeSchema.meta({
2038
+ description: 'Effective tool approval mode for interactive agent conversations.',
2039
+ }).optional(),
2040
+ visibility: ConversationVisibilitySchema.meta({
2041
+ description:
2042
+ 'Visibility determine if the conversation should be seen by the user only or by anyone with access to the project If not specified, the default is project',
2043
+ }).optional(),
2044
+ tool_names: z
2045
+ .array(z.string())
2046
+ .meta({
2047
+ description:
2048
+ 'The tools to use, list of tool or function names. You can use + and - to add or remove from default, if no sign, then list replaces default',
2049
+ })
2050
+ .optional(),
2051
+ initial_skills: z
2052
+ .array(z.string())
2053
+ .meta({
2054
+ description:
2055
+ 'Builtin system skills to activate at conversation start. Their related tools are exposed from the first turn and their instructions are injected into the initial context, replacing the learn_<skill> round-trip.',
2056
+ })
2057
+ .optional(),
2058
+ initial_tool_calls: z
2059
+ .array(InitialToolCallSchema)
2060
+ .meta({
2061
+ description:
2062
+ "Tool calls executed before the first model turn. Results are injected into the initial context. These run sequentially with the caller's authority before the first model turn. Only a bounded set of read/hydration tools is accepted.",
2063
+ })
2064
+ .optional(),
2065
+ excluded_tools: z
2066
+ .array(z.string())
2067
+ .meta({
2068
+ description:
2069
+ 'Hard denylist of tool names for this conversation. Excluded tools are never exposed to the model and are refused at execution time, even when a skill or tool refresh would otherwise unlock them. Takes precedence over tool_names, initial_skills, and skill-based tool activation.',
2070
+ })
2071
+ .optional(),
2072
+ max_iterations: z
2073
+ .number()
2074
+ .meta({
2075
+ description:
2076
+ 'The maximum number of iterations in case of a conversation. If <=0 the default of 20 will be used.',
2077
+ })
2078
+ .optional(),
2079
+ interactive: z
2080
+ .boolean()
2081
+ .meta({ description: 'Whether the conversation should be interactive or not' })
2082
+ .optional(),
2083
+ user_channels: z
2084
+ .array(UserChannelSchema)
2085
+ .meta({
2086
+ description:
2087
+ 'Array of channels to use for user communication. Multiple channels can be active simultaneously (e.g., both email and interactive). Each channel contains its own configuration and state (e.g., email threading info).',
2088
+ })
2089
+ .optional(),
2090
+ disable_interaction_tools: z
2091
+ .boolean()
2092
+ .meta({ description: 'Whether to disable the generation of interaction tools or not.' })
2093
+ .optional(),
2094
+ search_scope: AgentSearchScope_CollectionSchema.meta({
2095
+ description:
2096
+ 'On which scope should the searched by applied, by the search_tool. Only supports collection scope or null for now.',
2097
+ }).optional(),
2098
+ collection_id: z
2099
+ .string()
2100
+ .meta({ description: 'The collection in which this workflow is executing' })
2101
+ .optional(),
2102
+ disabled_mcp_collections: z
2103
+ .array(z.string())
2104
+ .meta({
2105
+ description:
2106
+ 'Denylist of MCP tool-collection ids deactivated for this conversation. `undefined`/empty means all installed/connected MCP collections are active (back-compat, and new servers stay active by default). Listed collections are excluded even if connected. Can be updated mid-conversation via the MCP config signal.',
2107
+ })
2108
+ .optional(),
2109
+ checkpoint_tokens: z
2110
+ .number()
2111
+ .meta({
2112
+ description:
2113
+ 'The token threshold in thousands (K) for creating checkpoints. If total tokens exceed this value, a checkpoint will be created. When set it wins over every other checkpoint setting, including the structured `checkpoint` override below. If not specified, the default is computed from the selected model context window (80%, capped at 500k).',
2114
+ })
2115
+ .optional(),
2116
+ checkpoint: AgentCheckpointConfigurationSchema.meta({
2117
+ description:
2118
+ "Structured per-run checkpoint override. Field-wise it takes precedence over the interaction's `agent_runner_options.checkpoint` and the project's `configuration.agent.checkpoint`. The legacy absolute `checkpoint_tokens` above still wins over everything when set.",
2119
+ }).optional(),
2120
+ strip_options: ConversationStripOptionsSchema.meta({
2121
+ description:
2122
+ 'Configuration for stripping large data (images, text) from conversation history to prevent JSON serialization issues and reduce storage bloat.',
2123
+ }).optional(),
2124
+ task_id: z.string().meta({ description: 'In child execution workflow, this is the curent task_id' }).optional(),
2125
+ launch_id: z
2126
+ .string()
2127
+ .meta({
2128
+ description:
2129
+ 'Parent-assigned launch ID for non-blocking workstreams. The child uses this when signaling progress/completion back to the parent.',
2130
+ })
2131
+ .optional(),
2132
+ debug_mode: z.boolean().meta({ description: 'Whether to enable debug mode' }).optional(),
2133
+ max_nested_conversation_depth: z
2134
+ .number()
2135
+ .meta({ description: 'Maximum depth for nested conversations to prevent infinite recursion (default: 5)' })
2136
+ .optional(),
2137
+ parent_metadata: z
2138
+ .looseObject({})
2139
+ .meta({
2140
+ description:
2141
+ "Metadata inherited from parent workflow. Used to propagate context (e.g., apiKey, session info) to child workflows/workstreams. When a workstream is spawned, the parent's `data` is preserved here so that child tools can access it via metadata.parent_metadata.",
2142
+ })
2143
+ .optional(),
2144
+ non_blocking_subagents: z
2145
+ .boolean()
2146
+ .meta({
2147
+ description:
2148
+ 'When true, subagent/workstream tool calls use fire-and-forget `startChild()` instead of blocking `executeChild()`. The parent continues reasoning while children run, receiving progress/completion via Temporal signals.',
2149
+ })
2150
+ .optional(),
2151
+ restart_from_workflow_run_id: z
2152
+ .string()
2153
+ .meta({
2154
+ description:
2155
+ "Temporal runId of a previous workflow to restart/fork from. When set, conversation history is loaded from the old run's GCS storage instead of calling startConversation fresh.",
2156
+ })
2157
+ .optional(),
2158
+ source_first_workflow_run_id: z
2159
+ .string()
2160
+ .meta({
2161
+ description:
2162
+ 'The Temporal firstExecutionRunId of the original workflow being restarted/forked. Used by loadConversationForRestart to look up the original ExecutionRun so that token accumulation and status updates target a valid run.',
2163
+ })
2164
+ .optional(),
2165
+ is_fork: z
2166
+ .boolean()
2167
+ .meta({
2168
+ description:
2169
+ 'When true, indicates this is a fork (new ExecutionRun) rather than a restart (reuse original).',
2170
+ })
2171
+ .optional(),
2172
+ agent_run_id: z
2173
+ .string()
2174
+ .meta({
2175
+ description:
2176
+ 'The AgentRun MongoDB _id. Used for artifact storage paths: agents/{agent_run_id}/ Flows into ConversationState and down to workstreams. Undefined for legacy workflows started before the AgentRun system.',
2177
+ })
2178
+ .optional(),
2179
+ schedule_id: z
2180
+ .string()
2181
+ .meta({
2182
+ description:
2183
+ 'The Schedule MongoDB _id. Set when this execution was triggered by a Temporal schedule. Used by the workflow to create an AgentRun on first run if agent_run_id is absent.',
2184
+ })
2185
+ .optional(),
2186
+ })
2187
+ .meta({ id: 'AsyncConversationExecutionPayload' });
2188
+
2189
+ export const RunCreatePayloadSchema = z
2190
+ .strictObject({
2191
+ data: z
2192
+ .unknown()
2193
+ .meta({
2194
+ description:
2195
+ 'If a `@memory` property exists on the input data then the value will be used as the value of a memory pack location. and the other properties of the data will contain the memory pack mapping.',
2196
+ })
2197
+ .optional(),
2198
+ config: InteractionExecutionConfigurationSchema.optional(),
2199
+ result_schema: z.union([JSONSchemaSchema, SchemaRefSchema, z.null()]).optional(),
2200
+ stream: z.boolean().optional(),
2201
+ do_validate: z.boolean().optional(),
2202
+ tags: z.array(z.string()).optional(),
2203
+ conversation: z
2204
+ .unknown()
2205
+ .meta({
2206
+ description:
2207
+ 'The conversation state to be used in the execution if any. If the `true` is passed then the conversation will be returned in the result. The true value must be used for the first execution that starts the conversation. If conversation is falsy then no conversation is returned back. For regular executions the conversation is not returned back to save memory.',
2208
+ })
2209
+ .optional(),
2210
+ tool_definitions: z
2211
+ .array(ToolDefinitionSchema)
2212
+ .meta({ description: 'The tools to be used in the execution' })
2213
+ .optional(),
2214
+ workflow: ExecutionRunWorkflowSchema.meta({
2215
+ description: 'The workflow related to this Interaction Run.',
2216
+ }).optional(),
2217
+ prompts: z
2218
+ .array(InCodePromptSchema)
2219
+ .meta({
2220
+ description:
2221
+ 'Only used by ad-hoc interactions which defines the prompt in the execution payload itself These are temporary interactions using "tmp:" suffix.',
2222
+ })
2223
+ .optional(),
2224
+ asyncCompletion: AsyncCompletionOptionsSchema.meta({
2225
+ description:
2226
+ 'Options for async completion and/or streaming LLM response chunks to Redis. Used by agent workflows for async activity completion and real-time streaming.',
2227
+ }).optional(),
2228
+ interaction: z.string().meta({
2229
+ description:
2230
+ 'The interaction name and suffixed by an optional tag or version separated from the name using a @ character If no version/tag part is specified then the latest version is used. Example: ReviewContract, ReviewContract@draft, ReviewContract@1, ReviewContract@some-tag',
2231
+ }),
2232
+ })
2233
+ .meta({
2234
+ id: 'RunCreatePayload',
2235
+ description:
2236
+ 'Interaction execution payload for creating a new run It uses interaction field (from NamedInteractionExecutionPayload) to pass the interaction ID to run',
2237
+ });
2238
+
2239
+ export const AsyncExecutionPayloadSchema = z
2240
+ .discriminatedUnion('type', [AsyncConversationExecutionPayloadSchema, AsyncInteractionExecutionPayloadSchema])
2241
+ .meta({ id: 'AsyncExecutionPayload' });
2242
+
2243
+ /** Query, header, and computed-facet contracts that are authored directly from their wire shapes. */
2244
+
2245
+ export const CatalogTagQuerySchema = z
2246
+ .strictObject({
2247
+ tag: z.string().optional(),
2248
+ })
2249
+ .meta({ id: 'CatalogTagQuery' });
2250
+
2251
+ export const StoredCatalogInteractionsQuerySchema = z
2252
+ .strictObject({
2253
+ tag: z.string().optional(),
2254
+ status: z.string().optional(),
2255
+ published: z.boolean().optional(),
2256
+ })
2257
+ .meta({ id: 'StoredCatalogInteractionsQuery' });
2258
+
2259
+ export const ExecuteInteractionByEndpointQuerySchema = z
2260
+ .strictObject({
2261
+ tag: z.string().optional(),
2262
+ })
2263
+ .meta({ id: 'ExecuteInteractionByEndpointQuery' });
2264
+
2265
+ export const ExecuteInteractionByEndpointHeadersSchema = z
2266
+ .strictObject({
2267
+ 'x-interaction-tag': z.string().optional(),
2268
+ })
2269
+ .meta({ id: 'ExecuteInteractionByEndpointHeaders' });
2270
+
2271
+ export const ResolveInteractionQuerySchema = z
2272
+ .strictObject({
2273
+ environment: z.string().optional(),
2274
+ model: z.string().optional(),
2275
+ hasImage: z.boolean().optional(),
2276
+ hasVideo: z.boolean().optional(),
2277
+ })
2278
+ .meta({ id: 'ResolveInteractionQuery' });
2279
+
2280
+ // `z.unknown().meta({ type: [...] })` rather than `z.union([z.array(...), z.number()])`, which is
2281
+ // the shape the TypeScript index signature actually describes. Two reasons, and they agree:
2282
+ // the published component is `{ type: ['array', 'number'] }`, so this re-emits it unchanged; and
2283
+ // a union here would publish `anyOf` on an additionalProperties value, which the generated-client
2284
+ // rules rule out for a primitive-or-collection value. The emitted schema is what AJV compiles, so
2285
+ // array-or-number is enforced either way.
2286
+ export const ComputedFacetResponseSchema = z
2287
+ .object({
2288
+ total: z.number().optional(),
2289
+ })
2290
+ .catchall(z.unknown().meta({ type: ['array', 'number'] }))
2291
+ .meta({ id: 'ComputedFacetResponse' });
2292
+
2293
+ const resumeConversationFields = {
2294
+ run: ExecutionRunDocRefSchema,
2295
+ environment: z.string(),
2296
+ options: StatelessExecutionOptionsSchema,
2297
+ // Optional because `unknown` includes `undefined` in TypeScript and `JSON.stringify` drops an
2298
+ // undefined value entirely, so a caller resuming without prior conversation state sends no
2299
+ // `conversation` key at all. `z.unknown()` alone still lists it in `required`, which rejected
2300
+ // exactly those callers — the first message of a conversation.
2301
+ conversation: z.unknown().optional(),
2302
+ tools: z.array(ToolDefinitionSchema),
2303
+ strip_options: ConversationStripOptionsSchema.optional(),
2304
+ asyncCompletion: AsyncCompletionOptionsSchema.optional(),
2305
+ };
2306
+
2307
+ export const ToolResultsPayloadSchema = z
2308
+ .strictObject({ ...resumeConversationFields, results: z.array(ToolResultSchema) })
2309
+ .meta({ id: 'ToolResultsPayload' });
2310
+
2311
+ export const UserMessagePayloadSchema = z
2312
+ .strictObject({ ...resumeConversationFields, message: z.string() })
2313
+ .meta({ id: 'UserMessagePayload' });
2314
+
2315
+ export const ExecutionResponseSchema = z
2316
+ .strictObject({
2317
+ result: z.array(CompletionResultSchema),
2318
+ token_usage: ExecutionTokenUsageSchema.optional(),
2319
+ tool_use: z.array(ToolUseSchema).optional(),
2320
+ finish_reason: z.string().optional(),
2321
+ error: z
2322
+ .strictObject({
2323
+ code: z.enum(['validation_error', 'json_error', 'content_policy_violation']),
2324
+ message: z.string(),
2325
+ data: z.array(CompletionResultSchema).optional(),
2326
+ })
2327
+ .optional(),
2328
+ original_response: z.unknown().optional(),
2329
+ conversation: z.unknown().optional(),
2330
+ prompt: z.unknown(),
2331
+ execution_time: z.number().optional(),
2332
+ chunks: z.number().optional(),
2333
+ })
2334
+ .meta({ id: 'ExecutionResponse' });
2335
+
2336
+ export const ComputeRunFacetPayloadSchema = z
2337
+ .strictObject({ facets: z.array(FacetSpecSchema), query: RunSearchQuerySchema.optional() })
2338
+ .meta({ id: 'ComputeRunFacetPayload' });
2339
+
2340
+ export const RunSearchMetaResponseSchema = z
2341
+ .strictObject({
2342
+ count: z.strictObject({ lower_bound: z.number().optional(), total: z.number().optional() }),
2343
+ facet: z.record(
2344
+ z.string(),
2345
+ z.strictObject({
2346
+ buckets: z.array(z.strictObject({ _id: z.string(), count: z.number() })),
2347
+ }),
2348
+ ),
2349
+ })
2350
+ .meta({ id: 'RunSearchMetaResponse' });
2351
+
2352
+ export const RunClonePayloadSchema = z
2353
+ .strictObject({
2354
+ source_run_id: z.string(),
2355
+ workflow: z.strictObject({ run_id: z.string(), workflow_id: z.string() }),
2356
+ })
2357
+ .meta({ id: 'RunClonePayload' });