@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
@@ -0,0 +1,115 @@
1
+ import { existsSync, readdirSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ /**
4
+ * Keys the org `@catalog` barrel holds after its app and element getters
5
+ * (src/catalog/org.ts renderBarrel). A later key in an object literal wins,
6
+ * so an app or element whose catalog key is one of these is shadowed:
7
+ * `catalog.users` is the org user lookups, not the element (edk#2839).
8
+ * `tables` is emitted only while the workspace has a table catalog; the
9
+ * others always are.
10
+ */
11
+ export const ORG_CATALOG_KEYS = [
12
+ "users",
13
+ "userGroups",
14
+ "aiProviders",
15
+ "cloudLinks",
16
+ "categories",
17
+ "groups",
18
+ "phoneProviders",
19
+ "voiceAuths",
20
+ ];
21
+ const ALWAYS_EMITTED_CATALOG_KEYS = new Set(ORG_CATALOG_KEYS);
22
+ const TABLES_CATALOG_KEY = "tables";
23
+ /**
24
+ * True for every key the barrel can hold. Pull and `elementum new` never mint
25
+ * one of these for a new app or element (it becomes `users2`), so adding a
26
+ * table later can't shadow it.
27
+ */
28
+ export function isReservedCatalogKey(refName) {
29
+ return ALWAYS_EMITTED_CATALOG_KEYS.has(refName) || refName === TABLES_CATALOG_KEY;
30
+ }
31
+ /**
32
+ * True when the barrel shadows an app or element getter named `refName` now:
33
+ * an always-emitted key, or `tables` while the workspace has a table catalog.
34
+ * Only a shadowed folder is refused or moved; an existing `tables` element in
35
+ * a workspace with no tables keeps working as `catalog.tables`.
36
+ */
37
+ export function isShadowedCatalogKey(refName, tablesEmitted) {
38
+ return ALWAYS_EMITTED_CATALOG_KEYS.has(refName) || (refName === TABLES_CATALOG_KEY && tablesEmitted);
39
+ }
40
+ /** True when `<orgRoot>/tables/` holds a table catalog, which makes the barrel emit `tables`. */
41
+ export function orgHasTableCatalogs(orgRoot) {
42
+ const dir = join(orgRoot, "tables");
43
+ if (!existsSync(dir))
44
+ return false;
45
+ return readdirSync(dir, { withFileTypes: true })
46
+ .some((entry) => entry.isDirectory() && existsSync(join(dir, entry.name, "generated", "catalog.ts")));
47
+ }
48
+ /**
49
+ * `base` when it isn't a reserved catalog key, else the first of `<base>2`,
50
+ * `<base>3`, … that isn't `taken` (a folder there that belongs to another
51
+ * root).
52
+ */
53
+ export function unreservedRefName(base, taken = () => false) {
54
+ if (!isReservedCatalogKey(base))
55
+ return base;
56
+ let i = 2;
57
+ while (taken(`${base}${i}`))
58
+ i++;
59
+ return `${base}${i}`;
60
+ }
61
+ /** True when `dir` holds nothing but pull's own `generated/` output (a dependency stub). */
62
+ export function isGeneratedOnlyFolder(dir) {
63
+ return readdirSync(dir).filter((entry) => entry !== ".DS_Store").every((entry) => entry === "generated");
64
+ }
65
+ function shadowedRemedy(bag, refName, suggestion) {
66
+ return `If it is on the platform, commit your work, delete ${bag}/${refName}/ and pull it again; pull picks a folder ` +
67
+ `name the barrel doesn't shadow. Otherwise rename the folder and its file to ${suggestion}, run ` +
68
+ `\`elementum generate\`, and use catalog.${suggestion}. The namespace stays, so nothing on the platform changes (edk#2839).`;
69
+ }
70
+ /** Pull refuses to write over an authored root whose ref name the barrel shadows. */
71
+ export function reservedRefNameError(bag, refName, suggestion) {
72
+ return new Error(`${bag}/${refName}: "${refName}" is a reserved @catalog key (catalog.${refName} is the org's own entry), ` +
73
+ `so the ${bag === "apps" ? "app" : "element"} can't be reached as catalog.${refName}. ${shadowedRemedy(bag, refName, suggestion)}`);
74
+ }
75
+ /** The barrel leaves out a folder with source that an org entry shadows. */
76
+ export function shadowedFolderWarning(bag, refName, suggestion) {
77
+ return `${bag}/${refName}/ can't be reached as catalog.${refName}: that is the org's own entry, so the @catalog barrel ` +
78
+ `leaves the ${bag === "apps" ? "app" : "element"} out. ${shadowedRemedy(bag, refName, suggestion)}`;
79
+ }
80
+ /**
81
+ * Pure shared allocator: app/element collisions receive disambiguated keys.
82
+ * Apps and elements share the barrel's key space: an element whose folder
83
+ * name an app also uses gets `<name>2` (the first free). The barrel, pull and
84
+ * the reserved-name checks all use this, so they agree on each element's key.
85
+ */
86
+ export function computeElementKeys(appHandles, elementHandles) {
87
+ const used = new Set(appHandles);
88
+ const elementKeys = new Map();
89
+ for (const h of elementHandles) {
90
+ if (!used.has(h)) {
91
+ elementKeys.set(h, h);
92
+ used.add(h);
93
+ continue;
94
+ }
95
+ let i = 2;
96
+ let candidate = `${h}${i}`;
97
+ while (used.has(candidate)) {
98
+ i++;
99
+ candidate = `${h}${i}`;
100
+ }
101
+ elementKeys.set(h, candidate);
102
+ used.add(candidate);
103
+ }
104
+ return elementKeys;
105
+ }
106
+ /** The `<bag>/<handle>/` folders that hold a catalog (`generated/catalog.ts`), sorted, as the barrel lists them. */
107
+ export function catalogFolders(orgRoot, bag) {
108
+ const dir = join(orgRoot, bag);
109
+ if (!existsSync(dir))
110
+ return [];
111
+ return readdirSync(dir, { withFileTypes: true })
112
+ .filter((entry) => entry.isDirectory() && existsSync(join(dir, entry.name, "generated", "catalog.ts")))
113
+ .map((entry) => entry.name)
114
+ .sort();
115
+ }
@@ -5,11 +5,12 @@
5
5
  * both parents accept the identical shape.
6
6
  */
7
7
  import type { Filter } from "../shared/filters/types.js";
8
+ import type { FilterFieldToken } from "../shared/filters/index.js";
8
9
  import type { AccessPolicyGroupRef, AccessPolicyServiceAccountRef, AccessPolicyUserRef } from "./principal.js";
9
10
  export { groupId, userId, type AccessPolicyGroupRef, type AccessPolicyPrincipal, type AccessPolicyPrincipalRef, type AccessPolicyServiceAccountRef, type AccessPolicyUserRef, type GroupId, type UserId, } from "./principal.js";
10
11
  export interface AccessPolicyOptions {
11
12
  /** Row-level-security predicate. Omit for the platform default (matches every record). */
12
- readonly filter?: Filter;
13
+ readonly filter?: Filter<FilterFieldToken, unknown>;
13
14
  readonly userIds?: readonly AccessPolicyUserRef[];
14
15
  readonly groupIds?: readonly AccessPolicyGroupRef[];
15
16
  readonly serviceAccountIds?: readonly AccessPolicyServiceAccountRef[];
@@ -36,6 +36,8 @@ export interface NormalizedAccessPolicy {
36
36
  readonly userIds?: readonly AccessPolicyUserRef[];
37
37
  readonly groupIds?: readonly AccessPolicyGroupRef[];
38
38
  readonly serviceAccountIds?: readonly AccessPolicyServiceAccountRef[];
39
+ /** Pull-only: export matched it to the policy the platform adds for the app's creator (edk#2156); the printer notes it. */
40
+ readonly platformCreatorPolicy?: true;
39
41
  }
40
42
  export interface FilterFromTfOptions {
41
43
  /**
@@ -44,6 +46,11 @@ export interface FilterFromTfOptions {
44
46
  * that always rebuild a bare label into its lookup leave this off.
45
47
  */
46
48
  readonly optionLookupsAreIdentities?: boolean;
49
+ /**
50
+ * Access policies (#1733): a stored options-by-label lookup prints as
51
+ * `filter.textOption(label)`, the preferred spelling. Stage keys stay plain.
52
+ */
53
+ readonly optionLookupsAsTextOption?: boolean;
47
54
  }
48
55
  /** Decode one `filter` attribute through the shared exhaustive codec. */
49
56
  export declare function filterFromTf(value: TfValue, owner: AccessPolicyOwner, where: string, ctx?: FromTfContext, options?: FilterFromTfOptions): Filter<RefExpr, RefExpr>;
@@ -12,7 +12,10 @@
12
12
  */
13
13
  import { EntityTfError } from "../../engine/entity.js";
14
14
  import { dataRefLabel, groupCatalogKey, resourceRefLabel } from "../../engine/pull/context.js";
15
- import { appResourceLabelPrefix, elementResourceLabelPrefix, isTfExpr, scopedLabelToBagKey, scopedResourceLabel, tfLabelToTsLabel, } from "../../engine/tf/index.js";
15
+ import { appResourceLabelPrefix, elementResourceLabelPrefix, isTfExpr, scopedResourceLabel, tfLabelToTsLabel, } from "../../engine/tf/index.js";
16
+ import { SYSTEM_FIELD_KEY_SET } from "../../core/system-fields.js";
17
+ import { bagKeyForPulledCustomField } from "../field/from-tf.js";
18
+ import { ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
16
19
  import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-codec.js";
17
20
  import { groupId, userId, } from "./principal.js";
18
21
  import { KNOWN_ACCESS_POLICY_ATTRS } from "./types.js";
@@ -30,7 +33,8 @@ function fieldRef(value, owner, where) {
30
33
  // final throw below can handle it instead of a silent wrong answer.
31
34
  const prefix = owner.scope === "element" ? elementResourceLabelPrefix(owner.ownerTfLabel) : appResourceLabelPrefix(owner.ownerTfLabel);
32
35
  if (value.label.startsWith(prefix)) {
33
- return { kind: "field", appHandle: owner.ownerRefName, fieldKey: scopedLabelToBagKey(owner.ownerTfLabel, value.label, owner.scope) };
36
+ const reserved = owner.scope === "element" ? new Set(ELEMENT_SYSTEM_FIELD_KEYS) : SYSTEM_FIELD_KEY_SET;
37
+ return { kind: "field", appHandle: owner.ownerRefName, fieldKey: bagKeyForPulledCustomField(owner.ownerTfLabel, value.label, owner.scope, reserved) };
34
38
  }
35
39
  }
36
40
  // A system field (status/title/id/stage/…) has no own resource block — ei
@@ -88,6 +92,9 @@ export function filterFromTf(value, owner, where, ctx, options) {
88
92
  reference: () => { throw new EntityTfError(`${where}: access-policy reference values are not supported`); },
89
93
  literal: (literal) => picklistOptionLabel(literal, owner) ?? stageName(literal, owner, ctx) ?? literal,
90
94
  ...(options?.optionLookupsAreIdentities === true && { optionLookupsAreIdentities: true }),
95
+ ...(options?.optionLookupsAsTextOption === true && {
96
+ optionLookupsAreIdentities: (stored) => picklistOptionLabel(stored, owner) !== undefined,
97
+ }),
91
98
  });
92
99
  }
93
100
  catch (error) {
@@ -265,14 +272,22 @@ export function accessPolicyFromTf(block, owner, ctx) {
265
272
  const filterOwner = owner.foreignFieldRefsById !== undefined
266
273
  ? owner
267
274
  : { ...owner, foreignFieldRefsById: ctx.foreignFieldRefsById };
268
- const filter = attrs["filter"] !== undefined ? filterFromTf(attrs["filter"], filterOwner, where, ctx) : { type: "TRUE" };
275
+ // #1733: a resolved option prints as `filter.textOption(label)`, the
276
+ // preferred spelling; build still resolves a plain label here too.
277
+ const filter = attrs["filter"] !== undefined
278
+ ? filterFromTf(attrs["filter"], filterOwner, where, ctx, { optionLookupsAsTextOption: true })
279
+ : { type: "TRUE" };
269
280
  const userIds = principalList(attrs["user_ids"], "elementum_user", `${where}: user_ids`, ctx);
270
281
  const groupIds = principalList(attrs["group_ids"], "elementum_group", `${where}: group_ids`, ctx);
271
282
  const serviceAccountIds = principalList(attrs["service_account_ids"], "elementum_service_account", `${where}: service_account_ids`, ctx, owner);
283
+ // The import id is `<object id>:<policy id>`.
284
+ const policyId = ctx.importId(`${block.type}.${label}`)?.split(":").at(-1);
285
+ const platformCreatorPolicy = policyId !== undefined && ctx.platformCreatorPolicyIds?.has(policyId) === true;
272
286
  return {
273
287
  filter,
274
288
  ...(userIds !== undefined && { userIds }),
275
289
  ...(groupIds !== undefined && { groupIds }),
276
290
  ...(serviceAccountIds !== undefined && { serviceAccountIds }),
291
+ ...(platformCreatorPolicy && { platformCreatorPolicy: true }),
277
292
  };
278
293
  }
@@ -18,6 +18,7 @@
18
18
  * the integration harness strips it for fidelity against authored fixtures.
19
19
  */
20
20
  import type { OrgRefLookup } from "../../engine/build/context.js";
21
+ import type { OptionIdIndex } from "../../engine/pull/field-refs-registry.js";
21
22
  import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
22
23
  import type { Filter } from "../shared/filters/types.js";
23
24
  import type { AppServiceAccount } from "../service-account/build.js";
@@ -41,6 +42,8 @@ export interface AccessPolicyToTfContext {
41
42
  readonly appRefName?: string;
42
43
  readonly serviceAccounts?: Readonly<Record<string, AppServiceAccount>>;
43
44
  readonly fieldAddresses?: ReadonlyMap<string, string>;
45
+ /** Option ids known offline, so a raw id's warning can name its label (#1733). */
46
+ readonly optionIds?: OptionIdIndex;
44
47
  /**
45
48
  * Resolve an app that owns a `serviceAccountRef` in these policies but is
46
49
  * NOT this policy's owner — an element granting an app's service account
@@ -75,6 +78,22 @@ export interface FilterToTfContext extends Omit<AccessPolicyToTfContext, "orgRef
75
78
  readonly fieldType?: string;
76
79
  readonly name?: string;
77
80
  }, where: string) => TfValue | undefined;
81
+ /**
82
+ * The owner is only a data source here, so it has no field resources and no
83
+ * options locals. Its own fields go through `foreignField` too (a parent
84
+ * that matches the owner otherwise skips that path), and an option label
85
+ * stays the authored label instead of an options-by-label local.
86
+ */
87
+ readonly ownerFieldsThroughForeign?: boolean;
88
+ /**
89
+ * Set by access policies (#1733): `filter.textOption(label)` must name
90
+ * exactly one option of the field, and warnings name this resource. Views
91
+ * and the other filter owners leave it off and keep their option rules.
92
+ */
93
+ readonly optionSelections?: {
94
+ readonly address: string;
95
+ readonly name: string;
96
+ };
78
97
  }
79
98
  export interface AccessPolicyToTfResult {
80
99
  readonly block: TfBlock;
@@ -19,9 +19,11 @@
19
19
  */
20
20
  import { isUnsafePlatformId } from "../../core/index.js";
21
21
  import { EntityTfError } from "../../engine/entity.js";
22
+ import { recordValidations } from "../../engine/validation.js";
22
23
  import { expr, isUuid, sanitizeName, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
23
24
  import { fieldRefToTfValue } from "../field/to-tf.js";
24
25
  import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
26
+ import { plainOptionStringWarning, rawOptionIdWarning } from "../shared/raw-option-id.js";
25
27
  import { serviceAccountRefToTf } from "../service-account/to-tf.js";
26
28
  import { ACCESS_POLICY_RESOURCE_TYPE } from "./types.js";
27
29
  import { describeDroppedEntry, finishMemberList } from "./member-list.js";
@@ -31,12 +33,17 @@ function isFieldToken(v) {
31
33
  function fieldValueToTf(token, where, ctx) {
32
34
  const refName = token.refName ?? "";
33
35
  const parent = token.parent;
34
- if (ctx.foreignField !== undefined && parent !== undefined && parent !== (ctx.ownerRefName ?? ctx.appRefName) && parent !== ctx.ownerTfLabel) {
36
+ const ownerRefName = ctx.ownerRefName ?? ctx.appRefName;
37
+ const otherOwner = parent !== undefined && parent !== ownerRefName && parent !== ctx.ownerTfLabel;
38
+ // A data-source owner has no field resources. Its own fields (parent matches
39
+ // the owner) still go through foreignField; only a different owner does
40
+ // otherwise.
41
+ if (ctx.foreignField !== undefined && parent !== undefined && (otherOwner || ctx.ownerFieldsThroughForeign === true)) {
35
42
  const foreign = ctx.foreignField({ ...token, refName, parent }, where);
36
43
  if (foreign !== undefined)
37
44
  return foreign;
38
45
  }
39
- const value = fieldRefToTfValue(token.fieldType ?? "", refName, ctx.ownerTfLabel, ctx.scope, ctx.fieldAddresses);
46
+ const value = fieldRefToTfValue(token.fieldType ?? "", refName, ctx.ownerTfLabel, ctx.scope, ctx.fieldAddresses, token.resourceKey);
40
47
  if (value === undefined) {
41
48
  throw new EntityTfError(`${where}: field token "${refName}" has no terraform field resource mapping`);
42
49
  }
@@ -44,8 +51,16 @@ function fieldValueToTf(token, where, ctx) {
44
51
  }
45
52
  /** Resolve a PICKLIST/STATUS-field-typed string against its options-by-label local, if the field carries picklist metadata. */
46
53
  function picklistLiteralToTf(literal, field, ctx) {
54
+ // A data-source owner has no options local in this workspace. The caller
55
+ // keeps the label as authored (`?? value`) instead of a local that does not exist.
56
+ if (ctx.ownerFieldsThroughForeign === true)
57
+ return undefined;
47
58
  if (field?.options === undefined || !field.options.includes(literal))
48
59
  return undefined;
60
+ return expr.local(optionsLocalName(field, ctx), [{ index: literal }]);
61
+ }
62
+ /** The field's options-by-label local name. */
63
+ function optionsLocalName(field, ctx) {
49
64
  // Hand-built refs to an app's system status/stage carry no tags; match them
50
65
  // by key, as field resolution does. Elements have no status/stage system fields.
51
66
  const systemKey = ctx.scope === "element" ? undefined : field.refName;
@@ -55,9 +70,47 @@ function picklistLiteralToTf(literal, field, ctx) {
55
70
  ? `${ctx.ownerTfLabel}_stage_options_by_label`
56
71
  : undefined;
57
72
  // Non-status/stage picklists: the field's own options-by-label local, keyed
58
- // by its scoped resource label — same derivation fieldToTf's options pass uses.
59
- const resolvedLocalName = localName ?? `${scopedResourceLabel(ctx.ownerTfLabel, tsLabelToTfLabel(field?.refName ?? ""), ctx.scope)}_options_by_label`;
60
- return expr.local(resolvedLocalName, [{ index: literal }]);
73
+ // by its scoped resource label — same child part fieldToTf uses (#1871).
74
+ const childPart = tsLabelToTfLabel(field.resourceKey ?? field.refName ?? "");
75
+ return localName ?? `${scopedResourceLabel(ctx.ownerTfLabel, childPart, ctx.scope)}_options_by_label`;
76
+ }
77
+ /**
78
+ * A filter value on a field with static options (#1733). A raw option id and
79
+ * a plain string each build as before and warn once, naming the preferred
80
+ * `filter.textOption(label)`. On an access policy, `filter.textOption(label)`
81
+ * must also name exactly one option; the other owners of this codec (views,
82
+ * dashboards, relationships, dynamic layouts) do not check that here.
83
+ */
84
+ function checkOptionSelection(value, field, valueType, isOptionLabel, where, ctx) {
85
+ const selections = ctx.optionSelections;
86
+ const options = field.options;
87
+ if (options === undefined || value === "" || field.tags?.includes("STAGE"))
88
+ return;
89
+ const fieldName = field.name ?? field.refName ?? "unknown";
90
+ const slot = selections !== undefined ? `${where}.filter` : where;
91
+ const warn = (message) => recordValidations([{
92
+ severity: "warning",
93
+ address: selections?.address ?? where,
94
+ name: selections?.name ?? ctx.ownerRefName ?? ctx.ownerTfLabel,
95
+ ownerKind: selections !== undefined ? "access-policy" : "filter",
96
+ message,
97
+ }]);
98
+ if (isUuid(value) && !options.includes(value)) {
99
+ warn(rawOptionIdWarning({ slot, fieldName, id: value, options, localName: optionsLocalName(field, ctx), index: ctx.optionIds }));
100
+ return;
101
+ }
102
+ if (!isOptionLabel) {
103
+ warn(plainOptionStringWarning(slot, fieldName, value, options, ctx.resolvePicklistLiterals !== false));
104
+ return;
105
+ }
106
+ if (selections === undefined || valueType !== "text")
107
+ return;
108
+ const matches = options.filter((option) => option === value).length;
109
+ if (matches === 1)
110
+ return;
111
+ throw new EntityTfError(matches === 0
112
+ ? `${where}: filter.textOption(${JSON.stringify(value)}) names no option of field "${fieldName}"; expected one of: ${options.map((option) => JSON.stringify(option)).join(", ")}`
113
+ : `${where}: filter.textOption(${JSON.stringify(value)}) matches ${matches} options of field "${fieldName}", so it names no single option`);
61
114
  }
62
115
  /**
63
116
  * Encode one canonical filter through the shared exhaustive Terraform codec.
@@ -80,8 +133,10 @@ export function filterToTf(f, where, ctx) {
80
133
  return fieldValueToTf(field, where, ctx);
81
134
  },
82
135
  reference: () => { throw new EntityTfError(`${where}: access-policy filters do not support reference values`); },
83
- literal: (value, field, _valueType, isOptionLabel) => {
136
+ literal: (value, field, valueType, isOptionLabel) => {
84
137
  if (typeof value === "string") {
138
+ if (isFieldToken(field))
139
+ checkOptionSelection(value, field, valueType, isOptionLabel, where, ctx);
85
140
  // An option selection stays an identity whichever wrapper the platform
86
141
  // stored it behind, even on views where raw TEXT picklist labels
87
142
  // intentionally stay literal (rather than IDs).
@@ -219,9 +274,11 @@ function accessPolicyTfLabel(ownerTfLabel, index, scope) {
219
274
  export function accessPolicyToTf(entry, index, ctx) {
220
275
  const label = accessPolicyTfLabel(ctx.ownerTfLabel, index, ctx.scope);
221
276
  const where = `accessPolicies[${index}]`;
277
+ const address = `${ACCESS_POLICY_RESOURCE_TYPE}.${label}`;
278
+ const optionSelections = { address, name: `${ctx.ownerRefName ?? ctx.ownerTfLabel} ${where}` };
222
279
  const attrs = {
223
280
  object_id: ctx.objectId,
224
- filter: entry.filter !== undefined ? filterToTf(entry.filter, where, ctx) : { type: "true" },
281
+ filter: entry.filter !== undefined ? filterToTf(entry.filter, where, { ...ctx, optionSelections }) : { type: "true" },
225
282
  };
226
283
  // `userIds: []` (and the other lists) removes every member, so it must
227
284
  // reach the provider as `[]`: an omitted list changes nothing (#2160). A
@@ -241,6 +298,6 @@ export function accessPolicyToTf(entry, index, ctx) {
241
298
  attrs["service_account_ids"] = serviceAccountIds;
242
299
  return {
243
300
  block: { kind: "resource", type: ACCESS_POLICY_RESOURCE_TYPE, label, attrs },
244
- address: `${ACCESS_POLICY_RESOURCE_TYPE}.${label}`,
301
+ address,
245
302
  };
246
303
  }
@@ -1,6 +1,7 @@
1
- import type { AgentRef, CatalogRef, ConnectorRef, SkillRef } from "../../catalog/index.js";
1
+ import type { AgentRef, CatalogRef, ConnectorRef, ElementCatalogRef, FieldRef, SkillRef } from "../../catalog/index.js";
2
2
  import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
3
3
  import type { UnsafePlatformId } from "../../core/platform-id.js";
4
+ import type { Filter } from "../shared/filters/types.js";
4
5
  import type { AgentTool, AgentToolRunAs } from "./tools.js";
5
6
  /** JWT authentication config (Hydra's `AgentAuthenticationInput`). */
6
7
  export interface AgentAuthentication {
@@ -53,6 +54,51 @@ export type SkillAccess = {
53
54
  readonly skills: readonly SkillRef[];
54
55
  readonly preloadedSkills?: readonly SkillRef[];
55
56
  };
57
+ /** Ask a Question or Approvals, the agent's built-in system skills. */
58
+ export interface AgentSystemSkill {
59
+ readonly enabled: boolean;
60
+ /** Shown with the skill. Omit it to leave the live description unchanged. */
61
+ readonly description?: string;
62
+ }
63
+ /**
64
+ * A record field Ask a Question can offer as a dynamic dropdown.
65
+ * `field` belongs to exactly one of `app` or `element`. `fieldName` is the
66
+ * name the platform stores for the dropdown; it keeps the field's name from
67
+ * when the dropdown was set up, so set it when the field was renamed since.
68
+ * Defaults to the field's display name.
69
+ */
70
+ export type AgentDynamicDropdown = {
71
+ readonly app: CatalogRef<"app">;
72
+ readonly element?: never;
73
+ readonly field: FieldRef;
74
+ readonly fieldName?: string;
75
+ readonly multiple: boolean;
76
+ /**
77
+ * Limits which records the dropdown offers. Use the filter helpers
78
+ * (`filter.eq` and the rest). Omit it to store no filter.
79
+ */
80
+ readonly filter?: Filter;
81
+ } | {
82
+ readonly app?: never;
83
+ readonly element: ElementCatalogRef;
84
+ readonly field: FieldRef;
85
+ readonly fieldName?: string;
86
+ readonly multiple: boolean;
87
+ /** Limits which records the dropdown offers. Omit it to store no filter. */
88
+ readonly filter?: Filter;
89
+ };
90
+ /** Ask a Question, including the dropdowns it can offer. */
91
+ export interface AgentAskUserQuestion extends AgentSystemSkill {
92
+ readonly dynamicDropdowns?: readonly AgentDynamicDropdown[];
93
+ }
94
+ /**
95
+ * Built-in system skills. Omit the whole object to leave the live Ask a
96
+ * Question and Approvals settings unchanged.
97
+ */
98
+ export interface AgentSystemSkillsConfig {
99
+ readonly askUserQuestion?: AgentAskUserQuestion;
100
+ readonly approvals?: AgentSystemSkill;
101
+ }
56
102
  export declare const agentStartingActionVariableType: {
57
103
  readonly number: "NUMBER";
58
104
  readonly select: "SELECT";
@@ -122,6 +168,11 @@ export interface AgentV2Options extends EntityDeployOptions {
122
168
  readonly a2aCreateRecordEnabled?: boolean;
123
169
  readonly conversationIdleTimeout?: string;
124
170
  readonly skillAccess?: SkillAccess;
171
+ /**
172
+ * Ask a Question and Approvals. Omit it and apply leaves the live value
173
+ * alone, including a value set in the UI.
174
+ */
175
+ readonly systemSkillsConfig?: AgentSystemSkillsConfig;
125
176
  readonly agentAuthentication?: AgentAuthentication;
126
177
  readonly a2aSkills?: readonly A2ASkill[];
127
178
  readonly tools?: readonly AgentTool[];
@@ -39,6 +39,37 @@ function serializeStartingAction(action) {
39
39
  ...(action.variables !== undefined ? { variables: action.variables } : {}),
40
40
  };
41
41
  }
42
+ function serializeSystemSkill(skill) {
43
+ return {
44
+ enabled: skill.enabled,
45
+ ...(skill.description !== undefined ? { description: skill.description } : {}),
46
+ };
47
+ }
48
+ function serializeDynamicDropdown(row) {
49
+ const owner = row.app !== undefined ? { app: row.app } : { element: row.element };
50
+ return {
51
+ ...owner,
52
+ field: row.field,
53
+ ...(row.fieldName !== undefined ? { fieldName: row.fieldName } : {}),
54
+ multiple: row.multiple,
55
+ ...(row.filter !== undefined ? { filter: row.filter } : {}),
56
+ };
57
+ }
58
+ function serializeSystemSkills(config) {
59
+ return {
60
+ ...(config.askUserQuestion !== undefined
61
+ ? {
62
+ askUserQuestion: {
63
+ ...serializeSystemSkill(config.askUserQuestion),
64
+ ...(config.askUserQuestion.dynamicDropdowns !== undefined
65
+ ? { dynamicDropdowns: config.askUserQuestion.dynamicDropdowns.map(serializeDynamicDropdown) }
66
+ : {}),
67
+ },
68
+ }
69
+ : {}),
70
+ ...(config.approvals !== undefined ? { approvals: serializeSystemSkill(config.approvals) } : {}),
71
+ };
72
+ }
42
73
  function serializeSkillAccess(access) {
43
74
  const preloaded = access.preloadedSkills !== undefined ? { preloadedSkillIds: access.preloadedSkills } : {};
44
75
  if (access.mode === "CUSTOM") {
@@ -178,6 +209,9 @@ export function agent(opts) {
178
209
  ...(opts.skillAccess !== undefined
179
210
  ? { skillAccessConfig: serializeSkillAccess(opts.skillAccess) }
180
211
  : {}),
212
+ ...(opts.systemSkillsConfig !== undefined
213
+ ? { systemSkillsConfig: serializeSystemSkills(opts.systemSkillsConfig) }
214
+ : {}),
181
215
  ...(opts.agentAuthentication !== undefined
182
216
  ? { agentAuthentication: opts.agentAuthentication }
183
217
  : {}),
@@ -14,6 +14,7 @@ import { quote } from "../../../../pull/util.js";
14
14
  import { catalogRefForFieldOwner } from "../../../engine/pull/catalog-ref.js";
15
15
  import { sdkPackageSpecifier } from "../../../internal/sdk-package.js";
16
16
  import { safeIdentifier } from "../../../internal/safe-identifier.js";
17
+ import { printFilter } from "../../shared/filters/print.js";
17
18
  const TOOL_FACTORY_BY_TYPE_KEY = {
18
19
  createRecord: "agentCreateRecord",
19
20
  searchAspect: "agentSearchRecords",
@@ -129,6 +130,9 @@ export function printAgentV2(agent, opts) {
129
130
  }
130
131
  if (usesUnsafePlatformId)
131
132
  lines.push(`import { unsafePlatformId } from "${sdkPackageSpecifier("core")}";`);
133
+ if (agent.systemSkillsConfig?.askUserQuestion?.dynamicDropdowns?.some((row) => row.filter !== undefined) === true) {
134
+ lines.push(`import { filter } from "${sdkPackageSpecifier("automations")}";`);
135
+ }
132
136
  // Always needed: `connector:` is required and always a catalog.aiProviders
133
137
  // token (or the TODO placeholder), and the barrel already re-exports
134
138
  // org.aiProviders — no separate relative org.js import is needed here.
@@ -176,6 +180,9 @@ export function printAgentV2(agent, opts) {
176
180
  if (agent.skillAccess !== undefined) {
177
181
  lines.push(...printSkillAccess(agent.skillAccess, appRefName, crossOrg).map((l) => ` ${l}`));
178
182
  }
183
+ if (agent.systemSkillsConfig !== undefined) {
184
+ lines.push(...printSystemSkillsConfig(agent.systemSkillsConfig, appRefName, crossOrg).map((l) => ` ${l}`));
185
+ }
179
186
  if (agent.runAs !== undefined)
180
187
  lines.push(` runAs: ${printRunAs(agent.runAs, appRefName)},`);
181
188
  if (agent.agentAuthentication !== undefined) {
@@ -208,6 +215,67 @@ export function printAgentV2(agent, opts) {
208
215
  lines.push("");
209
216
  return lines.join("\n");
210
217
  }
218
+ function printSystemSkillsConfig(config, appRefName, crossOrg) {
219
+ const lines = ["systemSkillsConfig: {"];
220
+ if (config.askUserQuestion !== undefined) {
221
+ lines.push(" askUserQuestion: {");
222
+ lines.push(` enabled: ${String(config.askUserQuestion.enabled)},`);
223
+ if (config.askUserQuestion.description !== undefined) {
224
+ lines.push(` description: ${quote(config.askUserQuestion.description)},`);
225
+ }
226
+ if (config.askUserQuestion.dynamicDropdowns !== undefined) {
227
+ if (config.askUserQuestion.dynamicDropdowns.length === 0) {
228
+ lines.push(" dynamicDropdowns: [],");
229
+ }
230
+ else {
231
+ lines.push(" dynamicDropdowns: [");
232
+ for (const row of config.askUserQuestion.dynamicDropdowns) {
233
+ lines.push(` ${printDynamicDropdown(row, appRefName, crossOrg)}`);
234
+ }
235
+ lines.push(" ],");
236
+ }
237
+ }
238
+ lines.push(" },");
239
+ }
240
+ if (config.approvals !== undefined) {
241
+ lines.push(" approvals: {");
242
+ lines.push(` enabled: ${String(config.approvals.enabled)},`);
243
+ if (config.approvals.description !== undefined) {
244
+ lines.push(` description: ${quote(config.approvals.description)},`);
245
+ }
246
+ lines.push(" },");
247
+ }
248
+ lines.push("},");
249
+ return lines;
250
+ }
251
+ function printDropdownFilter(filter) {
252
+ return printFilter(filter, {
253
+ field: printDropdownFilterRef,
254
+ reference: printDropdownFilterRef,
255
+ quote,
256
+ });
257
+ }
258
+ function printDropdownFilterRef(ref) {
259
+ if (ref.kind === "field") {
260
+ return `catalog${safeMember(ref.appHandle)}.fields${safeMember(ref.fieldKey)}`;
261
+ }
262
+ return `undefined /* TODO: unsupported filter reference ${quote(ref.kind)} */`;
263
+ }
264
+ function printDynamicDropdown(row, appRefName, crossOrg) {
265
+ const ownerKey = row.owner.kind === "element" ? "element" : "app";
266
+ const filterExpr = row.filter === undefined ? "" : `, filter: ${printDropdownFilter(row.filter)}`;
267
+ if (crossOrg && row.owner.self !== true) {
268
+ const name = row.owner.name ?? row.owner.refName;
269
+ const todo = ` // TODO: cross-org clone — "${name}" was resolved in the SOURCE org; verify it exists (with this name) in the destination org`;
270
+ const owner = `{ __kind: ${quote(ownerKey)}, refName: ${quote(name)}, name: ${quote(name)} }`;
271
+ const field = `{ __kind: "field", refName: ${quote(row.fieldName)}, name: ${quote(row.fieldName)}, fieldType: "TEXT", parent: ${quote(name)}, parentKind: ${quote(ownerKey)}, parentName: ${quote(name)} }`;
272
+ return `{ ${ownerKey}: ${owner}, field: ${field}, multiple: ${String(row.multiple)}${filterExpr} },${todo}`;
273
+ }
274
+ const refName = row.owner.self === true ? appRefName : row.owner.refName;
275
+ const ownerExpr = `catalog${safeMember(refName)}`;
276
+ const storedName = row.storedFieldName === undefined ? "" : ` fieldName: ${quote(row.storedFieldName)},`;
277
+ return `{ ${ownerKey}: ${ownerExpr}, field: ${ownerExpr}.fields${safeMember(row.fieldKey)},${storedName} multiple: ${String(row.multiple)}${filterExpr} },`;
278
+ }
211
279
  /** Dot access for identifier-safe names, bracket access otherwise. */
212
280
  function safeMember(name) {
213
281
  return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) ? `.${name}` : `[${quote(name)}]`;
@@ -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
  /**
@@ -57,6 +59,7 @@ export interface NormalizedAgent {
57
59
  readonly a2aStreaming?: boolean;
58
60
  readonly a2aCreateRecordEnabled?: boolean;
59
61
  readonly startingActions?: readonly AgentStartingAction[];
62
+ readonly systemSkillsConfig?: NormalizedSystemSkillsConfig;
60
63
  readonly tools: readonly NormalizedAgentTool[];
61
64
  readonly a2aSkills?: readonly NormalizedA2ASkill[];
62
65
  }
@@ -71,4 +74,34 @@ export interface AgentFromTfResult {
71
74
  * diagnostic (the caller partitions per-agent by agent_id, but stays
72
75
  * defensive).
73
76
  */
74
- export declare function agentFromTf(agentBlock: TfBlock, toolBlocks: readonly TfBlock[], appLabel: string, _appRefName: string, ctx: FromTfContext, a2aSkillBlocks?: readonly TfBlock[]): AgentFromTfResult;
77
+ export declare function agentFromTf(agentBlock: TfBlock, toolBlocks: readonly TfBlock[], appLabel: string, appRefName: string, ctx: FromTfContext, a2aSkillBlocks?: readonly TfBlock[]): AgentFromTfResult;
78
+ export interface NormalizedDropdownOwner {
79
+ readonly kind: "app" | "element";
80
+ readonly refName: string;
81
+ /** Display name. A cross-org clone prints this instead of the catalog key. */
82
+ readonly name?: string;
83
+ /** This agent's owning app. The printer uses the pull's app refName. */
84
+ readonly self?: boolean;
85
+ }
86
+ export interface NormalizedDynamicDropdown {
87
+ readonly owner: NormalizedDropdownOwner;
88
+ readonly fieldKey: string;
89
+ /** Platform display name (`field` on the wire). */
90
+ readonly fieldName: string;
91
+ /** Set when the stored name is not the field's name in this export. */
92
+ readonly storedFieldName?: string;
93
+ readonly multiple: boolean;
94
+ /** Present when the dropdown limits its records. */
95
+ readonly filter?: Filter<RefExpr, RefExpr>;
96
+ }
97
+ export interface NormalizedSystemSkill {
98
+ readonly enabled: boolean;
99
+ readonly description?: string;
100
+ }
101
+ export interface NormalizedAskUserQuestion extends NormalizedSystemSkill {
102
+ readonly dynamicDropdowns?: readonly NormalizedDynamicDropdown[];
103
+ }
104
+ export interface NormalizedSystemSkillsConfig {
105
+ readonly askUserQuestion?: NormalizedAskUserQuestion;
106
+ readonly approvals?: NormalizedSystemSkill;
107
+ }