@elementumai/edk 0.9.7 → 0.9.9

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 (148) hide show
  1. package/README.md +3 -2
  2. package/dist-sdk/src/catalog/factories.d.ts +14 -3
  3. package/dist-sdk/src/catalog/factories.js +32 -0
  4. package/dist-sdk/src/catalog/from-authoring.js +27 -33
  5. package/dist-sdk/src/catalog/index.d.ts +2 -2
  6. package/dist-sdk/src/catalog/index.js +2 -2
  7. package/dist-sdk/src/catalog/org.js +67 -29
  8. package/dist-sdk/src/catalog/token.js +10 -0
  9. package/dist-sdk/src/catalog/types.d.ts +20 -2
  10. package/dist-sdk/src/catalog/types.js +5 -0
  11. package/dist-sdk/src/core/index.d.ts +1 -1
  12. package/dist-sdk/src/core/index.js +1 -1
  13. package/dist-sdk/src/core/platform-id.d.ts +2 -0
  14. package/dist-sdk/src/core/platform-id.js +4 -0
  15. package/dist-sdk/src/core/system-fields.d.ts +14 -0
  16. package/dist-sdk/src/core/system-fields.js +6 -0
  17. package/dist-sdk/src/core/triggers/on-demand.d.ts +27 -24
  18. package/dist-sdk/src/core/triggers/on-demand.js +33 -12
  19. package/dist-sdk/src/core/types/aspect-category.d.ts +1 -0
  20. package/dist-sdk/src/core/types/aspect-category.js +1 -0
  21. package/dist-sdk/src/engine/build/context.d.ts +20 -8
  22. package/dist-sdk/src/engine/build/source-context.d.ts +14 -17
  23. package/dist-sdk/src/engine/build/source-context.js +1 -1
  24. package/dist-sdk/src/engine/pull/context.d.ts +9 -0
  25. package/dist-sdk/src/engine/pull/org.d.ts +4 -0
  26. package/dist-sdk/src/engine/pull/org.js +17 -2
  27. package/dist-sdk/src/engine/pull/procedure-refs.d.ts +16 -0
  28. package/dist-sdk/src/engine/pull/procedure-refs.js +69 -0
  29. package/dist-sdk/src/engine/tf/expr.js +1 -1
  30. package/dist-sdk/src/engine/workspace/authoring-layout.d.ts +15 -0
  31. package/dist-sdk/src/engine/workspace/authoring-layout.js +33 -1
  32. package/dist-sdk/src/engine/workspace/loader.d.ts +40 -0
  33. package/dist-sdk/src/engine/workspace/loader.js +328 -0
  34. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -0
  35. package/dist-sdk/src/entities/access-policy/from-tf.js +10 -2
  36. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +1 -0
  37. package/dist-sdk/src/entities/access-policy/to-tf.js +7 -2
  38. package/dist-sdk/src/entities/agent/build.d.ts +54 -8
  39. package/dist-sdk/src/entities/agent/build.js +36 -1
  40. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +126 -2
  41. package/dist-sdk/src/entities/agent/from-tf.d.ts +7 -6
  42. package/dist-sdk/src/entities/agent/from-tf.js +176 -5
  43. package/dist-sdk/src/entities/agent/index.d.ts +2 -2
  44. package/dist-sdk/src/entities/agent/index.js +1 -1
  45. package/dist-sdk/src/entities/agent/to-tf.d.ts +4 -4
  46. package/dist-sdk/src/entities/agent/to-tf.js +185 -11
  47. package/dist-sdk/src/entities/agent/tools.d.ts +16 -5
  48. package/dist-sdk/src/entities/agent/tools.js +13 -1
  49. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +7 -0
  50. package/dist-sdk/src/entities/agent-tool/from-tf.js +29 -4
  51. package/dist-sdk/src/entities/agent-tool/to-tf.js +10 -9
  52. package/dist-sdk/src/entities/agent-tool/types.js +1 -0
  53. package/dist-sdk/src/entities/app/build.d.ts +2 -2
  54. package/dist-sdk/src/entities/app/build.js +6 -3
  55. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +5 -0
  56. package/dist-sdk/src/entities/app/display-blocks-to-layout.d.ts +45 -0
  57. package/dist-sdk/src/entities/app/display-blocks-to-layout.js +98 -0
  58. package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.d.ts +55 -0
  59. package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.js +99 -0
  60. package/dist-sdk/src/entities/app/from-tf.js +9 -7
  61. package/dist-sdk/src/entities/app/to-tf.js +15 -7
  62. package/dist-sdk/src/entities/automation/build.d.ts +8 -1
  63. package/dist-sdk/src/entities/automation/build.js +36 -5
  64. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +3 -7
  65. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +2 -0
  66. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +77 -8
  67. package/dist-sdk/src/entities/automation/from-tf.d.ts +10 -1
  68. package/dist-sdk/src/entities/automation/from-tf.js +803 -62
  69. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  70. package/dist-sdk/src/entities/automation/module.js +13 -3
  71. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +12 -4
  72. package/dist-sdk/src/entities/automation/output-key-wire-name.js +17 -6
  73. package/dist-sdk/src/entities/automation/script-code.d.ts +1 -1
  74. package/dist-sdk/src/entities/automation/script-code.js +15 -11
  75. package/dist-sdk/src/entities/automation/task-label.d.ts +2 -0
  76. package/dist-sdk/src/entities/automation/task-label.js +18 -0
  77. package/dist-sdk/src/entities/automation/tasks.d.ts +60 -9
  78. package/dist-sdk/src/entities/automation/tasks.js +16 -4
  79. package/dist-sdk/src/entities/automation/to-tf.d.ts +4 -0
  80. package/dist-sdk/src/entities/automation/to-tf.js +385 -52
  81. package/dist-sdk/src/entities/automation/triggers.d.ts +14 -5
  82. package/dist-sdk/src/entities/automation/triggers.js +1 -1
  83. package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
  84. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
  85. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +1 -1
  86. package/dist-sdk/src/entities/element/build.d.ts +30 -7
  87. package/dist-sdk/src/entities/element/build.js +6 -3
  88. package/dist-sdk/src/entities/element/from-tf.js +7 -3
  89. package/dist-sdk/src/entities/element/index.d.ts +1 -1
  90. package/dist-sdk/src/entities/element/index.js +1 -1
  91. package/dist-sdk/src/entities/element/to-tf.js +49 -8
  92. package/dist-sdk/src/entities/field/from-tf.d.ts +6 -0
  93. package/dist-sdk/src/entities/field/from-tf.js +12 -0
  94. package/dist-sdk/src/entities/field/module.js +1 -0
  95. package/dist-sdk/src/entities/field/to-tf.d.ts +1 -1
  96. package/dist-sdk/src/entities/field/to-tf.js +19 -5
  97. package/dist-sdk/src/entities/org/category-ref.d.ts +5 -0
  98. package/dist-sdk/src/entities/org/category-ref.js +12 -0
  99. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -3
  100. package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +1 -0
  101. package/dist-sdk/src/entities/record-create-form/to-tf.js +13 -5
  102. package/dist-sdk/src/entities/relationship/from-tf.js +15 -4
  103. package/dist-sdk/src/entities/role/from-tf.js +10 -4
  104. package/dist-sdk/src/entities/search-table/build.d.ts +1 -1
  105. package/dist-sdk/src/entities/search-table/from-tf.d.ts +1 -0
  106. package/dist-sdk/src/entities/search-table/from-tf.js +6 -0
  107. package/dist-sdk/src/entities/search-table/printer.js +3 -1
  108. package/dist-sdk/src/entities/search-table/to-tf.js +3 -3
  109. package/dist-sdk/src/entities/search-table/types.js +1 -0
  110. package/dist-sdk/src/entities/service-account/from-tf.js +10 -4
  111. package/dist-sdk/src/entities/service-account/to-tf.d.ts +2 -1
  112. package/dist-sdk/src/entities/service-account/to-tf.js +7 -0
  113. package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -1
  114. package/dist-sdk/src/entities/shared/filters/ast.js +3 -0
  115. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +7 -1
  116. package/dist-sdk/src/entities/shared/filters/tf-codec.js +8 -4
  117. package/dist-sdk/src/entities/shared/handle-description.d.ts +12 -0
  118. package/dist-sdk/src/entities/shared/handle-description.js +20 -0
  119. package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -1
  120. package/dist-sdk/src/entities/shared/types/field-types.js +5 -8
  121. package/dist-sdk/src/entities/skill/build.d.ts +51 -2
  122. package/dist-sdk/src/entities/skill/build.js +65 -8
  123. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +35 -3
  124. package/dist-sdk/src/entities/skill/from-tf.d.ts +11 -0
  125. package/dist-sdk/src/entities/skill/from-tf.js +39 -7
  126. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  127. package/dist-sdk/src/entities/skill/index.js +1 -1
  128. package/dist-sdk/src/entities/skill/input-coverage.d.ts +21 -0
  129. package/dist-sdk/src/entities/skill/input-coverage.js +148 -5
  130. package/dist-sdk/src/entities/skill/to-tf.d.ts +6 -25
  131. package/dist-sdk/src/entities/skill/to-tf.js +22 -38
  132. package/dist-sdk/src/entities/skill/tools.d.ts +2 -1
  133. package/dist-sdk/src/entities/skill/tools.js +3 -1
  134. package/dist-sdk/src/entities/skill-tool/from-tf.js +10 -3
  135. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +5 -5
  136. package/dist-sdk/src/entities/skill-tool/to-tf.js +5 -7
  137. package/dist-sdk/src/entities/table/to-tf.js +3 -4
  138. package/dist-sdk/src/entities/task/to-tf.js +3 -2
  139. package/dist-sdk/src/entities/view/from-tf.js +36 -10
  140. package/dist-sdk/src/entities/view/to-tf.d.ts +2 -0
  141. package/dist-sdk/src/entities/view/to-tf.js +44 -30
  142. package/dist-sdk/src/entities/widget/from-tf.js +2 -2
  143. package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
  144. package/dist-sdk/src/entities/widget/to-tf.js +52 -23
  145. package/dist-sdk/src/graph/index.d.ts +19 -1
  146. package/dist-sdk/src/graph/index.js +20 -0
  147. package/dist-sdk/src/graph/types.d.ts +19 -0
  148. package/package.json +10 -5
@@ -10,10 +10,10 @@
10
10
  * app_id as the owning app's resource ref, the connector as a
11
11
  * `data.elementum_ai_provider_connector` ref, agent-prefixed tool labels.
12
12
  * `skillAccess` emits `skill_access_config` (confirmed live against the
13
- * provider's `elementum_agent` schema). Authoring knobs the terraform
14
- * dialect still doesn't carry (temperature, reasoningEffort,
15
- * startingActions, …) degrade through `diagnostics` — reported, never
16
- * silent (plan §4.3).
13
+ * provider's `elementum_agent` schema). `startingActions` emit
14
+ * `starting_actions` (issue #760). Authoring knobs the terraform dialect
15
+ * still doesn't carry (temperature, reasoningEffort, …) degrade through
16
+ * `diagnostics` — reported, never silent (plan §4.3).
17
17
  */
18
18
  import { workspaceAspectKey } from "../../engine/build/context.js";
19
19
  import { EntityTfError } from "../../engine/entity.js";
@@ -30,19 +30,149 @@ import { AGENT_RESOURCE_TYPE } from "./module.js";
30
30
  * Config knobs `agent` accepts that the terraform dialect does not
31
31
  * carry (yet). `runAs`/`agentAuthentication`/`a2aStreaming`/
32
32
  * `conversationIdleTimeout` moved out of this list in issue #170,
33
- * `a2aCreateRecordEnabled` in issue #215 — they're now emitted (see the
34
- * attrs assembly below); the encoders below still drop a value that
35
- * doesn't fit the terraform-path shape, diagnosed individually rather
36
- * than through this blanket list.
33
+ * `a2aCreateRecordEnabled` in issue #215, `startingActions` in issue
34
+ * #760 — they're now emitted (see the attrs assembly below); the
35
+ * encoders below still drop a value that doesn't fit the terraform-path
36
+ * shape, diagnosed individually rather than through this blanket list.
37
37
  */
38
38
  const UNSUPPORTED_AGENT_KNOBS = [
39
39
  "temperature",
40
40
  "reasoningEffort",
41
- "startingActions",
42
41
  "avatarAttachmentId",
43
42
  "managedById",
44
43
  "serviceAccountId",
45
44
  ];
45
+ const STARTING_ACTION_VARIABLE_TYPES = new Set(["TEXT", "NUMBER", "SELECT"]);
46
+ function startingActionValidationValue(validation, variableKey, where, diagnostics) {
47
+ const value = {};
48
+ if (validation.minLength !== undefined) {
49
+ if (typeof validation.minLength === "number" && Number.isSafeInteger(validation.minLength)) {
50
+ value["min_length"] = validation.minLength;
51
+ }
52
+ else {
53
+ diagnostics.push(`${where}: starting action variable "${variableKey}" has non-integer validation minLength ${JSON.stringify(validation.minLength)}; dropped`);
54
+ }
55
+ }
56
+ if (validation.maxLength !== undefined) {
57
+ if (typeof validation.maxLength === "number" && Number.isSafeInteger(validation.maxLength)) {
58
+ value["max_length"] = validation.maxLength;
59
+ }
60
+ else {
61
+ diagnostics.push(`${where}: starting action variable "${variableKey}" has non-integer validation maxLength ${JSON.stringify(validation.maxLength)}; dropped`);
62
+ }
63
+ }
64
+ if (typeof validation.pattern === "string" && validation.pattern !== "")
65
+ value["pattern"] = validation.pattern;
66
+ if (typeof validation.errorMessage === "string" && validation.errorMessage !== "") {
67
+ value["error_message"] = validation.errorMessage;
68
+ }
69
+ return Object.keys(value).length > 0 ? value : undefined;
70
+ }
71
+ function startingActionVariableValue(variable, where, diagnostics) {
72
+ if (typeof variable.key !== "string" || variable.key === "") {
73
+ diagnostics.push(`${where}: starting action variable is missing key; dropped`);
74
+ return undefined;
75
+ }
76
+ if (typeof variable.label !== "string" || variable.label === "") {
77
+ diagnostics.push(`${where}: starting action variable "${variable.key}" is missing label; dropped`);
78
+ return undefined;
79
+ }
80
+ if (typeof variable.type !== "string" || !STARTING_ACTION_VARIABLE_TYPES.has(variable.type)) {
81
+ diagnostics.push(`${where}: starting action variable "${variable.key}" has unrecognized type ${JSON.stringify(variable.type)}; dropped`);
82
+ return undefined;
83
+ }
84
+ const value = {
85
+ key: variable.key,
86
+ label: variable.label,
87
+ type: variable.type,
88
+ };
89
+ if (variable.required === true)
90
+ value["required"] = true;
91
+ if (typeof variable.placeholder === "string" && variable.placeholder !== "") {
92
+ value["placeholder"] = variable.placeholder;
93
+ }
94
+ let options;
95
+ if (variable.options !== undefined && variable.options.length > 0) {
96
+ if (variable.type !== "SELECT") {
97
+ diagnostics.push(`${where}: starting action variable "${variable.key}" is type ${variable.type} but has options (only SELECT carries options); dropped`);
98
+ }
99
+ else {
100
+ const encoded = [];
101
+ for (const option of variable.options) {
102
+ if (typeof option.label !== "string" || typeof option.value !== "string") {
103
+ diagnostics.push(`${where}: starting action variable "${variable.key}" has an unrecognized option; dropped`);
104
+ continue;
105
+ }
106
+ encoded.push({ label: option.label, value: option.value });
107
+ }
108
+ if (encoded.length > 0)
109
+ options = encoded;
110
+ }
111
+ }
112
+ if (variable.type === "SELECT" && options === undefined) {
113
+ diagnostics.push(`${where}: starting action variable "${variable.key}" is type SELECT but has no valid options; dropped`);
114
+ return undefined;
115
+ }
116
+ if (options !== undefined)
117
+ value["options"] = options;
118
+ if (variable.validation !== undefined) {
119
+ const validation = startingActionValidationValue(variable.validation, variable.key, where, diagnostics);
120
+ if (validation !== undefined)
121
+ value["validation"] = validation;
122
+ }
123
+ return value;
124
+ }
125
+ function startingActionValue(action, where, diagnostics) {
126
+ if (typeof action.name !== "string" || action.name === "") {
127
+ diagnostics.push(`${where}: starting action is missing name; dropped`);
128
+ return undefined;
129
+ }
130
+ if (typeof action.prompt !== "string") {
131
+ diagnostics.push(`${where}: starting action "${action.name}" is missing prompt; dropped`);
132
+ return undefined;
133
+ }
134
+ if (typeof action.order !== "number" || !Number.isSafeInteger(action.order)) {
135
+ diagnostics.push(`${where}: starting action "${action.name}" is missing integer order; dropped`);
136
+ return undefined;
137
+ }
138
+ const value = {
139
+ name: action.name,
140
+ prompt: action.prompt,
141
+ order: action.order,
142
+ };
143
+ if (action.enabled === false)
144
+ value["enabled"] = false;
145
+ if (typeof action.icon === "string" && action.icon !== "")
146
+ value["icon"] = action.icon;
147
+ if (action.variables !== undefined && action.variables.length > 0) {
148
+ const variables = [];
149
+ for (const variable of action.variables) {
150
+ const encoded = startingActionVariableValue(variable, where, diagnostics);
151
+ if (encoded !== undefined)
152
+ variables.push(encoded);
153
+ }
154
+ if (variables.length > 0)
155
+ value["variables"] = variables;
156
+ }
157
+ return value;
158
+ }
159
+ /**
160
+ * Empty `variables`/`options` are OMITTED throughout, matching ei's exporter
161
+ * (`cmd/elementum/export/hcl_agent.go` only sets them when non-empty) —
162
+ * emitting `[]` here would break build-vs-export fidelity. The provider
163
+ * carries the other half of that contract: both attributes are
164
+ * Optional+Computed with an empty-list default, so an omitted list plans
165
+ * clean against the concrete list its Read hydrates.
166
+ */
167
+ function startingActionsValue(actions, where, diagnostics) {
168
+ const encoded = [];
169
+ for (const action of actions) {
170
+ const value = startingActionValue(action, where, diagnostics);
171
+ if (value !== undefined)
172
+ encoded.push(value);
173
+ }
174
+ return encoded.length > 0 ? encoded : undefined;
175
+ }
46
176
  /**
47
177
  * `runAs` authoring is the opaque object shape shared with agent-tool's
48
178
  * `runAs` (the remaining agent-level portion of board item B28(d));
@@ -215,13 +345,52 @@ export function agentToTf(entity, ctx) {
215
345
  }
216
346
  const payload = entity.payload;
217
347
  const elementum = payload?.agent?.elementum;
218
- if (payload === null || typeof payload !== "object" || elementum === undefined) {
219
- throw new EntityTfError(`agent "${entity.refName}" has no agent.elementum payload — was it built with agent?`);
348
+ const bedrock = payload?.agent?.bedrock;
349
+ if (payload === null || typeof payload !== "object" || (elementum === undefined && bedrock === undefined)) {
350
+ throw new EntityTfError(`agent "${entity.refName}" has no agent payload — was it built with agent or bedrockAgent?`);
220
351
  }
221
352
  // The bag key IS the label (the stable naming contract) — the agent's
222
353
  // refName comes from its file name, exactly like an app's.
223
354
  const agentBareTfLabel = tsLabelToTfLabel(entity.refName);
224
355
  const tfLabel = appScopedResourceLabel(ctx.appTfLabel, agentBareTfLabel);
356
+ if (bedrock !== undefined) {
357
+ const name = bedrock.name ?? "";
358
+ const where = `agent "${name}"`;
359
+ const attrs = {
360
+ app_id: expr.resourceAttr(APP_RESOURCE_TYPE, ctx.appTfLabel, ["id"]),
361
+ type: "bedrock",
362
+ name,
363
+ description: bedrock.description ?? "",
364
+ instructions: bedrock.instructions ?? "",
365
+ bedrock_agent_arn: bedrock.agentAliasArn ?? "",
366
+ };
367
+ if (bedrock.firstMessage !== undefined) {
368
+ attrs["first_message"] = bedrock.firstMessage;
369
+ }
370
+ const connector = bedrock.aiProviderConnectorId;
371
+ if (connector === undefined) {
372
+ ctx.diagnostics.push(`${where}: no provider connector token for bedrock agent`);
373
+ }
374
+ else {
375
+ const tsLabel = connector.parent !== undefined
376
+ ? `${connector.parent}.${connector.refName ?? ""}`
377
+ : (connector.refName ?? "");
378
+ const resolved = ctx.orgRefs.byTsLabel(CONNECTOR_ORG_BAG, tsLabel);
379
+ if (resolved === undefined) {
380
+ ctx.diagnostics.push(`${where}: connector token "${tsLabel}" is not in the org catalog — re-run \`elementum pull org --data-only\``);
381
+ }
382
+ else {
383
+ attrs["ai_provider_connector_id"] = expr.dataAttr("elementum_ai_provider_connector", resolved.tfLabel, ["id"]);
384
+ }
385
+ }
386
+ return {
387
+ blocks: [{ kind: "resource", type: AGENT_RESOURCE_TYPE, label: tfLabel, attrs }],
388
+ address: `${AGENT_RESOURCE_TYPE}.${tfLabel}`,
389
+ };
390
+ }
391
+ if (elementum === undefined) {
392
+ throw new EntityTfError(`agent "${entity.refName}" has no agent payload — was it built with agent or bedrockAgent?`);
393
+ }
225
394
  const name = elementum.name ?? "";
226
395
  const where = `agent "${name}"`;
227
396
  const attrs = {
@@ -248,6 +417,11 @@ export function agentToTf(entity, ctx) {
248
417
  attrs["a2a_streaming"] = elementum.a2aStreaming;
249
418
  if (elementum.a2aCreateRecordEnabled !== undefined)
250
419
  attrs["a2a_create_record_enabled"] = elementum.a2aCreateRecordEnabled;
420
+ if (elementum.startingActions !== undefined) {
421
+ const value = startingActionsValue(elementum.startingActions, where, ctx.diagnostics);
422
+ if (value !== undefined)
423
+ attrs["starting_actions"] = value;
424
+ }
251
425
  const connector = elementum.aiProviderConnectorId;
252
426
  if (connector === undefined) {
253
427
  ctx.diagnostics.push(`${where}: no connector token — the platform will pick a default model`);
@@ -52,6 +52,14 @@ export interface AgentSearchRawIdField {
52
52
  readonly description: string;
53
53
  }
54
54
  export type AgentSearchFieldInput<Target extends ToolTarget = ToolTarget> = AgentSearchField<Target> | AgentSearchRawIdField;
55
+ /** A runtime value supplied by the agent for a search filter variable. */
56
+ export interface AgentFilterVariable {
57
+ /** Stable platform identifier referenced by the filter JSON. */
58
+ readonly id: UnsafePlatformId;
59
+ readonly name: string;
60
+ readonly description: string;
61
+ readonly required: boolean;
62
+ }
55
63
  /** A typed target field exposed through a search-table tool's newer fields dialect. */
56
64
  export interface AgentSearchTableField<Target extends ElementCatalogRef = ElementCatalogRef> {
57
65
  readonly field: FieldRef<Target["refName"]>;
@@ -141,6 +149,7 @@ interface CommonToolOptions {
141
149
  export type SearchRecordsToolOptions<Target extends ToolTarget = ToolTarget> = CommonToolOptions & TargetOption<Target> & {
142
150
  readonly queryDescription: string;
143
151
  readonly fields?: readonly AgentSearchFieldInput<Target>[];
152
+ readonly filterVariables?: readonly AgentFilterVariable[];
144
153
  /** Pre-built wire `Filter` (may embed `FieldRef` tokens — resolved at deploy). */
145
154
  readonly filter?: Filter;
146
155
  /** Pre-built wire `Sort` (`{ orders: [{ field, direction }] }`). */
@@ -172,6 +181,7 @@ type SearchTableFieldDialect<Target extends ElementCatalogRef> = {
172
181
  export type SearchTableToolV2<Target extends ElementCatalogRef = ElementCatalogRef> = CommonToolOptions & TargetOption<Target> & {
173
182
  readonly table: SearchTableRef;
174
183
  readonly queryDescription: string;
184
+ readonly filterVariables?: readonly AgentFilterVariable[];
175
185
  readonly filter?: Filter;
176
186
  readonly limit?: number;
177
187
  } & SearchTableFieldDialect<Target>;
@@ -183,12 +193,13 @@ export declare function agentCreateRecord<Target extends ToolTarget>(opts: Creat
183
193
  export type UpdateRecordToolV2<Target extends ToolTarget = ToolTarget> = CommonToolOptions & TargetOption<Target> & {
184
194
  readonly fields?: readonly AgentRecordFieldInput<Target>[];
185
195
  /**
186
- * How the agent should identify which record to update — the provider
187
- * requires this (there's no way to infer it) and rejects an empty value
188
- * at apply with an opaque "Unable to validate" error, so it's required
189
- * here instead. Example: "Identify the ticket by its ID or subject line."
196
+ * How the agent should identify which record to update. Omit entirely
197
+ * when there's no description; the platform accepts that. An explicit
198
+ * empty string is always a mistake, never a valid value - it rejects that
199
+ * at apply with an opaque "Unable to validate" error.
200
+ * Example: "Identify the ticket by its ID or subject line."
190
201
  */
191
- readonly handleDescription: string;
202
+ readonly handleDescription?: string;
192
203
  };
193
204
  export declare function agentUpdateRecord<Target extends ToolTarget>(opts: UpdateRecordToolV2<Target>): AgentTool;
194
205
  type RelatedTargetOption<Target extends ToolTarget> = Target extends {
@@ -1,7 +1,16 @@
1
1
  import { isValidToolName } from "../agent-tool/types.js";
2
+ import { assertHandleDescriptionNotEmpty } from "../shared/handle-description.js";
2
3
  function targetOf(opts) {
3
4
  return ("app" in opts && opts.app !== undefined ? opts.app : opts.element);
4
5
  }
6
+ function filterVariableToken(variable) {
7
+ return {
8
+ id: variable.id.value,
9
+ name: variable.name,
10
+ description: variable.description,
11
+ required: variable.required,
12
+ };
13
+ }
5
14
  function serializeRunAs(runAs) {
6
15
  if ("currentUser" in runAs)
7
16
  return { currentUser: true };
@@ -109,6 +118,7 @@ export function agentSearchRecords(opts) {
109
118
  aspectId: targetOf(opts),
110
119
  queryDescription: opts.queryDescription,
111
120
  ...(opts.fields !== undefined ? { fields: opts.fields.map(searchFieldToken) } : {}),
121
+ ...(opts.filterVariables !== undefined ? { filterVariables: opts.filterVariables.map(filterVariableToken) } : {}),
112
122
  ...(opts.filter !== undefined ? { filter: opts.filter } : {}),
113
123
  ...(opts.sort !== undefined ? { sort: opts.sort } : {}),
114
124
  ...(opts.limit !== undefined ? { limit: opts.limit } : {}),
@@ -126,6 +136,7 @@ export function agentSearchTable(opts) {
126
136
  // legacy `return_fields` dialects while both carry typed FieldRefs.
127
137
  ...(opts.fields !== undefined ? { searchTableFields: opts.fields.map(searchTableFieldToken) } : {}),
128
138
  ...(opts.returnFields !== undefined ? { returnFields: opts.returnFields.map(returnFieldToken) } : {}),
139
+ ...(opts.filterVariables !== undefined ? { filterVariables: opts.filterVariables.map(filterVariableToken) } : {}),
129
140
  ...(opts.filter !== undefined ? { filter: opts.filter } : {}),
130
141
  ...(opts.limit !== undefined ? { limit: opts.limit } : {}),
131
142
  },
@@ -141,12 +152,13 @@ export function agentCreateRecord(opts) {
141
152
  });
142
153
  }
143
154
  export function agentUpdateRecord(opts) {
155
+ assertHandleDescriptionNotEmpty(opts.handleDescription, "agentUpdateRecord");
144
156
  return tool({
145
157
  updateRecord: {
146
158
  ...common(opts),
147
159
  aspectId: targetOf(opts),
148
160
  ...(opts.fields !== undefined ? { fields: opts.fields.map(recordFieldToken) } : {}),
149
- handleDescription: opts.handleDescription,
161
+ ...(opts.handleDescription !== undefined ? { handleDescription: opts.handleDescription } : {}),
150
162
  },
151
163
  });
152
164
  }
@@ -40,6 +40,12 @@ export interface NormalizedSearchTableReturnField {
40
40
  readonly name?: string;
41
41
  readonly displayName?: string;
42
42
  }
43
+ export interface NormalizedFilterVariable {
44
+ readonly id: string;
45
+ readonly name: string;
46
+ readonly description: string;
47
+ readonly required: boolean;
48
+ }
43
49
  export type NormalizedToolTarget = {
44
50
  readonly kind: "self";
45
51
  } | {
@@ -87,6 +93,7 @@ export interface NormalizedAgentTool {
87
93
  readonly target?: NormalizedToolTarget;
88
94
  /** createRecord/searchAspect/updateRecord only; searchTable ids are upgraded later by recursive pull. */
89
95
  readonly fields?: readonly NormalizedToolField[];
96
+ readonly filterVariables?: readonly NormalizedFilterVariable[];
90
97
  /** searchTable's newer field shape (field_id/name/description) — mutually exclusive with `returnFields`. */
91
98
  readonly searchTableFields?: readonly NormalizedSearchTableField[];
92
99
  /** searchTable's legacy field shape (field_id/name/display_name) — mutually exclusive with `searchTableFields`. */
@@ -168,6 +168,7 @@ export function toolFromTf(block, owner, ctx) {
168
168
  fieldScope = resolved.fieldScope;
169
169
  }
170
170
  let fields;
171
+ let filterVariables;
171
172
  let searchTableFields;
172
173
  const rawFields = attrs["fields"];
173
174
  if (Array.isArray(rawFields)) {
@@ -225,6 +226,27 @@ export function toolFromTf(block, owner, ctx) {
225
226
  else if (rawFields !== undefined) {
226
227
  ctx.diagnostics.push(`${where}: fields is not a list; dropped`);
227
228
  }
229
+ const rawFilterVariables = attrs["filter_variables"];
230
+ if (Array.isArray(rawFilterVariables)) {
231
+ filterVariables = [];
232
+ for (const item of rawFilterVariables) {
233
+ if (typeof item !== "object" || item === null || Array.isArray(item) || isTfExpr(item)) {
234
+ ctx.diagnostics.push(`${where}: filter_variables item has an unrecognized shape; dropped`);
235
+ continue;
236
+ }
237
+ const rec = item;
238
+ if (typeof rec["id"] !== "string" || rec["id"] === "" || typeof rec["name"] !== "string" || typeof rec["description"] !== "string" || typeof rec["required"] !== "boolean") {
239
+ ctx.diagnostics.push(`${where}: filter_variables item is missing a required attribute; dropped`);
240
+ continue;
241
+ }
242
+ filterVariables.push({ id: rec["id"], name: rec["name"], description: rec["description"], required: rec["required"] });
243
+ }
244
+ if (filterVariables.length === 0)
245
+ filterVariables = undefined;
246
+ }
247
+ else if (rawFilterVariables !== undefined) {
248
+ ctx.diagnostics.push(`${where}: filter_variables is not a list; dropped`);
249
+ }
228
250
  // The provider export normalizes searchTable field_id to a raw platform id.
229
251
  // Preserve it here; the recursive pull printer can upgrade known ids using
230
252
  // the target element's dependency field registry.
@@ -254,9 +276,6 @@ export function toolFromTf(block, owner, ctx) {
254
276
  else if (rawReturnFields !== undefined) {
255
277
  ctx.diagnostics.push(`${where}: return_fields is not a list; dropped`);
256
278
  }
257
- if (subType.typeKey === "searchAspect" && attrs["filter_variables"] !== undefined) {
258
- ctx.diagnostics.push(`${where}: filter_variables are not supported on the terraform path yet; a rebuilt stream will omit them`);
259
- }
260
279
  let searchTableKey;
261
280
  let searchTableName;
262
281
  if (subType.typeKey === "searchTable") {
@@ -301,6 +320,7 @@ export function toolFromTf(block, owner, ctx) {
301
320
  ...(target !== undefined && { target }),
302
321
  ...(relatedTarget !== undefined && { relatedTarget }),
303
322
  ...(fields !== undefined && { fields }),
323
+ ...(filterVariables !== undefined && { filterVariables }),
304
324
  ...(searchTableFields !== undefined && { searchTableFields }),
305
325
  ...(returnFields !== undefined && { returnFields }),
306
326
  ...((subType.typeKey === "searchAspect" || subType.typeKey === "searchTable") && {
@@ -308,7 +328,12 @@ export function toolFromTf(block, owner, ctx) {
308
328
  }),
309
329
  ...(typeof attrs["result_limit"] === "number" && { limit: attrs["result_limit"] }),
310
330
  ...(subType.typeKey === "updateRecord" && {
311
- handleDescription: optionalString(attrs, "handle_description", where, ctx) ?? "",
331
+ // A live "" is not reconstructable any more than a missing attribute
332
+ // is - agentUpdateRecord's own assertHandleDescriptionNotEmpty throws
333
+ // on an explicit "", so printing one straight into an
334
+ // agentUpdateRecord({...}) call would crash the next time this source
335
+ // loads. Collapse it to undefined here so the printer never sees it.
336
+ handleDescription: optionalString(attrs, "handle_description", where, ctx) || undefined,
312
337
  }),
313
338
  ...(searchTableKey !== undefined && { searchTableKey }),
314
339
  ...(searchTableName !== undefined && { searchTableName }),
@@ -15,8 +15,8 @@
15
15
  import { workspaceAspectKey } from "../../engine/build/context.js";
16
16
  import { automationRunTargetResourceAttr } from "../automation/to-tf.js";
17
17
  import { appScopedResourceLabel, expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
18
- import { EntityTfError } from "../../engine/entity.js";
19
18
  import { fieldRefToTfValue } from "../field/to-tf.js";
19
+ import { encodeOptionalHandleDescription } from "../shared/handle-description.js";
20
20
  import { TOOL_SUB_TYPE_BY_TYPE_KEY } from "./types.js";
21
21
  function serviceAccountIdValue(token, where, ctx) {
22
22
  if (token.__kind !== "serviceAccount" || token.name === undefined || token.name === "") {
@@ -305,14 +305,7 @@ export function toolToTf(entry, ctx) {
305
305
  attrs["related_target_id"] = resolveTarget(inner.relatedAspectId, ctx).value;
306
306
  }
307
307
  if (typeKey === "updateRecord") {
308
- if (inner.handleDescription === undefined || inner.handleDescription === "") {
309
- // The provider requires a non-empty handle_description and rejects an
310
- // empty one at apply with an opaque "Unable to validate" error — fail
311
- // loud at build time instead (same discipline as the tool-name check).
312
- throw new EntityTfError(`${where}: agentUpdateRecord requires a non-empty \`handleDescription\` — the platform ` +
313
- `uses it to identify which record to update and rejects an empty value at apply.`);
314
- }
315
- attrs["handle_description"] = inner.handleDescription;
308
+ encodeOptionalHandleDescription(attrs, inner.handleDescription);
316
309
  }
317
310
  if (typeKey === "searchAspect" || typeKey === "searchTable") {
318
311
  attrs["query_description"] = inner.queryDescription ?? "";
@@ -322,6 +315,14 @@ export function toolToTf(entry, ctx) {
322
315
  ctx.diagnostics.push(`${where}: filter/sort are not supported on the terraform path yet; dropped`);
323
316
  }
324
317
  }
318
+ if ((typeKey === "searchAspect" || typeKey === "searchTable") && inner.filterVariables !== undefined && inner.filterVariables.length > 0) {
319
+ attrs["filter_variables"] = inner.filterVariables.map((variable) => ({
320
+ id: typeof variable.id === "string" ? variable.id : variable.id?.value ?? "",
321
+ name: variable.name ?? "",
322
+ description: variable.description ?? "",
323
+ required: variable.required ?? false,
324
+ }));
325
+ }
325
326
  if (typeKey === "searchTable") {
326
327
  const table = inner.searchTableId;
327
328
  if (table?.refName === undefined || table.refName === "") {
@@ -81,6 +81,7 @@ export const KNOWN_TOOL_ATTRS = {
81
81
  "query_description",
82
82
  "result_limit",
83
83
  "fields",
84
+ "filter_variables",
84
85
  "return_fields",
85
86
  ]),
86
87
  relateRecord: new Set([
@@ -352,8 +352,8 @@ export interface AppV2Options<F extends Record<string, AppField> = Record<string
352
352
  readonly name: string;
353
353
  readonly category: AppCategory;
354
354
  readonly namespace?: string;
355
- /** The platform's aspect handle (business acronym, e.g. "PRD") — distinct from the refName. Omit to let the platform assign one. */
356
- readonly handle?: string;
355
+ /** Required platform aspect handle (business acronym, e.g. "PRD") — distinct from the refName. */
356
+ readonly handle: string;
357
357
  readonly description?: string;
358
358
  readonly icon?: string;
359
359
  readonly color?: string;
@@ -279,11 +279,14 @@ export const APP_HANDLE_RE = /^[a-zA-Z]+$/;
279
279
  * as an opaque platform error during apply. App-specific on purpose: elements
280
280
  * carry their own equivalent in `src/elements/build.ts`.
281
281
  *
282
- * - `handle` — letters only (a–z, A–Z), when provided (it's optional)
282
+ * - `handle` — required and letters only (a–z, A–Z)
283
283
  * - `namespace` — lowercase letters only (a–z), when provided
284
284
  */
285
285
  function validateAppOptions(opts) {
286
- if (opts.handle !== undefined && !APP_HANDLE_RE.test(opts.handle)) {
286
+ if (!opts.handle) {
287
+ throw new Error(`app "${opts.name}": handle is required by the platform.`);
288
+ }
289
+ if (!APP_HANDLE_RE.test(opts.handle)) {
287
290
  throw new Error(`app "${opts.name}": handle "${opts.handle}" must contain only letters (a–z, A–Z).`);
288
291
  }
289
292
  if (opts.namespace !== undefined && !/^[a-z]+$/.test(opts.namespace)) {
@@ -315,7 +318,7 @@ export function app(opts) {
315
318
  parent: refName,
316
319
  parentKind: kind,
317
320
  parentName: opts.name,
318
- fieldType: field.type,
321
+ fieldType: field.expression !== undefined ? "CALCULATED" : field.type,
319
322
  ...("dynamicSource" in field && field.dynamicSource === true ? { dynamicSource: true } : {}),
320
323
  ...(field.options !== undefined ? { options: picklistOptionLabels(field.options) } : {}),
321
324
  ...(field.tags !== undefined ? { tags: field.tags } : {}),
@@ -326,6 +326,11 @@ export interface NormalizedApp {
326
326
  readonly cloudLinkId?: string;
327
327
  readonly cloudLinkClientHandle?: string;
328
328
  readonly commentsEnabled?: boolean;
329
+ readonly cloudOptions?: {
330
+ readonly snowflake?: {
331
+ readonly hybridTable?: boolean;
332
+ };
333
+ };
329
334
  readonly cloudConnection?: NormalizedCloudConnectionSnowflake;
330
335
  /** Record-view (LAYOUT) display blocks, flat with `childKeys` linkage. */
331
336
  readonly displayBlocks?: readonly NormalizedDisplayBlock[];
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Compose→terraform bridge for `displayBlocks`/`recordCreateDisplayBlocks`.
3
+ * `serializeDisplayBlocks` (`display-blocks.ts`) turns the authored
4
+ * `DisplayBlock[]` into the GraphQL-compose wire shape consumed by `to-tf`
5
+ * payloads — this module maps THAT wire shape into `AppLayoutSectionWire[]`,
6
+ * the shape `viewToTf`/`layoutToTf` (`entities/view/to-tf.ts`) already knows
7
+ * how to emit as `elementum_layout`.
8
+ *
9
+ * Only `field`/`group` blocks have an `elementum_layout` equivalent — the
10
+ * provider's `sections` schema has no `widget`/`comments` section type (see
11
+ * `entities/view/types.ts`'s `SECTION_TYPE_TO_WIRE`). `widget`/`comments`
12
+ * blocks are diagnosed and dropped individually rather than killing the
13
+ * whole payload. `AppLayoutSectionWire` groups are flat (`fields` only) —
14
+ * a `group` nested inside a `group` is diagnosed and dropped (its own
15
+ * contents only; the outer group keeps its direct fields), since there is
16
+ * no nested-section shape to target.
17
+ *
18
+ * This is a pure, entity-agnostic transform (it knows nothing about apps or
19
+ * elements) — kept alongside `display-blocks.ts` rather than under
20
+ * `entities/element/`.
21
+ */
22
+ import type { AppLayoutSectionWire } from "../view/to-tf.js";
23
+ /**
24
+ * Maps serialized `displayBlocks` (the `Record<string, unknown>[]` shape
25
+ * `serializeDisplayBlocks` produces) into `elementum_layout` group sections.
26
+ *
27
+ * - A top-level `GROUP` block → one section (`name`/`icon`/`color`/
28
+ * `maxColumns` carried over, `fields` from its direct `FIELD` children).
29
+ * - Top-level `FIELD` blocks with no enclosing group are collected into one
30
+ * implicit group section named `"Details"` (the target shape requires a
31
+ * non-empty section name — see `IMPLICIT_GROUP_NAME`).
32
+ * Intentionally always appended LAST, after every named `GROUP` section,
33
+ * regardless of where the bare fields appeared relative to groups in the
34
+ * authored list — e.g. `[field, group]` renders as
35
+ * `[group, implicit-field-group]`. A single implicit group has no natural
36
+ * authored position of its own (it isn't one authored block, it's the
37
+ * union of every bare field), so a fixed, deterministic position was
38
+ * chosen over trying to infer one from interleaving.
39
+ * - `WIDGET`/`COMMENTS` blocks (top-level or nested) and nested `GROUP`
40
+ * blocks are diagnosed and dropped individually; everything else mappable
41
+ * in the same payload still lands. A block with no recognizable shape at
42
+ * all (not a record, or missing/malformed `properties.type`) is likewise
43
+ * diagnosed and dropped rather than silently ignored.
44
+ */
45
+ export declare function displayBlocksToLayoutSections(blocks: readonly unknown[], where: string, diagnostics: string[]): AppLayoutSectionWire[];