@elementumai/edk 0.13.4 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist-sdk/src/catalog/factories.d.ts +4 -2
  2. package/dist-sdk/src/catalog/factories.js +3 -1
  3. package/dist-sdk/src/catalog/from-authoring.d.ts +8 -3
  4. package/dist-sdk/src/catalog/from-authoring.js +21 -8
  5. package/dist-sdk/src/engine/build/context.d.ts +17 -0
  6. package/dist-sdk/src/engine/coverage-gaps.d.ts +10 -0
  7. package/dist-sdk/src/engine/coverage-gaps.js +16 -0
  8. package/dist-sdk/src/engine/pull/context.d.ts +56 -0
  9. package/dist-sdk/src/engine/pull/context.js +8 -0
  10. package/dist-sdk/src/engine/pull/pulled-roots.d.ts +14 -1
  11. package/dist-sdk/src/engine/pull/pulled-roots.js +23 -3
  12. package/dist-sdk/src/engine/pull/ref-only.d.ts +6 -1
  13. package/dist-sdk/src/engine/pull/ref-only.js +4 -1
  14. package/dist-sdk/src/engine/pull/stream-root.d.ts +13 -1
  15. package/dist-sdk/src/engine/pull/stream-root.js +54 -4
  16. package/dist-sdk/src/engine/validation.d.ts +36 -1
  17. package/dist-sdk/src/engine/validation.js +56 -2
  18. package/dist-sdk/src/engine/workspace/loader.d.ts +6 -0
  19. package/dist-sdk/src/engine/workspace/loader.js +87 -2
  20. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
  21. package/dist-sdk/src/entities/access-policy/from-tf.js +58 -17
  22. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +3 -1
  23. package/dist-sdk/src/entities/access-policy/to-tf.js +1 -1
  24. package/dist-sdk/src/entities/agent/build.d.ts +15 -0
  25. package/dist-sdk/src/entities/agent/build.js +139 -16
  26. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -3
  27. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +39 -25
  28. package/dist-sdk/src/entities/agent/module.js +95 -3
  29. package/dist-sdk/src/entities/agent/to-tf.js +6 -4
  30. package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +7 -0
  31. package/dist-sdk/src/entities/agent-evaluation/from-tf.js +14 -5
  32. package/dist-sdk/src/entities/agent-evaluation/module.js +4 -2
  33. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +11 -2
  34. package/dist-sdk/src/entities/agent-tool/from-tf.js +38 -40
  35. package/dist-sdk/src/entities/agent-tool/to-tf.js +12 -5
  36. package/dist-sdk/src/entities/app/build.d.ts +1 -1
  37. package/dist-sdk/src/entities/automation/build.d.ts +75 -42
  38. package/dist-sdk/src/entities/automation/build.js +17 -7
  39. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +14 -2
  40. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +9 -0
  41. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +57 -12
  42. package/dist-sdk/src/entities/automation/from-tf.d.ts +51 -0
  43. package/dist-sdk/src/entities/automation/from-tf.js +476 -93
  44. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  45. package/dist-sdk/src/entities/automation/index.js +1 -1
  46. package/dist-sdk/src/entities/automation/module.js +90 -9
  47. package/dist-sdk/src/entities/automation/operators.d.ts +6 -2
  48. package/dist-sdk/src/entities/automation/operators.js +0 -2
  49. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +8 -0
  50. package/dist-sdk/src/entities/automation/task-output-labels.js +11 -0
  51. package/dist-sdk/src/entities/automation/tasks.d.ts +37 -2
  52. package/dist-sdk/src/entities/automation/tasks.js +38 -1
  53. package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -0
  54. package/dist-sdk/src/entities/automation/to-tf.js +413 -47
  55. package/dist-sdk/src/entities/chart/to-tf.js +18 -5
  56. package/dist-sdk/src/entities/dashboard/from-tf.js +45 -11
  57. package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +5 -3
  58. package/dist-sdk/src/entities/dashboard-widget-order/order.js +6 -4
  59. package/dist-sdk/src/entities/datamine/from-tf.js +10 -3
  60. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +9 -2
  61. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +35 -7
  62. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +63 -7
  63. package/dist-sdk/src/entities/element/build.d.ts +4 -1
  64. package/dist-sdk/src/entities/element/build.js +3 -4
  65. package/dist-sdk/src/entities/field/from-tf.js +8 -1
  66. package/dist-sdk/src/entities/field/to-tf.d.ts +29 -2
  67. package/dist-sdk/src/entities/field/to-tf.js +106 -7
  68. package/dist-sdk/src/entities/phone-service/from-tf.d.ts +7 -0
  69. package/dist-sdk/src/entities/phone-service/from-tf.js +15 -7
  70. package/dist-sdk/src/entities/phone-service/module.js +4 -2
  71. package/dist-sdk/src/entities/portal/to-tf.d.ts +1 -1
  72. package/dist-sdk/src/entities/portal/to-tf.js +61 -2
  73. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -1
  74. package/dist-sdk/src/entities/relationship/from-tf.js +34 -4
  75. package/dist-sdk/src/entities/relationship/to-tf.js +24 -6
  76. package/dist-sdk/src/entities/role/from-tf.js +3 -1
  77. package/dist-sdk/src/entities/search-table/from-tf.d.ts +3 -1
  78. package/dist-sdk/src/entities/search-table/from-tf.js +6 -3
  79. package/dist-sdk/src/entities/search-table/module.js +18 -2
  80. package/dist-sdk/src/entities/search-table/to-tf.js +10 -16
  81. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +6 -1
  82. package/dist-sdk/src/entities/shared/filters/index.d.ts +6 -1
  83. package/dist-sdk/src/entities/shared/filters/index.js +8 -2
  84. package/dist-sdk/src/entities/shared/filters/print.js +18 -7
  85. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +11 -0
  86. package/dist-sdk/src/entities/shared/filters/tf-codec.js +24 -2
  87. package/dist-sdk/src/entities/shared/run-automation-requirement.d.ts +15 -0
  88. package/dist-sdk/src/entities/shared/run-automation-requirement.js +28 -0
  89. package/dist-sdk/src/entities/shared/search-table-address.d.ts +17 -0
  90. package/dist-sdk/src/entities/shared/search-table-address.js +24 -0
  91. package/dist-sdk/src/entities/shared/skip-release.d.ts +49 -0
  92. package/dist-sdk/src/entities/shared/skip-release.js +74 -0
  93. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -3
  94. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +11 -5
  95. package/dist-sdk/src/entities/skill/module.js +3 -25
  96. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +4 -2
  97. package/dist-sdk/src/entities/skill-tool/from-tf.js +28 -27
  98. package/dist-sdk/src/entities/skill-tool/to-tf.js +12 -5
  99. package/dist-sdk/src/entities/skill-tool/types.d.ts +1 -0
  100. package/dist-sdk/src/entities/skill-tool/types.js +2 -1
  101. package/dist-sdk/src/entities/table/catalog.d.ts +16 -0
  102. package/dist-sdk/src/entities/table/catalog.js +44 -2
  103. package/dist-sdk/src/entities/table/from-tf.js +30 -4
  104. package/dist-sdk/src/entities/table/keys.d.ts +27 -0
  105. package/dist-sdk/src/entities/table/keys.js +46 -0
  106. package/dist-sdk/src/entities/table/to-tf.js +2 -2
  107. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +12 -1
  108. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +9 -4
  109. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +215 -10
  110. package/dist-sdk/src/entities/view/agent-view-layout.d.ts +10 -4
  111. package/dist-sdk/src/entities/view/custom-view-runtime-rules.d.ts +43 -0
  112. package/dist-sdk/src/entities/view/custom-view-runtime-rules.js +285 -0
  113. package/dist-sdk/src/entities/view/custom-view-validate.d.ts +3 -1
  114. package/dist-sdk/src/entities/view/custom-view-validate.js +24 -5
  115. package/dist-sdk/src/entities/view/from-tf.js +14 -1
  116. package/dist-sdk/src/entities/widget/from-tf.js +14 -7
  117. package/dist-sdk/src/entities/widget/to-tf.js +7 -5
  118. package/dist-sdk/src/graph/index.d.ts +14 -1
  119. package/dist-sdk/src/graph/index.js +2 -0
  120. package/dist-sdk/src/graph/resource-types.d.ts +2 -0
  121. package/dist-sdk/src/graph/resource-types.js +3 -0
  122. package/dist-sdk/src/graph/types.d.ts +82 -0
  123. package/package.json +1 -1
@@ -15,18 +15,6 @@ function fieldValue(token, ctx, where) {
15
15
  throw new EntityTfError(`${where}: field ${token.refName} has no Terraform resource mapping`);
16
16
  return value;
17
17
  }
18
- /**
19
- * The platform indexes the owner's record ID with every app or element search
20
- * table and returns it first among the attribute fields, whether or not the
21
- * source lists it. Build writes the same list, so a table that leaves out
22
- * `fields.id` (or lists it later) doesn't plan a replacement on every apply,
23
- * which `attribute_field_ids` forces on any difference (#2890).
24
- */
25
- function withRecordIdFirst(attributes, ownerTfLabel) {
26
- const recordId = expr.local(`${ownerTfLabel}_id_field_id`);
27
- const key = JSON.stringify(recordId);
28
- return [recordId, ...attributes.filter((value) => JSON.stringify(value) !== key)];
29
- }
30
18
  function connectorValue(token, ctx, where) {
31
19
  const key = token?.parent !== undefined ? `${token.parent}.${token.refName ?? ""}` : token?.refName ?? "";
32
20
  const resolved = ctx.orgRefs.byTsLabel(CONNECTOR_ORG_BAG, key);
@@ -96,15 +84,21 @@ export function searchTableToTf(entity, ctx) {
96
84
  throw new EntityTfError(`search table ${entity.refName}: Terraform supports exactly one vector index`);
97
85
  const vectorField = fieldValue(index.fieldId, aspectCtx, `search table ${entity.refName}`);
98
86
  if (JSON.stringify(vectorField) === JSON.stringify(expr.local(`${ctx.appTfLabel}_id_field_id`))) {
99
- // Build always lists the record ID as an attribute (#2890), and the provider
100
- // refuses a vector field that is also an attribute: say so here, naming it.
101
- throw new EntityTfError(`search table ${entity.refName}: the record ID (fields.id) is always an attribute field, which the provider doesn't allow as the vector index field; index a text field`);
87
+ // The platform adds the record ID to every new app or element search
88
+ // table's attribute fields (#2890), and a vector field can't also be an
89
+ // attribute: say so here, naming it.
90
+ throw new EntityTfError(`search table ${entity.refName}: the platform adds the record ID (fields.id) to a search table's attribute fields, so it can't be the vector index field; index a text field`);
102
91
  }
103
92
  const attrs = {
104
93
  object_id: objectId,
105
94
  field_id: vectorField,
106
95
  ai_provider_connector_id: connectorValue(index.aiProviderConnectorId, ctx, `search table ${entity.refName}`),
107
- attribute_field_ids: withRecordIdFirst((payload.attributeFieldIds ?? []).map((field) => fieldValue(field, aspectCtx, `search table ${entity.refName}`)), ctx.appTfLabel),
96
+ // Exactly the authored list: pull prints the live attributes, which hold the
97
+ // record ID only when the platform added it (tables made before February
98
+ // 2026 don't have it), and the provider doesn't count the record ID the
99
+ // platform put first as a change when the source leaves it out or lists it
100
+ // later (#2890, #3086).
101
+ attribute_field_ids: (payload.attributeFieldIds ?? []).map((field) => fieldValue(field, aspectCtx, `search table ${entity.refName}`)),
108
102
  duration: payload.duration ?? "DAYS",
109
103
  target_lag: payload.targetLag ?? 1,
110
104
  };
@@ -89,8 +89,13 @@ export function resolveDataTaskTarget(ctx, dataLabel) {
89
89
  const attrs = ctx.dataAttrs?.("elementum_task", dataLabel);
90
90
  const namespace = typeof attrs?.namespace === "string" ? attrs.namespace : undefined;
91
91
  const name = ctx.dataName("elementum_task", dataLabel) ?? (typeof attrs?.name === "string" ? attrs.name : undefined);
92
+ // A task in the workspace first, then the export's ref-only root: the
93
+ // refName its fields' identities carry, so a relationship's target and its
94
+ // join fields name it alike (edk#3146). Only then the name-derived label.
92
95
  const refName = (namespace !== undefined ? ctx.foreignTaskRefNamespaces?.get(namespace) : undefined)
93
- ?? (name !== undefined ? ctx.foreignTaskRefNames?.get(name) : undefined);
96
+ ?? (name !== undefined ? ctx.foreignTaskRefNames?.get(name) : undefined)
97
+ ?? (namespace !== undefined ? ctx.refOnlyTaskRefNamespaces?.get(namespace) : undefined)
98
+ ?? (name !== undefined ? ctx.refOnlyTaskRefNames?.get(name) : undefined);
94
99
  const key = refName ?? tfLabelToTsLabel(dataLabel);
95
100
  return { key, name: name ?? key, ...(namespace !== undefined ? { namespace } : {}), catalogRef: true };
96
101
  }
@@ -106,8 +106,13 @@ export interface FieldLeftValue<Source extends FilterField = FilterField> {
106
106
  readonly [FIELD_VALUE_SOURCE]?: Source;
107
107
  }
108
108
  export declare function fieldValue<Source extends FilterField>(value: Source): FieldLeftValue<Source>;
109
+ /**
110
+ * `aspect` (an app or element restriction by raw id) is refused: pull can't
111
+ * write it back to source without a platform id, so authoring it would
112
+ * produce source that no pull reproduces (#3144).
113
+ */
109
114
  export declare function fieldValue(value: FilterField, options?: {
110
- readonly aspect?: string;
115
+ readonly aspect?: never;
111
116
  readonly treatNullAsEquals?: boolean;
112
117
  }): Extract<FilterValue<FilterField, FilterReferenceValue>, {
113
118
  type: "FIELD";
@@ -118,10 +118,12 @@ export function currentUser(valueType = "ID") {
118
118
  // Retain authoring-only type/options without adding them to the wire value.
119
119
  const FIELD_VALUE_SOURCE = Symbol("FieldValueSource");
120
120
  export function fieldValue(value, options) {
121
+ if (options?.aspect !== undefined) {
122
+ throw new EdkValidationError("filter.fieldValue: `aspect` is not supported; a field value restricted to an app or element has no portable form (#3144)");
123
+ }
121
124
  const operand = {
122
125
  type: "FIELD",
123
126
  value: fieldWireValue(value),
124
- ...(options?.aspect !== undefined && { aspect: options.aspect }),
125
127
  ...(options?.treatNullAsEquals !== undefined && { treatNullAsEquals: options.treatNullAsEquals }),
126
128
  };
127
129
  Object.defineProperty(operand, FIELD_VALUE_SOURCE, { value });
@@ -242,8 +244,12 @@ function resolveStaticFieldValue(field, input) {
242
244
  return picklistStaticValueToApiId(field, input);
243
245
  }
244
246
  export function toFilterValue(input, valueType = "TEXT") {
245
- if (isCanonicalFilterValue(input))
247
+ if (isCanonicalFilterValue(input)) {
248
+ if (input.type === "FIELD" && input.aspect !== undefined) {
249
+ throw new EdkValidationError("a FIELD filter value can't name an app or element (`aspect`); it has no portable form (#3144)");
250
+ }
246
251
  return input;
252
+ }
247
253
  if (isCurrentUser(input))
248
254
  return { type: "CURRENT_USER", valueType: input.valueType };
249
255
  if (isUserRef(input)) {
@@ -122,13 +122,14 @@ function printFilterValue(value, codec, call, quote) {
122
122
  case "BOOLEAN": return String(value.value);
123
123
  case "NULL": return "null";
124
124
  case "FIELD": {
125
- if (value.aspect === undefined && value.treatNullAsEquals === undefined)
126
- return codec.field(value.value);
127
- const options = [
128
- ...(value.aspect !== undefined ? [`aspect: ${quote(value.aspect)}`] : []),
129
- ...(value.treatNullAsEquals !== undefined ? [`treatNullAsEquals: ${value.treatNullAsEquals}`] : []),
130
- ];
131
- return call("fieldValue", `${codec.field(value.value)}, { ${options.join(", ")} }`);
125
+ // `filter.fieldValue` refuses `aspect`, so it has no printed form (#3144).
126
+ if (value.aspect !== undefined)
127
+ throw new EntityTfError("a field filter value that names an app or element (aspect) has no printed form");
128
+ const field = codec.field(value.value);
129
+ if (value.treatNullAsEquals === undefined && printsAsFieldToken(field))
130
+ return field;
131
+ const options = value.treatNullAsEquals !== undefined ? [`treatNullAsEquals: ${value.treatNullAsEquals}`] : [];
132
+ return call("fieldValue", options.length === 0 ? field : `${field}, { ${options.join(", ")} }`);
132
133
  }
133
134
  case "CURRENT_USER": return call("currentUser", quote(value.valueType ?? "ID"));
134
135
  case "USER": {
@@ -193,3 +194,13 @@ function printFilterValue(value, codec, call, quote) {
193
194
  }
194
195
  }
195
196
  }
197
+ /**
198
+ * Whether a printed field stands alone as a FIELD value. A quoted key or id
199
+ * would rebuild as a TEXT literal, and an `unsafePlatformId(...)` (a field
200
+ * pull couldn't name, such as a related record's field the export doesn't
201
+ * look up) is no comparison value at all, so either prints inside
202
+ * `fieldValue(...)` (#3144).
203
+ */
204
+ function printsAsFieldToken(printed) {
205
+ return !/^["'`]/.test(printed) && !/(^|\.)unsafePlatformId\(/.test(printed);
206
+ }
@@ -1,5 +1,16 @@
1
+ import { EntityTfError } from "../../../engine/entity.js";
1
2
  import { type TfValue } from "../../../engine/tf/index.js";
2
3
  import type { DateTimeUnit, Filter, LikeMode, ValueType } from "./types.js";
4
+ /**
5
+ * A filter value the platform holds but authored source can't, such as a
6
+ * FIELD value restricted to an app or element (`aspect`). A pull fails on it
7
+ * with an authoring blocker instead of dropping the filter, because writing
8
+ * the owner without it would remove the live filter on the next apply
9
+ * (#3144).
10
+ */
11
+ export declare class UnauthorableFilterValueError extends EntityTfError {
12
+ constructor(message: string);
13
+ }
3
14
  export type TfFilterType = "and" | "or" | "equals" | "greater_than" | "greater_than_equals" | "less_than" | "less_than_equals" | "like" | "in" | "between" | "contains" | "overlaps" | "is_null" | "current_range" | "consecutive_range" | "true" | "false";
4
15
  type TfDateTimeUnit = Lowercase<DateTimeUnit>;
5
16
  type TfLikeMode = Lowercase<LikeMode>;
@@ -1,5 +1,18 @@
1
1
  import { EntityTfError } from "../../../engine/entity.js";
2
2
  import { isTfExpr } from "../../../engine/tf/index.js";
3
+ /**
4
+ * A filter value the platform holds but authored source can't, such as a
5
+ * FIELD value restricted to an app or element (`aspect`). A pull fails on it
6
+ * with an authoring blocker instead of dropping the filter, because writing
7
+ * the owner without it would remove the live filter on the next apply
8
+ * (#3144).
9
+ */
10
+ export class UnauthorableFilterValueError extends EntityTfError {
11
+ constructor(message) {
12
+ super(message);
13
+ this.name = "UnauthorableFilterValueError";
14
+ }
15
+ }
3
16
  const TYPE_ALIASES = {
4
17
  and: "and",
5
18
  or: "or",
@@ -219,7 +232,10 @@ function filterValueToWire(value) {
219
232
  ...(value.current_user_type !== undefined && { valueType: value.current_user_type.toUpperCase() }),
220
233
  ...(value.real_type !== undefined && { realType: value.real_type.toUpperCase() }),
221
234
  ...(value.multiple !== undefined && { multiple: value.multiple }),
222
- ...(value.field_id !== undefined && { field: value.field_id }),
235
+ // The compared field goes under canonical `value`, as the provider sends
236
+ // it: jarvis's FieldValue has no `field` and dropped it (#3144). A FIELD
237
+ // value has no literal, so this never meets the `value` above.
238
+ ...(value.field_id !== undefined && { value: value.field_id }),
223
239
  ...(value.aspect_id !== undefined && { aspect: value.aspect_id }),
224
240
  ...(value.treat_null_as_equals !== undefined && { treatNullAsEquals: value.treat_null_as_equals }),
225
241
  ...(value.object !== undefined && { aspect: value.object }),
@@ -676,10 +692,16 @@ function filterValueFromTf(value, codec, fieldScope, field) {
676
692
  case "field":
677
693
  if (value.field_id === undefined)
678
694
  throw new EntityTfError("field filter value requires field_id");
695
+ // A FIELD value's aspect has no portable authored form: a reference
696
+ // can't be held and a raw id would put a platform id in source. Export
697
+ // writes aspect_id since #3144 (no platform code sets one today), and
698
+ // dropping it would remove it on the next apply, so pull fails instead.
699
+ if (value.aspect_id !== undefined) {
700
+ throw new UnauthorableFilterValueError("field filter value names an app or element (aspect_id), which source can't hold yet");
701
+ }
679
702
  return {
680
703
  type: "FIELD",
681
704
  value: codec.field(value.field_id, fieldScope),
682
- ...(typeof value.aspect_id === "string" && { aspect: value.aspect_id }),
683
705
  ...(value.treat_null_as_equals !== undefined && { treatNullAsEquals: value.treat_null_as_equals }),
684
706
  };
685
707
  case "record_field": {
@@ -0,0 +1,15 @@
1
+ import { type TfBlock } from "../../engine/tf/index.js";
2
+ import type { StreamExtractContext } from "../../graph/types.js";
3
+ /**
4
+ * A skill or agent tool that runs a same-stream automation prints a catalog
5
+ * ref to it. If pull skips that automation and keeps no authored file for
6
+ * it, build cannot emit the tool, so stream-root drops it from its owner's
7
+ * file and releases it (#1731). A skill tool names the automation through
8
+ * its workflow_publish when it is active and through the automation itself
9
+ * when it is not; an agent tool always names the automation itself. Both
10
+ * forms are required here (edk#3151).
11
+ */
12
+ export declare function requireRunAutomationTarget(tool: TfBlock, owner: {
13
+ readonly kind: "skill" | "agent";
14
+ readonly refName: string;
15
+ }, ctx: StreamExtractContext): void;
@@ -0,0 +1,28 @@
1
+ import { isTfExpr, scopedLabelToBagKey } from "../../engine/tf/index.js";
2
+ /**
3
+ * A skill or agent tool that runs a same-stream automation prints a catalog
4
+ * ref to it. If pull skips that automation and keeps no authored file for
5
+ * it, build cannot emit the tool, so stream-root drops it from its owner's
6
+ * file and releases it (#1731). A skill tool names the automation through
7
+ * its workflow_publish when it is active and through the automation itself
8
+ * when it is not; an agent tool always names the automation itself. Both
9
+ * forms are required here (edk#3151).
10
+ */
11
+ export function requireRunAutomationTarget(tool, owner, ctx) {
12
+ const automation = tool.attrs["automation_id"];
13
+ const toolName = tool.attrs["name"];
14
+ if (!isTfExpr(automation) || automation.$expr !== "resource-attr" || typeof toolName !== "string")
15
+ return;
16
+ if (automation.type !== "elementum_workflow_publish" && automation.type !== "elementum_automation")
17
+ return;
18
+ ctx.requiresExtracted?.push({
19
+ address: `${tool.type}.${tool.label}`,
20
+ requires: `${automation.type}.${automation.label}`,
21
+ requiresOwnFile: { kind: "automation", refName: scopedLabelToBagKey(ctx.appTfLabel, automation.label) },
22
+ prune: (root) => root,
23
+ pruneOwnFile: {
24
+ kind: owner.kind,
25
+ prune: (items) => items.map((item) => item.refName === owner.refName ? { ...item, tools: item.tools.filter((t) => t.name !== toolName) } : item),
26
+ },
27
+ });
28
+ }
@@ -0,0 +1,17 @@
1
+ import { type ChildResourceScope } from "../../engine/tf/index.js";
2
+ /**
3
+ * The resource label of an agent or skill tool's search table owned by an app
4
+ * or element built in this project. edk#2880: a table pull couldn't key (an
5
+ * unnamed table added after the element was pulled, or an element pulled with
6
+ * --no-adopt) reaches here as a literal whose refName is the platform's display
7
+ * name ("Search Table"). Its label would contain a space, so name the causes
8
+ * and their remedies instead of emitting a reference OpenTofu can't read.
9
+ */
10
+ export declare function localSearchTableLabel(where: string, table: {
11
+ readonly refName: string;
12
+ readonly name?: string;
13
+ }, owner: {
14
+ readonly refName: string;
15
+ readonly tfLabel: string;
16
+ readonly scope: ChildResourceScope;
17
+ }): string;
@@ -0,0 +1,24 @@
1
+ import { EntityTfError } from "../../engine/entity.js";
2
+ import { scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
3
+ /** A label OpenTofu accepts in a reference (`<type>.<label>.id`). */
4
+ const REFERENCE_LABEL = /^[A-Za-z_][A-Za-z0-9_-]*$/;
5
+ /**
6
+ * The resource label of an agent or skill tool's search table owned by an app
7
+ * or element built in this project. edk#2880: a table pull couldn't key (an
8
+ * unnamed table added after the element was pulled, or an element pulled with
9
+ * --no-adopt) reaches here as a literal whose refName is the platform's display
10
+ * name ("Search Table"). Its label would contain a space, so name the causes
11
+ * and their remedies instead of emitting a reference OpenTofu can't read.
12
+ */
13
+ export function localSearchTableLabel(where, table, owner) {
14
+ const label = scopedResourceLabel(owner.tfLabel, tsLabelToTfLabel(table.refName), owner.scope);
15
+ if (REFERENCE_LABEL.test(label))
16
+ return label;
17
+ const kind = owner.scope === "element" ? "element" : "app";
18
+ throw new EntityTfError(`${where}: search table ${JSON.stringify(table.name ?? table.refName)} isn't a catalog search table of ${kind} "${owner.refName}" ` +
19
+ `(pull wrote it this way because it couldn't match the table to a key of the ${kind}'s catalog), so it has no address here ` +
20
+ `(it would build as "${label}"). If the table was added after the ${kind} was pulled, re-pull the ${kind} ` +
21
+ `(\`elementum pull ${kind} ${owner.tfLabel}\`) and then this app. If the ${kind} was pulled with --no-adopt or --portable, ` +
22
+ `set the tool's table to \`catalog.${owner.refName}.searchTables.<key>\` with the key the ${kind}'s catalog gives it, ` +
23
+ `or re-pull the ${kind} with adoption and then this app.`);
24
+ }
@@ -0,0 +1,49 @@
1
+ import { type FromTfContext } from "../../engine/pull/context.js";
2
+ import { type TfValue } from "../../engine/tf/index.js";
3
+ import type { EntityKindId, QuarantinedOwnFile } from "../../graph/types.js";
4
+ /**
5
+ * Leave an inline resource out of source and out of adoption (edk#3166).
6
+ *
7
+ * A resource that pull writes no source for must not be imported either, or
8
+ * the next plan destroys it on the platform. Every extract context has
9
+ * `ctx.skipped` and `ctx.releaseIfManaged` for that; this helper adds the
10
+ * typed skipped gap and picks the route by why the resource can't be written:
11
+ *
12
+ * - `{ reference }`: a reference pull can't resolve (how the export names it,
13
+ * see {@link unresolvedReferenceName}). It registers an unresolved
14
+ * requirement, the route #1731 uses for a chart widget whose chart is
15
+ * skipped, so stream-root skips and releases it and reports "it needs
16
+ * <reference>, which is not a resource this pull extracts". Without a
17
+ * requirement list (a context that does not adopt) it records `fallback`.
18
+ * - `{ problem }`: a shape the export gives that pull can't author ("its
19
+ * size \"XL\" is not a dashboard widget size"). It skips and releases the
20
+ * resource directly and reports the problem as the reason.
21
+ */
22
+ export declare function skipAndRelease(ctx: Pick<FromTfContext, "requiresExtracted" | "skipped" | "releaseIfManaged" | "diagnostics">, address: string, why: {
23
+ readonly reference: string;
24
+ } | {
25
+ readonly problem: string;
26
+ }, fallback: string, ownFile?: OwnFileSkip): void;
27
+ /** A skipped resource printed as its own file, and the extract result's list its file is quarantined in. */
28
+ interface OwnFileSkip {
29
+ readonly kind: EntityKindId;
30
+ readonly refName: string;
31
+ readonly quarantineOwnFiles: QuarantinedOwnFile[];
32
+ }
33
+ /**
34
+ * {@link skipAndRelease} for a resource printed as its own file (a phone
35
+ * service, an agent evaluation). The sweep keeps an earlier pull's file of a
36
+ * skipped child, so build would emit it again and the next plan would
37
+ * create a second copy of the live resource once adoption releases it. The
38
+ * file is quarantined instead, and archived to .edk-state/pull-backups once
39
+ * state no longer manages `address` (#1858, #2054); the skipped gap says so.
40
+ * Only a route that skips the resource quarantines its file: without a
41
+ * requirement list nothing is skipped, so nothing is quarantined.
42
+ */
43
+ export declare function skipOwnFileAndRelease(ctx: Parameters<typeof skipAndRelease>[0], address: string, why: Parameters<typeof skipAndRelease>[2], fallback: string, ownFile: {
44
+ readonly kind: EntityKindId;
45
+ readonly refName: string;
46
+ }, quarantineOwnFiles: QuarantinedOwnFile[]): void;
47
+ /** How the export named a reference pull could not resolve, for {@link skipAndRelease}'s `reference`. */
48
+ export declare function unresolvedReferenceName(value: TfValue | undefined, attribute: string): string;
49
+ export {};
@@ -0,0 +1,74 @@
1
+ import { typedCoverageGap } from "../../engine/coverage-gaps.js";
2
+ import { dataRefLabel, ownFileArchiveConsequence } from "../../engine/pull/context.js";
3
+ import { isTfExpr } from "../../engine/tf/index.js";
4
+ const SKIPPED_CONSEQUENCE = "it is not written to source or adopted, and adoption releases it if state already manages it; it keeps running on the platform unmanaged until a later pull can write it";
5
+ /**
6
+ * Leave an inline resource out of source and out of adoption (edk#3166).
7
+ *
8
+ * A resource that pull writes no source for must not be imported either, or
9
+ * the next plan destroys it on the platform. Every extract context has
10
+ * `ctx.skipped` and `ctx.releaseIfManaged` for that; this helper adds the
11
+ * typed skipped gap and picks the route by why the resource can't be written:
12
+ *
13
+ * - `{ reference }`: a reference pull can't resolve (how the export names it,
14
+ * see {@link unresolvedReferenceName}). It registers an unresolved
15
+ * requirement, the route #1731 uses for a chart widget whose chart is
16
+ * skipped, so stream-root skips and releases it and reports "it needs
17
+ * <reference>, which is not a resource this pull extracts". Without a
18
+ * requirement list (a context that does not adopt) it records `fallback`.
19
+ * - `{ problem }`: a shape the export gives that pull can't author ("its
20
+ * size \"XL\" is not a dashboard widget size"). It skips and releases the
21
+ * resource directly and reports the problem as the reason.
22
+ */
23
+ export function skipAndRelease(ctx, address, why, fallback, ownFile) {
24
+ if ("reference" in why) {
25
+ if (ctx.requiresExtracted === undefined) {
26
+ ctx.diagnostics.push(fallback);
27
+ return;
28
+ }
29
+ ctx.requiresExtracted.push({
30
+ address,
31
+ requires: why.reference,
32
+ unresolved: true,
33
+ prune: (root) => root,
34
+ // Stream-root quarantines the file once it releases the address and
35
+ // says so in the skipped gap (#2892).
36
+ ...(ownFile !== undefined && { pruneOwnFile: { kind: ownFile.kind, prune: (items) => items, archiveRefName: ownFile.refName } }),
37
+ });
38
+ return;
39
+ }
40
+ ctx.skipped.push(address);
41
+ ctx.releaseIfManaged?.push(address);
42
+ if (ownFile !== undefined)
43
+ ownFile.quarantineOwnFiles.push({ kind: ownFile.kind, refName: ownFile.refName, afterRelease: [address] });
44
+ const consequence = SKIPPED_CONSEQUENCE + (ownFile !== undefined ? ownFileArchiveConsequence(ownFile.kind, ownFile.refName) : "");
45
+ ctx.diagnostics.push(typedCoverageGap({ kind: "skipped", entity: address, detail: `left out of the pull, skipped: ${why.problem}`, consequence }));
46
+ }
47
+ /**
48
+ * {@link skipAndRelease} for a resource printed as its own file (a phone
49
+ * service, an agent evaluation). The sweep keeps an earlier pull's file of a
50
+ * skipped child, so build would emit it again and the next plan would
51
+ * create a second copy of the live resource once adoption releases it. The
52
+ * file is quarantined instead, and archived to .edk-state/pull-backups once
53
+ * state no longer manages `address` (#1858, #2054); the skipped gap says so.
54
+ * Only a route that skips the resource quarantines its file: without a
55
+ * requirement list nothing is skipped, so nothing is quarantined.
56
+ */
57
+ export function skipOwnFileAndRelease(ctx, address, why, fallback, ownFile, quarantineOwnFiles) {
58
+ skipAndRelease(ctx, address, why, fallback, { ...ownFile, quarantineOwnFiles });
59
+ }
60
+ /** How the export named a reference pull could not resolve, for {@link skipAndRelease}'s `reference`. */
61
+ export function unresolvedReferenceName(value, attribute) {
62
+ if (value === undefined)
63
+ return `a resolvable ${attribute}`;
64
+ if (isTfExpr(value) && value.$expr === "data-attr") {
65
+ const label = dataRefLabel(value, value.type);
66
+ if (label !== undefined)
67
+ return `data.${value.type}.${label}`;
68
+ }
69
+ if (isTfExpr(value) && value.$expr === "resource-attr")
70
+ return `${value.type}.${value.label}`;
71
+ if (typeof value === "string")
72
+ return `${attribute} ${JSON.stringify(value)}`;
73
+ return `a resolvable ${attribute}`;
74
+ }
@@ -42,9 +42,9 @@ export interface PrintSkillV2Options {
42
42
  */
43
43
  readonly foreignElementRefNames?: ReadonlyMap<string, string>;
44
44
  /**
45
- * Same as {@link foreignAppRefNames}, keyed for standalone tasks — a
46
- * `foreignTask` tool target whose name is a key here prints
47
- * `catalog.<refName>` instead of the literal stub.
45
+ * Display name → refName for standalone tasks on disk. A task has no
46
+ * catalog entry, so a `foreignTask` tool target whose name is a key here
47
+ * still prints the inline stub, carrying this refName (#3148).
48
48
  */
49
49
  readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
50
50
  /** Terraform label → authored catalog ref. Field identities stay on the label. */
@@ -296,10 +296,12 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
296
296
  : foreignAppRefNames;
297
297
  // Display-name map first: the terraform label and the authored catalog key
298
298
  // differ (#1427). Extract-time refName is the state/namespace join for
299
- // apps and elements. Task refNames are terraform labels, so they stay on
300
- // the inline stub unless the map names a workspace catalog key (#1452).
299
+ // apps and elements. A task-type app has no catalog entry, even once
300
+ // pulled (#3148), so it always prints the inline stub, carrying the
301
+ // pulled task's refName when the map names one.
301
302
  const mapped = refNames?.get(tool.target.name);
302
- const catalogRefName = mapped ?? (tool.target.kind === "foreignTask" ? undefined : tool.target.refName);
303
+ const catalogRefName = tool.target.kind === "foreignTask" ? undefined : mapped ?? tool.target.refName;
304
+ const stubRefName = (tool.target.kind === "foreignTask" ? mapped : undefined) ?? tool.target.refName ?? tool.target.name;
303
305
  if (catalogRefName !== undefined) {
304
306
  lines.push(` ${entityKind}: catalog.${catalogRefName},`);
305
307
  }
@@ -311,7 +313,7 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
311
313
  const todo = crossOrg
312
314
  ? ` // TODO: cross-org clone — "${tool.target.name}" was resolved in the SOURCE org; verify it exists (with this name) in the destination org`
313
315
  : "";
314
- lines.push(` ${entityKind}: { __kind: ${quote(entityKind)}, refName: ${quote(tool.target.refName ?? tool.target.name)}, name: ${quote(tool.target.name)}${tool.target.namespace !== undefined ? `, namespace: ${quote(tool.target.namespace)}` : ""} },${todo}`);
316
+ lines.push(` ${entityKind}: { __kind: ${quote(entityKind)}, refName: ${quote(stubRefName)}, name: ${quote(tool.target.name)}${tool.target.namespace !== undefined ? `, namespace: ${quote(tool.target.namespace)}` : ""} },${todo}`);
315
317
  }
316
318
  }
317
319
  if (tool.typeKey === "searchAspect") {
@@ -362,7 +364,11 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
362
364
  lines.push(` table: catalog.${tableOwner}.searchTables${safeMember(typedTable.tableKey)},`);
363
365
  }
364
366
  else {
365
- lines.push(` table: { __kind: "searchTable", refName: ${quote(tool.searchTableName ?? "")}, name: ${quote(tool.searchTableName ?? "")}, parent: ${quote(parent)} },`);
367
+ // An id-pinned lookup (a name two tables of the owner share, e.g. two
368
+ // unnamed tables) keeps its id, as print-agent-v2.ts does; without it
369
+ // build writes a name lookup that plan rejects as ambiguous (edk#2881).
370
+ const pinnedId = tool.searchTableId !== undefined ? `, id: ${quote(tool.searchTableId)}` : "";
371
+ lines.push(` table: { __kind: "searchTable", refName: ${quote(tool.searchTableName ?? "")}, name: ${quote(tool.searchTableName ?? "")}, parent: ${quote(parent)}${pinnedId} },`);
366
372
  }
367
373
  }
368
374
  lines.push(` queryDescription: ${quote(tool.queryDescription ?? "")},`);
@@ -1,7 +1,8 @@
1
1
  /** The skill entity's registry entry + resource-type constant (see src/graph/). */
2
2
  import { rootParentFactoryEntry } from "../../catalog/render-helpers.js";
3
- import { isTfExpr, scopedLabelToBagKey } from "../../engine/tf/index.js";
3
+ import { isTfExpr } from "../../engine/tf/index.js";
4
4
  import { GROUP_RESOURCE_TYPE } from "../org/group.js";
5
+ import { requireRunAutomationTarget } from "../shared/run-automation-requirement.js";
5
6
  import { printSkillV2 } from "./deserializer/print-skill-v2.js";
6
7
  import { skillFromTf } from "./from-tf.js";
7
8
  import { skillToTf } from "./to-tf.js";
@@ -42,29 +43,6 @@ function skillRefFromAuthoring(args) {
42
43
  : entityRefName;
43
44
  return { __kind: "skill", refName: entityRefName, name, parent: entityParent };
44
45
  }
45
- /**
46
- * A tool that runs a same-stream automation prints a catalog ref to it. If
47
- * pull skips that automation and keeps no authored file for it, build cannot
48
- * emit the tool, so stream-root drops it from the skill and releases it.
49
- */
50
- function requireRunAutomationTarget(tool, skillRefName, ctx) {
51
- const automation = tool.attrs["automation_id"];
52
- const toolName = tool.attrs["name"];
53
- if (!isTfExpr(automation) || automation.$expr !== "resource-attr" || typeof toolName !== "string")
54
- return;
55
- if (automation.type !== "elementum_workflow_publish" && automation.type !== "elementum_automation")
56
- return;
57
- ctx.requiresExtracted?.push({
58
- address: `${tool.type}.${tool.label}`,
59
- requires: `${automation.type}.${automation.label}`,
60
- requiresOwnFile: { kind: "automation", refName: scopedLabelToBagKey(ctx.appTfLabel, automation.label) },
61
- prune: (root) => root,
62
- pruneOwnFile: {
63
- kind: "skill",
64
- prune: (skills) => skills.map((skill) => skill.refName === skillRefName ? { ...skill, tools: skill.tools.filter((t) => t.name !== toolName) } : skill),
65
- },
66
- });
67
- }
68
46
  function extractSkills(ownBlocks, stream, ctx) {
69
47
  const toolBlocks = stream.byKind.get("skill-tool") ?? [];
70
48
  const items = [];
@@ -80,7 +58,7 @@ function extractSkills(ownBlocks, stream, ctx) {
80
58
  if (skill !== undefined) {
81
59
  items.push(skill);
82
60
  for (const tool of ownTools)
83
- requireRunAutomationTarget(tool, skill.refName, ctx);
61
+ requireRunAutomationTarget(tool, { kind: "skill", refName: skill.refName }, ctx);
84
62
  }
85
63
  else if (skippedReason !== undefined) {
86
64
  skipped.push(`${SKILL_RESOURCE_TYPE}.${skillLabel}`);
@@ -133,7 +133,9 @@ export interface SkillToolOwner {
133
133
  readonly skillLabel: string;
134
134
  }
135
135
  /**
136
- * One tool block → its normalized shape; undefined = skipped with a
137
- * diagnostic (unimplemented sub-type, wrong owner, unresolvable target).
136
+ * One tool block → its normalized shape; undefined = skipped (unimplemented
137
+ * sub-type, wrong owner, unresolvable target). A tool written to no source
138
+ * is also left out of adoption, or released if state has it, so the next
139
+ * plan doesn't destroy it (edk#3172); skipAndRelease does both.
138
140
  */
139
141
  export declare function skillToolFromTf(block: TfBlock, owner: SkillToolOwner, ctx: FromTfContext): NormalizedSkillTool | undefined;