@elementumai/edk 0.12.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/README.md +8 -2
  2. package/dist-sdk/src/catalog/factories.d.ts +7 -1
  3. package/dist-sdk/src/catalog/factories.js +10 -2
  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 +12 -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/coverage-gaps.d.ts +2 -0
  15. package/dist-sdk/src/engine/coverage-gaps.js +4 -0
  16. package/dist-sdk/src/engine/ei/run.d.ts +8 -0
  17. package/dist-sdk/src/engine/ei/run.js +46 -7
  18. package/dist-sdk/src/engine/pull/authored-address.js +42 -6
  19. package/dist-sdk/src/engine/pull/authored-root.d.ts +88 -0
  20. package/dist-sdk/src/engine/pull/authored-root.js +306 -0
  21. package/dist-sdk/src/engine/pull/context.d.ts +34 -0
  22. package/dist-sdk/src/engine/pull/field-refs-registry.d.ts +114 -0
  23. package/dist-sdk/src/engine/pull/field-refs-registry.js +501 -0
  24. package/dist-sdk/src/engine/pull/org.d.ts +1 -0
  25. package/dist-sdk/src/engine/pull/org.js +2 -0
  26. package/dist-sdk/src/engine/pull/partition.d.ts +8 -0
  27. package/dist-sdk/src/engine/pull/partition.js +43 -0
  28. package/dist-sdk/src/engine/pull/pulled-roots.d.ts +89 -0
  29. package/dist-sdk/src/engine/pull/pulled-roots.js +203 -0
  30. package/dist-sdk/src/engine/pull/ref-only.d.ts +4 -0
  31. package/dist-sdk/src/engine/pull/ref-only.js +7 -1
  32. package/dist-sdk/src/engine/pull/source-resources.d.ts +39 -0
  33. package/dist-sdk/src/engine/pull/source-resources.js +110 -0
  34. package/dist-sdk/src/engine/pull/stream-root.d.ts +159 -0
  35. package/dist-sdk/src/engine/pull/stream-root.js +579 -0
  36. package/dist-sdk/src/engine/workspace/authoring-layout.js +16 -2
  37. package/dist-sdk/src/engine/workspace/reserved-catalog-keys.d.ts +47 -0
  38. package/dist-sdk/src/engine/workspace/reserved-catalog-keys.js +115 -0
  39. package/dist-sdk/src/entities/access-policy/build.d.ts +2 -1
  40. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
  41. package/dist-sdk/src/entities/access-policy/from-tf.js +17 -5
  42. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +19 -0
  43. package/dist-sdk/src/entities/access-policy/to-tf.js +65 -8
  44. package/dist-sdk/src/entities/agent/build.d.ts +52 -1
  45. package/dist-sdk/src/entities/agent/build.js +34 -0
  46. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +70 -1
  47. package/dist-sdk/src/entities/agent/from-tf.d.ts +36 -1
  48. package/dist-sdk/src/entities/agent/from-tf.js +289 -2
  49. package/dist-sdk/src/entities/agent/index.d.ts +1 -1
  50. package/dist-sdk/src/entities/agent/module.js +1 -0
  51. package/dist-sdk/src/entities/agent/to-tf.d.ts +11 -11
  52. package/dist-sdk/src/entities/agent/to-tf.js +179 -17
  53. package/dist-sdk/src/entities/agent-tool/from-tf.js +6 -0
  54. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
  55. package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -2
  56. package/dist-sdk/src/entities/app/build.d.ts +33 -13
  57. package/dist-sdk/src/entities/app/build.js +14 -12
  58. package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
  59. package/dist-sdk/src/entities/app/from-tf.js +7 -9
  60. package/dist-sdk/src/entities/app/index.d.ts +1 -0
  61. package/dist-sdk/src/entities/app/index.js +1 -0
  62. package/dist-sdk/src/entities/app/module.js +3 -0
  63. package/dist-sdk/src/entities/app/stage-keys.d.ts +2 -2
  64. package/dist-sdk/src/entities/app/stage-keys.js +3 -3
  65. package/dist-sdk/src/entities/app/to-tf.js +1 -0
  66. package/dist-sdk/src/entities/approval-chain/build.d.ts +46 -11
  67. package/dist-sdk/src/entities/approval-chain/build.js +120 -8
  68. package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +24 -2
  69. package/dist-sdk/src/entities/approval-chain/from-tf.js +148 -6
  70. package/dist-sdk/src/entities/approval-chain/index.d.ts +4 -1
  71. package/dist-sdk/src/entities/approval-chain/index.js +4 -1
  72. package/dist-sdk/src/entities/approval-chain/module.js +23 -5
  73. package/dist-sdk/src/entities/approval-chain/printer.d.ts +1 -1
  74. package/dist-sdk/src/entities/approval-chain/printer.js +91 -5
  75. package/dist-sdk/src/entities/approval-chain/steps-tf.d.ts +77 -0
  76. package/dist-sdk/src/entities/approval-chain/steps-tf.js +255 -0
  77. package/dist-sdk/src/entities/approval-chain/steps.d.ts +71 -0
  78. package/dist-sdk/src/entities/approval-chain/steps.js +83 -0
  79. package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +16 -6
  80. package/dist-sdk/src/entities/approval-chain/to-tf.js +37 -4
  81. package/dist-sdk/src/entities/automation/build.d.ts +10 -1
  82. package/dist-sdk/src/entities/automation/build.js +70 -27
  83. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +21 -5
  84. package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -5
  85. package/dist-sdk/src/entities/automation/from-tf.js +665 -112
  86. package/dist-sdk/src/entities/automation/index.d.ts +2 -1
  87. package/dist-sdk/src/entities/automation/index.js +1 -0
  88. package/dist-sdk/src/entities/automation/module.d.ts +4 -3
  89. package/dist-sdk/src/entities/automation/module.js +45 -12
  90. package/dist-sdk/src/entities/automation/refs-read.d.ts +19 -0
  91. package/dist-sdk/src/entities/automation/refs-read.js +48 -0
  92. package/dist-sdk/src/entities/automation/slack-message-refs.d.ts +9 -0
  93. package/dist-sdk/src/entities/automation/slack-message-refs.js +75 -0
  94. package/dist-sdk/src/entities/automation/system-ref-name.d.ts +23 -3
  95. package/dist-sdk/src/entities/automation/system-ref-name.js +86 -4
  96. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +11 -0
  97. package/dist-sdk/src/entities/automation/task-output-labels.js +23 -0
  98. package/dist-sdk/src/entities/automation/tasks.d.ts +29 -4
  99. package/dist-sdk/src/entities/automation/tasks.js +34 -11
  100. package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -1
  101. package/dist-sdk/src/entities/automation/to-tf.js +563 -103
  102. package/dist-sdk/src/entities/automation/triggers.d.ts +0 -8
  103. package/dist-sdk/src/entities/automation/triggers.js +26 -11
  104. package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +50 -0
  105. package/dist-sdk/src/entities/automation/unsafe-script-output.js +92 -0
  106. package/dist-sdk/src/entities/chart/build.d.ts +9 -1
  107. package/dist-sdk/src/entities/chart/from-tf.js +3 -0
  108. package/dist-sdk/src/entities/chart/to-tf.js +19 -2
  109. package/dist-sdk/src/entities/dashboard/from-tf.d.ts +3 -1
  110. package/dist-sdk/src/entities/dashboard/from-tf.js +42 -2
  111. package/dist-sdk/src/entities/dashboard/to-tf.js +9 -1
  112. package/dist-sdk/src/entities/dashboard-widget-order/module.d.ts +10 -0
  113. package/dist-sdk/src/entities/dashboard-widget-order/module.js +25 -0
  114. package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +31 -0
  115. package/dist-sdk/src/entities/dashboard-widget-order/order.js +102 -0
  116. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +2 -0
  117. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +44 -5
  118. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +46 -12
  119. package/dist-sdk/src/entities/element/audit-field-guard.d.ts +9 -0
  120. package/dist-sdk/src/entities/element/audit-field-guard.js +88 -0
  121. package/dist-sdk/src/entities/element/build.js +2 -1
  122. package/dist-sdk/src/entities/element/from-tf.d.ts +1 -0
  123. package/dist-sdk/src/entities/element/from-tf.js +4 -7
  124. package/dist-sdk/src/entities/element/module.js +5 -0
  125. package/dist-sdk/src/entities/element/system-fields.d.ts +13 -0
  126. package/dist-sdk/src/entities/element/system-fields.js +23 -0
  127. package/dist-sdk/src/entities/element/to-tf.js +1 -0
  128. package/dist-sdk/src/entities/field/build.d.ts +9 -0
  129. package/dist-sdk/src/entities/field/from-tf.d.ts +52 -1
  130. package/dist-sdk/src/entities/field/from-tf.js +212 -14
  131. package/dist-sdk/src/entities/field/module.js +4 -0
  132. package/dist-sdk/src/entities/field/to-tf.d.ts +5 -1
  133. package/dist-sdk/src/entities/field/to-tf.js +33 -12
  134. package/dist-sdk/src/entities/org/category.js +1 -0
  135. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  136. package/dist-sdk/src/entities/org/index.js +1 -0
  137. package/dist-sdk/src/entities/org/voice-auth.d.ts +5 -0
  138. package/dist-sdk/src/entities/org/voice-auth.js +33 -0
  139. package/dist-sdk/src/entities/organization/build.d.ts +3 -0
  140. package/dist-sdk/src/entities/organization/build.js +2 -0
  141. package/dist-sdk/src/entities/organization/index.d.ts +1 -0
  142. package/dist-sdk/src/entities/organization/index.js +1 -0
  143. package/dist-sdk/src/entities/organization/to-tf.d.ts +2 -0
  144. package/dist-sdk/src/entities/organization/to-tf.js +59 -1
  145. package/dist-sdk/src/entities/organization/voice-auth.d.ts +60 -0
  146. package/dist-sdk/src/entities/organization/voice-auth.js +60 -0
  147. package/dist-sdk/src/entities/phone-service/build.d.ts +9 -1
  148. package/dist-sdk/src/entities/phone-service/build.js +1 -0
  149. package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +3 -0
  150. package/dist-sdk/src/entities/phone-service/from-tf.d.ts +1 -0
  151. package/dist-sdk/src/entities/phone-service/from-tf.js +8 -1
  152. package/dist-sdk/src/entities/phone-service/to-tf.js +16 -0
  153. package/dist-sdk/src/entities/record-create-form/from-tf.js +2 -2
  154. package/dist-sdk/src/entities/relationship/from-tf.js +9 -4
  155. package/dist-sdk/src/entities/relationship/module.js +2 -2
  156. package/dist-sdk/src/entities/relationship/pair-check.d.ts +6 -2
  157. package/dist-sdk/src/entities/relationship/pair-check.js +105 -18
  158. package/dist-sdk/src/entities/relationship/to-tf.js +5 -2
  159. package/dist-sdk/src/entities/role/build.d.ts +3 -4
  160. package/dist-sdk/src/entities/role/permission-levels.d.ts +7 -0
  161. package/dist-sdk/src/entities/role/permission-levels.js +78 -0
  162. package/dist-sdk/src/entities/role/to-tf.js +32 -2
  163. package/dist-sdk/src/entities/search-table/build.d.ts +9 -3
  164. package/dist-sdk/src/entities/search-table/build.js +4 -4
  165. package/dist-sdk/src/entities/search-table/printer.js +3 -1
  166. package/dist-sdk/src/entities/search-table/to-tf.js +20 -2
  167. package/dist-sdk/src/entities/service-account/module.d.ts +2 -1
  168. package/dist-sdk/src/entities/service-account/module.js +4 -1
  169. package/dist-sdk/src/entities/service-account/resource-type.d.ts +2 -0
  170. package/dist-sdk/src/entities/service-account/resource-type.js +2 -0
  171. package/dist-sdk/src/entities/service-account/role-membership-check.d.ts +20 -0
  172. package/dist-sdk/src/entities/service-account/role-membership-check.js +80 -0
  173. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +15 -0
  174. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +36 -0
  175. package/dist-sdk/src/entities/shared/context.d.ts +14 -1
  176. package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
  177. package/dist-sdk/src/entities/shared/filters/index.d.ts +97 -15
  178. package/dist-sdk/src/entities/shared/filters/index.js +30 -7
  179. package/dist-sdk/src/entities/shared/filters/option-lookups.d.ts +57 -0
  180. package/dist-sdk/src/entities/shared/filters/option-lookups.js +108 -0
  181. package/dist-sdk/src/entities/shared/filters/print.d.ts +2 -0
  182. package/dist-sdk/src/entities/shared/filters/print.js +19 -6
  183. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +16 -7
  184. package/dist-sdk/src/entities/shared/filters/tf-codec.js +25 -5
  185. package/dist-sdk/src/entities/shared/filters/types.d.ts +4 -0
  186. package/dist-sdk/src/entities/shared/raw-option-id.d.ts +30 -0
  187. package/dist-sdk/src/entities/shared/raw-option-id.js +41 -0
  188. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
  189. package/dist-sdk/src/entities/shared/tool-field-ref.js +3 -2
  190. package/dist-sdk/src/entities/skill/input-coverage.js +5 -2
  191. package/dist-sdk/src/entities/sla/build.d.ts +96 -0
  192. package/dist-sdk/src/entities/sla/build.js +124 -0
  193. package/dist-sdk/src/entities/sla/from-tf.d.ts +40 -0
  194. package/dist-sdk/src/entities/sla/from-tf.js +164 -0
  195. package/dist-sdk/src/entities/sla/index.d.ts +1 -0
  196. package/dist-sdk/src/entities/sla/index.js +1 -0
  197. package/dist-sdk/src/entities/sla/module.d.ts +4 -0
  198. package/dist-sdk/src/entities/sla/module.js +73 -0
  199. package/dist-sdk/src/entities/sla/printer.d.ts +2 -0
  200. package/dist-sdk/src/entities/sla/printer.js +84 -0
  201. package/dist-sdk/src/entities/sla/to-tf.d.ts +12 -0
  202. package/dist-sdk/src/entities/sla/to-tf.js +81 -0
  203. package/dist-sdk/src/entities/table/build.d.ts +7 -2
  204. package/dist-sdk/src/entities/table/build.js +22 -1
  205. package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +4 -1
  206. package/dist-sdk/src/entities/table/from-tf.js +89 -14
  207. package/dist-sdk/src/entities/table/index.d.ts +1 -1
  208. package/dist-sdk/src/entities/table/to-tf.js +41 -2
  209. package/dist-sdk/src/entities/task/from-tf.js +3 -2
  210. package/dist-sdk/src/entities/view/custom-view-validate.d.ts +6 -4
  211. package/dist-sdk/src/entities/view/custom-view-validate.js +36 -18
  212. package/dist-sdk/src/entities/view/from-tf.js +16 -4
  213. package/dist-sdk/src/entities/view/to-tf.js +66 -47
  214. package/dist-sdk/src/entities/visual-flow/module.js +52 -1
  215. package/dist-sdk/src/entities/widget/from-tf.js +19 -8
  216. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +49 -4
  217. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  218. package/dist-sdk/src/graph/index.d.ts +9 -0
  219. package/dist-sdk/src/graph/index.js +8 -0
  220. package/dist-sdk/src/graph/modules.js +13 -1
  221. package/dist-sdk/src/graph/resource-types.d.ts +47 -0
  222. package/dist-sdk/src/graph/resource-types.js +62 -0
  223. package/dist-sdk/src/graph/types.d.ts +113 -6
  224. package/package.json +7 -4
@@ -10,6 +10,8 @@ import { type FromTfContext } from "../../engine/pull/context.js";
10
10
  import { type TfBlock } from "../../engine/tf/index.js";
11
11
  import { type NormalizedA2ASkill } from "../agent-a2a-skill/from-tf.js";
12
12
  import { type NormalizedAgentTool } from "../agent-tool/from-tf.js";
13
+ import type { RefExpr } from "../shared/filters/ast.js";
14
+ import type { Filter } from "../shared/filters/types.js";
13
15
  import type { AgentAuthentication, AgentStartingAction } from "./build.js";
14
16
  import type { AgentToolRunAs } from "./tools.js";
15
17
  /**
@@ -24,6 +26,8 @@ export type NormalizedSkillRef = {
24
26
  readonly kind: "foreign";
25
27
  readonly name: string;
26
28
  readonly appName: string;
29
+ /** The owner's namespace, when ei looked the owner up by it (edk#2919). */
30
+ readonly appNamespace?: string;
27
31
  readonly appRefName?: string;
28
32
  readonly key?: string;
29
33
  } | {
@@ -57,6 +61,7 @@ export interface NormalizedAgent {
57
61
  readonly a2aStreaming?: boolean;
58
62
  readonly a2aCreateRecordEnabled?: boolean;
59
63
  readonly startingActions?: readonly AgentStartingAction[];
64
+ readonly systemSkillsConfig?: NormalizedSystemSkillsConfig;
60
65
  readonly tools: readonly NormalizedAgentTool[];
61
66
  readonly a2aSkills?: readonly NormalizedA2ASkill[];
62
67
  }
@@ -71,4 +76,34 @@ export interface AgentFromTfResult {
71
76
  * diagnostic (the caller partitions per-agent by agent_id, but stays
72
77
  * defensive).
73
78
  */
74
- export declare function agentFromTf(agentBlock: TfBlock, toolBlocks: readonly TfBlock[], appLabel: string, _appRefName: string, ctx: FromTfContext, a2aSkillBlocks?: readonly TfBlock[]): AgentFromTfResult;
79
+ export declare function agentFromTf(agentBlock: TfBlock, toolBlocks: readonly TfBlock[], appLabel: string, appRefName: string, ctx: FromTfContext, a2aSkillBlocks?: readonly TfBlock[]): AgentFromTfResult;
80
+ export interface NormalizedDropdownOwner {
81
+ readonly kind: "app" | "element";
82
+ readonly refName: string;
83
+ /** Display name. A cross-org clone prints this instead of the catalog key. */
84
+ readonly name?: string;
85
+ /** This agent's owning app. The printer uses the pull's app refName. */
86
+ readonly self?: boolean;
87
+ }
88
+ export interface NormalizedDynamicDropdown {
89
+ readonly owner: NormalizedDropdownOwner;
90
+ readonly fieldKey: string;
91
+ /** Platform display name (`field` on the wire). */
92
+ readonly fieldName: string;
93
+ /** Set when the stored name is not the field's name in this export. */
94
+ readonly storedFieldName?: string;
95
+ readonly multiple: boolean;
96
+ /** Present when the dropdown limits its records. */
97
+ readonly filter?: Filter<RefExpr, RefExpr>;
98
+ }
99
+ export interface NormalizedSystemSkill {
100
+ readonly enabled: boolean;
101
+ readonly description?: string;
102
+ }
103
+ export interface NormalizedAskUserQuestion extends NormalizedSystemSkill {
104
+ readonly dynamicDropdowns?: readonly NormalizedDynamicDropdown[];
105
+ }
106
+ export interface NormalizedSystemSkillsConfig {
107
+ readonly askUserQuestion?: NormalizedAskUserQuestion;
108
+ readonly approvals?: NormalizedSystemSkill;
109
+ }
@@ -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 { dataAspectDisplayName, dataAspectRefName, 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"]);
@@ -73,6 +77,33 @@ function parseSkillRef(item, where, ownerTfLabel, ctx) {
73
77
  const owner = ownerId === undefined ? undefined : ctx.importedResource?.(ownerId);
74
78
  appName = typeof owner?.attrs["name"] === "string" ? owner.attrs["name"] : undefined;
75
79
  }
80
+ // ei looks another app up by namespace alone (`data "elementum_app" { namespace }`),
81
+ // as for a service account's owner (#2197). The namespace is unique where
82
+ // a display name is not, so it alone picks the owner and its catalog
83
+ // skill (edk#2919).
84
+ const appNamespace = appName === undefined && appDataLabel !== undefined
85
+ ? ctx.dataAttrs?.(APP_RESOURCE_TYPE, appDataLabel)?.["namespace"]
86
+ : undefined;
87
+ if (typeof appNamespace === "string" && appNamespace !== "" && appDataLabel !== undefined) {
88
+ const catalogSkill = ctx.foreignSkillRefsByOwnerNamespace?.get(JSON.stringify([appNamespace, name]));
89
+ const ownerInWorkspace = ctx.foreignAppRefNamespaces?.get(appNamespace) !== undefined;
90
+ if (catalogSkill === undefined && !ownerInWorkspace) {
91
+ ctx.diagnostics.push(`${where}: data.${SKILL_RESOURCE_TYPE}.${item.label}: owner namespace "${appNamespace}" is not in the workspace or the export's ref-only catalog; ` +
92
+ "kept as a literal skill token looked up by that namespace — pull that app and re-pull for a catalog token");
93
+ }
94
+ // The workspace app with this namespace; else the namespace's catalog
95
+ // key, which is the app's refName once it is pulled.
96
+ const appRefName = dataAspectRefName(ctx, "app", appDataLabel);
97
+ return {
98
+ kind: "foreign",
99
+ name,
100
+ appName: dataAspectDisplayName(ctx, "app", appDataLabel) ?? appNamespace,
101
+ appNamespace,
102
+ ...(catalogSkill !== undefined
103
+ ? { appRefName: catalogSkill.appRefName, key: catalogSkill.skillRefName }
104
+ : appRefName !== undefined ? { appRefName } : {}),
105
+ };
106
+ }
76
107
  if (appName === undefined) {
77
108
  ctx.diagnostics.push(`${where}: data.${SKILL_RESOURCE_TYPE}.${item.label} has no resolvable app_id owner; dropped`);
78
109
  return undefined;
@@ -362,7 +393,7 @@ function parseSkillAccessConfig(value, where, ownerTfLabel, ctx) {
362
393
  * diagnostic (the caller partitions per-agent by agent_id, but stays
363
394
  * defensive).
364
395
  */
365
- export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx, a2aSkillBlocks = []) {
396
+ export function agentFromTf(agentBlock, toolBlocks, appLabel, appRefName, ctx, a2aSkillBlocks = []) {
366
397
  const label = agentBlock.label;
367
398
  if (label === undefined || label === "") {
368
399
  throw new EntityTfError("elementum_agent block is missing its label");
@@ -419,6 +450,9 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx,
419
450
  if (attrs["starting_actions"] !== undefined) {
420
451
  ctx.diagnostics.push(`${where}: starting_actions has no authoring slot on bedrock agents yet; a rebuilt stream will omit it`);
421
452
  }
453
+ if (attrs["system_skills_config"] !== undefined) {
454
+ ctx.diagnostics.push(`${where}: system_skills_config is only authored on elementum agents; a rebuilt stream will omit it`);
455
+ }
422
456
  return {
423
457
  agent: {
424
458
  refName: scopedLabelToBagKey(appLabel, label),
@@ -474,6 +508,9 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx,
474
508
  const a2aStreaming = optionalBoolean(attrs, "a2a_streaming", where, ctx);
475
509
  const a2aCreateRecordEnabled = optionalBoolean(attrs, "a2a_create_record_enabled", where, ctx);
476
510
  const startingActions = attrs["starting_actions"] === undefined ? undefined : parseStartingActions(attrs["starting_actions"], where, ctx);
511
+ const systemSkillsConfig = attrs["system_skills_config"] === undefined
512
+ ? undefined
513
+ : parseSystemSkillsConfig(attrs["system_skills_config"], where, `${AGENT_RESOURCE_TYPE}.${label}`, appLabel, appRefName, ctx);
477
514
  const firstMessage = optionalString(attrs, "first_message", where, ctx);
478
515
  const maxTokens = attrs["max_tokens"];
479
516
  const maxLength = typeof maxTokens === "number" && Number.isSafeInteger(maxTokens) && maxTokens > 0
@@ -498,8 +535,258 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx,
498
535
  ...(a2aStreaming !== undefined && { a2aStreaming }),
499
536
  ...(a2aCreateRecordEnabled !== undefined && { a2aCreateRecordEnabled }),
500
537
  ...(startingActions !== undefined && { startingActions }),
538
+ ...(systemSkillsConfig !== undefined && { systemSkillsConfig }),
501
539
  tools,
502
540
  ...(a2aSkills.length > 0 && { a2aSkills }),
503
541
  },
504
542
  };
505
543
  }
544
+ function blockUnresolvableId(ctx, address, description) {
545
+ reportAuthoringBlocker(ctx, {
546
+ address,
547
+ description,
548
+ remedy: "Point each dynamic dropdown at an app or element and a field this export resolved to a reference, then pull again.",
549
+ ownFileKind: "agent",
550
+ });
551
+ }
552
+ function catalogRefForResourceLabel(label, kind, ctx) {
553
+ const byNamespace = kind === "app" ? ctx.foreignAppRefNamespaces : ctx.foreignElementRefNamespaces;
554
+ if (byNamespace === undefined)
555
+ return undefined;
556
+ const direct = byNamespace.get(label);
557
+ if (direct !== undefined)
558
+ return direct;
559
+ const matches = [...new Set([...byNamespace.entries()].filter(([namespace]) => sanitizeName(namespace) === label).map(([, refName]) => refName))];
560
+ return matches.length === 1 ? matches[0] : undefined;
561
+ }
562
+ function dropdownOwnerFromValue(value, appLabel, address, where, ctx) {
563
+ if (value === undefined) {
564
+ blockUnresolvableId(ctx, address, `${where}: aspect_id is missing, so pull cannot reproduce this dynamic dropdown.`);
565
+ return undefined;
566
+ }
567
+ if (resourceRefLabel(value, APP_RESOURCE_TYPE) === appLabel) {
568
+ return { owner: { kind: "app", refName: "", self: true }, fieldScopeLabel: appLabel, fieldScope: "app" };
569
+ }
570
+ for (const [type, kind] of [["elementum_app", "app"], ["elementum_element", "element"]]) {
571
+ const resourceLabel = resourceRefLabel(value, type);
572
+ if (resourceLabel === undefined)
573
+ continue;
574
+ const refName = catalogRefForResourceLabel(resourceLabel, kind, ctx);
575
+ if (refName === undefined) {
576
+ blockUnresolvableId(ctx, address, `${where}: aspect_id references ${type}.${resourceLabel}, which is not an app or element in this workspace.`);
577
+ return undefined;
578
+ }
579
+ const name = importedAspectName(ctx, kind, resourceLabel);
580
+ return {
581
+ owner: { kind, refName, ...(name !== undefined ? { name } : {}) },
582
+ fieldScopeLabel: resourceLabel,
583
+ fieldScope: kind,
584
+ };
585
+ }
586
+ if (isTfExpr(value) && value.$expr === "data-attr" && (value.type === "elementum_app" || value.type === "elementum_element")) {
587
+ const kind = value.type === "elementum_element" ? "element" : "app";
588
+ const target = resolveDataAspectTarget(ctx, kind, value.label);
589
+ if (target.catalogRef !== true) {
590
+ blockUnresolvableId(ctx, address, `${where}: aspect_id references data.${value.type}.${value.label}, which pull cannot name.`);
591
+ return undefined;
592
+ }
593
+ return {
594
+ owner: { kind, refName: target.key, ...(target.name !== "" ? { name: target.name } : {}) },
595
+ fieldScopeLabel: value.label,
596
+ fieldScope: kind,
597
+ };
598
+ }
599
+ const shown = typeof value === "string" ? value : JSON.stringify(value);
600
+ blockUnresolvableId(ctx, address, `${where}: aspect_id ${shown} is not a reference to an app or element.`);
601
+ return undefined;
602
+ }
603
+ function parseSystemSkillsConfig(value, where, address, appLabel, appRefName, ctx) {
604
+ const rec = plainObject(value);
605
+ if (rec === undefined) {
606
+ blockUnresolvableId(ctx, address, `${where}: system_skills_config has an unrecognized shape, so pull cannot reproduce it.`);
607
+ return undefined;
608
+ }
609
+ const ask = rec["ask_user_question"] === undefined
610
+ ? undefined
611
+ : parseAskUserQuestion(rec["ask_user_question"], `${where} ask_user_question`, address, appLabel, appRefName, ctx);
612
+ const approvals = rec["approvals"] === undefined
613
+ ? undefined
614
+ : parseSystemSkill(rec["approvals"], `${where} approvals`, address, ctx);
615
+ if (ask === null || approvals === null)
616
+ return undefined;
617
+ if (ask === undefined && approvals === undefined)
618
+ return undefined;
619
+ return {
620
+ ...(ask !== undefined ? { askUserQuestion: ask } : {}),
621
+ ...(approvals !== undefined ? { approvals } : {}),
622
+ };
623
+ }
624
+ function parseSystemSkill(value, where, address, ctx) {
625
+ const rec = plainObject(value);
626
+ if (rec === undefined) {
627
+ blockUnresolvableId(ctx, address, `${where} has an unrecognized shape, so pull cannot reproduce it.`);
628
+ return null;
629
+ }
630
+ if (typeof rec["enabled"] !== "boolean") {
631
+ blockUnresolvableId(ctx, address, `${where}.enabled is missing, so pull cannot reproduce it.`);
632
+ return null;
633
+ }
634
+ const description = typeof rec["description"] === "string" ? rec["description"] : undefined;
635
+ return { enabled: rec["enabled"], ...(description !== undefined ? { description } : {}) };
636
+ }
637
+ /**
638
+ * The field's name in this export. A resource block and a
639
+ * `data.elementum_field` lookup both carry it; a system-field local does not.
640
+ * This is the name the same pull writes into the catalog, including a
641
+ * `--no-adopt` pull whose name index still has the pre-rename name.
642
+ */
643
+ function exportedDropdownFieldName(fieldRef, ctx) {
644
+ if (fieldRef === undefined || !isTfExpr(fieldRef))
645
+ return undefined;
646
+ if (fieldRef.$expr === "resource-attr") {
647
+ const name = ctx.resourceByAddress?.(`${fieldRef.type}.${fieldRef.label}`)?.attrs["name"];
648
+ return typeof name === "string" && name !== "" ? name : undefined;
649
+ }
650
+ if (fieldRef.$expr === "data-attr" && fieldRef.type === "elementum_field") {
651
+ const name = ctx.dataAttrs?.("elementum_field", fieldRef.label)?.["name"];
652
+ return typeof name === "string" && name !== "" ? name : undefined;
653
+ }
654
+ return undefined;
655
+ }
656
+ /**
657
+ * True when build would send `storedName` anyway. The name in this export
658
+ * wins, compared exactly, so a case-only rename still prints `fieldName`.
659
+ * The name index is the fallback for a field with no name in the export.
660
+ * An owning-app dropdown stores its ref as `""`; looking that key up misses
661
+ * and must not count as a difference.
662
+ */
663
+ function storedNameIsCurrentDisplay(storedName, fieldKey, fieldRef, ownerRefName, ctx) {
664
+ const exported = exportedDropdownFieldName(fieldRef, ctx);
665
+ if (exported !== undefined)
666
+ return exported === storedName;
667
+ if (ownerRefName === "")
668
+ return true;
669
+ return ctx.fieldNamesByOwnerRefName?.get(ownerRefName)?.get(storedName.toLowerCase()) === fieldKey;
670
+ }
671
+ function unresolvedFilterId(value) {
672
+ if (value === null || typeof value !== "object")
673
+ return undefined;
674
+ if (Array.isArray(value)) {
675
+ for (const item of value) {
676
+ const found = unresolvedFilterId(item);
677
+ if (found !== undefined)
678
+ return found;
679
+ }
680
+ return undefined;
681
+ }
682
+ const record = value;
683
+ if (record.kind === "unresolved")
684
+ return typeof record.uuid === "string" ? record.uuid : "unknown";
685
+ for (const item of Object.values(record)) {
686
+ const found = unresolvedFilterId(item);
687
+ if (found !== undefined)
688
+ return found;
689
+ }
690
+ return undefined;
691
+ }
692
+ /**
693
+ * A `data.elementum_field` label back to the dropdown aspect's field key.
694
+ * `resolveToolFieldKey` already reads the dropdown's own `field_id` in this
695
+ * shape; a filter field on the same aspect arrives the same way, and without
696
+ * this the shared codec throws and the whole agent is dropped.
697
+ */
698
+ function dropdownFilterDataField(label, scope, ownerTfLabel, ownerRefName, ctx) {
699
+ const fieldKey = resolveToolFieldKey({ $expr: "data-attr", type: "elementum_field", label, path: ["id"] }, ownerTfLabel, scope, ctx);
700
+ return fieldKey === undefined ? undefined : { kind: "field", appHandle: ownerRefName, fieldKey };
701
+ }
702
+ /** A stored dropdown filter, or null when pull must stop rather than print a platform id. */
703
+ function dropdownFilterFromValue(value, scope, ownerTfLabel, ownerRefName, address, where, ctx) {
704
+ if (value === undefined)
705
+ return undefined;
706
+ let filter;
707
+ try {
708
+ filter = filterFromTf(value, {
709
+ type: scope === "element" ? "elementum_element" : "elementum_app",
710
+ label: ownerTfLabel,
711
+ ownerRefName,
712
+ ownerTfLabel,
713
+ scope,
714
+ foreignFieldRefsById: ctx.foreignFieldRefsById,
715
+ dataField: (label) => dropdownFilterDataField(label, scope, ownerTfLabel, ownerRefName, ctx),
716
+ }, `${where}.filter`, ctx, { optionLookupsAreIdentities: true });
717
+ }
718
+ catch (error) {
719
+ const message = error instanceof EntityTfError ? error.message : String(error);
720
+ blockUnresolvableId(ctx, address, `${where}.filter cannot be reproduced: ${message}`);
721
+ return null;
722
+ }
723
+ const unresolved = unresolvedFilterId(filter);
724
+ if (unresolved !== undefined) {
725
+ blockUnresolvableId(ctx, address, `${where}.filter field ${unresolved} is not a reference this export resolved, so pull cannot reproduce it.`);
726
+ return null;
727
+ }
728
+ return filter;
729
+ }
730
+ function parseAskUserQuestion(value, where, address, appLabel, appRefName, ctx) {
731
+ const skill = parseSystemSkill(value, where, address, ctx);
732
+ if (skill === null || skill === undefined)
733
+ return skill;
734
+ const rec = plainObject(value);
735
+ if (rec === undefined || rec["dynamic_dropdowns"] === undefined)
736
+ return skill;
737
+ if (!Array.isArray(rec["dynamic_dropdowns"])) {
738
+ blockUnresolvableId(ctx, address, `${where}.dynamic_dropdowns is not a list, so pull cannot reproduce it.`);
739
+ return null;
740
+ }
741
+ const dropdowns = [];
742
+ for (let i = 0; i < rec["dynamic_dropdowns"].length; i++) {
743
+ const item = rec["dynamic_dropdowns"][i];
744
+ if (item === undefined)
745
+ continue;
746
+ const rowWhere = `${where}.dynamic_dropdowns[${i}]`;
747
+ const row = plainObject(item);
748
+ if (row === undefined) {
749
+ blockUnresolvableId(ctx, address, `${rowWhere} has an unrecognized shape, so pull cannot reproduce it.`);
750
+ return null;
751
+ }
752
+ const owner = dropdownOwnerFromValue(row["aspect_id"], appLabel, address, rowWhere, ctx);
753
+ if (owner === undefined)
754
+ return null;
755
+ const fieldKey = resolveToolFieldKey(row["field_id"], owner.fieldScopeLabel, owner.fieldScope, ctx);
756
+ if (fieldKey === undefined) {
757
+ const shown = typeof row["field_id"] === "string" ? row["field_id"] : JSON.stringify(row["field_id"]);
758
+ blockUnresolvableId(ctx, address, `${rowWhere}.field_id ${shown} is not a reference to a field of that app or element, so pull cannot reproduce it.`);
759
+ return null;
760
+ }
761
+ if (typeof row["multiple"] !== "boolean" || typeof row["field"] !== "string" || row["field"] === "") {
762
+ blockUnresolvableId(ctx, address, `${rowWhere} is missing field or multiple, so pull cannot reproduce it.`);
763
+ return null;
764
+ }
765
+ if (isUuid(row["field"])) {
766
+ blockUnresolvableId(ctx, address, `${rowWhere}.field is a platform id, so pull cannot reproduce it.`);
767
+ return null;
768
+ }
769
+ const storedName = row["field"];
770
+ const ownerRefName = owner.owner.self === true ? appRefName : owner.owner.refName;
771
+ const matchesDisplayName = storedNameIsCurrentDisplay(storedName, fieldKey, row["field_id"], ownerRefName, ctx);
772
+ const filter = dropdownFilterFromValue(row["filter"], owner.fieldScope, owner.fieldScopeLabel, ownerRefName, address, rowWhere, ctx);
773
+ if (filter === null)
774
+ return null;
775
+ dropdowns.push({
776
+ owner: owner.owner,
777
+ fieldKey,
778
+ fieldName: storedName,
779
+ ...(matchesDisplayName ? {} : { storedFieldName: storedName }),
780
+ multiple: row["multiple"],
781
+ ...(filter !== undefined ? { filter } : {}),
782
+ });
783
+ }
784
+ return { ...skill, dynamicDropdowns: dropdowns };
785
+ }
786
+ function importedAspectName(ctx, kind, label) {
787
+ const type = kind === "element" ? "elementum_element" : "elementum_app";
788
+ const id = ctx.importId(`${type}.${label}`);
789
+ const imported = id === undefined ? undefined : ctx.importedResource?.(id);
790
+ const name = imported?.attrs["name"];
791
+ return typeof name === "string" && name !== "" ? name : undefined;
792
+ }
@@ -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";
@@ -116,6 +116,7 @@ export const agentModule = {
116
116
  appTfLabel: ctx.appTfLabel,
117
117
  orgRefs: ctx.orgRefs,
118
118
  workspaceAspects: ctx.workspaceAspects,
119
+ ...(ctx.outOfScopeApps !== undefined && { outOfScopeApps: ctx.outOfScopeApps }),
119
120
  serviceAccounts: ctx.streamRootEntity?.payload?.serviceAccounts,
120
121
  diagnostics: ctx.diagnostics,
121
122
  ...(ctx.siblingEntities !== undefined && { siblingEntities: ctx.siblingEntities }),
@@ -15,7 +15,7 @@
15
15
  * still doesn't carry (temperature, reasoningEffort, …) degrade through
16
16
  * `diagnostics` — reported, never silent (plan §4.3).
17
17
  */
18
- import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
18
+ import { type ForeignRootIdentity, type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
19
19
  import { type DeployableEntity } from "../../engine/entity.js";
20
20
  import { type TfBlock } from "../../engine/tf/index.js";
21
21
  import type { AppServiceAccount } from "../service-account/build.js";
@@ -25,6 +25,8 @@ export interface AgentToTfContext {
25
25
  readonly appTfLabel: string;
26
26
  readonly orgRefs: OrgRefLookup;
27
27
  readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
28
+ /** See `ToTfContext.outOfScopeApps`: apps authored here but left out of a scoped build. */
29
+ readonly outOfScopeApps?: ReadonlyMap<string, ForeignRootIdentity>;
28
30
  /** Inline service accounts authored on the owning app, keyed by stable bag key. */
29
31
  readonly serviceAccounts?: Readonly<Record<string, AppServiceAccount>>;
30
32
  /** Degradations land here — reported by the caller, never silent. */
@@ -46,17 +48,16 @@ export interface AgentToTfResult {
46
48
  readonly address: string;
47
49
  }
48
50
  /**
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`, …
51
+ * The cross-agent a2a-skill-name numbering that ei's export copies
52
+ * (`a2aSkillImportBlocks` in `cmd/elementum/export/imports.go`, over one
53
+ * app's own agents only, edk#2508): a same-app, same-named a2a skill on two
54
+ * different agents is not a collision on the platform — the first agent to
55
+ * use a sanitized name gets the bare label, each later agent `_1`, `_2`, …
55
56
  *
56
57
  * The order is shared with ei: agent name by UTF-16 code unit, then (for
57
58
  * 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`),
59
+ * tails sort alike. The Go comparator is in `a2aSkillImportBlocks`
60
+ * (`compareUTF16`, `agentChildParts`),
60
61
  * and the two must stay in sync; changing one without the other moves
61
62
  * `agent_id` and replaces skills on the first plan after a pull (edk#1728).
62
63
  * Before edk#1728 ei walked agents in id order.
@@ -76,8 +77,7 @@ export interface AgentToTfResult {
76
77
  * cross-agent counter), so an intra-agent duplicate still collides on one
77
78
  * address instead of silently acquiring a distinct label — that's a real
78
79
  * 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
80
+ * a build error from `agentToTf`'s `seenA2ASkillAddresses` check. Only DIFFERENT agents reusing a name are
81
81
  * the #294 case this disambiguates.
82
82
  */
83
83
  export declare function computeA2ASkillLabelSuffixes(siblingAgents: readonly DeployableEntity[]): ReadonlyMap<string, string>;