@elementumai/edk 0.9.14 → 0.9.16

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 (124) hide show
  1. package/dist-sdk/pull/util.d.ts +0 -15
  2. package/dist-sdk/pull/util.js +44 -5
  3. package/dist-sdk/src/catalog/factories.d.ts +4 -2
  4. package/dist-sdk/src/catalog/factories.js +4 -0
  5. package/dist-sdk/src/catalog/from-authoring.js +5 -1
  6. package/dist-sdk/src/catalog/index.d.ts +2 -2
  7. package/dist-sdk/src/catalog/index.js +1 -1
  8. package/dist-sdk/src/catalog/token.js +2 -2
  9. package/dist-sdk/src/catalog/types.d.ts +7 -2
  10. package/dist-sdk/src/core/types/app.d.ts +4 -4
  11. package/dist-sdk/src/engine/build/context.d.ts +5 -4
  12. package/dist-sdk/src/engine/build/source-context.d.ts +2 -0
  13. package/dist-sdk/src/engine/build/source-context.js +16 -0
  14. package/dist-sdk/src/engine/progress.d.ts +19 -1
  15. package/dist-sdk/src/engine/progress.js +33 -5
  16. package/dist-sdk/src/engine/pull/context.d.ts +9 -1
  17. package/dist-sdk/src/engine/pull/ref-only.d.ts +6 -2
  18. package/dist-sdk/src/engine/pull/ref-only.js +14 -3
  19. package/dist-sdk/src/engine/workspace/loader.js +23 -2
  20. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +1 -1
  21. package/dist-sdk/src/entities/access-policy/from-tf.js +47 -12
  22. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +5 -3
  23. package/dist-sdk/src/entities/access-policy/to-tf.js +23 -1
  24. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -0
  25. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +50 -4
  26. package/dist-sdk/src/entities/agent/from-tf.d.ts +1 -0
  27. package/dist-sdk/src/entities/agent/from-tf.js +18 -3
  28. package/dist-sdk/src/entities/agent/module.js +1 -0
  29. package/dist-sdk/src/entities/agent/to-tf.js +15 -0
  30. package/dist-sdk/src/entities/agent/tools.d.ts +98 -5
  31. package/dist-sdk/src/entities/agent/tools.js +12 -3
  32. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +15 -0
  33. package/dist-sdk/src/entities/agent-tool/from-tf.js +47 -4
  34. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +9 -0
  35. package/dist-sdk/src/entities/agent-tool/to-tf.js +82 -25
  36. package/dist-sdk/src/entities/app/build.d.ts +2 -2
  37. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +4 -4
  38. package/dist-sdk/src/entities/app/module.js +8 -0
  39. package/dist-sdk/src/entities/app/to-tf.js +1 -0
  40. package/dist-sdk/src/entities/approval-chain/build.d.ts +8 -1
  41. package/dist-sdk/src/entities/approval-chain/build.js +3 -0
  42. package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +2 -1
  43. package/dist-sdk/src/entities/approval-chain/from-tf.js +20 -7
  44. package/dist-sdk/src/entities/approval-chain/printer.js +13 -2
  45. package/dist-sdk/src/entities/approval-chain/to-tf.js +3 -0
  46. package/dist-sdk/src/entities/automation/build.d.ts +19 -12
  47. package/dist-sdk/src/entities/automation/build.js +36 -13
  48. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +4 -0
  49. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +19 -0
  50. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +222 -65
  51. package/dist-sdk/src/entities/automation/from-tf.d.ts +86 -6
  52. package/dist-sdk/src/entities/automation/from-tf.js +360 -63
  53. package/dist-sdk/src/entities/automation/index.d.ts +3 -2
  54. package/dist-sdk/src/entities/automation/index.js +3 -2
  55. package/dist-sdk/src/entities/automation/module.js +21 -16
  56. package/dist-sdk/src/entities/automation/output-field-types.d.ts +5 -0
  57. package/dist-sdk/src/entities/automation/output-field-types.js +12 -0
  58. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +20 -0
  59. package/dist-sdk/src/entities/automation/output-key-wire-name.js +22 -0
  60. package/dist-sdk/src/entities/automation/script-code.d.ts +32 -0
  61. package/dist-sdk/src/entities/automation/script-code.js +72 -5
  62. package/dist-sdk/src/entities/automation/tasks.d.ts +60 -24
  63. package/dist-sdk/src/entities/automation/tasks.js +33 -14
  64. package/dist-sdk/src/entities/automation/to-tf.d.ts +0 -2
  65. package/dist-sdk/src/entities/automation/to-tf.js +123 -46
  66. package/dist-sdk/src/entities/automation/triggers.d.ts +5 -2
  67. package/dist-sdk/src/entities/automation/types.d.ts +2 -0
  68. package/dist-sdk/src/entities/automation/types.js +5 -0
  69. package/dist-sdk/src/entities/automation/workflow-output.d.ts +35 -0
  70. package/dist-sdk/src/entities/automation/workflow-output.js +53 -0
  71. package/dist-sdk/src/entities/chart/build.d.ts +3 -3
  72. package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
  73. package/dist-sdk/src/entities/chart/from-tf.js +20 -13
  74. package/dist-sdk/src/entities/chart/to-tf.js +7 -5
  75. package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
  76. package/dist-sdk/src/entities/dashboard/to-tf.js +1 -0
  77. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +3 -2
  78. package/dist-sdk/src/entities/element/build.d.ts +11 -8
  79. package/dist-sdk/src/entities/element/build.js +14 -5
  80. package/dist-sdk/src/entities/element/locals.d.ts +2 -2
  81. package/dist-sdk/src/entities/element/locals.js +6 -2
  82. package/dist-sdk/src/entities/element/system-fields.d.ts +4 -0
  83. package/dist-sdk/src/entities/element/system-fields.js +12 -0
  84. package/dist-sdk/src/entities/element/to-tf.js +1 -0
  85. package/dist-sdk/src/entities/field/build.d.ts +2 -2
  86. package/dist-sdk/src/entities/field/from-tf.js +82 -4
  87. package/dist-sdk/src/entities/field/to-tf.d.ts +1 -1
  88. package/dist-sdk/src/entities/field/to-tf.js +11 -4
  89. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -2
  90. package/dist-sdk/src/entities/relationship/from-tf.js +8 -5
  91. package/dist-sdk/src/entities/relationship/to-tf.js +13 -3
  92. package/dist-sdk/src/entities/search-table/from-tf.js +6 -6
  93. package/dist-sdk/src/entities/search-table/module.js +2 -2
  94. package/dist-sdk/src/entities/search-table/types.d.ts +1 -0
  95. package/dist-sdk/src/entities/search-table/types.js +1 -0
  96. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +3 -3
  97. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +10 -6
  98. package/dist-sdk/src/entities/shared/filters/ast.d.ts +4 -2
  99. package/dist-sdk/src/entities/shared/filters/index.d.ts +12 -2
  100. package/dist-sdk/src/entities/shared/filters/index.js +17 -1
  101. package/dist-sdk/src/entities/shared/filters/print.js +25 -11
  102. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
  103. package/dist-sdk/src/entities/shared/filters/tf-codec.js +39 -7
  104. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
  105. package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
  106. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +6 -0
  107. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +47 -18
  108. package/dist-sdk/src/entities/skill/module.js +10 -0
  109. package/dist-sdk/src/entities/skill/to-tf.js +19 -0
  110. package/dist-sdk/src/entities/skill/tools.d.ts +29 -7
  111. package/dist-sdk/src/entities/skill/tools.js +6 -2
  112. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +18 -0
  113. package/dist-sdk/src/entities/skill-tool/from-tf.js +77 -4
  114. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
  115. package/dist-sdk/src/entities/skill-tool/to-tf.js +90 -46
  116. package/dist-sdk/src/entities/task/module.js +1 -1
  117. package/dist-sdk/src/entities/view/from-tf.js +30 -9
  118. package/dist-sdk/src/entities/view/to-tf.js +18 -10
  119. package/dist-sdk/src/entities/widget/from-tf.js +3 -3
  120. package/dist-sdk/src/entities/widget/to-tf.js +1 -0
  121. package/dist-sdk/src/graph/index.d.ts +15 -0
  122. package/dist-sdk/src/graph/index.js +19 -0
  123. package/dist-sdk/src/graph/types.d.ts +37 -1
  124. package/package.json +2 -1
@@ -1,7 +1,7 @@
1
1
  import { EntityTfError } from "../../engine/entity.js";
2
2
  import { resourceRefLabel } from "../../engine/pull/context.js";
3
3
  import { isTfExpr, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
4
- import { fieldKeyFromTfRef } from "../field/from-tf.js";
4
+ import { fieldKeyFromTfValue } from "../field/from-tf.js";
5
5
  import { KNOWN_SEARCH_TABLE_ATTRS, SEARCH_TABLE_VARIANT_BY_RESOURCE } from "./types.js";
6
6
  import { connectorIdentityFromTf } from "../shared/connector-from-tf.js";
7
7
  function requiredString(attrs, key, where) {
@@ -17,10 +17,10 @@ function assertKnown(block, variant) {
17
17
  }
18
18
  }
19
19
  }
20
- function fieldKey(value, ownerTfLabel, scope, where) {
20
+ function fieldKey(value, ownerRefName, ownerTfLabel, scope, ctx, where) {
21
21
  if (value === undefined)
22
22
  throw new EntityTfError(`${where}: field reference is required`);
23
- const key = fieldKeyFromTfRef(value, ownerTfLabel, scope);
23
+ const key = fieldKeyFromTfValue(value, ownerRefName, ownerTfLabel, scope, ctx);
24
24
  if (key === undefined)
25
25
  throw new EntityTfError(`${where}: field value is not a field resource reference`);
26
26
  return key;
@@ -105,10 +105,10 @@ export function searchTableFromTf(block, ownerTfLabel, scope, ctx) {
105
105
  kind: "snowflake",
106
106
  refName,
107
107
  ...(typeof block.attrs["name"] === "string" && { name: block.attrs["name"] }),
108
- fieldKey: fieldKey(block.attrs["field_id"], ownerTfLabel, aspectScope, where),
109
- attributeFieldKeys: rawAttributes.map((value) => fieldKey(value, ownerTfLabel, aspectScope, where)),
108
+ fieldKey: fieldKey(block.attrs["field_id"], tfLabelToTsLabel(ownerTfLabel), ownerTfLabel, aspectScope, ctx, where),
109
+ attributeFieldKeys: rawAttributes.map((value) => fieldKey(value, tfLabelToTsLabel(ownerTfLabel), ownerTfLabel, aspectScope, ctx, where)),
110
110
  ...(rawTextIndexFields !== undefined && {
111
- textIndexFieldKeys: rawTextIndexFields.map((value) => fieldKey(value, ownerTfLabel, aspectScope, where)),
111
+ textIndexFieldKeys: rawTextIndexFields.map((value) => fieldKey(value, tfLabelToTsLabel(ownerTfLabel), ownerTfLabel, aspectScope, ctx, where)),
112
112
  }),
113
113
  connectorKey: connectorKey(block.attrs["ai_provider_connector_id"], ctx, where),
114
114
  duration: duration,
@@ -7,7 +7,7 @@ import { EntityTfError } from "../../engine/entity.js";
7
7
  import { searchTableFromTf } from "./from-tf.js";
8
8
  import { printSearchTable } from "./printer.js";
9
9
  import { searchTableToTf } from "./to-tf.js";
10
- import { SEARCH_TABLE_RESOURCE_TYPES } from "./types.js";
10
+ import { SEARCH_TABLE_DATA_SOURCE_TYPE, SEARCH_TABLE_RESOURCE_TYPES } from "./types.js";
11
11
  function isConfigured(value) {
12
12
  return (typeof value === "object" &&
13
13
  value !== null &&
@@ -89,7 +89,7 @@ export const searchTableModule = {
89
89
  },
90
90
  data: {
91
91
  participates: true,
92
- resourceType: "elementum_search_table",
92
+ resourceType: SEARCH_TABLE_DATA_SOURCE_TYPE,
93
93
  lookupAttr: "name",
94
94
  referencedByBuild: true,
95
95
  },
@@ -3,6 +3,7 @@ export declare const SEARCH_TABLE_RESOURCE_TYPES: {
3
3
  readonly linked: "elementum_linked_ai_search_table";
4
4
  readonly table: "elementum_table_search_table";
5
5
  };
6
+ export declare const SEARCH_TABLE_DATA_SOURCE_TYPE: "elementum_search_table";
6
7
  export type SearchTableResourceVariant = keyof typeof SEARCH_TABLE_RESOURCE_TYPES;
7
8
  export declare const SEARCH_TABLE_VARIANT_BY_RESOURCE: Map<string, "snowflake" | "table" | "linked">;
8
9
  export declare const KNOWN_SEARCH_TABLE_ATTRS: Readonly<Record<"snowflake" | "linked" | "table", ReadonlySet<string>>>;
@@ -3,6 +3,7 @@ export const SEARCH_TABLE_RESOURCE_TYPES = {
3
3
  linked: "elementum_linked_ai_search_table",
4
4
  table: "elementum_table_search_table",
5
5
  };
6
+ export const SEARCH_TABLE_DATA_SOURCE_TYPE = "elementum_search_table";
6
7
  export const SEARCH_TABLE_VARIANT_BY_RESOURCE = new Map(Object.entries(SEARCH_TABLE_RESOURCE_TYPES).map(([variant, resource]) => [resource, variant]));
7
8
  export const KNOWN_SEARCH_TABLE_ATTRS = {
8
9
  snowflake: new Set([
@@ -4,9 +4,9 @@ import type { FromTfContext } from "../../engine/pull/context.js";
4
4
  * lookups are intentionally namespace-only, so fall back through the
5
5
  * recursive pull's namespace -> refName and display-name -> refName maps.
6
6
  */
7
- export declare function dataAspectDisplayName(ctx: FromTfContext, kind: "app" | "element", label: string): string | undefined;
7
+ export declare function dataAspectDisplayName(ctx: FromTfContext, kind: "app" | "element" | "task", label: string): string | undefined;
8
8
  /** Resolve the stable pulled catalog key for the same foreign lookup. */
9
- export declare function dataAspectRefName(ctx: FromTfContext, kind: "app" | "element", label: string, displayName?: string): string | undefined;
9
+ export declare function dataAspectRefName(ctx: FromTfContext, kind: "app" | "element" | "task", label: string, displayName?: string): string | undefined;
10
10
  export interface ResolvedAspectTarget {
11
11
  readonly key: string;
12
12
  readonly name: string;
@@ -21,4 +21,4 @@ export interface ResolvedAspectTarget {
21
21
  * the real namespace still attached) when it wasn't - never a bare guessed
22
22
  * name with no namespace, which matches nothing on the platform.
23
23
  */
24
- export declare function resolveDataAspectTarget(ctx: FromTfContext, kind: "app" | "element", dataLabel: string): ResolvedAspectTarget;
24
+ export declare function resolveDataAspectTarget(ctx: FromTfContext, kind: "app" | "element" | "task", dataLabel: string): ResolvedAspectTarget;
@@ -5,7 +5,7 @@ import { tfLabelToTsLabel } from "../../engine/tf/index.js";
5
5
  * recursive pull's namespace -> refName and display-name -> refName maps.
6
6
  */
7
7
  export function dataAspectDisplayName(ctx, kind, label) {
8
- const type = kind === "app" ? "elementum_app" : "elementum_element";
8
+ const type = kind === "app" ? "elementum_app" : kind === "element" ? "elementum_element" : "elementum_task";
9
9
  const direct = ctx.dataName(type, label);
10
10
  if (direct !== undefined)
11
11
  return direct;
@@ -17,25 +17,29 @@ export function dataAspectDisplayName(ctx, kind, label) {
17
17
  return undefined;
18
18
  const refName = kind === "app"
19
19
  ? ctx.foreignAppRefNamespaces?.get(namespace)
20
- : ctx.foreignElementRefNamespaces?.get(namespace);
20
+ : kind === "element"
21
+ ? ctx.foreignElementRefNamespaces?.get(namespace)
22
+ : undefined;
21
23
  if (refName === undefined)
22
24
  return undefined;
23
- const names = kind === "app" ? ctx.foreignAppRefNames : ctx.foreignElementRefNames;
25
+ const names = kind === "app" ? ctx.foreignAppRefNames : kind === "element" ? ctx.foreignElementRefNames : undefined;
24
26
  return [...(names?.entries() ?? [])].find(([, candidateRefName]) => candidateRefName === refName)?.[0];
25
27
  }
26
28
  /** Resolve the stable pulled catalog key for the same foreign lookup. */
27
29
  export function dataAspectRefName(ctx, kind, label, displayName) {
30
+ if (kind === "task")
31
+ return tfLabelToTsLabel(label);
28
32
  const type = kind === "app" ? "elementum_app" : "elementum_element";
29
33
  const attrs = ctx.dataAttrs?.(type, label);
30
34
  const namespace = typeof attrs?.namespace === "string" ? attrs.namespace : undefined;
31
- const byNamespace = kind === "app" ? ctx.foreignAppRefNamespaces : ctx.foreignElementRefNamespaces;
35
+ const byNamespace = kind === "app" ? ctx.foreignAppRefNamespaces : kind === "element" ? ctx.foreignElementRefNamespaces : undefined;
32
36
  if (namespace !== undefined) {
33
37
  const refName = byNamespace?.get(namespace);
34
38
  if (refName !== undefined)
35
39
  return refName;
36
40
  }
37
41
  const name = displayName ?? dataAspectDisplayName(ctx, kind, label);
38
- const byName = kind === "app" ? ctx.foreignAppRefNames : ctx.foreignElementRefNames;
42
+ const byName = kind === "app" ? ctx.foreignAppRefNames : kind === "element" ? ctx.foreignElementRefNames : undefined;
39
43
  return name === undefined ? undefined : byName?.get(name);
40
44
  }
41
45
  /**
@@ -46,7 +50,7 @@ export function dataAspectRefName(ctx, kind, label, displayName) {
46
50
  * name with no namespace, which matches nothing on the platform.
47
51
  */
48
52
  export function resolveDataAspectTarget(ctx, kind, dataLabel) {
49
- const type = kind === "app" ? "elementum_app" : "elementum_element";
53
+ const type = kind === "app" ? "elementum_app" : kind === "element" ? "elementum_element" : "elementum_task";
50
54
  const displayName = dataAspectDisplayName(ctx, kind, dataLabel);
51
55
  const refName = dataAspectRefName(ctx, kind, dataLabel, displayName);
52
56
  const attrs = ctx.dataAttrs?.(type, dataLabel);
@@ -39,7 +39,7 @@ export interface AppRefAst {
39
39
  readonly kind: "app";
40
40
  readonly appHandle: string;
41
41
  /** Present for a foreign data lookup that is not in the local catalog. */
42
- readonly entityType?: "app" | "element";
42
+ readonly entityType?: "app" | "element" | "task";
43
43
  /** Provider lookup name for that foreign app/element. */
44
44
  readonly name?: string;
45
45
  }
@@ -57,7 +57,7 @@ export interface FieldRefAst {
57
57
  * `AppRefAst.name`, which this mirrors).
58
58
  */
59
59
  readonly foreign?: {
60
- readonly entityType: "app" | "element";
60
+ readonly entityType: "app" | "element" | "task";
61
61
  /** The owner's display name — resolves a same-name local catalog entry, same convention as `AppRefAst.name`. */
62
62
  readonly name: string;
63
63
  /** Stable namespace for a portable inline fieldRef owner lookup. */
@@ -210,6 +210,8 @@ export type RefExpr =
210
210
  kind: "taskRef";
211
211
  task: string;
212
212
  path: readonly string[];
213
+ /** Pulled task-reference envelope names an execute-script output absent from its schema. */
214
+ undeclaredScriptOutput?: true;
213
215
  }
214
216
  /** Reference to a trigger input: `ctx.trigger.<path...>`. */
215
217
  | {
@@ -49,13 +49,23 @@ export interface CurrentUserFilterValue {
49
49
  readonly valueType: "ID" | "EMAIL" | "DOMAIN";
50
50
  }
51
51
  export declare function currentUser(valueType?: "ID" | "EMAIL" | "DOMAIN"): CurrentUserFilterValue;
52
+ /** A field used as an explicit comparison operand, preserving its identity. */
53
+ export interface FieldLeftValue {
54
+ readonly type: "FIELD";
55
+ readonly value: FilterField;
56
+ readonly aspect?: never;
57
+ readonly treatNullAsEquals?: true;
58
+ }
59
+ export declare function fieldValue(value: FilterField): FieldLeftValue;
52
60
  export declare function fieldValue(value: FilterField, options?: {
53
61
  readonly aspect?: string;
54
62
  readonly treatNullAsEquals?: boolean;
55
- }): FilterValue<FilterField, FilterReferenceValue>;
63
+ }): Extract<FilterValue<FilterField, FilterReferenceValue>, {
64
+ type: "FIELD";
65
+ }>;
56
66
  type AuthoredFilterValue = FilterValue<FilterField, FilterReferenceValue>;
57
67
  export type FilterInput = string | number | boolean | null | Ref<unknown> | FilterReferenceInput | FilterField | CurrentUserFilterValue | AuthoredFilterValue;
58
- export type LeftRef = FilterField | Ref<unknown> | FilterReferenceInput;
68
+ export type LeftRef = FilterField | Ref<unknown> | FilterReferenceInput | FieldLeftValue;
59
69
  export declare const UNRESOLVED_REFERENCE_MARKER = "__edkUnresolvedReference::";
60
70
  export declare function refDataToFilterReference(data: import("../ref.js").RefData): FilterReference;
61
71
  export declare function toFilterValue(input: FilterInput, valueType?: ValueType): FilterValue<FilterField, FilterReferenceValue>;
@@ -78,13 +78,17 @@ export function isFilterReferenceInput(value) {
78
78
  export function currentUser(valueType = "ID") {
79
79
  return { __kind: "currentUser", valueType };
80
80
  }
81
+ // Retain authoring-only type/options without adding them to the wire value.
82
+ const FIELD_VALUE_SOURCE = Symbol("FieldValueSource");
81
83
  export function fieldValue(value, options) {
82
- return {
84
+ const operand = {
83
85
  type: "FIELD",
84
86
  value: fieldWireValue(value),
85
87
  ...(options?.aspect !== undefined && { aspect: options.aspect }),
86
88
  ...(options?.treatNullAsEquals !== undefined && { treatNullAsEquals: options.treatNullAsEquals }),
87
89
  };
90
+ Object.defineProperty(operand, FIELD_VALUE_SOURCE, { value });
91
+ return operand;
88
92
  }
89
93
  export const UNRESOLVED_REFERENCE_MARKER = "__edkUnresolvedReference::";
90
94
  export function refDataToFilterReference(data) {
@@ -130,7 +134,15 @@ function fieldWireValue(field) {
130
134
  return field.value;
131
135
  return isAppField(field) ? field.id : field;
132
136
  }
137
+ function isFieldLeftValue(value) {
138
+ return typeof value === "object" && value !== null && "type" in value && value.type === "FIELD";
139
+ }
140
+ function sourceField(left) {
141
+ return left[FIELD_VALUE_SOURCE] ?? left.value;
142
+ }
133
143
  function leftType(left, fallback, explicit) {
144
+ if (isFieldLeftValue(left))
145
+ return leftType(sourceField(left), fallback, explicit);
134
146
  if (explicit !== undefined)
135
147
  return explicit;
136
148
  if (isFilterReferenceInput(left))
@@ -140,6 +152,8 @@ function leftType(left, fallback, explicit) {
140
152
  return fieldTypeToValueType(isAppField(left) ? left.type : "fieldType" in left ? left.fieldType : undefined);
141
153
  }
142
154
  function leftDescriptor(left, fallback, explicit) {
155
+ if (isFieldLeftValue(left))
156
+ return { leftValue: left };
143
157
  if (isFilterReferenceInput(left))
144
158
  return { leftValue: toFilterValue(left) };
145
159
  if (isRef(left))
@@ -150,6 +164,8 @@ function leftDescriptor(left, fallback, explicit) {
150
164
  return { field: fieldWireValue(left) };
151
165
  }
152
166
  function resolveStaticFieldValue(field, input) {
167
+ if (isFieldLeftValue(field))
168
+ return resolveStaticFieldValue(sourceField(field), input);
153
169
  if (isRef(input) || isFilterReferenceInput(input) || !isAppField(field))
154
170
  return input;
155
171
  return picklistStaticValueToApiId(field, input);
@@ -1,3 +1,4 @@
1
+ import { EntityTfError } from "../../../engine/entity.js";
1
2
  function defaultQuote(value) { return JSON.stringify(value); }
2
3
  /** Print every canonical filter through the same public `filter.*` authoring surface. */
3
4
  export function printFilter(filter, codec) {
@@ -7,11 +8,24 @@ export function printFilter(filter, codec) {
7
8
  codec.used?.(helper);
8
9
  return `${namespace}.${helper}(${args})`;
9
10
  };
10
- const value = (input) => printFilterValue(input, codec, call, quote);
11
+ const literals = "value" in filter ? [filter.value]
12
+ : "values" in filter ? filter.values
13
+ : "min" in filter ? [filter.min, filter.max] : [];
14
+ const uuidValues = literals.length > 0 && literals.every((literal) => literal.type === "UUID");
15
+ const explicitType = uuidValues ? `, ${quote("UUID")}` : "";
16
+ const value = (input) => input.type === "UUID"
17
+ ? uuidValues ? quote(input.value) : `{ type: "UUID", value: ${quote(input.value)} }`
18
+ : printFilterValue(input, codec, call, quote);
19
+ if ("leftValue" in filter && filter.leftValue?.type === "FIELD") {
20
+ const operand = filter.leftValue;
21
+ if ((operand.aspect != null && operand.aspect !== "") || (operand.treatNullAsEquals != null && operand.treatNullAsEquals !== true)) {
22
+ throw new EntityTfError("filter FIELD left operand cannot represent aspect or nondefault treatNullAsEquals");
23
+ }
24
+ }
11
25
  const left = "field" in filter && filter.field !== undefined
12
26
  ? codec.field(filter.field)
13
27
  : "leftValue" in filter && filter.leftValue !== undefined
14
- ? filter.leftValue.type === "FIELD" ? codec.field(filter.leftValue.value) : value(filter.leftValue)
28
+ ? filter.leftValue.type === "FIELD" ? call("fieldValue", codec.field(filter.leftValue.value)) : value(filter.leftValue)
15
29
  : "undefined /* TODO: filter has no left side */";
16
30
  const core = () => {
17
31
  switch (filter.type) {
@@ -19,19 +33,19 @@ export function printFilter(filter, codec) {
19
33
  case "FALSE": return call("whereFalse", "");
20
34
  case "AND": return call("and", filter.children.map((child) => printFilter(child, codec)).join(", "));
21
35
  case "OR": return call("or", filter.children.map((child) => printFilter(child, codec)).join(", "));
22
- case "EQUALS": return call(filter.not === true ? "neq" : "eq", `${left}, ${value(filter.value)}`);
23
- case "GREATER_THAN": return call("gt", `${left}, ${value(filter.value)}`);
24
- case "GREATER_THAN_EQUALS": return call("gte", `${left}, ${value(filter.value)}`);
25
- case "LESS_THAN": return call("lt", `${left}, ${value(filter.value)}`);
26
- case "LESS_THAN_EQUALS": return call("lte", `${left}, ${value(filter.value)}`);
27
- case "LIKE": return call("like", `${left}, ${value(filter.value)}${printLikeOptions(filter, quote)}`);
36
+ case "EQUALS": return call(filter.not === true ? "neq" : "eq", `${left}, ${value(filter.value)}${explicitType}`);
37
+ case "GREATER_THAN": return call("gt", `${left}, ${value(filter.value)}${explicitType}`);
38
+ case "GREATER_THAN_EQUALS": return call("gte", `${left}, ${value(filter.value)}${explicitType}`);
39
+ case "LESS_THAN": return call("lt", `${left}, ${value(filter.value)}${explicitType}`);
40
+ case "LESS_THAN_EQUALS": return call("lte", `${left}, ${value(filter.value)}${explicitType}`);
41
+ case "LIKE": return call("like", `${left}, ${value(filter.value)}${printLikeOptions(filter, quote) || (uuidValues ? ", undefined" : "")}${explicitType}`);
28
42
  case "IS_NULL": return call(filter.not === true ? "isNotNull" : "isNull", left);
29
- case "IN": return call(filter.not === true ? "isNotIn" : "isIn", `${left}, [${filter.values.map(value).join(", ")}]`);
30
- case "BETWEEN": return call("between", `${left}, ${value(filter.min)}, ${value(filter.max)}${filter.not === true ? ", { not: true }" : ""}`);
43
+ case "IN": return call(filter.not === true ? "isNotIn" : "isIn", `${left}, [${filter.values.map(value).join(", ")}]${explicitType}`);
44
+ case "BETWEEN": return call("between", `${left}, ${value(filter.min)}, ${value(filter.max)}${filter.not === true ? ", { not: true }" : uuidValues ? ", undefined" : ""}${explicitType}`);
31
45
  case "CONTAINS":
32
46
  case "OVERLAPS": {
33
47
  const helper = filter.type === "CONTAINS" ? "contains" : "overlaps";
34
- return call(helper, `${left}, [${filter.values.map(value).join(", ")}]${filter.not === true ? ", { not: true }" : ""}`);
48
+ return call(helper, `${left}, [${filter.values.map(value).join(", ")}]${filter.not === true ? ", { not: true }" : uuidValues ? ", undefined" : ""}${explicitType}`);
35
49
  }
36
50
  case "CURRENT_RANGE": {
37
51
  const options = [`unit: ${quote(filter.unit)}`];
@@ -103,7 +103,7 @@ export interface FilterToTfCodec {
103
103
  export interface FilterFromTfCodec<Field = string, ReferenceValue = never> {
104
104
  readonly field: (value: TfValue, fieldScope: "app" | "user") => Field;
105
105
  readonly aspect?: (value: TfValue) => Field;
106
- readonly reference: (value: TfValue) => ReferenceValue;
106
+ readonly reference: (value: TfValue, role: "left" | "value") => ReferenceValue;
107
107
  /**
108
108
  * A structured reference envelope can carry a more authoritative output
109
109
  * type than the provider's legacy outer `real_type` default. Consumers
@@ -156,6 +156,32 @@ function filterValueToWire(value) {
156
156
  ...(value.required !== undefined && { required: value.required }),
157
157
  };
158
158
  }
159
+ /** Validate every supplied identity; a malformed canonical value must not fall back to a legacy alias. */
160
+ function fieldOperandToTf(raw, codec) {
161
+ let identity;
162
+ for (const key of ["value", "field", "field_id"]) {
163
+ if (!Object.hasOwn(raw, key))
164
+ continue;
165
+ const candidate = raw[key];
166
+ if (candidate === null || candidate === undefined || Array.isArray(candidate) ||
167
+ (typeof candidate !== "string" && typeof candidate !== "object") ||
168
+ (typeof candidate === "string" && candidate.trim() === "")) {
169
+ throw new EntityTfError(`FIELD.${key} must be a non-empty field identity`);
170
+ }
171
+ const resolved = codec.field(candidate);
172
+ if (!(typeof resolved === "string" && resolved.trim() !== "") && !isTfExpr(resolved)) {
173
+ throw new EntityTfError(`FIELD.${key} must resolve to a non-empty field identity`);
174
+ }
175
+ // Compare resolved identities, not optional metadata on authored tokens.
176
+ if (identity !== undefined && JSON.stringify(identity) !== JSON.stringify(resolved)) {
177
+ throw new EntityTfError("FIELD value and legacy aliases disagree");
178
+ }
179
+ identity = resolved;
180
+ }
181
+ if (identity === undefined)
182
+ throw new EntityTfError("FIELD requires value (or legacy field)");
183
+ return identity;
184
+ }
159
185
  function wireFilterValueToTf(value, field, codec, role = "value", operator) {
160
186
  if (value === null || typeof value !== "object" || isTfExpr(value)) {
161
187
  throw new EntityTfError("invalid wire filter value");
@@ -191,12 +217,15 @@ function wireFilterValueToTf(value, field, codec, role = "value", operator) {
191
217
  };
192
218
  }
193
219
  if (type === "field") {
194
- const fieldValue = raw.value ?? raw.field ?? raw.field_id;
195
- if (fieldValue === undefined)
196
- throw new EntityTfError("field filter value requires value");
220
+ // left_value retains only identity. Validate every accepted spelling and
221
+ // alias before conversion can discard metadata or coerce its value.
222
+ if (role === "left" && ([raw.aspect, raw.aspect_id].some((aspect) => aspect != null && aspect !== "") ||
223
+ [raw.treatNullAsEquals, raw.treat_null_as_equals].some((flag) => flag != null && flag !== true))) {
224
+ throw new EntityTfError("filter FIELD left operand cannot represent aspect or nondefault treatNullAsEquals");
225
+ }
197
226
  return {
198
227
  type,
199
- field_id: codec.field(fieldValue),
228
+ field_id: fieldOperandToTf(raw, codec),
200
229
  ...((raw.aspect ?? raw.aspect_id) !== undefined && { aspect_id: (raw.aspect ?? raw.aspect_id) }),
201
230
  ...((raw.treatNullAsEquals ?? raw.treat_null_as_equals) !== undefined && { treat_null_as_equals: Boolean(raw.treatNullAsEquals ?? raw.treat_null_as_equals) }),
202
231
  };
@@ -330,7 +359,7 @@ export function filterTfToWire(value) {
330
359
  ...("field_id" in filter && filter.field_id !== undefined && { field: filter.field_id }),
331
360
  ...("left_value" in filter && filter.left_value !== undefined && {
332
361
  leftValue: filter.left_value.field_id !== undefined
333
- ? { type: "FIELD", field: filter.left_value.field_id }
362
+ ? { type: "FIELD", value: filter.left_value.field_id }
334
363
  : { type: "REFERENCE", value: tfReferenceToWire(filter.left_value.value_reference), realType: (filter.left_value.real_type ?? "text").toUpperCase() },
335
364
  }),
336
365
  };
@@ -435,7 +464,7 @@ export function filterFromTf(value, codec, fieldScope = "app") {
435
464
  leftValue: {
436
465
  type: "REFERENCE",
437
466
  realType: codec.referenceType?.(filter.left_value.value_reference, fallback) ?? fallback,
438
- value: codec.reference(filter.left_value.value_reference),
467
+ value: codec.reference(filter.left_value.value_reference, "left"),
439
468
  },
440
469
  };
441
470
  }
@@ -487,6 +516,9 @@ export function filterFromTf(value, codec, fieldScope = "app") {
487
516
  function filterValueFromTf(value, codec, fieldScope) {
488
517
  const type = value.type.toLowerCase();
489
518
  const literal = codec.literal?.(value.value, type) ?? value.value;
519
+ if (["text", "uuid", "number", "boolean", "date", "datetime"].includes(type) && typeof literal === "object" && literal !== null) {
520
+ throw new EntityTfError(`${type} filter literal contains an unresolved expression or object`);
521
+ }
490
522
  switch (type) {
491
523
  case "null": return { type: "NULL" };
492
524
  case "current_user": {
@@ -500,7 +532,7 @@ function filterValueFromTf(value, codec, fieldScope) {
500
532
  return {
501
533
  type: "REFERENCE",
502
534
  realType: codec.referenceType?.(value.value_reference, fallback) ?? fallback,
503
- value: codec.reference(value.value_reference),
535
+ value: codec.reference(value.value_reference, "value"),
504
536
  ...(value.multiple === true && { multiple: true }),
505
537
  };
506
538
  }
@@ -16,4 +16,4 @@
16
16
  */
17
17
  import type { FromTfContext } from "../../engine/pull/context.js";
18
18
  import { type ChildResourceScope, type TfValue } from "../../engine/tf/index.js";
19
- export declare function resolveToolFieldKey(fieldRef: TfValue | undefined, scopeTfLabel: string, scope?: ChildResourceScope, ctx?: Pick<FromTfContext, "dataAttrs" | "foreignFieldRefsByDataAddress">): string | undefined;
19
+ export declare function resolveToolFieldKey(fieldRef: TfValue | undefined, scopeTfLabel: string, scope?: ChildResourceScope | "task", ctx?: Pick<FromTfContext, "dataAttrs" | "foreignFieldRefsByDataAddress">): string | undefined;
@@ -4,12 +4,12 @@ export function resolveToolFieldKey(fieldRef, scopeTfLabel, scope = "app", ctx)
4
4
  if (fieldRef === undefined)
5
5
  return undefined;
6
6
  if (isTfExpr(fieldRef) && fieldRef.$expr === "resource-attr" && FIELD_SUB_TYPE_BY_RESOURCE.has(fieldRef.type)) {
7
- return scopedLabelToBagKey(scopeTfLabel, fieldRef.label, scope);
7
+ return scopedLabelToBagKey(scopeTfLabel, fieldRef.label, scope === "task" ? "app" : scope);
8
8
  }
9
9
  if (isTfExpr(fieldRef) && fieldRef.$expr === "data-attr" && fieldRef.type === "elementum_field") {
10
10
  const fieldAttrs = ctx?.dataAttrs?.("elementum_field", fieldRef.label);
11
11
  const objectId = fieldAttrs?.object_id;
12
- const ownerType = scope === "element" ? "elementum_element" : "elementum_app";
12
+ const ownerType = scope === "element" ? "elementum_element" : scope === "task" ? "elementum_task" : "elementum_app";
13
13
  const addressesResolvedToSameTarget = objectId !== undefined && isTfExpr(objectId) && objectId.$expr === "data-attr" &&
14
14
  objectId.type === ownerType && objectId.label === scopeTfLabel && objectId.path.join(".") === "id";
15
15
  if (addressesResolvedToSameTarget) {
@@ -30,6 +30,10 @@ export function resolveToolFieldKey(fieldRef, scopeTfLabel, scope = "app", ctx)
30
30
  if (fieldRef.label.startsWith(prefix)) {
31
31
  return tfLabelToTsLabel(fieldRef.label.slice(prefix.length));
32
32
  }
33
+ const taskPrefix = `elementum_task_${scopeTfLabel}_`;
34
+ if (scope === "task" && fieldRef.label.startsWith(taskPrefix)) {
35
+ return tfLabelToTsLabel(fieldRef.label.slice(taskPrefix.length));
36
+ }
33
37
  }
34
38
  if (isTfExpr(fieldRef) && fieldRef.$expr === "local") {
35
39
  const prefix = `${scopeTfLabel}_`;
@@ -35,6 +35,12 @@ export interface PrintSkillV2Options {
35
35
  * `catalog.<refName>` instead of the literal stub.
36
36
  */
37
37
  readonly foreignElementRefNames?: ReadonlyMap<string, string>;
38
+ /**
39
+ * Same as {@link foreignAppRefNames}, keyed for standalone tasks — a
40
+ * `foreignTask` tool target whose name is a key here prints
41
+ * `catalog.<refName>` instead of the literal stub.
42
+ */
43
+ readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
38
44
  /** Raw foreign field id → typed catalog field identity, supplied by recursive pull. */
39
45
  readonly foreignFieldRefsById?: ReadonlyMap<string, {
40
46
  readonly ownerRefName: string;
@@ -13,6 +13,7 @@
13
13
  * Unresolved field and automation platform ids print as `unsafePlatformId(...)`.
14
14
  */
15
15
  import { quote } from "../../../../pull/util.js";
16
+ import { sanitizeName, tfLabelToTsLabel } from "../../../engine/tf/index.js";
16
17
  import { sdkPackageSpecifier } from "../../../internal/sdk-package.js";
17
18
  import { safeIdentifier } from "../../../internal/safe-identifier.js";
18
19
  const TOOL_FACTORY_BY_TYPE_KEY = {
@@ -51,6 +52,7 @@ export function printSkillV2(skill, opts) {
51
52
  ]),
52
53
  ].sort();
53
54
  const usesUnsafePlatformId = skill.tools.some((tool) => tool.automationRawId !== undefined ||
55
+ tool.searchTableRawId !== undefined ||
54
56
  tool.target?.kind === "unresolved" ||
55
57
  tool.fields?.some((field) => field.rawFieldId !== undefined && !opts.foreignFieldRefsById?.has(field.rawFieldId)) === true ||
56
58
  (tool.filterVariables?.length ?? 0) > 0);
@@ -116,7 +118,7 @@ export function printSkillV2(skill, opts) {
116
118
  if (skill.tools.length > 0) {
117
119
  lines.push(" tools: [");
118
120
  for (const tool of skill.tools) {
119
- lines.push(...printTool(tool, appRefName, crossOrg, opts.foreignAppRefNames, opts.foreignElementRefNames, opts.foreignFieldRefsById, opts.foreignSearchTableRefsByName).map((l) => ` ${l}`));
121
+ lines.push(...printTool(tool, appRefName, crossOrg, opts.foreignAppRefNames, opts.foreignElementRefNames, opts.foreignTaskRefNames, opts.foreignFieldRefsById, opts.foreignSearchTableRefsByName).map((l) => ` ${l}`));
120
122
  }
121
123
  lines.push(" ],");
122
124
  }
@@ -126,7 +128,7 @@ export function printSkillV2(skill, opts) {
126
128
  lines.push("");
127
129
  return lines.join("\n");
128
130
  }
129
- function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames) {
131
+ function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames, foreignTaskRefNames) {
130
132
  // `fields` (and therefore this) is only ever reached for createRecord/
131
133
  // searchAspect/updateRecord, which always carry a target — automation/
132
134
  // runAgent tools return before this point. The undefined branch only
@@ -141,8 +143,20 @@ function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNa
141
143
  if (tool.target.kind === "unresolved") {
142
144
  return { kind: "raw", entityType: "app", name: tool.target.uuid, refName: tool.target.uuid };
143
145
  }
146
+ if (tool.target.kind === "foreignTask") {
147
+ const foreignRefName = foreignTaskRefNames?.get(tool.target.name) ?? tool.target.refName ?? tool.target.name;
148
+ return {
149
+ kind: "raw",
150
+ entityType: "task",
151
+ name: tool.target.name,
152
+ refName: foreignRefName,
153
+ ...(tool.target.namespace !== undefined && { namespace: tool.target.namespace }),
154
+ };
155
+ }
144
156
  const entityKind = tool.target.kind === "foreignElement" ? "element" : "app";
145
- const refNames = tool.target.kind === "foreignElement" ? foreignElementRefNames : foreignAppRefNames;
157
+ const refNames = tool.target.kind === "foreignElement"
158
+ ? foreignElementRefNames
159
+ : foreignAppRefNames;
146
160
  const foreignRefName = tool.target.refName ?? refNames?.get(tool.target.name);
147
161
  return foreignRefName !== undefined
148
162
  ? refNames?.get(tool.target.name) !== undefined
@@ -156,7 +170,7 @@ function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNa
156
170
  }
157
171
  : { kind: "raw", entityType: entityKind, name: tool.target.name, refName: tool.target.name };
158
172
  }
159
- function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElementRefNames, foreignFieldRefsById, foreignSearchTableRefsByName) {
173
+ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElementRefNames, foreignTaskRefNames, foreignFieldRefsById, foreignSearchTableRefsByName) {
160
174
  const factory = TOOL_FACTORY_BY_TYPE_KEY[tool.typeKey] ?? "skillSearchRecords";
161
175
  const lines = [`${factory}({`];
162
176
  const targetRefName = tool.target?.kind === "self"
@@ -165,7 +179,9 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
165
179
  ? tool.target.refName ?? foreignElementRefNames?.get(tool.target.name)
166
180
  : tool.target?.kind === "foreignApp"
167
181
  ? tool.target.refName ?? foreignAppRefNames?.get(tool.target.name)
168
- : undefined;
182
+ : tool.target?.kind === "foreignTask"
183
+ ? tool.target.refName ?? foreignTaskRefNames?.get(tool.target.name)
184
+ : undefined;
169
185
  lines.push(` name: ${quote(tool.name)},`);
170
186
  lines.push(` description: ${quote(tool.description)},`);
171
187
  if (tool.status !== undefined)
@@ -183,7 +199,14 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
183
199
  if (tool.typeKey === "automation") {
184
200
  lines.push(tool.automationRawId !== undefined
185
201
  ? ` automation: unsafePlatformId(${quote(tool.automationRawId)}),`
186
- : ` automation: catalog.${appRefName}.automations${safeMember(tool.automationKey ?? "")},`);
202
+ : tool.automationForeignName !== undefined
203
+ ? // A cross-app/element automation reference - no typed catalog
204
+ // token for a foreign automation exists yet (mirrors the raw
205
+ // foreign-literal fallback used for an unresolved search table
206
+ // elsewhere in this printer). refName is a best-effort guess
207
+ // from the display name, not a verified catalog key.
208
+ ` automation: { __kind: "automation", refName: ${quote(tfLabelToTsLabel(sanitizeName(tool.automationForeignName)))}, name: ${quote(tool.automationForeignName)}, parent: ${quote(tool.automationForeignParentRefName ?? tool.automationForeignParentName ?? "")}, parentName: ${quote(tool.automationForeignParentName ?? "")}, parentKind: ${quote(tool.automationForeignParentKind ?? "app")} } /* TODO: foreign automation reference - no catalog token available; verify the parent/refName before deploying */,`
209
+ : ` automation: catalog.${appRefName}.automations${safeMember(tool.automationKey ?? "")},`);
187
210
  const inputs = tool.inputs ?? [];
188
211
  if (inputs.length > 0) {
189
212
  lines.push(" inputs: {");
@@ -236,19 +259,18 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
236
259
  // platform response. Do not manufacture an empty unsafePlatformId.
237
260
  }
238
261
  else if (tool.target !== undefined) {
239
- // Board issue #42: the target can be a foreign APP or a foreign
240
- // ELEMENT — each stub carries the right `__kind` and is looked up
241
- // against its own map, never conflated.
242
- const entityKind = tool.target.kind === "foreignElement" ? "element" : "app";
243
- const refNames = tool.target.kind === "foreignElement" ? foreignElementRefNames : foreignAppRefNames;
262
+ const entityKind = tool.target.kind === "foreignElement" ? "element" : tool.target.kind === "foreignTask" ? "task" : "app";
263
+ const refNames = tool.target.kind === "foreignElement"
264
+ ? foreignElementRefNames
265
+ : tool.target.kind === "foreignTask"
266
+ ? foreignTaskRefNames
267
+ : foreignAppRefNames;
244
268
  const catalogRefName = refNames?.get(tool.target.name);
245
269
  if (catalogRefName !== undefined) {
246
- // The dependency is already pulled into this workspace (board issue
247
- // #40) — a typed token, not a stub.
248
270
  lines.push(` ${entityKind}: catalog.${catalogRefName},`);
249
271
  }
250
272
  else {
251
- // The foreign app/element's catalog may not exist in this workspace —
273
+ // The foreign app/element/task's catalog may not exist in this workspace —
252
274
  // a literal token compiles and deploys; swap for a catalog token when
253
275
  // available (`edk pull app`/`edk pull element` reports missing
254
276
  // dependencies like this one).
@@ -264,18 +286,25 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
264
286
  lines.push(` limit: ${tool.limit},`);
265
287
  }
266
288
  if (tool.typeKey === "searchTable") {
267
- if (tool.searchTableKey !== undefined) {
289
+ if (tool.searchTableRawId !== undefined) {
290
+ // The search table itself has no portable lookup at all (not even a
291
+ // name) - round-trip the raw platform id instead of dropping a live
292
+ // tool, the same unsafePlatformId() escape used elsewhere in this
293
+ // printer (mirrors print-agent-v2.ts's identical case, #1099).
294
+ lines.push(` table: unsafePlatformId(${quote(tool.searchTableRawId)}), // TODO: this search table has no portable lookup (no name, no local resource) - verify/replace with a real table reference if one becomes available`);
295
+ }
296
+ else if (tool.searchTableKey !== undefined) {
268
297
  lines.push(` table: catalog.${targetRefName ?? appRefName}.searchTables${safeMember(tool.searchTableKey)},`);
269
298
  }
270
299
  else {
271
- const targetNameOrUuid = tool.target?.kind === "foreignApp" || tool.target?.kind === "foreignElement"
300
+ const targetNameOrUuid = tool.target?.kind === "foreignApp" || tool.target?.kind === "foreignElement" || tool.target?.kind === "foreignTask"
272
301
  ? tool.target.name
273
302
  : tool.target?.kind === "tableOwned"
274
303
  ? tool.searchTableOwnerName
275
304
  : tool.target?.kind === "unresolved" ? tool.target.uuid : undefined;
276
305
  const parent = tool.target?.kind === "self"
277
306
  ? appRefName
278
- : tool.target?.kind === "foreignApp" || tool.target?.kind === "foreignElement"
307
+ : tool.target?.kind === "foreignApp" || tool.target?.kind === "foreignElement" || tool.target?.kind === "foreignTask"
279
308
  ? tool.target.refName ?? targetNameOrUuid ?? ""
280
309
  : tool.target?.kind === "tableOwned"
281
310
  ? tool.searchTableOwnerRefName ?? targetNameOrUuid ?? ""
@@ -315,7 +344,7 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
315
344
  lines.push(` handleDescription: ${quote(tool.handleDescription)},`);
316
345
  }
317
346
  if (tool.fields !== undefined && tool.fields.length > 0) {
318
- const owner = fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames);
347
+ const owner = fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames, foreignTaskRefNames);
319
348
  lines.push(" fields: [");
320
349
  for (const f of tool.fields) {
321
350
  // A foreign/out-of-scope aspect's field has no field resource ei can