@elementumai/edk 0.8.0-preview.11 → 0.8.2-alpha.5

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 (180) hide show
  1. package/README.md +510 -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 +83 -4
  6. package/dist-sdk/src/catalog/from-authoring.js +19 -2
  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 +134 -50
  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 +18 -0
  14. package/dist-sdk/src/catalog/types.d.ts +75 -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 +26 -1
  21. package/dist-sdk/src/engine/build/context.d.ts +58 -0
  22. package/dist-sdk/src/engine/build/context.js +11 -1
  23. package/dist-sdk/src/engine/build/source-context.d.ts +45 -0
  24. package/dist-sdk/src/engine/build/source-context.js +23 -0
  25. package/dist-sdk/src/engine/pull/context.d.ts +15 -0
  26. package/dist-sdk/src/engine/pull/org.d.ts +10 -0
  27. package/dist-sdk/src/engine/pull/org.js +34 -4
  28. package/dist-sdk/src/engine/tf/index.d.ts +2 -2
  29. package/dist-sdk/src/engine/tf/index.js +2 -2
  30. package/dist-sdk/src/engine/tf/labels.d.ts +54 -0
  31. package/dist-sdk/src/engine/tf/labels.js +75 -0
  32. package/dist-sdk/src/engine/tf/parse.d.ts +15 -0
  33. package/dist-sdk/src/engine/tf/parse.js +162 -0
  34. package/dist-sdk/src/entities/access-policy/build.d.ts +26 -0
  35. package/dist-sdk/src/entities/access-policy/build.js +7 -0
  36. package/dist-sdk/src/entities/access-policy/filter.d.ts +61 -0
  37. package/dist-sdk/src/entities/access-policy/filter.js +83 -0
  38. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +66 -0
  39. package/dist-sdk/src/entities/access-policy/from-tf.js +187 -0
  40. package/dist-sdk/src/entities/access-policy/module.d.ts +3 -0
  41. package/dist-sdk/src/entities/access-policy/module.js +17 -0
  42. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +43 -0
  43. package/dist-sdk/src/entities/access-policy/to-tf.js +164 -0
  44. package/dist-sdk/src/entities/access-policy/types.d.ts +4 -0
  45. package/dist-sdk/src/entities/access-policy/types.js +10 -0
  46. package/dist-sdk/src/entities/agent/build.d.ts +2 -0
  47. package/dist-sdk/src/entities/agent/build.js +1 -0
  48. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +38 -3
  49. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +257 -32
  50. package/dist-sdk/src/entities/agent/from-tf.d.ts +29 -9
  51. package/dist-sdk/src/entities/agent/from-tf.js +146 -19
  52. package/dist-sdk/src/entities/agent/index.d.ts +1 -1
  53. package/dist-sdk/src/entities/agent/module.js +14 -4
  54. package/dist-sdk/src/entities/agent/to-tf.d.ts +46 -1
  55. package/dist-sdk/src/entities/agent/to-tf.js +160 -14
  56. package/dist-sdk/src/entities/agent/tools.d.ts +88 -9
  57. package/dist-sdk/src/entities/agent/tools.js +46 -7
  58. package/dist-sdk/src/entities/agent-a2a-skill/from-tf.d.ts +17 -0
  59. package/dist-sdk/src/entities/agent-a2a-skill/from-tf.js +64 -0
  60. package/dist-sdk/src/entities/agent-a2a-skill/module.d.ts +4 -0
  61. package/dist-sdk/src/entities/agent-a2a-skill/module.js +14 -0
  62. package/dist-sdk/src/entities/agent-a2a-skill/to-tf.d.ts +40 -0
  63. package/dist-sdk/src/entities/agent-a2a-skill/to-tf.js +47 -0
  64. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +51 -4
  65. package/dist-sdk/src/entities/agent-tool/from-tf.js +131 -35
  66. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +11 -4
  67. package/dist-sdk/src/entities/agent-tool/to-tf.js +176 -30
  68. package/dist-sdk/src/entities/agent-tool/types.d.ts +5 -4
  69. package/dist-sdk/src/entities/agent-tool/types.js +38 -6
  70. package/dist-sdk/src/entities/app/build.d.ts +91 -13
  71. package/dist-sdk/src/entities/app/build.js +63 -5
  72. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +3 -0
  73. package/dist-sdk/src/entities/app/from-tf.d.ts +1 -1
  74. package/dist-sdk/src/entities/app/from-tf.js +32 -22
  75. package/dist-sdk/src/entities/app/index.d.ts +4 -1
  76. package/dist-sdk/src/entities/app/index.js +2 -1
  77. package/dist-sdk/src/entities/app/module.js +10 -2
  78. package/dist-sdk/src/entities/app/to-tf.d.ts +5 -0
  79. package/dist-sdk/src/entities/app/to-tf.js +45 -4
  80. package/dist-sdk/src/entities/automation/build.d.ts +57 -13
  81. package/dist-sdk/src/entities/automation/build.js +62 -42
  82. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +25 -8
  83. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +16 -1
  84. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +206 -47
  85. package/dist-sdk/src/entities/automation/filter.d.ts +37 -3
  86. package/dist-sdk/src/entities/automation/filter.js +54 -3
  87. package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -27
  88. package/dist-sdk/src/entities/automation/from-tf.js +1344 -222
  89. package/dist-sdk/src/entities/automation/index.d.ts +4 -0
  90. package/dist-sdk/src/entities/automation/index.js +4 -0
  91. package/dist-sdk/src/entities/automation/module.js +29 -32
  92. package/dist-sdk/src/entities/automation/operators.d.ts +29 -2
  93. package/dist-sdk/src/entities/automation/operators.js +27 -1
  94. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +19 -0
  95. package/dist-sdk/src/entities/automation/output-key-wire-name.js +24 -0
  96. package/dist-sdk/src/entities/automation/script-code.d.ts +10 -21
  97. package/dist-sdk/src/entities/automation/script-code.js +272 -5
  98. package/dist-sdk/src/entities/automation/tasks.d.ts +125 -19
  99. package/dist-sdk/src/entities/automation/tasks.js +83 -15
  100. package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -29
  101. package/dist-sdk/src/entities/automation/to-tf.js +1291 -230
  102. package/dist-sdk/src/entities/automation/triggers.d.ts +9 -1
  103. package/dist-sdk/src/entities/automation/types.d.ts +29 -4
  104. package/dist-sdk/src/entities/automation/types.js +76 -46
  105. package/dist-sdk/src/entities/element/build.d.ts +44 -13
  106. package/dist-sdk/src/entities/element/build.js +45 -3
  107. package/dist-sdk/src/entities/element/from-tf.d.ts +1 -1
  108. package/dist-sdk/src/entities/element/from-tf.js +28 -14
  109. package/dist-sdk/src/entities/element/index.d.ts +4 -1
  110. package/dist-sdk/src/entities/element/index.js +2 -1
  111. package/dist-sdk/src/entities/element/module.js +4 -1
  112. package/dist-sdk/src/entities/element/to-tf.js +26 -3
  113. package/dist-sdk/src/entities/field/build.d.ts +61 -14
  114. package/dist-sdk/src/entities/field/build.js +10 -0
  115. package/dist-sdk/src/entities/field/calc/runtime.js +4 -0
  116. package/dist-sdk/src/entities/field/from-tf.d.ts +5 -3
  117. package/dist-sdk/src/entities/field/from-tf.js +118 -7
  118. package/dist-sdk/src/entities/field/module.js +3 -2
  119. package/dist-sdk/src/entities/field/to-tf.d.ts +46 -11
  120. package/dist-sdk/src/entities/field/to-tf.js +166 -17
  121. package/dist-sdk/src/entities/field/types.d.ts +26 -0
  122. package/dist-sdk/src/entities/field/types.js +34 -12
  123. package/dist-sdk/src/entities/file-reader/build.d.ts +108 -50
  124. package/dist-sdk/src/entities/file-reader/build.js +23 -23
  125. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.d.ts +6 -0
  126. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +109 -0
  127. package/dist-sdk/src/entities/file-reader/from-tf.d.ts +13 -0
  128. package/dist-sdk/src/entities/file-reader/from-tf.js +172 -0
  129. package/dist-sdk/src/entities/file-reader/index.d.ts +8 -3
  130. package/dist-sdk/src/entities/file-reader/index.js +7 -2
  131. package/dist-sdk/src/entities/file-reader/module.d.ts +3 -0
  132. package/dist-sdk/src/entities/file-reader/module.js +115 -0
  133. package/dist-sdk/src/entities/file-reader/to-tf.d.ts +14 -0
  134. package/dist-sdk/src/entities/file-reader/to-tf.js +84 -0
  135. package/dist-sdk/src/entities/file-reader/types.d.ts +32 -0
  136. package/dist-sdk/src/entities/file-reader/types.js +30 -0
  137. package/dist-sdk/src/entities/org/ai-provider.d.ts +13 -0
  138. package/dist-sdk/src/entities/org/ai-provider.js +46 -0
  139. package/dist-sdk/src/entities/org/connector.d.ts +8 -1
  140. package/dist-sdk/src/entities/org/connector.js +12 -14
  141. package/dist-sdk/src/entities/org/group.js +10 -1
  142. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  143. package/dist-sdk/src/entities/org/index.js +1 -0
  144. package/dist-sdk/src/entities/org/user.js +10 -1
  145. package/dist-sdk/src/entities/shared/filters/ast.d.ts +59 -9
  146. package/dist-sdk/src/entities/shared/filters/types.d.ts +1 -1
  147. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +17 -0
  148. package/dist-sdk/src/entities/shared/tool-field-ref.js +46 -0
  149. package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -1
  150. package/dist-sdk/src/entities/shared/types/field-types.js +9 -0
  151. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +19 -0
  152. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +128 -11
  153. package/dist-sdk/src/entities/skill/from-tf.js +4 -3
  154. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  155. package/dist-sdk/src/entities/skill/module.js +7 -1
  156. package/dist-sdk/src/entities/skill/to-tf.d.ts +26 -0
  157. package/dist-sdk/src/entities/skill/to-tf.js +65 -4
  158. package/dist-sdk/src/entities/skill/tools.d.ts +37 -8
  159. package/dist-sdk/src/entities/skill/tools.js +43 -1
  160. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +34 -4
  161. package/dist-sdk/src/entities/skill-tool/from-tf.js +128 -18
  162. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +13 -1
  163. package/dist-sdk/src/entities/skill-tool/to-tf.js +164 -25
  164. package/dist-sdk/src/entities/skill-tool/types.d.ts +5 -7
  165. package/dist-sdk/src/entities/skill-tool/types.js +47 -11
  166. package/dist-sdk/src/entities/view/from-tf.d.ts +6 -2
  167. package/dist-sdk/src/entities/view/from-tf.js +11 -9
  168. package/dist-sdk/src/entities/view/to-tf.d.ts +9 -7
  169. package/dist-sdk/src/entities/view/to-tf.js +39 -18
  170. package/dist-sdk/src/entities/view/types.d.ts +1 -1
  171. package/dist-sdk/src/entities/view/types.js +1 -1
  172. package/dist-sdk/src/graph/deferred-catalog-render.d.ts +0 -5
  173. package/dist-sdk/src/graph/deferred-catalog-render.js +1 -20
  174. package/dist-sdk/src/graph/index.d.ts +8 -0
  175. package/dist-sdk/src/graph/index.js +13 -9
  176. package/dist-sdk/src/graph/modules.js +8 -1
  177. package/dist-sdk/src/graph/types.d.ts +98 -4
  178. package/package.json +49 -16
  179. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +0 -76
  180. package/dist-sdk/src/entities/automation/value-ref-tf.js +0 -190
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Access-policy emission (#69): one authored `accessPolicies[]` entry → one
3
+ * `elementum_access_policy` resource block, in ei's dialect. The owning
4
+ * app/element's to-tf drives the pass and supplies the `object_id`
5
+ * back-reference — this module never names the owner's resource type.
6
+ *
7
+ * Label: apps use `AppChildResourceName` (`apps_<ns>_<ns>_access_policy`);
8
+ * elements use ei's actual export label (`<ns>_access_policy`) — NOT
9
+ * `ElementChildResourceName` (`elements_<ns>_<ns>_access_policy`). ei's
10
+ * element access-policy import/HCL path never took the scoped prefix
11
+ * other element children (fields, list views) use. First entry has no
12
+ * suffix; later ones are `_1`, `_2`, … (0-indexed, matching ei).
13
+ *
14
+ * This pass emits authored entries only. Creating an app/element has a
15
+ * platform side-effect: it mints an extra policy for the creating user
16
+ * (`user_ids = [you]`, typically `filter = { type = "true" }`) that is not
17
+ * in `accessPolicies[]` and must not be synthesized here. Pull sees it;
18
+ * the integration harness strips it for fidelity against authored fixtures.
19
+ */
20
+ import type { OrgRefLookup } from "../../engine/build/context.js";
21
+ import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
22
+ export interface AccessPolicyToTfContext {
23
+ readonly ownerTfLabel: string;
24
+ readonly scope: ChildResourceScope;
25
+ /** The owner's id reference, e.g. `elementum_app.<ns>.id` — computed by the owner's to-tf. */
26
+ readonly objectId: TfValue;
27
+ readonly orgRefs: OrgRefLookup;
28
+ readonly diagnostics: string[];
29
+ }
30
+ export interface AccessPolicyToTfResult {
31
+ readonly block: TfBlock;
32
+ readonly address: string;
33
+ }
34
+ /** Authored filter shape — a plain wire-like object produced by `filter.ts`'s helpers (never hand-built by callers). */
35
+ export type AccessPolicyFilterInput = Record<string, unknown>;
36
+ export interface AccessPolicyEntryWire {
37
+ readonly filter?: AccessPolicyFilterInput;
38
+ readonly userIds?: readonly unknown[];
39
+ readonly groupIds?: readonly unknown[];
40
+ readonly serviceAccountIds?: readonly string[];
41
+ }
42
+ /** One authored access-policy entry → its resource block, positioned by `index` (0-based) for label numbering. */
43
+ export declare function accessPolicyToTf(entry: AccessPolicyEntryWire, index: number, ctx: AccessPolicyToTfContext): AccessPolicyToTfResult;
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Access-policy emission (#69): one authored `accessPolicies[]` entry → one
3
+ * `elementum_access_policy` resource block, in ei's dialect. The owning
4
+ * app/element's to-tf drives the pass and supplies the `object_id`
5
+ * back-reference — this module never names the owner's resource type.
6
+ *
7
+ * Label: apps use `AppChildResourceName` (`apps_<ns>_<ns>_access_policy`);
8
+ * elements use ei's actual export label (`<ns>_access_policy`) — NOT
9
+ * `ElementChildResourceName` (`elements_<ns>_<ns>_access_policy`). ei's
10
+ * element access-policy import/HCL path never took the scoped prefix
11
+ * other element children (fields, list views) use. First entry has no
12
+ * suffix; later ones are `_1`, `_2`, … (0-indexed, matching ei).
13
+ *
14
+ * This pass emits authored entries only. Creating an app/element has a
15
+ * platform side-effect: it mints an extra policy for the creating user
16
+ * (`user_ids = [you]`, typically `filter = { type = "true" }`) that is not
17
+ * in `accessPolicies[]` and must not be synthesized here. Pull sees it;
18
+ * the integration harness strips it for fidelity against authored fixtures.
19
+ */
20
+ import { EntityTfError } from "../../engine/entity.js";
21
+ import { expr, scopedResourceLabel } from "../../engine/tf/index.js";
22
+ import { fieldRefToTfValue } from "../field/to-tf.js";
23
+ import { ACCESS_POLICY_RESOURCE_TYPE } from "./types.js";
24
+ function isFieldToken(v) {
25
+ return typeof v === "object" && v !== null && v.__kind === "field";
26
+ }
27
+ function fieldValueToTf(token, where, ctx) {
28
+ const refName = token.refName ?? "";
29
+ const value = fieldRefToTfValue(token.fieldType ?? "", refName, ctx.ownerTfLabel, ctx.scope);
30
+ if (value === undefined) {
31
+ throw new EntityTfError(`${where}: field token "${refName}" has no terraform field resource mapping`);
32
+ }
33
+ return value;
34
+ }
35
+ /** Resolve a PICKLIST/STATUS-field-typed string against its options-by-label local, if the field carries picklist metadata. */
36
+ function picklistLiteralToTf(literal, field, ctx) {
37
+ if (field?.options === undefined || !field.options.includes(literal))
38
+ return undefined;
39
+ const localName = field.tags?.includes("STATUS")
40
+ ? `${ctx.ownerTfLabel}_status_options_by_label`
41
+ : field.tags?.includes("STAGE")
42
+ ? `${ctx.ownerTfLabel}_stage_options_by_label`
43
+ : undefined;
44
+ // Non-status/stage picklists: the field's own options-by-label local, keyed
45
+ // by its scoped resource label — same derivation fieldToTf's options pass uses.
46
+ const resolvedLocalName = localName ?? `${scopedResourceLabel(ctx.ownerTfLabel, field?.refName ?? "", ctx.scope)}_options_by_label`;
47
+ return expr.local(resolvedLocalName, [{ index: literal }]);
48
+ }
49
+ /**
50
+ * Encode one `FilterAst` (authored via `entities/access-policy/filter.ts`'s
51
+ * `eq`/`and`/… helpers). Coverage matches automation's own `filterToTf` —
52
+ * the only proven, working filter-grammar round-trip in this codebase —
53
+ * minus the trigger/task `leftValue` branch, which cannot occur here.
54
+ */
55
+ function filterToTf(f, where, ctx) {
56
+ if (typeof f !== "object" || f === null || typeof f.type !== "string") {
57
+ throw new EntityTfError(`${where}: invalid filter`);
58
+ }
59
+ const raw = f;
60
+ const type = raw.type.toLowerCase();
61
+ const result = { type };
62
+ const field = isFieldToken(raw.field) ? raw.field : undefined;
63
+ if (field !== undefined)
64
+ result.field_id = fieldValueToTf(field, where, ctx);
65
+ if (Array.isArray(raw.children)) {
66
+ result.children = raw.children.map((child) => filterToTf(child, where, ctx));
67
+ }
68
+ if (raw.value !== undefined)
69
+ result.value = literalValueToTf(raw.value, field, where, ctx);
70
+ if (Array.isArray(raw.values)) {
71
+ result.values = raw.values.map((item) => literalValueToTf(item, field, where, ctx));
72
+ }
73
+ if (typeof raw.not === "boolean")
74
+ result.not = raw.not;
75
+ if (typeof raw.caseInsensitive === "boolean")
76
+ result.case_insensitive = raw.caseInsensitive;
77
+ if (typeof raw.mode === "string")
78
+ result.mode = raw.mode;
79
+ if (result.type === "like" && result.mode === undefined)
80
+ result.mode = "legacy";
81
+ return result;
82
+ }
83
+ /** The wire `Value` shape (`{type, value?}`) `filter.ts`'s `eq`/`isIn`/etc. embed at `value`/`values[]`. */
84
+ function literalValueToTf(raw, field, where, ctx) {
85
+ if (typeof raw !== "object" || raw === null || typeof raw.type !== "string") {
86
+ throw new EntityTfError(`${where}: invalid filter value`);
87
+ }
88
+ const rec = raw;
89
+ const type = rec.type.toLowerCase();
90
+ if (type === "null")
91
+ return { type: "NULL" };
92
+ if (type === "current_user")
93
+ return { type: "CURRENT_USER", current_user_type: rec.currentUserType };
94
+ if (type === "field")
95
+ return fieldValueToTf(rec.value, where, ctx);
96
+ if (type === "text" && typeof rec.value === "string") {
97
+ const picklist = picklistLiteralToTf(rec.value, field, ctx);
98
+ return picklist ?? { type: "TEXT", value: rec.value };
99
+ }
100
+ return { type: type.toUpperCase(), value: rec.value };
101
+ }
102
+ function isOrgPrincipalRef(v) {
103
+ return typeof v === "object" && v !== null && v.__kind === "orgPrincipalRef";
104
+ }
105
+ function isGroupToken(v) {
106
+ return typeof v === "object" && v !== null && v.__kind === "group";
107
+ }
108
+ function principalListToTf(items, dataType, where, ctx) {
109
+ if (items === undefined || items.length === 0)
110
+ return undefined;
111
+ const values = [];
112
+ for (const item of items) {
113
+ if (isOrgPrincipalRef(item)) {
114
+ ctx.orgRefs.rawLookup(item.dataType, item.label, item.value);
115
+ values.push(expr.dataAttr(item.dataType, item.label, ["id"]));
116
+ }
117
+ else if (dataType === "elementum_group" && isGroupToken(item)) {
118
+ const resolved = ctx.orgRefs.byTsLabel("groups", item.refName ?? "");
119
+ if (resolved === undefined) {
120
+ ctx.diagnostics.push(`${where}: group token "${item.refName}" is not in the org catalog — re-run \`elementum pull org --data-only\``);
121
+ }
122
+ else {
123
+ values.push(expr.dataAttr("elementum_group", resolved.tfLabel, ["id"]));
124
+ }
125
+ }
126
+ else if (typeof item === "string") {
127
+ values.push(item);
128
+ }
129
+ else {
130
+ ctx.diagnostics.push(`${where}: ${dataType} list item has an unrecognized shape; dropped`);
131
+ }
132
+ }
133
+ return values.length > 0 ? values : undefined;
134
+ }
135
+ function accessPolicyTfLabel(ownerTfLabel, index, scope) {
136
+ const childPart = index === 0 ? "access_policy" : `access_policy_${index}`;
137
+ // ei element export: ElementResourceName + "_access_policy" (imports.go
138
+ // `prefix + "_access_policy"`, hcl_access_policy.go FallbackBaseName).
139
+ if (scope === "element")
140
+ return `${ownerTfLabel}_${childPart}`;
141
+ return scopedResourceLabel(ownerTfLabel, childPart, scope);
142
+ }
143
+ /** One authored access-policy entry → its resource block, positioned by `index` (0-based) for label numbering. */
144
+ export function accessPolicyToTf(entry, index, ctx) {
145
+ const label = accessPolicyTfLabel(ctx.ownerTfLabel, index, ctx.scope);
146
+ const where = `accessPolicies[${index}]`;
147
+ const attrs = {
148
+ object_id: ctx.objectId,
149
+ filter: entry.filter !== undefined ? filterToTf(entry.filter, where, ctx) : { type: "true" },
150
+ };
151
+ const userIds = principalListToTf(entry.userIds, "elementum_user", `${where}.userIds`, ctx);
152
+ if (userIds !== undefined)
153
+ attrs["user_ids"] = userIds;
154
+ const groupIds = principalListToTf(entry.groupIds, "elementum_group", `${where}.groupIds`, ctx);
155
+ if (groupIds !== undefined)
156
+ attrs["group_ids"] = groupIds;
157
+ if (entry.serviceAccountIds !== undefined && entry.serviceAccountIds.length > 0) {
158
+ attrs["service_account_ids"] = [...entry.serviceAccountIds];
159
+ }
160
+ return {
161
+ block: { kind: "resource", type: ACCESS_POLICY_RESOURCE_TYPE, label, attrs },
162
+ address: `${ACCESS_POLICY_RESOURCE_TYPE}.${label}`,
163
+ };
164
+ }
@@ -0,0 +1,4 @@
1
+ /** The access-policy entity's resource-type constant (see src/graph/). */
2
+ export declare const ACCESS_POLICY_RESOURCE_TYPE: "elementum_access_policy";
3
+ /** Attributes `accessPolicyFromTf` understands — anything else is dialect growth, reported loudly. */
4
+ export declare const KNOWN_ACCESS_POLICY_ATTRS: ReadonlySet<string>;
@@ -0,0 +1,10 @@
1
+ /** The access-policy entity's resource-type constant (see src/graph/). */
2
+ export const ACCESS_POLICY_RESOURCE_TYPE = "elementum_access_policy";
3
+ /** Attributes `accessPolicyFromTf` understands — anything else is dialect growth, reported loudly. */
4
+ export const KNOWN_ACCESS_POLICY_ATTRS = new Set([
5
+ "object_id",
6
+ "filter",
7
+ "user_ids",
8
+ "group_ids",
9
+ "service_account_ids",
10
+ ]);
@@ -70,6 +70,8 @@ export interface AgentV2Options extends EntityDeployOptions {
70
70
  readonly runAs?: AgentToolRunAs;
71
71
  readonly startingActions?: readonly Record<string, unknown>[];
72
72
  readonly a2aStreaming?: boolean;
73
+ /** Enable A2A record creation — when set, allows A2A conversations to create records through this agent. */
74
+ readonly a2aCreateRecordEnabled?: boolean;
73
75
  readonly conversationIdleTimeout?: string;
74
76
  readonly skillAccess?: SkillAccess;
75
77
  readonly agentAuthentication?: AgentAuthentication;
@@ -113,6 +113,7 @@ export function defineAgent(opts) {
113
113
  ...(opts.runAs !== undefined ? { runAs: opts.runAs } : {}),
114
114
  ...(opts.startingActions !== undefined ? { startingActions: opts.startingActions } : {}),
115
115
  ...(opts.a2aStreaming !== undefined ? { a2aStreaming: opts.a2aStreaming } : {}),
116
+ ...(opts.a2aCreateRecordEnabled !== undefined ? { a2aCreateRecordEnabled: opts.a2aCreateRecordEnabled } : {}),
116
117
  ...(opts.conversationIdleTimeout !== undefined
117
118
  ? { conversationIdleTimeout: opts.conversationIdleTimeout }
118
119
  : {}),
@@ -2,7 +2,9 @@
2
2
  * printAgentV2 — pulled agent rendering for the terraform path (M3).
3
3
  * Consumes the `NormalizedAgent` that `agentFromTf` produces and emits an
4
4
  * `apps/<app>/agents/<refName>.ts` authoring file: `defineAgent` with the
5
- * connector as an `org.connectors` token, tool targets as `catalog` tokens
5
+ * connector as a `catalog.aiProviders.<provider>.models.<model>` token (the
6
+ * generated org-root barrel re-exports `org.aiProviders`, so this file needs
7
+ * no separate relative `org.js` import), tool targets as `catalog` tokens
6
8
  * (self-app) or a TODO literal (foreign apps — their catalog may not exist
7
9
  * in this workspace), and tool fields as `catalog.<app>.fields.<key>`.
8
10
  *
@@ -12,7 +14,40 @@ import type { NormalizedAgent } from "../from-tf.js";
12
14
  export interface PrintAgentV2Options {
13
15
  /** The owning app's refName — `parent:` and the catalog token root. */
14
16
  readonly appRefName: string;
15
- /** Module specifier for the workspace org bags (e.g. "../../../org.js"). */
16
- readonly orgImportPath: string;
17
+ /**
18
+ * Set for a cross-org clone: the connector and any foreign-app tool
19
+ * target were resolved against the SOURCE org, so — absent a same-name
20
+ * match in {@link destinationConnectorKeys} — they're flagged as TODOs
21
+ * for manual review instead of printed as resolved references.
22
+ */
23
+ readonly crossOrg?: boolean;
24
+ /**
25
+ * The destination org's connector compound keys (`"<provider>.<model>"`,
26
+ * cross-org only). When the source's `connectorKey` is a member, that
27
+ * means the destination org ALSO has that provider/model pair (keys are
28
+ * name-derived, see `src/engine/tf/labels.ts`) — printed as a resolved
29
+ * reference instead of a TODO.
30
+ */
31
+ readonly destinationConnectorKeys?: ReadonlySet<string>;
32
+ /**
33
+ * A destination-org connector compound key (`"<provider>.<model>"`) the
34
+ * caller already confirmed (e.g. `edk clone app --target-root` prompting
35
+ * the user interactively when the source connector — or the absence of
36
+ * one — has no automatic match). When set, takes priority over both the
37
+ * TODO paths below — printed directly, uncommented.
38
+ */
39
+ readonly connectorKeyOverride?: string;
40
+ /**
41
+ * Name → refName for every app already on disk in this workspace (board
42
+ * issue #40). A `foreignApp` tool target whose name is a key here prints
43
+ * `catalog.<refName>` instead of the always-safe literal stub.
44
+ */
45
+ readonly foreignAppRefNames?: ReadonlyMap<string, string>;
46
+ /**
47
+ * Name → refName for every element already on disk in this workspace
48
+ * (board issue #42/#40). A `foreignElement` tool target whose name is a
49
+ * key here prints `catalog.<refName>` instead of the literal stub.
50
+ */
51
+ readonly foreignElementRefNames?: ReadonlyMap<string, string>;
17
52
  }
18
53
  export declare function printAgentV2(agent: NormalizedAgent, opts: PrintAgentV2Options): string;