@elementumai/edk 0.8.0-preview.11 → 0.8.1

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 (165) hide show
  1. package/README.md +378 -324
  2. package/dist-sdk/src/catalog/ai-provider-models.d.ts +30 -0
  3. package/dist-sdk/src/catalog/ai-provider-models.js +63 -0
  4. package/dist-sdk/src/catalog/factories.d.ts +56 -3
  5. package/dist-sdk/src/catalog/factories.js +65 -2
  6. package/dist-sdk/src/catalog/from-authoring.js +6 -1
  7. package/dist-sdk/src/catalog/index.d.ts +3 -2
  8. package/dist-sdk/src/catalog/index.js +3 -2
  9. package/dist-sdk/src/catalog/org.d.ts +1 -1
  10. package/dist-sdk/src/catalog/org.js +83 -6
  11. package/dist-sdk/src/catalog/render.d.ts +13 -1
  12. package/dist-sdk/src/catalog/render.js +21 -4
  13. package/dist-sdk/src/catalog/token.js +14 -0
  14. package/dist-sdk/src/catalog/types.d.ts +60 -3
  15. package/dist-sdk/src/catalog/types.js +3 -0
  16. package/dist-sdk/src/core/system-fields.d.ts +2 -0
  17. package/dist-sdk/src/core/system-fields.js +2 -0
  18. package/dist-sdk/src/core/types/ai-provider.d.ts +10 -23
  19. package/dist-sdk/src/core/types/ai-provider.js +1 -25
  20. package/dist-sdk/src/core/types/app.d.ts +20 -1
  21. package/dist-sdk/src/engine/build/context.d.ts +18 -0
  22. package/dist-sdk/src/engine/build/source-context.d.ts +45 -0
  23. package/dist-sdk/src/engine/build/source-context.js +23 -0
  24. package/dist-sdk/src/engine/pull/context.d.ts +15 -0
  25. package/dist-sdk/src/engine/pull/org.d.ts +10 -0
  26. package/dist-sdk/src/engine/pull/org.js +34 -4
  27. package/dist-sdk/src/engine/tf/index.d.ts +1 -1
  28. package/dist-sdk/src/engine/tf/index.js +1 -1
  29. package/dist-sdk/src/engine/tf/labels.d.ts +45 -0
  30. package/dist-sdk/src/engine/tf/labels.js +71 -0
  31. package/dist-sdk/src/entities/access-policy/build.d.ts +26 -0
  32. package/dist-sdk/src/entities/access-policy/build.js +7 -0
  33. package/dist-sdk/src/entities/access-policy/filter.d.ts +61 -0
  34. package/dist-sdk/src/entities/access-policy/filter.js +83 -0
  35. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +48 -0
  36. package/dist-sdk/src/entities/access-policy/from-tf.js +189 -0
  37. package/dist-sdk/src/entities/access-policy/module.d.ts +3 -0
  38. package/dist-sdk/src/entities/access-policy/module.js +17 -0
  39. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +36 -0
  40. package/dist-sdk/src/entities/access-policy/to-tf.js +149 -0
  41. package/dist-sdk/src/entities/access-policy/types.d.ts +4 -0
  42. package/dist-sdk/src/entities/access-policy/types.js +10 -0
  43. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +38 -3
  44. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +199 -32
  45. package/dist-sdk/src/entities/agent/from-tf.d.ts +18 -3
  46. package/dist-sdk/src/entities/agent/from-tf.js +135 -15
  47. package/dist-sdk/src/entities/agent/index.d.ts +1 -1
  48. package/dist-sdk/src/entities/agent/module.js +8 -2
  49. package/dist-sdk/src/entities/agent/to-tf.js +62 -10
  50. package/dist-sdk/src/entities/agent/tools.d.ts +88 -9
  51. package/dist-sdk/src/entities/agent/tools.js +46 -7
  52. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +51 -4
  53. package/dist-sdk/src/entities/agent-tool/from-tf.js +131 -35
  54. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +4 -2
  55. package/dist-sdk/src/entities/agent-tool/to-tf.js +103 -17
  56. package/dist-sdk/src/entities/agent-tool/types.d.ts +5 -4
  57. package/dist-sdk/src/entities/agent-tool/types.js +38 -6
  58. package/dist-sdk/src/entities/app/build.d.ts +63 -13
  59. package/dist-sdk/src/entities/app/build.js +48 -1
  60. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +3 -0
  61. package/dist-sdk/src/entities/app/from-tf.d.ts +1 -1
  62. package/dist-sdk/src/entities/app/from-tf.js +32 -15
  63. package/dist-sdk/src/entities/app/index.d.ts +4 -1
  64. package/dist-sdk/src/entities/app/index.js +2 -1
  65. package/dist-sdk/src/entities/app/module.js +9 -2
  66. package/dist-sdk/src/entities/app/to-tf.d.ts +5 -0
  67. package/dist-sdk/src/entities/app/to-tf.js +33 -4
  68. package/dist-sdk/src/entities/automation/build.d.ts +57 -13
  69. package/dist-sdk/src/entities/automation/build.js +48 -36
  70. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +25 -8
  71. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +16 -1
  72. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +179 -43
  73. package/dist-sdk/src/entities/automation/filter.d.ts +15 -3
  74. package/dist-sdk/src/entities/automation/filter.js +12 -2
  75. package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -27
  76. package/dist-sdk/src/entities/automation/from-tf.js +1229 -223
  77. package/dist-sdk/src/entities/automation/index.d.ts +4 -0
  78. package/dist-sdk/src/entities/automation/index.js +4 -0
  79. package/dist-sdk/src/entities/automation/module.js +29 -32
  80. package/dist-sdk/src/entities/automation/operators.d.ts +29 -2
  81. package/dist-sdk/src/entities/automation/operators.js +27 -1
  82. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +19 -0
  83. package/dist-sdk/src/entities/automation/output-key-wire-name.js +24 -0
  84. package/dist-sdk/src/entities/automation/script-code.d.ts +10 -21
  85. package/dist-sdk/src/entities/automation/script-code.js +272 -5
  86. package/dist-sdk/src/entities/automation/tasks.d.ts +125 -19
  87. package/dist-sdk/src/entities/automation/tasks.js +83 -15
  88. package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -29
  89. package/dist-sdk/src/entities/automation/to-tf.js +1134 -231
  90. package/dist-sdk/src/entities/automation/triggers.d.ts +9 -1
  91. package/dist-sdk/src/entities/automation/types.d.ts +29 -4
  92. package/dist-sdk/src/entities/automation/types.js +76 -46
  93. package/dist-sdk/src/entities/element/build.d.ts +23 -10
  94. package/dist-sdk/src/entities/element/build.js +1 -0
  95. package/dist-sdk/src/entities/element/from-tf.d.ts +1 -1
  96. package/dist-sdk/src/entities/element/from-tf.js +18 -3
  97. package/dist-sdk/src/entities/element/index.d.ts +4 -1
  98. package/dist-sdk/src/entities/element/index.js +2 -1
  99. package/dist-sdk/src/entities/element/module.js +3 -1
  100. package/dist-sdk/src/entities/element/to-tf.js +21 -3
  101. package/dist-sdk/src/entities/field/build.d.ts +56 -13
  102. package/dist-sdk/src/entities/field/build.js +10 -0
  103. package/dist-sdk/src/entities/field/calc/runtime.js +4 -0
  104. package/dist-sdk/src/entities/field/from-tf.d.ts +5 -3
  105. package/dist-sdk/src/entities/field/from-tf.js +118 -7
  106. package/dist-sdk/src/entities/field/module.js +3 -2
  107. package/dist-sdk/src/entities/field/to-tf.d.ts +27 -9
  108. package/dist-sdk/src/entities/field/to-tf.js +62 -17
  109. package/dist-sdk/src/entities/field/types.d.ts +26 -0
  110. package/dist-sdk/src/entities/field/types.js +34 -12
  111. package/dist-sdk/src/entities/file-reader/build.d.ts +108 -50
  112. package/dist-sdk/src/entities/file-reader/build.js +23 -23
  113. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.d.ts +6 -0
  114. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +109 -0
  115. package/dist-sdk/src/entities/file-reader/from-tf.d.ts +13 -0
  116. package/dist-sdk/src/entities/file-reader/from-tf.js +172 -0
  117. package/dist-sdk/src/entities/file-reader/index.d.ts +8 -3
  118. package/dist-sdk/src/entities/file-reader/index.js +7 -2
  119. package/dist-sdk/src/entities/file-reader/module.d.ts +3 -0
  120. package/dist-sdk/src/entities/file-reader/module.js +115 -0
  121. package/dist-sdk/src/entities/file-reader/to-tf.d.ts +14 -0
  122. package/dist-sdk/src/entities/file-reader/to-tf.js +84 -0
  123. package/dist-sdk/src/entities/file-reader/types.d.ts +32 -0
  124. package/dist-sdk/src/entities/file-reader/types.js +30 -0
  125. package/dist-sdk/src/entities/org/ai-provider.d.ts +13 -0
  126. package/dist-sdk/src/entities/org/ai-provider.js +46 -0
  127. package/dist-sdk/src/entities/org/connector.d.ts +8 -1
  128. package/dist-sdk/src/entities/org/connector.js +12 -14
  129. package/dist-sdk/src/entities/org/group.js +10 -1
  130. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  131. package/dist-sdk/src/entities/org/index.js +1 -0
  132. package/dist-sdk/src/entities/org/user.js +10 -1
  133. package/dist-sdk/src/entities/shared/filters/ast.d.ts +44 -9
  134. package/dist-sdk/src/entities/shared/filters/types.d.ts +1 -1
  135. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +17 -0
  136. package/dist-sdk/src/entities/shared/tool-field-ref.js +31 -0
  137. package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -1
  138. package/dist-sdk/src/entities/shared/types/field-types.js +9 -0
  139. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +19 -0
  140. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +36 -8
  141. package/dist-sdk/src/entities/skill/from-tf.js +4 -3
  142. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  143. package/dist-sdk/src/entities/skill/module.js +6 -1
  144. package/dist-sdk/src/entities/skill/to-tf.js +3 -2
  145. package/dist-sdk/src/entities/skill/tools.d.ts +25 -3
  146. package/dist-sdk/src/entities/skill/tools.js +17 -0
  147. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +15 -2
  148. package/dist-sdk/src/entities/skill-tool/from-tf.js +32 -11
  149. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -0
  150. package/dist-sdk/src/entities/skill-tool/to-tf.js +32 -9
  151. package/dist-sdk/src/entities/view/from-tf.d.ts +6 -2
  152. package/dist-sdk/src/entities/view/from-tf.js +11 -9
  153. package/dist-sdk/src/entities/view/to-tf.d.ts +9 -7
  154. package/dist-sdk/src/entities/view/to-tf.js +33 -18
  155. package/dist-sdk/src/entities/view/types.d.ts +1 -1
  156. package/dist-sdk/src/entities/view/types.js +1 -1
  157. package/dist-sdk/src/graph/deferred-catalog-render.d.ts +0 -5
  158. package/dist-sdk/src/graph/deferred-catalog-render.js +1 -20
  159. package/dist-sdk/src/graph/index.d.ts +8 -0
  160. package/dist-sdk/src/graph/index.js +13 -9
  161. package/dist-sdk/src/graph/modules.js +6 -1
  162. package/dist-sdk/src/graph/types.d.ts +77 -3
  163. package/package.json +42 -14
  164. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +0 -76
  165. package/dist-sdk/src/entities/automation/value-ref-tf.js +0 -190
@@ -1,190 +0,0 @@
1
- /**
2
- * Value-reference codec for the automation tf dialect.
3
- *
4
- * The compose wire carries refs as JSON envelopes ({triggerReference},
5
- * {taskReference}, {variableReference}, {templateReference}, {value}); ei's
6
- * HCL dialect carries them as `refs["…"]` RESOURCE EXPRESSIONS resolved at
7
- * apply — `elementum_on_demand_trigger.x.refs["STUDENT_NAME"]` — with plain
8
- * literals for static values and `${…}` interpolated strings for multi-part
9
- * templates (cmd/elementum/export/hcl_task.go convertToRefsSyntax). ei's
10
- * exporter falls back to embedding the raw JSON (with platform ids) when it
11
- * can't resolve a ref; that fallback is NOT reproduced here — build emits only
12
- * the id-free refs syntax, and pull reports the JSON fallback loudly instead
13
- * of guessing.
14
- *
15
- * refs-map KEY naming (provider sources):
16
- * - on_demand trigger: the DECLARED parameter name (the authored schema key;
17
- * the wire's triggerReference name is the Mobius-canonicalized form —
18
- * reverse-mapped here via the declared names).
19
- * - variable task: the variable_name (buildVariableTaskRefs).
20
- * - execute_script: "Result" for the whole result, "result.<prop>" per
21
- * output-schema property.
22
- */
23
- import { normalizeOnDemandParamKey } from "../../../pull/util.js";
24
- import { expr, isTfExpr, sanitizeName } from "../../engine/tf/index.js";
25
- import { AUTOMATION_SUB_TYPE_BY_RESOURCE, AUTOMATION_SUB_TYPE_BY_TYPE_KEY } from "./types.js";
26
- const VARIABLE_TASK_TYPE = AUTOMATION_SUB_TYPE_BY_TYPE_KEY.get("variable").resourceType;
27
- function refsExpr(type, label, key) {
28
- return expr.resourceAttr(type, label, ["refs", { index: key }]);
29
- }
30
- /** Wire ref envelope → tf attribute value (literal, refs expression, or template). */
31
- export function wireRefToTf(ref, ctx) {
32
- if (ref === null || typeof ref !== "object") {
33
- return typeof ref === "string" || typeof ref === "number" || typeof ref === "boolean"
34
- ? { value: ref }
35
- : { unsupported: `unrecognized value shape ${JSON.stringify(ref)}` };
36
- }
37
- const r = ref;
38
- if ("value" in r && Object.keys(r).length === 1) {
39
- const v = r["value"];
40
- if (typeof v === "string" || typeof v === "number" || typeof v === "boolean")
41
- return { value: v };
42
- return { unsupported: `static value of unsupported type ${JSON.stringify(v)}` };
43
- }
44
- const trig = r["triggerReference"];
45
- if (trig !== undefined && typeof trig?.name === "string") {
46
- // The wire carries the AUTHORED name verbatim (canonicalization dropped);
47
- // exact declared match wins. The canonical-form lookup remains only for
48
- // sources printed by the old printer, whose access paths were camelCased.
49
- const declared = ctx.paramNames.includes(trig.name)
50
- ? trig.name
51
- : (ctx.paramNames.find((p) => normalizeOnDemandParamKey(p) === trig.name) ?? trig.name);
52
- return { value: refsExpr(ctx.triggerType, ctx.autoLabel, declared) };
53
- }
54
- const task = r["taskReference"];
55
- if (task !== undefined && typeof task?.name === "string") {
56
- const refKey = task.taskRefKey ?? "";
57
- const type = ctx.taskType(refKey);
58
- if (type === undefined)
59
- return { unsupported: `taskReference to unknown/uncarried task "${refKey}"` };
60
- const key = task.name === "result" ? "Result" : task.name;
61
- if (key !== "Result" && !key.startsWith("result.")) {
62
- return { unsupported: `taskReference output "${task.name}" has no known refs-map key` };
63
- }
64
- if (key.startsWith("result.")) {
65
- // Per-property result refs exist ONLY when the script declares that
66
- // property in its output schema — otherwise the apply fails with
67
- // "Invalid index" on the refs map. Fail at build instead, with the fix.
68
- const prop = key.slice("result.".length);
69
- if (!ctx.taskResultProps(refKey).includes(prop)) {
70
- return {
71
- unsupported: `references result.${prop} of task "${refKey}", but that task declares no output schema for it — ` +
72
- `add outputs: { ${prop}: "text" } (or the right type) to its executeScript`,
73
- };
74
- }
75
- }
76
- return { value: refsExpr(type, `${ctx.autoLabel}_${sanitizeName(refKey)}`, key) };
77
- }
78
- const variable = r["variableReference"];
79
- if (variable !== undefined && typeof variable?.id === "string") {
80
- const target = ctx.variableById.get(variable.id);
81
- if (target === undefined)
82
- return { unsupported: `variableReference to an id not created in this workflow` };
83
- return {
84
- value: refsExpr(VARIABLE_TASK_TYPE, `${ctx.autoLabel}_${sanitizeName(target.taskRefKey)}`, target.varName),
85
- };
86
- }
87
- const template = r["templateReference"];
88
- if (template !== undefined && typeof template?.template === "string") {
89
- const params = template.parameters ?? [];
90
- // Single bare placeholder collapses to the ref itself (matches ei).
91
- if (template.template === "{{{p1}}}" && params.length === 1) {
92
- return wireRefToTf(params[0]?.value?.value, ctx);
93
- }
94
- const byName = new Map();
95
- for (const p of params) {
96
- if (typeof p?.value?.name === "string")
97
- byName.set(p.value.name, p.value.value);
98
- }
99
- const parts = [];
100
- let rest = template.template;
101
- const placeholder = /\{\{\{(\w+)\}\}\}/;
102
- for (;;) {
103
- const m = placeholder.exec(rest);
104
- if (m === null)
105
- break;
106
- if (m.index > 0)
107
- parts.push(rest.slice(0, m.index));
108
- const inner = wireRefToTf(byName.get(m[1]), ctx);
109
- if ("unsupported" in inner)
110
- return inner;
111
- if (isTfExpr(inner.value))
112
- parts.push(inner.value);
113
- else
114
- parts.push(String(inner.value));
115
- rest = rest.slice(m.index + m[0].length);
116
- }
117
- if (rest !== "")
118
- parts.push(rest);
119
- return { value: { $expr: "template", parts } };
120
- }
121
- return { unsupported: `unsupported reference kind: ${Object.keys(r).join(", ")}` };
122
- }
123
- /** Index the stamped variable ids in a finalized payload: id → {taskRefKey, varName}. */
124
- export function indexVariableIds(tasks) {
125
- const index = new Map();
126
- for (const t of tasks) {
127
- const variable = t.task?.["variable"];
128
- for (const c of variable?.create ?? []) {
129
- if (typeof c?.id === "string" && typeof c?.name === "string" && typeof t.refKey === "string") {
130
- index.set(c.id, { taskRefKey: t.refKey, varName: c.name });
131
- }
132
- }
133
- }
134
- return index;
135
- }
136
- function refKeyFromLabel(label, autoLabel) {
137
- return label.startsWith(`${autoLabel}_`) ? label.slice(autoLabel.length + 1) : label;
138
- }
139
- /** tf attribute value → printer AST node (inverse of wireRefToTf). */
140
- export function tfRefToAst(value, ctx) {
141
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
142
- // A raw JSON envelope means ei fell back past refs syntax (unresolvable
143
- // ref at export time) — report rather than round-trip platform ids.
144
- if (typeof value === "string" && value.startsWith('{"')) {
145
- return { unsupported: "ei exported a raw JSON value reference (refs-syntax fallback); not round-tripped" };
146
- }
147
- return { ast: value };
148
- }
149
- if (!isTfExpr(value))
150
- return { unsupported: `unrecognized tf value ${JSON.stringify(value)}` };
151
- if (value.$expr === "template") {
152
- const parts = [];
153
- for (const part of value.parts) {
154
- if (typeof part === "string") {
155
- parts.push(part);
156
- continue;
157
- }
158
- const inner = tfRefToAst(part, ctx);
159
- if ("unsupported" in inner)
160
- return inner;
161
- if (typeof inner.ast === "object")
162
- parts.push(inner.ast);
163
- else
164
- parts.push(String(inner.ast));
165
- }
166
- return { ast: { kind: "template", parts } };
167
- }
168
- if (value.$expr === "resource-attr" && value.path.length === 2 && value.path[0] === "refs") {
169
- const seg = value.path[1];
170
- const key = typeof seg === "object" ? seg.index : String(seg);
171
- const type = value.type;
172
- if (ctx.isTriggerType(type)) {
173
- // The refs key IS the declared parameter name — print it verbatim; the
174
- // printer emits bracket access when it isn't identifier-safe.
175
- return { ast: { kind: "triggerRef", path: [key] } };
176
- }
177
- const refKeyOf = (label) => ctx.refKeyByLabel.get(label) ?? refKeyFromLabel(label, ctx.autoLabel);
178
- if (type === VARIABLE_TASK_TYPE) {
179
- return {
180
- ast: { kind: "variableParamRef", varTask: refKeyOf(value.label), name: key },
181
- };
182
- }
183
- if (AUTOMATION_SUB_TYPE_BY_RESOURCE.has(type)) {
184
- const path = key === "Result" ? ["result"] : key.split(".");
185
- return { ast: { kind: "taskRef", task: refKeyOf(value.label), path } };
186
- }
187
- return { unsupported: `refs expression on unrecognized resource type ${type}` };
188
- }
189
- return { unsupported: `unsupported tf expression ${JSON.stringify(value).slice(0, 120)}` };
190
- }