@elementumai/edk 0.10.4 → 0.12.0

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 (171) hide show
  1. package/README.md +49 -13
  2. package/dist-sdk/src/catalog/token.js +2 -1
  3. package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -0
  4. package/dist-sdk/src/core/triggers/on-demand.js +3 -0
  5. package/dist-sdk/src/core/wire/ref-serializer.js +26 -1
  6. package/dist-sdk/src/engine/build/context.d.ts +4 -0
  7. package/dist-sdk/src/engine/coverage-gaps.d.ts +7 -0
  8. package/dist-sdk/src/engine/coverage-gaps.js +12 -0
  9. package/dist-sdk/src/engine/ei/json-stream-reader.d.ts +43 -0
  10. package/dist-sdk/src/engine/ei/json-stream-reader.js +234 -0
  11. package/dist-sdk/src/engine/ei/run.d.ts +42 -1
  12. package/dist-sdk/src/engine/ei/run.js +201 -32
  13. package/dist-sdk/src/engine/ei/saved-plan.d.ts +16 -0
  14. package/dist-sdk/src/engine/ei/saved-plan.js +19 -0
  15. package/dist-sdk/src/engine/ei/state.d.ts +1 -1
  16. package/dist-sdk/src/engine/ei/state.js +17 -4
  17. package/dist-sdk/src/engine/progress.d.ts +3 -1
  18. package/dist-sdk/src/engine/progress.js +7 -3
  19. package/dist-sdk/src/engine/pull/authored-address.d.ts +15 -1
  20. package/dist-sdk/src/engine/pull/authored-address.js +180 -29
  21. package/dist-sdk/src/engine/pull/context.d.ts +37 -2
  22. package/dist-sdk/src/engine/pull/context.js +7 -4
  23. package/dist-sdk/src/engine/pull/ref-only.d.ts +18 -0
  24. package/dist-sdk/src/engine/pull/ref-only.js +52 -0
  25. package/dist-sdk/src/engine/tf/index.d.ts +2 -2
  26. package/dist-sdk/src/engine/tf/index.js +2 -2
  27. package/dist-sdk/src/engine/tf/labels.d.ts +22 -0
  28. package/dist-sdk/src/engine/tf/labels.js +50 -0
  29. package/dist-sdk/src/engine/tf/model.d.ts +2 -0
  30. package/dist-sdk/src/engine/tf/model.js +26 -0
  31. package/dist-sdk/src/engine/validation.d.ts +2 -0
  32. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +18 -0
  33. package/dist-sdk/src/entities/access-policy/from-tf.js +58 -24
  34. package/dist-sdk/src/entities/access-policy/member-list.d.ts +32 -0
  35. package/dist-sdk/src/entities/access-policy/member-list.js +57 -0
  36. package/dist-sdk/src/entities/access-policy/module.js +10 -0
  37. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +4 -3
  38. package/dist-sdk/src/entities/access-policy/to-tf.js +21 -12
  39. package/dist-sdk/src/entities/agent/build.js +7 -5
  40. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +2 -0
  41. package/dist-sdk/src/entities/agent/from-tf.js +13 -3
  42. package/dist-sdk/src/entities/agent/to-tf.js +11 -5
  43. package/dist-sdk/src/entities/agent/tools.d.ts +8 -0
  44. package/dist-sdk/src/entities/agent/tools.js +6 -2
  45. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
  46. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +29 -0
  47. package/dist-sdk/src/entities/agent-tool/to-tf.js +56 -3
  48. package/dist-sdk/src/entities/agent-tool/types.d.ts +12 -8
  49. package/dist-sdk/src/entities/agent-tool/types.js +13 -9
  50. package/dist-sdk/src/entities/app/build.d.ts +12 -1
  51. package/dist-sdk/src/entities/app/build.js +80 -4
  52. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +5 -7
  53. package/dist-sdk/src/entities/app/from-tf.js +17 -12
  54. package/dist-sdk/src/entities/app/stage-keys.d.ts +18 -3
  55. package/dist-sdk/src/entities/app/stage-keys.js +40 -6
  56. package/dist-sdk/src/entities/app/to-tf.js +7 -4
  57. package/dist-sdk/src/entities/automation/build.d.ts +52 -31
  58. package/dist-sdk/src/entities/automation/build.js +59 -20
  59. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +7 -4
  60. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +39 -14
  61. package/dist-sdk/src/entities/automation/from-tf.d.ts +35 -2
  62. package/dist-sdk/src/entities/automation/from-tf.js +721 -93
  63. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  64. package/dist-sdk/src/entities/automation/module.d.ts +22 -2
  65. package/dist-sdk/src/entities/automation/module.js +244 -57
  66. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +22 -2
  67. package/dist-sdk/src/entities/automation/output-key-wire-name.js +54 -3
  68. package/dist-sdk/src/entities/automation/run-target.d.ts +61 -0
  69. package/dist-sdk/src/entities/automation/run-target.js +104 -0
  70. package/dist-sdk/src/entities/automation/script-code.d.ts +11 -1
  71. package/dist-sdk/src/entities/automation/script-code.js +106 -4
  72. package/dist-sdk/src/entities/automation/script-lint.d.ts +13 -0
  73. package/dist-sdk/src/entities/automation/script-lint.js +418 -0
  74. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +17 -1
  75. package/dist-sdk/src/entities/automation/task-output-labels.js +58 -1
  76. package/dist-sdk/src/entities/automation/tasks.d.ts +67 -22
  77. package/dist-sdk/src/entities/automation/tasks.js +18 -4
  78. package/dist-sdk/src/entities/automation/to-tf.d.ts +1 -3
  79. package/dist-sdk/src/entities/automation/to-tf.js +354 -64
  80. package/dist-sdk/src/entities/automation/triggers.d.ts +63 -11
  81. package/dist-sdk/src/entities/automation/triggers.js +45 -5
  82. package/dist-sdk/src/entities/automation/types.d.ts +21 -0
  83. package/dist-sdk/src/entities/automation/types.js +26 -0
  84. package/dist-sdk/src/entities/chart/build.d.ts +9 -1
  85. package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
  86. package/dist-sdk/src/entities/chart/from-tf.js +25 -1
  87. package/dist-sdk/src/entities/chart/index.d.ts +1 -1
  88. package/dist-sdk/src/entities/chart/printer.js +5 -2
  89. package/dist-sdk/src/entities/chart/to-tf.js +19 -1
  90. package/dist-sdk/src/entities/dashboard/from-tf.d.ts +11 -1
  91. package/dist-sdk/src/entities/dashboard/from-tf.js +57 -7
  92. package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
  93. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +8 -2
  94. package/dist-sdk/src/entities/dynamic-layout/condition-keys.d.ts +48 -0
  95. package/dist-sdk/src/entities/dynamic-layout/condition-keys.js +261 -0
  96. package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
  97. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +66 -20
  98. package/dist-sdk/src/entities/dynamic-layout/module.js +2 -1
  99. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +4 -2
  100. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +341 -32
  101. package/dist-sdk/src/entities/element/build.d.ts +10 -0
  102. package/dist-sdk/src/entities/element/build.js +1 -0
  103. package/dist-sdk/src/entities/element/from-tf.js +14 -9
  104. package/dist-sdk/src/entities/element/to-tf.js +7 -4
  105. package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
  106. package/dist-sdk/src/entities/field/from-tf.js +79 -1
  107. package/dist-sdk/src/entities/field/module.js +14 -1
  108. package/dist-sdk/src/entities/field/to-tf.d.ts +38 -3
  109. package/dist-sdk/src/entities/field/to-tf.js +108 -34
  110. package/dist-sdk/src/entities/file-reader/module.js +3 -3
  111. package/dist-sdk/src/entities/file-reader/to-tf.js +3 -3
  112. package/dist-sdk/src/entities/file-reader/types.d.ts +4 -16
  113. package/dist-sdk/src/entities/file-reader/types.js +7 -0
  114. package/dist-sdk/src/entities/org/group.d.ts +1 -0
  115. package/dist-sdk/src/entities/org/group.js +2 -1
  116. package/dist-sdk/src/entities/org/role.js +5 -0
  117. package/dist-sdk/src/entities/record-create-form/from-tf.d.ts +8 -0
  118. package/dist-sdk/src/entities/record-create-form/from-tf.js +10 -2
  119. package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +2 -1
  120. package/dist-sdk/src/entities/record-create-form/to-tf.js +14 -2
  121. package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -0
  122. package/dist-sdk/src/entities/relationship/from-tf.js +88 -10
  123. package/dist-sdk/src/entities/relationship/to-tf.d.ts +3 -2
  124. package/dist-sdk/src/entities/relationship/to-tf.js +79 -8
  125. package/dist-sdk/src/entities/role/from-tf.js +24 -7
  126. package/dist-sdk/src/entities/role/to-tf.js +25 -7
  127. package/dist-sdk/src/entities/service-account/from-tf.js +2 -1
  128. package/dist-sdk/src/entities/service-account/module.js +20 -0
  129. package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +5 -5
  130. package/dist-sdk/src/entities/service-account/role-fidelity.js +21 -13
  131. package/dist-sdk/src/entities/service-account/to-tf.js +12 -4
  132. package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
  133. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
  134. package/dist-sdk/src/entities/shared/filters/tf-codec.js +12 -7
  135. package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -3
  136. package/dist-sdk/src/entities/shared/types/field-types.js +3 -1
  137. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -2
  138. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +8 -1
  139. package/dist-sdk/src/entities/skill/from-tf.js +10 -3
  140. package/dist-sdk/src/entities/skill/module.js +18 -0
  141. package/dist-sdk/src/entities/skill/to-tf.d.ts +8 -1
  142. package/dist-sdk/src/entities/skill/to-tf.js +23 -14
  143. package/dist-sdk/src/entities/skill/tools.d.ts +8 -0
  144. package/dist-sdk/src/entities/skill/tools.js +6 -2
  145. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
  146. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
  147. package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -2
  148. package/dist-sdk/src/entities/task/to-tf.js +1 -0
  149. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +8 -2
  150. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +20 -10
  151. package/dist-sdk/src/entities/view/from-tf.d.ts +68 -4
  152. package/dist-sdk/src/entities/view/from-tf.js +394 -22
  153. package/dist-sdk/src/entities/view/module.js +20 -0
  154. package/dist-sdk/src/entities/view/portable.d.ts +11 -0
  155. package/dist-sdk/src/entities/view/portable.js +47 -0
  156. package/dist-sdk/src/entities/view/to-tf.d.ts +4 -1
  157. package/dist-sdk/src/entities/view/to-tf.js +25 -7
  158. package/dist-sdk/src/entities/view/types.js +1 -1
  159. package/dist-sdk/src/entities/widget/build.d.ts +4 -3
  160. package/dist-sdk/src/entities/widget/from-tf.d.ts +3 -0
  161. package/dist-sdk/src/entities/widget/from-tf.js +100 -3
  162. package/dist-sdk/src/entities/widget/to-tf.d.ts +16 -1
  163. package/dist-sdk/src/entities/widget/to-tf.js +77 -14
  164. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +30 -9
  165. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  166. package/dist-sdk/src/graph/field-resource-types.d.ts +2 -0
  167. package/dist-sdk/src/graph/field-resource-types.js +11 -0
  168. package/dist-sdk/src/graph/index.d.ts +41 -3
  169. package/dist-sdk/src/graph/index.js +24 -2
  170. package/dist-sdk/src/graph/types.d.ts +195 -5
  171. package/package.json +1 -1
@@ -16,6 +16,7 @@ import { appResourceLabelPrefix, elementResourceLabelPrefix, isTfExpr, scopedLab
16
16
  import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-codec.js";
17
17
  import { groupId, userId, } from "./principal.js";
18
18
  import { KNOWN_ACCESS_POLICY_ATTRS } from "./types.js";
19
+ import { finishPulledMemberList } from "./member-list.js";
19
20
  function fieldRef(value, owner, where) {
20
21
  if (isTfExpr(value) && value.$expr === "resource-attr" && value.type.endsWith("_field") && value.path[0] === "id") {
21
22
  // scopedLabelToBagKey's stripping is a documented no-op when the label
@@ -117,6 +118,30 @@ function stageName(value, owner, ctx) {
117
118
  // an ambiguous selection when two stage names are identical.
118
119
  return name !== undefined && entries.filter((stage) => stage.name === name).length === 1 ? name : undefined;
119
120
  }
121
+ /**
122
+ * The EDK ref of the app that owns a service-account block, read from the
123
+ * block's `app_id`: the owner itself when that is the app the ref points at,
124
+ * otherwise a foreign app the workspace knows by name or namespace (a
125
+ * namespace-only `data "elementum_app"` lookup included). Undefined
126
+ * when it doesn't resolve, so the caller drops the member.
127
+ */
128
+ export function serviceAccountAppRefName(appId, owner, ctx) {
129
+ const appDataLabel = dataRefLabel(appId, "elementum_app");
130
+ const appResourceLabel = resourceRefLabel(appId, "elementum_app");
131
+ const appName = appDataLabel === undefined ? undefined : ctx.dataName("elementum_app", appDataLabel);
132
+ if (appName !== undefined)
133
+ return ctx.foreignAppRefNames?.get(appName);
134
+ // Export looks up another app's service account through its owning app by
135
+ // namespace (edk#2197).
136
+ const appNamespace = appDataLabel === undefined ? undefined : ctx.dataAttrs?.("elementum_app", appDataLabel)?.["namespace"];
137
+ if (typeof appNamespace === "string")
138
+ return ctx.foreignAppRefNamespaces?.get(appNamespace);
139
+ if (appResourceLabel === undefined)
140
+ return undefined;
141
+ if (owner?.scope === "app" && owner.label === appResourceLabel)
142
+ return owner.ownerRefName;
143
+ return ctx.foreignAppRefNamespaces?.get(appResourceLabel);
144
+ }
120
145
  function principalListItem(item, dataType, where, ctx, owner) {
121
146
  const label = dataRefLabel(item, dataType);
122
147
  if (label !== undefined) {
@@ -126,17 +151,7 @@ function principalListItem(item, dataType, where, ctx, owner) {
126
151
  return undefined;
127
152
  }
128
153
  if (dataType === "elementum_service_account") {
129
- const appId = ctx.dataAttrs?.(dataType, label)?.["app_id"];
130
- const appDataLabel = dataRefLabel(appId, "elementum_app");
131
- const appResourceLabel = resourceRefLabel(appId, "elementum_app");
132
- const appName = appDataLabel === undefined ? undefined : ctx.dataName("elementum_app", appDataLabel);
133
- const appRefName = appName !== undefined
134
- ? ctx.foreignAppRefNames?.get(appName)
135
- : appResourceLabel !== undefined && owner?.scope === "app" && owner.label === appResourceLabel
136
- ? owner.ownerRefName
137
- : appResourceLabel === undefined
138
- ? undefined
139
- : ctx.foreignAppRefNamespaces?.get(appResourceLabel);
154
+ const appRefName = serviceAccountAppRefName(ctx.dataAttrs?.(dataType, label)?.["app_id"], owner, ctx);
140
155
  if (appRefName === undefined) {
141
156
  ctx.diagnostics.push(`${where}: data.${dataType}.${label} has no resolvable app_id owner; dropped`);
142
157
  return undefined;
@@ -164,17 +179,7 @@ function principalListItem(item, dataType, where, ctx, owner) {
164
179
  ctx.diagnostics.push(`${where}: elementum_service_account.${resourceLabel} has no recoverable display name; dropped`);
165
180
  return undefined;
166
181
  }
167
- const appId = account?.attrs["app_id"];
168
- const appDataLabel = dataRefLabel(appId, "elementum_app");
169
- const appResourceLabel = resourceRefLabel(appId, "elementum_app");
170
- const appName = appDataLabel === undefined ? undefined : ctx.dataName("elementum_app", appDataLabel);
171
- const appRefName = appName !== undefined
172
- ? ctx.foreignAppRefNames?.get(appName)
173
- : appResourceLabel !== undefined && owner?.scope === "app" && owner.label === appResourceLabel
174
- ? owner.ownerRefName
175
- : appResourceLabel === undefined
176
- ? undefined
177
- : ctx.foreignAppRefNamespaces?.get(appResourceLabel);
182
+ const appRefName = serviceAccountAppRefName(account?.attrs["app_id"], owner, ctx);
178
183
  if (appRefName === undefined) {
179
184
  ctx.diagnostics.push(`${where}: elementum_service_account.${resourceLabel} has no resolvable app_id owner; dropped`);
180
185
  return undefined;
@@ -201,16 +206,45 @@ export function principalList(value, dataType, where, ctx, owner) {
201
206
  return undefined;
202
207
  }
203
208
  const items = [];
209
+ let dropped = 0;
204
210
  for (const item of value) {
205
211
  const decoded = dataType === "elementum_user"
206
212
  ? principalListItem(item, "elementum_user", where, ctx)
207
213
  : dataType === "elementum_group"
208
214
  ? principalListItem(item, "elementum_group", where, ctx)
209
215
  : principalListItem(item, "elementum_service_account", where, ctx, owner);
210
- if (decoded !== undefined)
216
+ if (decoded === undefined)
217
+ dropped += 1;
218
+ else
211
219
  items.push(decoded);
212
220
  }
213
- return items.length > 0 ? items : undefined;
221
+ // A shorter service_account_ids list is the exact set and removes whoever
222
+ // pull could not name (#2160). Users and groups may stay as raw ids; a
223
+ // service account may not (#388). Drop the whole list so apply keeps the
224
+ // live members instead of deleting the unnamed one (#2259). Every member
225
+ // list follows that rule through finishPulledMemberList (edk#2200); the
226
+ // service-account diagnostic is kept so #2259's wording still appears.
227
+ if (dataType === "elementum_service_account" && dropped > 0 && items.length > 0) {
228
+ ctx.diagnostics.push(`${where}: a service account could not be named, so the list is omitted and apply keeps the live members`);
229
+ }
230
+ return finishPulledMemberList(where, items, dropped, ctx.diagnostics);
231
+ }
232
+ /**
233
+ * Export file order is not label-suffix order. Build numbers policies by
234
+ * array index (`access_policy`, then `access_policy_1`), so pull must follow
235
+ * the suffix or a later build swaps the addresses (#2088).
236
+ */
237
+ export function accessPolicyBlocksInLabelOrder(blocks) {
238
+ return [...blocks].sort((a, b) => {
239
+ const byIndex = accessPolicyLabelIndex(a.label ?? "") - accessPolicyLabelIndex(b.label ?? "");
240
+ return byIndex !== 0 ? byIndex : (a.label ?? "").localeCompare(b.label ?? "");
241
+ });
242
+ }
243
+ function accessPolicyLabelIndex(label) {
244
+ const match = /(?:^|_)access_policy(?:_(\d+))?$/.exec(label);
245
+ if (match === null)
246
+ return Number.MAX_SAFE_INTEGER;
247
+ return match[1] === undefined ? 0 : Number.parseInt(match[1], 10);
214
248
  }
215
249
  /** One `elementum_access_policy` block → its normalized shape, or undefined when it belongs to a different owner. */
216
250
  export function accessPolicyFromTf(block, owner, ctx) {
@@ -0,0 +1,32 @@
1
+ /**
2
+ * How the provider applies a member list, which decides what the build error
3
+ * tells the user:
4
+ * - `exact`: access-policy, role and service-account lists. A set list
5
+ * replaces the platform's members, so a partial list removes the rest.
6
+ * - `viewShare`: a view's `user_ids` / `group_ids`. An update only adds
7
+ * members, and a new view with neither list set is shared with the aspect's
8
+ * access-policy principals instead.
9
+ */
10
+ export type MemberListKind = "exact" | "viewShare";
11
+ /** A dropped list entry as text for a drop message, cut short when it is long. */
12
+ export declare function describeDroppedEntry(value: unknown): string;
13
+ /**
14
+ * Finish a built member list (access-policy, view-sharing or role
15
+ * `user_ids` / `group_ids` / `service_account_ids`). Building only some of the
16
+ * authored members must not pass silently: on an exact list apply would
17
+ * remove the rest, and on a view the user would get a different share than
18
+ * they wrote (edk#2198):
19
+ * - nothing dropped: the built list, including an empty one;
20
+ * - every entry dropped: no list (each drop becomes a diagnostic), so apply
21
+ * leaves the platform's members as they are;
22
+ * - some entries dropped: the build fails and names them.
23
+ */
24
+ export declare function finishMemberList<T>(where: string, built: T[], dropped: readonly string[], diagnostics: string[], kind?: MemberListKind): T[] | undefined;
25
+ /**
26
+ * Finish a pulled member list. Source sets an exact list, so writing only the
27
+ * members pull could decode would make the next apply remove the rest
28
+ * (edk#2200). When any member was dropped (each one already diagnosed), the
29
+ * whole list is omitted: an omitted list leaves the platform's members as
30
+ * they are (#2160).
31
+ */
32
+ export declare function finishPulledMemberList<T>(where: string, decoded: T[], droppedCount: number, diagnostics: string[]): T[] | undefined;
@@ -0,0 +1,57 @@
1
+ import { EntityTfError } from "../../engine/entity.js";
2
+ /** A dropped list entry as text for a drop message, cut short when it is long. */
3
+ export function describeDroppedEntry(value) {
4
+ let text;
5
+ try {
6
+ text = JSON.stringify(value) ?? String(value);
7
+ }
8
+ catch {
9
+ text = String(value);
10
+ }
11
+ return text.length > 120 ? `${text.slice(0, 117)}...` : text;
12
+ }
13
+ /**
14
+ * Finish a built member list (access-policy, view-sharing or role
15
+ * `user_ids` / `group_ids` / `service_account_ids`). Building only some of the
16
+ * authored members must not pass silently: on an exact list apply would
17
+ * remove the rest, and on a view the user would get a different share than
18
+ * they wrote (edk#2198):
19
+ * - nothing dropped: the built list, including an empty one;
20
+ * - every entry dropped: no list (each drop becomes a diagnostic), so apply
21
+ * leaves the platform's members as they are;
22
+ * - some entries dropped: the build fails and names them.
23
+ */
24
+ export function finishMemberList(where, built, dropped, diagnostics, kind = "exact") {
25
+ if (dropped.length === 0)
26
+ return built;
27
+ if (built.length === 0) {
28
+ diagnostics.push(...dropped);
29
+ return undefined;
30
+ }
31
+ const total = built.length + dropped.length;
32
+ const them = dropped.length === 1 ? "that member" : "those members";
33
+ const fix = `Fix ${dropped.length === 1 ? "it" : "each one"} (for an org user or group, re-run \`elementum pull org --data-only\`)`;
34
+ const consequence = kind === "exact"
35
+ ? `This list is applied exactly, so building the rest would make apply remove ${them} from the platform. ` +
36
+ `${fix}, or remove the whole list to leave its members as they are.`
37
+ : `A view share list only adds members on update, so building the rest would quietly leave ${them} out of the share you wrote. ` +
38
+ `${fix}. Removing the list is not the same: a new view with neither userIds nor groupIds is shared with its app or element's access-policy members.`;
39
+ throw new EntityTfError(`${where}: ${dropped.length} of ${total} members could not be built, so the build stops instead of writing the other ${built.length}. ` +
40
+ `${consequence} Not built: ${dropped.map((d) => d.replace(`${where}: `, "").replace(/; dropped$/, "")).join(" | ")}`);
41
+ }
42
+ /**
43
+ * Finish a pulled member list. Source sets an exact list, so writing only the
44
+ * members pull could decode would make the next apply remove the rest
45
+ * (edk#2200). When any member was dropped (each one already diagnosed), the
46
+ * whole list is omitted: an omitted list leaves the platform's members as
47
+ * they are (#2160).
48
+ */
49
+ export function finishPulledMemberList(where, decoded, droppedCount, diagnostics) {
50
+ if (droppedCount === 0)
51
+ return decoded.length > 0 ? decoded : undefined;
52
+ if (decoded.length > 0) {
53
+ diagnostics.push(`${where}: ${droppedCount} of ${decoded.length + droppedCount} live members could not be decoded (listed above), so the whole list is omitted from source. ` +
54
+ `Apply leaves this list's live members as they are; EDK manages the list again once pull can decode every member`);
55
+ }
56
+ return undefined;
57
+ }
@@ -14,4 +14,14 @@ export const accessPolicyModule = {
14
14
  lifecycle: NO_LIFECYCLE,
15
15
  canvas: { participates: true, label: "Access Policies", glyph: "🔒", component: "generic" },
16
16
  catalog: NO_CATALOG,
17
+ roundtrip: {
18
+ referenceAliases: [],
19
+ // Provider set attributes (edk#2437): order carries no meaning.
20
+ unorderedListAttributes: ["user_ids", "group_ids", "service_account_ids"],
21
+ },
22
+ // The platform creates one for the creator with every app, element and task,
23
+ // and it can't be told apart from the others, so a portable source has none.
24
+ portable: {
25
+ leaveOut: [{ resourceType: ACCESS_POLICY_RESOURCE_TYPE, reason: "access policies are left to the destination org" }],
26
+ },
17
27
  };
@@ -22,6 +22,7 @@ import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engin
22
22
  import type { Filter } from "../shared/filters/types.js";
23
23
  import type { AppServiceAccount } from "../service-account/build.js";
24
24
  import type { AccessPolicyGroupRef, AccessPolicyServiceAccountRef, AccessPolicyUserRef } from "./principal.js";
25
+ import { type MemberListKind } from "./member-list.js";
25
26
  export interface AccessPolicyToTfContext {
26
27
  readonly ownerTfLabel: string;
27
28
  /** App or element refName used to verify filter-field ownership. */
@@ -92,12 +93,12 @@ export interface AccessPolicyEntryWire {
92
93
  }
93
94
  export declare function principalListToTf(items: readonly AccessPolicyUserRef[] | undefined, dataType: "elementum_user", where: string, ctx: Omit<AccessPolicyToTfContext, "orgRefs"> & {
94
95
  readonly orgRefs?: OrgRefLookup;
95
- }): TfValue[] | undefined;
96
+ }, kind?: MemberListKind): TfValue[] | undefined;
96
97
  export declare function principalListToTf(items: readonly AccessPolicyGroupRef[] | undefined, dataType: "elementum_group", where: string, ctx: Omit<AccessPolicyToTfContext, "orgRefs"> & {
97
98
  readonly orgRefs?: OrgRefLookup;
98
- }): TfValue[] | undefined;
99
+ }, kind?: MemberListKind): TfValue[] | undefined;
99
100
  export declare function principalListToTf(items: readonly AccessPolicyServiceAccountRef[] | undefined, dataType: "elementum_service_account", where: string, ctx: Omit<AccessPolicyToTfContext, "orgRefs"> & {
100
101
  readonly orgRefs?: OrgRefLookup;
101
- }): TfValue[] | undefined;
102
+ }, kind?: MemberListKind): TfValue[] | undefined;
102
103
  /** One authored access-policy entry → its resource block, positioned by `index` (0-based) for label numbering. */
103
104
  export declare function accessPolicyToTf(entry: AccessPolicyEntryWire, index: number, ctx: AccessPolicyToTfContext): AccessPolicyToTfResult;
@@ -24,6 +24,7 @@ import { fieldRefToTfValue } from "../field/to-tf.js";
24
24
  import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
25
25
  import { serviceAccountRefToTf } from "../service-account/to-tf.js";
26
26
  import { ACCESS_POLICY_RESOURCE_TYPE } from "./types.js";
27
+ import { describeDroppedEntry, finishMemberList } from "./member-list.js";
27
28
  function isFieldToken(v) {
28
29
  return typeof v === "object" && v !== null && v.__kind === "field";
29
30
  }
@@ -134,21 +135,22 @@ function resolveForeignOwningApp(item, ctx) {
134
135
  const resolved = ctx.resolveServiceAccountApp?.(appRefName);
135
136
  return resolved === undefined ? undefined : { appRefName, ...resolved };
136
137
  }
137
- export function principalListToTf(items, dataType, where, ctx) {
138
+ export function principalListToTf(items, dataType, where, ctx, kind) {
138
139
  if (items === undefined || items.length === 0)
139
140
  return undefined;
140
141
  const values = [];
142
+ const dropped = [];
141
143
  for (const item of items) {
142
144
  if (isOrgPrincipalRef(item)) {
143
145
  if (ctx.orgRefs === undefined) {
144
- ctx.diagnostics.push(`${where}: pulled principal reference requires org context; dropped`);
146
+ dropped.push(`${where}: pulled principal reference requires org context; dropped`);
145
147
  }
146
148
  else if (item.dataType === "elementum_service_account") {
147
149
  // A service account is app-owned, so its data source requires
148
150
  // `app_id`. The pulled shape carries only a name, so the owner must be
149
151
  // the owning app — an element cannot say which app it meant.
150
152
  if (ctx.scope !== "app") {
151
- ctx.diagnostics.push(`${where}: pulled service-account reference ${JSON.stringify(item.value)} needs an app owner to supply app_id; dropped`);
153
+ dropped.push(`${where}: pulled service-account reference ${JSON.stringify(item.value)} needs an app owner to supply app_id; dropped`);
152
154
  }
153
155
  else {
154
156
  ctx.orgRefs.rawLookup(item.dataType, item.label, item.value, { app_id: ctx.objectId });
@@ -162,7 +164,7 @@ export function principalListToTf(items, dataType, where, ctx) {
162
164
  }
163
165
  else if (dataType === "elementum_user" && isUserToken(item)) {
164
166
  if (ctx.orgRefs === undefined) {
165
- ctx.diagnostics.push(`${where}: userRef requires org context; dropped`);
167
+ dropped.push(`${where}: userRef requires org context; dropped`);
166
168
  }
167
169
  else {
168
170
  const label = sanitizeName(item.email.split("@", 1)[0] ?? item.email);
@@ -173,7 +175,7 @@ export function principalListToTf(items, dataType, where, ctx) {
173
175
  else if (dataType === "elementum_group" && isGroupToken(item)) {
174
176
  const resolved = ctx.orgRefs?.byTsLabel("groups", item.refName ?? "");
175
177
  if (resolved === undefined) {
176
- ctx.diagnostics.push(`${where}: group token "${item.refName}" is not in the org catalog — re-run \`elementum pull org --data-only\``);
178
+ dropped.push(`${where}: group token "${item.refName}" is not in the org catalog — re-run \`elementum pull org --data-only\``);
177
179
  }
178
180
  else {
179
181
  values.push(expr.dataAttr("elementum_group", resolved.tfLabel, ["id"]));
@@ -188,10 +190,10 @@ export function principalListToTf(items, dataType, where, ctx) {
188
190
  ? { appRefName: ctx.appRefName, appTfLabel: ctx.ownerTfLabel, appId: ctx.objectId, serviceAccounts: ctx.serviceAccounts }
189
191
  : resolveForeignOwningApp(item, ctx);
190
192
  if (owning === undefined || ctx.orgRefs === undefined) {
191
- ctx.diagnostics.push(`${where}: serviceAccount ${JSON.stringify(item.name ?? "")} cannot resolve its owning app ${JSON.stringify(item.appRefName ?? "")}; dropped`);
193
+ dropped.push(`${where}: serviceAccount ${JSON.stringify(item.name ?? "")} cannot resolve its owning app ${JSON.stringify(item.appRefName ?? "")}; dropped`);
192
194
  }
193
195
  else {
194
- const value = serviceAccountRefToTf(item, { ...owning, orgRefs: ctx.orgRefs }, where, ctx.diagnostics);
196
+ const value = serviceAccountRefToTf(item, { ...owning, orgRefs: ctx.orgRefs }, where, dropped);
195
197
  if (value !== undefined)
196
198
  values.push(value);
197
199
  }
@@ -200,10 +202,10 @@ export function principalListToTf(items, dataType, where, ctx) {
200
202
  values.push(item);
201
203
  }
202
204
  else {
203
- ctx.diagnostics.push(`${where}: ${dataType} list item has an unrecognized shape; dropped`);
205
+ dropped.push(`${where}: ${dataType} list item has an unrecognized shape (${describeDroppedEntry(item)}); dropped`);
204
206
  }
205
207
  }
206
- return values.length > 0 ? values : undefined;
208
+ return finishMemberList(where, values, dropped, ctx.diagnostics, kind);
207
209
  }
208
210
  function accessPolicyTfLabel(ownerTfLabel, index, scope) {
209
211
  const childPart = index === 0 ? "access_policy" : `access_policy_${index}`;
@@ -221,13 +223,20 @@ export function accessPolicyToTf(entry, index, ctx) {
221
223
  object_id: ctx.objectId,
222
224
  filter: entry.filter !== undefined ? filterToTf(entry.filter, where, ctx) : { type: "true" },
223
225
  };
224
- const userIds = principalListToTf(entry.userIds, "elementum_user", `${where}.userIds`, ctx);
226
+ // `userIds: []` (and the other lists) removes every member, so it must
227
+ // reach the provider as `[]`: an omitted list changes nothing (#2160). A
228
+ // list whose every entry is dropped (each one diagnosed) stays omitted, so
229
+ // apply changes nothing rather than removing every member; a list with only
230
+ // some entries dropped fails the build (edk#2198, finishMemberList).
231
+ const userIds = entry.userIds?.length === 0 ? [] : principalListToTf(entry.userIds, "elementum_user", `${where}.userIds`, ctx);
225
232
  if (userIds !== undefined)
226
233
  attrs["user_ids"] = userIds;
227
- const groupIds = principalListToTf(entry.groupIds, "elementum_group", `${where}.groupIds`, ctx);
234
+ const groupIds = entry.groupIds?.length === 0 ? [] : principalListToTf(entry.groupIds, "elementum_group", `${where}.groupIds`, ctx);
228
235
  if (groupIds !== undefined)
229
236
  attrs["group_ids"] = groupIds;
230
- const serviceAccountIds = principalListToTf(entry.serviceAccountIds, "elementum_service_account", `${where}.serviceAccountIds`, ctx);
237
+ const serviceAccountIds = entry.serviceAccountIds?.length === 0
238
+ ? []
239
+ : principalListToTf(entry.serviceAccountIds, "elementum_service_account", `${where}.serviceAccountIds`, ctx);
231
240
  if (serviceAccountIds !== undefined)
232
241
  attrs["service_account_ids"] = serviceAccountIds;
233
242
  return {
@@ -13,8 +13,9 @@
13
13
  * the typed `app` reference, exactly like `automation`.
14
14
  */
15
15
  import { slimTokens } from "../../catalog/index.js";
16
- import { appScopedResourceLabel, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
16
+ import { appScopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
17
17
  import { currentValidationMode, currentValidationScope, recordValidations, ValidationFailureError, } from "../../engine/validation.js";
18
+ import { agentToolBareLabel, agentToolLabelSuffixes } from "../agent-tool/to-tf.js";
18
19
  import { RUN_AUTOMATION_TOOL_RESOURCE_TYPE } from "../agent-tool/types.js";
19
20
  export const agentStartingActionVariableType = {
20
21
  number: "NUMBER",
@@ -74,14 +75,15 @@ function serializeA2ASkill(s) {
74
75
  * bag-less (paramless automation → undefined) or non-empty, so skipping
75
76
  * empty costs no real coverage.
76
77
  */
77
- function runAutomationToolAddress(appTfLabel, agentRefName, toolName) {
78
+ function runAutomationToolAddress(appTfLabel, agentRefName, toolName, labelSuffix) {
78
79
  const agentBare = tsLabelToTfLabel(agentRefName);
79
- const label = appScopedResourceLabel(appTfLabel, sanitizeName(`${agentBare}_${toolName}`));
80
+ const label = appScopedResourceLabel(appTfLabel, agentToolBareLabel(agentBare, toolName, labelSuffix));
80
81
  return `${RUN_AUTOMATION_TOOL_RESOURCE_TYPE}.${label}`;
81
82
  }
82
83
  export function validateAgentTools(agentName, tools, identity) {
83
84
  const failures = [];
84
- for (const tool of tools) {
85
+ const labelSuffixes = agentToolLabelSuffixes(tsLabelToTfLabel(identity?.agentRefName ?? ""), tools);
86
+ for (const [index, tool] of tools.entries()) {
85
87
  const inner = tool["executeWorkflow"];
86
88
  if (inner === undefined || typeof inner !== "object")
87
89
  continue;
@@ -94,7 +96,7 @@ export function validateAgentTools(agentName, tools, identity) {
94
96
  failures.push({
95
97
  severity: "fatal",
96
98
  address: appTfLabel !== "" && agentRefName !== ""
97
- ? runAutomationToolAddress(appTfLabel, agentRefName, toolName)
99
+ ? runAutomationToolAddress(appTfLabel, agentRefName, toolName, labelSuffixes[index] ?? "")
98
100
  : `agent.${agentName}`,
99
101
  name: agentName,
100
102
  ownerKind: "agent",
@@ -427,6 +427,8 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
427
427
  const lines = [`${factory}({`];
428
428
  lines.push(` name: ${quote(tool.name)},`);
429
429
  lines.push(` description: ${quote(tool.description)},`);
430
+ if (tool.labelSuffix !== undefined)
431
+ lines.push(` labelSuffix: ${tool.labelSuffix},`);
430
432
  if (tool.startMessage !== undefined)
431
433
  lines.push(` startMessage: ${quote(tool.startMessage)},`);
432
434
  if (tool.runAs !== undefined)
@@ -9,9 +9,10 @@
9
9
  import { typedCoverageGap } from "../../engine/coverage-gaps.js";
10
10
  import { EntityTfError } from "../../engine/entity.js";
11
11
  import { dataRefLabel, optionalBoolean, optionalString, ownerMismatchBlocker, plainObject, reportAuthoringBlocker, resourceRefLabel } from "../../engine/pull/context.js";
12
- import { isTfExpr, isUuid, scopedLabelToBagKey, } from "../../engine/tf/index.js";
12
+ import { appScopedResourceLabel, exportLabelSuffix, isTfExpr, isUuid, scopedLabelToBagKey, tsLabelToTfLabel, } from "../../engine/tf/index.js";
13
13
  import { a2aSkillFromTf } from "../agent-a2a-skill/from-tf.js";
14
14
  import { toolFromTf } from "../agent-tool/from-tf.js";
15
+ import { agentToolBareLabel } from "../agent-tool/to-tf.js";
15
16
  import { connectorIdentityFromTf } from "../shared/connector-from-tf.js";
16
17
  import { APP_RESOURCE_TYPE } from "../app/module.js";
17
18
  import { SKILL_RESOURCE_TYPE } from "../skill/module.js";
@@ -433,11 +434,20 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx,
433
434
  };
434
435
  }
435
436
  const owner = { appType: APP_RESOURCE_TYPE, appLabel, ownerTfLabel: appLabel, agentType: AGENT_RESOURCE_TYPE, agentLabel: label };
437
+ // Pin the `_N` ei gave each suffixed tool (edk#1987). ei counts in the
438
+ // platform's order, including tools pull doesn't print (unimplemented
439
+ // kinds), and the export file is sorted by resource type, so counting the
440
+ // printed tools again would shift their labels.
441
+ const agentBare = tsLabelToTfLabel(scopedLabelToBagKey(appLabel, label));
436
442
  const tools = [];
437
443
  for (const block of toolBlocks) {
438
444
  const tool = toolFromTf(block, owner, ctx);
439
- if (tool !== undefined)
440
- tools.push(tool);
445
+ if (tool === undefined)
446
+ continue;
447
+ const labelSuffix = block.label === undefined
448
+ ? undefined
449
+ : exportLabelSuffix(appScopedResourceLabel(appLabel, agentToolBareLabel(agentBare, tool.name, "")), block.label);
450
+ tools.push(labelSuffix === undefined ? tool : { ...tool, labelSuffix });
441
451
  }
442
452
  const a2aSkills = [];
443
453
  for (const block of a2aSkillBlocks) {
@@ -20,7 +20,7 @@ import { workspaceAspectKey } from "../../engine/build/context.js";
20
20
  import { EntityTfError } from "../../engine/entity.js";
21
21
  import { appScopedResourceLabel, expr, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
22
22
  import { a2aSkillToTf } from "../agent-a2a-skill/to-tf.js";
23
- import { toolToTf } from "../agent-tool/to-tf.js";
23
+ import { agentToolLabelSuffixes, assertUniqueToolAddresses, toolName, toolToTf } from "../agent-tool/to-tf.js";
24
24
  import { APP_RESOURCE_TYPE } from "../app/module.js";
25
25
  import { CONNECTOR_ORG_BAG } from "../org/connector.js";
26
26
  import { resolveForeignRef } from "../shared/foreign-ref.js";
@@ -470,11 +470,14 @@ export function agentToTf(entity, ctx) {
470
470
  attrs["skill_access_config"] = skillAccessValue;
471
471
  }
472
472
  const blocks = [{ kind: "resource", type: AGENT_RESOURCE_TYPE, label: tfLabel, attrs }];
473
- for (const entry of payload.tools ?? []) {
473
+ const toolLabelSuffixes = agentToolLabelSuffixes(agentBareTfLabel, payload.tools ?? []);
474
+ const toolAddresses = [];
475
+ (payload.tools ?? []).forEach((entry, index) => {
474
476
  const tool = toolToTf(entry, {
475
477
  appRefName: ctx.appRefName,
476
478
  appTfLabel: ctx.appTfLabel,
477
479
  agentBareTfLabel,
480
+ labelSuffix: toolLabelSuffixes[index] ?? "",
478
481
  activeAutomationRefNames: ctx.activeAutomationRefNames,
479
482
  foreignAppRef: (l, n, ns) => ctx.orgRefs.foreignApp(l, n, ns),
480
483
  foreignElementRef: (l, n, ns) => ctx.orgRefs.foreignElement(l, n, ns),
@@ -508,9 +511,12 @@ export function agentToTf(entity, ctx) {
508
511
  },
509
512
  diagnostics: ctx.diagnostics,
510
513
  });
511
- if (tool !== undefined)
512
- blocks.push(tool.block);
513
- }
514
+ if (tool === undefined)
515
+ return;
516
+ toolAddresses.push({ name: toolName(entry), address: tool.address });
517
+ blocks.push(tool.block);
518
+ });
519
+ assertUniqueToolAddresses(where, toolAddresses);
514
520
  // Board issue #294: two agents in the same app can legitimately both
515
521
  // author an a2a skill with the same display name — ei's own exporter
516
522
  // disambiguates that case with a numeric suffix rather than rejecting it
@@ -153,6 +153,14 @@ interface CommonToolOptions {
153
153
  readonly description: string;
154
154
  readonly startMessage?: string;
155
155
  readonly runAs?: AgentToolRunAs;
156
+ /**
157
+ * Pins the `_N` on this tool's terraform label, for a tool whose name shares
158
+ * a label with others (`a-b`, `a_b`, `aB`). Pull writes it when ei's export
159
+ * gave the tool a suffix; keep it, or the tool's address changes. Without
160
+ * it, a colliding tool takes the lowest free `_N` in tool order. Never sent
161
+ * to the platform. A whole number from 1 to `Number.MAX_SAFE_INTEGER`.
162
+ */
163
+ readonly labelSuffix?: number;
156
164
  }
157
165
  export type SearchRecordsToolOptions<Target extends ToolTarget = ToolTarget> = CommonToolOptions & TargetOption<Target> & {
158
166
  readonly queryDescription: string;
@@ -32,11 +32,15 @@ function common(opts) {
32
32
  // Every tool factory routes through here, so this is the single enforcement
33
33
  // point — the tf passes never re-check.
34
34
  if (!isValidToolName(opts.name)) {
35
- throw new Error(`agent tool name "${opts.name}" must be 1–64 characters of letters, digits, and ` +
36
- `underscores (A–Z, a–z, 0–9, _) with no consecutive underscores — no hyphens or spaces.`);
35
+ throw new Error(`agent tool name "${opts.name}" must be 1–64 characters of letters, digits, underscores, ` +
36
+ `and hyphens (A–Z, a–z, 0–9, _, -) with no consecutive underscores — no spaces.`);
37
+ }
38
+ if (opts.labelSuffix !== undefined && (!Number.isSafeInteger(opts.labelSuffix) || opts.labelSuffix < 1)) {
39
+ throw new Error(`agent tool "${opts.name}" labelSuffix must be a whole number from 1 to Number.MAX_SAFE_INTEGER; got ${String(opts.labelSuffix)}.`);
37
40
  }
38
41
  return {
39
42
  name: opts.name,
43
+ ...(opts.labelSuffix !== undefined ? { labelSuffix: opts.labelSuffix } : {}),
40
44
  description: opts.description,
41
45
  ...(opts.startMessage !== undefined ? { startMessage: opts.startMessage } : {}),
42
46
  ...(opts.runAs !== undefined ? { runAs: serializeRunAs(opts.runAs) } : {}),
@@ -99,6 +99,8 @@ export interface NormalizedAgentTool {
99
99
  readonly name: string;
100
100
  readonly description: string;
101
101
  readonly startMessage?: string;
102
+ /** The `_N` ei gave this tool's label (edk#1987); see the builders' `labelSuffix`. */
103
+ readonly labelSuffix?: number;
102
104
  readonly runAs?: AgentToolRunAs;
103
105
  /** absent for executeWorkflow — its target is an automation, not an aspect. searchTable's target is also optional. */
104
106
  readonly target?: NormalizedToolTarget;
@@ -20,6 +20,8 @@ export interface ToolToTfContext {
20
20
  readonly appTfLabel: string;
21
21
  /** The owning agent's bare tfLabel (before apps_ prefix). */
22
22
  readonly agentBareTfLabel: string;
23
+ /** `_N` from {@link agentToolLabelSuffixes} when this tool's label collides with an earlier sibling's. */
24
+ readonly labelSuffix?: string;
23
25
  /** Records a foreign-app data lookup for data.tf; returns its tfLabel. */
24
26
  foreignAppRef(tfLabel: string, name: string, namespace?: string): void;
25
27
  /** Records a foreign-ELEMENT data lookup for data.tf (board issue #42). */
@@ -55,6 +57,33 @@ export interface ToolToTfResult {
55
57
  /** `<resourceType>.<tfLabel>` — bookkeeping for the agent catalog. */
56
58
  readonly address: string;
57
59
  }
60
+ /** An agent tool's bare label: `sanitizeName(<agent>_<tool name>)` plus its collision suffix. */
61
+ export declare function agentToolBareLabel(agentBareTfLabel: string, toolName: string, labelSuffix: string): string;
62
+ /**
63
+ * `_N` suffixes, by tool index, for one agent's tools whose labels collide
64
+ * (`a-b` and `a_b` both sanitize to `a_b`), with one counter across tool
65
+ * kinds as in ei's export (`GenerateImportBlocks`, `toolNames` in
66
+ * imports.go). A tool with `labelSuffix` keeps that `_N`; the others take the
67
+ * lowest free count in tool order (`collisionLabelSuffixes`), so an unpinned
68
+ * tool's order is part of its address. Pull pins every tool ei suffixed
69
+ * (agentFromTf), so a pulled agent rebuilds its exported labels even when ei
70
+ * counted a tool pull doesn't print. Every known tool kind counts, implemented
71
+ * or not, as in ei. Parity holds within one agent only: ei's counter spans
72
+ * the whole app and is keyed on the agent's display name (edk#2000).
73
+ */
74
+ export declare function agentToolLabelSuffixes(agentBareTfLabel: string, tools: readonly Record<string, unknown>[]): readonly string[];
75
+ /** A tool entry's (`{ createRecord: { name, ... } }`) platform name, or "". */
76
+ export declare function toolName(entry: Record<string, unknown>): string;
77
+ /**
78
+ * Fail the build when two of one owner's tools land on one resource address
79
+ * (`a-b`, `a_b` and `a_b_1` of one kind: the second gets `_1`, the third is
80
+ * `a_b_1` already). OpenTofu would reject the duplicate only at plan, so name
81
+ * both tools here instead (edk#1987).
82
+ */
83
+ export declare function assertUniqueToolAddresses(owner: string, tools: readonly {
84
+ readonly name: string;
85
+ readonly address: string;
86
+ }[]): void;
58
87
  /**
59
88
  * One authored tool entry (`{ createRecord: {...} }`) → its resource block;
60
89
  * undefined = degraded with a diagnostic (unimplemented sub-type, missing