@elementumai/edk 0.0.0-oidc-bootstrap → 0.8.0-preview.11

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 (360) hide show
  1. package/README.md +408 -3
  2. package/dist-sdk/elementum-entity-client/clients/agents/models/agent-tool.d.ts +188 -0
  3. package/dist-sdk/elementum-entity-client/clients/agents/models/agent-tool.js +20 -0
  4. package/dist-sdk/elementum-entity-client/clients/agents/models/agent.d.ts +245 -0
  5. package/dist-sdk/elementum-entity-client/clients/agents/models/agent.js +30 -0
  6. package/dist-sdk/elementum-entity-client/clients/ai-provider-connectors/models/ai-provider-connector.d.ts +18 -0
  7. package/dist-sdk/elementum-entity-client/clients/ai-provider-connectors/models/ai-provider-connector.js +8 -0
  8. package/dist-sdk/elementum-entity-client/clients/aspects/models/aspect.d.ts +718 -0
  9. package/dist-sdk/elementum-entity-client/clients/aspects/models/aspect.js +52 -0
  10. package/dist-sdk/elementum-entity-client/clients/aspects/models/field-base.d.ts +23 -0
  11. package/dist-sdk/elementum-entity-client/clients/aspects/models/field-base.js +1 -0
  12. package/dist-sdk/elementum-entity-client/clients/aspects/models/field-types.d.ts +148 -0
  13. package/dist-sdk/elementum-entity-client/clients/aspects/models/field-types.js +12 -0
  14. package/dist-sdk/elementum-entity-client/clients/aspects/models/format.d.ts +63 -0
  15. package/dist-sdk/elementum-entity-client/clients/aspects/models/format.js +17 -0
  16. package/dist-sdk/elementum-entity-client/clients/aspects/models/index.d.ts +39 -0
  17. package/dist-sdk/elementum-entity-client/clients/aspects/models/index.js +35 -0
  18. package/dist-sdk/elementum-entity-client/clients/aspects/models/picklist-config.d.ts +116 -0
  19. package/dist-sdk/elementum-entity-client/clients/aspects/models/picklist-config.js +11 -0
  20. package/dist-sdk/elementum-entity-client/clients/automation/models/automation.d.ts +178 -0
  21. package/dist-sdk/elementum-entity-client/clients/automation/models/automation.js +18 -0
  22. package/dist-sdk/elementum-entity-client/clients/document-models/models/document-model.d.ts +200 -0
  23. package/dist-sdk/elementum-entity-client/clients/document-models/models/document-model.js +1 -0
  24. package/dist-sdk/elementum-entity-client/clients/search-tables/models/index.d.ts +1 -0
  25. package/dist-sdk/elementum-entity-client/clients/search-tables/models/index.js +1 -0
  26. package/dist-sdk/elementum-entity-client/clients/search-tables/models/search-table-wire.d.ts +141 -0
  27. package/dist-sdk/elementum-entity-client/clients/search-tables/models/search-table-wire.js +22 -0
  28. package/dist-sdk/elementum-entity-client/clients/skills/models/skill-tool.d.ts +123 -0
  29. package/dist-sdk/elementum-entity-client/clients/skills/models/skill-tool.js +14 -0
  30. package/dist-sdk/elementum-entity-client/clients/skills/models/skill.d.ts +78 -0
  31. package/dist-sdk/elementum-entity-client/clients/skills/models/skill.js +23 -0
  32. package/dist-sdk/elementum-entity-client/clients/tables/models/index.d.ts +1 -0
  33. package/dist-sdk/elementum-entity-client/clients/tables/models/index.js +1 -0
  34. package/dist-sdk/elementum-entity-client/clients/tables/models/table-wire.d.ts +265 -0
  35. package/dist-sdk/elementum-entity-client/clients/tables/models/table-wire.js +15 -0
  36. package/dist-sdk/elementum-entity-client/errors.d.ts +90 -0
  37. package/dist-sdk/elementum-entity-client/errors.js +111 -0
  38. package/dist-sdk/elementum-entity-client/models/connection.d.ts +30 -0
  39. package/dist-sdk/elementum-entity-client/models/connection.js +16 -0
  40. package/dist-sdk/elementum-entity-client/types.d.ts +71 -0
  41. package/dist-sdk/elementum-entity-client/types.js +1 -0
  42. package/dist-sdk/fs/entity.d.ts +104 -0
  43. package/dist-sdk/fs/entity.js +52 -0
  44. package/dist-sdk/pull/util.d.ts +130 -0
  45. package/dist-sdk/pull/util.js +204 -0
  46. package/dist-sdk/src/catalog/factories.d.ts +189 -0
  47. package/dist-sdk/src/catalog/factories.js +202 -0
  48. package/dist-sdk/src/catalog/from-authoring.d.ts +103 -0
  49. package/dist-sdk/src/catalog/from-authoring.js +462 -0
  50. package/dist-sdk/src/catalog/index.d.ts +11 -0
  51. package/dist-sdk/src/catalog/index.js +11 -0
  52. package/dist-sdk/src/catalog/org.d.ts +11 -0
  53. package/dist-sdk/src/catalog/org.js +211 -0
  54. package/dist-sdk/src/catalog/render-helpers.d.ts +35 -0
  55. package/dist-sdk/src/catalog/render-helpers.js +82 -0
  56. package/dist-sdk/src/catalog/render.d.ts +36 -0
  57. package/dist-sdk/src/catalog/render.js +176 -0
  58. package/dist-sdk/src/catalog/token.d.ts +10 -0
  59. package/dist-sdk/src/catalog/token.js +62 -0
  60. package/dist-sdk/src/catalog/types.d.ts +158 -0
  61. package/dist-sdk/src/catalog/types.js +83 -0
  62. package/dist-sdk/src/catalog/write.d.ts +43 -0
  63. package/dist-sdk/src/catalog/write.js +109 -0
  64. package/dist-sdk/src/core/app-to-ui.d.ts +22 -0
  65. package/dist-sdk/src/core/app-to-ui.js +75 -0
  66. package/dist-sdk/src/core/index.d.ts +10 -0
  67. package/dist-sdk/src/core/index.js +9 -0
  68. package/dist-sdk/src/core/system-fields.d.ts +93 -0
  69. package/dist-sdk/src/core/system-fields.js +151 -0
  70. package/dist-sdk/src/core/triggers/on-demand.d.ts +144 -0
  71. package/dist-sdk/src/core/triggers/on-demand.js +112 -0
  72. package/dist-sdk/src/core/types/ai-provider.d.ts +36 -0
  73. package/dist-sdk/src/core/types/ai-provider.js +32 -0
  74. package/dist-sdk/src/core/types/app.d.ts +838 -0
  75. package/dist-sdk/src/core/types/app.js +210 -0
  76. package/dist-sdk/src/core/types/aspect-category.d.ts +35 -0
  77. package/dist-sdk/src/core/types/aspect-category.js +33 -0
  78. package/dist-sdk/src/core/types/cloud-link.d.ts +34 -0
  79. package/dist-sdk/src/core/types/cloud-link.js +32 -0
  80. package/dist-sdk/src/core/types/display-block.d.ts +149 -0
  81. package/dist-sdk/src/core/types/display-block.js +61 -0
  82. package/dist-sdk/src/core/types/group.d.ts +13 -0
  83. package/dist-sdk/src/core/types/group.js +6 -0
  84. package/dist-sdk/src/core/types/platform.d.ts +2 -0
  85. package/dist-sdk/src/core/types/platform.js +1 -0
  86. package/dist-sdk/src/core/types/user.d.ts +20 -0
  87. package/dist-sdk/src/core/types/user.js +8 -0
  88. package/dist-sdk/src/core/wire/ref-serializer.d.ts +45 -0
  89. package/dist-sdk/src/core/wire/ref-serializer.js +89 -0
  90. package/dist-sdk/src/engine/build/context.d.ts +49 -0
  91. package/dist-sdk/src/engine/build/context.js +6 -0
  92. package/dist-sdk/src/engine/entity.d.ts +44 -0
  93. package/dist-sdk/src/engine/entity.js +15 -0
  94. package/dist-sdk/src/engine/pull/context.d.ts +23 -0
  95. package/dist-sdk/src/engine/pull/context.js +44 -0
  96. package/dist-sdk/src/engine/pull/org.d.ts +44 -0
  97. package/dist-sdk/src/engine/pull/org.js +104 -0
  98. package/dist-sdk/src/engine/tf/escape.d.ts +22 -0
  99. package/dist-sdk/src/engine/tf/escape.js +28 -0
  100. package/dist-sdk/src/engine/tf/expr.d.ts +25 -0
  101. package/dist-sdk/src/engine/tf/expr.js +405 -0
  102. package/dist-sdk/src/engine/tf/index.d.ts +12 -0
  103. package/dist-sdk/src/engine/tf/index.js +11 -0
  104. package/dist-sdk/src/engine/tf/labels.d.ts +31 -0
  105. package/dist-sdk/src/engine/tf/labels.js +125 -0
  106. package/dist-sdk/src/engine/tf/model.d.ts +84 -0
  107. package/dist-sdk/src/engine/tf/model.js +49 -0
  108. package/dist-sdk/src/engine/tf/parse.d.ts +41 -0
  109. package/dist-sdk/src/engine/tf/parse.js +189 -0
  110. package/dist-sdk/src/engine/tf/render.d.ts +13 -0
  111. package/dist-sdk/src/engine/tf/render.js +102 -0
  112. package/dist-sdk/src/engine/workspace/authoring-layout.d.ts +43 -0
  113. package/dist-sdk/src/engine/workspace/authoring-layout.js +201 -0
  114. package/dist-sdk/src/entities/agent/build.d.ts +108 -0
  115. package/dist-sdk/src/entities/agent/build.js +148 -0
  116. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +18 -0
  117. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +177 -0
  118. package/dist-sdk/src/entities/agent/from-tf.d.ts +50 -0
  119. package/dist-sdk/src/entities/agent/from-tf.js +169 -0
  120. package/dist-sdk/src/entities/agent/index.d.ts +7 -0
  121. package/dist-sdk/src/entities/agent/index.js +7 -0
  122. package/dist-sdk/src/entities/agent/module.d.ts +4 -0
  123. package/dist-sdk/src/entities/agent/module.js +116 -0
  124. package/dist-sdk/src/entities/agent/to-tf.d.ts +33 -0
  125. package/dist-sdk/src/entities/agent/to-tf.js +136 -0
  126. package/dist-sdk/src/entities/agent/tools.d.ts +205 -0
  127. package/dist-sdk/src/entities/agent/tools.js +199 -0
  128. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +63 -0
  129. package/dist-sdk/src/entities/agent-tool/from-tf.js +169 -0
  130. package/dist-sdk/src/entities/agent-tool/module.d.ts +3 -0
  131. package/dist-sdk/src/entities/agent-tool/module.js +32 -0
  132. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +38 -0
  133. package/dist-sdk/src/entities/agent-tool/to-tf.js +164 -0
  134. package/dist-sdk/src/entities/agent-tool/types.d.ts +42 -0
  135. package/dist-sdk/src/entities/agent-tool/types.js +70 -0
  136. package/dist-sdk/src/entities/app/build.d.ts +318 -0
  137. package/dist-sdk/src/entities/app/build.js +325 -0
  138. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +165 -0
  139. package/dist-sdk/src/entities/app/deserializer/normalize.js +12 -0
  140. package/dist-sdk/src/entities/app/display-blocks.d.ts +26 -0
  141. package/dist-sdk/src/entities/app/display-blocks.js +34 -0
  142. package/dist-sdk/src/entities/app/from-tf.d.ts +23 -0
  143. package/dist-sdk/src/entities/app/from-tf.js +180 -0
  144. package/dist-sdk/src/entities/app/index.d.ts +11 -0
  145. package/dist-sdk/src/entities/app/index.js +10 -0
  146. package/dist-sdk/src/entities/app/locals.d.ts +11 -0
  147. package/dist-sdk/src/entities/app/locals.js +31 -0
  148. package/dist-sdk/src/entities/app/module.d.ts +4 -0
  149. package/dist-sdk/src/entities/app/module.js +59 -0
  150. package/dist-sdk/src/entities/app/to-tf.d.ts +28 -0
  151. package/dist-sdk/src/entities/app/to-tf.js +183 -0
  152. package/dist-sdk/src/entities/approval-chain/build.d.ts +24 -0
  153. package/dist-sdk/src/entities/approval-chain/build.js +56 -0
  154. package/dist-sdk/src/entities/approval-chain/index.d.ts +6 -0
  155. package/dist-sdk/src/entities/approval-chain/index.js +6 -0
  156. package/dist-sdk/src/entities/approval-chain/steps.d.ts +24 -0
  157. package/dist-sdk/src/entities/approval-chain/steps.js +20 -0
  158. package/dist-sdk/src/entities/automation/build.d.ts +215 -0
  159. package/dist-sdk/src/entities/automation/build.js +424 -0
  160. package/dist-sdk/src/entities/automation/catalog-render.d.ts +5 -0
  161. package/dist-sdk/src/entities/automation/catalog-render.js +35 -0
  162. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +135 -0
  163. package/dist-sdk/src/entities/automation/deserializer/ast.js +13 -0
  164. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +40 -0
  165. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +1040 -0
  166. package/dist-sdk/src/entities/automation/filter.d.ts +81 -0
  167. package/dist-sdk/src/entities/automation/filter.js +146 -0
  168. package/dist-sdk/src/entities/automation/from-tf.d.ts +36 -0
  169. package/dist-sdk/src/entities/automation/from-tf.js +252 -0
  170. package/dist-sdk/src/entities/automation/index.d.ts +18 -0
  171. package/dist-sdk/src/entities/automation/index.js +21 -0
  172. package/dist-sdk/src/entities/automation/module.d.ts +3 -0
  173. package/dist-sdk/src/entities/automation/module.js +153 -0
  174. package/dist-sdk/src/entities/automation/operators.d.ts +66 -0
  175. package/dist-sdk/src/entities/automation/operators.js +43 -0
  176. package/dist-sdk/src/entities/automation/script-code.d.ts +62 -0
  177. package/dist-sdk/src/entities/automation/script-code.js +366 -0
  178. package/dist-sdk/src/entities/automation/serialize.d.ts +6 -0
  179. package/dist-sdk/src/entities/automation/serialize.js +41 -0
  180. package/dist-sdk/src/entities/automation/tasks.d.ts +535 -0
  181. package/dist-sdk/src/entities/automation/tasks.js +697 -0
  182. package/dist-sdk/src/entities/automation/to-tf.d.ts +38 -0
  183. package/dist-sdk/src/entities/automation/to-tf.js +266 -0
  184. package/dist-sdk/src/entities/automation/triggers.d.ts +197 -0
  185. package/dist-sdk/src/entities/automation/triggers.js +202 -0
  186. package/dist-sdk/src/entities/automation/types.d.ts +53 -0
  187. package/dist-sdk/src/entities/automation/types.js +101 -0
  188. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +76 -0
  189. package/dist-sdk/src/entities/automation/value-ref-tf.js +190 -0
  190. package/dist-sdk/src/entities/element/build.d.ts +108 -0
  191. package/dist-sdk/src/entities/element/build.js +109 -0
  192. package/dist-sdk/src/entities/element/from-tf.d.ts +19 -0
  193. package/dist-sdk/src/entities/element/from-tf.js +155 -0
  194. package/dist-sdk/src/entities/element/index.d.ts +9 -0
  195. package/dist-sdk/src/entities/element/index.js +9 -0
  196. package/dist-sdk/src/entities/element/locals.d.ts +7 -0
  197. package/dist-sdk/src/entities/element/locals.js +12 -0
  198. package/dist-sdk/src/entities/element/module.d.ts +8 -0
  199. package/dist-sdk/src/entities/element/module.js +63 -0
  200. package/dist-sdk/src/entities/element/to-tf.d.ts +14 -0
  201. package/dist-sdk/src/entities/element/to-tf.js +151 -0
  202. package/dist-sdk/src/entities/field/build.d.ts +69 -0
  203. package/dist-sdk/src/entities/field/build.js +74 -0
  204. package/dist-sdk/src/entities/field/calc/aggregate.d.ts +60 -0
  205. package/dist-sdk/src/entities/field/calc/aggregate.js +71 -0
  206. package/dist-sdk/src/entities/field/calc/date.d.ts +73 -0
  207. package/dist-sdk/src/entities/field/calc/date.js +109 -0
  208. package/dist-sdk/src/entities/field/calc/index.d.ts +229 -0
  209. package/dist-sdk/src/entities/field/calc/index.js +433 -0
  210. package/dist-sdk/src/entities/field/calc/numeric.d.ts +22 -0
  211. package/dist-sdk/src/entities/field/calc/numeric.js +67 -0
  212. package/dist-sdk/src/entities/field/calc/runtime.d.ts +61 -0
  213. package/dist-sdk/src/entities/field/calc/runtime.js +170 -0
  214. package/dist-sdk/src/entities/field/calc/text.d.ts +100 -0
  215. package/dist-sdk/src/entities/field/calc/text.js +208 -0
  216. package/dist-sdk/src/entities/field/calc/types.d.ts +86 -0
  217. package/dist-sdk/src/entities/field/calc/types.js +23 -0
  218. package/dist-sdk/src/entities/field/calc.d.ts +108 -0
  219. package/dist-sdk/src/entities/field/calc.js +54 -0
  220. package/dist-sdk/src/entities/field/from-tf.d.ts +29 -0
  221. package/dist-sdk/src/entities/field/from-tf.js +73 -0
  222. package/dist-sdk/src/entities/field/locals.d.ts +8 -0
  223. package/dist-sdk/src/entities/field/locals.js +24 -0
  224. package/dist-sdk/src/entities/field/module.d.ts +3 -0
  225. package/dist-sdk/src/entities/field/module.js +49 -0
  226. package/dist-sdk/src/entities/field/options.d.ts +27 -0
  227. package/dist-sdk/src/entities/field/options.js +76 -0
  228. package/dist-sdk/src/entities/field/record-shape.d.ts +57 -0
  229. package/dist-sdk/src/entities/field/record-shape.js +1 -0
  230. package/dist-sdk/src/entities/field/to-tf.d.ts +55 -0
  231. package/dist-sdk/src/entities/field/to-tf.js +97 -0
  232. package/dist-sdk/src/entities/field/types.d.ts +27 -0
  233. package/dist-sdk/src/entities/field/types.js +46 -0
  234. package/dist-sdk/src/entities/file-reader/build.d.ts +124 -0
  235. package/dist-sdk/src/entities/file-reader/build.js +105 -0
  236. package/dist-sdk/src/entities/file-reader/index.d.ts +5 -0
  237. package/dist-sdk/src/entities/file-reader/index.js +5 -0
  238. package/dist-sdk/src/entities/flow/activities/agent.d.ts +15 -0
  239. package/dist-sdk/src/entities/flow/activities/agent.js +29 -0
  240. package/dist-sdk/src/entities/flow/activities/approval.d.ts +9 -0
  241. package/dist-sdk/src/entities/flow/activities/approval.js +18 -0
  242. package/dist-sdk/src/entities/flow/activities/automation.d.ts +12 -0
  243. package/dist-sdk/src/entities/flow/activities/automation.js +22 -0
  244. package/dist-sdk/src/entities/flow/activities/ctx.d.ts +34 -0
  245. package/dist-sdk/src/entities/flow/activities/ctx.js +38 -0
  246. package/dist-sdk/src/entities/flow/activities/form.d.ts +22 -0
  247. package/dist-sdk/src/entities/flow/activities/form.js +36 -0
  248. package/dist-sdk/src/entities/flow/activities/index.d.ts +14 -0
  249. package/dist-sdk/src/entities/flow/activities/index.js +13 -0
  250. package/dist-sdk/src/entities/flow/activities/input-refs.d.ts +39 -0
  251. package/dist-sdk/src/entities/flow/activities/input-refs.js +19 -0
  252. package/dist-sdk/src/entities/flow/activities/prompt-template.d.ts +13 -0
  253. package/dist-sdk/src/entities/flow/activities/prompt-template.js +34 -0
  254. package/dist-sdk/src/entities/flow/activities/render-catalog.d.ts +140 -0
  255. package/dist-sdk/src/entities/flow/activities/render-catalog.js +174 -0
  256. package/dist-sdk/src/entities/flow/activities/types.d.ts +33 -0
  257. package/dist-sdk/src/entities/flow/activities/types.js +1 -0
  258. package/dist-sdk/src/entities/flow/build.d.ts +38 -0
  259. package/dist-sdk/src/entities/flow/build.js +115 -0
  260. package/dist-sdk/src/entities/flow/index.d.ts +8 -0
  261. package/dist-sdk/src/entities/flow/index.js +7 -0
  262. package/dist-sdk/src/entities/flow/serialize.d.ts +51 -0
  263. package/dist-sdk/src/entities/flow/serialize.js +94 -0
  264. package/dist-sdk/src/entities/flow/util.d.ts +27 -0
  265. package/dist-sdk/src/entities/flow/util.js +38 -0
  266. package/dist-sdk/src/entities/org/category.d.ts +5 -0
  267. package/dist-sdk/src/entities/org/category.js +33 -0
  268. package/dist-sdk/src/entities/org/cloud-link.d.ts +5 -0
  269. package/dist-sdk/src/entities/org/cloud-link.js +33 -0
  270. package/dist-sdk/src/entities/org/connector.d.ts +5 -0
  271. package/dist-sdk/src/entities/org/connector.js +37 -0
  272. package/dist-sdk/src/entities/org/group.d.ts +5 -0
  273. package/dist-sdk/src/entities/org/group.js +31 -0
  274. package/dist-sdk/src/entities/org/index.d.ts +10 -0
  275. package/dist-sdk/src/entities/org/index.js +10 -0
  276. package/dist-sdk/src/entities/org/role.d.ts +7 -0
  277. package/dist-sdk/src/entities/org/role.js +21 -0
  278. package/dist-sdk/src/entities/org/user.d.ts +7 -0
  279. package/dist-sdk/src/entities/org/user.js +21 -0
  280. package/dist-sdk/src/entities/search-table/build.d.ts +41 -0
  281. package/dist-sdk/src/entities/search-table/build.js +79 -0
  282. package/dist-sdk/src/entities/search-table/index.d.ts +5 -0
  283. package/dist-sdk/src/entities/search-table/index.js +5 -0
  284. package/dist-sdk/src/entities/search-table/module.d.ts +6 -0
  285. package/dist-sdk/src/entities/search-table/module.js +64 -0
  286. package/dist-sdk/src/entities/shared/context.d.ts +93 -0
  287. package/dist-sdk/src/entities/shared/context.js +156 -0
  288. package/dist-sdk/src/entities/shared/filters/ast.d.ts +242 -0
  289. package/dist-sdk/src/entities/shared/filters/ast.js +65 -0
  290. package/dist-sdk/src/entities/shared/filters/index.d.ts +211 -0
  291. package/dist-sdk/src/entities/shared/filters/index.js +372 -0
  292. package/dist-sdk/src/entities/shared/filters/types.d.ts +170 -0
  293. package/dist-sdk/src/entities/shared/filters/types.js +7 -0
  294. package/dist-sdk/src/entities/shared/ref.d.ts +160 -0
  295. package/dist-sdk/src/entities/shared/ref.js +119 -0
  296. package/dist-sdk/src/entities/shared/types/common.d.ts +106 -0
  297. package/dist-sdk/src/entities/shared/types/common.js +64 -0
  298. package/dist-sdk/src/entities/shared/types/field-types.d.ts +49 -0
  299. package/dist-sdk/src/entities/shared/types/field-types.js +48 -0
  300. package/dist-sdk/src/entities/shared/types/platform.d.ts +46 -0
  301. package/dist-sdk/src/entities/shared/types/platform.js +10 -0
  302. package/dist-sdk/src/entities/skill/build.d.ts +25 -0
  303. package/dist-sdk/src/entities/skill/build.js +50 -0
  304. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +20 -0
  305. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +96 -0
  306. package/dist-sdk/src/entities/skill/from-tf.d.ts +33 -0
  307. package/dist-sdk/src/entities/skill/from-tf.js +95 -0
  308. package/dist-sdk/src/entities/skill/index.d.ts +7 -0
  309. package/dist-sdk/src/entities/skill/index.js +7 -0
  310. package/dist-sdk/src/entities/skill/module.d.ts +4 -0
  311. package/dist-sdk/src/entities/skill/module.js +106 -0
  312. package/dist-sdk/src/entities/skill/to-tf.d.ts +33 -0
  313. package/dist-sdk/src/entities/skill/to-tf.js +58 -0
  314. package/dist-sdk/src/entities/skill/tools.d.ts +71 -0
  315. package/dist-sdk/src/entities/skill/tools.js +88 -0
  316. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +47 -0
  317. package/dist-sdk/src/entities/skill-tool/from-tf.js +121 -0
  318. package/dist-sdk/src/entities/skill-tool/module.d.ts +3 -0
  319. package/dist-sdk/src/entities/skill-tool/module.js +21 -0
  320. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +32 -0
  321. package/dist-sdk/src/entities/skill-tool/to-tf.js +107 -0
  322. package/dist-sdk/src/entities/skill-tool/types.d.ts +40 -0
  323. package/dist-sdk/src/entities/skill-tool/types.js +67 -0
  324. package/dist-sdk/src/entities/table/build.d.ts +74 -0
  325. package/dist-sdk/src/entities/table/build.js +339 -0
  326. package/dist-sdk/src/entities/table/catalog-render.d.ts +5 -0
  327. package/dist-sdk/src/entities/table/catalog-render.js +39 -0
  328. package/dist-sdk/src/entities/table/fields.d.ts +81 -0
  329. package/dist-sdk/src/entities/table/fields.js +70 -0
  330. package/dist-sdk/src/entities/table/filter.d.ts +41 -0
  331. package/dist-sdk/src/entities/table/filter.js +89 -0
  332. package/dist-sdk/src/entities/table/index.d.ts +8 -0
  333. package/dist-sdk/src/entities/table/index.js +12 -0
  334. package/dist-sdk/src/entities/table/joins.d.ts +26 -0
  335. package/dist-sdk/src/entities/table/joins.js +31 -0
  336. package/dist-sdk/src/entities/table/keys.d.ts +11 -0
  337. package/dist-sdk/src/entities/table/keys.js +25 -0
  338. package/dist-sdk/src/entities/table/module.d.ts +5 -0
  339. package/dist-sdk/src/entities/table/module.js +25 -0
  340. package/dist-sdk/src/entities/table/state.d.ts +39 -0
  341. package/dist-sdk/src/entities/table/state.js +43 -0
  342. package/dist-sdk/src/entities/view/from-tf.d.ts +25 -0
  343. package/dist-sdk/src/entities/view/from-tf.js +233 -0
  344. package/dist-sdk/src/entities/view/module.d.ts +24 -0
  345. package/dist-sdk/src/entities/view/module.js +61 -0
  346. package/dist-sdk/src/entities/view/to-tf.d.ts +63 -0
  347. package/dist-sdk/src/entities/view/to-tf.js +156 -0
  348. package/dist-sdk/src/entities/view/types.d.ts +58 -0
  349. package/dist-sdk/src/entities/view/types.js +89 -0
  350. package/dist-sdk/src/graph/deferred-catalog-render.d.ts +14 -0
  351. package/dist-sdk/src/graph/deferred-catalog-render.js +37 -0
  352. package/dist-sdk/src/graph/index.d.ts +83 -0
  353. package/dist-sdk/src/graph/index.js +207 -0
  354. package/dist-sdk/src/graph/modules.d.ts +7 -0
  355. package/dist-sdk/src/graph/modules.js +37 -0
  356. package/dist-sdk/src/graph/types.d.ts +301 -0
  357. package/dist-sdk/src/graph/types.js +102 -0
  358. package/dist-sdk/src/internal/sdk-package.d.ts +7 -0
  359. package/dist-sdk/src/internal/sdk-package.js +23 -0
  360. package/package.json +173 -8
@@ -0,0 +1,20 @@
1
+ /**
2
+ * v2 approval-chain steps. Parallel to v1 `src/approvalChains/steps.ts`. A step
3
+ * targets a user or group by **raw id** (`UserRef`/`GroupRef`) — users and
4
+ * groups are org-directory entities the EDK never manages and that don't live
5
+ * in v2 state, so they're id-by-value, not catalog tokens.
6
+ */
7
+ import { EdkValidationError } from "../../../elementum-entity-client/errors.js";
8
+ export function userStep(user, options) {
9
+ return { kind: "user", ref: user, ...(options?.id != null ? { id: options.id } : {}) };
10
+ }
11
+ export function groupStep(group, options) {
12
+ const { approvalsRequired, denialsRequired, id } = options;
13
+ if (approvalsRequired < 0 || denialsRequired < 0) {
14
+ throw new EdkValidationError(`groupStep: approvalsRequired and denialsRequired must be >= 0 (got ${approvalsRequired}, ${denialsRequired}).`);
15
+ }
16
+ if (approvalsRequired === 0 && denialsRequired === 0) {
17
+ throw new EdkValidationError("groupStep: at least one of approvalsRequired or denialsRequired must be > 0.");
18
+ }
19
+ return { kind: "group", ref: group, approvalsRequired, denialsRequired, ...(id != null ? { id } : {}) };
20
+ }
@@ -0,0 +1,215 @@
1
+ import type { AutomationCatalogRef } from "../../catalog/index.js";
2
+ import { type Context } from "../shared/context.js";
3
+ import { type Ref, type Simplify, type ValueOrRef } from "../shared/ref.js";
4
+ import type { DeployableEntity, EntityDeployOptions, RecordFieldContext } from "../../engine/entity.js";
5
+ import { type ScriptInput } from "./script-code.js";
6
+ /** Structural empty object — neutral element for the `&`-accumulated task map. */
7
+ type EmptyObject = {
8
+ [K in never]: never;
9
+ };
10
+ /** One onDemand trigger parameter's authoring metadata, surfaced to the catalog. */
11
+ export interface TriggerParamMeta {
12
+ readonly name: string;
13
+ readonly required: boolean;
14
+ }
15
+ /**
16
+ * A trigger definition: the full wire trigger envelope (discriminated by kind,
17
+ * e.g. `{ createRecord: {...} }`) and the typed `ctx.trigger` shape.
18
+ */
19
+ export interface TriggerDef<TOutput> {
20
+ readonly wire: Record<string, unknown>;
21
+ /** Phantom — the typed shape exposed as `ctx.trigger`. */
22
+ readonly __output?: TOutput;
23
+ /** onDemand parameter metadata (declaration order) — used by `ref()` to populate the catalog's trigger bag. */
24
+ readonly __params?: readonly TriggerParamMeta[];
25
+ /** The owning app's refName, when this trigger's `record` output is app-field-typed. */
26
+ readonly __recordApp?: string;
27
+ }
28
+ /** A named child task inside an operator (forEach/switch/forkJoin) branch. */
29
+ export interface ChildTask {
30
+ readonly name: string;
31
+ readonly def: TaskDef<unknown>;
32
+ /** Display name distinct from `refKey` (`name`), when adopting a platform-authored task. */
33
+ readonly displayName?: string;
34
+ }
35
+ /**
36
+ * One branch of an operator: a label (case name, or `null` for forEach body /
37
+ * switch default), an optional filter (switch case condition), and its tasks.
38
+ * Maps to the wire `children` entry `{ label, filter?, tasks }`.
39
+ */
40
+ export interface OperatorChild {
41
+ readonly label: string | null;
42
+ readonly filter?: Record<string, unknown>;
43
+ readonly tasks: readonly ChildTask[];
44
+ }
45
+ /**
46
+ * A task definition produced by a factory. `key` is the one-of discriminator the
47
+ * platform expects (e.g. `"recordSearch"`); `config` is that task's inner body
48
+ * (minus `name`, which the builder injects from the `.task(name, …)` call —
49
+ * mirroring v1, where the task name lives inside the body). The wire task becomes
50
+ * `{ [key]: { name, ...config } }`. Operators additionally carry
51
+ * `operatorChildren`, emitted as the wire task's `children`.
52
+ */
53
+ export interface TaskDef<TOutput> {
54
+ readonly key: string;
55
+ readonly config: Record<string, unknown>;
56
+ readonly operatorChildren?: readonly OperatorChild[];
57
+ /** Phantom — the typed shape exposed as `ctx.tasks.<name>`. */
58
+ readonly __output?: TOutput;
59
+ /** The owning app's refName, when this task's `record`/`records` output is app-field-typed. */
60
+ readonly __recordApp?: string;
61
+ }
62
+ /** Placeholder `forEachTaskRefKey` the forEach item proxy emits; replaced with the real refKey. */
63
+ export declare const FOR_EACH_PLACEHOLDER = "__forEach__";
64
+ /**
65
+ * The finalized workflow body `defineAutomation` embeds — the wire trigger, the
66
+ * serialized task list, and the optional output properties. Produced by
67
+ * {@link WorkflowChain.__finalize}; not authored by hand.
68
+ */
69
+ export interface WorkflowDef {
70
+ readonly trigger: unknown;
71
+ readonly tasks: Record<string, unknown>[];
72
+ readonly outputProperties?: {
73
+ outputs: Array<{
74
+ name: string;
75
+ value: unknown;
76
+ }>;
77
+ };
78
+ /** See {@link RecordFieldContext}. Omitted when no trigger/task in this workflow is record-bearing. */
79
+ readonly recordFieldContext?: RecordFieldContext;
80
+ }
81
+ /**
82
+ * The minimal contract `defineAutomation`'s `workflow:` field accepts: anything
83
+ * that can finalize itself to a {@link WorkflowDef}. A `defineWorkflow()` chain
84
+ * satisfies this once a trigger is set ({@link WorkflowBuilder}). The pre-trigger
85
+ * stage ({@link WorkflowStarted}) does not, so a triggerless workflow is a
86
+ * compile error at the assignment.
87
+ */
88
+ export interface WorkflowChain {
89
+ /** @internal — consumed by `defineAutomation`; not part of the authoring API. */
90
+ __finalize(): WorkflowDef;
91
+ /** @internal — onDemand parameter metadata; empty for non-onDemand triggers. */
92
+ __triggerParams(): readonly TriggerParamMeta[];
93
+ /** @internal — output property names declared via `.outputs()`; empty if none. */
94
+ __outputNames(): readonly string[];
95
+ }
96
+ /** A value an output property can carry: a typed ctx ref, or a literal. */
97
+ type OutputValue = Ref<unknown> | string | number | boolean | null;
98
+ /** `Ref<T>` values resolve to `T` by the time the platform hands them to a script. */
99
+ type ResolvedRefs<I> = {
100
+ [K in keyof I]: I[K] extends Ref<infer T> ? T : I[K];
101
+ };
102
+ /**
103
+ * A workflow with a trigger set. `.task()` accumulates typed task outputs;
104
+ * `.outputs()` declares the automation-level output properties (optional).
105
+ * Assign the chain straight to `defineAutomation`'s `workflow:` field.
106
+ *
107
+ * v3 fluent surface: trigger factories return this builder directly
108
+ * (`onDemand({...}).executeScript(...)`), and the Phase-1 task kinds have
109
+ * dedicated methods whose options take ctx-lambdas. The generic `.task()` stays
110
+ * as the escape hatch for every other kind.
111
+ */
112
+ export interface WorkflowBuilder<TTrigger, TTasks extends Record<string, unknown>, TVars extends Record<string, unknown> = EmptyObject> extends WorkflowChain {
113
+ task<TName extends string, TOutput>(name: TName, fn: (ctx: Context<TTrigger, TTasks, TVars>) => TaskDef<TOutput>,
114
+ /**
115
+ * Display name distinct from `refKey` — only needed when adopting a
116
+ * platform-authored task whose wire `name` differs from its `refKey`
117
+ * (e.g. a UI-built "For Each" task, whose slugged refKey is "For_Each").
118
+ * Omit for normally-authored tasks; the wire name defaults to `refKey`.
119
+ */
120
+ displayName?: string): WorkflowBuilder<TTrigger, Simplify<TTasks & Record<TName, TOutput>>, TVars>;
121
+ /**
122
+ * Fluent executeScript (v3). `inputs` is a ctx-lambda mapping input names to
123
+ * refs/values; `code` is a FUNCTION — the TS contract is the authoring
124
+ * surface (typed `input.parameters` from `inputs`; the return type flows to
125
+ * `ctx.tasks.<name>.result.*` downstream). Its transpiled body ships as the
126
+ * platform script. String bodies exist only on the generic factory, for the
127
+ * pulled-source path.
128
+ *
129
+ * The output schema is INFERRED from the code's `return {...}` literals —
130
+ * property names statically, property types from literal values (default
131
+ * text). Pass `outputs` only to override: a non-text property whose value
132
+ * isn't a literal, or a return the scan can't enumerate.
133
+ */
134
+ executeScript<TName extends string, I extends Record<string, ValueOrRef<unknown>> = Record<string, never>, R extends Record<string, unknown> = Record<string, unknown>>(name: TName, opts: {
135
+ readonly inputs?: (ctx: Context<TTrigger, TTasks, TVars>) => I;
136
+ readonly code: (input: ScriptInput<ResolvedRefs<I>>) => R;
137
+ /** Override the inferred output schema: property name → `"text" | "integer" | "number" | "decimal" | "boolean"`. */
138
+ readonly outputs?: Record<string, string>;
139
+ }): WorkflowBuilder<TTrigger, Simplify<TTasks & Record<TName, {
140
+ result: R;
141
+ textResult: string;
142
+ }>>, TVars>;
143
+ /**
144
+ * Fluent setVariable (v3): one variable, NAMED THE SAME as its task — read
145
+ * it downstream as `ctx.variables.<name>`, the variable's typed ref
146
+ * (`Ref<string>` for the default TEXT type). (The variable name is
147
+ * platform-visible and must be workflow-unique — ei's export resolves
148
+ * variable refs by name per workflow — so it mirrors the task name rather
149
+ * than a fixed "value".) `value` is a ctx-lambda returning a ref, template,
150
+ * or literal (`(ctx) => "static"` for constants — the lambda form keeps
151
+ * `ctx` fully typed; a bare `ValueOrRef<unknown>` union would collapse to
152
+ * `unknown` and erase it).
153
+ */
154
+ setVariable<TName extends string, TType extends string = "TEXT">(name: TName, opts: {
155
+ readonly value: (ctx: Context<TTrigger, TTasks, TVars>) => ValueOrRef<unknown>;
156
+ /** Platform variable type (default "TEXT"). */
157
+ readonly type?: TType;
158
+ }): WorkflowBuilder<TTrigger, Simplify<TTasks & Record<TName, Record<string, never>>>, Simplify<TVars & Record<TName, VariableValueOf<TType>>>>;
159
+ /**
160
+ * Declare the workflow's output properties — a map of output name → value,
161
+ * where each value is a typed ctx ref (`ctx.tasks.x.y`, `ctx.trigger.z`) or a
162
+ * literal. The ctx sees the trigger and every task, since outputs are read
163
+ * after the workflow runs.
164
+ */
165
+ outputs(fn: (ctx: Context<TTrigger, TTasks, TVars>) => Record<string, OutputValue>): WorkflowBuilder<TTrigger, TTasks, TVars>;
166
+ }
167
+ /** Platform variable type → the TS value type its `ctx.variables.<name>` ref carries. */
168
+ type VariableValueOf<T extends string> = T extends "TEXT" ? string : T extends "NUMBER" | "DECIMAL" | "INTEGER" ? number : T extends "BOOLEAN" ? boolean : unknown;
169
+ /** The pre-trigger stage — a trigger must be set before tasks or outputs. */
170
+ export interface WorkflowStarted {
171
+ trigger<TOutput>(trigger: TriggerDef<TOutput>): WorkflowBuilder<TOutput, EmptyObject>;
172
+ }
173
+ /**
174
+ * A trigger that is ALSO the start of a workflow chain (v3): assign it to
175
+ * `workflow:` and chain tasks directly — `onDemand({}).executeScript(...)` —
176
+ * or keep the legacy `defineWorkflow().trigger(...)` form; both accept it.
177
+ */
178
+ export type TriggerChain<TOutput> = TriggerDef<TOutput> & WorkflowBuilder<TOutput, EmptyObject>;
179
+ /** Wrap a TriggerDef so it doubles as the chain start. Used by the trigger factories. */
180
+ export declare function chainableTrigger<TOutput>(trigger: TriggerDef<TOutput>): TriggerChain<TOutput>;
181
+ /**
182
+ * Begin a workflow body. Set a trigger, chain `.task(...)`, optionally close
183
+ * with `.outputs(...)`, then assign the result to `defineAutomation`'s
184
+ * `workflow:` field — no terminal `.build()`.
185
+ */
186
+ export declare function defineWorkflow(): WorkflowStarted;
187
+ export interface AutomationV2Options extends EntityDeployOptions {
188
+ /** The automation's display name. Changing it updates the existing automation. */
189
+ readonly name: string;
190
+ /** The owning app's ref name (e.g. `"incidents"`). */
191
+ readonly parent: string;
192
+ readonly status?: "DRAFT" | "ACTIVE";
193
+ /** Publish token preserved by pull; bump deliberately to republish a changed workflow. */
194
+ readonly workflowRevision?: string;
195
+ /** The workflow body — a `defineWorkflow()` chain with a trigger set. */
196
+ readonly workflow: WorkflowChain;
197
+ }
198
+ /**
199
+ * The configured result of `defineAutomation` — its reference surface (`ref()`)
200
+ * and its deployable entity (`def()`). Both take `refName` as a **call-time
201
+ * argument** (the file's own name, never stored on the entity) — see
202
+ * `AppConfigured` in `src/aspects/build.ts` for the design rationale.
203
+ */
204
+ export interface AutomationConfigured {
205
+ ref(refName: string): AutomationCatalogRef;
206
+ def(refName: string): DeployableEntity;
207
+ }
208
+ /**
209
+ * Define a v2 automation. Identity comes from the authoring file's `refName`
210
+ * plus `parent`; the display `name` lives only in the payload, so renaming an
211
+ * automation plans as an update rather than a create. Returns an
212
+ * `AutomationConfigured` with `ref(refName)` and `def(refName)`.
213
+ */
214
+ export declare function defineAutomation(opts: AutomationV2Options): AutomationConfigured;
215
+ export {};
@@ -0,0 +1,424 @@
1
+ /**
2
+ * v2 automation authoring — an options-shaped `defineAutomation` whose workflow
3
+ * body is a typed, chainable `defineWorkflow()`:
4
+ *
5
+ * defineAutomation({
6
+ * name: "Escalate",
7
+ * parent: "incidents",
8
+ * status: "DRAFT",
9
+ * workflow: defineWorkflow()
10
+ * .trigger(recordCreated({ app }))
11
+ * .task("search", (ctx) => recordSearch({ app, filter: ... }))
12
+ * .task("notify", (ctx) => sendEmail({ to: "...", body: ctx.tasks.search.totalCount }))
13
+ * .outputs((ctx) => ({ found: ctx.tasks.search.totalCount })), // optional
14
+ * }) // → AutomationConfigured
15
+ *
16
+ * `defineAutomation` is **not** chained — it takes an options object and returns
17
+ * an `AutomationConfigured` with `.ref(refName)` and `.def(refName)`. The chaining
18
+ * lives on the `workflow` field, built by `defineWorkflow()`: set a trigger, chain
19
+ * `.task(...)`, optionally close with `.outputs(...)`. Assign the chain straight to
20
+ * `workflow:` — no terminal `.build()` call.
21
+ *
22
+ * The typed `ctx` (compile-time-safe `ctx.trigger.x` / `ctx.tasks.y.output`)
23
+ * comes from the **shared core engine** (`core/context` + `core/ref`), which is
24
+ * reference-model-agnostic — it only models data flow *inside* the automation.
25
+ * Cross-entity references are `CatalogRef` tokens, resolved at deploy.
26
+ */
27
+ import { randomUUID } from "crypto";
28
+ import { buildContext } from "../shared/context.js";
29
+ import { isRef } from "../shared/ref.js";
30
+ import { serializeNode } from "./serialize.js";
31
+ import { extractScriptBody, inferOutputSchema } from "./script-code.js";
32
+ // Runtime import of the two Phase-1 factories the fluent methods sugar over.
33
+ // tasks.ts's own import of build.ts is type-only, so there is no runtime cycle.
34
+ import { executeScript as executeScriptTask, setVariable as setVariableTask } from "./tasks.js";
35
+ /** Placeholder `forEachTaskRefKey` the forEach item proxy emits; replaced with the real refKey. */
36
+ export const FOR_EACH_PLACEHOLDER = "__forEach__";
37
+ /**
38
+ * Serialize one task (recursively for operators) to the wire
39
+ * `{ refKey, task, children? }` shape. The task's human display name is
40
+ * injected into the body — `displayName` when given (an adopted task whose
41
+ * platform-side name differs from its `refKey`, e.g. "For Each" vs.
42
+ * "For_Each"), else `refKey` itself, matching prior behavior; operator
43
+ * children become `children`; a forEach task's `__forEach__` placeholder is
44
+ * swapped for its real refKey.
45
+ */
46
+ function serializeTaskEntry(name, def, displayName) {
47
+ const result = {
48
+ refKey: name,
49
+ task: serializeNode({ [def.key]: { name: displayName ?? name, ...def.config } }),
50
+ };
51
+ if (def.operatorChildren && def.operatorChildren.length > 0) {
52
+ result.children = def.operatorChildren.map((child) => ({
53
+ label: child.label,
54
+ ...(child.filter !== undefined ? { filter: serializeNode(child.filter) } : {}),
55
+ tasks: child.tasks.map((t) => serializeTaskEntry(t.name, t.def, t.displayName)),
56
+ }));
57
+ }
58
+ if (def.key === "forEach")
59
+ replaceForEachPlaceholder(result, name);
60
+ return result;
61
+ }
62
+ /** Replace every `forEachTaskRefKey: "__forEach__"` in the tree with `refKey`. */
63
+ function replaceForEachPlaceholder(node, refKey) {
64
+ if (node === null || typeof node !== "object")
65
+ return;
66
+ if (Array.isArray(node)) {
67
+ for (const item of node)
68
+ replaceForEachPlaceholder(item, refKey);
69
+ return;
70
+ }
71
+ const rec = node;
72
+ for (const key of Object.keys(rec)) {
73
+ if (key === "forEachTaskRefKey" && rec[key] === FOR_EACH_PLACEHOLDER) {
74
+ rec[key] = refKey;
75
+ }
76
+ else {
77
+ replaceForEachPlaceholder(rec[key], refKey);
78
+ }
79
+ }
80
+ }
81
+ /**
82
+ * Map every task's refKey (its `.task(name, …)` name) to its factory key,
83
+ * descending into operator children — the forward mirror of the deserializer's
84
+ * `taskTypeByRefKey`. Used to resolve the type of the task a `taskReference`
85
+ * points at so output-name rewrites apply only to the right task kind.
86
+ */
87
+ function collectTaskKinds(tasks) {
88
+ const out = new Map();
89
+ const visit = (entries) => {
90
+ for (const { name, def } of entries) {
91
+ out.set(name, def.key);
92
+ for (const child of def.operatorChildren ?? [])
93
+ visit(child.tasks);
94
+ }
95
+ };
96
+ visit(tasks);
97
+ return out;
98
+ }
99
+ /**
100
+ * Map every record-bearing task's refKey to the app refName that owns its
101
+ * `.record`/`.records` output, descending into operator children — mirrors
102
+ * `collectTaskKinds`. Feeds `RecordFieldContext.taskAppRefNameByRefKey` so the
103
+ * deploy pipeline knows which app's fields a `record.<refName>` wire path
104
+ * under that refKey belongs to.
105
+ */
106
+ function collectRecordApps(tasks) {
107
+ const out = {};
108
+ const visit = (entries) => {
109
+ for (const { name, def } of entries) {
110
+ if (def.__recordApp !== undefined)
111
+ out[name] = def.__recordApp;
112
+ for (const child of def.operatorChildren ?? [])
113
+ visit(child.tasks);
114
+ }
115
+ };
116
+ visit(tasks);
117
+ return out;
118
+ }
119
+ /**
120
+ * Tasks whose output carries a `.record` sub-object. Mirrors the deserializer's
121
+ * `RECORD_BEARING_TASK_TYPES` — kept local to avoid a builder → pull-path import.
122
+ */
123
+ const RECORD_BEARING_TASK_KEYS = new Set(["recordSearch", "createRecord", "findRelatedRecords"]);
124
+ /**
125
+ * Single-scalar-output task kinds whose EDK factory exposes the result as
126
+ * `output` (`TaskDef<{ output: unknown }>`), but whose platform wire name
127
+ * differs. Confirmed against real pulled wire data — aiSummarize/aiTransform
128
+ * name their producing task's output `response`; documentModel (rawText data
129
+ * source) names it `text`. Mirrors the deserializer's `OUTPUT_KEY_WIRE_NAME`
130
+ * (`deserializer/ref-deserializer.ts`) — keep the two in sync.
131
+ */
132
+ const OUTPUT_KEY_WIRE_NAME = {
133
+ aiSummarize: "response",
134
+ aiTransform: "response",
135
+ documentModel: "text",
136
+ };
137
+ /**
138
+ * Forward output-name rewrites, the inverse of the deserializer's read-side
139
+ * normalization (`applyOutputNameInverseRewrites` in
140
+ * `materialize/ref-deserializer.ts` — keep the two in sync):
141
+ * - recordSearch: `totalCount` → the platform's `count`.
142
+ * - aiAgent: `result` / `result.<field>` → the platform's
143
+ * `ai_agent_task_response` (text) / `ai_agent_task_structured_output.<field>` (json).
144
+ * - record-bearing tasks: the read path reinjects a `.record` hop on the id
145
+ * accessor (wire `recordId` → source `record.recordId`); collapse it back to
146
+ * the platform's flat `recordId` on write.
147
+ * - single-scalar-output tasks (see `OUTPUT_KEY_WIRE_NAME`): `output` →
148
+ * the platform's actual output name for that task kind.
149
+ */
150
+ function rewriteForwardTaskRefName(taskKey, name) {
151
+ if (taskKey === "recordSearch" && name === "totalCount") {
152
+ return "count";
153
+ }
154
+ if (taskKey === "aiAgent") {
155
+ const segs = name.split(".");
156
+ if (segs[0] !== "result")
157
+ return name;
158
+ if (segs.length === 1)
159
+ return "ai_agent_task_response";
160
+ return ["ai_agent_task_structured_output", ...segs.slice(1).map((s) => s.toLowerCase())].join(".");
161
+ }
162
+ if (taskKey && RECORD_BEARING_TASK_KEYS.has(taskKey) && name === "record.recordId") {
163
+ return "recordId";
164
+ }
165
+ const wireOutputKey = taskKey ? OUTPUT_KEY_WIRE_NAME[taskKey] : undefined;
166
+ if (wireOutputKey) {
167
+ const segs = name.split(".");
168
+ if (segs[0] === "output")
169
+ return [wireOutputKey, ...segs.slice(1)].join(".");
170
+ }
171
+ return name;
172
+ }
173
+ /**
174
+ * Walk a serialized wire node and rewrite, in place, the `name` of every task
175
+ * output reference whose target task needs an output-name rewrite. Two wire
176
+ * shapes carry a task-ref name: `{ taskReference: { taskRefKey, name } }`
177
+ * (`core/wire/ref-serializer`'s `serializeRefData`, used at ordinary value
178
+ * positions) and `{ type: "TASK", taskRefKey, name }` (`core/filters`'
179
+ * `refDataToFilterReference`, used at filter `leftValue`/`value` positions by
180
+ * the `ref*` filter helpers) — both need the same rewrite. Runs at finalize,
181
+ * when the full refKey→kind map is known.
182
+ */
183
+ function rewriteTaskOutputRefs(node, taskKindByRefKey) {
184
+ if (Array.isArray(node)) {
185
+ for (const item of node)
186
+ rewriteTaskOutputRefs(item, taskKindByRefKey);
187
+ return;
188
+ }
189
+ if (node === null || typeof node !== "object")
190
+ return;
191
+ const rec = node;
192
+ const ref = rec.taskReference;
193
+ if (ref && typeof ref.taskRefKey === "string" && typeof ref.name === "string") {
194
+ ref.name = rewriteForwardTaskRefName(taskKindByRefKey.get(ref.taskRefKey), ref.name);
195
+ }
196
+ if (rec.type === "TASK" && typeof rec.taskRefKey === "string" && typeof rec.name === "string") {
197
+ rec.name = rewriteForwardTaskRefName(taskKindByRefKey.get(rec.taskRefKey), rec.name);
198
+ }
199
+ for (const v of Object.values(rec))
200
+ rewriteTaskOutputRefs(v, taskKindByRefKey);
201
+ }
202
+ /**
203
+ * Walk serialized tasks and assign UUIDs to any `variable.create` entries that
204
+ * lack one. Returns a `"taskRefKey::varName" → uuid` map used by
205
+ * `resolveVariableParamMarkers` to replace `__variableParamRef` placeholders.
206
+ */
207
+ function stampAndCollectVariableIds(tasks) {
208
+ const map = new Map();
209
+ const visit = (ts) => {
210
+ for (const t of ts) {
211
+ const refKey = t.refKey;
212
+ const task = t.task;
213
+ const variable = task?.variable;
214
+ if (variable?.create) {
215
+ for (const c of variable.create) {
216
+ if (!c.id)
217
+ c.id = randomUUID();
218
+ map.set(`${refKey}::${c.name}`, c.id);
219
+ }
220
+ }
221
+ const children = t.children;
222
+ if (children) {
223
+ for (const ch of children)
224
+ visit(ch.tasks);
225
+ }
226
+ }
227
+ };
228
+ visit(tasks);
229
+ return map;
230
+ }
231
+ /**
232
+ * Replace every `{ __variableParamRef: { variableTaskRefKey, name } }` marker
233
+ * in the serialized tree with `{ variableReference: { id, name: "variable|<id>" } }`.
234
+ * Throws when a referenced variable isn't in `idMap` — the variable must be
235
+ * created by a `setVariable` task in the same workflow.
236
+ */
237
+ function resolveVariableParamMarkers(node, idMap) {
238
+ if (node === null || typeof node !== "object")
239
+ return;
240
+ if (Array.isArray(node)) {
241
+ for (const item of node)
242
+ resolveVariableParamMarkers(item, idMap);
243
+ return;
244
+ }
245
+ const o = node;
246
+ const marker = o.__variableParamRef;
247
+ if (marker) {
248
+ const key = `${marker.variableTaskRefKey}::${marker.name}`;
249
+ const id = idMap.get(key);
250
+ if (!id) {
251
+ throw new Error(`Variable "${marker.name}" not found on task "${marker.variableTaskRefKey}". ` +
252
+ `Check that a setVariable task with that refKey creates a variable with that name.`);
253
+ }
254
+ delete o.__variableParamRef;
255
+ o.variableReference = { id, name: `variable|${id}` };
256
+ return;
257
+ }
258
+ for (const v of Object.values(o))
259
+ resolveVariableParamMarkers(v, idMap);
260
+ }
261
+ function serializeOutputValue(value) {
262
+ return isRef(value) ? serializeNode(value) : { value };
263
+ }
264
+ function makeWorkflowBuilder(state) {
265
+ const builder = {
266
+ task(name, fn, displayName) {
267
+ const ctx = buildContext(state.tasks.map((t) => t.name));
268
+ const def = fn(ctx);
269
+ return makeWorkflowBuilder({ ...state, tasks: [...state.tasks, { name, def, displayName }] });
270
+ },
271
+ executeScript(name, opts) {
272
+ // Sugar over the generic factory: resolve the ctx-lambda inputs, then
273
+ // delegate. The declared return type carries the {result: R} phantom;
274
+ // the factory's runtime TaskDef is shape-identical. The body is
275
+ // extracted HERE (not left to the factory) so the output schema can be
276
+ // inferred from its return literals; the generic factory itself never
277
+ // infers — pulled sources must emit exactly the schema the platform
278
+ // has, or adopted no-schema scripts would drift.
279
+ const body = extractScriptBody(opts.code);
280
+ const outputs = opts.outputs ?? inferOutputSchema(body);
281
+ return builder.task(name, (ctx) => executeScriptTask({
282
+ code: body,
283
+ ...(opts.inputs !== undefined ? { inputs: opts.inputs(ctx) } : {}),
284
+ ...(outputs !== undefined ? { outputs } : {}),
285
+ }));
286
+ },
287
+ setVariable(name, opts) {
288
+ return builder.task(name, (ctx) => setVariableTask({
289
+ create: [{ name, type: opts.type ?? "TEXT", value: opts.value(ctx) }],
290
+ }));
291
+ },
292
+ outputs(fn) {
293
+ const ctx = buildContext(state.tasks.map((t) => t.name));
294
+ const map = fn(ctx);
295
+ const outputs = Object.entries(map).map(([name, value]) => ({
296
+ name,
297
+ value: serializeOutputValue(value),
298
+ }));
299
+ return makeWorkflowBuilder({ ...state, outputs });
300
+ },
301
+ __triggerParams() {
302
+ return state.trigger.__params ?? [];
303
+ },
304
+ __outputNames() {
305
+ return state.outputs?.map((o) => o.name) ?? [];
306
+ },
307
+ __finalize() {
308
+ const taskKindByRefKey = collectTaskKinds(state.tasks);
309
+ const tasks = state.tasks.map((t) => serializeTaskEntry(t.name, t.def, t.displayName));
310
+ const outputs = state.outputs?.map((o) => ({ ...o }));
311
+ rewriteTaskOutputRefs(tasks, taskKindByRefKey);
312
+ if (outputs)
313
+ rewriteTaskOutputRefs(outputs, taskKindByRefKey);
314
+ // Trigger reference names are NOT canonicalized: the authored name is
315
+ // the name, everywhere in EDK. (Mobius canonicalizes reference names in
316
+ // ITS storage — `ValueReference.ofTriggerReference` — but on the tf
317
+ // path the provider mints references from the trigger's refs map, which
318
+ // is keyed by DECLARED parameter names, so the canonical form never
319
+ // crosses EDK's boundary. The old canonicalize-then-reverse-map dance
320
+ // existed for the legacy compose path and mangled ALL-CAPS names.)
321
+ const variableIdMap = stampAndCollectVariableIds(tasks);
322
+ if (variableIdMap.size > 0) {
323
+ resolveVariableParamMarkers(tasks, variableIdMap);
324
+ if (outputs)
325
+ resolveVariableParamMarkers(outputs, variableIdMap);
326
+ }
327
+ const taskAppRefNameByRefKey = collectRecordApps(state.tasks);
328
+ const recordFieldContext = state.trigger.__recordApp !== undefined || Object.keys(taskAppRefNameByRefKey).length > 0
329
+ ? {
330
+ ...(state.trigger.__recordApp !== undefined ? { triggerAppRefName: state.trigger.__recordApp } : {}),
331
+ ...(Object.keys(taskAppRefNameByRefKey).length > 0 ? { taskAppRefNameByRefKey } : {}),
332
+ }
333
+ : undefined;
334
+ return {
335
+ trigger: serializeNode(state.trigger.wire),
336
+ tasks,
337
+ ...(outputs && outputs.length > 0 ? { outputProperties: { outputs } } : {}),
338
+ ...(recordFieldContext !== undefined ? { recordFieldContext } : {}),
339
+ };
340
+ },
341
+ };
342
+ return builder;
343
+ }
344
+ /** Wrap a TriggerDef so it doubles as the chain start. Used by the trigger factories. */
345
+ export function chainableTrigger(trigger) {
346
+ return { ...trigger, ...makeWorkflowBuilder({ trigger, tasks: [] }) };
347
+ }
348
+ /**
349
+ * Begin a workflow body. Set a trigger, chain `.task(...)`, optionally close
350
+ * with `.outputs(...)`, then assign the result to `defineAutomation`'s
351
+ * `workflow:` field — no terminal `.build()`.
352
+ */
353
+ export function defineWorkflow() {
354
+ return {
355
+ trigger(trigger) {
356
+ return makeWorkflowBuilder({ trigger, tasks: [] });
357
+ },
358
+ };
359
+ }
360
+ /**
361
+ * Define a v2 automation. Identity comes from the authoring file's `refName`
362
+ * plus `parent`; the display `name` lives only in the payload, so renaming an
363
+ * automation plans as an update rather than a create. Returns an
364
+ * `AutomationConfigured` with `ref(refName)` and `def(refName)`.
365
+ */
366
+ export function defineAutomation(opts) {
367
+ return {
368
+ ref(refName) {
369
+ const triggerParams = opts.workflow.__triggerParams();
370
+ const outputNames = opts.workflow.__outputNames();
371
+ // Bag keys are the DECLARED names, verbatim (no canonicalization —
372
+ // access non-identifier names with brackets: trigger["STUDENT NAME 2"]).
373
+ // `required: true` is stamped only when true (canonical form) — it is
374
+ // what agentRunAutomation's typed inputs and def() validation read.
375
+ const trigger = triggerParams.length > 0
376
+ ? Object.fromEntries(triggerParams.map((p) => [
377
+ p.name,
378
+ {
379
+ __kind: "triggerParameter",
380
+ refName: p.name,
381
+ name: p.name,
382
+ parent: refName,
383
+ ...(p.required ? { required: true } : {}),
384
+ },
385
+ ]))
386
+ : undefined;
387
+ const outputs = outputNames.length > 0
388
+ ? Object.fromEntries(outputNames.map((n) => [n, { __kind: "outputProperty", refName: n, name: n, parent: refName }]))
389
+ : undefined;
390
+ return {
391
+ __kind: "automation",
392
+ refName: refName,
393
+ name: opts.name,
394
+ parent: opts.parent,
395
+ ...(trigger !== undefined ? { trigger } : {}),
396
+ ...(outputs !== undefined ? { outputs } : {}),
397
+ };
398
+ },
399
+ def(refName) {
400
+ const wf = opts.workflow.__finalize();
401
+ // `recordFieldContext` is a structural extension, not a declared `DeployableEntity`
402
+ // property (see `RecordFieldContext`'s doc comment) — assigning to `entity`
403
+ // first (rather than returning the literal directly) avoids an excess-property
404
+ // error against the `DeployableEntity` return type while still attaching it for
405
+ // `recordFieldContextOf` to read back at deploy time.
406
+ const entity = {
407
+ kind: "automation",
408
+ parent: opts.parent,
409
+ refName,
410
+ payload: {
411
+ name: opts.name,
412
+ status: opts.status ?? "DRAFT",
413
+ workflowRevision: opts.workflowRevision ?? "1.0.0",
414
+ trigger: wf.trigger,
415
+ tasks: wf.tasks,
416
+ ...(wf.outputProperties ? { outputProperties: wf.outputProperties } : {}),
417
+ },
418
+ ...(opts.enabled !== undefined ? { enabled: opts.enabled } : {}),
419
+ ...(wf.recordFieldContext !== undefined ? { recordFieldContext: wf.recordFieldContext } : {}),
420
+ };
421
+ return entity;
422
+ },
423
+ };
424
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Catalog emission dialect for automations (trigger / outputs bags).
3
+ */
4
+ import type { CatalogRenderArgs, CatalogRenderResult } from "../../graph/types.js";
5
+ export declare function renderAutomationCatalogEntry(args: CatalogRenderArgs): CatalogRenderResult;