@elementumai/edk 0.9.6 → 0.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/README.md +34 -3
  2. package/dist-sdk/src/catalog/factories.d.ts +26 -6
  3. package/dist-sdk/src/catalog/factories.js +41 -6
  4. package/dist-sdk/src/catalog/from-authoring.js +27 -33
  5. package/dist-sdk/src/catalog/index.d.ts +2 -2
  6. package/dist-sdk/src/catalog/index.js +2 -2
  7. package/dist-sdk/src/catalog/org.js +93 -42
  8. package/dist-sdk/src/catalog/token.js +10 -0
  9. package/dist-sdk/src/catalog/types.d.ts +42 -3
  10. package/dist-sdk/src/catalog/types.js +5 -0
  11. package/dist-sdk/src/core/index.d.ts +2 -2
  12. package/dist-sdk/src/core/index.js +1 -1
  13. package/dist-sdk/src/core/platform-id.d.ts +2 -0
  14. package/dist-sdk/src/core/platform-id.js +4 -0
  15. package/dist-sdk/src/core/system-fields.d.ts +18 -0
  16. package/dist-sdk/src/core/system-fields.js +21 -0
  17. package/dist-sdk/src/core/triggers/on-demand.d.ts +27 -24
  18. package/dist-sdk/src/core/triggers/on-demand.js +33 -12
  19. package/dist-sdk/src/core/types/app.d.ts +14 -9
  20. package/dist-sdk/src/core/types/aspect-category.d.ts +1 -0
  21. package/dist-sdk/src/core/types/aspect-category.js +1 -0
  22. package/dist-sdk/src/core/types/platform.d.ts +1 -1
  23. package/dist-sdk/src/engine/build/context.d.ts +24 -8
  24. package/dist-sdk/src/engine/build/source-context.d.ts +14 -17
  25. package/dist-sdk/src/engine/build/source-context.js +1 -1
  26. package/dist-sdk/src/engine/pull/context.d.ts +18 -0
  27. package/dist-sdk/src/engine/pull/org.d.ts +4 -0
  28. package/dist-sdk/src/engine/pull/org.js +17 -2
  29. package/dist-sdk/src/engine/pull/procedure-refs.d.ts +16 -0
  30. package/dist-sdk/src/engine/pull/procedure-refs.js +69 -0
  31. package/dist-sdk/src/engine/pull/ref-only.d.ts +14 -0
  32. package/dist-sdk/src/engine/pull/ref-only.js +35 -2
  33. package/dist-sdk/src/engine/tf/expr.js +1 -1
  34. package/dist-sdk/src/engine/workspace/authoring-layout.d.ts +15 -0
  35. package/dist-sdk/src/engine/workspace/authoring-layout.js +33 -1
  36. package/dist-sdk/src/engine/workspace/loader.d.ts +40 -0
  37. package/dist-sdk/src/engine/workspace/loader.js +328 -0
  38. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -0
  39. package/dist-sdk/src/entities/access-policy/from-tf.js +24 -4
  40. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +7 -0
  41. package/dist-sdk/src/entities/access-policy/to-tf.js +11 -3
  42. package/dist-sdk/src/entities/agent/build.d.ts +54 -8
  43. package/dist-sdk/src/entities/agent/build.js +36 -1
  44. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +144 -3
  45. package/dist-sdk/src/entities/agent/from-tf.d.ts +7 -6
  46. package/dist-sdk/src/entities/agent/from-tf.js +176 -5
  47. package/dist-sdk/src/entities/agent/index.d.ts +2 -2
  48. package/dist-sdk/src/entities/agent/index.js +1 -1
  49. package/dist-sdk/src/entities/agent/module.js +1 -0
  50. package/dist-sdk/src/entities/agent/to-tf.d.ts +5 -4
  51. package/dist-sdk/src/entities/agent/to-tf.js +186 -11
  52. package/dist-sdk/src/entities/agent/tools.d.ts +16 -5
  53. package/dist-sdk/src/entities/agent/tools.js +13 -1
  54. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +16 -0
  55. package/dist-sdk/src/entities/agent-tool/from-tf.js +39 -6
  56. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -0
  57. package/dist-sdk/src/entities/agent-tool/to-tf.js +12 -12
  58. package/dist-sdk/src/entities/agent-tool/types.js +1 -0
  59. package/dist-sdk/src/entities/app/build.d.ts +44 -24
  60. package/dist-sdk/src/entities/app/build.js +18 -8
  61. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +15 -0
  62. package/dist-sdk/src/entities/app/display-blocks-to-layout.d.ts +45 -0
  63. package/dist-sdk/src/entities/app/display-blocks-to-layout.js +98 -0
  64. package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.d.ts +55 -0
  65. package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.js +99 -0
  66. package/dist-sdk/src/entities/app/from-tf.js +79 -14
  67. package/dist-sdk/src/entities/app/index.d.ts +3 -2
  68. package/dist-sdk/src/entities/app/index.js +2 -1
  69. package/dist-sdk/src/entities/app/to-tf.js +30 -6
  70. package/dist-sdk/src/entities/automation/build.d.ts +37 -18
  71. package/dist-sdk/src/entities/automation/build.js +121 -12
  72. package/dist-sdk/src/entities/automation/catalog-render.js +5 -2
  73. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +8 -10
  74. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +2 -0
  75. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +103 -20
  76. package/dist-sdk/src/entities/automation/from-tf.d.ts +10 -1
  77. package/dist-sdk/src/entities/automation/from-tf.js +1165 -91
  78. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  79. package/dist-sdk/src/entities/automation/module.js +15 -5
  80. package/dist-sdk/src/entities/automation/operators.d.ts +2 -2
  81. package/dist-sdk/src/entities/automation/operators.js +1 -0
  82. package/dist-sdk/src/entities/automation/output-field-types.d.ts +17 -0
  83. package/dist-sdk/src/entities/automation/output-field-types.js +45 -0
  84. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +20 -4
  85. package/dist-sdk/src/entities/automation/output-key-wire-name.js +33 -6
  86. package/dist-sdk/src/entities/automation/script-code.d.ts +1 -1
  87. package/dist-sdk/src/entities/automation/script-code.js +168 -36
  88. package/dist-sdk/src/entities/automation/task-label.d.ts +2 -0
  89. package/dist-sdk/src/entities/automation/task-label.js +18 -0
  90. package/dist-sdk/src/entities/automation/tasks.d.ts +159 -45
  91. package/dist-sdk/src/entities/automation/tasks.js +60 -47
  92. package/dist-sdk/src/entities/automation/to-tf.d.ts +7 -1
  93. package/dist-sdk/src/entities/automation/to-tf.js +816 -87
  94. package/dist-sdk/src/entities/automation/triggers.d.ts +14 -5
  95. package/dist-sdk/src/entities/automation/triggers.js +1 -1
  96. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +78 -0
  97. package/dist-sdk/src/entities/automation/value-ref-tf.js +193 -0
  98. package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
  99. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
  100. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +1 -1
  101. package/dist-sdk/src/entities/element/build.d.ts +30 -7
  102. package/dist-sdk/src/entities/element/build.js +7 -3
  103. package/dist-sdk/src/entities/element/from-tf.js +7 -3
  104. package/dist-sdk/src/entities/element/index.d.ts +3 -2
  105. package/dist-sdk/src/entities/element/index.js +3 -2
  106. package/dist-sdk/src/entities/element/to-tf.js +49 -8
  107. package/dist-sdk/src/entities/field/build.d.ts +94 -3
  108. package/dist-sdk/src/entities/field/build.js +82 -3
  109. package/dist-sdk/src/entities/field/from-tf.d.ts +6 -0
  110. package/dist-sdk/src/entities/field/from-tf.js +104 -1
  111. package/dist-sdk/src/entities/field/locals.js +6 -7
  112. package/dist-sdk/src/entities/field/module.js +1 -0
  113. package/dist-sdk/src/entities/field/options.d.ts +2 -0
  114. package/dist-sdk/src/entities/field/options.js +12 -2
  115. package/dist-sdk/src/entities/field/record-shape.d.ts +12 -15
  116. package/dist-sdk/src/entities/field/to-tf.d.ts +13 -3
  117. package/dist-sdk/src/entities/field/to-tf.js +191 -56
  118. package/dist-sdk/src/entities/field/types.js +2 -0
  119. package/dist-sdk/src/entities/org/category-ref.d.ts +5 -0
  120. package/dist-sdk/src/entities/org/category-ref.js +12 -0
  121. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -3
  122. package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +1 -0
  123. package/dist-sdk/src/entities/record-create-form/to-tf.js +18 -13
  124. package/dist-sdk/src/entities/relationship/from-tf.js +100 -7
  125. package/dist-sdk/src/entities/role/from-tf.js +10 -4
  126. package/dist-sdk/src/entities/search-table/build.d.ts +1 -1
  127. package/dist-sdk/src/entities/search-table/from-tf.d.ts +1 -0
  128. package/dist-sdk/src/entities/search-table/from-tf.js +6 -0
  129. package/dist-sdk/src/entities/search-table/printer.js +3 -1
  130. package/dist-sdk/src/entities/search-table/to-tf.js +3 -3
  131. package/dist-sdk/src/entities/search-table/types.js +1 -0
  132. package/dist-sdk/src/entities/service-account/from-tf.js +10 -4
  133. package/dist-sdk/src/entities/service-account/to-tf.d.ts +2 -1
  134. package/dist-sdk/src/entities/service-account/to-tf.js +7 -0
  135. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +9 -0
  136. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +39 -0
  137. package/dist-sdk/src/entities/shared/filters/ast.d.ts +24 -1
  138. package/dist-sdk/src/entities/shared/filters/ast.js +4 -0
  139. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +13 -2
  140. package/dist-sdk/src/entities/shared/filters/tf-codec.js +14 -8
  141. package/dist-sdk/src/entities/shared/handle-description.d.ts +12 -0
  142. package/dist-sdk/src/entities/shared/handle-description.js +20 -0
  143. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +5 -3
  144. package/dist-sdk/src/entities/shared/tool-field-ref.js +11 -16
  145. package/dist-sdk/src/entities/shared/types/common.d.ts +7 -5
  146. package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -1
  147. package/dist-sdk/src/entities/shared/types/field-types.js +5 -8
  148. package/dist-sdk/src/entities/shared/types/platform.d.ts +15 -2
  149. package/dist-sdk/src/entities/skill/build.d.ts +51 -2
  150. package/dist-sdk/src/entities/skill/build.js +65 -8
  151. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
  152. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +79 -18
  153. package/dist-sdk/src/entities/skill/from-tf.d.ts +11 -0
  154. package/dist-sdk/src/entities/skill/from-tf.js +47 -5
  155. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  156. package/dist-sdk/src/entities/skill/index.js +1 -1
  157. package/dist-sdk/src/entities/skill/input-coverage.d.ts +89 -0
  158. package/dist-sdk/src/entities/skill/input-coverage.js +327 -0
  159. package/dist-sdk/src/entities/skill/module.js +2 -0
  160. package/dist-sdk/src/entities/skill/to-tf.d.ts +9 -25
  161. package/dist-sdk/src/entities/skill/to-tf.js +29 -40
  162. package/dist-sdk/src/entities/skill/tools.d.ts +12 -2
  163. package/dist-sdk/src/entities/skill/tools.js +3 -6
  164. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +19 -0
  165. package/dist-sdk/src/entities/skill-tool/from-tf.js +50 -14
  166. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +9 -7
  167. package/dist-sdk/src/entities/skill-tool/to-tf.js +29 -23
  168. package/dist-sdk/src/entities/table/to-tf.js +21 -5
  169. package/dist-sdk/src/entities/task/to-tf.js +3 -2
  170. package/dist-sdk/src/entities/view/from-tf.js +36 -10
  171. package/dist-sdk/src/entities/view/to-tf.d.ts +2 -0
  172. package/dist-sdk/src/entities/view/to-tf.js +49 -30
  173. package/dist-sdk/src/entities/visual-flow/from-tf.js +6 -2
  174. package/dist-sdk/src/entities/widget/from-tf.js +2 -2
  175. package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
  176. package/dist-sdk/src/entities/widget/to-tf.js +52 -23
  177. package/dist-sdk/src/graph/index.d.ts +19 -1
  178. package/dist-sdk/src/graph/index.js +20 -0
  179. package/dist-sdk/src/graph/types.d.ts +22 -0
  180. package/package.json +11 -5
@@ -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
  }),
@@ -10,7 +10,7 @@
10
10
  * AST-based `printSkillV2` in `print-skill.ts` — same precedent as
11
11
  * `entities/agent/deserializer/print-agent.ts` vs. `print-agent-v2.ts`.
12
12
  *
13
- * Platform ids never reach printed source.
13
+ * Unresolved field and automation platform ids print as `unsafePlatformId(...)`.
14
14
  */
15
15
  import type { NormalizedSkill } from "../from-tf.js";
16
16
  export interface PrintSkillV2Options {
@@ -10,7 +10,7 @@
10
10
  * AST-based `printSkillV2` in `print-skill.ts` — same precedent as
11
11
  * `entities/agent/deserializer/print-agent.ts` vs. `print-agent-v2.ts`.
12
12
  *
13
- * Platform ids never reach printed source.
13
+ * Unresolved field and automation platform ids print as `unsafePlatformId(...)`.
14
14
  */
15
15
  import { quote } from "../../../../pull/util.js";
16
16
  import { sdkPackageSpecifier } from "../../../internal/sdk-package.js";
@@ -50,7 +50,8 @@ export function printSkillV2(skill, opts) {
50
50
  : []),
51
51
  ]),
52
52
  ].sort();
53
- const usesUnsafePlatformId = skill.tools.some((tool) => tool.fields?.some((field) => field.rawFieldId !== undefined && !opts.foreignFieldRefsById?.has(field.rawFieldId)) === true);
53
+ const usesUnsafePlatformId = skill.tools.some((tool) => tool.automationRawId !== undefined ||
54
+ tool.fields?.some((field) => field.rawFieldId !== undefined && !opts.foreignFieldRefsById?.has(field.rawFieldId)) === true);
54
55
  const lines = [];
55
56
  lines.push("/**");
56
57
  lines.push(` * ${skill.name}`);
@@ -69,12 +70,44 @@ export function printSkillV2(skill, opts) {
69
70
  lines.push(` name: ${quote(skill.name)},`);
70
71
  lines.push(` app: catalog.${appRefName},`);
71
72
  lines.push(` description: ${quote(skill.description)},`);
72
- 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
+ }
73
103
  if (skill.status !== undefined)
74
104
  lines.push(` status: ${quote(skill.status)},`);
75
105
  if (skill.properties !== undefined) {
76
106
  lines.push(` properties: ${JSON.stringify(skill.properties)},`);
77
107
  }
108
+ if (skill.discovery !== undefined) {
109
+ lines.push(` discovery: ${JSON.stringify(skill.discovery)},`);
110
+ }
78
111
  if (skill.tools.length > 0) {
79
112
  lines.push(" tools: [");
80
113
  for (const tool of skill.tools) {
@@ -95,12 +128,23 @@ function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNa
95
128
  // exists to satisfy NormalizedSkillTool.target's now-optional type.
96
129
  if (tool.target === undefined || tool.target.kind === "self")
97
130
  return { kind: "catalog", expr: `catalog.${appRefName}` };
131
+ if (tool.target.kind === "unresolved") {
132
+ return { kind: "raw", entityType: "app", name: tool.target.uuid, refName: tool.target.uuid };
133
+ }
98
134
  const entityKind = tool.target.kind === "foreignElement" ? "element" : "app";
99
135
  const refNames = tool.target.kind === "foreignElement" ? foreignElementRefNames : foreignAppRefNames;
100
- const foreignRefName = refNames?.get(tool.target.name);
136
+ const foreignRefName = tool.target.refName ?? refNames?.get(tool.target.name);
101
137
  return foreignRefName !== undefined
102
- ? { kind: "catalog", expr: `catalog.${foreignRefName}` }
103
- : { kind: "raw", entityType: entityKind, name: tool.target.name };
138
+ ? refNames?.get(tool.target.name) !== undefined
139
+ ? { kind: "catalog", expr: `catalog.${foreignRefName}` }
140
+ : {
141
+ kind: "raw",
142
+ entityType: entityKind,
143
+ name: tool.target.name,
144
+ refName: foreignRefName,
145
+ ...(tool.target.namespace !== undefined && { namespace: tool.target.namespace }),
146
+ }
147
+ : { kind: "raw", entityType: entityKind, name: tool.target.name, refName: tool.target.name };
104
148
  }
105
149
  function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElementRefNames, foreignFieldRefsById, foreignSearchTableRefsByName) {
106
150
  const factory = TOOL_FACTORY_BY_TYPE_KEY[tool.typeKey] ?? "skillSearchRecords";
@@ -108,9 +152,9 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
108
152
  const targetRefName = tool.target?.kind === "self"
109
153
  ? appRefName
110
154
  : tool.target?.kind === "foreignElement"
111
- ? foreignElementRefNames?.get(tool.target.name)
155
+ ? tool.target.refName ?? foreignElementRefNames?.get(tool.target.name)
112
156
  : tool.target?.kind === "foreignApp"
113
- ? foreignAppRefNames?.get(tool.target.name)
157
+ ? tool.target.refName ?? foreignAppRefNames?.get(tool.target.name)
114
158
  : undefined;
115
159
  lines.push(` name: ${quote(tool.name)},`);
116
160
  lines.push(` description: ${quote(tool.description)},`);
@@ -127,7 +171,9 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
127
171
  return lines;
128
172
  }
129
173
  if (tool.typeKey === "automation") {
130
- lines.push(` automation: catalog.${appRefName}.automations${safeMember(tool.automationKey ?? "")},`);
174
+ lines.push(tool.automationRawId !== undefined
175
+ ? ` automation: unsafePlatformId(${quote(tool.automationRawId)}),`
176
+ : ` automation: catalog.${appRefName}.automations${safeMember(tool.automationKey ?? "")},`);
131
177
  const inputs = tool.inputs ?? [];
132
178
  const missingRequired = tool.missingRequiredInputs ?? [];
133
179
  if (inputs.length > 0 || missingRequired.length > 0) {
@@ -179,17 +225,24 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
179
225
  // element.)
180
226
  lines.push(` ${tool.typeKey === "searchTable" ? "element" : "app"}: catalog.${appRefName},`);
181
227
  }
228
+ else if (tool.target?.kind === "unresolved") {
229
+ // Export couldn't resolve target_id to any portable app/element
230
+ // reference (board issue #648) — keep the raw platform id visible and
231
+ // cast past the type system instead of silently dropping the tool.
232
+ const entityKind = tool.typeKey === "searchTable" ? "element" : "app";
233
+ lines.push(` ${entityKind}: ${quote(tool.target.uuid)} as any /* TODO: unresolved ${entityKind} - export couldn't resolve target_id to a portable reference; replace with a real ref before deploying */,`);
234
+ }
182
235
  else if (tool.target !== undefined) {
183
236
  // Board issue #42: the target can be a foreign APP or a foreign
184
237
  // ELEMENT — each stub carries the right `__kind` and is looked up
185
238
  // against its own map, never conflated.
186
239
  const entityKind = tool.target.kind === "foreignElement" ? "element" : "app";
187
240
  const refNames = tool.target.kind === "foreignElement" ? foreignElementRefNames : foreignAppRefNames;
188
- const foreignRefName = refNames?.get(tool.target.name);
189
- if (foreignRefName !== undefined) {
241
+ const catalogRefName = refNames?.get(tool.target.name);
242
+ if (catalogRefName !== undefined) {
190
243
  // The dependency is already pulled into this workspace (board issue
191
244
  // #40) — a typed token, not a stub.
192
- lines.push(` ${entityKind}: catalog.${foreignRefName},`);
245
+ lines.push(` ${entityKind}: catalog.${catalogRefName},`);
193
246
  }
194
247
  else {
195
248
  // The foreign app/element's catalog may not exist in this workspace —
@@ -199,7 +252,7 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
199
252
  const todo = crossOrg
200
253
  ? ` // TODO: cross-org clone — "${tool.target.name}" was resolved in the SOURCE org; verify it exists (with this name) in the destination org`
201
254
  : "";
202
- lines.push(` ${entityKind}: { __kind: ${quote(entityKind)}, refName: ${quote(tool.target.name)}, name: ${quote(tool.target.name)} },${todo}`);
255
+ 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}`);
203
256
  }
204
257
  }
205
258
  if (tool.typeKey === "searchAspect") {
@@ -212,10 +265,18 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
212
265
  lines.push(` table: catalog.${targetRefName ?? appRefName}.searchTables${safeMember(tool.searchTableKey)},`);
213
266
  }
214
267
  else {
215
- const parent = tool.target?.kind === "self" ? appRefName : tool.target?.name ?? "";
268
+ const targetNameOrUuid = tool.target?.kind === "foreignApp" || tool.target?.kind === "foreignElement"
269
+ ? tool.target.name
270
+ : tool.target?.kind === "unresolved" ? tool.target.uuid : undefined;
271
+ const parent = tool.target?.kind === "self"
272
+ ? appRefName
273
+ : tool.target?.kind === "foreignApp" || tool.target?.kind === "foreignElement"
274
+ ? tool.target.refName ?? targetNameOrUuid ?? ""
275
+ : targetNameOrUuid ?? "";
276
+ const lookupParent = tool.target?.kind === "self" ? appRefName : targetNameOrUuid ?? "";
216
277
  const typedTable = tool.searchTableName === undefined
217
278
  ? undefined
218
- : foreignSearchTableRefsByName?.get(searchTableLookupKey(parent, tool.searchTableName));
279
+ : foreignSearchTableRefsByName?.get(searchTableLookupKey(lookupParent, tool.searchTableName));
219
280
  if (typedTable !== undefined) {
220
281
  lines.push(` table: catalog.${typedTable.ownerRefName}.searchTables${safeMember(typedTable.tableKey)},`);
221
282
  }
@@ -227,8 +288,8 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
227
288
  if (tool.limit !== undefined)
228
289
  lines.push(` limit: ${tool.limit},`);
229
290
  }
230
- if (tool.typeKey === "updateRecord") {
231
- lines.push(` handleDescription: ${quote(tool.handleDescription ?? "")},`);
291
+ if (tool.typeKey === "updateRecord" && tool.handleDescription !== undefined) {
292
+ lines.push(` handleDescription: ${quote(tool.handleDescription)},`);
232
293
  }
233
294
  if (tool.fields !== undefined && tool.fields.length > 0) {
234
295
  const owner = fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames);
@@ -251,7 +312,7 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
251
312
  ? [`field: ${owner.expr}.fields.${f.key}`]
252
313
  : [
253
314
  `field: { __kind: "field", refName: ${quote(f.key)}, name: ${quote(f.name ?? f.key)}, fieldType: "TEXT", ` +
254
- `parent: ${quote(owner.name)}, parentKind: ${quote(owner.entityType)}, parentName: ${quote(owner.name)} }`,
315
+ `parent: ${quote(owner.refName)}, parentKind: ${quote(owner.entityType)}, parentName: ${quote(owner.name)}${owner.namespace !== undefined ? `, parentNamespace: ${quote(owner.namespace)}` : ""} }`,
255
316
  ];
256
317
  parts.push(`name: ${quote(f.name ?? "")}`);
257
318
  parts.push(`description: ${quote(f.description ?? "")}`);
@@ -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,6 +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, decomposeSkillInstructions, skillCoverageGapDiagnostics, skillCoverageReportLines, } from "./input-coverage.js";
13
14
  import { SKILL_RESOURCE_TYPE } from "./module.js";
14
15
  /** Attributes `skillFromTf` understands — anything else is dialect growth, reported loudly. */
15
16
  const KNOWN_SKILL_ATTRS = new Set([
@@ -21,18 +22,28 @@ const KNOWN_SKILL_ATTRS = new Set([
21
22
  "status",
22
23
  "type",
23
24
  "properties",
24
- "depends_on",
25
- ]);
26
- /** Dialect attrs with no authoring slot yet — reported by name, skill still pulled. */
27
- const UNAUTHORABLE_SKILL_ATTRS = new Set([
28
25
  "routing_priority",
29
26
  "aliases",
30
27
  "example_utterances",
31
28
  "positive_keywords",
32
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([
33
34
  "user_ids",
34
35
  "group_ids",
35
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
+ }
36
47
  /**
37
48
  * The `elementum_agentic_skill` block + its tool blocks → the normalized
38
49
  * skill. Tool blocks belonging to OTHER skills are skipped with a
@@ -75,6 +86,21 @@ export function skillFromTf(skillBlock, toolBlocks, appLabel, ctx) {
75
86
  }
76
87
  }
77
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
+ };
78
104
  const owner = { appType: APP_RESOURCE_TYPE, appLabel, ownerTfLabel: appLabel, skillType: SKILL_RESOURCE_TYPE, skillLabel: label };
79
105
  const tools = [];
80
106
  for (const block of toolBlocks) {
@@ -82,14 +108,30 @@ export function skillFromTf(skillBlock, toolBlocks, appLabel, ctx) {
82
108
  if (tool !== undefined)
83
109
  tools.push(tool);
84
110
  }
111
+ const rawInstructions = optionalString(attrs, "instructions", where, ctx) ?? "";
112
+ const coverageTools = tools.map((tool) => ({
113
+ name: tool.name,
114
+ fields: (tool.fields ?? []).flatMap((field) => field.name ?? field.key ?? []),
115
+ inputs: (tool.inputs ?? []).map((input) => input.parameterName),
116
+ }));
117
+ const coverage = analyzeSkillInputCoverage(name, rawInstructions, coverageTools);
118
+ ctx.reports?.push(...skillCoverageReportLines(coverage));
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;
85
124
  return {
86
125
  skill: {
87
126
  refName: scopedLabelToBagKey(appLabel, label),
88
127
  name,
89
128
  description: optionalString(attrs, "description", where, ctx) ?? "",
90
- instructions: optionalString(attrs, "instructions", where, ctx) ?? "",
129
+ instructions,
130
+ ...(decomposed.inputs.length > 0 && { inputs: decomposed.inputs }),
131
+ ...(decomposed.lookups.length > 0 && { lookups: decomposed.lookups }),
91
132
  ...((status === "ACTIVE" || status === "INACTIVE") && { status }),
92
133
  ...(properties !== undefined && { properties }),
134
+ ...(Object.keys(discovery).length > 0 && { discovery }),
93
135
  tools,
94
136
  },
95
137
  };
@@ -3,6 +3,6 @@
3
3
  * which the deploy wire client injects) with `CatalogRef` tokens at every
4
4
  * reference position. Standalone from v1.
5
5
  */
6
- export { skill, type SkillConfigured, type SkillV2Options } from "./build.js";
6
+ export { skill, type SkillConfigured, type SkillDiscoveryOptions, type SkillInputSpec, type SkillInputsOption, type SkillLookupSpec, type SkillLookupsOption, type SkillV2Options, } from "./build.js";
7
7
  export { serviceAccountRef, type AgentToolRunAs, type ServiceAccountRef, } from "../agent/run-as.js";
8
8
  export { skillAutomation, skillCreateRecord, skillRunAgent, skillSearchRecords, skillSearchTable, skillUpdateRecord, type SkillRecordField, type SkillRecordFieldInput, type SkillRecordRawIdField, type SkillSearchField, type SkillSearchFieldInput, type SkillSearchRawIdField, type SkillToolStatus, type SkillTool, } from "./tools.js";
@@ -3,6 +3,6 @@
3
3
  * which the deploy wire client injects) with `CatalogRef` tokens at every
4
4
  * reference position. Standalone from v1.
5
5
  */
6
- export { skill } from "./build.js";
6
+ export { skill, } from "./build.js";
7
7
  export { serviceAccountRef, } from "../agent/run-as.js";
8
8
  export { skillAutomation, skillCreateRecord, skillRunAgent, skillSearchRecords, skillSearchTable, skillUpdateRecord, } from "./tools.js";
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Skill input-coverage analysis.
3
+ *
4
+ * The platform's current skill contract keeps the form schema and lookup
5
+ * bindings in the instructions Markdown while tool fields/inputs are
6
+ * structured resources. This module compares those two real sources instead
7
+ * of inventing a second persisted schema. The headings and list shape match
8
+ * the skill generator contract:
9
+ *
10
+ * ## Input Schema
11
+ * - field_name (required): description
12
+ *
13
+ * ## Lookup Notes
14
+ * - field_name: resolve_field_name (source_table)
15
+ */
16
+ export interface SkillInputDefinition {
17
+ readonly name: string;
18
+ readonly description?: string;
19
+ readonly required?: boolean;
20
+ }
21
+ export interface SkillLookupDefinition {
22
+ readonly input: string;
23
+ readonly tool: string;
24
+ readonly source?: string;
25
+ }
26
+ export interface DecomposedSkillInstructions {
27
+ readonly prose: string;
28
+ readonly inputs: readonly SkillInputDefinition[];
29
+ readonly lookups: readonly SkillLookupDefinition[];
30
+ }
31
+ export interface SkillCoverageTool {
32
+ readonly name: string;
33
+ readonly fields: readonly string[];
34
+ readonly inputs: readonly string[];
35
+ }
36
+ export type SkillCoverageTarget = {
37
+ readonly kind: "lookup";
38
+ readonly tool: string;
39
+ } | {
40
+ readonly kind: "field";
41
+ readonly tool: string;
42
+ readonly name: string;
43
+ } | {
44
+ readonly kind: "input";
45
+ readonly tool: string;
46
+ readonly name: string;
47
+ };
48
+ export interface SkillCoverageBinding {
49
+ readonly input: string;
50
+ readonly targets: readonly SkillCoverageTarget[];
51
+ }
52
+ export type SkillCoverageGap = {
53
+ readonly kind: "input-schema-missing";
54
+ } | {
55
+ readonly kind: "missing-field";
56
+ readonly input: string;
57
+ } | {
58
+ readonly kind: "missing-lookup-tool";
59
+ readonly input: string;
60
+ readonly tool: string;
61
+ } | {
62
+ readonly kind: "unbound-lookup";
63
+ readonly input: string;
64
+ readonly tool: string;
65
+ } | {
66
+ readonly kind: "leftover-tool";
67
+ readonly tool: string;
68
+ };
69
+ export interface SkillInputCoverageReport {
70
+ readonly skill: string;
71
+ readonly inputs: readonly string[];
72
+ readonly tools: readonly string[];
73
+ readonly bindings: readonly SkillCoverageBinding[];
74
+ readonly gaps: readonly SkillCoverageGap[];
75
+ }
76
+ export declare function parseSkillInputDefinition(line: string): SkillInputDefinition | undefined;
77
+ export declare function parseSkillLookupDefinition(line: string): SkillLookupDefinition | undefined;
78
+ export declare function formatSkillInputSchema(inputs: readonly SkillInputDefinition[]): string;
79
+ export declare function formatSkillLookupNotes(lookups: readonly SkillLookupDefinition[]): string;
80
+ export declare function deriveSkillInstructions(baseProse: string | undefined, inputs?: readonly SkillInputDefinition[], lookups?: readonly SkillLookupDefinition[]): string;
81
+ export declare function decomposeSkillInstructions(markdown: string): DecomposedSkillInstructions;
82
+ /** Compare instruction-declared form variables with the deployed tool surface. */
83
+ export declare function analyzeSkillInputCoverage(skill: string, instructions: string, coverageTools: readonly SkillCoverageTool[]): SkillInputCoverageReport;
84
+ /** Informational coverage lines emitted on stderr and in JSON `reports`. */
85
+ export declare function skillCoverageReportLines(report: SkillInputCoverageReport): string[];
86
+ /** Only actionable gaps; these remain warnings and JSON `diagnostics`. */
87
+ export declare function skillCoverageGapDiagnostics(report: SkillInputCoverageReport): string[];
88
+ /** Convert a skill def() payload's closed tool envelopes to analyzer input. */
89
+ export declare function coverageToolsFromWire(entries: readonly Record<string, unknown>[]): SkillCoverageTool[];