@elementumai/edk 0.12.0 → 0.13.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 (193) hide show
  1. package/README.md +2 -0
  2. package/dist-sdk/src/catalog/factories.d.ts +7 -1
  3. package/dist-sdk/src/catalog/factories.js +2 -0
  4. package/dist-sdk/src/catalog/index.d.ts +2 -2
  5. package/dist-sdk/src/catalog/index.js +1 -1
  6. package/dist-sdk/src/catalog/org.js +79 -34
  7. package/dist-sdk/src/catalog/token.js +5 -0
  8. package/dist-sdk/src/catalog/types.d.ts +7 -1
  9. package/dist-sdk/src/catalog/types.js +3 -0
  10. package/dist-sdk/src/core/system-fields.d.ts +1 -1
  11. package/dist-sdk/src/core/system-fields.js +1 -1
  12. package/dist-sdk/src/core/types/app.d.ts +6 -0
  13. package/dist-sdk/src/engine/build/context.d.ts +3 -0
  14. package/dist-sdk/src/engine/pull/authored-address.js +42 -6
  15. package/dist-sdk/src/engine/pull/authored-root.d.ts +88 -0
  16. package/dist-sdk/src/engine/pull/authored-root.js +306 -0
  17. package/dist-sdk/src/engine/pull/context.d.ts +10 -0
  18. package/dist-sdk/src/engine/pull/field-refs-registry.d.ts +114 -0
  19. package/dist-sdk/src/engine/pull/field-refs-registry.js +501 -0
  20. package/dist-sdk/src/engine/pull/org.d.ts +1 -0
  21. package/dist-sdk/src/engine/pull/org.js +2 -0
  22. package/dist-sdk/src/engine/pull/partition.d.ts +8 -0
  23. package/dist-sdk/src/engine/pull/partition.js +43 -0
  24. package/dist-sdk/src/engine/pull/pulled-roots.d.ts +89 -0
  25. package/dist-sdk/src/engine/pull/pulled-roots.js +203 -0
  26. package/dist-sdk/src/engine/pull/ref-only.d.ts +4 -0
  27. package/dist-sdk/src/engine/pull/ref-only.js +7 -1
  28. package/dist-sdk/src/engine/pull/source-resources.d.ts +39 -0
  29. package/dist-sdk/src/engine/pull/source-resources.js +110 -0
  30. package/dist-sdk/src/engine/pull/stream-root.d.ts +148 -0
  31. package/dist-sdk/src/engine/pull/stream-root.js +563 -0
  32. package/dist-sdk/src/engine/workspace/reserved-catalog-keys.d.ts +47 -0
  33. package/dist-sdk/src/engine/workspace/reserved-catalog-keys.js +115 -0
  34. package/dist-sdk/src/entities/access-policy/build.d.ts +2 -1
  35. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
  36. package/dist-sdk/src/entities/access-policy/from-tf.js +18 -3
  37. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +19 -0
  38. package/dist-sdk/src/entities/access-policy/to-tf.js +65 -8
  39. package/dist-sdk/src/entities/agent/build.d.ts +52 -1
  40. package/dist-sdk/src/entities/agent/build.js +34 -0
  41. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +68 -0
  42. package/dist-sdk/src/entities/agent/from-tf.d.ts +34 -1
  43. package/dist-sdk/src/entities/agent/from-tf.js +262 -2
  44. package/dist-sdk/src/entities/agent/index.d.ts +1 -1
  45. package/dist-sdk/src/entities/agent/to-tf.d.ts +8 -10
  46. package/dist-sdk/src/entities/agent/to-tf.js +158 -14
  47. package/dist-sdk/src/entities/agent-tool/from-tf.js +6 -0
  48. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
  49. package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -2
  50. package/dist-sdk/src/entities/app/build.d.ts +33 -13
  51. package/dist-sdk/src/entities/app/build.js +14 -12
  52. package/dist-sdk/src/entities/app/from-tf.js +24 -9
  53. package/dist-sdk/src/entities/app/index.d.ts +1 -0
  54. package/dist-sdk/src/entities/app/index.js +1 -0
  55. package/dist-sdk/src/entities/app/module.js +1 -0
  56. package/dist-sdk/src/entities/app/stage-keys.d.ts +2 -2
  57. package/dist-sdk/src/entities/app/stage-keys.js +3 -3
  58. package/dist-sdk/src/entities/app/to-tf.js +1 -0
  59. package/dist-sdk/src/entities/approval-chain/build.d.ts +46 -11
  60. package/dist-sdk/src/entities/approval-chain/build.js +120 -8
  61. package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +24 -2
  62. package/dist-sdk/src/entities/approval-chain/from-tf.js +148 -6
  63. package/dist-sdk/src/entities/approval-chain/index.d.ts +4 -1
  64. package/dist-sdk/src/entities/approval-chain/index.js +4 -1
  65. package/dist-sdk/src/entities/approval-chain/module.js +23 -5
  66. package/dist-sdk/src/entities/approval-chain/printer.d.ts +1 -1
  67. package/dist-sdk/src/entities/approval-chain/printer.js +91 -5
  68. package/dist-sdk/src/entities/approval-chain/steps-tf.d.ts +77 -0
  69. package/dist-sdk/src/entities/approval-chain/steps-tf.js +255 -0
  70. package/dist-sdk/src/entities/approval-chain/steps.d.ts +71 -0
  71. package/dist-sdk/src/entities/approval-chain/steps.js +83 -0
  72. package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +16 -6
  73. package/dist-sdk/src/entities/approval-chain/to-tf.js +37 -4
  74. package/dist-sdk/src/entities/automation/build.js +70 -27
  75. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +20 -5
  76. package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -5
  77. package/dist-sdk/src/entities/automation/from-tf.js +593 -101
  78. package/dist-sdk/src/entities/automation/index.d.ts +1 -0
  79. package/dist-sdk/src/entities/automation/index.js +1 -0
  80. package/dist-sdk/src/entities/automation/module.d.ts +4 -3
  81. package/dist-sdk/src/entities/automation/module.js +33 -12
  82. package/dist-sdk/src/entities/automation/refs-read.d.ts +19 -0
  83. package/dist-sdk/src/entities/automation/refs-read.js +48 -0
  84. package/dist-sdk/src/entities/automation/slack-message-refs.d.ts +9 -0
  85. package/dist-sdk/src/entities/automation/slack-message-refs.js +75 -0
  86. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +11 -0
  87. package/dist-sdk/src/entities/automation/task-output-labels.js +23 -0
  88. package/dist-sdk/src/entities/automation/tasks.d.ts +29 -4
  89. package/dist-sdk/src/entities/automation/tasks.js +34 -11
  90. package/dist-sdk/src/entities/automation/to-tf.d.ts +3 -0
  91. package/dist-sdk/src/entities/automation/to-tf.js +337 -77
  92. package/dist-sdk/src/entities/automation/triggers.d.ts +0 -8
  93. package/dist-sdk/src/entities/automation/triggers.js +26 -11
  94. package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +50 -0
  95. package/dist-sdk/src/entities/automation/unsafe-script-output.js +92 -0
  96. package/dist-sdk/src/entities/chart/build.d.ts +9 -1
  97. package/dist-sdk/src/entities/chart/from-tf.js +3 -0
  98. package/dist-sdk/src/entities/chart/to-tf.js +19 -2
  99. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +2 -0
  100. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +44 -5
  101. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +46 -12
  102. package/dist-sdk/src/entities/element/audit-field-guard.d.ts +9 -0
  103. package/dist-sdk/src/entities/element/audit-field-guard.js +88 -0
  104. package/dist-sdk/src/entities/element/build.js +2 -1
  105. package/dist-sdk/src/entities/element/from-tf.js +15 -2
  106. package/dist-sdk/src/entities/element/module.js +3 -0
  107. package/dist-sdk/src/entities/element/system-fields.d.ts +13 -0
  108. package/dist-sdk/src/entities/element/system-fields.js +23 -0
  109. package/dist-sdk/src/entities/element/to-tf.js +1 -0
  110. package/dist-sdk/src/entities/field/build.d.ts +9 -0
  111. package/dist-sdk/src/entities/field/from-tf.d.ts +29 -1
  112. package/dist-sdk/src/entities/field/from-tf.js +99 -6
  113. package/dist-sdk/src/entities/field/module.js +4 -0
  114. package/dist-sdk/src/entities/field/to-tf.d.ts +5 -1
  115. package/dist-sdk/src/entities/field/to-tf.js +33 -12
  116. package/dist-sdk/src/entities/org/category.js +1 -0
  117. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  118. package/dist-sdk/src/entities/org/index.js +1 -0
  119. package/dist-sdk/src/entities/org/voice-auth.d.ts +5 -0
  120. package/dist-sdk/src/entities/org/voice-auth.js +33 -0
  121. package/dist-sdk/src/entities/organization/build.d.ts +3 -0
  122. package/dist-sdk/src/entities/organization/build.js +2 -0
  123. package/dist-sdk/src/entities/organization/index.d.ts +1 -0
  124. package/dist-sdk/src/entities/organization/index.js +1 -0
  125. package/dist-sdk/src/entities/organization/to-tf.d.ts +2 -0
  126. package/dist-sdk/src/entities/organization/to-tf.js +59 -1
  127. package/dist-sdk/src/entities/organization/voice-auth.d.ts +60 -0
  128. package/dist-sdk/src/entities/organization/voice-auth.js +60 -0
  129. package/dist-sdk/src/entities/phone-service/build.d.ts +9 -1
  130. package/dist-sdk/src/entities/phone-service/build.js +1 -0
  131. package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +3 -0
  132. package/dist-sdk/src/entities/phone-service/from-tf.d.ts +1 -0
  133. package/dist-sdk/src/entities/phone-service/from-tf.js +8 -1
  134. package/dist-sdk/src/entities/phone-service/to-tf.js +16 -0
  135. package/dist-sdk/src/entities/record-create-form/from-tf.js +2 -2
  136. package/dist-sdk/src/entities/relationship/from-tf.js +7 -2
  137. package/dist-sdk/src/entities/relationship/module.js +2 -2
  138. package/dist-sdk/src/entities/relationship/pair-check.d.ts +6 -2
  139. package/dist-sdk/src/entities/relationship/pair-check.js +105 -18
  140. package/dist-sdk/src/entities/relationship/to-tf.js +5 -2
  141. package/dist-sdk/src/entities/role/permission-levels.d.ts +7 -0
  142. package/dist-sdk/src/entities/role/permission-levels.js +78 -0
  143. package/dist-sdk/src/entities/role/to-tf.js +32 -2
  144. package/dist-sdk/src/entities/service-account/module.d.ts +2 -1
  145. package/dist-sdk/src/entities/service-account/module.js +4 -1
  146. package/dist-sdk/src/entities/service-account/resource-type.d.ts +2 -0
  147. package/dist-sdk/src/entities/service-account/resource-type.js +2 -0
  148. package/dist-sdk/src/entities/service-account/role-membership-check.d.ts +20 -0
  149. package/dist-sdk/src/entities/service-account/role-membership-check.js +80 -0
  150. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +15 -0
  151. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +36 -0
  152. package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
  153. package/dist-sdk/src/entities/shared/filters/index.d.ts +85 -14
  154. package/dist-sdk/src/entities/shared/filters/index.js +18 -6
  155. package/dist-sdk/src/entities/shared/filters/option-lookups.d.ts +57 -0
  156. package/dist-sdk/src/entities/shared/filters/option-lookups.js +108 -0
  157. package/dist-sdk/src/entities/shared/filters/print.js +9 -5
  158. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +12 -7
  159. package/dist-sdk/src/entities/shared/filters/tf-codec.js +9 -5
  160. package/dist-sdk/src/entities/shared/raw-option-id.d.ts +30 -0
  161. package/dist-sdk/src/entities/shared/raw-option-id.js +41 -0
  162. package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
  163. package/dist-sdk/src/entities/skill/input-coverage.js +5 -2
  164. package/dist-sdk/src/entities/sla/build.d.ts +96 -0
  165. package/dist-sdk/src/entities/sla/build.js +124 -0
  166. package/dist-sdk/src/entities/sla/from-tf.d.ts +40 -0
  167. package/dist-sdk/src/entities/sla/from-tf.js +164 -0
  168. package/dist-sdk/src/entities/sla/index.d.ts +1 -0
  169. package/dist-sdk/src/entities/sla/index.js +1 -0
  170. package/dist-sdk/src/entities/sla/module.d.ts +4 -0
  171. package/dist-sdk/src/entities/sla/module.js +73 -0
  172. package/dist-sdk/src/entities/sla/printer.d.ts +2 -0
  173. package/dist-sdk/src/entities/sla/printer.js +84 -0
  174. package/dist-sdk/src/entities/sla/to-tf.d.ts +12 -0
  175. package/dist-sdk/src/entities/sla/to-tf.js +81 -0
  176. package/dist-sdk/src/entities/table/build.d.ts +7 -2
  177. package/dist-sdk/src/entities/table/build.js +22 -1
  178. package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +4 -1
  179. package/dist-sdk/src/entities/table/from-tf.js +89 -14
  180. package/dist-sdk/src/entities/table/index.d.ts +1 -1
  181. package/dist-sdk/src/entities/table/to-tf.js +41 -2
  182. package/dist-sdk/src/entities/task/from-tf.js +2 -1
  183. package/dist-sdk/src/entities/view/from-tf.js +7 -4
  184. package/dist-sdk/src/entities/widget/from-tf.js +13 -2
  185. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +49 -4
  186. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  187. package/dist-sdk/src/graph/index.d.ts +5 -0
  188. package/dist-sdk/src/graph/index.js +7 -0
  189. package/dist-sdk/src/graph/modules.js +11 -1
  190. package/dist-sdk/src/graph/resource-types.d.ts +47 -0
  191. package/dist-sdk/src/graph/resource-types.js +62 -0
  192. package/dist-sdk/src/graph/types.d.ts +78 -6
  193. package/package.json +6 -3
@@ -9,11 +9,14 @@
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 { appScopedResourceLabel, exportLabelSuffix, isTfExpr, isUuid, scopedLabelToBagKey, tsLabelToTfLabel, } from "../../engine/tf/index.js";
12
+ import { appScopedResourceLabel, exportLabelSuffix, isTfExpr, isUuid, sanitizeName, scopedLabelToBagKey, tsLabelToTfLabel, } from "../../engine/tf/index.js";
13
+ import { filterFromTf } from "../access-policy/from-tf.js";
13
14
  import { a2aSkillFromTf } from "../agent-a2a-skill/from-tf.js";
14
15
  import { toolFromTf } from "../agent-tool/from-tf.js";
15
16
  import { agentToolBareLabel } from "../agent-tool/to-tf.js";
17
+ import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
16
18
  import { connectorIdentityFromTf } from "../shared/connector-from-tf.js";
19
+ import { resolveToolFieldKey } from "../shared/tool-field-ref.js";
17
20
  import { APP_RESOURCE_TYPE } from "../app/module.js";
18
21
  import { SKILL_RESOURCE_TYPE } from "../skill/module.js";
19
22
  import { AGENT_RESOURCE_TYPE } from "./module.js";
@@ -36,6 +39,7 @@ const KNOWN_AGENT_ATTRS = new Set([
36
39
  "type",
37
40
  "bedrock_agent_arn",
38
41
  "starting_actions",
42
+ "system_skills_config",
39
43
  ]);
40
44
  /** Dialect attrs with no authoring slot yet — reported by name, agent still pulled. */
41
45
  const UNAUTHORABLE_AGENT_ATTRS = new Set(["model"]);
@@ -362,7 +366,7 @@ function parseSkillAccessConfig(value, where, ownerTfLabel, ctx) {
362
366
  * diagnostic (the caller partitions per-agent by agent_id, but stays
363
367
  * defensive).
364
368
  */
365
- export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx, a2aSkillBlocks = []) {
369
+ export function agentFromTf(agentBlock, toolBlocks, appLabel, appRefName, ctx, a2aSkillBlocks = []) {
366
370
  const label = agentBlock.label;
367
371
  if (label === undefined || label === "") {
368
372
  throw new EntityTfError("elementum_agent block is missing its label");
@@ -419,6 +423,9 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx,
419
423
  if (attrs["starting_actions"] !== undefined) {
420
424
  ctx.diagnostics.push(`${where}: starting_actions has no authoring slot on bedrock agents yet; a rebuilt stream will omit it`);
421
425
  }
426
+ if (attrs["system_skills_config"] !== undefined) {
427
+ ctx.diagnostics.push(`${where}: system_skills_config is only authored on elementum agents; a rebuilt stream will omit it`);
428
+ }
422
429
  return {
423
430
  agent: {
424
431
  refName: scopedLabelToBagKey(appLabel, label),
@@ -474,6 +481,9 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx,
474
481
  const a2aStreaming = optionalBoolean(attrs, "a2a_streaming", where, ctx);
475
482
  const a2aCreateRecordEnabled = optionalBoolean(attrs, "a2a_create_record_enabled", where, ctx);
476
483
  const startingActions = attrs["starting_actions"] === undefined ? undefined : parseStartingActions(attrs["starting_actions"], where, ctx);
484
+ const systemSkillsConfig = attrs["system_skills_config"] === undefined
485
+ ? undefined
486
+ : parseSystemSkillsConfig(attrs["system_skills_config"], where, `${AGENT_RESOURCE_TYPE}.${label}`, appLabel, appRefName, ctx);
477
487
  const firstMessage = optionalString(attrs, "first_message", where, ctx);
478
488
  const maxTokens = attrs["max_tokens"];
479
489
  const maxLength = typeof maxTokens === "number" && Number.isSafeInteger(maxTokens) && maxTokens > 0
@@ -498,8 +508,258 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx,
498
508
  ...(a2aStreaming !== undefined && { a2aStreaming }),
499
509
  ...(a2aCreateRecordEnabled !== undefined && { a2aCreateRecordEnabled }),
500
510
  ...(startingActions !== undefined && { startingActions }),
511
+ ...(systemSkillsConfig !== undefined && { systemSkillsConfig }),
501
512
  tools,
502
513
  ...(a2aSkills.length > 0 && { a2aSkills }),
503
514
  },
504
515
  };
505
516
  }
517
+ function blockUnresolvableId(ctx, address, description) {
518
+ reportAuthoringBlocker(ctx, {
519
+ address,
520
+ description,
521
+ remedy: "Point each dynamic dropdown at an app or element and a field this export resolved to a reference, then pull again.",
522
+ ownFileKind: "agent",
523
+ });
524
+ }
525
+ function catalogRefForResourceLabel(label, kind, ctx) {
526
+ const byNamespace = kind === "app" ? ctx.foreignAppRefNamespaces : ctx.foreignElementRefNamespaces;
527
+ if (byNamespace === undefined)
528
+ return undefined;
529
+ const direct = byNamespace.get(label);
530
+ if (direct !== undefined)
531
+ return direct;
532
+ const matches = [...new Set([...byNamespace.entries()].filter(([namespace]) => sanitizeName(namespace) === label).map(([, refName]) => refName))];
533
+ return matches.length === 1 ? matches[0] : undefined;
534
+ }
535
+ function dropdownOwnerFromValue(value, appLabel, address, where, ctx) {
536
+ if (value === undefined) {
537
+ blockUnresolvableId(ctx, address, `${where}: aspect_id is missing, so pull cannot reproduce this dynamic dropdown.`);
538
+ return undefined;
539
+ }
540
+ if (resourceRefLabel(value, APP_RESOURCE_TYPE) === appLabel) {
541
+ return { owner: { kind: "app", refName: "", self: true }, fieldScopeLabel: appLabel, fieldScope: "app" };
542
+ }
543
+ for (const [type, kind] of [["elementum_app", "app"], ["elementum_element", "element"]]) {
544
+ const resourceLabel = resourceRefLabel(value, type);
545
+ if (resourceLabel === undefined)
546
+ continue;
547
+ const refName = catalogRefForResourceLabel(resourceLabel, kind, ctx);
548
+ if (refName === undefined) {
549
+ blockUnresolvableId(ctx, address, `${where}: aspect_id references ${type}.${resourceLabel}, which is not an app or element in this workspace.`);
550
+ return undefined;
551
+ }
552
+ const name = importedAspectName(ctx, kind, resourceLabel);
553
+ return {
554
+ owner: { kind, refName, ...(name !== undefined ? { name } : {}) },
555
+ fieldScopeLabel: resourceLabel,
556
+ fieldScope: kind,
557
+ };
558
+ }
559
+ if (isTfExpr(value) && value.$expr === "data-attr" && (value.type === "elementum_app" || value.type === "elementum_element")) {
560
+ const kind = value.type === "elementum_element" ? "element" : "app";
561
+ const target = resolveDataAspectTarget(ctx, kind, value.label);
562
+ if (target.catalogRef !== true) {
563
+ blockUnresolvableId(ctx, address, `${where}: aspect_id references data.${value.type}.${value.label}, which pull cannot name.`);
564
+ return undefined;
565
+ }
566
+ return {
567
+ owner: { kind, refName: target.key, ...(target.name !== "" ? { name: target.name } : {}) },
568
+ fieldScopeLabel: value.label,
569
+ fieldScope: kind,
570
+ };
571
+ }
572
+ const shown = typeof value === "string" ? value : JSON.stringify(value);
573
+ blockUnresolvableId(ctx, address, `${where}: aspect_id ${shown} is not a reference to an app or element.`);
574
+ return undefined;
575
+ }
576
+ function parseSystemSkillsConfig(value, where, address, appLabel, appRefName, ctx) {
577
+ const rec = plainObject(value);
578
+ if (rec === undefined) {
579
+ blockUnresolvableId(ctx, address, `${where}: system_skills_config has an unrecognized shape, so pull cannot reproduce it.`);
580
+ return undefined;
581
+ }
582
+ const ask = rec["ask_user_question"] === undefined
583
+ ? undefined
584
+ : parseAskUserQuestion(rec["ask_user_question"], `${where} ask_user_question`, address, appLabel, appRefName, ctx);
585
+ const approvals = rec["approvals"] === undefined
586
+ ? undefined
587
+ : parseSystemSkill(rec["approvals"], `${where} approvals`, address, ctx);
588
+ if (ask === null || approvals === null)
589
+ return undefined;
590
+ if (ask === undefined && approvals === undefined)
591
+ return undefined;
592
+ return {
593
+ ...(ask !== undefined ? { askUserQuestion: ask } : {}),
594
+ ...(approvals !== undefined ? { approvals } : {}),
595
+ };
596
+ }
597
+ function parseSystemSkill(value, where, address, ctx) {
598
+ const rec = plainObject(value);
599
+ if (rec === undefined) {
600
+ blockUnresolvableId(ctx, address, `${where} has an unrecognized shape, so pull cannot reproduce it.`);
601
+ return null;
602
+ }
603
+ if (typeof rec["enabled"] !== "boolean") {
604
+ blockUnresolvableId(ctx, address, `${where}.enabled is missing, so pull cannot reproduce it.`);
605
+ return null;
606
+ }
607
+ const description = typeof rec["description"] === "string" ? rec["description"] : undefined;
608
+ return { enabled: rec["enabled"], ...(description !== undefined ? { description } : {}) };
609
+ }
610
+ /**
611
+ * The field's name in this export. A resource block and a
612
+ * `data.elementum_field` lookup both carry it; a system-field local does not.
613
+ * This is the name the same pull writes into the catalog, including a
614
+ * `--no-adopt` pull whose name index still has the pre-rename name.
615
+ */
616
+ function exportedDropdownFieldName(fieldRef, ctx) {
617
+ if (fieldRef === undefined || !isTfExpr(fieldRef))
618
+ return undefined;
619
+ if (fieldRef.$expr === "resource-attr") {
620
+ const name = ctx.resourceByAddress?.(`${fieldRef.type}.${fieldRef.label}`)?.attrs["name"];
621
+ return typeof name === "string" && name !== "" ? name : undefined;
622
+ }
623
+ if (fieldRef.$expr === "data-attr" && fieldRef.type === "elementum_field") {
624
+ const name = ctx.dataAttrs?.("elementum_field", fieldRef.label)?.["name"];
625
+ return typeof name === "string" && name !== "" ? name : undefined;
626
+ }
627
+ return undefined;
628
+ }
629
+ /**
630
+ * True when build would send `storedName` anyway. The name in this export
631
+ * wins, compared exactly, so a case-only rename still prints `fieldName`.
632
+ * The name index is the fallback for a field with no name in the export.
633
+ * An owning-app dropdown stores its ref as `""`; looking that key up misses
634
+ * and must not count as a difference.
635
+ */
636
+ function storedNameIsCurrentDisplay(storedName, fieldKey, fieldRef, ownerRefName, ctx) {
637
+ const exported = exportedDropdownFieldName(fieldRef, ctx);
638
+ if (exported !== undefined)
639
+ return exported === storedName;
640
+ if (ownerRefName === "")
641
+ return true;
642
+ return ctx.fieldNamesByOwnerRefName?.get(ownerRefName)?.get(storedName.toLowerCase()) === fieldKey;
643
+ }
644
+ function unresolvedFilterId(value) {
645
+ if (value === null || typeof value !== "object")
646
+ return undefined;
647
+ if (Array.isArray(value)) {
648
+ for (const item of value) {
649
+ const found = unresolvedFilterId(item);
650
+ if (found !== undefined)
651
+ return found;
652
+ }
653
+ return undefined;
654
+ }
655
+ const record = value;
656
+ if (record.kind === "unresolved")
657
+ return typeof record.uuid === "string" ? record.uuid : "unknown";
658
+ for (const item of Object.values(record)) {
659
+ const found = unresolvedFilterId(item);
660
+ if (found !== undefined)
661
+ return found;
662
+ }
663
+ return undefined;
664
+ }
665
+ /**
666
+ * A `data.elementum_field` label back to the dropdown aspect's field key.
667
+ * `resolveToolFieldKey` already reads the dropdown's own `field_id` in this
668
+ * shape; a filter field on the same aspect arrives the same way, and without
669
+ * this the shared codec throws and the whole agent is dropped.
670
+ */
671
+ function dropdownFilterDataField(label, scope, ownerTfLabel, ownerRefName, ctx) {
672
+ const fieldKey = resolveToolFieldKey({ $expr: "data-attr", type: "elementum_field", label, path: ["id"] }, ownerTfLabel, scope, ctx);
673
+ return fieldKey === undefined ? undefined : { kind: "field", appHandle: ownerRefName, fieldKey };
674
+ }
675
+ /** A stored dropdown filter, or null when pull must stop rather than print a platform id. */
676
+ function dropdownFilterFromValue(value, scope, ownerTfLabel, ownerRefName, address, where, ctx) {
677
+ if (value === undefined)
678
+ return undefined;
679
+ let filter;
680
+ try {
681
+ filter = filterFromTf(value, {
682
+ type: scope === "element" ? "elementum_element" : "elementum_app",
683
+ label: ownerTfLabel,
684
+ ownerRefName,
685
+ ownerTfLabel,
686
+ scope,
687
+ foreignFieldRefsById: ctx.foreignFieldRefsById,
688
+ dataField: (label) => dropdownFilterDataField(label, scope, ownerTfLabel, ownerRefName, ctx),
689
+ }, `${where}.filter`, ctx, { optionLookupsAreIdentities: true });
690
+ }
691
+ catch (error) {
692
+ const message = error instanceof EntityTfError ? error.message : String(error);
693
+ blockUnresolvableId(ctx, address, `${where}.filter cannot be reproduced: ${message}`);
694
+ return null;
695
+ }
696
+ const unresolved = unresolvedFilterId(filter);
697
+ if (unresolved !== undefined) {
698
+ blockUnresolvableId(ctx, address, `${where}.filter field ${unresolved} is not a reference this export resolved, so pull cannot reproduce it.`);
699
+ return null;
700
+ }
701
+ return filter;
702
+ }
703
+ function parseAskUserQuestion(value, where, address, appLabel, appRefName, ctx) {
704
+ const skill = parseSystemSkill(value, where, address, ctx);
705
+ if (skill === null || skill === undefined)
706
+ return skill;
707
+ const rec = plainObject(value);
708
+ if (rec === undefined || rec["dynamic_dropdowns"] === undefined)
709
+ return skill;
710
+ if (!Array.isArray(rec["dynamic_dropdowns"])) {
711
+ blockUnresolvableId(ctx, address, `${where}.dynamic_dropdowns is not a list, so pull cannot reproduce it.`);
712
+ return null;
713
+ }
714
+ const dropdowns = [];
715
+ for (let i = 0; i < rec["dynamic_dropdowns"].length; i++) {
716
+ const item = rec["dynamic_dropdowns"][i];
717
+ if (item === undefined)
718
+ continue;
719
+ const rowWhere = `${where}.dynamic_dropdowns[${i}]`;
720
+ const row = plainObject(item);
721
+ if (row === undefined) {
722
+ blockUnresolvableId(ctx, address, `${rowWhere} has an unrecognized shape, so pull cannot reproduce it.`);
723
+ return null;
724
+ }
725
+ const owner = dropdownOwnerFromValue(row["aspect_id"], appLabel, address, rowWhere, ctx);
726
+ if (owner === undefined)
727
+ return null;
728
+ const fieldKey = resolveToolFieldKey(row["field_id"], owner.fieldScopeLabel, owner.fieldScope, ctx);
729
+ if (fieldKey === undefined) {
730
+ const shown = typeof row["field_id"] === "string" ? row["field_id"] : JSON.stringify(row["field_id"]);
731
+ blockUnresolvableId(ctx, address, `${rowWhere}.field_id ${shown} is not a reference to a field of that app or element, so pull cannot reproduce it.`);
732
+ return null;
733
+ }
734
+ if (typeof row["multiple"] !== "boolean" || typeof row["field"] !== "string" || row["field"] === "") {
735
+ blockUnresolvableId(ctx, address, `${rowWhere} is missing field or multiple, so pull cannot reproduce it.`);
736
+ return null;
737
+ }
738
+ if (isUuid(row["field"])) {
739
+ blockUnresolvableId(ctx, address, `${rowWhere}.field is a platform id, so pull cannot reproduce it.`);
740
+ return null;
741
+ }
742
+ const storedName = row["field"];
743
+ const ownerRefName = owner.owner.self === true ? appRefName : owner.owner.refName;
744
+ const matchesDisplayName = storedNameIsCurrentDisplay(storedName, fieldKey, row["field_id"], ownerRefName, ctx);
745
+ const filter = dropdownFilterFromValue(row["filter"], owner.fieldScope, owner.fieldScopeLabel, ownerRefName, address, rowWhere, ctx);
746
+ if (filter === null)
747
+ return null;
748
+ dropdowns.push({
749
+ owner: owner.owner,
750
+ fieldKey,
751
+ fieldName: storedName,
752
+ ...(matchesDisplayName ? {} : { storedFieldName: storedName }),
753
+ multiple: row["multiple"],
754
+ ...(filter !== undefined ? { filter } : {}),
755
+ });
756
+ }
757
+ return { ...skill, dynamicDropdowns: dropdowns };
758
+ }
759
+ function importedAspectName(ctx, kind, label) {
760
+ const type = kind === "element" ? "elementum_element" : "elementum_app";
761
+ const id = ctx.importId(`${type}.${label}`);
762
+ const imported = id === undefined ? undefined : ctx.importedResource?.(id);
763
+ const name = imported?.attrs["name"];
764
+ return typeof name === "string" && name !== "" ? name : undefined;
765
+ }
@@ -3,7 +3,7 @@
3
3
  * the deploy wire client injects) with `CatalogRef` tokens at every reference
4
4
  * position. Standalone from v1.
5
5
  */
6
- export { agent, bedrockAgent, type A2ASkill, type AgentAuthentication, type AgentConfigured, type AgentV2Options, type BedrockAgentOptions, agentStartingActionVariableType, type AgentStartingAction, type AgentStartingActionVariable, type AgentStartingActionVariableType, type SkillAccess, } from "./build.js";
6
+ export { agent, bedrockAgent, type A2ASkill, type AgentAuthentication, type AgentConfigured, type AgentV2Options, type BedrockAgentOptions, agentStartingActionVariableType, type AgentStartingAction, type AgentStartingActionVariable, type AgentStartingActionVariableType, type SkillAccess, type AgentAskUserQuestion, type AgentDynamicDropdown, type AgentSystemSkill, type AgentSystemSkillsConfig, } from "./build.js";
7
7
  export { agentCreateRecord, agentExecuteWorkflow, agentMcp, agentRelateRecord, agentRunAgent, agentRunAutomation, agentSearchRecords, agentSearchTable, agentUpdateRecord, type AgentExecuteWorkflowInput, type AgentExecuteWorkflowOutput, type RunAutomationInputs, type RunAutomationOptionalInput, type RunAutomationOutput, type RunAutomationOutputs, type RunAutomationRequiredInput, type RunAutomationToolV2, type AgentMcpHeader, type AgentRecordField, type AgentRecordFieldInput, type AgentRecordRawIdField, type AgentSearchField, type AgentSearchFieldInput, type AgentFilterVariable, type AgentSearchRawIdField, type AgentSearchReturnField, type AgentSearchReturnFieldInput, type AgentSearchRawIdReturnField, type AgentSearchTableField, type AgentSearchTableFieldInput, type AgentSearchTableRawIdField, type SearchTableToolV2, type AgentToolRunAs, type AgentTool, } from "./tools.js";
8
8
  export { serviceAccountRef, type ServiceAccountRef } from "./run-as.js";
9
9
  export * as filter from "../shared/filters/index.js";
@@ -46,17 +46,16 @@ export interface AgentToTfResult {
46
46
  readonly address: string;
47
47
  }
48
48
  /**
49
- * Mirrors ei's cross-agent a2a-skill-name disambiguation
50
- * (`cmd/elementum/export/imports.go`'s `a2aNames` counting map over
51
- * `app.AllAgents()`): a same-app, same-named a2a skill on two different
52
- * agents is not a collision on the platform — ei's exporter gives the
53
- * first occurrence of a sanitized name the bare label, each later
54
- * occurrence `_1`, `_2`, …
49
+ * The cross-agent a2a-skill-name numbering that ei's export copies
50
+ * (`a2aSkillImportBlocks` in `cmd/elementum/export/imports.go`, over one
51
+ * app's own agents only, edk#2508): a same-app, same-named a2a skill on two
52
+ * different agents is not a collision on the platform — the first agent to
53
+ * use a sanitized name gets the bare label, each later agent `_1`, `_2`, …
55
54
  *
56
55
  * The order is shared with ei: agent name by UTF-16 code unit, then (for
57
56
  * identical names) refName here and the agent's own label in ei, whose `_N`
58
- * tails sort alike. The Go comparator is in the a2a loop of
59
- * `cmd/elementum/export/imports.go` (`compareUTF16`, `agentChildParts`),
57
+ * tails sort alike. The Go comparator is in `a2aSkillImportBlocks`
58
+ * (`compareUTF16`, `agentChildParts`),
60
59
  * and the two must stay in sync; changing one without the other moves
61
60
  * `agent_id` and replaces skills on the first plan after a pull (edk#1728).
62
61
  * Before edk#1728 ei walked agents in id order.
@@ -76,8 +75,7 @@ export interface AgentToTfResult {
76
75
  * cross-agent counter), so an intra-agent duplicate still collides on one
77
76
  * address instead of silently acquiring a distinct label — that's a real
78
77
  * authoring mistake (two skills with the identical name on ONE agent),
79
- * still caught and dropped by `agentToTf`'s existing
80
- * `seenA2ASkillAddresses` check. Only DIFFERENT agents reusing a name are
78
+ * a build error from `agentToTf`'s `seenA2ASkillAddresses` check. Only DIFFERENT agents reusing a name are
81
79
  * the #294 case this disambiguates.
82
80
  */
83
81
  export declare function computeA2ASkillLabelSuffixes(siblingAgents: readonly DeployableEntity[]): ReadonlyMap<string, string>;
@@ -17,13 +17,15 @@
17
17
  */
18
18
  import { typedCoverageGap } from "../../engine/coverage-gaps.js";
19
19
  import { workspaceAspectKey } from "../../engine/build/context.js";
20
+ import { filterToTf } from "../access-policy/to-tf.js";
21
+ import { authoredFieldKeysFromPayload, fieldRefToTfValue } from "../field/to-tf.js";
20
22
  import { EntityTfError } from "../../engine/entity.js";
21
23
  import { appScopedResourceLabel, expr, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
22
24
  import { a2aSkillToTf } from "../agent-a2a-skill/to-tf.js";
23
25
  import { agentToolLabelSuffixes, assertUniqueToolAddresses, toolName, toolToTf } from "../agent-tool/to-tf.js";
24
26
  import { APP_RESOURCE_TYPE } from "../app/module.js";
25
27
  import { CONNECTOR_ORG_BAG } from "../org/connector.js";
26
- import { resolveForeignRef } from "../shared/foreign-ref.js";
28
+ import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
27
29
  import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "../service-account/module.js";
28
30
  import { SKILL_RESOURCE_TYPE } from "../skill/module.js";
29
31
  import { AGENT_RESOURCE_TYPE } from "./module.js";
@@ -248,17 +250,16 @@ function toSortableAgents(entities) {
248
250
  return out;
249
251
  }
250
252
  /**
251
- * Mirrors ei's cross-agent a2a-skill-name disambiguation
252
- * (`cmd/elementum/export/imports.go`'s `a2aNames` counting map over
253
- * `app.AllAgents()`): a same-app, same-named a2a skill on two different
254
- * agents is not a collision on the platform — ei's exporter gives the
255
- * first occurrence of a sanitized name the bare label, each later
256
- * occurrence `_1`, `_2`, …
253
+ * The cross-agent a2a-skill-name numbering that ei's export copies
254
+ * (`a2aSkillImportBlocks` in `cmd/elementum/export/imports.go`, over one
255
+ * app's own agents only, edk#2508): a same-app, same-named a2a skill on two
256
+ * different agents is not a collision on the platform — the first agent to
257
+ * use a sanitized name gets the bare label, each later agent `_1`, `_2`, …
257
258
  *
258
259
  * The order is shared with ei: agent name by UTF-16 code unit, then (for
259
260
  * identical names) refName here and the agent's own label in ei, whose `_N`
260
- * tails sort alike. The Go comparator is in the a2a loop of
261
- * `cmd/elementum/export/imports.go` (`compareUTF16`, `agentChildParts`),
261
+ * tails sort alike. The Go comparator is in `a2aSkillImportBlocks`
262
+ * (`compareUTF16`, `agentChildParts`),
262
263
  * and the two must stay in sync; changing one without the other moves
263
264
  * `agent_id` and replaces skills on the first plan after a pull (edk#1728).
264
265
  * Before edk#1728 ei walked agents in id order.
@@ -278,8 +279,7 @@ function toSortableAgents(entities) {
278
279
  * cross-agent counter), so an intra-agent duplicate still collides on one
279
280
  * address instead of silently acquiring a distinct label — that's a real
280
281
  * authoring mistake (two skills with the identical name on ONE agent),
281
- * still caught and dropped by `agentToTf`'s existing
282
- * `seenA2ASkillAddresses` check. Only DIFFERENT agents reusing a name are
282
+ * a build error from `agentToTf`'s `seenA2ASkillAddresses` check. Only DIFFERENT agents reusing a name are
283
283
  * the #294 case this disambiguates.
284
284
  */
285
285
  export function computeA2ASkillLabelSuffixes(siblingAgents) {
@@ -354,6 +354,145 @@ function skillIdValue(token, ctx) {
354
354
  ctx.orgRefs.foreignSkill(tfLabel, name, appId);
355
355
  return expr.dataAttr(SKILL_RESOURCE_TYPE, tfLabel, ["id"]);
356
356
  }
357
+ const ELEMENT_RESOURCE_TYPE = "elementum_element";
358
+ function dropdownAspect(token, kind, where, ctx) {
359
+ const refName = token.refName ?? "";
360
+ if (refName === "") {
361
+ throw new EntityTfError(`${where}: dynamic dropdown aspect has no refName`);
362
+ }
363
+ if (kind === "app" && refName === ctx.appRefName) {
364
+ const self = ctx.workspaceAspects?.get(workspaceAspectKey("app", refName));
365
+ return {
366
+ value: expr.resourceAttr(APP_RESOURCE_TYPE, ctx.appTfLabel, ["id"]),
367
+ localTfLabel: ctx.appTfLabel,
368
+ fieldOwnership: authoredFieldKeysFromPayload(self?.streamRootEntity?.payload),
369
+ };
370
+ }
371
+ const sibling = ctx.workspaceAspects?.get(workspaceAspectKey(kind, refName));
372
+ if (sibling !== undefined) {
373
+ const resourceType = kind === "element" ? ELEMENT_RESOURCE_TYPE : APP_RESOURCE_TYPE;
374
+ return {
375
+ value: expr.resourceAttr(resourceType, sibling.tfLabel, ["id"]),
376
+ localTfLabel: sibling.tfLabel,
377
+ fieldOwnership: authoredFieldKeysFromPayload(sibling.streamRootEntity?.payload),
378
+ };
379
+ }
380
+ const name = token.name ?? refName;
381
+ if (name === "") {
382
+ throw new EntityTfError(`${where}: dynamic dropdown ${kind} "${refName}" has no name to look up`);
383
+ }
384
+ const tfLabel = sanitizeName(token.namespace ?? name);
385
+ if (kind === "element") {
386
+ ctx.orgRefs.foreignElement(tfLabel, name, token.namespace);
387
+ return { value: expr.dataAttr(ELEMENT_RESOURCE_TYPE, tfLabel, ["id"]), foreignTfLabel: tfLabel };
388
+ }
389
+ ctx.orgRefs.foreignApp(tfLabel, name, token.namespace);
390
+ return { value: expr.dataAttr(APP_RESOURCE_TYPE, tfLabel, ["id"]), foreignTfLabel: tfLabel };
391
+ }
392
+ function dropdownFieldValue(field, aspect, where, ctx) {
393
+ const refName = field.refName ?? "";
394
+ if (refName === "") {
395
+ throw new EntityTfError(`${where}: dynamic dropdown field has no refName`);
396
+ }
397
+ if (field.parent !== undefined && (field.parent !== aspect.refName || (field.parentKind ?? "app") !== aspect.kind)) {
398
+ throw new EntityTfError(`${where}: field "${refName}" belongs to ${field.parentKind ?? "app"} "${field.parent}", not ${aspect.kind} "${aspect.refName}"`);
399
+ }
400
+ if (aspect.localTfLabel !== undefined) {
401
+ const value = fieldRefToTfValue(field.fieldType ?? "", refName, aspect.localTfLabel, aspect.kind, aspect.fieldOwnership);
402
+ if (value === undefined) {
403
+ throw new EntityTfError(`${where}: field "${refName}" has no terraform address on ${aspect.kind} "${aspect.refName}"`);
404
+ }
405
+ return value;
406
+ }
407
+ const fieldName = field.name ?? refName;
408
+ const ownerLabel = aspect.foreignTfLabel;
409
+ if (ownerLabel === undefined) {
410
+ throw new EntityTfError(`${where}: field "${refName}" has no lookup address on ${aspect.kind} "${aspect.refName}"`);
411
+ }
412
+ const dataLabel = foreignFieldDataLabel(aspect.kind, ownerLabel, fieldName);
413
+ ctx.orgRefs.foreignField("elementum_field", dataLabel, aspect.value, fieldName);
414
+ return expr.dataAttr("elementum_field", dataLabel, ["id"]);
415
+ }
416
+ function systemSkillValue(skill, where, ctx, withDropdowns) {
417
+ if (typeof skill.enabled !== "boolean") {
418
+ throw new EntityTfError(`${where}: enabled must be a boolean`);
419
+ }
420
+ const value = { enabled: skill.enabled };
421
+ if (skill.description !== undefined)
422
+ value["description"] = skill.description;
423
+ if (!withDropdowns)
424
+ return value;
425
+ if (skill.dynamicDropdowns === undefined)
426
+ return value;
427
+ value["dynamic_dropdowns"] = skill.dynamicDropdowns.map((row, index) => {
428
+ const rowWhere = `${where} dynamic dropdown ${index + 1}`;
429
+ const app = row.app;
430
+ const element = row.element;
431
+ if ((app === undefined) === (element === undefined)) {
432
+ throw new EntityTfError(`${rowWhere}: set exactly one of app or element`);
433
+ }
434
+ const kind = app !== undefined ? "app" : "element";
435
+ const token = app ?? element;
436
+ if (token === undefined)
437
+ throw new EntityTfError(`${rowWhere}: set exactly one of app or element`);
438
+ const aspect = dropdownAspect(token, kind, rowWhere, ctx);
439
+ const field = row.field;
440
+ if (field === undefined)
441
+ throw new EntityTfError(`${rowWhere}: field is required`);
442
+ if (typeof row.multiple !== "boolean")
443
+ throw new EntityTfError(`${rowWhere}: multiple must be a boolean`);
444
+ const fieldName = row.fieldName ?? field.name ?? field.refName ?? "";
445
+ if (fieldName === "")
446
+ throw new EntityTfError(`${rowWhere}: field has no name`);
447
+ const aspectRef = {
448
+ refName: token.refName ?? "",
449
+ kind,
450
+ value: aspect.value,
451
+ localTfLabel: aspect.localTfLabel,
452
+ foreignTfLabel: aspect.foreignTfLabel,
453
+ fieldOwnership: aspect.fieldOwnership,
454
+ };
455
+ const dropdown = {
456
+ aspect_id: aspect.value,
457
+ field: fieldName,
458
+ field_id: dropdownFieldValue(field, aspectRef, rowWhere, ctx),
459
+ multiple: row.multiple,
460
+ };
461
+ if (row.filter !== undefined) {
462
+ const local = aspect.localTfLabel !== undefined;
463
+ // An in-workspace aspect addresses its own fields as resources and
464
+ // system-field locals. A data-source aspect has neither: its fields go
465
+ // through foreignField (`ownerFieldsThroughForeign`) and come out as
466
+ // `data.elementum_field` lookups, while `ownerRefName` stays the real
467
+ // refName so `filter.textOption` still sees them as this aspect's.
468
+ dropdown["filter"] = filterToTf(row.filter, `${rowWhere} filter`, {
469
+ ownerTfLabel: local ? aspect.localTfLabel ?? "" : aspect.foreignTfLabel ?? aspectRef.refName,
470
+ ownerRefName: aspectRef.refName,
471
+ scope: kind,
472
+ objectId: aspect.value,
473
+ diagnostics: ctx.diagnostics,
474
+ fieldAddresses: aspect.fieldOwnership,
475
+ ...(local ? {} : { resolvePicklistLiterals: false, ownerFieldsThroughForeign: true }),
476
+ foreignField: (_fieldToken, fieldWhere) => dropdownFieldValue(_fieldToken, aspectRef, fieldWhere, ctx),
477
+ });
478
+ }
479
+ return dropdown;
480
+ });
481
+ return value;
482
+ }
483
+ function systemSkillsValue(config, where, ctx) {
484
+ const value = {};
485
+ if (config.askUserQuestion !== undefined) {
486
+ value["ask_user_question"] = systemSkillValue(config.askUserQuestion, `${where} askUserQuestion`, ctx, true);
487
+ }
488
+ if (config.approvals !== undefined) {
489
+ value["approvals"] = systemSkillValue(config.approvals, `${where} approvals`, ctx, false);
490
+ }
491
+ if (Object.keys(value).length === 0) {
492
+ throw new EntityTfError(`${where}: systemSkillsConfig has neither askUserQuestion nor approvals`);
493
+ }
494
+ return value;
495
+ }
357
496
  /** `elementum_agent` + one tool resource per implemented tool, in ei's dialect. */
358
497
  export function agentToTf(entity, ctx) {
359
498
  if (entity.kind !== "agent") {
@@ -457,6 +596,9 @@ export function agentToTf(entity, ctx) {
457
596
  ctx.diagnostics.push(`${where}: ${knob} is not carried by the terraform path yet; dropped (apply leaves the agent's live ${knob} unchanged)`);
458
597
  }
459
598
  }
599
+ if (elementum.systemSkillsConfig !== undefined) {
600
+ attrs["system_skills_config"] = systemSkillsValue(elementum.systemSkillsConfig, where, ctx);
601
+ }
460
602
  const skillAccess = elementum.skillAccessConfig;
461
603
  if (skillAccess !== undefined) {
462
604
  const mode = skillAccess.mode ?? "NONE";
@@ -522,7 +664,7 @@ export function agentToTf(entity, ctx) {
522
664
  // disambiguates that case with a numeric suffix rather than rejecting it
523
665
  // (see computeA2ASkillLabelSuffixes). A collision within THIS agent's own
524
666
  // a2aSkills list (the same name twice on one agent) is a real authoring
525
- // mistake, not a cross-agent scoping gap — still caught and dropped below.
667
+ // mistake, not a cross-agent scoping gap — a build error below.
526
668
  const a2aSkillLabelSuffixes = computeA2ASkillLabelSuffixes(ctx.siblingEntities ?? [entity]);
527
669
  const seenA2ASkillAddresses = new Set();
528
670
  payload.a2aSkills?.forEach((entry) => {
@@ -536,8 +678,10 @@ export function agentToTf(entity, ctx) {
536
678
  if (skill === undefined)
537
679
  return;
538
680
  if (seenA2ASkillAddresses.has(skill.address)) {
539
- ctx.diagnostics.push(`${where}: a2a skill "${entry.name}" collides with another skill's label (${skill.address}) — names must be unique per agent; dropped`);
540
- return;
681
+ // Dropping it would delete a live skill on the next apply (edk#2508).
682
+ throw new EntityTfError(`${where}: two a2a skills named like ${JSON.stringify(entry.name)} both get the address ${skill.address} ` +
683
+ "(the label lowercases a name, splits camelCase and turns spaces, hyphens and other punctuation into `_`, so names such as \"AskBot\" and \"Ask Bot\" share one). " +
684
+ "A2A skill names must be unique per agent; rename one of them.");
541
685
  }
542
686
  seenA2ASkillAddresses.add(skill.address);
543
687
  blocks.push(skill.block);
@@ -441,6 +441,12 @@ function executeWorkflowFromTf(block, name, where, owner, ctx) {
441
441
  : undefined;
442
442
  if (autoLabel === undefined) {
443
443
  ctx.diagnostics.push(`${where}: automation_id is not an automation/workflow_publish resource reference (${JSON.stringify(autoRef)}); skipped`);
444
+ if (typeof autoRef === "string" && block.type !== undefined && block.label !== undefined) {
445
+ // A raw id: the export left the automation out, so no source can manage
446
+ // the tool. Release an earlier adoption rather than destroy it (#2525).
447
+ ctx.skipped.push(`${block.type}.${block.label}`);
448
+ ctx.releaseIfManaged?.push(`${block.type}.${block.label}`);
449
+ }
444
450
  return undefined;
445
451
  }
446
452
  const inputs = [];
@@ -68,8 +68,8 @@ export declare function agentToolBareLabel(agentBareTfLabel: string, toolName: s
68
68
  * tool's order is part of its address. Pull pins every tool ei suffixed
69
69
  * (agentFromTf), so a pulled agent rebuilds its exported labels even when ei
70
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).
71
+ * or not, as in ei. ei counts per agent too, keyed on the agent's label, so
72
+ * another agent's tools never shift these (edk#2000).
73
73
  */
74
74
  export declare function agentToolLabelSuffixes(agentBareTfLabel: string, tools: readonly Record<string, unknown>[]): readonly string[];
75
75
  /** A tool entry's (`{ createRecord: { name, ... } }`) platform name, or "". */
@@ -178,8 +178,8 @@ export function agentToolBareLabel(agentBareTfLabel, toolName, labelSuffix) {
178
178
  * tool's order is part of its address. Pull pins every tool ei suffixed
179
179
  * (agentFromTf), so a pulled agent rebuilds its exported labels even when ei
180
180
  * counted a tool pull doesn't print. Every known tool kind counts, implemented
181
- * or not, as in ei. Parity holds within one agent only: ei's counter spans
182
- * the whole app and is keyed on the agent's display name (edk#2000).
181
+ * or not, as in ei. ei counts per agent too, keyed on the agent's label, so
182
+ * another agent's tools never shift these (edk#2000).
183
183
  */
184
184
  export function agentToolLabelSuffixes(agentBareTfLabel, tools) {
185
185
  return collisionLabelSuffixes(tools.map((entry) => {