@elementumai/edk 0.9.18 → 0.9.20

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 (219) hide show
  1. package/README.md +154 -9
  2. package/dist-sdk/src/catalog/factories.d.ts +35 -1
  3. package/dist-sdk/src/catalog/factories.js +36 -0
  4. package/dist-sdk/src/catalog/from-authoring.d.ts +13 -8
  5. package/dist-sdk/src/catalog/from-authoring.js +34 -9
  6. package/dist-sdk/src/catalog/index.d.ts +2 -2
  7. package/dist-sdk/src/catalog/index.js +2 -2
  8. package/dist-sdk/src/catalog/org.d.ts +39 -1
  9. package/dist-sdk/src/catalog/org.js +460 -50
  10. package/dist-sdk/src/catalog/render.js +6 -6
  11. package/dist-sdk/src/catalog/token.js +7 -0
  12. package/dist-sdk/src/catalog/types.d.ts +44 -1
  13. package/dist-sdk/src/catalog/types.js +13 -0
  14. package/dist-sdk/src/core/triggers/on-demand.d.ts +39 -3
  15. package/dist-sdk/src/core/triggers/on-demand.js +10 -2
  16. package/dist-sdk/src/engine/build/context.d.ts +1 -1
  17. package/dist-sdk/src/engine/ei/run.d.ts +149 -0
  18. package/dist-sdk/src/engine/ei/run.js +1132 -0
  19. package/dist-sdk/src/engine/logging.d.ts +17 -0
  20. package/dist-sdk/src/engine/logging.js +18 -0
  21. package/dist-sdk/src/engine/pull/ref-only.d.ts +5 -0
  22. package/dist-sdk/src/engine/pull/ref-only.js +64 -27
  23. package/dist-sdk/src/engine/pull/result-output.d.ts +8 -0
  24. package/dist-sdk/src/engine/pull/result-output.js +88 -4
  25. package/dist-sdk/src/engine/tf/expr.js +39 -14
  26. package/dist-sdk/src/engine/tf/index.d.ts +3 -3
  27. package/dist-sdk/src/engine/tf/index.js +2 -2
  28. package/dist-sdk/src/engine/tf/labels.d.ts +8 -0
  29. package/dist-sdk/src/engine/tf/labels.js +13 -0
  30. package/dist-sdk/src/engine/tf/model.d.ts +22 -1
  31. package/dist-sdk/src/engine/tf/parse.d.ts +19 -0
  32. package/dist-sdk/src/engine/tf/parse.js +197 -10
  33. package/dist-sdk/src/engine/tf/render.d.ts +4 -2
  34. package/dist-sdk/src/engine/tf/render.js +41 -7
  35. package/dist-sdk/src/engine/validation.d.ts +39 -0
  36. package/dist-sdk/src/engine/validation.js +85 -0
  37. package/dist-sdk/src/engine/workspace/loader.js +49 -12
  38. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +11 -1
  39. package/dist-sdk/src/entities/access-policy/from-tf.js +6 -1
  40. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +11 -0
  41. package/dist-sdk/src/entities/access-policy/to-tf.js +16 -6
  42. package/dist-sdk/src/entities/agent/build.d.ts +4 -16
  43. package/dist-sdk/src/entities/agent/build.js +40 -5
  44. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +4 -2
  45. package/dist-sdk/src/entities/agent/to-tf.js +6 -3
  46. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
  47. package/dist-sdk/src/entities/agent-tool/from-tf.js +7 -1
  48. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
  49. package/dist-sdk/src/entities/agent-tool/to-tf.js +29 -6
  50. package/dist-sdk/src/entities/app/build.d.ts +98 -19
  51. package/dist-sdk/src/entities/app/build.js +51 -19
  52. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +22 -1
  53. package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
  54. package/dist-sdk/src/entities/app/from-tf.js +11 -5
  55. package/dist-sdk/src/entities/app/index.d.ts +6 -5
  56. package/dist-sdk/src/entities/app/index.js +2 -0
  57. package/dist-sdk/src/entities/app/module.js +18 -2
  58. package/dist-sdk/src/entities/app/to-tf.js +21 -11
  59. package/dist-sdk/src/entities/automation/build.d.ts +49 -6
  60. package/dist-sdk/src/entities/automation/build.js +163 -19
  61. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +24 -1
  62. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +320 -39
  63. package/dist-sdk/src/entities/automation/from-tf.d.ts +28 -6
  64. package/dist-sdk/src/entities/automation/from-tf.js +563 -74
  65. package/dist-sdk/src/entities/automation/generated/task-output-contracts.d.ts +33 -0
  66. package/dist-sdk/src/entities/automation/generated/task-output-contracts.js +183 -0
  67. package/dist-sdk/src/entities/automation/index.d.ts +2 -2
  68. package/dist-sdk/src/entities/automation/index.js +1 -1
  69. package/dist-sdk/src/entities/automation/module.d.ts +2 -0
  70. package/dist-sdk/src/entities/automation/module.js +93 -8
  71. package/dist-sdk/src/entities/automation/output-field-types.d.ts +7 -0
  72. package/dist-sdk/src/entities/automation/output-field-types.js +36 -0
  73. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +9 -0
  74. package/dist-sdk/src/entities/automation/output-key-wire-name.js +13 -0
  75. package/dist-sdk/src/entities/automation/script-code.d.ts +17 -0
  76. package/dist-sdk/src/entities/automation/script-code.js +91 -5
  77. package/dist-sdk/src/entities/automation/system-ref-name.d.ts +16 -0
  78. package/dist-sdk/src/entities/automation/system-ref-name.js +48 -0
  79. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +17 -0
  80. package/dist-sdk/src/entities/automation/task-output-labels.js +47 -0
  81. package/dist-sdk/src/entities/automation/tasks.d.ts +53 -4
  82. package/dist-sdk/src/entities/automation/tasks.js +38 -9
  83. package/dist-sdk/src/entities/automation/to-tf.d.ts +4 -0
  84. package/dist-sdk/src/entities/automation/to-tf.js +647 -167
  85. package/dist-sdk/src/entities/automation/triggers.d.ts +4 -2
  86. package/dist-sdk/src/entities/automation/triggers.js +4 -0
  87. package/dist-sdk/src/entities/automation/types.js +1 -0
  88. package/dist-sdk/src/entities/chart/from-tf.js +33 -17
  89. package/dist-sdk/src/entities/chart/module.js +3 -1
  90. package/dist-sdk/src/entities/chart/printer.d.ts +1 -0
  91. package/dist-sdk/src/entities/chart/printer.js +26 -16
  92. package/dist-sdk/src/entities/chart/rebind-owner.d.ts +3 -0
  93. package/dist-sdk/src/entities/chart/rebind-owner.js +42 -0
  94. package/dist-sdk/src/entities/chart/to-tf.js +21 -12
  95. package/dist-sdk/src/entities/dashboard/build.d.ts +4 -0
  96. package/dist-sdk/src/entities/dashboard/from-tf.js +15 -4
  97. package/dist-sdk/src/entities/dashboard/to-tf.d.ts +2 -0
  98. package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
  99. package/dist-sdk/src/entities/dashboard-widget/module.js +4 -0
  100. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +72 -30
  101. package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +3 -0
  102. package/dist-sdk/src/entities/dynamic-layout/dialect.js +5 -0
  103. package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +9 -6
  104. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +188 -26
  105. package/dist-sdk/src/entities/dynamic-layout/module.js +4 -1
  106. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +5 -1
  107. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +254 -23
  108. package/dist-sdk/src/entities/element/build.d.ts +33 -13
  109. package/dist-sdk/src/entities/element/build.js +5 -1
  110. package/dist-sdk/src/entities/element/from-tf.d.ts +12 -0
  111. package/dist-sdk/src/entities/element/from-tf.js +64 -3
  112. package/dist-sdk/src/entities/element/index.d.ts +5 -2
  113. package/dist-sdk/src/entities/element/index.js +2 -0
  114. package/dist-sdk/src/entities/element/module.js +11 -3
  115. package/dist-sdk/src/entities/element/to-tf.js +20 -2
  116. package/dist-sdk/src/entities/field/build.d.ts +14 -1
  117. package/dist-sdk/src/entities/field/build.js +3 -0
  118. package/dist-sdk/src/entities/field/from-tf.d.ts +3 -0
  119. package/dist-sdk/src/entities/field/from-tf.js +50 -1
  120. package/dist-sdk/src/entities/field/media-types.d.ts +6 -0
  121. package/dist-sdk/src/entities/field/media-types.js +30 -0
  122. package/dist-sdk/src/entities/field/module.js +1 -0
  123. package/dist-sdk/src/entities/field/to-tf.d.ts +23 -2
  124. package/dist-sdk/src/entities/field/to-tf.js +142 -22
  125. package/dist-sdk/src/entities/file-reader/from-tf.js +14 -5
  126. package/dist-sdk/src/entities/file-reader/module.js +1 -0
  127. package/dist-sdk/src/entities/file-reader/types.d.ts +2 -0
  128. package/dist-sdk/src/entities/file-reader/types.js +1 -1
  129. package/dist-sdk/src/entities/portal/build.d.ts +26 -0
  130. package/dist-sdk/src/entities/portal/build.js +37 -0
  131. package/dist-sdk/src/entities/portal/from-tf.d.ts +27 -0
  132. package/dist-sdk/src/entities/portal/from-tf.js +75 -0
  133. package/dist-sdk/src/entities/portal/index.d.ts +1 -0
  134. package/dist-sdk/src/entities/portal/index.js +1 -0
  135. package/dist-sdk/src/entities/portal/module.d.ts +3 -0
  136. package/dist-sdk/src/entities/portal/module.js +28 -0
  137. package/dist-sdk/src/entities/portal/to-tf.d.ts +12 -0
  138. package/dist-sdk/src/entities/portal/to-tf.js +73 -0
  139. package/dist-sdk/src/entities/portal/types.d.ts +1 -0
  140. package/dist-sdk/src/entities/portal/types.js +1 -0
  141. package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -1
  142. package/dist-sdk/src/entities/relationship/from-tf.js +53 -10
  143. package/dist-sdk/src/entities/relationship/module.js +2 -0
  144. package/dist-sdk/src/entities/relationship/pair-check.d.ts +7 -0
  145. package/dist-sdk/src/entities/relationship/pair-check.js +68 -0
  146. package/dist-sdk/src/entities/relationship/to-tf.d.ts +10 -0
  147. package/dist-sdk/src/entities/relationship/to-tf.js +31 -13
  148. package/dist-sdk/src/entities/search-table/module.js +1 -0
  149. package/dist-sdk/src/entities/search-table/to-tf.d.ts +1 -0
  150. package/dist-sdk/src/entities/search-table/to-tf.js +1 -1
  151. package/dist-sdk/src/entities/service-account/build.d.ts +15 -2
  152. package/dist-sdk/src/entities/service-account/from-tf.d.ts +2 -4
  153. package/dist-sdk/src/entities/service-account/from-tf.js +17 -5
  154. package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +56 -0
  155. package/dist-sdk/src/entities/service-account/role-fidelity.js +243 -0
  156. package/dist-sdk/src/entities/service-account/to-tf.d.ts +14 -0
  157. package/dist-sdk/src/entities/service-account/to-tf.js +17 -0
  158. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +1 -1
  159. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +5 -2
  160. package/dist-sdk/src/entities/shared/filters/ast.d.ts +15 -2
  161. package/dist-sdk/src/entities/shared/filters/index.d.ts +25 -2
  162. package/dist-sdk/src/entities/shared/filters/index.js +38 -5
  163. package/dist-sdk/src/entities/shared/filters/print.js +31 -3
  164. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +25 -3
  165. package/dist-sdk/src/entities/shared/filters/tf-codec.js +51 -15
  166. package/dist-sdk/src/entities/shared/filters/types.d.ts +22 -5
  167. package/dist-sdk/src/entities/shared/foreign-ref.d.ts +16 -0
  168. package/dist-sdk/src/entities/shared/foreign-ref.js +17 -1
  169. package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -9
  170. package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -5
  171. package/dist-sdk/src/entities/shared/types/field-types.js +4 -0
  172. package/dist-sdk/src/entities/skill/access-policy.d.ts +17 -0
  173. package/dist-sdk/src/entities/skill/access-policy.js +101 -0
  174. package/dist-sdk/src/entities/skill/build.d.ts +3 -0
  175. package/dist-sdk/src/entities/skill/build.js +3 -0
  176. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +4 -1
  177. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +23 -1
  178. package/dist-sdk/src/entities/skill/from-tf.d.ts +2 -0
  179. package/dist-sdk/src/entities/skill/from-tf.js +70 -22
  180. package/dist-sdk/src/entities/skill/index.d.ts +2 -0
  181. package/dist-sdk/src/entities/skill/index.js +1 -0
  182. package/dist-sdk/src/entities/skill/input-coverage.d.ts +7 -0
  183. package/dist-sdk/src/entities/skill/input-coverage.js +11 -0
  184. package/dist-sdk/src/entities/skill/module.js +1 -0
  185. package/dist-sdk/src/entities/skill/to-tf.d.ts +2 -2
  186. package/dist-sdk/src/entities/skill/to-tf.js +19 -6
  187. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
  188. package/dist-sdk/src/entities/skill-tool/from-tf.js +8 -2
  189. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -2
  190. package/dist-sdk/src/entities/skill-tool/to-tf.js +29 -6
  191. package/dist-sdk/src/entities/table/catalog.d.ts +14 -0
  192. package/dist-sdk/src/entities/table/catalog.js +66 -0
  193. package/dist-sdk/src/entities/table/module.js +2 -1
  194. package/dist-sdk/src/entities/table/to-tf.js +5 -5
  195. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +89 -0
  196. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +277 -0
  197. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +51 -0
  198. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +360 -0
  199. package/dist-sdk/src/entities/view/agent-view-layout.d.ts +151 -0
  200. package/dist-sdk/src/entities/view/agent-view-layout.js +21 -0
  201. package/dist-sdk/src/entities/view/from-tf.d.ts +6 -3
  202. package/dist-sdk/src/entities/view/from-tf.js +161 -14
  203. package/dist-sdk/src/entities/view/module.js +30 -3
  204. package/dist-sdk/src/entities/view/to-tf.d.ts +24 -2
  205. package/dist-sdk/src/entities/view/to-tf.js +95 -9
  206. package/dist-sdk/src/entities/view/types.d.ts +4 -15
  207. package/dist-sdk/src/entities/view/types.js +17 -15
  208. package/dist-sdk/src/entities/widget/build.d.ts +16 -1
  209. package/dist-sdk/src/entities/widget/build.js +11 -1
  210. package/dist-sdk/src/entities/widget/to-tf.js +36 -10
  211. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +38 -10
  212. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  213. package/dist-sdk/src/graph/index.d.ts +54 -0
  214. package/dist-sdk/src/graph/index.js +30 -0
  215. package/dist-sdk/src/graph/modules.js +2 -0
  216. package/dist-sdk/src/graph/types.d.ts +133 -2
  217. package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
  218. package/dist-sdk/src/internal/sdk-package.js +1 -0
  219. package/package.json +11 -1
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Captured from mobius `service_tasks` (2026-10-02), validated byte-for-byte
3
+ * against the live registry, and proven end-to-end on local (publish + 0-diff
4
+ * round-trip) for every affected task type. Hand-maintained: update it
5
+ * deliberately when the platform's task output contracts change.
6
+ * `canonical-reference-model.test.ts` locks the canonical output names +
7
+ * fieldTypes this fix emits against the forward/inverse rewrite maps, so a
8
+ * change here that breaks the mapping fails CI.
9
+ *
10
+ * Each entry is an executor's **referenceable** output contract — the canonical
11
+ * reference name → { fieldType, multiple } the platform validates against. This
12
+ * is the source of truth for a workflow output/task-input `taskReference.name`
13
+ * and its fieldType; EDK emits `{taskReference:{taskId,name:<canonical>},fieldType}`
14
+ * directly (no display labels). See DESIGN-canonical-reference-model.md.
15
+ *
16
+ * `executeScript` (script-runner-javascript) outputs beyond the base ones are
17
+ * author-declared via the task's `output_schema` (fieldType comes from there,
18
+ * canonical name is `result.<field>`); only the base outputs are listed here.
19
+ * createRecord/updateField also expose a `<relation-field-id>` ASPECT_REFERENCES
20
+ * output keyed by the field UUID — handled per-instance, not in this table.
21
+ */
22
+ export interface OutputContract {
23
+ readonly fieldType: string;
24
+ readonly multiple: boolean;
25
+ }
26
+ /** executor name (service_tasks.name) → canonical referenceable output → contract. */
27
+ export declare const TASK_OUTPUT_CONTRACTS: Readonly<Record<string, Readonly<Record<string, OutputContract>>>>;
28
+ /**
29
+ * EDK terraform resource type → service_tasks executor name, so to-tf/from-tf
30
+ * can look up a task's contract from its resource type. aiAgent has two
31
+ * executors (completion/run) with an identical contract.
32
+ */
33
+ export declare const RESOURCE_TYPE_TO_EXECUTOR: Readonly<Record<string, string>>;
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Captured from mobius `service_tasks` (2026-10-02), validated byte-for-byte
3
+ * against the live registry, and proven end-to-end on local (publish + 0-diff
4
+ * round-trip) for every affected task type. Hand-maintained: update it
5
+ * deliberately when the platform's task output contracts change.
6
+ * `canonical-reference-model.test.ts` locks the canonical output names +
7
+ * fieldTypes this fix emits against the forward/inverse rewrite maps, so a
8
+ * change here that breaks the mapping fails CI.
9
+ *
10
+ * Each entry is an executor's **referenceable** output contract — the canonical
11
+ * reference name → { fieldType, multiple } the platform validates against. This
12
+ * is the source of truth for a workflow output/task-input `taskReference.name`
13
+ * and its fieldType; EDK emits `{taskReference:{taskId,name:<canonical>},fieldType}`
14
+ * directly (no display labels). See DESIGN-canonical-reference-model.md.
15
+ *
16
+ * `executeScript` (script-runner-javascript) outputs beyond the base ones are
17
+ * author-declared via the task's `output_schema` (fieldType comes from there,
18
+ * canonical name is `result.<field>`); only the base outputs are listed here.
19
+ * createRecord/updateField also expose a `<relation-field-id>` ASPECT_REFERENCES
20
+ * output keyed by the field UUID — handled per-instance, not in this table.
21
+ */
22
+ /** executor name (service_tasks.name) → canonical referenceable output → contract. */
23
+ export const TASK_OUTPUT_CONTRACTS = {
24
+ ai_classify_completion: {
25
+ response: { fieldType: "TEXT", multiple: false },
26
+ reason: { fieldType: "TEXT", multiple: false },
27
+ success: { fieldType: "BOOLEAN", multiple: false },
28
+ },
29
+ ai_summarize_completion: {
30
+ response: { fieldType: "TEXT", multiple: false },
31
+ success: { fieldType: "BOOLEAN", multiple: false },
32
+ },
33
+ ai_transform_completion: {
34
+ response: { fieldType: "TEXT", multiple: false },
35
+ success: { fieldType: "BOOLEAN", multiple: false },
36
+ },
37
+ ai_search_table: {
38
+ firstFoundRecord: { fieldType: "AI_SEARCH_TABLE_RECORD", multiple: false },
39
+ firstFoundRecordJson: { fieldType: "JSON", multiple: false },
40
+ firstFoundRecordText: { fieldType: "TEXT", multiple: false },
41
+ searchTableRecords: { fieldType: "AI_SEARCH_TABLE_RECORD", multiple: true },
42
+ searchTableRecordsJson: { fieldType: "JSON", multiple: false },
43
+ searchTableRecordsText: { fieldType: "TEXT", multiple: false },
44
+ },
45
+ ai_file_analysis_completion: {
46
+ documentModel: { fieldType: "DOCUMENT_MODEL_RECORD", multiple: false },
47
+ success: { fieldType: "BOOLEAN", multiple: false },
48
+ },
49
+ ai_agent_completion: {
50
+ ai_agent_task_response: { fieldType: "TEXT", multiple: false },
51
+ ai_agent_task_status: { fieldType: "BOOLEAN", multiple: false },
52
+ ai_agent_task_error: { fieldType: "TEXT", multiple: false },
53
+ ai_agent_task_output_files: { fieldType: "ATTACHMENT", multiple: true },
54
+ ai_agent_task_structured_output: { fieldType: "OBJECT", multiple: false },
55
+ },
56
+ ai_agent_run: {
57
+ ai_agent_task_response: { fieldType: "TEXT", multiple: false },
58
+ ai_agent_task_status: { fieldType: "BOOLEAN", multiple: false },
59
+ ai_agent_task_error: { fieldType: "TEXT", multiple: false },
60
+ ai_agent_task_output_files: { fieldType: "ATTACHMENT", multiple: true },
61
+ ai_agent_task_structured_output: { fieldType: "OBJECT", multiple: false },
62
+ },
63
+ send_api_request: {
64
+ success: { fieldType: "BOOLEAN", multiple: false },
65
+ response: { fieldType: "OBJECT", multiple: false },
66
+ textResponse: { fieldType: "TEXT", multiple: false },
67
+ statusCode: { fieldType: "NUMBER", multiple: false },
68
+ file: { fieldType: "FILE", multiple: false },
69
+ contentType: { fieldType: "TEXT", multiple: false },
70
+ },
71
+ "script-runner-javascript": {
72
+ result: { fieldType: "JSON", multiple: false },
73
+ textResult: { fieldType: "TEXT", multiple: false },
74
+ stringArrayResult: { fieldType: "TEXT", multiple: true },
75
+ numberArrayResult: { fieldType: "NUMBER", multiple: true },
76
+ },
77
+ aspect_records_search: {
78
+ count: { fieldType: "NUMBER", multiple: false },
79
+ record: { fieldType: "ASPECT_RECORD", multiple: false },
80
+ recordId: { fieldType: "ASPECT_RECORD_ID", multiple: false },
81
+ recordIds: { fieldType: "ASPECT_RECORD_ID", multiple: true },
82
+ records: { fieldType: "ASPECT_RECORD", multiple: true },
83
+ resultTruncatedByLimit: { fieldType: "BOOLEAN", multiple: false },
84
+ },
85
+ table_records_search: {
86
+ count: { fieldType: "NUMBER", multiple: false },
87
+ metaData: { fieldType: "JSON", multiple: false },
88
+ record: { fieldType: "TABLE_RECORD", multiple: false },
89
+ records: { fieldType: "TABLE_RECORD", multiple: true },
90
+ tableId: { fieldType: "TABLE_ID", multiple: false },
91
+ },
92
+ find_related_records: {
93
+ record: { fieldType: "ASPECT_RECORD", multiple: false },
94
+ records: { fieldType: "ASPECT_RECORD", multiple: true },
95
+ // `fields` (ASPECT_FIELD_PROPERTY) is NOT referenceable — intentionally omitted.
96
+ },
97
+ create_aspect_record_and_relate: {
98
+ record: { fieldType: "ASPECT_RECORD", multiple: false },
99
+ recordId: { fieldType: "ASPECT_RECORD_ID", multiple: false },
100
+ },
101
+ update_aspect_field: {
102
+ record: { fieldType: "ASPECT_RECORD", multiple: false },
103
+ recordId: { fieldType: "ASPECT_RECORD_ID", multiple: false },
104
+ },
105
+ relate_aspect_records: {
106
+ SUCCESS: { fieldType: "BOOLEAN", multiple: false },
107
+ },
108
+ calculation: {
109
+ calculationOutputMap: { fieldType: "OBJECT", multiple: false },
110
+ },
111
+ execution_procedure: {
112
+ result: { fieldType: "OBJECT", multiple: false },
113
+ },
114
+ bulk_update_fields: {
115
+ recordsUpdated: { fieldType: "NUMBER", multiple: false },
116
+ allMatchingRecordsUpdated: { fieldType: "BOOLEAN", multiple: false },
117
+ },
118
+ document_model: {
119
+ documentModels: { fieldType: "DOCUMENT_MODEL_RECORD", multiple: true },
120
+ },
121
+ save_attachment: {
122
+ attachments: { fieldType: "ATTACHMENT", multiple: true },
123
+ },
124
+ unzip_file: {
125
+ files: { fieldType: "FILE", multiple: true },
126
+ firstFile: { fieldType: "FILE", multiple: false },
127
+ },
128
+ user_search: {
129
+ count: { fieldType: "NUMBER", multiple: false },
130
+ user: { fieldType: "USER", multiple: false },
131
+ // user.id / user.name / user.email are referenceable sub-field outputs
132
+ // (fieldTypes confirmed live 0-diff: user.id is USER_ID, the rest TEXT).
133
+ // user.managerName / user.managerEmail are NOT referenceable at publish —
134
+ // their canonical name was never captured live; omitted deliberately.
135
+ "user.id": { fieldType: "USER_ID", multiple: false },
136
+ "user.name": { fieldType: "TEXT", multiple: false },
137
+ "user.email": { fieldType: "TEXT", multiple: false },
138
+ users: { fieldType: "USER", multiple: true },
139
+ },
140
+ user_group_search: {
141
+ count: { fieldType: "NUMBER", multiple: false },
142
+ group: { fieldType: "GROUP", multiple: false },
143
+ // group.id / group.name are referenceable sub-field outputs (#1271's
144
+ // TASK_OUTPUT_REFERENCE_NAMES ID→group.id, Name→group.name). fieldTypes
145
+ // confirmed live 0-diff: group.id is GROUP_ID, group.name is TEXT.
146
+ "group.id": { fieldType: "GROUP_ID", multiple: false },
147
+ "group.name": { fieldType: "TEXT", multiple: false },
148
+ groups: { fieldType: "GROUP", multiple: true },
149
+ },
150
+ // Executors with NO referenceable outputs (no reference table needed):
151
+ // send_email, send_tagged_message, generate_notification_simple,
152
+ // add_watcher_to_record, lock_aspect_fields, create_approval_chain,
153
+ // run_automation (childExecutionId is not referenceable).
154
+ };
155
+ /**
156
+ * EDK terraform resource type → service_tasks executor name, so to-tf/from-tf
157
+ * can look up a task's contract from its resource type. aiAgent has two
158
+ * executors (completion/run) with an identical contract.
159
+ */
160
+ export const RESOURCE_TYPE_TO_EXECUTOR = {
161
+ elementum_ai_classify_task: "ai_classify_completion",
162
+ elementum_ai_summarize_task: "ai_summarize_completion",
163
+ elementum_ai_transform_task: "ai_transform_completion",
164
+ elementum_ai_search_table_task: "ai_search_table",
165
+ elementum_ai_file_read_task: "ai_file_analysis_completion",
166
+ elementum_ai_agent_task: "ai_agent_completion",
167
+ elementum_api_task: "send_api_request",
168
+ elementum_execute_script_task: "script-runner-javascript",
169
+ elementum_record_search_task: "aspect_records_search",
170
+ elementum_table_records_search_task: "table_records_search",
171
+ elementum_find_related_records_task: "find_related_records",
172
+ elementum_create_record_task: "create_aspect_record_and_relate",
173
+ elementum_update_field_task: "update_aspect_field",
174
+ elementum_relate_records_task: "relate_aspect_records",
175
+ elementum_calculation_task: "calculation",
176
+ elementum_procedure_task: "execution_procedure",
177
+ elementum_bulk_update_fields_task: "bulk_update_fields",
178
+ elementum_file_reader_task: "document_model",
179
+ elementum_save_attachment_task: "save_attachment",
180
+ elementum_unzip_file_task: "unzip_file",
181
+ elementum_user_search_task: "user_search",
182
+ elementum_user_group_search_task: "user_group_search",
183
+ };
@@ -15,8 +15,8 @@ export { AUTOMATION_RESOURCE_TYPES, AUTOMATION_TASK_TYPES, AUTOMATION_TRIGGER_TY
15
15
  * from v1's deploy-wired builder.
16
16
  */
17
17
  export * as filter from "../shared/filters/index.js";
18
- export { automationStatus, chainableTrigger, actions, automation, type ActionBuilder, type ActionChain, type ActionDef, type ActionOptions, type ActionSequenceDef, type ActionsStarted, type AutomationConfigured, type AutomationOptions, type AutomationStatus, type ForkJoinBranch, type ForkJoinBranchBuilder, type ForkJoinConfig, type ForEachBuilder, type ForEachConfig, type NestedActionBuilder, type NestedActionChain, type NestedActionContext, type OperatorChild, type SwitchCase, type SwitchCaseBuilder, type SwitchConfig, type TriggerChain, type TriggerDef, type TriggerParamMeta } from "./build.js";
18
+ export { automationStatus, chainableTrigger, actions, automation, type ActionBuilder, type ActionChain, type ActionDef, type ActionOptions, type ActionSequenceDef, type ActionsStarted, type AutomationConfigured, type AutomationOptions, type AutomationStatus, type ForkJoinBranch, type ForkJoinBranchBuilder, type ForkJoinConfig, type ForEachBuilder, type ForEachConfig, type ForEachScope, type LoopScope, type NestedActionBuilder, type NestedActionChain, type NestedActionContext, type OperatorChild, type SwitchCase, type SwitchCaseBuilder, type SwitchConfig, type TriggerChain, type TriggerDef, type TriggerParamMeta } from "./build.js";
19
19
  export { ScriptCodeError, scriptFile, type ScriptCodeFn, type ScriptFile, type ScriptInput } from "./script-code.js";
20
20
  export { workflowOutput, workflowOutputType, type WorkflowOutputDeclaration, type WorkflowOutputType, } from "./workflow-output.js";
21
- export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, assignGroup, assignUser, assignmentEngine, bulkExcel, calculation, createRecord, executeScript, findRelatedRecords, generateReport, initiateCall, initiateEmailConversation, notification, postComment, postTeamsMessage, procedure, readFile, recordFieldLocking, recordSearch, relateRecords, runAutomation, saveAttachment, sendEmail, sendSurvey, setVariable, tableRecordsSearch, unzip, updateField, userGroupSearch, userSearch, withFieldMappings, type AddWatcherOptions, type AiAgentAttachment, type AiAgentOptions, type AiAgentOutput, type AiAgentOutputField, type AiAgentOutputFieldType, type AiClassifyCategorySource, type AiClassifyOptions, type AiClassifyStaticCategory, type AiEmailAnalysisOptions, type AiFileAnalysisOptions, type AiSearchTableOptions, type AiSearchTableOutput, type AiSummarizeOptions, type AiTransformOptions, type ApiRequestHeader, type ApiRequestOptions, type ApprovalChainOptions, type ApprovalChainTemplateOptions, type ApprovalStatusUpdateOptions, type ApprovalStatusUpdateStatus, type AssignGroupOptions, type AssignUserOptions, type AssignmentEngineOptions, type BulkExcelFieldMapping, type BulkExcelFieldSource, type BulkExcelOptions, type CalculationEntry, type CalculationExpression, type CalculationInclude, type CalculationOptions, type CalculationOutputs, type CalculationValueInput, type CalculationValueOptions, type CalculationValueOutputs, type CalculationValues, type CreateRecordOptions, type CreateRecordOutput, type EmailAttachment, type ExecuteScriptFieldMapping, type ExecuteScriptOptions, type FieldAssignment, type FindRelatedRecordsOptions, type FindRelatedRecordsOutput, type GenerateReportOptions, type InitiateCallOptions, type InitiateEmailConversationOptions, type InitiateEmailFirstEmail, type LegacyCalculationOptions, type MultiSelectUpdateMode, type NotificationOptions, type PostCommentOptions, type PostTeamsMessageOptions, type LegacyProcedureOptions, type ProcedureOptions, type TypedProcedureOptions, type ReadFileDataSource, type ReadFileOptions, type RecordFieldLockingOptions, type RecordId, type RecordReference, type RecordSearchOptions, type RecordSearchOutput, type RelateRecordsOptions, type RunAutomationInput, type RunAutomationOptions, type SaveAttachmentOptions, type ScriptOutputProperties, type ScriptOutputScalarType, type ScriptOutputType, type ScriptOutputs, type SendEmailOptions, type SendSurveyOptions, type SetVariableOptions, type TableRecordsSearchOptions, type TableRecordsSearchOutput, type UnzipOptions, type UpdateFieldAssignment, type UpdateFieldOptions, type UserSearchOptions, type VariableAssign, type VariableDecl } from "./tasks.js";
21
+ export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, requiredSecret, assignGroup, assignUser, assignmentEngine, bulkExcel, calculation, createRecord, executeScript, findRelatedRecords, generateReport, initiateCall, initiateEmailConversation, notification, postComment, postTeamsMessage, procedure, readFile, recordFieldLocking, recordSearch, relateRecords, runAutomation, saveAttachment, sendEmail, sendSurvey, setVariable, tableRecordsSearch, unzip, updateField, userGroupSearch, userSearch, withFieldMappings, type AddWatcherOptions, type AiAgentAttachment, type AiAgentOptions, type AiAgentOutput, type AiAgentOutputField, type AiAgentOutputFieldType, type AiClassifyCategorySource, type AiClassifyOptions, type AiClassifyStaticCategory, type AiEmailAnalysisOptions, type AiFileAnalysisOptions, type AiSearchTableOptions, type AiSearchTableOutput, type AiSummarizeOptions, type AiTransformOptions, type ApiRequestHeader, type ApiRequestOptions, type ApprovalChainOptions, type RequiredSecret, type ApprovalChainTemplateOptions, type ApprovalStatusUpdateOptions, type ApprovalStatusUpdateStatus, type AssignGroupOptions, type AssignUserOptions, type AssignmentEngineOptions, type BulkExcelFieldMapping, type BulkExcelFieldSource, type BulkExcelOptions, type CalculationEntry, type CalculationExpression, type CalculationInclude, type CalculationOptions, type CalculationOutputs, type CalculationValueInput, type CalculationValueOptions, type CalculationValueOutputs, type CalculationValues, type CreateRecordOptions, type CreateRecordOutput, type EmailAttachment, type ExecuteScriptFieldMapping, type ExecuteScriptOptions, type FieldAssignment, type FindRelatedRecordsOptions, type FindRelatedRecordsOutput, type GenerateReportOptions, type InitiateCallOptions, type InitiateEmailConversationOptions, type InitiateEmailFirstEmail, type LegacyCalculationOptions, type MultiSelectUpdateMode, type NotificationOptions, type PostCommentOptions, type PostTeamsMessageOptions, type LegacyProcedureOptions, type ProcedureOptions, type TypedProcedureOptions, type ReadFileDataSource, type ReadFileOptions, type RecordFieldLockingOptions, type RecordId, type RecordReference, type RecordSearchOptions, type RecordSearchOutput, type RelateRecordsOptions, type RunAutomationInput, type RunAutomationOptions, type SaveAttachmentOptions, type ScriptOutputProperties, type ScriptOutputScalarType, type ScriptOutputType, type ScriptOutputs, type SendEmailOptions, type SendSurveyOptions, type SetVariableOptions, type TableRecordsSearchOptions, type TableRecordsSearchOutput, type UnzipOptions, type UpdateFieldAssignment, type UpdateFieldOptions, type UserGroupSearchOptions, type UserGroupSearchOutput, type UserGroupShape, type UserSearchOptions, type VariableAssign, type VariableDecl } from "./tasks.js";
22
22
  export { approvalProcessStatusUpdated, attachment, commentAdded, conversationEnd, dataMine, emailReceived, onDemand, recordCreated, recordUpdated, schedule, slackMessage, surveyResponseCreate, temporal, webHook, webhook, type AttachmentTriggerOptions, type AttachmentTriggerOutput, type CommentAddedTriggerOptions, type CommentAddedTriggerOutput, type ConversationEndConversationType, type ConversationEndTriggerOptions, type ConversationEndTriggerOutput, type DataMineTriggerOptions, type DataMineTriggerOutput, type EmailReceivedTriggerOptions, type EmailReceivedTriggerOutput, type RecordTriggerOptions, type RecordTriggerOutput, type ScheduleFrequency, type ScheduleTriggerOptions, type ScheduleTriggerOutput, type SlackMessageTriggerOutput, type SurveyResponseCreateTriggerOptions, type SurveyResponseCreateTriggerOutput, type TemporalTriggerOptions, type TemporalUnit, type WebhookTriggerOptions, type WebhookTriggerOutput, type Weekday, type approvalProcessStatusUpdatedStatus, type approvalProcessStatusUpdatedTriggerOptions } from "./triggers.js";
@@ -18,7 +18,7 @@ export * as filter from "../shared/filters/index.js";
18
18
  export { automationStatus, chainableTrigger, actions, automation } from "./build.js";
19
19
  export { ScriptCodeError, scriptFile } from "./script-code.js";
20
20
  export { workflowOutput, workflowOutputType, } from "./workflow-output.js";
21
- export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, assignGroup, assignUser, assignmentEngine, bulkExcel, calculation, createRecord, executeScript, findRelatedRecords, generateReport, initiateCall, initiateEmailConversation, notification, postComment, postTeamsMessage, procedure, readFile, recordFieldLocking, recordSearch, relateRecords, runAutomation, saveAttachment, sendEmail, sendSurvey, setVariable, tableRecordsSearch, unzip, updateField, userGroupSearch, userSearch, withFieldMappings } from "./tasks.js";
21
+ export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, requiredSecret, assignGroup, assignUser, assignmentEngine, bulkExcel, calculation, createRecord, executeScript, findRelatedRecords, generateReport, initiateCall, initiateEmailConversation, notification, postComment, postTeamsMessage, procedure, readFile, recordFieldLocking, recordSearch, relateRecords, runAutomation, saveAttachment, sendEmail, sendSurvey, setVariable, tableRecordsSearch, unzip, updateField, userGroupSearch, userSearch, withFieldMappings } from "./tasks.js";
22
22
  export { approvalProcessStatusUpdated, attachment, commentAdded, conversationEnd, dataMine, emailReceived, onDemand, recordCreated, recordUpdated, schedule, slackMessage, surveyResponseCreate, temporal, webHook, webhook } from "./triggers.js";
23
23
  // Pull a deployed automation back as editable v2 source. `automation`
24
24
  // is a plain factory returning a builder-chain object (not an Object.assign-able
@@ -1,3 +1,5 @@
1
1
  /** The automation entity's registry entry (see src/graph/). */
2
2
  import { type EntityKindModule } from "../../graph/types.js";
3
3
  export declare const automationModule: EntityKindModule;
4
+ /** The provider's `normalizeOnDemandFilterRefName`, which computes `filter_refs` at plan time. */
5
+ export declare function onDemandFilterRefName(name: string): string;
@@ -1,9 +1,11 @@
1
1
  /** The automation entity's registry entry (see src/graph/). */
2
2
  import { sanitizeName, tfLabelToTsLabel, isTfExpr } from "../../engine/tf/index.js";
3
3
  import { renderAutomationCatalogEntry } from "./catalog-render.js";
4
- import { preserveAuthoredAutomationPullMeta, printAutomationV2WithScriptFiles, SCRIPT_FILES_DIR } from "./deserializer/print-automation.js";
5
- import { automationFromTf, automationOwnedAddresses, UnsupportedMultiTriggerError } from "./from-tf.js";
4
+ import { hasUnresolvedForEachItem, preserveAuthoredAutomationPullMeta, printAutomationV2WithScriptFiles, SCRIPT_FILES_DIR } from "./deserializer/print-automation.js";
5
+ import { recordValidations } from "../../engine/validation.js";
6
+ import { automationFromTf, automationOwnedAddresses, ForEachItemOutsideLoopError, UnsupportedMultiTriggerError } from "./from-tf.js";
6
7
  import { scriptFileRefs } from "./script-code.js";
8
+ import { TASK_OUTPUT_REFERENCE_NAMES } from "./task-output-labels.js";
7
9
  import { automationToTf } from "./to-tf.js";
8
10
  import { ALL_AUTOMATION_SUB_TYPES, AUTOMATION_RESOURCE_TYPE, WORKFLOW_PUBLISH_RESOURCE_TYPE, } from "./types.js";
9
11
  function isConfigured(value) {
@@ -103,7 +105,9 @@ function registerForeignObjectIdDeps(doc, automationLabel, ctx) {
103
105
  function extractAutomations(ownBlocks, stream, ctx) {
104
106
  const items = [];
105
107
  const skipped = [];
108
+ const releaseIfManaged = [];
106
109
  const diagnostics = [];
110
+ const validations = [];
107
111
  const adoptionAddressAliases = [];
108
112
  for (const autoBlock of ownBlocks) {
109
113
  const autoLabel = autoBlock.label ?? "";
@@ -123,20 +127,41 @@ function extractAutomations(ownBlocks, stream, ctx) {
123
127
  diagnostics.push(...(extracted.diagnostics ?? []).map((diagnostic) => `${autoLabel}: ${diagnostic}`));
124
128
  }
125
129
  catch (err) {
126
- // Multi-trigger is unsupported, not an extract gap. Skipping it would
127
- // let `pull app` / `pull element` succeed without the automation.
128
- if (err instanceof UnsupportedMultiTriggerError)
129
- throw err;
130
+ // Multi-trigger is unsupported, not an extract gap. Collect every
131
+ // offender and keep going. The addresses still go through `skipped` so
132
+ // adoption will not import a graph that was not written, and the
133
+ // message stays out of `diagnostics` (those are warnings).
134
+ if (err instanceof UnsupportedMultiTriggerError) {
135
+ const failure = {
136
+ severity: "fatal",
137
+ address: `${AUTOMATION_RESOURCE_TYPE}.${autoLabel}`,
138
+ name: err.automationName,
139
+ ownerKind: "automation",
140
+ message: err.message,
141
+ };
142
+ validations.push(failure);
143
+ recordValidations([failure]);
144
+ skipped.push(...automationOwnedAddresses(doc, autoLabel));
145
+ continue;
146
+ }
130
147
  // Report the automation's FULL graph (trigger/tasks/branches/publish),
131
148
  // not just its root - otherwise those children's otherwise-adoptable
132
149
  // resource TYPES get imported into state anyway, and build (which
133
150
  // never wrote this automation to source) can't reproduce them, so
134
151
  // `plan` shows them as destroy-on-apply. See automationOwnedAddresses.
135
- skipped.push(...automationOwnedAddresses(doc, autoLabel));
152
+ const owned = automationOwnedAddresses(doc, autoLabel);
153
+ skipped.push(...owned);
154
+ // A sibling-loop item reference has no authored form at all, so an
155
+ // earlier pull's state binding can never be reproduced either: release
156
+ // it rather than let the next apply destroy the live automation (#1320).
157
+ // That skip is a diagnostic, not a validation fatal: the automation is
158
+ // not printed, so the build must not also report the placeholder.
159
+ if (err instanceof ForEachItemOutsideLoopError)
160
+ releaseIfManaged.push(...owned);
136
161
  diagnostics.push(`${autoLabel}: ${err instanceof Error ? err.message : String(err)}`);
137
162
  }
138
163
  }
139
- return { items, skipped, diagnostics, adoptionAddressAliases };
164
+ return { items, skipped, releaseIfManaged, diagnostics, validations, adoptionAddressAliases };
140
165
  }
141
166
  export const automationModule = {
142
167
  kind: "automation",
@@ -206,10 +231,15 @@ export const automationModule = {
206
231
  };
207
232
  },
208
233
  mergePulledSource: preserveAuthoredAutomationPullMeta,
234
+ isUnbuildablePulledSource: hasUnresolvedForEachItem,
209
235
  toTf: (entity, ctx) => automationToTf(entity, {
210
236
  appRefName: ctx.appRefName,
211
237
  appTfLabel: ctx.appTfLabel,
212
238
  parentScope: ctx.parentScope === "element" ? "element" : "app",
239
+ ...(ctx.streamRootEntity?.payload?.auditFields === true
240
+ ? { ownerAuditFields: true }
241
+ : {}),
242
+ ...(ctx.elementsWithoutAuditFields !== undefined ? { elementsWithoutAuditFields: ctx.elementsWithoutAuditFields } : {}),
213
243
  diagnostics: ctx.diagnostics,
214
244
  fieldAddresses: ctx.fieldAddresses ?? new Map(),
215
245
  fieldNames: ctx.fieldNames ?? new Map(),
@@ -237,4 +267,59 @@ export const automationModule = {
237
267
  stubRef: automationStubRef,
238
268
  refFromAuthoring: automationRefFromAuthoring,
239
269
  },
270
+ roundtrip: {
271
+ referenceAliases: [],
272
+ managedLookupAttributes: [{
273
+ lookupType: AUTOMATION_RESOURCE_TYPE,
274
+ attribute: "parameter_ids",
275
+ ownerType: "elementum_on_demand_trigger",
276
+ ownerReference: "automation",
277
+ }],
278
+ taskOutputReferenceNames: TASK_OUTPUT_REFERENCE_NAMES,
279
+ recordFieldOutputKeys: [{ nameAttribute: "name", ownerAttribute: "object_id" }],
280
+ computedReferenceMaps: [{
281
+ resourceType: "elementum_on_demand_trigger",
282
+ attribute: "filter_refs",
283
+ listAttribute: "parameters",
284
+ nameAttribute: "name",
285
+ value: (name) => `trigger.${onDemandFilterRefName(name)}`,
286
+ }],
287
+ exportedAttributeLocals: [{
288
+ resourceType: "elementum_variable_task",
289
+ attribute: "variable_id",
290
+ localPrefix: "edk_variable_id_",
291
+ }],
292
+ },
240
293
  };
294
+ /** The provider's `normalizeOnDemandFilterRefName`, which computes `filter_refs` at plan time. */
295
+ export function onDemandFilterRefName(name) {
296
+ const runes = [...name];
297
+ const isWordRune = (rune) => /^[\p{L}\p{Nd}]$/u.test(rune);
298
+ // Go's unicode.ToUpper/ToLower map one rune to one rune; JS case mapping
299
+ // can expand (ß → SS, İ → i + U+0307). An expanded upper case keeps the
300
+ // rune; an expanded lower case keeps its first rune (İ → i).
301
+ const toUpper = (rune) => {
302
+ const upper = rune.toUpperCase();
303
+ return [...upper].length === 1 ? upper : rune;
304
+ };
305
+ const toLower = (rune) => [...rune.toLowerCase()][0] ?? rune;
306
+ if (runes.length === 0)
307
+ return "";
308
+ if (runes.every(isWordRune))
309
+ return toLower(runes[0]) + runes.slice(1).join("");
310
+ let normalized = "";
311
+ let nextIsUpper = false;
312
+ for (const rune of runes) {
313
+ if (!isWordRune(rune)) {
314
+ nextIsUpper = true;
315
+ }
316
+ else if (nextIsUpper) {
317
+ normalized += toUpper(rune);
318
+ nextIsUpper = false;
319
+ }
320
+ else {
321
+ normalized += toLower(rune);
322
+ }
323
+ }
324
+ return normalized;
325
+ }
@@ -16,6 +16,13 @@ export declare function outputFieldTypesFromScriptSchema(schema: unknown): Map<s
16
16
  multiple: boolean;
17
17
  kind: string;
18
18
  }> | undefined;
19
+ /**
20
+ * Top-level output names the schema lists more than once, at both
21
+ * `result.<name>` and `<name>`. Such a name resolves to its first entry
22
+ * everywhere (see outputFieldTypesFromScriptSchema), so an exported
23
+ * envelope type taken from a later entry is not authored intent.
24
+ */
25
+ export declare function repeatedScriptOutputNames(schema: unknown): ReadonlySet<string>;
19
26
  /**
20
27
  * A nested result path belongs to its declared top-level object even when the
21
28
  * current schema projection does not yet model that object's item properties.
@@ -58,12 +58,19 @@ export function outputFieldTypesFromScriptSchema(schema) {
58
58
  : undefined;
59
59
  return fieldType === undefined ? undefined : { fieldType, multiple: false, kind };
60
60
  };
61
+ // A name the platform stores twice resolves to its FIRST entry, the same
62
+ // one from-tf's decoded `outputs` keeps, so pulled source, ref typing, and
63
+ // workflow-output inference never disagree about a repeated name.
64
+ const seen = new Set();
61
65
  for (const property of properties) {
62
66
  if (!isObject(property))
63
67
  continue;
64
68
  for (const body of Object.values(property)) {
65
69
  if (!isObject(body) || typeof body.name !== "string")
66
70
  continue;
71
+ if (seen.has(body.name))
72
+ continue;
73
+ seen.add(body.name);
67
74
  const resolved = nodeType(property);
68
75
  if (resolved === undefined)
69
76
  continue;
@@ -73,6 +80,35 @@ export function outputFieldTypesFromScriptSchema(schema) {
73
80
  }
74
81
  return out.size > 0 ? out : undefined;
75
82
  }
83
+ /**
84
+ * Top-level output names the schema lists more than once, at both
85
+ * `result.<name>` and `<name>`. Such a name resolves to its first entry
86
+ * everywhere (see outputFieldTypesFromScriptSchema), so an exported
87
+ * envelope type taken from a later entry is not authored intent.
88
+ */
89
+ export function repeatedScriptOutputNames(schema) {
90
+ const repeated = new Set();
91
+ if (!isObject(schema))
92
+ return repeated;
93
+ const objectNode = isObject(schema.object) ? schema.object : schema;
94
+ const properties = objectNode.properties;
95
+ if (!Array.isArray(properties))
96
+ return repeated;
97
+ const seen = new Set();
98
+ for (const property of properties) {
99
+ if (!isObject(property))
100
+ continue;
101
+ const body = Object.values(property)[0];
102
+ if (!isObject(body) || typeof body.name !== "string")
103
+ continue;
104
+ if (seen.has(body.name)) {
105
+ repeated.add(body.name);
106
+ repeated.add(`result.${body.name}`);
107
+ }
108
+ seen.add(body.name);
109
+ }
110
+ return repeated;
111
+ }
76
112
  /**
77
113
  * A nested result path belongs to its declared top-level object even when the
78
114
  * current schema projection does not yet model that object's item properties.
@@ -16,6 +16,15 @@
16
16
  * either side can never introduce a cycle.
17
17
  */
18
18
  export declare const OUTPUT_KEY_WIRE_NAME: Readonly<Record<string, string>>;
19
+ /**
20
+ * CANONICAL reference model: EDK's single-scalar `.output` accessor → the
21
+ * platform's CANONICAL output name (service_tasks), used for a workflow
22
+ * OUTPUT's `taskReference.name` (NOT the refs-map display label in
23
+ * {@link OUTPUT_KEY_WIRE_NAME}). The aiClassify/aiSummarize/aiTransform family's
24
+ * canonical output is `response`. See DESIGN-canonical-reference-model.md;
25
+ * validated against TASK_OUTPUT_CONTRACTS by canonical-reference-model.test.ts.
26
+ */
27
+ export declare const OUTPUT_KEY_CANONICAL: Readonly<Record<string, string>>;
19
28
  /**
20
29
  * Compares a raw wire segment against an {@link OUTPUT_KEY_WIRE_NAME} value.
21
30
  * The Title-Case wire name above is confirmed against each task's own
@@ -21,6 +21,19 @@ export const OUTPUT_KEY_WIRE_NAME = {
21
21
  aiClassify: "Response",
22
22
  documentModel: "text",
23
23
  };
24
+ /**
25
+ * CANONICAL reference model: EDK's single-scalar `.output` accessor → the
26
+ * platform's CANONICAL output name (service_tasks), used for a workflow
27
+ * OUTPUT's `taskReference.name` (NOT the refs-map display label in
28
+ * {@link OUTPUT_KEY_WIRE_NAME}). The aiClassify/aiSummarize/aiTransform family's
29
+ * canonical output is `response`. See DESIGN-canonical-reference-model.md;
30
+ * validated against TASK_OUTPUT_CONTRACTS by canonical-reference-model.test.ts.
31
+ */
32
+ export const OUTPUT_KEY_CANONICAL = {
33
+ aiSummarize: "response",
34
+ aiTransform: "response",
35
+ aiClassify: "response",
36
+ };
24
37
  /**
25
38
  * Compares a raw wire segment against an {@link OUTPUT_KEY_WIRE_NAME} value.
26
39
  * The Title-Case wire name above is confirmed against each task's own
@@ -39,6 +39,23 @@ export declare function readScriptFile(ref: ScriptFile): string;
39
39
  export declare class ScriptCodeError extends Error {
40
40
  constructor(message: string);
41
41
  }
42
+ /**
43
+ * The platform runs a script body as plain JavaScript, so TypeScript-only
44
+ * syntax (`const out: Record<string, string> = {}`, `x as T`, `value!`,
45
+ * `implements`) fails there at runtime. A body that parses as JavaScript,
46
+ * which includes every pulled script, is returned unchanged so it round-trips
47
+ * byte for byte (`f(a < b, c > (d))` stays two comparisons). One that parses
48
+ * only as TypeScript has its types erased by the TypeScript transpiler with an
49
+ * ESNext target, so no syntax is downleveled into helpers; one that parses as
50
+ * neither is refused. `label` names the script in errors. With
51
+ * `stripTypes: false` (script files, which must hold plain JavaScript)
52
+ * TypeScript syntax is refused instead of stripped.
53
+ */
54
+ export declare function toPlatformScriptBody(body: string, label: string, options?: {
55
+ readonly stripTypes?: boolean;
56
+ /** @internal Test seam for the optional runtime dependency. */
57
+ readonly loadTypeScript?: () => object | undefined;
58
+ }): string;
42
59
  /**
43
60
  * Extract the platform script body from an authored code function. Accepts the
44
61
  * shapes a transpiler emits for `(input) => …`: arrow with block body, arrow