@elementumai/edk 0.9.11 → 0.9.13

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 (90) hide show
  1. package/README.md +39 -5
  2. package/dist-sdk/src/catalog/factories.d.ts +35 -14
  3. package/dist-sdk/src/catalog/factories.js +64 -13
  4. package/dist-sdk/src/catalog/from-authoring.js +4 -4
  5. package/dist-sdk/src/catalog/index.d.ts +1 -1
  6. package/dist-sdk/src/catalog/org.js +3 -2
  7. package/dist-sdk/src/catalog/token.js +4 -0
  8. package/dist-sdk/src/catalog/types.d.ts +13 -3
  9. package/dist-sdk/src/core/triggers/on-demand.d.ts +4 -28
  10. package/dist-sdk/src/core/triggers/on-demand.js +2 -4
  11. package/dist-sdk/src/engine/entity.d.ts +2 -0
  12. package/dist-sdk/src/engine/logging.d.ts +90 -0
  13. package/dist-sdk/src/engine/logging.js +124 -0
  14. package/dist-sdk/src/engine/progress.d.ts +122 -0
  15. package/dist-sdk/src/engine/progress.js +685 -0
  16. package/dist-sdk/src/engine/pull/result-output.d.ts +24 -0
  17. package/dist-sdk/src/engine/pull/result-output.js +59 -0
  18. package/dist-sdk/src/entities/agent/tools.d.ts +2 -2
  19. package/dist-sdk/src/entities/app/build.d.ts +8 -1
  20. package/dist-sdk/src/entities/app/from-tf.js +4 -4
  21. package/dist-sdk/src/entities/app/to-tf.js +9 -13
  22. package/dist-sdk/src/entities/automation/build.d.ts +11 -16
  23. package/dist-sdk/src/entities/automation/build.js +60 -16
  24. package/dist-sdk/src/entities/automation/catalog-render.js +1 -1
  25. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +1 -2
  26. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +23 -5
  27. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +247 -35
  28. package/dist-sdk/src/entities/automation/from-tf.js +181 -24
  29. package/dist-sdk/src/entities/automation/index.d.ts +2 -2
  30. package/dist-sdk/src/entities/automation/module.js +2 -2
  31. package/dist-sdk/src/entities/automation/output-field-types.js +25 -13
  32. package/dist-sdk/src/entities/automation/script-code.d.ts +12 -4
  33. package/dist-sdk/src/entities/automation/script-code.js +659 -101
  34. package/dist-sdk/src/entities/automation/task-label.js +25 -2
  35. package/dist-sdk/src/entities/automation/tasks.d.ts +60 -28
  36. package/dist-sdk/src/entities/automation/tasks.js +31 -15
  37. package/dist-sdk/src/entities/automation/to-tf.js +443 -64
  38. package/dist-sdk/src/entities/automation/triggers.d.ts +15 -9
  39. package/dist-sdk/src/entities/automation/triggers.js +4 -2
  40. package/dist-sdk/src/entities/chart/build.d.ts +15 -3
  41. package/dist-sdk/src/entities/chart/build.js +6 -1
  42. package/dist-sdk/src/entities/chart/from-tf.d.ts +8 -2
  43. package/dist-sdk/src/entities/chart/from-tf.js +71 -8
  44. package/dist-sdk/src/entities/chart/index.d.ts +1 -1
  45. package/dist-sdk/src/entities/chart/index.js +1 -1
  46. package/dist-sdk/src/entities/chart/printer.js +27 -7
  47. package/dist-sdk/src/entities/chart/to-tf.js +56 -2
  48. package/dist-sdk/src/entities/datamine/from-tf.js +11 -1
  49. package/dist-sdk/src/entities/element/build.d.ts +6 -5
  50. package/dist-sdk/src/entities/element/from-tf.js +3 -2
  51. package/dist-sdk/src/entities/element/module.js +1 -0
  52. package/dist-sdk/src/entities/element/to-tf.d.ts +3 -0
  53. package/dist-sdk/src/entities/element/to-tf.js +9 -1
  54. package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
  55. package/dist-sdk/src/entities/field/from-tf.js +73 -1
  56. package/dist-sdk/src/entities/field/metadata.d.ts +18 -0
  57. package/dist-sdk/src/entities/field/metadata.js +34 -0
  58. package/dist-sdk/src/entities/relationship/build.d.ts +17 -6
  59. package/dist-sdk/src/entities/relationship/column-contract.d.ts +24 -0
  60. package/dist-sdk/src/entities/relationship/column-contract.js +41 -0
  61. package/dist-sdk/src/entities/relationship/from-tf.js +19 -34
  62. package/dist-sdk/src/entities/relationship/to-tf.js +15 -2
  63. package/dist-sdk/src/entities/shared/context.d.ts +6 -3
  64. package/dist-sdk/src/entities/shared/context.js +19 -1
  65. package/dist-sdk/src/entities/shared/filters/index.d.ts +7 -0
  66. package/dist-sdk/src/entities/shared/filters/index.js +36 -1
  67. package/dist-sdk/src/entities/shared/filters/print.js +2 -0
  68. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +8 -1
  69. package/dist-sdk/src/entities/shared/filters/tf-codec.js +10 -6
  70. package/dist-sdk/src/entities/shared/filters/types.d.ts +2 -1
  71. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -0
  72. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +36 -23
  73. package/dist-sdk/src/entities/skill/module.js +1 -0
  74. package/dist-sdk/src/entities/skill/to-tf.d.ts +1 -1
  75. package/dist-sdk/src/entities/skill/to-tf.js +17 -0
  76. package/dist-sdk/src/entities/skill/tools.d.ts +38 -12
  77. package/dist-sdk/src/entities/skill/tools.js +2 -1
  78. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +8 -12
  79. package/dist-sdk/src/entities/skill-tool/from-tf.js +28 -44
  80. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +4 -0
  81. package/dist-sdk/src/entities/skill-tool/to-tf.js +45 -7
  82. package/dist-sdk/src/entities/table/build.js +10 -2
  83. package/dist-sdk/src/entities/view/to-tf.js +5 -7
  84. package/dist-sdk/src/entities/widget/build.d.ts +26 -0
  85. package/dist-sdk/src/entities/widget/from-tf.js +30 -5
  86. package/dist-sdk/src/entities/widget/to-tf.js +111 -7
  87. package/dist-sdk/src/graph/types.d.ts +5 -0
  88. package/package.json +1 -1
  89. package/dist-sdk/src/core/types/platform.d.ts +0 -2
  90. package/dist-sdk/src/core/types/platform.js +0 -1
@@ -0,0 +1,24 @@
1
+ import type { TextEffect } from "../logging.js";
2
+ export interface PullResultSegment {
3
+ readonly text: string;
4
+ readonly textEffects?: readonly TextEffect[];
5
+ }
6
+ export type PullResultLine = string | readonly PullResultSegment[];
7
+ export type ManagedOutcome = "success" | "warning" | "failure";
8
+ export interface ManagedResultStatus {
9
+ readonly operation: string;
10
+ readonly outcome: ManagedOutcome;
11
+ }
12
+ export interface ManagedResultVerdict {
13
+ readonly failed?: boolean;
14
+ readonly skipped?: number;
15
+ readonly gaps?: number;
16
+ }
17
+ export declare function managedResultStatus(operation: string, verdict: ManagedResultVerdict): ManagedResultStatus;
18
+ /**
19
+ * Pull commands are pleasant for a person on a terminal and remain stable for
20
+ * scripts: interactive stdout gets a concise user summary, while a pipe or
21
+ * redirect gets the complete machine-readable result object.
22
+ */
23
+ export declare function writePullResult(result: unknown, humanLines: readonly PullResultLine[], status?: ManagedResultStatus): void;
24
+ export declare function countSummary(entries: readonly (readonly [singular: string, count: number, plural?: string])[]): string;
@@ -0,0 +1,59 @@
1
+ import { flushRepeatedTechnicalLogs, machineReadableLogsEnabled, renderTextEffects, writeUserOutput } from "../progress.js";
2
+ export function managedResultStatus(operation, verdict) {
3
+ const outcome = verdict.failed === true
4
+ ? "failure"
5
+ : (verdict.skipped ?? 0) > 0 || (verdict.gaps ?? 0) > 0
6
+ ? "warning"
7
+ : "success";
8
+ return { operation, outcome };
9
+ }
10
+ /**
11
+ * Pull commands are pleasant for a person on a terminal and remain stable for
12
+ * scripts: interactive stdout gets a concise user summary, while a pipe or
13
+ * redirect gets the complete machine-readable result object.
14
+ */
15
+ export function writePullResult(result, humanLines, status) {
16
+ // Put duplicate-warning summaries before the final success/warning/failure
17
+ // marker, so the marker remains the last diagnostic signal of the command.
18
+ flushRepeatedTechnicalLogs();
19
+ const resultWithStatus = status !== undefined && result !== null && typeof result === "object"
20
+ ? { ...result, status: status.outcome }
21
+ : result;
22
+ if (process.stdout.isTTY === true && !machineReadableLogsEnabled()) {
23
+ const renderedLines = humanLines.flatMap((line) => Array.isArray(line) && line.length === 0 ? [] : [renderPullResultLine(line)]);
24
+ if (status !== undefined) {
25
+ const message = status.outcome === "success"
26
+ ? `${status.operation} completed successfully`
27
+ : status.outcome === "warning"
28
+ ? `${status.operation} completed with warnings, see details above:`
29
+ : `${status.operation} has failed, see details below:`;
30
+ renderedLines.push(renderTextEffects(message, [{
31
+ start: 0,
32
+ end: message.length,
33
+ color: status.outcome === "success" ? "green" : status.outcome === "warning" ? "yellow" : "red",
34
+ bold: true,
35
+ }]));
36
+ }
37
+ writeUserOutput(`${renderedLines.join("\n")}\n`);
38
+ return;
39
+ }
40
+ if (status !== undefined && !machineReadableLogsEnabled()) {
41
+ const message = status.outcome === "success"
42
+ ? `${status.operation} completed successfully`
43
+ : status.outcome === "warning"
44
+ ? `${status.operation} completed with warnings`
45
+ : `${status.operation} failed`;
46
+ process.stderr.write(`[edk] ${message}\n`);
47
+ }
48
+ process.stdout.write(`${JSON.stringify(resultWithStatus, null, 2)}\n`);
49
+ }
50
+ function renderPullResultLine(line) {
51
+ if (typeof line === "string")
52
+ return line;
53
+ return line.map((segment) => renderTextEffects(segment.text, segment.textEffects)).join("");
54
+ }
55
+ export function countSummary(entries) {
56
+ return entries
57
+ .map(([singular, count, plural]) => `${count} ${count === 1 ? singular : (plural ?? `${singular}s`)}`)
58
+ .join(", ");
59
+ }
@@ -239,8 +239,8 @@ type KnownKeys<T> = {
239
239
  * - wide token (plain AutomationCatalogRef — foreign app or hand-written)
240
240
  * → permissive Record (graceful degradation; def() still validates).
241
241
  */
242
- type TriggerBagOf<A extends AutomationCatalogRef> = [NonNullable<A["trigger"]>] extends [never] ? EmptyBag : KnownKeys<NonNullable<A["trigger"]>> extends infer KK ? [keyof KK] extends [never] ? Readonly<Record<string, TriggerParameterRef>> : KK : never;
243
- type OutputBagOf<A extends AutomationCatalogRef> = [NonNullable<A["outputs"]>] extends [never] ? EmptyBag : KnownKeys<NonNullable<A["outputs"]>> extends infer KK ? [keyof KK] extends [never] ? Readonly<Record<string, OutputPropertyRef>> : KK : never;
242
+ export type TriggerBagOf<A extends AutomationCatalogRef> = [NonNullable<A["trigger"]>] extends [never] ? EmptyBag : KnownKeys<NonNullable<A["trigger"]>> extends infer KK ? [keyof KK] extends [never] ? Readonly<Record<string, TriggerParameterRef>> : KK : never;
243
+ export type OutputBagOf<A extends AutomationCatalogRef> = [NonNullable<A["outputs"]>] extends [never] ? EmptyBag : KnownKeys<NonNullable<A["outputs"]>> extends infer KK ? [keyof KK] extends [never] ? Readonly<Record<string, OutputPropertyRef>> : KK : never;
244
244
  /** Keys whose catalog entry carries `required: true` (rendered by the generated catalog). */
245
245
  type RequiredParamKeys<T> = {
246
246
  [K in keyof T]: T[K] extends {
@@ -275,6 +275,12 @@ export interface AppLayout {
275
275
  /** A saved list view (`elementum_list_view`). */
276
276
  export interface AppListView extends ManagedViewSharing {
277
277
  readonly name: string;
278
+ /**
279
+ * Display columns for the saved list. Create/update also seeds the
280
+ * organization (Everyone) Display Settings table-state default
281
+ * (`owner` = this app/element, `parentId` = the list view id). Show/Hide
282
+ * Columns (ColumnOrder) and Just Me preferences are not authored here.
283
+ */
278
284
  readonly columns: readonly AppViewFieldRef[];
279
285
  readonly allowRecordCreation?: boolean;
280
286
  readonly density?: ListViewDensity;
@@ -430,7 +436,8 @@ export interface AppV2Options<F extends Record<string, AppField> = Record<string
430
436
  * targeting another app/element lists rows through a matching entry here
431
437
  * whose columns join comparable stored values, not through that child's
432
438
  * `relationField` / `autoRelate`. Do not join system `"id"` (HANDLE) to a
433
- * child `relationField`.
439
+ * child `relationField` or dynamic dropdown (create fails with
440
+ * `Unable to validate`).
434
441
  */
435
442
  readonly relationships?: Readonly<Record<string, AppRelationship>>;
436
443
  /** Display order of all authored views (by key). Defaults to declaration order by view bag. */
@@ -149,16 +149,16 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
149
149
  const systemConfig = systemFieldConfigFromTf(attrs["system_field_config"], `app "${label}"`, ctx);
150
150
  const titleName = optionalString(attrs, "title_field_name", `app "${label}"`, ctx);
151
151
  if (titleName !== undefined || titleFieldDescription !== undefined || systemConfig.has("title")) {
152
- fields.push(systemEntry("title", titleName ?? "Title", "TEXT", "TITLE", titleFieldDescription, systemConfig.get("title")));
152
+ fields.push(systemEntry("title", titleName ?? DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES.title, "TEXT", "TITLE", titleFieldDescription, systemConfig.get("title")));
153
153
  }
154
154
  const idName = optionalString(attrs, "id_field_name", `app "${label}"`, ctx);
155
155
  if (idName !== undefined || idFieldDescription !== undefined || systemConfig.has("id")) {
156
- fields.push(systemEntry("id", idName ?? "ID", "TEXT", "HANDLE", idFieldDescription, systemConfig.get("id")));
156
+ fields.push(systemEntry("id", idName ?? DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES.id, "TEXT", "HANDLE", idFieldDescription, systemConfig.get("id")));
157
157
  }
158
- const statusName = optionalString(attrs, "status_field_name", `app "${label}"`, ctx) ?? "Status";
158
+ const statusName = optionalString(attrs, "status_field_name", `app "${label}"`, ctx) ?? DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES.status;
159
159
  const statusOptions = optionsFromTf(attrs["status_options"], `app "${label}" status_options`, ctx);
160
160
  if (!hasCustomStatusField
161
- && (statusName !== "Status" || statusOptions !== undefined || statusFieldDescription !== undefined || systemConfig.has("status"))) {
161
+ && (statusName !== DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES.status || statusOptions !== undefined || statusFieldDescription !== undefined || systemConfig.has("status"))) {
162
162
  const flags = systemConfig.get("status");
163
163
  fields.push({
164
164
  key: "status",
@@ -21,9 +21,9 @@ import { expr, snakeSlug } from "../../engine/tf/index.js";
21
21
  import { accessPolicyToTf } from "../access-policy/to-tf.js";
22
22
  import { dashboardsToTf } from "../dashboard/to-tf.js";
23
23
  import { picklistLabel } from "../field/options.js";
24
+ import { fieldMetadataFromEntries } from "../field/metadata.js";
24
25
  import { dynamicLayoutsToTf } from "../dynamic-layout/to-tf.js";
25
26
  import { fieldToTf } from "../field/to-tf.js";
26
- import { SUB_TYPE_BY_TYPE_KEY } from "../field/types.js";
27
27
  import { CATEGORY_ORG_BAG } from "../org/category.js";
28
28
  import { categoryIdExpr, missingCategoryDiagnostic } from "../org/category-ref.js";
29
29
  import { CLOUD_LINK_ORG_BAG } from "../org/cloud-link.js";
@@ -114,7 +114,7 @@ export function appToTf(entity, ctx) {
114
114
  // --- Field pass: fold system-tagged fields, emit one resource per custom field.
115
115
  const blocks = [];
116
116
  const fieldAddresses = new Map();
117
- const fieldMetadata = new Map();
117
+ const fieldMetadata = fieldMetadataFromEntries(payload.fields);
118
118
  const fieldNames = new Map();
119
119
  let statusOptions;
120
120
  let stages;
@@ -128,17 +128,6 @@ export function appToTf(entity, ctx) {
128
128
  const inner = fieldEntry[typeKey];
129
129
  const name = inner.name ?? "";
130
130
  const fieldKey = inner.__refName ?? snakeSlug(name);
131
- const subType = SUB_TYPE_BY_TYPE_KEY.get(typeKey);
132
- if (fieldKey !== "" && name !== "" && subType !== undefined) {
133
- fieldMetadata.set(fieldKey, {
134
- name,
135
- fieldType: subType.authoringType,
136
- ...(inner.picklistValues !== undefined
137
- ? { options: inner.picklistValues.map((value) => picklistLabel(value)) }
138
- : {}),
139
- ...(inner.tags !== undefined ? { tags: inner.tags } : {}),
140
- });
141
- }
142
131
  if (fieldKey !== "" && name !== "")
143
132
  fieldNames.set(fieldKey, name);
144
133
  const systemTag = inner.tags?.find((tag) => SYSTEM_FIELD_TAGS.has(tag));
@@ -148,6 +137,13 @@ export function appToTf(entity, ctx) {
148
137
  ctx.diagnostics.push(`systemFields: unsupported semantic tag ${systemTag}; validation flags dropped`);
149
138
  }
150
139
  else {
140
+ // Canonical system key (title/id/status/…) must map to the display
141
+ // name even when __refName was missing and fieldKey became
142
+ // snakeSlug("App Name") → "app_name". Cross-app automation refs
143
+ // look up record.title by the system key; missing it silently
144
+ // falls back to DEPLOY_DEFAULT "Title" (tofu Invalid index).
145
+ if (name !== "")
146
+ fieldNames.set(systemKey, name);
151
147
  systemFieldConfig[SYSTEM_FIELD_HCL_KEY_BY_KEY[systemKey]] = {
152
148
  required: inner.required ?? false,
153
149
  required_on_close: inner.requiredOnClose ?? false,
@@ -79,6 +79,8 @@ export interface ActionDef<TOutput> {
79
79
  readonly __output?: TOutput;
80
80
  /** The owning app's refName, when this task's `record`/`records` output is app-field-typed. */
81
81
  readonly __recordApp?: string;
82
+ /** Product kind of `__recordApp` — app vs element. Used to pick live FIND_PARENT refs keys. */
83
+ readonly __recordKind?: "app" | "element";
82
84
  }
83
85
  /** Placeholder `forEachTaskRefKey` the forEach item proxy emits; replaced with the real refKey. */
84
86
  export declare const FOR_EACH_PLACEHOLDER = "__forEach__";
@@ -173,9 +175,10 @@ interface ActionMethods<TTrigger, TActions extends Record<string, unknown>, TVar
173
175
  readonly inputs?: (ctx: NestedActionContext<TTrigger, TActions, TVars, TItem>) => I;
174
176
  readonly code: (input: ScriptInput<ResolvedRefs<NoInfer<I>>>) => R;
175
177
  /**
176
- * Override the inferred output schema: property name → `"text" |
177
- * "integer" | "number" | "decimal" | "boolean"`, or `{ name,
178
- * properties }` to also carry the root object's name. `null`
178
+ * Override the inferred output schema: property name → scalar type or a
179
+ * recursive `{ type: "array", items }` / `{ type: "object", properties }`
180
+ * descriptor; the object form may also carry `name` for the root.
181
+ * `null`
179
182
  * explicitly means "no schema" and suppresses inference; omitting the
180
183
  * option infers from the code body.
181
184
  */
@@ -207,7 +210,7 @@ interface ActionMethods<TTrigger, TActions extends Record<string, unknown>, TVar
207
210
  updateField<TName extends string, A extends AppOrElementRef, const Fields extends readonly import("./tasks.js").FieldAssignment[]>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").UpdateFieldOptions<A, Fields>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, {
208
211
  record: RecordShape<A>;
209
212
  }>;
210
- findRelatedRecords<TName extends string, A extends AppOrElementRef>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").FindRelatedRecordsOptions<A>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").RecordSearchOutput<A>>;
213
+ findRelatedRecords<TName extends string, A extends AppOrElementRef>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").FindRelatedRecordsOptions<A>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").FindRelatedRecordsOutput<A>>;
211
214
  relateRecords<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").RelateRecordsOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
212
215
  sendEmail<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").SendEmailOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
213
216
  postComment<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").PostCommentOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
@@ -219,9 +222,7 @@ interface ActionMethods<TTrigger, TActions extends Record<string, unknown>, TVar
219
222
  aiSummarize<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").AiSummarizeOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, {
220
223
  output: unknown;
221
224
  }>;
222
- aiTransform<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").AiTransformOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, {
223
- output: unknown;
224
- }>;
225
+ aiTransform<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").AiTransformOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, Record<string, unknown>>;
225
226
  aiSearchTable<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").AiSearchTableOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").AiSearchTableOutput>;
226
227
  aiFileAnalysis<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").AiFileAnalysisOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, {
227
228
  output: unknown;
@@ -234,16 +235,10 @@ interface ActionMethods<TTrigger, TActions extends Record<string, unknown>, TVar
234
235
  }>;
235
236
  calculation<TName extends string, const Values extends import("./tasks.js").CalculationValues>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").CalculationOptions<Values>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").CalculationValueOutputs<Values>>;
236
237
  calculation<TName extends string, const Entries extends readonly import("./tasks.js").CalculationEntry[]>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").LegacyCalculationOptions<Entries>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").CalculationOutputs<Entries>>;
237
- procedure<TName extends string, const Parameters extends readonly import("../../catalog/types.js").ProcedureParameterType[]>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").TypedProcedureOptions<Parameters>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, {
238
- output: unknown;
239
- }>;
240
- procedure<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").LegacyProcedureOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, {
241
- output: unknown;
242
- }>;
238
+ procedure<TName extends string, const Parameters extends readonly import("../../catalog/types.js").ProcedureParameterType[]>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").TypedProcedureOptions<Parameters>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, Record<string, unknown>>;
239
+ procedure<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").LegacyProcedureOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, Record<string, unknown>>;
243
240
  runAutomation<TName extends string, const A extends AutomationCatalogRef>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").RunAutomationOptions<A>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").RunAutomationOutput<A>>;
244
- readFile<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").ReadFileOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, {
245
- output: unknown;
246
- }>;
241
+ readFile<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").ReadFileOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, Record<string, unknown>>;
247
242
  approvalChain<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").ApprovalChainOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
248
243
  approvalStatusUpdate<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").ApprovalStatusUpdateOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
249
244
  addWatcher<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").AddWatcherOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
@@ -134,7 +134,6 @@ function collectExecuteScriptOutputSchemas(tasks) {
134
134
  * unrecognized, including `"object"`), which is real for the wire's own
135
135
  * default but would be a wrong guess if promoted to `OutputPropertyRef.valueType`.
136
136
  */
137
- const KNOWN_SCRIPT_OUTPUT_KINDS = new Set(["bool", "integer", "number", "string"]);
138
137
  /**
139
138
  * Resolve an automation-level output's `valueType` from its (already
140
139
  * serialized) value: only when it's a plain ref to an executeScript task's
@@ -157,9 +156,9 @@ function resolveOutputValueType(value, scriptSchemas) {
157
156
  if (schema === undefined)
158
157
  return undefined;
159
158
  const resolved = outputFieldTypesFromScriptSchema(schema)?.get(name);
160
- if (resolved === undefined || !KNOWN_SCRIPT_OUTPUT_KINDS.has(resolved.kind))
159
+ if (resolved === undefined || !["bool", "integer", "number", "string", "array"].includes(resolved.kind))
161
160
  return undefined;
162
- return resolved.fieldType;
161
+ return { fieldType: resolved.fieldType, multiple: resolved.multiple };
163
162
  }
164
163
  /**
165
164
  * Map every record-bearing task's refKey to the app refName that owns its
@@ -181,16 +180,39 @@ function collectRecordApps(tasks) {
181
180
  visit(tasks);
182
181
  return out;
183
182
  }
183
+ function collectRecordKinds(tasks) {
184
+ const out = {};
185
+ const visit = (entries) => {
186
+ for (const { name, def } of entries) {
187
+ if (def.__recordKind !== undefined)
188
+ out[name] = def.__recordKind;
189
+ for (const child of def.operatorChildren ?? [])
190
+ visit(child.tasks);
191
+ }
192
+ };
193
+ visit(tasks);
194
+ return out;
195
+ }
184
196
  /**
185
197
  * Tasks whose output carries a `.record` sub-object. Mirrors the deserializer's
186
198
  * `RECORD_BEARING_TASK_TYPES` — kept local to avoid a builder → pull-path import.
187
199
  */
188
200
  const RECORD_BEARING_TASK_KEYS = new Set(["recordSearch", "createRecord", "findRelatedRecords"]);
201
+ const FIND_RELATED_RECORDS_COUNT_REF_NAMES = new Set(["totalCount", "Records Size", "count"]);
202
+ function findRelatedRecordsTotalCountError(taskRefKey) {
203
+ const task = taskRefKey === undefined ? "findRelatedRecords" : `findRelatedRecords task "${taskRefKey}"`;
204
+ return new EntityTfError(`${task} does not expose totalCount. That output is recordSearch-only ` +
205
+ `(platform refs["Records Size"]). Use ctx.actions.<recordSearchTask>.totalCount ` +
206
+ `for a match count, or ctx.actions.${taskRefKey ?? "<findRelatedRecordsTask>"}.record / .records ` +
207
+ `for related rows. Do not invent a count ref.`);
208
+ }
189
209
  /**
190
210
  * Forward output-name rewrites, the inverse of the deserializer's read-side
191
211
  * normalization (`applyOutputNameInverseRewrites` in
192
212
  * `materialize/ref-deserializer.ts` — keep the two in sync):
193
213
  * - recordSearch: `totalCount` → the platform's `Records Size`.
214
+ * findRelatedRecords does **not** expose this key — reject it instead of
215
+ * emitting a fake `refs["totalCount"]` / `refs["Records Size"]`.
194
216
  * - aiSearchTable: `records` → the platform's `All Records` (NOT
195
217
  * recordSearch's `All found records` — #398.1).
196
218
  * - tableRecordsSearch interpolations map `records` → `All matching table
@@ -212,7 +234,10 @@ const RECORD_BEARING_TASK_KEYS = new Set(["recordSearch", "createRecord", "findR
212
234
  * - single-scalar-output tasks (see `OUTPUT_KEY_WIRE_NAME`): `output` →
213
235
  * the platform's actual output name for that task kind.
214
236
  */
215
- function rewriteForwardTaskRefName(taskKey, name) {
237
+ function rewriteForwardTaskRefName(taskKey, name, taskRefKey) {
238
+ if (taskKey === "findRelatedRecords" && FIND_RELATED_RECORDS_COUNT_REF_NAMES.has(name.split(".")[0])) {
239
+ throw findRelatedRecordsTotalCountError(taskRefKey);
240
+ }
216
241
  if (taskKey === "api") {
217
242
  return API_TASK_REF_WIRE_NAMES[name] ?? name;
218
243
  }
@@ -265,10 +290,10 @@ function rewriteTaskOutputRefs(node, taskKindByRefKey) {
265
290
  const rec = node;
266
291
  const ref = rec.taskReference;
267
292
  if (ref && typeof ref.taskRefKey === "string" && typeof ref.name === "string") {
268
- ref.name = rewriteForwardTaskRefName(taskKindByRefKey.get(ref.taskRefKey), ref.name);
293
+ ref.name = rewriteForwardTaskRefName(taskKindByRefKey.get(ref.taskRefKey), ref.name, ref.taskRefKey);
269
294
  }
270
295
  if (rec.type === "TASK" && typeof rec.taskRefKey === "string" && typeof rec.name === "string") {
271
- rec.name = rewriteForwardTaskRefName(taskKindByRefKey.get(rec.taskRefKey), rec.name);
296
+ rec.name = rewriteForwardTaskRefName(taskKindByRefKey.get(rec.taskRefKey), rec.name, rec.taskRefKey);
272
297
  }
273
298
  for (const v of Object.values(rec))
274
299
  rewriteTaskOutputRefs(v, taskKindByRefKey);
@@ -302,9 +327,23 @@ function stampAndCollectVariableIds(tasks) {
302
327
  visit(tasks);
303
328
  return map;
304
329
  }
330
+ /** Resolve a `setVariable` action's variable to its minted id, or throw. */
331
+ function resolveVariableId(idMap, variableTaskRefKey, name) {
332
+ const id = idMap.get(`${variableTaskRefKey}::${name}`);
333
+ if (!id) {
334
+ throw new Error(`Variable "${name}" not found on action "${variableTaskRefKey}". ` +
335
+ `Check that a setVariable action with that refKey creates a variable with that name.`);
336
+ }
337
+ return id;
338
+ }
305
339
  /**
306
- * Replace every `{ __variableParamRef: { variableTaskRefKey, name } }` marker
307
- * in the serialized tree with `{ variableReference: { id, name: "variable|<id>" } }`.
340
+ * Replace, in the serialized tree, every marker that names a workflow variable
341
+ * by its authoring-time `setVariable` refKey with the variable's minted id:
342
+ * - ordinary value positions: `{ __variableParamRef: { variableTaskRefKey, name } }`
343
+ * → `{ variableReference: { id, name: "variable|<id>" } }`.
344
+ * - filter value positions (recordSearch/switch/…): the `{ type: "VARIABLE",
345
+ * variableTaskRefKey, name }` reference emitted by `refDataToFilterReference`
346
+ * → `{ type: "VARIABLE", variableId: id }`, which to-tf emits as `variable.<uuid>` (#1045).
308
347
  * Throws when a referenced variable isn't in `idMap` — the variable must be
309
348
  * created by a `setVariable` action in the same automation.
310
349
  */
@@ -319,16 +358,16 @@ function resolveVariableParamMarkers(node, idMap) {
319
358
  const o = node;
320
359
  const marker = o.__variableParamRef;
321
360
  if (marker) {
322
- const key = `${marker.variableTaskRefKey}::${marker.name}`;
323
- const id = idMap.get(key);
324
- if (!id) {
325
- throw new Error(`Variable "${marker.name}" not found on action "${marker.variableTaskRefKey}". ` +
326
- `Check that a setVariable action with that refKey creates a variable with that name.`);
327
- }
361
+ const id = resolveVariableId(idMap, marker.variableTaskRefKey, marker.name);
328
362
  delete o.__variableParamRef;
329
363
  o.variableReference = { id, name: `variable|${id}` };
330
364
  return;
331
365
  }
366
+ if (o.type === "VARIABLE" && typeof o.variableTaskRefKey === "string") {
367
+ o.variableId = resolveVariableId(idMap, o.variableTaskRefKey, String(o.name));
368
+ delete o.variableTaskRefKey;
369
+ return;
370
+ }
332
371
  for (const v of Object.values(o))
333
372
  resolveVariableParamMarkers(v, idMap);
334
373
  }
@@ -496,10 +535,12 @@ function makeActionBuilder(state, mode = "root", item) {
496
535
  resolveVariableParamMarkers(outputs, variableIdMap);
497
536
  }
498
537
  const taskAppRefNameByRefKey = collectRecordApps(state.tasks);
538
+ const taskAppKindByRefKey = collectRecordKinds(state.tasks);
499
539
  const recordFieldContext = state.trigger.__recordApp !== undefined || Object.keys(taskAppRefNameByRefKey).length > 0
500
540
  ? {
501
541
  ...(state.trigger.__recordApp !== undefined ? { triggerAppRefName: state.trigger.__recordApp } : {}),
502
542
  ...(Object.keys(taskAppRefNameByRefKey).length > 0 ? { taskAppRefNameByRefKey } : {}),
543
+ ...(Object.keys(taskAppKindByRefKey).length > 0 ? { taskAppKindByRefKey } : {}),
503
544
  }
504
545
  : undefined;
505
546
  return {
@@ -566,7 +607,7 @@ export function automation(opts) {
566
607
  : undefined;
567
608
  const outputs = outputEntries.length > 0
568
609
  ? Object.fromEntries(outputEntries.map(({ name: n, value }) => {
569
- const valueType = resolveOutputValueType(value, scriptSchemas);
610
+ const resolvedOutput = resolveOutputValueType(value, scriptSchemas);
570
611
  return [
571
612
  n,
572
613
  {
@@ -574,7 +615,10 @@ export function automation(opts) {
574
615
  refName: n,
575
616
  name: n,
576
617
  parent: refName,
577
- ...(valueType !== undefined ? { valueType } : {}),
618
+ ...(resolvedOutput !== undefined ? {
619
+ valueType: resolvedOutput.fieldType,
620
+ ...(resolvedOutput.multiple ? { multiple: true } : {}),
621
+ } : {}),
578
622
  },
579
623
  ];
580
624
  }))
@@ -29,7 +29,7 @@ export function renderAutomationCatalogEntry(args) {
29
29
  lines.push(`${baseIndent} outputs: {`);
30
30
  for (const key of outputKeys) {
31
31
  const prop = ref.outputs[key];
32
- lines.push(`${baseIndent} ${safeCatalogKey(key)}: outputPropertyRef({ name: ${JSON.stringify(prop.name)}, parent: ${JSON.stringify(prop.parent ?? "")}${prop.valueType !== undefined ? `, valueType: ${JSON.stringify(prop.valueType)}` : ""} }),`);
32
+ lines.push(`${baseIndent} ${safeCatalogKey(key)}: outputPropertyRef({ name: ${JSON.stringify(prop.name)}, parent: ${JSON.stringify(prop.parent ?? "")}${prop.valueType !== undefined ? `, valueType: ${JSON.stringify(prop.valueType)}` : ""}${prop.multiple === true ? ", multiple: true" : ""} }),`);
33
33
  }
34
34
  lines.push(`${baseIndent} },`);
35
35
  }
@@ -72,8 +72,6 @@ export type TriggerAst = {
72
72
  defaultValue?: unknown;
73
73
  description?: string;
74
74
  }>;
75
- /** Round-tripped from the wire's `onDemand.showTriggeredBy` flag. */
76
- showTriggeredBy?: boolean;
77
75
  } | {
78
76
  kind: "recordCreate" | "recordUpdate" | "attachment";
79
77
  /** The owning app — `{kind: "unresolved", ...}` when the aspect never made it into the pull's catalog. */
@@ -90,6 +88,7 @@ export type TriggerAst = {
90
88
  kind: "conversationEnd";
91
89
  app: AppRefAst | UnresolvedRefAst;
92
90
  conversationType: string;
91
+ filter?: Filter<RefExpr, RefExpr>;
93
92
  } | {
94
93
  kind: "webhook";
95
94
  authenticated: boolean;
@@ -34,14 +34,32 @@ import type { AutomationAst } from "./ast.js";
34
34
  import type { UnresolvedReferenceDiagnostic } from "../../../graph/types.js";
35
35
  /** Keep the authored publish token across pull; live workflow versions are not author intent. */
36
36
  export declare function preserveAuthoredAutomationRevision(freshSource: string, existingSource: string): string;
37
+ /**
38
+ * Extract a string-literal (or `+`-concatenated literals) description from
39
+ * authored automation source. Pull reprints often omit description entirely
40
+ * because Go export cannot read it back from the platform today.
41
+ */
42
+ export declare function extractAuthoredAutomationDescription(source: string): string | undefined;
43
+ /**
44
+ * Keep a non-empty authored `description` across pull.
45
+ *
46
+ * Platform discovery historically omitted automation description (and the TF
47
+ * provider still does not round-trip it through GraphQL), so Go HCL export
48
+ * drops the attribute. Without this merge, pull → reprint → build clears
49
+ * description from config while state still has it, forcing an adopt update.
50
+ * Prefer a freshly pulled description when present; only reinstate the
51
+ * authored value when the fresh source omitted it.
52
+ */
53
+ export declare function preserveAuthoredAutomationDescription(freshSource: string, existingSource: string): string;
54
+ /** Pull merge: preserve authored revision + description across live reprint. */
55
+ export declare function preserveAuthoredAutomationPullMeta(freshSource: string, existingSource: string): string;
37
56
  export interface PrintAutomationV2Options {
38
57
  readonly refName?: string;
39
58
  /**
40
- * The owning app's refName to print as `parent:`. Defaults to
41
- * `ast.ownerHandle` (the app the automation was extracted FROM) — a caller
42
- * retargeting the file to a different app (e.g. `edk clone app`) must pass
43
- * this explicitly, or the printed `parent:` silently keeps pointing at the
44
- * source app.
59
+ * The owning app's authored catalog key. Defaults to `ast.ownerHandle`.
60
+ * Pull passes the on-disk refName (`eDKCloudBuilder`) when extract used
61
+ * the export label (`edkcloudbuilder`); every owner catalog path
62
+ * (`app:`, `.fields`, `.agents`, …) follows this key.
45
63
  */
46
64
  readonly appRefName?: string;
47
65
  /**