@elementumai/edk 0.9.6 → 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 (180) hide show
  1. package/README.md +34 -3
  2. package/dist-sdk/src/catalog/factories.d.ts +26 -6
  3. package/dist-sdk/src/catalog/factories.js +41 -6
  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 +93 -42
  8. package/dist-sdk/src/catalog/token.js +10 -0
  9. package/dist-sdk/src/catalog/types.d.ts +42 -3
  10. package/dist-sdk/src/catalog/types.js +5 -0
  11. package/dist-sdk/src/core/index.d.ts +2 -2
  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 +18 -0
  16. package/dist-sdk/src/core/system-fields.js +21 -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/app.d.ts +14 -9
  20. package/dist-sdk/src/core/types/aspect-category.d.ts +1 -0
  21. package/dist-sdk/src/core/types/aspect-category.js +1 -0
  22. package/dist-sdk/src/core/types/platform.d.ts +1 -1
  23. package/dist-sdk/src/engine/build/context.d.ts +24 -8
  24. package/dist-sdk/src/engine/build/source-context.d.ts +14 -17
  25. package/dist-sdk/src/engine/build/source-context.js +1 -1
  26. package/dist-sdk/src/engine/pull/context.d.ts +18 -0
  27. package/dist-sdk/src/engine/pull/org.d.ts +4 -0
  28. package/dist-sdk/src/engine/pull/org.js +17 -2
  29. package/dist-sdk/src/engine/pull/procedure-refs.d.ts +16 -0
  30. package/dist-sdk/src/engine/pull/procedure-refs.js +69 -0
  31. package/dist-sdk/src/engine/pull/ref-only.d.ts +14 -0
  32. package/dist-sdk/src/engine/pull/ref-only.js +35 -2
  33. package/dist-sdk/src/engine/tf/expr.js +1 -1
  34. package/dist-sdk/src/engine/workspace/authoring-layout.d.ts +15 -0
  35. package/dist-sdk/src/engine/workspace/authoring-layout.js +33 -1
  36. package/dist-sdk/src/engine/workspace/loader.d.ts +40 -0
  37. package/dist-sdk/src/engine/workspace/loader.js +328 -0
  38. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -0
  39. package/dist-sdk/src/entities/access-policy/from-tf.js +24 -4
  40. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +7 -0
  41. package/dist-sdk/src/entities/access-policy/to-tf.js +11 -3
  42. package/dist-sdk/src/entities/agent/build.d.ts +54 -8
  43. package/dist-sdk/src/entities/agent/build.js +36 -1
  44. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +144 -3
  45. package/dist-sdk/src/entities/agent/from-tf.d.ts +7 -6
  46. package/dist-sdk/src/entities/agent/from-tf.js +176 -5
  47. package/dist-sdk/src/entities/agent/index.d.ts +2 -2
  48. package/dist-sdk/src/entities/agent/index.js +1 -1
  49. package/dist-sdk/src/entities/agent/module.js +1 -0
  50. package/dist-sdk/src/entities/agent/to-tf.d.ts +5 -4
  51. package/dist-sdk/src/entities/agent/to-tf.js +186 -11
  52. package/dist-sdk/src/entities/agent/tools.d.ts +16 -5
  53. package/dist-sdk/src/entities/agent/tools.js +13 -1
  54. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +16 -0
  55. package/dist-sdk/src/entities/agent-tool/from-tf.js +39 -6
  56. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -0
  57. package/dist-sdk/src/entities/agent-tool/to-tf.js +12 -12
  58. package/dist-sdk/src/entities/agent-tool/types.js +1 -0
  59. package/dist-sdk/src/entities/app/build.d.ts +44 -24
  60. package/dist-sdk/src/entities/app/build.js +18 -8
  61. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +15 -0
  62. package/dist-sdk/src/entities/app/display-blocks-to-layout.d.ts +45 -0
  63. package/dist-sdk/src/entities/app/display-blocks-to-layout.js +98 -0
  64. package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.d.ts +55 -0
  65. package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.js +99 -0
  66. package/dist-sdk/src/entities/app/from-tf.js +79 -14
  67. package/dist-sdk/src/entities/app/index.d.ts +3 -2
  68. package/dist-sdk/src/entities/app/index.js +2 -1
  69. package/dist-sdk/src/entities/app/to-tf.js +30 -6
  70. package/dist-sdk/src/entities/automation/build.d.ts +37 -18
  71. package/dist-sdk/src/entities/automation/build.js +121 -12
  72. package/dist-sdk/src/entities/automation/catalog-render.js +5 -2
  73. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +8 -10
  74. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +2 -0
  75. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +103 -20
  76. package/dist-sdk/src/entities/automation/from-tf.d.ts +10 -1
  77. package/dist-sdk/src/entities/automation/from-tf.js +1165 -91
  78. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  79. package/dist-sdk/src/entities/automation/module.js +15 -5
  80. package/dist-sdk/src/entities/automation/operators.d.ts +2 -2
  81. package/dist-sdk/src/entities/automation/operators.js +1 -0
  82. package/dist-sdk/src/entities/automation/output-field-types.d.ts +17 -0
  83. package/dist-sdk/src/entities/automation/output-field-types.js +45 -0
  84. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +20 -4
  85. package/dist-sdk/src/entities/automation/output-key-wire-name.js +33 -6
  86. package/dist-sdk/src/entities/automation/script-code.d.ts +1 -1
  87. package/dist-sdk/src/entities/automation/script-code.js +168 -36
  88. package/dist-sdk/src/entities/automation/task-label.d.ts +2 -0
  89. package/dist-sdk/src/entities/automation/task-label.js +18 -0
  90. package/dist-sdk/src/entities/automation/tasks.d.ts +159 -45
  91. package/dist-sdk/src/entities/automation/tasks.js +60 -47
  92. package/dist-sdk/src/entities/automation/to-tf.d.ts +7 -1
  93. package/dist-sdk/src/entities/automation/to-tf.js +816 -87
  94. package/dist-sdk/src/entities/automation/triggers.d.ts +14 -5
  95. package/dist-sdk/src/entities/automation/triggers.js +1 -1
  96. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +78 -0
  97. package/dist-sdk/src/entities/automation/value-ref-tf.js +193 -0
  98. package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
  99. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
  100. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +1 -1
  101. package/dist-sdk/src/entities/element/build.d.ts +30 -7
  102. package/dist-sdk/src/entities/element/build.js +7 -3
  103. package/dist-sdk/src/entities/element/from-tf.js +7 -3
  104. package/dist-sdk/src/entities/element/index.d.ts +3 -2
  105. package/dist-sdk/src/entities/element/index.js +3 -2
  106. package/dist-sdk/src/entities/element/to-tf.js +49 -8
  107. package/dist-sdk/src/entities/field/build.d.ts +94 -3
  108. package/dist-sdk/src/entities/field/build.js +82 -3
  109. package/dist-sdk/src/entities/field/from-tf.d.ts +6 -0
  110. package/dist-sdk/src/entities/field/from-tf.js +104 -1
  111. package/dist-sdk/src/entities/field/locals.js +6 -7
  112. package/dist-sdk/src/entities/field/module.js +1 -0
  113. package/dist-sdk/src/entities/field/options.d.ts +2 -0
  114. package/dist-sdk/src/entities/field/options.js +12 -2
  115. package/dist-sdk/src/entities/field/record-shape.d.ts +12 -15
  116. package/dist-sdk/src/entities/field/to-tf.d.ts +13 -3
  117. package/dist-sdk/src/entities/field/to-tf.js +191 -56
  118. package/dist-sdk/src/entities/field/types.js +2 -0
  119. package/dist-sdk/src/entities/org/category-ref.d.ts +5 -0
  120. package/dist-sdk/src/entities/org/category-ref.js +12 -0
  121. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -3
  122. package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +1 -0
  123. package/dist-sdk/src/entities/record-create-form/to-tf.js +18 -13
  124. package/dist-sdk/src/entities/relationship/from-tf.js +100 -7
  125. package/dist-sdk/src/entities/role/from-tf.js +10 -4
  126. package/dist-sdk/src/entities/search-table/build.d.ts +1 -1
  127. package/dist-sdk/src/entities/search-table/from-tf.d.ts +1 -0
  128. package/dist-sdk/src/entities/search-table/from-tf.js +6 -0
  129. package/dist-sdk/src/entities/search-table/printer.js +3 -1
  130. package/dist-sdk/src/entities/search-table/to-tf.js +3 -3
  131. package/dist-sdk/src/entities/search-table/types.js +1 -0
  132. package/dist-sdk/src/entities/service-account/from-tf.js +10 -4
  133. package/dist-sdk/src/entities/service-account/to-tf.d.ts +2 -1
  134. package/dist-sdk/src/entities/service-account/to-tf.js +7 -0
  135. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +9 -0
  136. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +39 -0
  137. package/dist-sdk/src/entities/shared/filters/ast.d.ts +24 -1
  138. package/dist-sdk/src/entities/shared/filters/ast.js +4 -0
  139. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +13 -2
  140. package/dist-sdk/src/entities/shared/filters/tf-codec.js +14 -8
  141. package/dist-sdk/src/entities/shared/handle-description.d.ts +12 -0
  142. package/dist-sdk/src/entities/shared/handle-description.js +20 -0
  143. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +5 -3
  144. package/dist-sdk/src/entities/shared/tool-field-ref.js +11 -16
  145. package/dist-sdk/src/entities/shared/types/common.d.ts +7 -5
  146. package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -1
  147. package/dist-sdk/src/entities/shared/types/field-types.js +5 -8
  148. package/dist-sdk/src/entities/shared/types/platform.d.ts +15 -2
  149. package/dist-sdk/src/entities/skill/build.d.ts +51 -2
  150. package/dist-sdk/src/entities/skill/build.js +65 -8
  151. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
  152. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +79 -18
  153. package/dist-sdk/src/entities/skill/from-tf.d.ts +11 -0
  154. package/dist-sdk/src/entities/skill/from-tf.js +47 -5
  155. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  156. package/dist-sdk/src/entities/skill/index.js +1 -1
  157. package/dist-sdk/src/entities/skill/input-coverage.d.ts +89 -0
  158. package/dist-sdk/src/entities/skill/input-coverage.js +327 -0
  159. package/dist-sdk/src/entities/skill/module.js +2 -0
  160. package/dist-sdk/src/entities/skill/to-tf.d.ts +9 -25
  161. package/dist-sdk/src/entities/skill/to-tf.js +29 -40
  162. package/dist-sdk/src/entities/skill/tools.d.ts +12 -2
  163. package/dist-sdk/src/entities/skill/tools.js +3 -6
  164. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +19 -0
  165. package/dist-sdk/src/entities/skill-tool/from-tf.js +50 -14
  166. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +9 -7
  167. package/dist-sdk/src/entities/skill-tool/to-tf.js +29 -23
  168. package/dist-sdk/src/entities/table/to-tf.js +21 -5
  169. package/dist-sdk/src/entities/task/to-tf.js +3 -2
  170. package/dist-sdk/src/entities/view/from-tf.js +36 -10
  171. package/dist-sdk/src/entities/view/to-tf.d.ts +2 -0
  172. package/dist-sdk/src/entities/view/to-tf.js +49 -30
  173. package/dist-sdk/src/entities/visual-flow/from-tf.js +6 -2
  174. package/dist-sdk/src/entities/widget/from-tf.js +2 -2
  175. package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
  176. package/dist-sdk/src/entities/widget/to-tf.js +52 -23
  177. package/dist-sdk/src/graph/index.d.ts +19 -1
  178. package/dist-sdk/src/graph/index.js +20 -0
  179. package/dist-sdk/src/graph/types.d.ts +22 -0
  180. package/package.json +11 -5
@@ -48,17 +48,65 @@ function printConnectorToken(connectorKey) {
48
48
  export function printAgentV2(agent, opts) {
49
49
  const { appRefName } = opts;
50
50
  const crossOrg = opts.crossOrg === true;
51
+ if (agent.type === "bedrock") {
52
+ const lines = [];
53
+ lines.push("/**");
54
+ lines.push(` * ${agent.name}`);
55
+ lines.push(" *");
56
+ lines.push(" * Auto-generated by EDK (v2 pull). Hand-edit freely; the generator is a");
57
+ lines.push(" * one-shot starting point, not a live-binding view.");
58
+ lines.push(" */");
59
+ lines.push("");
60
+ lines.push(`import { bedrockAgent } from "${sdkPackageSpecifier("agents")}";`);
61
+ lines.push(`import catalog from "@catalog";`);
62
+ lines.push("");
63
+ const identifier = safeIdentifier(agent.refName, "agent");
64
+ lines.push(`const ${identifier} = bedrockAgent({`);
65
+ lines.push(` name: ${quote(agent.name)},`);
66
+ lines.push(` app: catalog.${appRefName},`);
67
+ if (agent.description !== undefined && agent.description !== "") {
68
+ lines.push(` description: ${quote(agent.description)},`);
69
+ }
70
+ const connectorMatchesDestination = agent.connectorKey !== undefined && (opts.destinationConnectorKeys?.has(agent.connectorKey) ?? false);
71
+ if (opts.connectorKeyOverride !== undefined) {
72
+ lines.push(` provider: ${printConnectorToken(opts.connectorKeyOverride)},`);
73
+ }
74
+ else if (agent.connectorKey !== undefined && crossOrg && !connectorMatchesDestination) {
75
+ lines.push(` provider: ${TODO_CONNECTOR_TOKEN}, // TODO: cross-org clone — provider "${agent.connectorKey}" was resolved in the SOURCE org; verify/replace with the destination org's catalog.aiProviders.<provider>.models.<model>`);
76
+ }
77
+ else if (agent.connectorKey !== undefined) {
78
+ lines.push(` provider: ${printConnectorToken(agent.connectorKey)},`);
79
+ }
80
+ else {
81
+ lines.push(` provider: ${TODO_CONNECTOR_TOKEN}, // TODO: no provider connector in the export — pick one`);
82
+ }
83
+ lines.push(` agentAliasArn: ${quote(agent.bedrockAgentArn ?? "")},`);
84
+ if (agent.instructions !== undefined && agent.instructions !== "") {
85
+ lines.push(` instructions: ${quote(agent.instructions)},`);
86
+ }
87
+ if (agent.firstMessage !== undefined && agent.firstMessage !== "") {
88
+ lines.push(` firstMessage: ${quote(agent.firstMessage)},`);
89
+ }
90
+ lines.push("});");
91
+ lines.push("");
92
+ lines.push(`export default ${identifier};`);
93
+ lines.push("");
94
+ return lines.join("\n");
95
+ }
51
96
  const usesServiceAccountRef = (agent.runAs !== undefined && "serviceAccount" in agent.runAs) ||
52
97
  agent.tools.some((tool) => tool.runAs !== undefined && "serviceAccount" in tool.runAs);
98
+ const usesStartingActionVariableType = agent.startingActions?.some((action) => (action.variables?.length ?? 0) > 0) === true;
53
99
  const factories = [
54
100
  ...new Set([
55
101
  ...agent.tools.map((t) => TOOL_FACTORY_BY_TYPE_KEY[t.typeKey]).filter(Boolean),
56
102
  ...(usesServiceAccountRef ? ["serviceAccountRef"] : []),
103
+ ...(usesStartingActionVariableType ? ["agentStartingActionVariableType"] : []),
57
104
  ]),
58
105
  ].sort();
59
106
  const usesUnsafePlatformId = agent.tools.some((tool) => {
60
107
  const targetOwner = searchTableTargetOwnerRefName(tool, appRefName, opts.foreignAppRefNames, opts.foreignElementRefNames);
61
- return (tool.fields?.some((field) => field.rawFieldId !== undefined) === true ||
108
+ return ((tool.filterVariables?.length ?? 0) > 0 ||
109
+ tool.fields?.some((field) => field.rawFieldId !== undefined) === true ||
62
110
  tool.searchTableFields?.some((field) => !searchTableFieldMatchesTarget(field.fieldId, targetOwner, opts.foreignFieldRefsById)) === true ||
63
111
  tool.returnFields?.some((field) => !searchTableFieldMatchesTarget(field.fieldId, targetOwner, opts.foreignFieldRefsById)) === true);
64
112
  });
@@ -106,11 +154,18 @@ export function printAgentV2(agent, opts) {
106
154
  lines.push(` connector: ${TODO_CONNECTOR_TOKEN}, // TODO: no connector in the export — pick one`);
107
155
  }
108
156
  lines.push(` description: ${quote(agent.description)},`);
109
- lines.push(` instructions: ${quote(agent.instructions)},`);
157
+ lines.push(` instructions: ${quote(agent.instructions ?? "")},`);
110
158
  if (agent.firstMessage !== undefined)
111
159
  lines.push(` firstMessage: ${quote(agent.firstMessage)},`);
112
160
  if (agent.maxLength !== undefined)
113
161
  lines.push(` maxLength: ${String(agent.maxLength)},`);
162
+ if (agent.startingActions !== undefined && agent.startingActions.length > 0) {
163
+ lines.push(" startingActions: [");
164
+ for (const action of agent.startingActions) {
165
+ lines.push(...printStartingAction(action).map((l) => ` ${l}`));
166
+ }
167
+ lines.push(" ],");
168
+ }
114
169
  if (agent.skillAccess !== undefined) {
115
170
  lines.push(...printSkillAccess(agent.skillAccess, appRefName, crossOrg).map((l) => ` ${l}`));
116
171
  }
@@ -178,6 +233,68 @@ function printSkillRefToken(ref, appRefName, crossOrg) {
178
233
  : "";
179
234
  return `{ __kind: "skill", refName: ${quote(ref.name)}, name: ${quote(ref.name)}, parent: ${quote(ref.appRefName ?? ref.appName)}, parentName: ${quote(ref.appName)} },${todo}`;
180
235
  }
236
+ function printStartingActionVariableType(type) {
237
+ if (type === "NUMBER")
238
+ return "agentStartingActionVariableType.number";
239
+ if (type === "SELECT")
240
+ return "agentStartingActionVariableType.select";
241
+ return "agentStartingActionVariableType.text";
242
+ }
243
+ function printStartingActionVariable(variable) {
244
+ const lines = [
245
+ "{",
246
+ ` key: ${quote(variable.key)},`,
247
+ ` label: ${quote(variable.label)},`,
248
+ ];
249
+ if (variable.placeholder !== undefined)
250
+ lines.push(` placeholder: ${quote(variable.placeholder)},`);
251
+ lines.push(` type: ${printStartingActionVariableType(variable.type)},`);
252
+ if (variable.required === true)
253
+ lines.push(" required: true,");
254
+ if (variable.type === "SELECT") {
255
+ lines.push(" options: [");
256
+ for (const option of variable.options) {
257
+ lines.push(` { value: ${quote(option.value)}, label: ${quote(option.label)} },`);
258
+ }
259
+ lines.push(" ],");
260
+ }
261
+ if (variable.validation !== undefined) {
262
+ const validation = variable.validation;
263
+ lines.push(" validation: {");
264
+ if (validation.pattern !== undefined)
265
+ lines.push(` pattern: ${quote(validation.pattern)},`);
266
+ if (validation.minLength !== undefined)
267
+ lines.push(` minLength: ${String(validation.minLength)},`);
268
+ if (validation.maxLength !== undefined)
269
+ lines.push(` maxLength: ${String(validation.maxLength)},`);
270
+ if (validation.errorMessage !== undefined)
271
+ lines.push(` errorMessage: ${quote(validation.errorMessage)},`);
272
+ lines.push(" },");
273
+ }
274
+ lines.push("},");
275
+ return lines;
276
+ }
277
+ function printStartingAction(action) {
278
+ const lines = [
279
+ "{",
280
+ ` name: ${quote(action.name)},`,
281
+ ` prompt: ${quote(action.prompt)},`,
282
+ ` order: ${String(action.order)},`,
283
+ ];
284
+ if (action.enabled === false)
285
+ lines.push(" enabled: false,");
286
+ if (action.icon !== undefined)
287
+ lines.push(` icon: ${quote(action.icon)},`);
288
+ if (action.variables !== undefined && action.variables.length > 0) {
289
+ lines.push(" variables: [");
290
+ for (const variable of action.variables) {
291
+ lines.push(...printStartingActionVariable(variable).map((l) => ` ${l}`));
292
+ }
293
+ lines.push(" ],");
294
+ }
295
+ lines.push("},");
296
+ return lines;
297
+ }
181
298
  function printSkillAccess(access, appRefName, crossOrg) {
182
299
  const hasPreloaded = access.preloadedSkills !== undefined && access.preloadedSkills.length > 0;
183
300
  if (access.mode !== "CUSTOM" && !hasPreloaded) {
@@ -257,6 +374,8 @@ function printA2ASkill(skill) {
257
374
  function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames) {
258
375
  if (tool.target === undefined || tool.target.kind === "self")
259
376
  return { kind: "catalog", expr: `catalog.${appRefName}` };
377
+ if (tool.target.kind === "unresolved")
378
+ return { kind: "raw", entityType: "app", name: tool.target.uuid };
260
379
  if (tool.target.kind === "foreignApp") {
261
380
  const foreignRefName = foreignAppRefNames?.get(tool.target.name);
262
381
  return foreignRefName !== undefined
@@ -355,6 +474,13 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
355
474
  // element.)
356
475
  lines.push(` ${tool.typeKey === "searchTable" ? "element" : "app"}: catalog.${appRefName},`);
357
476
  }
477
+ else if (tool.target?.kind === "unresolved") {
478
+ // Export couldn't resolve target_id to any portable app/element
479
+ // reference (board issue #648) — keep the raw platform id visible and
480
+ // cast past the type system instead of silently dropping the tool.
481
+ const entityKind = tool.typeKey === "searchTable" ? "element" : "app";
482
+ lines.push(` ${entityKind}: ${quote(tool.target.uuid)} as any /* TODO: unresolved ${entityKind} - export couldn't resolve target_id to a portable reference; replace with a real ref before deploying */,`);
483
+ }
358
484
  else if (tool.target !== undefined && tool.target.kind === "foreignApp") {
359
485
  const foreignRefName = foreignAppRefNames?.get(tool.target.name);
360
486
  if (foreignRefName !== undefined) {
@@ -390,6 +516,12 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
390
516
  if (tool.typeKey === "relateRecord" && tool.relatedTarget?.kind === "self") {
391
517
  lines.push(` relatedApp: catalog.${appRefName},`);
392
518
  }
519
+ else if (tool.typeKey === "relateRecord" && tool.relatedTarget?.kind === "unresolved") {
520
+ // Export couldn't resolve related_target_id to any portable reference
521
+ // (board issue #648) — keep the raw platform id visible instead of
522
+ // silently dropping the tool.
523
+ lines.push(` relatedApp: ${quote(tool.relatedTarget.uuid)} as any /* TODO: unresolved relatedApp - export couldn't resolve related_target_id to a portable reference; replace with a real ref before deploying */,`);
524
+ }
393
525
  else if (tool.typeKey === "relateRecord" && tool.relatedTarget?.kind === "foreignApp") {
394
526
  const foreignRefName = foreignAppRefNames?.get(tool.relatedTarget.name);
395
527
  if (foreignRefName !== undefined) {
@@ -419,6 +551,13 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
419
551
  if (tool.limit !== undefined)
420
552
  lines.push(` limit: ${tool.limit},`);
421
553
  }
554
+ if ((tool.typeKey === "searchAspect" || tool.typeKey === "searchTable") && tool.filterVariables !== undefined && tool.filterVariables.length > 0) {
555
+ lines.push(" filterVariables: [");
556
+ for (const variable of tool.filterVariables) {
557
+ lines.push(` { id: unsafePlatformId(${quote(variable.id)}), name: ${quote(variable.name)}, description: ${quote(variable.description)}, required: ${variable.required} },`);
558
+ }
559
+ lines.push(" ],");
560
+ }
422
561
  if (tool.typeKey === "updateRecord" && tool.handleDescription !== undefined) {
423
562
  lines.push(` handleDescription: ${quote(tool.handleDescription)},`);
424
563
  }
@@ -434,7 +573,9 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
434
573
  lines.push(` table: catalog.${targetRefName ?? appRefName}.searchTables${safeMember(tool.searchTableKey)},`);
435
574
  }
436
575
  else {
437
- const parent = tool.target?.kind === "self" ? appRefName : tool.target?.name ?? "";
576
+ const parent = tool.target?.kind === "self"
577
+ ? appRefName
578
+ : tool.target?.kind === "unresolved" ? tool.target.uuid : tool.target?.name ?? "";
438
579
  const typedTable = tool.searchTableName === undefined
439
580
  ? undefined
440
581
  : foreignSearchTableRefsByName?.get(JSON.stringify([parent, tool.searchTableName]));
@@ -10,14 +10,12 @@ 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 { AgentAuthentication } from "./build.js";
13
+ import type { AgentAuthentication, AgentStartingAction } from "./build.js";
14
14
  import type { AgentToolRunAs } from "./tools.js";
15
15
  /**
16
16
  * A resolved skill reference: this app's own skill (by catalog key), a
17
- * foreign app's (by skill name plus its owning app identity), or a raw platform id the export carries with
18
- * no way to resolve it further at all — confirmed live: a `skill_ids` entry
19
- * can be a bare UUID literal with neither a resource ref into this stream
20
- * nor a `data.elementum_agentic_skill` block backing it anywhere in the export.
17
+ * foreign app's skill (by name + foreign app refName if the app is
18
+ * recognized), or an unresolvable platform UUID literal.
21
19
  */
22
20
  export type NormalizedSkillRef = {
23
21
  readonly kind: "self";
@@ -44,7 +42,9 @@ export interface NormalizedAgent {
44
42
  readonly refName: string;
45
43
  readonly name: string;
46
44
  readonly description: string;
47
- readonly instructions: string;
45
+ readonly type?: "elementum" | "bedrock";
46
+ readonly bedrockAgentArn?: string;
47
+ readonly instructions?: string;
48
48
  readonly firstMessage?: string;
49
49
  readonly maxLength?: number;
50
50
  /** org.ts `aiProviders.<provider>.models.<model>` compound key ("<provider>.<model>"), when pinned. */
@@ -55,6 +55,7 @@ export interface NormalizedAgent {
55
55
  readonly conversationIdleTimeout?: string;
56
56
  readonly a2aStreaming?: boolean;
57
57
  readonly a2aCreateRecordEnabled?: boolean;
58
+ readonly startingActions?: readonly AgentStartingAction[];
58
59
  readonly tools: readonly NormalizedAgentTool[];
59
60
  readonly a2aSkills?: readonly NormalizedA2ASkill[];
60
61
  }
@@ -31,16 +31,18 @@ const KNOWN_AGENT_ATTRS = new Set([
31
31
  "conversation_idle_timeout",
32
32
  "a2a_streaming",
33
33
  "a2a_create_record_enabled",
34
+ "type",
35
+ "bedrock_agent_arn",
36
+ "starting_actions",
34
37
  ]);
35
38
  /** Dialect attrs with no authoring slot yet — reported by name, agent still pulled. */
36
- const UNAUTHORABLE_AGENT_ATTRS = new Set(["starting_actions", "model"]);
39
+ const UNAUTHORABLE_AGENT_ATTRS = new Set(["model"]);
40
+ const STARTING_ACTION_VARIABLE_TYPES = new Set(["TEXT", "NUMBER", "SELECT"]);
37
41
  /** Non-elementum agent variants (type + their config attrs) — the whole agent is skipped. */
38
42
  const VARIANT_ATTRS = new Set([
39
- "type",
40
43
  "snowflake_database",
41
44
  "snowflake_schema",
42
45
  "snowflake_name",
43
- "bedrock_agent_arn",
44
46
  "browser_agent_instructions",
45
47
  ]);
46
48
  /**
@@ -153,6 +155,151 @@ function parseJwtAuthentication(value, where, ctx) {
153
155
  },
154
156
  };
155
157
  }
158
+ function parseStartingActionValidation(value, where, ctx) {
159
+ const rec = plainObject(value);
160
+ if (rec === undefined) {
161
+ ctx.diagnostics.push(`${where}: validation has an unrecognized shape; dropped`);
162
+ return undefined;
163
+ }
164
+ const pattern = optionalString(rec, "pattern", where, ctx);
165
+ const errorMessage = optionalString(rec, "error_message", where, ctx);
166
+ const minLength = rec["min_length"];
167
+ const maxLength = rec["max_length"];
168
+ const validation = {
169
+ ...(pattern !== undefined && pattern !== "" && { pattern }),
170
+ ...(typeof minLength === "number" && Number.isSafeInteger(minLength) ? { minLength } : {}),
171
+ ...(typeof maxLength === "number" && Number.isSafeInteger(maxLength) ? { maxLength } : {}),
172
+ ...(errorMessage !== undefined && errorMessage !== "" && { errorMessage }),
173
+ };
174
+ if (minLength !== undefined && validation.minLength === undefined) {
175
+ ctx.diagnostics.push(`${where}: expected integer min_length, got ${JSON.stringify(minLength)}; dropped`);
176
+ }
177
+ if (maxLength !== undefined && validation.maxLength === undefined) {
178
+ ctx.diagnostics.push(`${where}: expected integer max_length, got ${JSON.stringify(maxLength)}; dropped`);
179
+ }
180
+ return Object.keys(validation).length > 0 ? validation : undefined;
181
+ }
182
+ function parseStartingActionVariable(value, where, ctx) {
183
+ const rec = plainObject(value);
184
+ if (rec === undefined) {
185
+ ctx.diagnostics.push(`${where}: starting action variable has an unrecognized shape; dropped`);
186
+ return undefined;
187
+ }
188
+ const key = optionalString(rec, "key", where, ctx);
189
+ const label = optionalString(rec, "label", where, ctx);
190
+ const type = optionalString(rec, "type", where, ctx);
191
+ if (key === undefined || key === "" || label === undefined || label === "") {
192
+ ctx.diagnostics.push(`${where}: starting action variable is missing key/label; dropped`);
193
+ return undefined;
194
+ }
195
+ if (type === undefined || !STARTING_ACTION_VARIABLE_TYPES.has(type)) {
196
+ ctx.diagnostics.push(`${where}: starting action variable "${key}" has unrecognized type ${JSON.stringify(type)}; dropped`);
197
+ return undefined;
198
+ }
199
+ let options;
200
+ const rawOptions = rec["options"];
201
+ if (Array.isArray(rawOptions) && rawOptions.length > 0) {
202
+ if (type !== "SELECT") {
203
+ ctx.diagnostics.push(`${where}: starting action variable "${key}" is type ${type} but has options (only SELECT carries options); dropped`);
204
+ }
205
+ else {
206
+ const parsed = [];
207
+ for (const item of rawOptions) {
208
+ const option = plainObject(item);
209
+ const optionLabel = option === undefined ? undefined : optionalString(option, "label", where, ctx);
210
+ const optionValue = option === undefined ? undefined : optionalString(option, "value", where, ctx);
211
+ if (optionLabel === undefined || optionValue === undefined) {
212
+ ctx.diagnostics.push(`${where}: starting action variable "${key}" has an unrecognized option; dropped`);
213
+ continue;
214
+ }
215
+ parsed.push({ value: optionValue, label: optionLabel });
216
+ }
217
+ if (parsed.length > 0)
218
+ options = parsed;
219
+ }
220
+ }
221
+ else if (rawOptions !== undefined && !Array.isArray(rawOptions)) {
222
+ ctx.diagnostics.push(`${where}: starting action variable "${key}" options is not a list; dropped`);
223
+ }
224
+ if (type === "SELECT" && options === undefined) {
225
+ ctx.diagnostics.push(`${where}: starting action variable "${key}" is type SELECT but has no valid options; dropped`);
226
+ return undefined;
227
+ }
228
+ const required = optionalBoolean(rec, "required", where, ctx);
229
+ const placeholder = optionalString(rec, "placeholder", where, ctx);
230
+ const validation = rec["validation"] === undefined ? undefined : parseStartingActionValidation(rec["validation"], `${where}: ${key}`, ctx);
231
+ const base = {
232
+ key,
233
+ label,
234
+ ...(placeholder !== undefined && placeholder !== "" && { placeholder }),
235
+ ...(required === true && { required: true }),
236
+ ...(validation !== undefined && { validation }),
237
+ };
238
+ if (type === "SELECT") {
239
+ return {
240
+ ...base,
241
+ type: "SELECT",
242
+ options: options,
243
+ };
244
+ }
245
+ return { ...base, type: type };
246
+ }
247
+ function parseStartingAction(value, where, ctx) {
248
+ const rec = plainObject(value);
249
+ if (rec === undefined) {
250
+ ctx.diagnostics.push(`${where}: starting action has an unrecognized shape; dropped`);
251
+ return undefined;
252
+ }
253
+ const name = optionalString(rec, "name", where, ctx);
254
+ const prompt = optionalString(rec, "prompt", where, ctx);
255
+ const order = rec["order"];
256
+ if (name === undefined || name === "" || typeof prompt !== "string") {
257
+ ctx.diagnostics.push(`${where}: starting action is missing name/prompt; dropped`);
258
+ return undefined;
259
+ }
260
+ if (typeof order !== "number" || !Number.isSafeInteger(order)) {
261
+ ctx.diagnostics.push(`${where}: starting action "${name}" is missing integer order; dropped`);
262
+ return undefined;
263
+ }
264
+ const enabled = optionalBoolean(rec, "enabled", where, ctx);
265
+ const icon = optionalString(rec, "icon", where, ctx);
266
+ let variables;
267
+ const rawVariables = rec["variables"];
268
+ if (Array.isArray(rawVariables) && rawVariables.length > 0) {
269
+ const parsed = [];
270
+ for (const item of rawVariables) {
271
+ const variable = parseStartingActionVariable(item, `${where}: ${name}`, ctx);
272
+ if (variable !== undefined)
273
+ parsed.push(variable);
274
+ }
275
+ if (parsed.length > 0)
276
+ variables = parsed;
277
+ }
278
+ else if (rawVariables !== undefined && !Array.isArray(rawVariables)) {
279
+ ctx.diagnostics.push(`${where}: starting action "${name}" variables is not a list; dropped`);
280
+ }
281
+ return {
282
+ name,
283
+ prompt,
284
+ order,
285
+ ...(enabled === false && { enabled: false }),
286
+ ...(icon !== undefined && icon !== "" && { icon }),
287
+ ...(variables !== undefined && { variables }),
288
+ };
289
+ }
290
+ function parseStartingActions(value, where, ctx) {
291
+ if (!Array.isArray(value)) {
292
+ ctx.diagnostics.push(`${where}: starting_actions is not a list; dropped`);
293
+ return undefined;
294
+ }
295
+ const actions = [];
296
+ for (const item of value) {
297
+ const action = parseStartingAction(item, where, ctx);
298
+ if (action !== undefined)
299
+ actions.push(action);
300
+ }
301
+ return actions.length > 0 ? actions : undefined;
302
+ }
156
303
  function parseSkillAccessConfig(value, where, ownerTfLabel, ctx) {
157
304
  if (typeof value !== "object" || value === null || Array.isArray(value) || isTfExpr(value)) {
158
305
  ctx.diagnostics.push(`${where}: skill_access_config has an unrecognized shape; dropped`);
@@ -201,9 +348,10 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx,
201
348
  const attrs = agentBlock.attrs;
202
349
  const name = optionalString(attrs, "name", `agent "${label}"`, ctx) ?? "";
203
350
  const where = `agent "${name}" (${AGENT_RESOURCE_TYPE}.${label})`;
204
- if (attrs["type"] !== undefined) {
351
+ const rawType = optionalString(attrs, "type", where, ctx);
352
+ if (rawType !== undefined && rawType !== "elementum" && rawType !== "bedrock") {
205
353
  return {
206
- skippedReason: `${where}: agent type ${JSON.stringify(attrs["type"])} has no terraform-path authoring yet; skipped`,
354
+ skippedReason: `${where}: agent type ${JSON.stringify(rawType)} has no terraform-path authoring yet; skipped`,
207
355
  };
208
356
  }
209
357
  for (const key of Object.keys(attrs)) {
@@ -240,6 +388,27 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx,
240
388
  ctx.diagnostics.push(`${where}: ai_provider_connector_id is not a connector data reference; dropped`);
241
389
  }
242
390
  }
391
+ if (rawType === "bedrock") {
392
+ const bedrockAgentArn = optionalString(attrs, "bedrock_agent_arn", where, ctx) ?? "";
393
+ const instructions = optionalString(attrs, "instructions", where, ctx);
394
+ const firstMessage = optionalString(attrs, "first_message", where, ctx);
395
+ if (attrs["starting_actions"] !== undefined) {
396
+ ctx.diagnostics.push(`${where}: starting_actions has no authoring slot on bedrock agents yet; a rebuilt stream will omit it`);
397
+ }
398
+ return {
399
+ agent: {
400
+ refName: scopedLabelToBagKey(appLabel, label),
401
+ name,
402
+ description: optionalString(attrs, "description", where, ctx) ?? "",
403
+ ...(instructions !== undefined && instructions !== "" && { instructions }),
404
+ ...(firstMessage !== undefined && { firstMessage }),
405
+ type: "bedrock",
406
+ bedrockAgentArn,
407
+ ...(connectorKey !== undefined && { connectorKey }),
408
+ tools: [],
409
+ },
410
+ };
411
+ }
243
412
  const owner = { appType: APP_RESOURCE_TYPE, appLabel, ownerTfLabel: appLabel, agentType: AGENT_RESOURCE_TYPE, agentLabel: label };
244
413
  const tools = [];
245
414
  for (const block of toolBlocks) {
@@ -271,6 +440,7 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx,
271
440
  const conversationIdleTimeout = optionalString(attrs, "conversation_idle_timeout", where, ctx);
272
441
  const a2aStreaming = optionalBoolean(attrs, "a2a_streaming", where, ctx);
273
442
  const a2aCreateRecordEnabled = optionalBoolean(attrs, "a2a_create_record_enabled", where, ctx);
443
+ const startingActions = attrs["starting_actions"] === undefined ? undefined : parseStartingActions(attrs["starting_actions"], where, ctx);
274
444
  const firstMessage = optionalString(attrs, "first_message", where, ctx);
275
445
  const maxTokens = attrs["max_tokens"];
276
446
  const maxLength = typeof maxTokens === "number" && Number.isSafeInteger(maxTokens) && maxTokens > 0
@@ -294,6 +464,7 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx,
294
464
  ...(conversationIdleTimeout !== undefined && { conversationIdleTimeout }),
295
465
  ...(a2aStreaming !== undefined && { a2aStreaming }),
296
466
  ...(a2aCreateRecordEnabled !== undefined && { a2aCreateRecordEnabled }),
467
+ ...(startingActions !== undefined && { startingActions }),
297
468
  tools,
298
469
  ...(a2aSkills.length > 0 && { a2aSkills }),
299
470
  },
@@ -3,8 +3,8 @@
3
3
  * the deploy wire client injects) with `CatalogRef` tokens at every reference
4
4
  * position. Standalone from v1.
5
5
  */
6
- export { agent, type A2ASkill, type AgentAuthentication, type AgentV2Options, agentStartingActionVariableType, type AgentStartingAction, type AgentStartingActionVariable, type AgentStartingActionVariableType, type SkillAccess, } from "./build.js";
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 AgentSearchRawIdField, type AgentSearchReturnField, type AgentSearchReturnFieldInput, type AgentSearchRawIdReturnField, type AgentSearchTableField, type AgentSearchTableFieldInput, type AgentSearchTableRawIdField, type SearchTableToolV2, type AgentToolRunAs, type AgentTool, } from "./tools.js";
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";
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";
10
10
  export { type Filter } from "../shared/filters/types.js";
@@ -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, agentStartingActionVariableType, } from "./build.js";
6
+ export { agent, bedrockAgent, agentStartingActionVariableType, } from "./build.js";
7
7
  export { agentCreateRecord, agentExecuteWorkflow, agentMcp, agentRelateRecord, agentRunAgent, agentRunAutomation, agentSearchRecords, agentSearchTable, agentUpdateRecord, } from "./tools.js";
8
8
  export { serviceAccountRef } from "./run-as.js";
9
9
  export * as filter from "../shared/filters/index.js";
@@ -116,6 +116,7 @@ export const agentModule = {
116
116
  serviceAccounts: ctx.streamRootEntity?.payload?.serviceAccounts,
117
117
  diagnostics: ctx.diagnostics,
118
118
  ...(ctx.siblingEntities !== undefined && { siblingEntities: ctx.siblingEntities }),
119
+ ...(ctx.activeAutomationRefNames !== undefined && { activeAutomationRefNames: ctx.activeAutomationRefNames }),
119
120
  }),
120
121
  },
121
122
  catalog: {
@@ -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 { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
19
19
  import { type DeployableEntity } from "../../engine/entity.js";
@@ -38,6 +38,7 @@ export interface AgentToTfContext {
38
38
  * behavior.
39
39
  */
40
40
  readonly siblingEntities?: readonly DeployableEntity[];
41
+ readonly activeAutomationRefNames?: ReadonlySet<string>;
41
42
  }
42
43
  export interface AgentToTfResult {
43
44
  readonly blocks: readonly TfBlock[];