@elementumai/edk 0.9.7 → 0.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +3 -2
  2. package/dist-sdk/src/catalog/factories.d.ts +14 -3
  3. package/dist-sdk/src/catalog/factories.js +32 -0
  4. package/dist-sdk/src/catalog/from-authoring.js +27 -33
  5. package/dist-sdk/src/catalog/index.d.ts +2 -2
  6. package/dist-sdk/src/catalog/index.js +2 -2
  7. package/dist-sdk/src/catalog/org.js +67 -29
  8. package/dist-sdk/src/catalog/token.js +10 -0
  9. package/dist-sdk/src/catalog/types.d.ts +20 -2
  10. package/dist-sdk/src/catalog/types.js +5 -0
  11. package/dist-sdk/src/core/index.d.ts +1 -1
  12. package/dist-sdk/src/core/index.js +1 -1
  13. package/dist-sdk/src/core/platform-id.d.ts +2 -0
  14. package/dist-sdk/src/core/platform-id.js +4 -0
  15. package/dist-sdk/src/core/system-fields.d.ts +14 -0
  16. package/dist-sdk/src/core/system-fields.js +6 -0
  17. package/dist-sdk/src/core/triggers/on-demand.d.ts +27 -24
  18. package/dist-sdk/src/core/triggers/on-demand.js +33 -12
  19. package/dist-sdk/src/core/types/aspect-category.d.ts +1 -0
  20. package/dist-sdk/src/core/types/aspect-category.js +1 -0
  21. package/dist-sdk/src/engine/build/context.d.ts +20 -8
  22. package/dist-sdk/src/engine/build/source-context.d.ts +14 -17
  23. package/dist-sdk/src/engine/build/source-context.js +1 -1
  24. package/dist-sdk/src/engine/pull/context.d.ts +9 -0
  25. package/dist-sdk/src/engine/pull/org.d.ts +4 -0
  26. package/dist-sdk/src/engine/pull/org.js +17 -2
  27. package/dist-sdk/src/engine/pull/procedure-refs.d.ts +16 -0
  28. package/dist-sdk/src/engine/pull/procedure-refs.js +69 -0
  29. package/dist-sdk/src/engine/tf/expr.js +1 -1
  30. package/dist-sdk/src/engine/workspace/authoring-layout.d.ts +15 -0
  31. package/dist-sdk/src/engine/workspace/authoring-layout.js +33 -1
  32. package/dist-sdk/src/engine/workspace/loader.d.ts +40 -0
  33. package/dist-sdk/src/engine/workspace/loader.js +328 -0
  34. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -0
  35. package/dist-sdk/src/entities/access-policy/from-tf.js +10 -2
  36. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +1 -0
  37. package/dist-sdk/src/entities/access-policy/to-tf.js +7 -2
  38. package/dist-sdk/src/entities/agent/build.d.ts +54 -8
  39. package/dist-sdk/src/entities/agent/build.js +36 -1
  40. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +126 -2
  41. package/dist-sdk/src/entities/agent/from-tf.d.ts +7 -6
  42. package/dist-sdk/src/entities/agent/from-tf.js +176 -5
  43. package/dist-sdk/src/entities/agent/index.d.ts +2 -2
  44. package/dist-sdk/src/entities/agent/index.js +1 -1
  45. package/dist-sdk/src/entities/agent/to-tf.d.ts +4 -4
  46. package/dist-sdk/src/entities/agent/to-tf.js +185 -11
  47. package/dist-sdk/src/entities/agent/tools.d.ts +16 -5
  48. package/dist-sdk/src/entities/agent/tools.js +13 -1
  49. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +7 -0
  50. package/dist-sdk/src/entities/agent-tool/from-tf.js +29 -4
  51. package/dist-sdk/src/entities/agent-tool/to-tf.js +10 -9
  52. package/dist-sdk/src/entities/agent-tool/types.js +1 -0
  53. package/dist-sdk/src/entities/app/build.d.ts +2 -2
  54. package/dist-sdk/src/entities/app/build.js +6 -3
  55. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +5 -0
  56. package/dist-sdk/src/entities/app/display-blocks-to-layout.d.ts +45 -0
  57. package/dist-sdk/src/entities/app/display-blocks-to-layout.js +98 -0
  58. package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.d.ts +55 -0
  59. package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.js +99 -0
  60. package/dist-sdk/src/entities/app/from-tf.js +9 -7
  61. package/dist-sdk/src/entities/app/to-tf.js +15 -7
  62. package/dist-sdk/src/entities/automation/build.d.ts +8 -1
  63. package/dist-sdk/src/entities/automation/build.js +36 -5
  64. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +3 -7
  65. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +2 -0
  66. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +77 -8
  67. package/dist-sdk/src/entities/automation/from-tf.d.ts +10 -1
  68. package/dist-sdk/src/entities/automation/from-tf.js +803 -62
  69. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  70. package/dist-sdk/src/entities/automation/module.js +13 -3
  71. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +12 -4
  72. package/dist-sdk/src/entities/automation/output-key-wire-name.js +17 -6
  73. package/dist-sdk/src/entities/automation/script-code.d.ts +1 -1
  74. package/dist-sdk/src/entities/automation/script-code.js +15 -11
  75. package/dist-sdk/src/entities/automation/task-label.d.ts +2 -0
  76. package/dist-sdk/src/entities/automation/task-label.js +18 -0
  77. package/dist-sdk/src/entities/automation/tasks.d.ts +60 -9
  78. package/dist-sdk/src/entities/automation/tasks.js +16 -4
  79. package/dist-sdk/src/entities/automation/to-tf.d.ts +4 -0
  80. package/dist-sdk/src/entities/automation/to-tf.js +385 -52
  81. package/dist-sdk/src/entities/automation/triggers.d.ts +14 -5
  82. package/dist-sdk/src/entities/automation/triggers.js +1 -1
  83. package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
  84. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
  85. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +1 -1
  86. package/dist-sdk/src/entities/element/build.d.ts +30 -7
  87. package/dist-sdk/src/entities/element/build.js +6 -3
  88. package/dist-sdk/src/entities/element/from-tf.js +7 -3
  89. package/dist-sdk/src/entities/element/index.d.ts +1 -1
  90. package/dist-sdk/src/entities/element/index.js +1 -1
  91. package/dist-sdk/src/entities/element/to-tf.js +49 -8
  92. package/dist-sdk/src/entities/field/from-tf.d.ts +6 -0
  93. package/dist-sdk/src/entities/field/from-tf.js +12 -0
  94. package/dist-sdk/src/entities/field/module.js +1 -0
  95. package/dist-sdk/src/entities/field/to-tf.d.ts +1 -1
  96. package/dist-sdk/src/entities/field/to-tf.js +19 -5
  97. package/dist-sdk/src/entities/org/category-ref.d.ts +5 -0
  98. package/dist-sdk/src/entities/org/category-ref.js +12 -0
  99. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -3
  100. package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +1 -0
  101. package/dist-sdk/src/entities/record-create-form/to-tf.js +13 -5
  102. package/dist-sdk/src/entities/relationship/from-tf.js +15 -4
  103. package/dist-sdk/src/entities/role/from-tf.js +10 -4
  104. package/dist-sdk/src/entities/search-table/build.d.ts +1 -1
  105. package/dist-sdk/src/entities/search-table/from-tf.d.ts +1 -0
  106. package/dist-sdk/src/entities/search-table/from-tf.js +6 -0
  107. package/dist-sdk/src/entities/search-table/printer.js +3 -1
  108. package/dist-sdk/src/entities/search-table/to-tf.js +3 -3
  109. package/dist-sdk/src/entities/search-table/types.js +1 -0
  110. package/dist-sdk/src/entities/service-account/from-tf.js +10 -4
  111. package/dist-sdk/src/entities/service-account/to-tf.d.ts +2 -1
  112. package/dist-sdk/src/entities/service-account/to-tf.js +7 -0
  113. package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -1
  114. package/dist-sdk/src/entities/shared/filters/ast.js +3 -0
  115. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +7 -1
  116. package/dist-sdk/src/entities/shared/filters/tf-codec.js +8 -4
  117. package/dist-sdk/src/entities/shared/handle-description.d.ts +12 -0
  118. package/dist-sdk/src/entities/shared/handle-description.js +20 -0
  119. package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -1
  120. package/dist-sdk/src/entities/shared/types/field-types.js +5 -8
  121. package/dist-sdk/src/entities/skill/build.d.ts +51 -2
  122. package/dist-sdk/src/entities/skill/build.js +65 -8
  123. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +35 -3
  124. package/dist-sdk/src/entities/skill/from-tf.d.ts +11 -0
  125. package/dist-sdk/src/entities/skill/from-tf.js +39 -7
  126. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  127. package/dist-sdk/src/entities/skill/index.js +1 -1
  128. package/dist-sdk/src/entities/skill/input-coverage.d.ts +21 -0
  129. package/dist-sdk/src/entities/skill/input-coverage.js +148 -5
  130. package/dist-sdk/src/entities/skill/to-tf.d.ts +6 -25
  131. package/dist-sdk/src/entities/skill/to-tf.js +22 -38
  132. package/dist-sdk/src/entities/skill/tools.d.ts +2 -1
  133. package/dist-sdk/src/entities/skill/tools.js +3 -1
  134. package/dist-sdk/src/entities/skill-tool/from-tf.js +10 -3
  135. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +5 -5
  136. package/dist-sdk/src/entities/skill-tool/to-tf.js +5 -7
  137. package/dist-sdk/src/entities/table/to-tf.js +3 -4
  138. package/dist-sdk/src/entities/task/to-tf.js +3 -2
  139. package/dist-sdk/src/entities/view/from-tf.js +36 -10
  140. package/dist-sdk/src/entities/view/to-tf.d.ts +2 -0
  141. package/dist-sdk/src/entities/view/to-tf.js +44 -30
  142. package/dist-sdk/src/entities/widget/from-tf.js +2 -2
  143. package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
  144. package/dist-sdk/src/entities/widget/to-tf.js +52 -23
  145. package/dist-sdk/src/graph/index.d.ts +19 -1
  146. package/dist-sdk/src/graph/index.js +20 -0
  147. package/dist-sdk/src/graph/types.d.ts +19 -0
  148. package/package.json +10 -5
@@ -6,6 +6,7 @@ export interface NormalizedSnowflakeSearchTable {
6
6
  readonly name?: string;
7
7
  readonly fieldKey: string;
8
8
  readonly attributeFieldKeys: readonly string[];
9
+ readonly textIndexFieldKeys?: readonly string[];
9
10
  readonly connectorKey: string;
10
11
  readonly duration: "DAYS" | "HOURS" | "MINUTES" | "SECONDS";
11
12
  readonly targetLag: number;
@@ -91,6 +91,9 @@ export function searchTableFromTf(block, ownerTfLabel, scope, ctx) {
91
91
  const rawAttributes = block.attrs["attribute_field_ids"];
92
92
  if (!Array.isArray(rawAttributes))
93
93
  throw new EntityTfError(`${where}: "attribute_field_ids" must be a list`);
94
+ const rawTextIndexFields = block.attrs["text_index_field_ids"];
95
+ if (rawTextIndexFields !== undefined && !Array.isArray(rawTextIndexFields))
96
+ throw new EntityTfError(`${where}: "text_index_field_ids" must be a list`);
94
97
  const duration = requiredString(block.attrs, "duration", where);
95
98
  if (!["DAYS", "HOURS", "MINUTES", "SECONDS"].includes(duration)) {
96
99
  throw new EntityTfError(`${where}: unsupported duration ${JSON.stringify(duration)}`);
@@ -104,6 +107,9 @@ export function searchTableFromTf(block, ownerTfLabel, scope, ctx) {
104
107
  ...(typeof block.attrs["name"] === "string" && { name: block.attrs["name"] }),
105
108
  fieldKey: fieldKey(block.attrs["field_id"], ownerTfLabel, aspectScope, where),
106
109
  attributeFieldKeys: rawAttributes.map((value) => fieldKey(value, ownerTfLabel, aspectScope, where)),
110
+ ...(rawTextIndexFields !== undefined && {
111
+ textIndexFieldKeys: rawTextIndexFields.map((value) => fieldKey(value, ownerTfLabel, aspectScope, where)),
112
+ }),
107
113
  connectorKey: connectorKey(block.attrs["ai_provider_connector_id"], ctx, where),
108
114
  duration: duration,
109
115
  targetLag,
@@ -36,7 +36,9 @@ parentScope, orgImportPath) {
36
36
  lines.push(` creationTimeout: ${quote(table.creationTimeout)},`);
37
37
  }
38
38
  else if (table.kind === "snowflake") {
39
- lines.push(` ${parentScope}: catalog${member(ownerRefName)},`, ` name: ${quote(table.name ?? table.refName)},`, ` attributeFields: [${table.attributeFieldKeys.map((key) => `catalog${member(ownerRefName)}.fields${member(key)}`).join(", ")}],`, ` vectorIndex: { field: catalog${member(ownerRefName)}.fields${member(table.fieldKey)}, service: ${connectorExpr(table.connectorKey)} },`, ` duration: searchTableDuration.${table.duration.toLowerCase()},`, ` targetLag: ${table.targetLag},`);
39
+ lines.push(` ${parentScope}: catalog${member(ownerRefName)},`, ` name: ${quote(table.name ?? table.refName)},`, ` attributeFields: [${table.attributeFieldKeys.map((key) => `catalog${member(ownerRefName)}.fields${member(key)}`).join(", ")}],`, ...(table.textIndexFieldKeys !== undefined
40
+ ? [` textIndexFields: [${table.textIndexFieldKeys.map((key) => `catalog${member(ownerRefName)}.fields${member(key)}`).join(", ")}],`]
41
+ : []), ` vectorIndex: { field: catalog${member(ownerRefName)}.fields${member(table.fieldKey)}, service: ${connectorExpr(table.connectorKey)} },`, ` duration: searchTableDuration.${table.duration.toLowerCase()},`, ` targetLag: ${table.targetLag},`);
40
42
  if (table.warehouse !== undefined)
41
43
  lines.push(` warehouse: ${quote(table.warehouse)},`);
42
44
  if (table.creationTimeout !== undefined)
@@ -82,9 +82,6 @@ export function searchTableToTf(entity, ctx) {
82
82
  throw new EntityTfError(`search table ${entity.refName}: no vector index`);
83
83
  if ((payload.vectorIndexes?.length ?? 0) > 1)
84
84
  throw new EntityTfError(`search table ${entity.refName}: Terraform supports exactly one vector index`);
85
- if ((payload.textIndexFieldIds?.length ?? 0) > 0) {
86
- ctx.diagnostics.push(`search table ${entity.refName}: textIndexFields have no elementum_ai_search_table attribute; dropped`);
87
- }
88
85
  const attrs = {
89
86
  object_id: objectId,
90
87
  field_id: fieldValue(index.fieldId, aspectCtx, `search table ${entity.refName}`),
@@ -93,6 +90,9 @@ export function searchTableToTf(entity, ctx) {
93
90
  duration: payload.duration ?? "DAYS",
94
91
  target_lag: payload.targetLag ?? 1,
95
92
  };
93
+ if (payload.textIndexFieldIds !== undefined) {
94
+ attrs["text_index_field_ids"] = payload.textIndexFieldIds.map((field) => fieldValue(field, aspectCtx, `search table ${entity.refName}`));
95
+ }
96
96
  if (payload.name !== undefined)
97
97
  attrs["name"] = payload.name;
98
98
  if (payload.warehouse !== undefined)
@@ -11,6 +11,7 @@ export const KNOWN_SEARCH_TABLE_ATTRS = {
11
11
  "field_id",
12
12
  "ai_provider_connector_id",
13
13
  "attribute_field_ids",
14
+ "text_index_field_ids",
14
15
  "duration",
15
16
  "target_lag",
16
17
  "warehouse",
@@ -8,10 +8,16 @@ function principal(value, type, where, ctx) {
8
8
  const label = dataRefLabel(value, type);
9
9
  if (label !== undefined) {
10
10
  const name = ctx.dataName(type, label);
11
- if (name !== undefined)
12
- return type === "elementum_user"
13
- ? { __kind: "user", email: name }
14
- : { __kind: "group", refName: tfLabelToTsLabel(label), name };
11
+ if (name !== undefined) {
12
+ if (type === "elementum_user") {
13
+ if (name.trim() === "" || !name.includes("@")) {
14
+ ctx.diagnostics.push(`${where}: data.${type}.${label} has invalid email ${JSON.stringify(name)}; dropped`);
15
+ return undefined;
16
+ }
17
+ return { __kind: "user", email: name.trim() };
18
+ }
19
+ return { __kind: "group", refName: tfLabelToTsLabel(label), name };
20
+ }
15
21
  ctx.diagnostics.push(`${where}: data.${type}.${label} has no lookup value; dropped`);
16
22
  return undefined;
17
23
  }
@@ -19,7 +19,8 @@ export declare function serviceAccountRefToTf(token: {
19
19
  }, opts: {
20
20
  readonly appRefName: string;
21
21
  readonly appTfLabel: string;
22
- readonly appId: TfValue;
22
+ /** Missing for a foreign reference whose owning app was not exported. */
23
+ readonly appId: TfValue | undefined;
23
24
  readonly serviceAccounts?: Readonly<Record<string, AppServiceAccount>>;
24
25
  readonly orgRefs: OrgRefLookup;
25
26
  }, where: string, diagnostics: string[]): TfValue | undefined;
@@ -27,6 +27,13 @@ export function serviceAccountRefToTf(token, opts, where, diagnostics) {
27
27
  if (local.length === 1) {
28
28
  return expr.resourceAttr(SERVICE_ACCOUNT_RESOURCE_TYPE, appScopedResourceLabel(opts.appTfLabel, tsLabelToTfLabel(local[0][0])), ["id"]);
29
29
  }
30
+ // A pulled foreign reference can lack an owning app id when the exporter
31
+ // could not resolve that app. Do not emit an invalid data source block with
32
+ // a missing required app_id; callers treat an undefined lookup as absent.
33
+ if (opts.appId === undefined) {
34
+ diagnostics.push(`${where}: service account ${JSON.stringify(token.name)} has no resolvable owning app id; dropped`);
35
+ return undefined;
36
+ }
30
37
  const label = appScopedResourceLabel(opts.appTfLabel, sanitizeName(token.name));
31
38
  opts.orgRefs.rawLookup(SERVICE_ACCOUNT_RESOURCE_TYPE, label, token.name, { app_id: opts.appId });
32
39
  return expr.dataAttr(SERVICE_ACCOUNT_RESOURCE_TYPE, label, ["id"]);
@@ -181,6 +181,12 @@ export interface CloudLinkRefAst {
181
181
  readonly handle: string;
182
182
  readonly name?: string;
183
183
  }
184
+ /** Reference to a configured procedure nested beneath its owning CloudLink. */
185
+ export interface ProcedureRefAst {
186
+ readonly kind: "procedure";
187
+ readonly cloudLinkKey: string;
188
+ readonly procedureKey: string;
189
+ }
184
190
  /**
185
191
  * Placeholder for an identifier (uuid or clientHandle) the catalog couldn't
186
192
  * resolve — printer emits it as a quoted literal with a `/* TODO *\/` comment.
@@ -238,7 +244,7 @@ export type RefExpr =
238
244
  | {
239
245
  kind: "template";
240
246
  parts: readonly (string | RefExpr)[];
241
- } | FieldRefAst | UserFieldRefAst | AppRefAst | AgentRefAst | AutomationRefAst | DocumentModelRefAst | DocumentModelFieldRefAst | ApprovalChainRefAst | DatamineRefAst | TableRefAst | TableColumnRefAst | ConnectorRefAst | CloudLinkRefAst | PhoneServiceRefAst | UserRefAst | UnresolvedRefAst
247
+ } | FieldRefAst | UserFieldRefAst | AppRefAst | AgentRefAst | AutomationRefAst | DocumentModelRefAst | DocumentModelFieldRefAst | ApprovalChainRefAst | DatamineRefAst | TableRefAst | TableColumnRefAst | SearchTableRefAst | ConnectorRefAst | CloudLinkRefAst | ProcedureRefAst | PhoneServiceRefAst | UserRefAst | UnresolvedRefAst
242
248
  /** Preserved terraform local expression for round-trip (e.g. status option ids by label). */
243
249
  | {
244
250
  kind: "localRef";
@@ -63,7 +63,10 @@ export function isRefExpr(value) {
63
63
  kind === "datamine" ||
64
64
  kind === "table" ||
65
65
  kind === "tableColumn" ||
66
+ kind === "searchTable" ||
66
67
  kind === "connector" ||
68
+ kind === "cloudLink" ||
69
+ kind === "procedure" ||
67
70
  kind === "phoneService" ||
68
71
  kind === "user" ||
69
72
  kind === "unresolved");
@@ -1,5 +1,5 @@
1
1
  import { type TfValue } from "../../../engine/tf/index.js";
2
- import type { DateTimeUnit, Filter, LikeMode } from "./types.js";
2
+ import type { DateTimeUnit, Filter, LikeMode, ValueType } from "./types.js";
3
3
  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
4
  type TfDateTimeUnit = Lowercase<DateTimeUnit>;
5
5
  type TfLikeMode = Lowercase<LikeMode>;
@@ -97,6 +97,12 @@ export interface FilterFromTfCodec<Field = string, ReferenceValue = never> {
97
97
  readonly field: (value: TfValue, fieldScope: "app" | "user") => Field;
98
98
  readonly aspect?: (value: TfValue) => Field;
99
99
  readonly reference: (value: TfValue) => ReferenceValue;
100
+ /**
101
+ * A structured reference envelope can carry a more authoritative output
102
+ * type than the provider's legacy outer `real_type` default. Consumers
103
+ * that understand that envelope may override the fallback here.
104
+ */
105
+ readonly referenceType?: (value: TfValue, fallback: ValueType) => ValueType;
100
106
  readonly literal?: (value: TfValue, valueType: string) => TfValue;
101
107
  }
102
108
  export type WireFilterValue = Readonly<{
@@ -425,14 +425,16 @@ export function filterFromTf(value, codec, fieldScope = "app") {
425
425
  return undefined;
426
426
  if (filter.left_value.field_id !== undefined)
427
427
  return { leftValue: { type: "FIELD", value: codec.field(filter.left_value.field_id, fieldScope) } };
428
- if (filter.left_value.value_reference !== undefined)
428
+ if (filter.left_value.value_reference !== undefined) {
429
+ const fallback = (filter.left_value.real_type?.toUpperCase() ?? "TEXT");
429
430
  return {
430
431
  leftValue: {
431
432
  type: "REFERENCE",
432
- realType: (filter.left_value.real_type?.toUpperCase() ?? "TEXT"),
433
+ realType: codec.referenceType?.(filter.left_value.value_reference, fallback) ?? fallback,
433
434
  value: codec.reference(filter.left_value.value_reference),
434
435
  },
435
436
  };
437
+ }
436
438
  return undefined;
437
439
  })();
438
440
  if (left === undefined)
@@ -487,15 +489,17 @@ function filterValueFromTf(value, codec, fieldScope) {
487
489
  const currentUserType = value.current_user_type?.toUpperCase();
488
490
  return { type: "CURRENT_USER", valueType: currentUserType === "EMAIL" || currentUserType === "DOMAIN" ? currentUserType : "ID" };
489
491
  }
490
- case "reference":
492
+ case "reference": {
491
493
  if (value.value_reference === undefined)
492
494
  throw new EntityTfError("reference filter value requires value_reference");
495
+ const fallback = (value.real_type?.toUpperCase() ?? "TEXT");
493
496
  return {
494
497
  type: "REFERENCE",
495
- realType: (value.real_type?.toUpperCase() ?? "TEXT"),
498
+ realType: codec.referenceType?.(value.value_reference, fallback) ?? fallback,
496
499
  value: codec.reference(value.value_reference),
497
500
  ...(value.multiple === true && { multiple: true }),
498
501
  };
502
+ }
499
503
  case "field":
500
504
  if (value.field_id === undefined)
501
505
  throw new EntityTfError("field filter value requires field_id");
@@ -0,0 +1,12 @@
1
+ import type { TfValue } from "../../engine/tf/index.js";
2
+ /**
3
+ * `handle_description` on an update-record tool (skill or agent) is optional
4
+ * on the wire: the platform accepts omitting it entirely (matching a legacy
5
+ * record's `null`), but always rejects an explicit empty string at apply
6
+ * with an opaque "Unable to validate" error - confirmed live against the
7
+ * platform (edk#801). Authoring should catch that mistake immediately
8
+ * rather than let it surface later during build.
9
+ */
10
+ export declare function assertHandleDescriptionNotEmpty(value: string | undefined, where: string): void;
11
+ /** Sets `handle_description` only when there's a real value - omitting matches how the platform itself treats "no description." */
12
+ export declare function encodeOptionalHandleDescription(attrs: Record<string, TfValue>, value: string | undefined): void;
@@ -0,0 +1,20 @@
1
+ // Copyright (c) ElementumAI, Inc.
2
+ // SPDX-License-Identifier: MPL-2.0
3
+ /**
4
+ * `handle_description` on an update-record tool (skill or agent) is optional
5
+ * on the wire: the platform accepts omitting it entirely (matching a legacy
6
+ * record's `null`), but always rejects an explicit empty string at apply
7
+ * with an opaque "Unable to validate" error - confirmed live against the
8
+ * platform (edk#801). Authoring should catch that mistake immediately
9
+ * rather than let it surface later during build.
10
+ */
11
+ export function assertHandleDescriptionNotEmpty(value, where) {
12
+ if (value === "") {
13
+ throw new Error(`${where}'s handleDescription must not be an empty string - omit it entirely if there is no description.`);
14
+ }
15
+ }
16
+ /** Sets `handle_description` only when there's a real value - omitting matches how the platform itself treats "no description." */
17
+ export function encodeOptionalHandleDescription(attrs, value) {
18
+ if (value)
19
+ attrs["handle_description"] = value;
20
+ }
@@ -1,3 +1,5 @@
1
+ import type { AppOrElementRef } from "../../../catalog/types.js";
2
+ import type { RecordShape } from "../../field/record-shape.js";
1
3
  /**
2
4
  * WorkflowFieldType — mirrors the Java enum in
3
5
  * jarvis/util/.../WorkflowFieldType.java
@@ -31,8 +33,11 @@ export declare const FIELD_TYPE_MAP: {
31
33
  readonly json: "JSON";
32
34
  readonly object: "OBJECT";
33
35
  readonly attachmentId: "ATTACHMENT_ID";
36
+ readonly record: "ASPECT_RECORD";
34
37
  };
35
38
  export type FieldTypeAlias = keyof typeof FIELD_TYPE_MAP;
39
+ /** On-demand `type: "record"` and its WorkflowFieldType / HCL spellings. */
40
+ export declare function isOnDemandRecordType(type: string | undefined): boolean;
36
41
  /**
37
42
  * Subset of {@link FieldTypeAlias} that Mobius's `onDemand` trigger
38
43
  * validator accepts. Mobius rejects `WorkflowFieldType.USER` and
@@ -55,4 +60,4 @@ export type TriggerFieldTypeAlias = Exclude<FieldTypeAlias, "user">;
55
60
  * Used when generating app definitions from Hydra's field metadata.
56
61
  */
57
62
  export declare const ASPECT_FIELD_TYPE_NAME_TO_WORKFLOW_FIELD_TYPE: Record<string, WorkflowFieldType>;
58
- export type FieldTypeToTS<A extends FieldTypeAlias> = A extends "text" ? string : A extends "number" | "decimal" ? number : A extends "boolean" ? boolean : A extends "date" | "datetime" ? string : A extends "user" ? string : A extends "attachmentId" ? string : A extends "json" | "object" ? unknown : unknown;
63
+ export type FieldTypeToTS<A extends FieldTypeAlias> = A extends "text" ? string : A extends "number" | "decimal" ? number : A extends "boolean" ? boolean : A extends "date" | "datetime" ? string : A extends "user" ? string : A extends "attachmentId" ? string : A extends "json" | "object" ? unknown : A extends "record" ? RecordShape<AppOrElementRef> : unknown;
@@ -1,11 +1,3 @@
1
- /**
2
- * WorkflowFieldType — mirrors the Java enum in
3
- * jarvis/util/.../WorkflowFieldType.java
4
- *
5
- * Only the subset relevant to on-demand trigger inputs and task
6
- * configurations is surfaced here. The full enum is listed for
7
- * forward-compatibility; uncommon types are commented.
8
- */
9
1
  /**
10
2
  * Map from user-friendly type names (used in the SDK's onDemand input
11
3
  * schema) to the platform's WorkflowFieldType value.
@@ -30,7 +22,12 @@ export const FIELD_TYPE_MAP = {
30
22
  json: "JSON",
31
23
  object: "OBJECT",
32
24
  attachmentId: "ATTACHMENT_ID",
25
+ record: "ASPECT_RECORD",
33
26
  };
27
+ /** On-demand `type: "record"` and its WorkflowFieldType / HCL spellings. */
28
+ export function isOnDemandRecordType(type) {
29
+ return type === "record" || type === "ASPECT_RECORD";
30
+ }
34
31
  /**
35
32
  * Maps a user-friendly FieldTypeAlias to the TypeScript type it represents.
36
33
  * Used to derive the phantom T in Ref<T> for trigger inputs.
@@ -1,16 +1,65 @@
1
1
  import type { CatalogRef, SkillRef } from "../../catalog/index.js";
2
2
  import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
3
3
  import type { SkillTool } from "./tools.js";
4
- export interface SkillV2Options extends EntityDeployOptions {
4
+ export interface SkillInputSpec {
5
+ /** Optional explicit field name (defaults to the record key when using an object shape). */
6
+ readonly name?: string;
7
+ readonly description?: string;
8
+ readonly required?: boolean;
9
+ }
10
+ export interface SkillLookupSpec {
11
+ readonly input: string;
12
+ readonly tool: string;
13
+ readonly source?: string;
14
+ }
15
+ export type SkillInputsOption = Readonly<Record<string, SkillInputSpec | string>> | readonly (SkillInputSpec & {
16
+ readonly name: string;
17
+ })[];
18
+ export type SkillLookupsOption = readonly SkillLookupSpec[] | Readonly<Record<string, {
19
+ readonly tool: string;
20
+ readonly source?: string;
21
+ } | string>>;
22
+ export type SkillV2Options = EntityDeployOptions & {
5
23
  readonly name: string;
6
24
  readonly app: CatalogRef<"app">;
7
25
  readonly description: string;
8
- readonly instructions: string;
9
26
  /** Skill status. Defaults to `DRAFT`. */
10
27
  readonly status?: "DRAFT" | "ACTIVE" | "INACTIVE";
11
28
  /** Opaque passthrough for the skill's `properties` JSON field. */
12
29
  readonly properties?: Record<string, unknown>;
30
+ /** Typed discovery signals used when routing user requests to this skill. */
31
+ readonly discovery?: SkillDiscoveryOptions;
13
32
  readonly tools?: readonly SkillTool[];
33
+ } & ({
34
+ /**
35
+ * Procedural instructions for the skill. When `inputs` or `lookups` are defined,
36
+ * the `## Input Schema` and `## Lookup Notes` sections are automatically derived.
37
+ */
38
+ readonly instructions: string;
39
+ /** Declarative input schema (form variables) for this skill. */
40
+ readonly inputs?: SkillInputsOption;
41
+ /** Declarative lookup bindings mapping form variables to lookup tools. */
42
+ readonly lookups?: SkillLookupsOption;
43
+ } | {
44
+ readonly instructions?: string;
45
+ /** Declarative input schema (form variables) for this skill. */
46
+ readonly inputs: SkillInputsOption;
47
+ /** Declarative lookup bindings mapping form variables to lookup tools. */
48
+ readonly lookups?: SkillLookupsOption;
49
+ } | {
50
+ readonly instructions?: string;
51
+ /** Declarative input schema (form variables) for this skill. */
52
+ readonly inputs?: SkillInputsOption;
53
+ /** Declarative lookup bindings mapping form variables to lookup tools. */
54
+ readonly lookups: SkillLookupsOption;
55
+ });
56
+ export interface SkillDiscoveryOptions {
57
+ /** Manual routing tie-breaker on the provider/UI scale, from -100 to 100. */
58
+ readonly routingPriority?: number;
59
+ readonly aliases?: readonly string[];
60
+ readonly exampleUtterances?: readonly string[];
61
+ readonly positiveKeywords?: readonly string[];
62
+ readonly negativeKeywords?: readonly string[];
14
63
  }
15
64
  /**
16
65
  * The configured result of `skill` — its catalog reference (`ref()`) and
@@ -11,17 +11,73 @@
11
11
  * `app` reference.
12
12
  */
13
13
  import { slimTokens } from "../../catalog/index.js";
14
+ import { deriveSkillInstructions, } from "./input-coverage.js";
14
15
  /**
15
- * The provider validates `name` client-side against this pattern (confirmed
16
- * live) — it is NOT a free-text display name like an agent's; the platform
17
- * uses it as the skill's identifier.
16
+ * `name` is a free-text display name, like an agent's — confirmed against
17
+ * the platform's actual create/update path, which only rejects a blank
18
+ * value. Skills created directly in the product commonly use human-readable
19
+ * names (e.g. "Fulfill Punchout Catalog") rather than a slug; a stricter
20
+ * pattern here would reject real, already-deployed data during pull/adopt.
18
21
  */
19
- const SKILL_NAME_PATTERN = /^[a-z0-9-]{1,64}$/;
22
+ const SKILL_NAME_LENGTH = 64;
23
+ function normalizeInputs(inputs) {
24
+ if (inputs === undefined)
25
+ return undefined;
26
+ if (Array.isArray(inputs)) {
27
+ return inputs.map((item) => ({
28
+ name: item.name,
29
+ ...(item.required !== undefined && { required: item.required }),
30
+ ...(item.description !== undefined && { description: item.description }),
31
+ }));
32
+ }
33
+ return Object.entries(inputs).map(([key, value]) => {
34
+ if (typeof value === "string") {
35
+ return { name: key, description: value };
36
+ }
37
+ return {
38
+ name: value.name ?? key,
39
+ ...(value.required !== undefined && { required: value.required }),
40
+ ...(value.description !== undefined && { description: value.description }),
41
+ };
42
+ });
43
+ }
44
+ function normalizeLookups(lookups) {
45
+ if (lookups === undefined)
46
+ return undefined;
47
+ if (Array.isArray(lookups)) {
48
+ return lookups.map((item) => ({
49
+ input: item.input,
50
+ tool: item.tool,
51
+ ...(item.source !== undefined && { source: item.source }),
52
+ }));
53
+ }
54
+ return Object.entries(lookups).map(([inputKey, value]) => {
55
+ if (typeof value === "string") {
56
+ return { input: inputKey, tool: value };
57
+ }
58
+ return {
59
+ input: inputKey,
60
+ tool: value.tool,
61
+ ...(value.source !== undefined && { source: value.source }),
62
+ };
63
+ });
64
+ }
20
65
  /** Build a v2 skill entity config, exposing `.ref(refName)` and `.def(refName)`. */
21
66
  export function skill(opts) {
22
- if (!SKILL_NAME_PATTERN.test(opts.name)) {
23
- throw new Error(`skill name "${opts.name}" must be 1-64 characters of lowercase letters, digits, and hyphens ` +
24
- `(a-z, 0-9, -) — the platform uses it as the skill's identifier, not a free-text label.`);
67
+ if (opts.name.length < 1 || opts.name.length > SKILL_NAME_LENGTH) {
68
+ throw new Error(`skill name ${JSON.stringify(opts.name)} must be 1-${SKILL_NAME_LENGTH} characters.`);
69
+ }
70
+ if (opts.discovery?.routingPriority !== undefined &&
71
+ (!Number.isFinite(opts.discovery.routingPriority) ||
72
+ opts.discovery.routingPriority < -100 ||
73
+ opts.discovery.routingPriority > 100)) {
74
+ throw new Error("skill discovery.routingPriority must be a finite number from -100 to 100");
75
+ }
76
+ const normalizedInputs = normalizeInputs(opts.inputs);
77
+ const normalizedLookups = normalizeLookups(opts.lookups);
78
+ const instructions = deriveSkillInstructions(opts.instructions, normalizedInputs, normalizedLookups);
79
+ if (instructions.trim() === "") {
80
+ throw new Error(`skill "${opts.name}" instructions must not be empty (provide instructions or non-empty inputs/lookups).`);
25
81
  }
26
82
  return {
27
83
  ref(refName) {
@@ -37,10 +93,11 @@ export function skill(opts) {
37
93
  skill: {
38
94
  name: opts.name,
39
95
  description: opts.description,
40
- instructions: opts.instructions,
96
+ instructions,
41
97
  status: opts.status ?? "DRAFT",
42
98
  type: "CUSTOM",
43
99
  ...(opts.properties !== undefined ? { properties: opts.properties } : {}),
100
+ ...(opts.discovery !== undefined ? { discovery: opts.discovery } : {}),
44
101
  },
45
102
  tools: opts.tools ?? [],
46
103
  }),
@@ -70,12 +70,44 @@ export function printSkillV2(skill, opts) {
70
70
  lines.push(` name: ${quote(skill.name)},`);
71
71
  lines.push(` app: catalog.${appRefName},`);
72
72
  lines.push(` description: ${quote(skill.description)},`);
73
- lines.push(` instructions: ${quote(skill.instructions)},`);
73
+ if (skill.instructions !== "" ||
74
+ ((skill.inputs === undefined || skill.inputs.length === 0) &&
75
+ (skill.lookups === undefined || skill.lookups.length === 0))) {
76
+ lines.push(` instructions: ${quote(skill.instructions)},`);
77
+ }
78
+ if (skill.inputs !== undefined && skill.inputs.length > 0) {
79
+ lines.push(" inputs: {");
80
+ for (const input of skill.inputs) {
81
+ const parts = [];
82
+ if (input.description !== undefined) {
83
+ parts.push(`description: ${quote(input.description)}`);
84
+ }
85
+ if (input.required !== undefined) {
86
+ parts.push(`required: ${input.required}`);
87
+ }
88
+ lines.push(` ${safeKey(input.name)}: { ${parts.join(", ")} },`);
89
+ }
90
+ lines.push(" },");
91
+ }
92
+ if (skill.lookups !== undefined && skill.lookups.length > 0) {
93
+ lines.push(" lookups: [");
94
+ for (const lookup of skill.lookups) {
95
+ const parts = [`input: ${quote(lookup.input)}`, `tool: ${quote(lookup.tool)}`];
96
+ if (lookup.source !== undefined) {
97
+ parts.push(`source: ${quote(lookup.source)}`);
98
+ }
99
+ lines.push(` { ${parts.join(", ")} },`);
100
+ }
101
+ lines.push(" ],");
102
+ }
74
103
  if (skill.status !== undefined)
75
104
  lines.push(` status: ${quote(skill.status)},`);
76
105
  if (skill.properties !== undefined) {
77
106
  lines.push(` properties: ${JSON.stringify(skill.properties)},`);
78
107
  }
108
+ if (skill.discovery !== undefined) {
109
+ lines.push(` discovery: ${JSON.stringify(skill.discovery)},`);
110
+ }
79
111
  if (skill.tools.length > 0) {
80
112
  lines.push(" tools: [");
81
113
  for (const tool of skill.tools) {
@@ -256,8 +288,8 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
256
288
  if (tool.limit !== undefined)
257
289
  lines.push(` limit: ${tool.limit},`);
258
290
  }
259
- if (tool.typeKey === "updateRecord") {
260
- lines.push(` handleDescription: ${quote(tool.handleDescription ?? "")},`);
291
+ if (tool.typeKey === "updateRecord" && tool.handleDescription !== undefined) {
292
+ lines.push(` handleDescription: ${quote(tool.handleDescription)},`);
261
293
  }
262
294
  if (tool.fields !== undefined && tool.fields.length > 0) {
263
295
  const owner = fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames);
@@ -8,15 +8,26 @@
8
8
  import { type FromTfContext } from "../../engine/pull/context.js";
9
9
  import { type TfBlock } from "../../engine/tf/index.js";
10
10
  import { type NormalizedSkillTool } from "../skill-tool/from-tf.js";
11
+ import { type SkillInputDefinition, type SkillLookupDefinition } from "./input-coverage.js";
12
+ export interface NormalizedSkillDiscovery {
13
+ readonly routingPriority?: number;
14
+ readonly aliases?: readonly string[];
15
+ readonly exampleUtterances?: readonly string[];
16
+ readonly positiveKeywords?: readonly string[];
17
+ readonly negativeKeywords?: readonly string[];
18
+ }
11
19
  export interface NormalizedSkill {
12
20
  /** Authoring key = the bijective image of the exported label. */
13
21
  readonly refName: string;
14
22
  readonly name: string;
15
23
  readonly description: string;
16
24
  readonly instructions: string;
25
+ readonly inputs?: readonly SkillInputDefinition[];
26
+ readonly lookups?: readonly SkillLookupDefinition[];
17
27
  /** Present only when it differs from the default ("DRAFT"). */
18
28
  readonly status?: "ACTIVE" | "INACTIVE";
19
29
  readonly properties?: Record<string, unknown>;
30
+ readonly discovery?: NormalizedSkillDiscovery;
20
31
  readonly tools: readonly NormalizedSkillTool[];
21
32
  }
22
33
  export interface SkillFromTfResult {
@@ -10,7 +10,7 @@ import { optionalString, resourceRefLabel } from "../../engine/pull/context.js";
10
10
  import { scopedLabelToBagKey } from "../../engine/tf/index.js";
11
11
  import { skillToolFromTf } from "../skill-tool/from-tf.js";
12
12
  import { APP_RESOURCE_TYPE } from "../app/module.js";
13
- import { analyzeSkillInputCoverage, skillCoverageGapDiagnostics, skillCoverageReportLines, } from "./input-coverage.js";
13
+ import { analyzeSkillInputCoverage, decomposeSkillInstructions, skillCoverageGapDiagnostics, skillCoverageReportLines, } from "./input-coverage.js";
14
14
  import { SKILL_RESOURCE_TYPE } from "./module.js";
15
15
  /** Attributes `skillFromTf` understands — anything else is dialect growth, reported loudly. */
16
16
  const KNOWN_SKILL_ATTRS = new Set([
@@ -22,18 +22,28 @@ const KNOWN_SKILL_ATTRS = new Set([
22
22
  "status",
23
23
  "type",
24
24
  "properties",
25
- "depends_on",
26
- ]);
27
- /** Dialect attrs with no authoring slot yet — reported by name, skill still pulled. */
28
- const UNAUTHORABLE_SKILL_ATTRS = new Set([
29
25
  "routing_priority",
30
26
  "aliases",
31
27
  "example_utterances",
32
28
  "positive_keywords",
33
29
  "negative_keywords",
30
+ "depends_on",
31
+ ]);
32
+ /** Dialect attrs with no authoring slot yet — reported by name, skill still pulled. */
33
+ const UNAUTHORABLE_SKILL_ATTRS = new Set([
34
34
  "user_ids",
35
35
  "group_ids",
36
36
  ]);
37
+ function optionalStringList(attrs, key, where, ctx) {
38
+ const value = attrs[key];
39
+ if (value === undefined || value === null)
40
+ return undefined;
41
+ if (!Array.isArray(value) || value.some((item) => typeof item !== "string")) {
42
+ ctx.diagnostics.push(`${where}: ${key} must be a list of strings; dropped`);
43
+ return undefined;
44
+ }
45
+ return value;
46
+ }
37
47
  /**
38
48
  * The `elementum_agentic_skill` block + its tool blocks → the normalized
39
49
  * skill. Tool blocks belonging to OTHER skills are skipped with a
@@ -76,6 +86,21 @@ export function skillFromTf(skillBlock, toolBlocks, appLabel, ctx) {
76
86
  }
77
87
  }
78
88
  const status = optionalString(attrs, "status", where, ctx);
89
+ const routingPriority = attrs["routing_priority"];
90
+ if (routingPriority !== undefined && typeof routingPriority !== "number") {
91
+ ctx.diagnostics.push(`${where}: routing_priority must be a number; dropped`);
92
+ }
93
+ const aliases = optionalStringList(attrs, "aliases", where, ctx);
94
+ const exampleUtterances = optionalStringList(attrs, "example_utterances", where, ctx);
95
+ const positiveKeywords = optionalStringList(attrs, "positive_keywords", where, ctx);
96
+ const negativeKeywords = optionalStringList(attrs, "negative_keywords", where, ctx);
97
+ const discovery = {
98
+ ...(typeof routingPriority === "number" && { routingPriority }),
99
+ ...(aliases !== undefined && { aliases }),
100
+ ...(exampleUtterances !== undefined && { exampleUtterances }),
101
+ ...(positiveKeywords !== undefined && { positiveKeywords }),
102
+ ...(negativeKeywords !== undefined && { negativeKeywords }),
103
+ };
79
104
  const owner = { appType: APP_RESOURCE_TYPE, appLabel, ownerTfLabel: appLabel, skillType: SKILL_RESOURCE_TYPE, skillLabel: label };
80
105
  const tools = [];
81
106
  for (const block of toolBlocks) {
@@ -83,23 +108,30 @@ export function skillFromTf(skillBlock, toolBlocks, appLabel, ctx) {
83
108
  if (tool !== undefined)
84
109
  tools.push(tool);
85
110
  }
86
- const instructions = optionalString(attrs, "instructions", where, ctx) ?? "";
111
+ const rawInstructions = optionalString(attrs, "instructions", where, ctx) ?? "";
87
112
  const coverageTools = tools.map((tool) => ({
88
113
  name: tool.name,
89
114
  fields: (tool.fields ?? []).flatMap((field) => field.name ?? field.key ?? []),
90
115
  inputs: (tool.inputs ?? []).map((input) => input.parameterName),
91
116
  }));
92
- const coverage = analyzeSkillInputCoverage(name, instructions, coverageTools);
117
+ const coverage = analyzeSkillInputCoverage(name, rawInstructions, coverageTools);
93
118
  ctx.reports?.push(...skillCoverageReportLines(coverage));
94
119
  ctx.diagnostics.push(...skillCoverageGapDiagnostics(coverage));
120
+ const decomposed = decomposeSkillInstructions(rawInstructions);
121
+ const instructions = decomposed.inputs.length > 0 || decomposed.lookups.length > 0
122
+ ? decomposed.prose
123
+ : rawInstructions;
95
124
  return {
96
125
  skill: {
97
126
  refName: scopedLabelToBagKey(appLabel, label),
98
127
  name,
99
128
  description: optionalString(attrs, "description", where, ctx) ?? "",
100
129
  instructions,
130
+ ...(decomposed.inputs.length > 0 && { inputs: decomposed.inputs }),
131
+ ...(decomposed.lookups.length > 0 && { lookups: decomposed.lookups }),
101
132
  ...((status === "ACTIVE" || status === "INACTIVE") && { status }),
102
133
  ...(properties !== undefined && { properties }),
134
+ ...(Object.keys(discovery).length > 0 && { discovery }),
103
135
  tools,
104
136
  },
105
137
  };