@vertesia/workflow 0.77.0 → 0.78.0-dev-9372725

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 (409) hide show
  1. package/package.json +128 -120
  2. package/src/activities/advanced/createDocumentTypeFromInteractionRun.ts +8 -5
  3. package/src/activities/advanced/createOrUpdateDocumentFromInteractionRun.ts +6 -10
  4. package/src/activities/advanced/updateDocumentFromInteractionRun.ts +4 -1
  5. package/src/activities/chunkDocument.ts +4 -1
  6. package/src/activities/executeInteraction.ts +16 -9
  7. package/src/activities/generateDocumentProperties.ts +13 -7
  8. package/src/activities/generateOrAssignContentType.ts +17 -11
  9. package/src/activities/index-dsl.ts +1 -1
  10. package/src/activities/notifyWebhook.test.ts +117 -19
  11. package/src/activities/notifyWebhook.ts +17 -4
  12. package/src/activities/rateLimiter.ts +41 -0
  13. package/src/conversion/image.ts +6 -3
  14. package/src/dsl/dsl-workflow.ts +80 -0
  15. package/src/dsl/setup/ActivityContext.ts +45 -12
  16. package/src/dsl/workflow-exec-child.test.ts +4 -3
  17. package/src/dsl/workflow-fetch.test.ts +1 -1
  18. package/src/dsl/workflow-import.test.ts +1 -1
  19. package/src/dsl/workflow.test.ts +2 -1
  20. package/src/errors.ts +13 -0
  21. package/src/index.ts +1 -1
  22. package/src/iterative-generation/activities/extractToc.ts +26 -12
  23. package/src/iterative-generation/activities/finalizeOutput.ts +52 -29
  24. package/src/iterative-generation/activities/generatePart.ts +66 -24
  25. package/src/iterative-generation/activities/generateToc.ts +85 -66
  26. package/src/iterative-generation/utils.ts +2 -2
  27. package/src/utils/blobs.ts +3 -1
  28. package/src/utils/client.ts +22 -8
  29. package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js +0 -32
  30. package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js.map +0 -1
  31. package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +0 -72
  32. package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +0 -1
  33. package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js +0 -18
  34. package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js.map +0 -1
  35. package/lib/cjs/activities/chunkDocument.js +0 -84
  36. package/lib/cjs/activities/chunkDocument.js.map +0 -1
  37. package/lib/cjs/activities/createDocumentFromOther.js +0 -64
  38. package/lib/cjs/activities/createDocumentFromOther.js.map +0 -1
  39. package/lib/cjs/activities/executeInteraction.js +0 -186
  40. package/lib/cjs/activities/executeInteraction.js.map +0 -1
  41. package/lib/cjs/activities/extractDocumentText.js +0 -156
  42. package/lib/cjs/activities/extractDocumentText.js.map +0 -1
  43. package/lib/cjs/activities/generateDocumentProperties.js +0 -78
  44. package/lib/cjs/activities/generateDocumentProperties.js.map +0 -1
  45. package/lib/cjs/activities/generateEmbeddings.js +0 -358
  46. package/lib/cjs/activities/generateEmbeddings.js.map +0 -1
  47. package/lib/cjs/activities/generateOrAssignContentType.js +0 -123
  48. package/lib/cjs/activities/generateOrAssignContentType.js.map +0 -1
  49. package/lib/cjs/activities/getObjectFromStore.js +0 -20
  50. package/lib/cjs/activities/getObjectFromStore.js.map +0 -1
  51. package/lib/cjs/activities/handleError.js +0 -22
  52. package/lib/cjs/activities/handleError.js.map +0 -1
  53. package/lib/cjs/activities/identifyTextSections.js +0 -48
  54. package/lib/cjs/activities/identifyTextSections.js.map +0 -1
  55. package/lib/cjs/activities/index-dsl.js +0 -43
  56. package/lib/cjs/activities/index-dsl.js.map +0 -1
  57. package/lib/cjs/activities/index.js +0 -21
  58. package/lib/cjs/activities/index.js.map +0 -1
  59. package/lib/cjs/activities/media/processPdfWithTextract.js +0 -103
  60. package/lib/cjs/activities/media/processPdfWithTextract.js.map +0 -1
  61. package/lib/cjs/activities/media/transcribeMediaWithGladia.js +0 -51
  62. package/lib/cjs/activities/media/transcribeMediaWithGladia.js.map +0 -1
  63. package/lib/cjs/activities/notifyWebhook.js +0 -33
  64. package/lib/cjs/activities/notifyWebhook.js.map +0 -1
  65. package/lib/cjs/activities/renditions/generateImageRendition.js +0 -66
  66. package/lib/cjs/activities/renditions/generateImageRendition.js.map +0 -1
  67. package/lib/cjs/activities/renditions/generateVideoRendition.js +0 -200
  68. package/lib/cjs/activities/renditions/generateVideoRendition.js.map +0 -1
  69. package/lib/cjs/activities/setDocumentStatus.js +0 -15
  70. package/lib/cjs/activities/setDocumentStatus.js.map +0 -1
  71. package/lib/cjs/conversion/TextractProcessor.js +0 -417
  72. package/lib/cjs/conversion/TextractProcessor.js.map +0 -1
  73. package/lib/cjs/conversion/image.js +0 -147
  74. package/lib/cjs/conversion/image.js.map +0 -1
  75. package/lib/cjs/conversion/markitdown.js +0 -42
  76. package/lib/cjs/conversion/markitdown.js.map +0 -1
  77. package/lib/cjs/conversion/mutool.js +0 -147
  78. package/lib/cjs/conversion/mutool.js.map +0 -1
  79. package/lib/cjs/conversion/pandoc.js +0 -39
  80. package/lib/cjs/conversion/pandoc.js.map +0 -1
  81. package/lib/cjs/dsl/conditions.js +0 -81
  82. package/lib/cjs/dsl/conditions.js.map +0 -1
  83. package/lib/cjs/dsl/dsl-workflow.js +0 -277
  84. package/lib/cjs/dsl/dsl-workflow.js.map +0 -1
  85. package/lib/cjs/dsl/dslProxyActivities.js +0 -23
  86. package/lib/cjs/dsl/dslProxyActivities.js.map +0 -1
  87. package/lib/cjs/dsl/projections.js +0 -59
  88. package/lib/cjs/dsl/projections.js.map +0 -1
  89. package/lib/cjs/dsl/setup/ActivityContext.js +0 -120
  90. package/lib/cjs/dsl/setup/ActivityContext.js.map +0 -1
  91. package/lib/cjs/dsl/setup/fetch/DataProvider.js +0 -51
  92. package/lib/cjs/dsl/setup/fetch/DataProvider.js.map +0 -1
  93. package/lib/cjs/dsl/setup/fetch/index.js +0 -16
  94. package/lib/cjs/dsl/setup/fetch/index.js.map +0 -1
  95. package/lib/cjs/dsl/setup/fetch/providers.js +0 -67
  96. package/lib/cjs/dsl/setup/fetch/providers.js.map +0 -1
  97. package/lib/cjs/dsl/test/test-child-workflow.js +0 -10
  98. package/lib/cjs/dsl/test/test-child-workflow.js.map +0 -1
  99. package/lib/cjs/dsl/validation.js +0 -122
  100. package/lib/cjs/dsl/validation.js.map +0 -1
  101. package/lib/cjs/dsl/vars.js +0 -341
  102. package/lib/cjs/dsl/vars.js.map +0 -1
  103. package/lib/cjs/dsl/walk.js +0 -100
  104. package/lib/cjs/dsl/walk.js.map +0 -1
  105. package/lib/cjs/dsl.js +0 -20
  106. package/lib/cjs/dsl.js.map +0 -1
  107. package/lib/cjs/errors.js +0 -49
  108. package/lib/cjs/errors.js.map +0 -1
  109. package/lib/cjs/index.js +0 -54
  110. package/lib/cjs/index.js.map +0 -1
  111. package/lib/cjs/iterative-generation/activities/extractToc.js +0 -47
  112. package/lib/cjs/iterative-generation/activities/extractToc.js.map +0 -1
  113. package/lib/cjs/iterative-generation/activities/finalizeOutput.js +0 -69
  114. package/lib/cjs/iterative-generation/activities/finalizeOutput.js.map +0 -1
  115. package/lib/cjs/iterative-generation/activities/generatePart.js +0 -73
  116. package/lib/cjs/iterative-generation/activities/generatePart.js.map +0 -1
  117. package/lib/cjs/iterative-generation/activities/generateToc.js +0 -91
  118. package/lib/cjs/iterative-generation/activities/generateToc.js.map +0 -1
  119. package/lib/cjs/iterative-generation/activities/index.js +0 -12
  120. package/lib/cjs/iterative-generation/activities/index.js.map +0 -1
  121. package/lib/cjs/iterative-generation/iterativeGenerationWorkflow.js +0 -56
  122. package/lib/cjs/iterative-generation/iterativeGenerationWorkflow.js.map +0 -1
  123. package/lib/cjs/iterative-generation/types.js +0 -5
  124. package/lib/cjs/iterative-generation/types.js.map +0 -1
  125. package/lib/cjs/iterative-generation/utils.js +0 -121
  126. package/lib/cjs/iterative-generation/utils.js.map +0 -1
  127. package/lib/cjs/package.json +0 -3
  128. package/lib/cjs/result-types.js +0 -10
  129. package/lib/cjs/result-types.js.map +0 -1
  130. package/lib/cjs/system/notifyWebhookWorkflow.js +0 -46
  131. package/lib/cjs/system/notifyWebhookWorkflow.js.map +0 -1
  132. package/lib/cjs/system/recalculateEmbeddingsWorkflow.js +0 -33
  133. package/lib/cjs/system/recalculateEmbeddingsWorkflow.js.map +0 -1
  134. package/lib/cjs/utils/auth.js +0 -15
  135. package/lib/cjs/utils/auth.js.map +0 -1
  136. package/lib/cjs/utils/blobs.js +0 -61
  137. package/lib/cjs/utils/blobs.js.map +0 -1
  138. package/lib/cjs/utils/chunks.js +0 -14
  139. package/lib/cjs/utils/chunks.js.map +0 -1
  140. package/lib/cjs/utils/client.js +0 -29
  141. package/lib/cjs/utils/client.js.map +0 -1
  142. package/lib/cjs/utils/expand-vars.js +0 -33
  143. package/lib/cjs/utils/expand-vars.js.map +0 -1
  144. package/lib/cjs/utils/memory.js +0 -65
  145. package/lib/cjs/utils/memory.js.map +0 -1
  146. package/lib/cjs/utils/renditions.js +0 -88
  147. package/lib/cjs/utils/renditions.js.map +0 -1
  148. package/lib/cjs/utils/storage.js +0 -55
  149. package/lib/cjs/utils/storage.js.map +0 -1
  150. package/lib/cjs/utils/tokens.js +0 -38
  151. package/lib/cjs/utils/tokens.js.map +0 -1
  152. package/lib/cjs/vars.js +0 -20
  153. package/lib/cjs/vars.js.map +0 -1
  154. package/lib/cjs/workflows.js +0 -15
  155. package/lib/cjs/workflows.js.map +0 -1
  156. package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js +0 -29
  157. package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js.map +0 -1
  158. package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +0 -69
  159. package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +0 -1
  160. package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js +0 -15
  161. package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js.map +0 -1
  162. package/lib/esm/activities/chunkDocument.js +0 -81
  163. package/lib/esm/activities/chunkDocument.js.map +0 -1
  164. package/lib/esm/activities/createDocumentFromOther.js +0 -58
  165. package/lib/esm/activities/createDocumentFromOther.js.map +0 -1
  166. package/lib/esm/activities/executeInteraction.js +0 -182
  167. package/lib/esm/activities/executeInteraction.js.map +0 -1
  168. package/lib/esm/activities/extractDocumentText.js +0 -153
  169. package/lib/esm/activities/extractDocumentText.js.map +0 -1
  170. package/lib/esm/activities/generateDocumentProperties.js +0 -75
  171. package/lib/esm/activities/generateDocumentProperties.js.map +0 -1
  172. package/lib/esm/activities/generateEmbeddings.js +0 -355
  173. package/lib/esm/activities/generateEmbeddings.js.map +0 -1
  174. package/lib/esm/activities/generateOrAssignContentType.js +0 -120
  175. package/lib/esm/activities/generateOrAssignContentType.js.map +0 -1
  176. package/lib/esm/activities/getObjectFromStore.js +0 -17
  177. package/lib/esm/activities/getObjectFromStore.js.map +0 -1
  178. package/lib/esm/activities/handleError.js +0 -19
  179. package/lib/esm/activities/handleError.js.map +0 -1
  180. package/lib/esm/activities/identifyTextSections.js +0 -45
  181. package/lib/esm/activities/identifyTextSections.js.map +0 -1
  182. package/lib/esm/activities/index-dsl.js +0 -21
  183. package/lib/esm/activities/index-dsl.js.map +0 -1
  184. package/lib/esm/activities/index.js +0 -5
  185. package/lib/esm/activities/index.js.map +0 -1
  186. package/lib/esm/activities/media/processPdfWithTextract.js +0 -99
  187. package/lib/esm/activities/media/processPdfWithTextract.js.map +0 -1
  188. package/lib/esm/activities/media/transcribeMediaWithGladia.js +0 -48
  189. package/lib/esm/activities/media/transcribeMediaWithGladia.js.map +0 -1
  190. package/lib/esm/activities/notifyWebhook.js +0 -30
  191. package/lib/esm/activities/notifyWebhook.js.map +0 -1
  192. package/lib/esm/activities/renditions/generateImageRendition.js +0 -63
  193. package/lib/esm/activities/renditions/generateImageRendition.js.map +0 -1
  194. package/lib/esm/activities/renditions/generateVideoRendition.js +0 -194
  195. package/lib/esm/activities/renditions/generateVideoRendition.js.map +0 -1
  196. package/lib/esm/activities/setDocumentStatus.js +0 -12
  197. package/lib/esm/activities/setDocumentStatus.js.map +0 -1
  198. package/lib/esm/conversion/TextractProcessor.js +0 -410
  199. package/lib/esm/conversion/TextractProcessor.js.map +0 -1
  200. package/lib/esm/conversion/image.js +0 -141
  201. package/lib/esm/conversion/image.js.map +0 -1
  202. package/lib/esm/conversion/markitdown.js +0 -36
  203. package/lib/esm/conversion/markitdown.js.map +0 -1
  204. package/lib/esm/conversion/mutool.js +0 -139
  205. package/lib/esm/conversion/mutool.js.map +0 -1
  206. package/lib/esm/conversion/pandoc.js +0 -36
  207. package/lib/esm/conversion/pandoc.js.map +0 -1
  208. package/lib/esm/dsl/conditions.js +0 -75
  209. package/lib/esm/dsl/conditions.js.map +0 -1
  210. package/lib/esm/dsl/dsl-workflow.js +0 -270
  211. package/lib/esm/dsl/dsl-workflow.js.map +0 -1
  212. package/lib/esm/dsl/dslProxyActivities.js +0 -20
  213. package/lib/esm/dsl/dslProxyActivities.js.map +0 -1
  214. package/lib/esm/dsl/projections.js +0 -55
  215. package/lib/esm/dsl/projections.js.map +0 -1
  216. package/lib/esm/dsl/setup/ActivityContext.js +0 -115
  217. package/lib/esm/dsl/setup/ActivityContext.js.map +0 -1
  218. package/lib/esm/dsl/setup/fetch/DataProvider.js +0 -47
  219. package/lib/esm/dsl/setup/fetch/DataProvider.js.map +0 -1
  220. package/lib/esm/dsl/setup/fetch/index.js +0 -12
  221. package/lib/esm/dsl/setup/fetch/index.js.map +0 -1
  222. package/lib/esm/dsl/setup/fetch/providers.js +0 -61
  223. package/lib/esm/dsl/setup/fetch/providers.js.map +0 -1
  224. package/lib/esm/dsl/test/test-child-workflow.js +0 -5
  225. package/lib/esm/dsl/test/test-child-workflow.js.map +0 -1
  226. package/lib/esm/dsl/validation.js +0 -118
  227. package/lib/esm/dsl/validation.js.map +0 -1
  228. package/lib/esm/dsl/vars.js +0 -335
  229. package/lib/esm/dsl/vars.js.map +0 -1
  230. package/lib/esm/dsl/walk.js +0 -96
  231. package/lib/esm/dsl/walk.js.map +0 -1
  232. package/lib/esm/dsl.js +0 -4
  233. package/lib/esm/dsl.js.map +0 -1
  234. package/lib/esm/errors.js +0 -42
  235. package/lib/esm/errors.js.map +0 -1
  236. package/lib/esm/index.js +0 -36
  237. package/lib/esm/index.js.map +0 -1
  238. package/lib/esm/iterative-generation/activities/extractToc.js +0 -44
  239. package/lib/esm/iterative-generation/activities/extractToc.js.map +0 -1
  240. package/lib/esm/iterative-generation/activities/finalizeOutput.js +0 -66
  241. package/lib/esm/iterative-generation/activities/finalizeOutput.js.map +0 -1
  242. package/lib/esm/iterative-generation/activities/generatePart.js +0 -70
  243. package/lib/esm/iterative-generation/activities/generatePart.js.map +0 -1
  244. package/lib/esm/iterative-generation/activities/generateToc.js +0 -88
  245. package/lib/esm/iterative-generation/activities/generateToc.js.map +0 -1
  246. package/lib/esm/iterative-generation/activities/index.js +0 -5
  247. package/lib/esm/iterative-generation/activities/index.js.map +0 -1
  248. package/lib/esm/iterative-generation/iterativeGenerationWorkflow.js +0 -53
  249. package/lib/esm/iterative-generation/iterativeGenerationWorkflow.js.map +0 -1
  250. package/lib/esm/iterative-generation/types.js +0 -2
  251. package/lib/esm/iterative-generation/types.js.map +0 -1
  252. package/lib/esm/iterative-generation/utils.js +0 -112
  253. package/lib/esm/iterative-generation/utils.js.map +0 -1
  254. package/lib/esm/result-types.js +0 -7
  255. package/lib/esm/result-types.js.map +0 -1
  256. package/lib/esm/system/notifyWebhookWorkflow.js +0 -43
  257. package/lib/esm/system/notifyWebhookWorkflow.js.map +0 -1
  258. package/lib/esm/system/recalculateEmbeddingsWorkflow.js +0 -30
  259. package/lib/esm/system/recalculateEmbeddingsWorkflow.js.map +0 -1
  260. package/lib/esm/utils/auth.js +0 -8
  261. package/lib/esm/utils/auth.js.map +0 -1
  262. package/lib/esm/utils/blobs.js +0 -51
  263. package/lib/esm/utils/blobs.js.map +0 -1
  264. package/lib/esm/utils/chunks.js +0 -9
  265. package/lib/esm/utils/chunks.js.map +0 -1
  266. package/lib/esm/utils/client.js +0 -25
  267. package/lib/esm/utils/client.js.map +0 -1
  268. package/lib/esm/utils/expand-vars.js +0 -30
  269. package/lib/esm/utils/expand-vars.js.map +0 -1
  270. package/lib/esm/utils/memory.js +0 -55
  271. package/lib/esm/utils/memory.js.map +0 -1
  272. package/lib/esm/utils/renditions.js +0 -80
  273. package/lib/esm/utils/renditions.js.map +0 -1
  274. package/lib/esm/utils/storage.js +0 -46
  275. package/lib/esm/utils/storage.js.map +0 -1
  276. package/lib/esm/utils/tokens.js +0 -34
  277. package/lib/esm/utils/tokens.js.map +0 -1
  278. package/lib/esm/vars.js +0 -4
  279. package/lib/esm/vars.js.map +0 -1
  280. package/lib/esm/workflows.js +0 -8
  281. package/lib/esm/workflows.js.map +0 -1
  282. package/lib/types/activities/advanced/createDocumentTypeFromInteractionRun.d.ts +0 -17
  283. package/lib/types/activities/advanced/createDocumentTypeFromInteractionRun.d.ts.map +0 -1
  284. package/lib/types/activities/advanced/createOrUpdateDocumentFromInteractionRun.d.ts +0 -39
  285. package/lib/types/activities/advanced/createOrUpdateDocumentFromInteractionRun.d.ts.map +0 -1
  286. package/lib/types/activities/advanced/updateDocumentFromInteractionRun.d.ts +0 -19
  287. package/lib/types/activities/advanced/updateDocumentFromInteractionRun.d.ts.map +0 -1
  288. package/lib/types/activities/chunkDocument.d.ts +0 -33
  289. package/lib/types/activities/chunkDocument.d.ts.map +0 -1
  290. package/lib/types/activities/createDocumentFromOther.d.ts +0 -21
  291. package/lib/types/activities/createDocumentFromOther.d.ts.map +0 -1
  292. package/lib/types/activities/executeInteraction.d.ts +0 -57
  293. package/lib/types/activities/executeInteraction.d.ts.map +0 -1
  294. package/lib/types/activities/extractDocumentText.d.ts +0 -10
  295. package/lib/types/activities/extractDocumentText.d.ts.map +0 -1
  296. package/lib/types/activities/generateDocumentProperties.d.ts +0 -32
  297. package/lib/types/activities/generateDocumentProperties.d.ts.map +0 -1
  298. package/lib/types/activities/generateEmbeddings.d.ts +0 -53
  299. package/lib/types/activities/generateEmbeddings.d.ts.map +0 -1
  300. package/lib/types/activities/generateOrAssignContentType.d.ts +0 -44
  301. package/lib/types/activities/generateOrAssignContentType.d.ts.map +0 -1
  302. package/lib/types/activities/getObjectFromStore.d.ts +0 -14
  303. package/lib/types/activities/getObjectFromStore.d.ts.map +0 -1
  304. package/lib/types/activities/handleError.d.ts +0 -6
  305. package/lib/types/activities/handleError.d.ts.map +0 -1
  306. package/lib/types/activities/identifyTextSections.d.ts +0 -12
  307. package/lib/types/activities/identifyTextSections.d.ts.map +0 -1
  308. package/lib/types/activities/index-dsl.d.ts +0 -20
  309. package/lib/types/activities/index-dsl.d.ts.map +0 -1
  310. package/lib/types/activities/index.d.ts +0 -5
  311. package/lib/types/activities/index.d.ts.map +0 -1
  312. package/lib/types/activities/media/processPdfWithTextract.d.ts +0 -26
  313. package/lib/types/activities/media/processPdfWithTextract.d.ts.map +0 -1
  314. package/lib/types/activities/media/transcribeMediaWithGladia.d.ts +0 -14
  315. package/lib/types/activities/media/transcribeMediaWithGladia.d.ts.map +0 -1
  316. package/lib/types/activities/notifyWebhook.d.ts +0 -16
  317. package/lib/types/activities/notifyWebhook.d.ts.map +0 -1
  318. package/lib/types/activities/renditions/generateImageRendition.d.ts +0 -14
  319. package/lib/types/activities/renditions/generateImageRendition.d.ts.map +0 -1
  320. package/lib/types/activities/renditions/generateVideoRendition.d.ts +0 -15
  321. package/lib/types/activities/renditions/generateVideoRendition.d.ts.map +0 -1
  322. package/lib/types/activities/setDocumentStatus.d.ts +0 -15
  323. package/lib/types/activities/setDocumentStatus.d.ts.map +0 -1
  324. package/lib/types/conversion/TextractProcessor.d.ts +0 -45
  325. package/lib/types/conversion/TextractProcessor.d.ts.map +0 -1
  326. package/lib/types/conversion/image.d.ts +0 -13
  327. package/lib/types/conversion/image.d.ts.map +0 -1
  328. package/lib/types/conversion/markitdown.d.ts +0 -2
  329. package/lib/types/conversion/markitdown.d.ts.map +0 -1
  330. package/lib/types/conversion/mutool.d.ts +0 -19
  331. package/lib/types/conversion/mutool.d.ts.map +0 -1
  332. package/lib/types/conversion/pandoc.d.ts +0 -2
  333. package/lib/types/conversion/pandoc.d.ts.map +0 -1
  334. package/lib/types/dsl/conditions.d.ts +0 -2
  335. package/lib/types/dsl/conditions.d.ts.map +0 -1
  336. package/lib/types/dsl/dsl-workflow.d.ts +0 -5
  337. package/lib/types/dsl/dsl-workflow.d.ts.map +0 -1
  338. package/lib/types/dsl/dslProxyActivities.d.ts +0 -10
  339. package/lib/types/dsl/dslProxyActivities.d.ts.map +0 -1
  340. package/lib/types/dsl/projections.d.ts +0 -4
  341. package/lib/types/dsl/projections.d.ts.map +0 -1
  342. package/lib/types/dsl/setup/ActivityContext.d.ts +0 -17
  343. package/lib/types/dsl/setup/ActivityContext.d.ts.map +0 -1
  344. package/lib/types/dsl/setup/fetch/DataProvider.d.ts +0 -9
  345. package/lib/types/dsl/setup/fetch/DataProvider.d.ts.map +0 -1
  346. package/lib/types/dsl/setup/fetch/index.d.ts +0 -6
  347. package/lib/types/dsl/setup/fetch/index.d.ts.map +0 -1
  348. package/lib/types/dsl/setup/fetch/providers.d.ts +0 -25
  349. package/lib/types/dsl/setup/fetch/providers.d.ts.map +0 -1
  350. package/lib/types/dsl/test/test-child-workflow.d.ts +0 -4
  351. package/lib/types/dsl/test/test-child-workflow.d.ts.map +0 -1
  352. package/lib/types/dsl/validation.d.ts +0 -4
  353. package/lib/types/dsl/validation.d.ts.map +0 -1
  354. package/lib/types/dsl/vars.d.ts +0 -48
  355. package/lib/types/dsl/vars.d.ts.map +0 -1
  356. package/lib/types/dsl/walk.d.ts +0 -18
  357. package/lib/types/dsl/walk.d.ts.map +0 -1
  358. package/lib/types/dsl.d.ts +0 -4
  359. package/lib/types/dsl.d.ts.map +0 -1
  360. package/lib/types/errors.d.ts +0 -23
  361. package/lib/types/errors.d.ts.map +0 -1
  362. package/lib/types/index.d.ts +0 -35
  363. package/lib/types/index.d.ts.map +0 -1
  364. package/lib/types/iterative-generation/activities/extractToc.d.ts +0 -10
  365. package/lib/types/iterative-generation/activities/extractToc.d.ts.map +0 -1
  366. package/lib/types/iterative-generation/activities/finalizeOutput.d.ts +0 -3
  367. package/lib/types/iterative-generation/activities/finalizeOutput.d.ts.map +0 -1
  368. package/lib/types/iterative-generation/activities/generatePart.d.ts +0 -3
  369. package/lib/types/iterative-generation/activities/generatePart.d.ts.map +0 -1
  370. package/lib/types/iterative-generation/activities/generateToc.d.ts +0 -4
  371. package/lib/types/iterative-generation/activities/generateToc.d.ts.map +0 -1
  372. package/lib/types/iterative-generation/activities/index.d.ts +0 -5
  373. package/lib/types/iterative-generation/activities/index.d.ts.map +0 -1
  374. package/lib/types/iterative-generation/iterativeGenerationWorkflow.d.ts +0 -3
  375. package/lib/types/iterative-generation/iterativeGenerationWorkflow.d.ts.map +0 -1
  376. package/lib/types/iterative-generation/types.d.ts +0 -79
  377. package/lib/types/iterative-generation/types.d.ts.map +0 -1
  378. package/lib/types/iterative-generation/utils.d.ts +0 -27
  379. package/lib/types/iterative-generation/utils.d.ts.map +0 -1
  380. package/lib/types/result-types.d.ts +0 -22
  381. package/lib/types/result-types.d.ts.map +0 -1
  382. package/lib/types/system/notifyWebhookWorkflow.d.ts +0 -7
  383. package/lib/types/system/notifyWebhookWorkflow.d.ts.map +0 -1
  384. package/lib/types/system/recalculateEmbeddingsWorkflow.d.ts +0 -25
  385. package/lib/types/system/recalculateEmbeddingsWorkflow.d.ts.map +0 -1
  386. package/lib/types/utils/auth.d.ts +0 -4
  387. package/lib/types/utils/auth.d.ts.map +0 -1
  388. package/lib/types/utils/blobs.d.ts +0 -7
  389. package/lib/types/utils/blobs.d.ts.map +0 -1
  390. package/lib/types/utils/chunks.d.ts +0 -9
  391. package/lib/types/utils/chunks.d.ts.map +0 -1
  392. package/lib/types/utils/client.d.ts +0 -12
  393. package/lib/types/utils/client.d.ts.map +0 -1
  394. package/lib/types/utils/expand-vars.d.ts +0 -8
  395. package/lib/types/utils/expand-vars.d.ts.map +0 -1
  396. package/lib/types/utils/memory.d.ts +0 -8
  397. package/lib/types/utils/memory.d.ts.map +0 -1
  398. package/lib/types/utils/renditions.d.ts +0 -23
  399. package/lib/types/utils/renditions.d.ts.map +0 -1
  400. package/lib/types/utils/storage.d.ts +0 -16
  401. package/lib/types/utils/storage.d.ts.map +0 -1
  402. package/lib/types/utils/tokens.d.ts +0 -11
  403. package/lib/types/utils/tokens.d.ts.map +0 -1
  404. package/lib/types/vars.d.ts +0 -3
  405. package/lib/types/vars.d.ts.map +0 -1
  406. package/lib/types/workflows.d.ts +0 -8
  407. package/lib/types/workflows.d.ts.map +0 -1
  408. package/lib/workflows-bundle.js +0 -12908
  409. package/src/activities/identifyTextSections.ts +0 -71
@@ -2,14 +2,24 @@ import { log } from "@temporalio/activity";
2
2
  import { WorkflowExecutionPayload } from "@vertesia/common";
3
3
  import { getVertesiaClient } from "../../utils/client.js";
4
4
  import { expandVars } from "../../utils/expand-vars.js";
5
- import { buildAndPublishMemoryPack, loadMemoryPack } from "../../utils/memory.js";
6
- import { IterativeGenerationPayload, Section, SECTION_ID_PLACEHOLDER, TocSection } from "../types.js";
5
+ import {
6
+ buildAndPublishMemoryPack,
7
+ loadMemoryPack,
8
+ } from "../../utils/memory.js";
9
+ import {
10
+ IterativeGenerationPayload,
11
+ Section,
12
+ SECTION_ID_PLACEHOLDER,
13
+ TocSection,
14
+ } from "../types.js";
7
15
 
8
- export async function it_gen_finalizeOutput(payload: WorkflowExecutionPayload): Promise<string> {
16
+ export async function it_gen_finalizeOutput(
17
+ payload: WorkflowExecutionPayload,
18
+ ): Promise<string> {
9
19
  const vars = payload.vars as IterativeGenerationPayload;
10
20
 
11
21
  const memory = vars.memory;
12
- const client = getVertesiaClient(payload);
22
+ const client = await getVertesiaClient(payload);
13
23
  const inMemory = await loadMemoryPack(client, `${memory}/input`);
14
24
  const outMemory = await loadMemoryPack(client, `${memory}/output`);
15
25
 
@@ -35,43 +45,56 @@ export async function it_gen_finalizeOutput(payload: WorkflowExecutionPayload):
35
45
  }
36
46
  const sections = JSON.parse(content) as Section[];
37
47
 
38
- await buildAndPublishMemoryPack(client, `${memory}/output`, async ({ copyText }) => {
39
- // copy the input toc file if any
40
- if (toc) {
41
- copyText(toc, tocName);
42
- }
43
- // copy the raw JSON content
44
- copyText(content, "content.json");
45
- if (vars.section_file_pattern) {
46
- log.info(`Saving sections to files using pattern: ${vars.section_file_pattern}`);
47
- // save sections to files
48
- for (const section of sections) {
49
- let content = section.content;
50
- if (vars.section_file_header) {
51
- content = getSectionFileHeader(section, vars.section_file_header) + '\n\n' + content;
48
+ await buildAndPublishMemoryPack(
49
+ client,
50
+ `${memory}/output`,
51
+ async ({ copyText }) => {
52
+ // copy the input toc file if any
53
+ if (toc) {
54
+ copyText(toc, tocName);
55
+ }
56
+ // copy the raw JSON content
57
+ copyText(content, "content.json");
58
+ if (vars.section_file_pattern) {
59
+ log.info(
60
+ `Saving sections to files using pattern: ${vars.section_file_pattern}`,
61
+ );
62
+ // save sections to files
63
+ for (const section of sections) {
64
+ let content = section.content;
65
+ if (vars.section_file_header) {
66
+ content =
67
+ getSectionFileHeader(
68
+ section,
69
+ vars.section_file_header,
70
+ ) +
71
+ "\n\n" +
72
+ content;
73
+ }
74
+ copyText(
75
+ content,
76
+ getSectionFileName(section, vars.section_file_pattern),
77
+ );
52
78
  }
53
- copyText(content, getSectionFileName(section, vars.section_file_pattern));
54
79
  }
55
- }
56
- return {
57
- ...inMeta,
58
- vars
59
- };
60
- });
80
+ return {
81
+ ...inMeta,
82
+ vars,
83
+ };
84
+ },
85
+ );
61
86
 
62
87
  return `Processing done. Extracted files to: ${vars.section_file_pattern}`;
63
88
  }
64
89
 
65
-
66
-
67
90
  function getSectionFileHeader(section: TocSection, header: string): string {
68
91
  const date = new Date().toISOString();
69
92
  return expandVars(header, {
70
93
  section,
71
- date
94
+ date,
72
95
  });
73
96
  }
74
97
 
75
98
  function getSectionFileName(section: TocSection, pattern: string): string {
76
99
  return pattern.replace(SECTION_ID_PLACEHOLDER, section.id);
77
- }
100
+ }
@@ -2,29 +2,50 @@ import { ApplicationFailure } from "@temporalio/workflow";
2
2
  import { WorkflowExecutionPayload } from "@vertesia/common";
3
3
  import { MemoryPack } from "@vertesia/memory";
4
4
  import { getVertesiaClient } from "../../utils/client.js";
5
- import { buildAndPublishMemoryPack, loadMemoryPack } from "../../utils/memory.js";
6
- import { IterativeGenerationPayload, OutputMemoryMeta, Section, TocPart, TocSection } from "../types.js";
5
+ import {
6
+ buildAndPublishMemoryPack,
7
+ loadMemoryPack,
8
+ } from "../../utils/memory.js";
9
+ import {
10
+ IterativeGenerationPayload,
11
+ OutputMemoryMeta,
12
+ Section,
13
+ TocPart,
14
+ TocSection,
15
+ } from "../types.js";
7
16
  import { executeWithVars, expectMemoryIsConsistent } from "../utils.js";
17
+ import { completionResultToString } from "@llumiverse/common";
8
18
 
9
- export async function it_gen_generatePart(payload: WorkflowExecutionPayload, path: number[]) {
19
+ export async function it_gen_generatePart(
20
+ payload: WorkflowExecutionPayload,
21
+ path: number[],
22
+ ) {
10
23
  const vars = payload.vars as IterativeGenerationPayload;
11
- const client = getVertesiaClient(payload);
24
+ const client = await getVertesiaClient(payload);
12
25
  const memory = vars.memory;
13
26
 
14
27
  const [sectionIndex, partIndex] = path;
15
28
  const outMemory = await loadMemoryPack(client, `${memory}/output`);
16
- const meta = await outMemory.getMetadata() as OutputMemoryMeta;
29
+ const meta = (await outMemory.getMetadata()) as OutputMemoryMeta;
17
30
 
18
31
  // the section we build is the section at the given index
19
32
  const section: TocSection = meta.toc.sections[sectionIndex];
20
33
  if (!section) {
21
- throw ApplicationFailure.nonRetryable('Section not found in the TOC', 'SectionNotFound', { memory, path });
34
+ throw ApplicationFailure.nonRetryable(
35
+ "Section not found in the TOC",
36
+ "SectionNotFound",
37
+ { memory, path },
38
+ );
22
39
  }
23
40
  let part: TocPart | undefined;
24
41
  if (partIndex !== undefined) {
25
42
  part = section.parts?.[partIndex];
26
43
  if (!part) {
27
- throw ApplicationFailure.nonRetryable('Part not found in the TOC section', 'PartNotFound', { memory, path });
44
+ throw ApplicationFailure.nonRetryable(
45
+ "Part not found in the TOC section",
46
+ "PartNotFound",
47
+ { memory, path },
48
+ );
28
49
  }
29
50
  }
30
51
 
@@ -32,17 +53,26 @@ export async function it_gen_generatePart(payload: WorkflowExecutionPayload, pat
32
53
 
33
54
  const content = await loadGeneratedContent(outMemory);
34
55
 
35
- let previously_generated = getPreviouslyGeneratedContent(content, !part, vars.remembrance_strategy);
56
+ let previously_generated = getPreviouslyGeneratedContent(
57
+ content,
58
+ !part,
59
+ vars.remembrance_strategy,
60
+ );
36
61
 
37
- if (!part) { // a new section
62
+ if (!part) {
63
+ // a new section
38
64
  content.push({
39
65
  id: section.id,
40
66
  name: section.name,
41
67
  description: section.description,
42
- content: ''
43
- })
68
+ content: "",
69
+ });
44
70
  } else if (!content.length) {
45
- throw ApplicationFailure.nonRetryable('content.json is empty while generating a part', 'InvalidIterationState', { memory, path });
71
+ throw ApplicationFailure.nonRetryable(
72
+ "content.json is empty while generating a part",
73
+ "InvalidIterationState",
74
+ { memory, path },
75
+ );
46
76
  }
47
77
 
48
78
  const interaction = vars.iterative_interaction || vars.interaction;
@@ -53,30 +83,42 @@ export async function it_gen_generatePart(payload: WorkflowExecutionPayload, pat
53
83
  section: section.name,
54
84
  part: part?.name,
55
85
  path: path,
56
- }
86
+ },
57
87
  });
58
88
 
59
- const result = r.result as string;
89
+ const result = r.result.map(completionResultToString).join('\n');
60
90
  content[content.length - 1].content += result;
61
91
  meta.lastProcessedPart = path;
62
- await buildAndPublishMemoryPack(client, `${memory}/output`, async ({ copyText }) => {
63
- copyText(JSON.stringify(content, null, 2), "content.json");
64
- return meta;
65
- });
92
+ await buildAndPublishMemoryPack(
93
+ client,
94
+ `${memory}/output`,
95
+ async ({ copyText }) => {
96
+ copyText(JSON.stringify(content, null, 2), "content.json");
97
+ return meta;
98
+ },
99
+ );
66
100
  }
67
101
 
68
102
  async function loadGeneratedContent(memory: MemoryPack): Promise<Section[]> {
69
- const content = await memory.getEntryText('content.json');
103
+ const content = await memory.getEntryText("content.json");
70
104
  return content ? JSON.parse(content) : [];
71
105
  }
72
106
 
73
- function getPreviouslyGeneratedContent(sections: Section[], isNewSection: boolean, strategy?: "document" | "section" | "none"): string {
107
+ function getPreviouslyGeneratedContent(
108
+ sections: Section[],
109
+ isNewSection: boolean,
110
+ strategy?: "document" | "section" | "none",
111
+ ): string {
74
112
  switch (strategy) {
75
113
  case "document":
76
- return sections.map((section: Section) => section.content || '').join('\n\n');
114
+ return sections
115
+ .map((section: Section) => section.content || "")
116
+ .join("\n\n");
77
117
  case "none":
78
- return '';
118
+ return "";
79
119
  default:
80
- return isNewSection ? '' : sections[sections.length - 1]?.content || '';
120
+ return isNewSection
121
+ ? ""
122
+ : sections[sections.length - 1]?.content || "";
81
123
  }
82
- }
124
+ }
@@ -1,98 +1,117 @@
1
1
  import { WorkflowExecutionPayload } from "@vertesia/common";
2
2
  import { getVertesiaClient } from "../../utils/client.js";
3
3
  import { buildAndPublishMemoryPack } from "../../utils/memory.js";
4
- import { IterativeGenerationPayload, OutputMemoryMeta, Toc, TocIndex } from "../types.js";
4
+ import {
5
+ IterativeGenerationPayload,
6
+ OutputMemoryMeta,
7
+ Toc,
8
+ TocIndex,
9
+ } from "../types.js";
5
10
  import { executeWithVars, tocIndex } from "../utils.js";
11
+ import { parseCompletionResultsToJson } from "@llumiverse/common";
6
12
 
7
13
  const defaultTocSchema = {
8
- "type": "object",
9
- "properties": {
10
- "sections": {
11
- "type": "array",
12
- "items": {
13
- "type": "object",
14
- "properties": {
15
- "id": {
16
- "type": "string",
17
- "description": "the id of the section, can be a filename if working on a file, a slug if working on a document or path, or a unique identifier if working on a model."
14
+ type: "object",
15
+ properties: {
16
+ sections: {
17
+ type: "array",
18
+ items: {
19
+ type: "object",
20
+ properties: {
21
+ id: {
22
+ type: "string",
23
+ description:
24
+ "the id of the section, can be a filename if working on a file, a slug if working on a document or path, or a unique identifier if working on a model.",
18
25
  },
19
- "operation": {
20
- "type": "string",
21
- "enum": ["create", "update", "delete"],
22
- "description": "The operation to perform on the section, create, update or delete. If update, you will be requested later to provide the list of change operation to perform."
26
+ operation: {
27
+ type: "string",
28
+ enum: ["create", "update", "delete"],
29
+ description:
30
+ "The operation to perform on the section, create, update or delete. If update, you will be requested later to provide the list of change operation to perform.",
23
31
  },
24
- "name": {
25
- "type": "string",
26
- "description": "The name or title of the section, should be the path in the OpenAPI spec, of the title of the section/part."
32
+ name: {
33
+ type: "string",
34
+ description:
35
+ "The name or title of the section, should be the path in the OpenAPI spec, of the title of the section/part.",
27
36
  },
28
- "description": {
29
- "type": "string"
37
+ description: {
38
+ type: "string",
30
39
  },
31
- "instructions": {
32
- "type": "string"
40
+ instructions: {
41
+ type: "string",
33
42
  },
34
- "parts":
35
- {
36
- "type": "array",
37
- "description": "when the section is too large, you can split it into parts, each part should have a title and description. Use it to split the section into subsection. When doing an API documentation, you can do one part for each path. When generating code, you can do one part for each method. When generating an OpenAPI spec, you can do one part for each operation.",
38
- "items": {
39
- "type": "object",
40
- "properties": {
41
- "id": {
42
- "type": "string",
43
- "description": "the id of the part, can be a filename if working on a file, a slug if working on a document or path, or a unique identifier if working on a model."
43
+ parts: {
44
+ type: "array",
45
+ description:
46
+ "when the section is too large, you can split it into parts, each part should have a title and description. Use it to split the section into subsection. When doing an API documentation, you can do one part for each path. When generating code, you can do one part for each method. When generating an OpenAPI spec, you can do one part for each operation.",
47
+ items: {
48
+ type: "object",
49
+ properties: {
50
+ id: {
51
+ type: "string",
52
+ description:
53
+ "the id of the part, can be a filename if working on a file, a slug if working on a document or path, or a unique identifier if working on a model.",
44
54
  },
45
- "name": {
46
- "type": "string",
47
- "description": "The name or title of the part, should be the path in the OpenAPI spec, of the title of the section/part."
55
+ name: {
56
+ type: "string",
57
+ description:
58
+ "The name or title of the part, should be the path in the OpenAPI spec, of the title of the section/part.",
48
59
  },
49
60
  /*
50
61
  "description": {
51
62
  "type": "string"
52
63
  },
53
64
  */
54
- "instructions": {
55
- "type": "string"
56
- }
65
+ instructions: {
66
+ type: "string",
67
+ },
57
68
  },
58
- "required": [
59
- "id",
60
- "name",
61
- ]
62
- }
63
- }
69
+ required: ["id", "name"],
70
+ },
71
+ },
64
72
  },
65
- "required": [
66
- "id",
67
- "name",
68
- "operation"
69
- ]
70
- }
71
- }
73
+ required: ["id", "name", "operation"],
74
+ },
75
+ },
72
76
  },
73
- "required": [
74
- "sections"
75
- ]
76
- }
77
+ required: ["sections"],
78
+ };
77
79
 
78
- export async function it_gen_generateToc(payload: WorkflowExecutionPayload): Promise<TocIndex> {
80
+ export async function it_gen_generateToc(
81
+ payload: WorkflowExecutionPayload,
82
+ ): Promise<TocIndex> {
79
83
  const vars = payload.vars as IterativeGenerationPayload;
80
84
 
81
85
  const schema = vars.toc_schema || defaultTocSchema;
82
86
 
83
- const client = getVertesiaClient(payload);
87
+ const client = await getVertesiaClient(payload);
88
+
89
+ const run = await executeWithVars(
90
+ client,
91
+ vars.interaction,
92
+ vars,
93
+ undefined,
94
+ schema,
95
+ );
84
96
 
85
- const run = await executeWithVars(client, vars.interaction, vars, undefined, schema);
97
+ //Parse the CompletionResult[] to get a Toc object
98
+ const jsonResults = parseCompletionResultsToJson(run.result);
86
99
 
87
- const toc = run.result as Toc;
100
+ const toc: Toc = {
101
+ sections: jsonResults.sections
102
+ };
88
103
 
89
- await buildAndPublishMemoryPack(client, `${vars.memory}/output`, async () => {
90
- return {
91
- toc,
92
- lastProcessedPart: undefined, // the part index (a number array)
93
- previouslyGenerated: ""
94
- } as OutputMemoryMeta
95
- });
104
+ await buildAndPublishMemoryPack(
105
+ client,
106
+ `${vars.memory}/output`,
107
+ async () => {
108
+ return {
109
+ toc,
110
+ lastProcessedPart: undefined, // the part index (a number array)
111
+ previouslyGenerated: "",
112
+ } satisfies OutputMemoryMeta;
113
+ },
114
+ );
96
115
 
97
116
  return tocIndex(toc);
98
117
  }
@@ -15,7 +15,7 @@ export interface ExecuteOptions {
15
15
  result_schema?: Record<string, any>;
16
16
  }
17
17
 
18
- export async function execute<T = any>(client: VertesiaClient, options: ExecuteOptions): Promise<ExecutionRun<any, T>> {
18
+ export async function execute(client: VertesiaClient, options: ExecuteOptions): Promise<ExecutionRun> {
19
19
  return client.interactions.executeByName(options.interaction, {
20
20
  data: {
21
21
  ...options.memory_mapping,
@@ -30,7 +30,7 @@ export async function execute<T = any>(client: VertesiaClient, options: ExecuteO
30
30
  });
31
31
  }
32
32
 
33
- export function executeWithVars<T = any>(client: VertesiaClient, interaction: string, vars: Record<string, any>, mapping?: Record<string, any>, result_schema?: Record<string, any>): Promise<ExecutionRun<any, T>> {
33
+ export function executeWithVars(client: VertesiaClient, interaction: string, vars: Record<string, any>, mapping?: Record<string, any>, result_schema?: Record<string, any>): Promise<ExecutionRun> {
34
34
  if (mapping) {
35
35
  mapping = { ...vars.input_mapping, ...mapping };
36
36
  } else {
@@ -14,7 +14,9 @@ export async function fetchBlobAsStream(client: VertesiaClient, blobUri: string)
14
14
  } catch (err: any) {
15
15
  if (err.message.includes("not found")) {
16
16
  //TODO improve error handling with a fetch fail error class in the client
17
- throw new DocumentNotFoundError(`Failed to download blob ${blobUri}: ${err.message}`, []);
17
+ throw new DocumentNotFoundError(`Not found at ${blobUri}: ${err.message}`, []);
18
+ } else if (err.message.includes("forbidden")) {
19
+ throw new DocumentNotFoundError(`Forbidden at ${blobUri}: ${err.message}`);
18
20
  } else {
19
21
  throw new Error(`Failed to download blob ${blobUri}: ${err.message}`);
20
22
  }
@@ -2,31 +2,45 @@
2
2
  * get a zeno client for a given token
3
3
  */
4
4
 
5
- import { VertesiaClient } from "@vertesia/client";
5
+ import {
6
+ decodeJWT,
7
+ VertesiaClient,
8
+ VertesiaClientProps,
9
+ } from "@vertesia/client";
6
10
  import { WorkflowExecutionBaseParams } from "@vertesia/common";
7
11
  import { WorkflowParamNotFoundError } from "../errors.js";
8
12
 
9
-
10
13
  export function getVertesiaClient(payload: WorkflowExecutionBaseParams) {
11
14
  return new VertesiaClient(getVertesiaClientOptions(payload));
12
15
  }
13
16
 
14
- export function getVertesiaClientOptions(payload: WorkflowExecutionBaseParams) {
17
+ export function getVertesiaClientOptions(
18
+ payload: WorkflowExecutionBaseParams,
19
+ ): VertesiaClientProps {
15
20
  if (!payload.auth_token) {
16
- throw new WorkflowParamNotFoundError("Authentication Token is missing from WorkflowExecutionPayload.authToken");
21
+ throw new WorkflowParamNotFoundError(
22
+ "Authentication Token is missing from WorkflowExecutionPayload.authToken",
23
+ );
17
24
  }
18
25
 
19
26
  if (!payload.config?.studio_url) {
20
- throw new WorkflowParamNotFoundError("Content Store URL is missing from WorkflowExecutionPayload.servers.storeUrl");
27
+ throw new WorkflowParamNotFoundError(
28
+ "Content Store URL is missing from WorkflowExecutionPayload.servers.storeUrl",
29
+ );
21
30
  }
22
31
 
23
32
  if (!payload.config?.store_url) {
24
- throw new WorkflowParamNotFoundError("Content Store URL is missing from WorkflowExecutionPayload.servers.storeUrl");
33
+ throw new WorkflowParamNotFoundError(
34
+ "Content Store URL is missing from WorkflowExecutionPayload.servers.storeUrl",
35
+ );
25
36
  }
26
37
 
38
+ const token = decodeJWT(payload.auth_token);
39
+
27
40
  return {
28
41
  serverUrl: payload.config.studio_url,
29
42
  storeUrl: payload.config.store_url,
30
- apikey: payload.auth_token
43
+ tokenServerUrl: token.iss,
44
+ apikey: payload.auth_token,
31
45
  };
32
- }
46
+ }
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDocumentTypeFromInteractionRun = createDocumentTypeFromInteractionRun;
4
- const activity_1 = require("@temporalio/activity");
5
- const projections_js_1 = require("../../dsl/projections.js");
6
- const ActivityContext_js_1 = require("../../dsl/setup/ActivityContext.js");
7
- const errors_js_1 = require("../../errors.js");
8
- async function createDocumentTypeFromInteractionRun(payload) {
9
- const { params, client } = await (0, ActivityContext_js_1.setupActivity)(payload);
10
- if (!params.run) {
11
- throw new errors_js_1.ActivityParamNotFoundError("run", payload.activity);
12
- }
13
- const genTypeRes = params.run.result;
14
- if (!genTypeRes.document_type) {
15
- activity_1.log.error("No name generated for type: " + JSON.stringify(genTypeRes), genTypeRes);
16
- throw new Error("No name generated for type");
17
- }
18
- activity_1.log.info("Generated schema for type", genTypeRes.metadata_schema);
19
- const typeData = {
20
- name: genTypeRes.document_type,
21
- object_schema: genTypeRes.metadata_schema,
22
- is_chunkable: !!genTypeRes.is_chunkable,
23
- };
24
- const type = await client.types.create(typeData);
25
- if (params.updateObjectId) {
26
- await client.objects.update(params.updateObjectId, {
27
- type: type.id,
28
- });
29
- }
30
- return (0, projections_js_1.projectResult)(payload, params, type, { id: type.id, name: type.name });
31
- }
32
- //# sourceMappingURL=createDocumentTypeFromInteractionRun.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createDocumentTypeFromInteractionRun.js","sourceRoot":"","sources":["../../../../src/activities/advanced/createDocumentTypeFromInteractionRun.ts"],"names":[],"mappings":";;AAuBA,oFA8BC;AApDD,mDAA2C;AAC3C,6DAAyD;AACzD,2EAAmE;AACnE,+CAA6D;AAmBtD,KAAK,UAAU,oCAAoC,CAAC,OAAgF;IACvI,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,kCAAa,EAA6C,OAAO,CAAC,CAAC;IAEpG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACd,MAAM,IAAI,sCAA0B,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;IAErC,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;QAC5B,cAAG,CAAC,KAAK,CAAC,8BAA8B,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,CAAC;QACnF,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAClD,CAAC;IAED,cAAG,CAAC,IAAI,CAAC,2BAA2B,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAmC;QAC7C,IAAI,EAAE,UAAU,CAAC,aAAa;QAC9B,aAAa,EAAE,UAAU,CAAC,eAAe;QACzC,YAAY,EAAE,CAAC,CAAC,UAAU,CAAC,YAAY;KAC1C,CAAA;IAED,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEjD,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;QACxB,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,EAAE;SAChB,CAAC,CAAC;IACP,CAAC;IAED,OAAO,IAAA,8BAAa,EAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AAClF,CAAC"}
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createOrUpdateDocumentFromInteractionRun = createOrUpdateDocumentFromInteractionRun;
4
- const activity_1 = require("@temporalio/activity");
5
- const common_1 = require("@vertesia/common");
6
- const ActivityContext_js_1 = require("../../dsl/setup/ActivityContext.js");
7
- const errors_js_1 = require("../../errors.js");
8
- async function createOrUpdateDocumentFromInteractionRun(payload) {
9
- const { params, client } = await (0, ActivityContext_js_1.setupActivity)(payload);
10
- const runId = params.run_id;
11
- const objectTypeName = params.object_type;
12
- if (!runId) {
13
- throw new errors_js_1.ActivityParamNotFoundError("run_id", payload.activity);
14
- }
15
- if (!objectTypeName && !params.update_existing_id) {
16
- throw new errors_js_1.ActivityParamNotFoundError("object_type", payload.activity);
17
- }
18
- activity_1.log.info("Creating document from interaction result", { runId, objectTypeName });
19
- const run = await client.runs.retrieve(runId).catch((e) => {
20
- throw new errors_js_1.DocumentNotFoundError(`Error fetching run ${runId}: ${e.message}`);
21
- });
22
- const type = objectTypeName ?
23
- await client.types.getTypeByName(objectTypeName).catch((e) => {
24
- throw new errors_js_1.DocumentNotFoundError(`Error fetching type ${objectTypeName}: ${e.message}`);
25
- })
26
- : undefined;
27
- const result = run.result;
28
- const resultIsObject = typeof result === 'object';
29
- const inputData = run.parameters;
30
- let name;
31
- if (resultIsObject) {
32
- name = result['name'] || result["title"] || inputData['name'] || params.fallback_name || 'Untitled';
33
- }
34
- else {
35
- name = inputData['name'] || params.fallback_name || 'Untitled';
36
- }
37
- const docPayload = {
38
- name,
39
- parent: params.parent ?? undefined,
40
- properties: resultIsObject ? result : {},
41
- text: !resultIsObject ? result : undefined,
42
- type: type?.id,
43
- status: common_1.ContentObjectStatus.completed,
44
- generation_run_info: {
45
- id: run.id,
46
- date: new Date().toISOString(),
47
- model: run.modelId,
48
- target: resultIsObject ? 'properties' : 'text'
49
- }
50
- };
51
- if (params.update_text_from_property) {
52
- const text = docPayload.properties[params.update_text_from_property];
53
- if (text) {
54
- docPayload.text = text;
55
- }
56
- }
57
- //create or update the document
58
- let newDoc = false;
59
- let doc = undefined;
60
- if (params.update_existing_id) {
61
- activity_1.log.info(`Updating existing document ${params.update_existing_id}`);
62
- doc = await client.objects.update(params.update_existing_id, docPayload);
63
- }
64
- else {
65
- activity_1.log.info(`Creating new document of type ${objectTypeName}`);
66
- doc = await client.objects.create(docPayload);
67
- newDoc = true;
68
- }
69
- activity_1.log.info(`Document ${objectTypeName + ' '}${doc.id}(${doc.name}) ${newDoc ? 'created' : 'updated'}`);
70
- return { id: doc.id, isNew: newDoc, type: name };
71
- }
72
- //# sourceMappingURL=createOrUpdateDocumentFromInteractionRun.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createOrUpdateDocumentFromInteractionRun.js","sourceRoot":"","sources":["../../../../src/activities/advanced/createOrUpdateDocumentFromInteractionRun.ts"],"names":[],"mappings":"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"}