@elementumai/edk 0.9.10 → 0.9.12
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.
- package/README.md +39 -5
- package/dist-sdk/src/catalog/factories.d.ts +42 -14
- package/dist-sdk/src/catalog/factories.js +77 -14
- package/dist-sdk/src/catalog/from-authoring.js +4 -4
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/org.js +3 -2
- package/dist-sdk/src/catalog/token.js +4 -0
- package/dist-sdk/src/catalog/types.d.ts +32 -5
- package/dist-sdk/src/catalog/types.js +1 -0
- package/dist-sdk/src/core/triggers/on-demand.d.ts +4 -28
- package/dist-sdk/src/core/triggers/on-demand.js +2 -4
- package/dist-sdk/src/engine/build/context.d.ts +3 -0
- package/dist-sdk/src/engine/entity.d.ts +2 -0
- package/dist-sdk/src/engine/logging.d.ts +90 -0
- package/dist-sdk/src/engine/logging.js +124 -0
- package/dist-sdk/src/engine/progress.d.ts +119 -0
- package/dist-sdk/src/engine/progress.js +647 -0
- package/dist-sdk/src/engine/pull/result-output.d.ts +24 -0
- package/dist-sdk/src/engine/pull/result-output.js +48 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +3 -3
- package/dist-sdk/src/entities/access-policy/from-tf.js +27 -8
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +13 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +34 -3
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +13 -7
- package/dist-sdk/src/entities/agent/tools.d.ts +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +13 -0
- package/dist-sdk/src/entities/app/build.d.ts +22 -2
- package/dist-sdk/src/entities/app/build.js +6 -0
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +13 -3
- package/dist-sdk/src/entities/app/from-tf.js +10 -7
- package/dist-sdk/src/entities/app/to-tf.js +14 -14
- package/dist-sdk/src/entities/automation/build.d.ts +11 -16
- package/dist-sdk/src/entities/automation/build.js +38 -8
- package/dist-sdk/src/entities/automation/catalog-render.js +1 -1
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +1 -2
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +23 -5
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +239 -34
- package/dist-sdk/src/entities/automation/from-tf.js +276 -19
- package/dist-sdk/src/entities/automation/index.d.ts +2 -2
- package/dist-sdk/src/entities/automation/module.js +3 -2
- package/dist-sdk/src/entities/automation/output-field-types.js +25 -13
- package/dist-sdk/src/entities/automation/script-code.d.ts +12 -4
- package/dist-sdk/src/entities/automation/script-code.js +659 -101
- package/dist-sdk/src/entities/automation/tasks.d.ts +60 -28
- package/dist-sdk/src/entities/automation/tasks.js +48 -15
- package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/automation/to-tf.js +514 -103
- package/dist-sdk/src/entities/automation/triggers.d.ts +15 -9
- package/dist-sdk/src/entities/automation/triggers.js +4 -2
- package/dist-sdk/src/entities/automation/types.js +1 -0
- package/dist-sdk/src/entities/chart/build.d.ts +15 -3
- package/dist-sdk/src/entities/chart/build.js +6 -1
- package/dist-sdk/src/entities/chart/from-tf.d.ts +8 -2
- package/dist-sdk/src/entities/chart/from-tf.js +71 -8
- package/dist-sdk/src/entities/chart/index.d.ts +1 -1
- package/dist-sdk/src/entities/chart/index.js +1 -1
- package/dist-sdk/src/entities/chart/printer.js +27 -7
- package/dist-sdk/src/entities/chart/to-tf.js +56 -2
- package/dist-sdk/src/entities/dashboard/from-tf.js +11 -2
- package/dist-sdk/src/entities/datamine/from-tf.js +11 -1
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +2 -1
- package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +8 -0
- package/dist-sdk/src/entities/dynamic-layout/dialect.js +12 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +64 -10
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +54 -6
- package/dist-sdk/src/entities/element/build.d.ts +8 -0
- package/dist-sdk/src/entities/element/from-tf.js +4 -3
- package/dist-sdk/src/entities/element/module.js +1 -0
- package/dist-sdk/src/entities/element/to-tf.d.ts +4 -1
- package/dist-sdk/src/entities/element/to-tf.js +28 -2
- package/dist-sdk/src/entities/field/build.d.ts +10 -1
- package/dist-sdk/src/entities/field/build.js +2 -1
- package/dist-sdk/src/entities/field/calc/index.js +7 -7
- package/dist-sdk/src/entities/field/calc/runtime.d.ts +19 -0
- package/dist-sdk/src/entities/field/calc/runtime.js +32 -0
- package/dist-sdk/src/entities/field/calc/types.d.ts +6 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
- package/dist-sdk/src/entities/field/from-tf.js +73 -1
- package/dist-sdk/src/entities/field/metadata.d.ts +18 -0
- package/dist-sdk/src/entities/field/metadata.js +34 -0
- package/dist-sdk/src/entities/file-reader/to-tf.js +10 -2
- package/dist-sdk/src/entities/relationship/build.d.ts +27 -9
- package/dist-sdk/src/entities/relationship/column-contract.d.ts +24 -0
- package/dist-sdk/src/entities/relationship/column-contract.js +41 -0
- package/dist-sdk/src/entities/relationship/from-tf.js +33 -48
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +33 -2
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +15 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +21 -0
- package/dist-sdk/src/entities/shared/context.d.ts +6 -3
- package/dist-sdk/src/entities/shared/context.js +19 -1
- package/dist-sdk/src/entities/shared/filters/index.d.ts +7 -0
- package/dist-sdk/src/entities/shared/filters/index.js +28 -0
- package/dist-sdk/src/entities/shared/filters/print.js +2 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +8 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +10 -6
- package/dist-sdk/src/entities/shared/filters/types.d.ts +1 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +52 -27
- package/dist-sdk/src/entities/skill/module.js +1 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/skill/to-tf.js +17 -0
- package/dist-sdk/src/entities/skill/tools.d.ts +48 -12
- package/dist-sdk/src/entities/skill/tools.js +12 -1
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +15 -12
- package/dist-sdk/src/entities/skill-tool/from-tf.js +50 -46
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +4 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +66 -7
- package/dist-sdk/src/entities/table/build.js +10 -2
- package/dist-sdk/src/entities/table/catalog-render.js +2 -1
- package/dist-sdk/src/entities/view/from-tf.js +9 -0
- package/dist-sdk/src/entities/view/to-tf.d.ts +7 -0
- package/dist-sdk/src/entities/view/to-tf.js +39 -12
- package/dist-sdk/src/entities/widget/build.d.ts +43 -7
- package/dist-sdk/src/entities/widget/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/widget/from-tf.js +162 -23
- package/dist-sdk/src/entities/widget/to-tf.d.ts +17 -0
- package/dist-sdk/src/entities/widget/to-tf.js +150 -6
- package/dist-sdk/src/graph/types.d.ts +13 -0
- package/package.json +1 -1
- package/dist-sdk/src/core/types/platform.d.ts +0 -2
- package/dist-sdk/src/core/types/platform.js +0 -1
|
@@ -89,9 +89,16 @@ export interface FilterToTfCodec {
|
|
|
89
89
|
* right-hand `value`/`values` references — provider Read / ei use different
|
|
90
90
|
* wire forms for TASK refs in each slot (#490).
|
|
91
91
|
*/
|
|
92
|
-
readonly reference: (value: unknown, role?: "left" | "value", realType?: string) => TfValue;
|
|
92
|
+
readonly reference: (value: unknown, role?: "left" | "value", realType?: string, operator?: TfFilterType) => TfValue;
|
|
93
93
|
readonly literal?: (value: TfValue, field: unknown | undefined, valueType: string) => TfValue;
|
|
94
94
|
readonly fieldFromLeftValue?: (value: unknown) => unknown | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Override the REFERENCE `real_type` that would otherwise default to TEXT.
|
|
97
|
+
* Return a GraphQL ValueType (TEXT/UUID/NUMBER/…) or undefined to keep the
|
|
98
|
+
* authored/default value. Used when a trigger-record Ref's field metadata
|
|
99
|
+
* is a better authority than `isNull`'s TEXT operator fallback.
|
|
100
|
+
*/
|
|
101
|
+
readonly referenceRealType?: (reference: unknown, role: "left" | "value", authored: string | undefined) => string | undefined;
|
|
95
102
|
}
|
|
96
103
|
export interface FilterFromTfCodec<Field = string, ReferenceValue = never> {
|
|
97
104
|
readonly field: (value: TfValue, fieldScope: "app" | "user") => Field;
|
|
@@ -38,13 +38,13 @@ function wireFilter(value) {
|
|
|
38
38
|
throw new EntityTfError("filter type is required");
|
|
39
39
|
return value;
|
|
40
40
|
}
|
|
41
|
-
function withLeft(filter, codec) {
|
|
41
|
+
function withLeft(filter, codec, operator) {
|
|
42
42
|
if (filter.field !== undefined)
|
|
43
43
|
return { field_id: codec.field(filter.field) };
|
|
44
44
|
if (filter.field_id !== undefined)
|
|
45
45
|
return { field_id: filter.field_id };
|
|
46
46
|
if (filter.leftValue !== undefined) {
|
|
47
|
-
const value = wireFilterValueToTf(filter.leftValue, undefined, codec, "left");
|
|
47
|
+
const value = wireFilterValueToTf(filter.leftValue, undefined, codec, "left", operator);
|
|
48
48
|
if (value.type === "field" && value.field_id !== undefined)
|
|
49
49
|
return { left_value: { field_id: value.field_id } };
|
|
50
50
|
if (value.type === "reference" && value.value_reference !== undefined)
|
|
@@ -76,7 +76,7 @@ export function filterToTf(value, codec) {
|
|
|
76
76
|
return { type, children: filter.children.map((child) => filterToTf(child, codec)) };
|
|
77
77
|
}
|
|
78
78
|
const field = filter.field ?? codec.fieldFromLeftValue?.(filter.leftValue);
|
|
79
|
-
const left = withLeft(filter, codec);
|
|
79
|
+
const left = withLeft(filter, codec, type);
|
|
80
80
|
if (left.field_id === undefined && left.left_value === undefined) {
|
|
81
81
|
throw new EntityTfError(`${type} filter has no left side`);
|
|
82
82
|
}
|
|
@@ -156,7 +156,7 @@ function filterValueToWire(value) {
|
|
|
156
156
|
...(value.required !== undefined && { required: value.required }),
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
|
-
function wireFilterValueToTf(value, field, codec, role = "value") {
|
|
159
|
+
function wireFilterValueToTf(value, field, codec, role = "value", operator) {
|
|
160
160
|
if (value === null || typeof value !== "object" || isTfExpr(value)) {
|
|
161
161
|
throw new EntityTfError("invalid wire filter value");
|
|
162
162
|
}
|
|
@@ -177,12 +177,16 @@ function wireFilterValueToTf(value, field, codec, role = "value") {
|
|
|
177
177
|
const reference = raw.value ?? raw.valueReference ?? raw.value_reference;
|
|
178
178
|
if (reference === undefined)
|
|
179
179
|
throw new EntityTfError("reference filter value requires value");
|
|
180
|
+
const authored = raw.realType ?? raw.real_type;
|
|
181
|
+
const authoredType = typeof authored === "string" ? authored : undefined;
|
|
182
|
+
const inferred = codec.referenceRealType?.(reference, role, authoredType);
|
|
183
|
+
const realType = String(inferred ?? authoredType ?? "TEXT");
|
|
180
184
|
// ei export always writes an explicit `multiple = false` on scalar text
|
|
181
185
|
// references. Omitting it plans null-vs-false drift after pull.
|
|
182
186
|
return {
|
|
183
187
|
type,
|
|
184
|
-
value_reference: codec.reference(reference, role,
|
|
185
|
-
real_type:
|
|
188
|
+
value_reference: codec.reference(reference, role, realType, operator),
|
|
189
|
+
real_type: realType.toLowerCase(),
|
|
186
190
|
multiple: typeof raw.multiple === "boolean" ? raw.multiple : false,
|
|
187
191
|
};
|
|
188
192
|
}
|
|
@@ -40,6 +40,11 @@ export interface PrintSkillV2Options {
|
|
|
40
40
|
readonly ownerRefName: string;
|
|
41
41
|
readonly fieldKey: string;
|
|
42
42
|
}>;
|
|
43
|
+
/** Platform table id → canonical table catalog identity. */
|
|
44
|
+
readonly foreignTableRefsById?: ReadonlyMap<string, {
|
|
45
|
+
readonly tableRefName: string;
|
|
46
|
+
readonly name: string;
|
|
47
|
+
}>;
|
|
43
48
|
/** Aspect/table display-name pair → typed search-table identity. */
|
|
44
49
|
readonly foreignSearchTableRefsByName?: ReadonlyMap<string, {
|
|
45
50
|
readonly ownerRefName: string;
|
|
@@ -51,7 +51,9 @@ export function printSkillV2(skill, opts) {
|
|
|
51
51
|
]),
|
|
52
52
|
].sort();
|
|
53
53
|
const usesUnsafePlatformId = skill.tools.some((tool) => tool.automationRawId !== undefined ||
|
|
54
|
-
tool.
|
|
54
|
+
tool.target?.kind === "unresolved" ||
|
|
55
|
+
tool.fields?.some((field) => field.rawFieldId !== undefined && !opts.foreignFieldRefsById?.has(field.rawFieldId)) === true ||
|
|
56
|
+
(tool.filterVariables?.length ?? 0) > 0);
|
|
55
57
|
const lines = [];
|
|
56
58
|
lines.push("/**");
|
|
57
59
|
lines.push(` * ${skill.name}`);
|
|
@@ -61,6 +63,9 @@ export function printSkillV2(skill, opts) {
|
|
|
61
63
|
lines.push(" */");
|
|
62
64
|
lines.push("");
|
|
63
65
|
lines.push(`import { ${[...factories, "skill"].sort().join(", ")} } from ${JSON.stringify(sdkPackageSpecifier("agents/skills"))};`);
|
|
66
|
+
if (skill.tools.some((tool) => tool.typeKey === "searchTable" && tool.target?.kind === "tableOwned")) {
|
|
67
|
+
lines.push(`import { tableSearchTableRef } from ${JSON.stringify(sdkPackageSpecifier("catalog"))};`);
|
|
68
|
+
}
|
|
64
69
|
if (usesUnsafePlatformId)
|
|
65
70
|
lines.push(`import { unsafePlatformId } from ${JSON.stringify(sdkPackageSpecifier("core"))};`);
|
|
66
71
|
lines.push(`import catalog from "@catalog";`);
|
|
@@ -128,6 +133,11 @@ function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNa
|
|
|
128
133
|
// exists to satisfy NormalizedSkillTool.target's now-optional type.
|
|
129
134
|
if (tool.target === undefined || tool.target.kind === "self")
|
|
130
135
|
return { kind: "catalog", expr: `catalog.${appRefName}` };
|
|
136
|
+
if (tool.target.kind === "tableOwned" && tool.searchTableOwnerRefName !== undefined) {
|
|
137
|
+
return { kind: "table", expr: `catalog.tables${safeMember(tool.searchTableOwnerRefName)}.columns` };
|
|
138
|
+
}
|
|
139
|
+
if (tool.target.kind === "tableOwned")
|
|
140
|
+
return { kind: "raw", entityType: "app", name: tool.searchTableOwnerName ?? "", refName: tool.searchTableOwnerRefName ?? "" };
|
|
131
141
|
if (tool.target.kind === "unresolved") {
|
|
132
142
|
return { kind: "raw", entityType: "app", name: tool.target.uuid, refName: tool.target.uuid };
|
|
133
143
|
}
|
|
@@ -175,18 +185,7 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
175
185
|
? ` automation: unsafePlatformId(${quote(tool.automationRawId)}),`
|
|
176
186
|
: ` automation: catalog.${appRefName}.automations${safeMember(tool.automationKey ?? "")},`);
|
|
177
187
|
const inputs = tool.inputs ?? [];
|
|
178
|
-
|
|
179
|
-
if (inputs.length > 0 || missingRequired.length > 0) {
|
|
180
|
-
// `missingRequiredInputs` names REQUIRED trigger parameters this tool
|
|
181
|
-
// has no real mapping for on the platform — `AutomationToolV2` demands
|
|
182
|
-
// every one be present, but there is no real data to print for them
|
|
183
|
-
// (see skill-tool/from-tf.ts's doc comment: inventing an entry here
|
|
184
|
-
// would get faithfully re-serialized to HCL by `elementum build` and
|
|
185
|
-
// propose writing fake data onto a live tool). Print only the REAL
|
|
186
|
-
// captured entries, verbatim, and — only when a required one is still
|
|
187
|
-
// missing — cast the whole (possibly empty) object so the file still
|
|
188
|
-
// compiles; the cast changes nothing about what gets built, since an
|
|
189
|
-
// empty/absent `inputs` already round-trips to the same wire shape.
|
|
188
|
+
if (inputs.length > 0) {
|
|
190
189
|
lines.push(" inputs: {");
|
|
191
190
|
for (const input of inputs) {
|
|
192
191
|
const parts = [];
|
|
@@ -198,10 +197,7 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
198
197
|
parts.push(`required: ${input.required}`);
|
|
199
198
|
lines.push(` ${safeKey(input.parameterName)}: { ${parts.join(", ")} },`);
|
|
200
199
|
}
|
|
201
|
-
|
|
202
|
-
? ` as any /* TODO: automation requires input(s) for ${missingRequired.map((n) => quote(n)).join(", ")} — this tool has no mapping configured on the platform; add real inputs and remove this cast before deploying */`
|
|
203
|
-
: "";
|
|
204
|
-
lines.push(` }${cast},`);
|
|
200
|
+
lines.push(" },");
|
|
205
201
|
}
|
|
206
202
|
if (tool.outputs !== undefined && tool.outputs.length > 0) {
|
|
207
203
|
lines.push(" outputs: {");
|
|
@@ -227,10 +223,17 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
227
223
|
}
|
|
228
224
|
else if (tool.target?.kind === "unresolved") {
|
|
229
225
|
// Export couldn't resolve target_id to any portable app/element
|
|
230
|
-
// reference (board issue #648) — keep the raw platform id visible
|
|
231
|
-
//
|
|
226
|
+
// reference (board issue #648) — keep the raw platform id visible via
|
|
227
|
+
// the same unsafePlatformId() escape automation/field refs already use,
|
|
228
|
+
// so build round-trips it directly instead of misreading it as a named
|
|
229
|
+
// reference; cast past the type system since the field itself is a
|
|
230
|
+
// strict CatalogRef.
|
|
232
231
|
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 */,`);
|
|
232
|
+
lines.push(` ${entityKind}: unsafePlatformId(${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 */,`);
|
|
233
|
+
}
|
|
234
|
+
else if (tool.target?.kind === "tableOwned") {
|
|
235
|
+
// Table-owned search tables intentionally have no target aspect in the
|
|
236
|
+
// platform response. Do not manufacture an empty unsafePlatformId.
|
|
234
237
|
}
|
|
235
238
|
else if (tool.target !== undefined) {
|
|
236
239
|
// Board issue #42: the target can be a foreign APP or a foreign
|
|
@@ -267,17 +270,30 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
267
270
|
else {
|
|
268
271
|
const targetNameOrUuid = tool.target?.kind === "foreignApp" || tool.target?.kind === "foreignElement"
|
|
269
272
|
? tool.target.name
|
|
270
|
-
: tool.target?.kind === "
|
|
273
|
+
: tool.target?.kind === "tableOwned"
|
|
274
|
+
? tool.searchTableOwnerName
|
|
275
|
+
: tool.target?.kind === "unresolved" ? tool.target.uuid : undefined;
|
|
271
276
|
const parent = tool.target?.kind === "self"
|
|
272
277
|
? appRefName
|
|
273
278
|
: tool.target?.kind === "foreignApp" || tool.target?.kind === "foreignElement"
|
|
274
279
|
? tool.target.refName ?? targetNameOrUuid ?? ""
|
|
280
|
+
: tool.target?.kind === "tableOwned"
|
|
281
|
+
? tool.searchTableOwnerRefName ?? targetNameOrUuid ?? ""
|
|
282
|
+
: targetNameOrUuid ?? "";
|
|
283
|
+
const lookupParent = tool.target?.kind === "self"
|
|
284
|
+
? appRefName
|
|
285
|
+
: tool.target?.kind === "tableOwned"
|
|
286
|
+
? tool.searchTableOwnerName ?? targetNameOrUuid ?? ""
|
|
275
287
|
: targetNameOrUuid ?? "";
|
|
276
|
-
const lookupParent = tool.target?.kind === "self" ? appRefName : targetNameOrUuid ?? "";
|
|
277
288
|
const typedTable = tool.searchTableName === undefined
|
|
278
289
|
? undefined
|
|
279
290
|
: foreignSearchTableRefsByName?.get(searchTableLookupKey(lookupParent, tool.searchTableName));
|
|
280
|
-
if (
|
|
291
|
+
if (tool.target?.kind === "tableOwned") {
|
|
292
|
+
const owner = tool.searchTableOwnerRefName ?? parent;
|
|
293
|
+
const ownerName = tool.searchTableOwnerName;
|
|
294
|
+
lines.push(` table: tableSearchTableRef({ name: ${quote(tool.searchTableName ?? "")}, parent: ${quote(owner)}${ownerName !== undefined ? `, parentName: ${quote(ownerName)}` : ""} }),`);
|
|
295
|
+
}
|
|
296
|
+
else if (typedTable !== undefined) {
|
|
281
297
|
lines.push(` table: catalog.${typedTable.ownerRefName}.searchTables${safeMember(typedTable.tableKey)},`);
|
|
282
298
|
}
|
|
283
299
|
else {
|
|
@@ -288,6 +304,13 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
288
304
|
if (tool.limit !== undefined)
|
|
289
305
|
lines.push(` limit: ${tool.limit},`);
|
|
290
306
|
}
|
|
307
|
+
if ((tool.typeKey === "searchAspect" || tool.typeKey === "searchTable") && tool.filterVariables !== undefined && tool.filterVariables.length > 0) {
|
|
308
|
+
lines.push(" filterVariables: [");
|
|
309
|
+
for (const variable of tool.filterVariables) {
|
|
310
|
+
lines.push(` { id: unsafePlatformId(${quote(variable.id)}), name: ${quote(variable.name)}, description: ${quote(variable.description)}, required: ${variable.required} },`);
|
|
311
|
+
}
|
|
312
|
+
lines.push(" ],");
|
|
313
|
+
}
|
|
291
314
|
if (tool.typeKey === "updateRecord" && tool.handleDescription !== undefined) {
|
|
292
315
|
lines.push(` handleDescription: ${quote(tool.handleDescription)},`);
|
|
293
316
|
}
|
|
@@ -310,10 +333,12 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
310
333
|
? [`field: catalog.${resolvedRaw.ownerRefName}.fields.${resolvedRaw.fieldKey}`]
|
|
311
334
|
: owner.kind === "catalog"
|
|
312
335
|
? [`field: ${owner.expr}.fields.${f.key}`]
|
|
313
|
-
:
|
|
314
|
-
`field:
|
|
315
|
-
|
|
316
|
-
|
|
336
|
+
: owner.kind === "table"
|
|
337
|
+
? [`field: ${owner.expr}${safeMember(f.key)}`]
|
|
338
|
+
: [
|
|
339
|
+
`field: { __kind: "field", refName: ${quote(f.key)}, name: ${quote(f.name ?? f.key)}, fieldType: "TEXT", ` +
|
|
340
|
+
`parent: ${quote(owner.refName)}, parentKind: ${quote(owner.entityType)}, parentName: ${quote(owner.name)}${owner.namespace !== undefined ? `, parentNamespace: ${quote(owner.namespace)}` : ""} }`,
|
|
341
|
+
];
|
|
317
342
|
parts.push(`name: ${quote(f.name ?? "")}`);
|
|
318
343
|
parts.push(`description: ${quote(f.description ?? "")}`);
|
|
319
344
|
if ((tool.typeKey === "createRecord" || tool.typeKey === "updateRecord") && f.required !== undefined) {
|
|
@@ -89,6 +89,7 @@ export const skillModule = {
|
|
|
89
89
|
...(opts.foreignAppRefNames !== undefined && { foreignAppRefNames: opts.foreignAppRefNames }),
|
|
90
90
|
...(opts.foreignElementRefNames !== undefined && { foreignElementRefNames: opts.foreignElementRefNames }),
|
|
91
91
|
...(opts.foreignFieldRefsById !== undefined && { foreignFieldRefsById: opts.foreignFieldRefsById }),
|
|
92
|
+
...(opts.foreignTableRefsById !== undefined && { foreignTableRefsById: opts.foreignTableRefsById }),
|
|
92
93
|
...(opts.foreignSearchTableRefsByName !== undefined && {
|
|
93
94
|
foreignSearchTableRefsByName: opts.foreignSearchTableRefsByName,
|
|
94
95
|
}),
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* `properties`, plus typed discovery/routing fields. Access policy
|
|
13
13
|
* (user_ids/group_ids) is not authored yet.
|
|
14
14
|
*/
|
|
15
|
-
import type
|
|
15
|
+
import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
|
|
16
16
|
import { type DeployableEntity } from "../../engine/entity.js";
|
|
17
17
|
import { type TfBlock } from "../../engine/tf/index.js";
|
|
18
18
|
import type { AppServiceAccount } from "../service-account/build.js";
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* `properties`, plus typed discovery/routing fields. Access policy
|
|
13
13
|
* (user_ids/group_ids) is not authored yet.
|
|
14
14
|
*/
|
|
15
|
+
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
15
16
|
import { EntityTfError } from "../../engine/entity.js";
|
|
16
17
|
import { appScopedResourceLabel, expr, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
17
18
|
import { skillToolToTf } from "../skill-tool/to-tf.js";
|
|
@@ -117,6 +118,22 @@ export function skillToTf(entity, ctx) {
|
|
|
117
118
|
foreignFieldRef: (t, l, o, n) => ctx.orgRefs.foreignField(t, l, o, n),
|
|
118
119
|
workspaceAspects: ctx.workspaceAspects,
|
|
119
120
|
serviceAccountRef: (_label, serviceAccountName) => serviceAccountValue(serviceAccountName, ctx),
|
|
121
|
+
tableSearchTableRef: (label, tableRefName, tableName, searchTableName) => {
|
|
122
|
+
const tableLabel = sanitizeName(tableRefName);
|
|
123
|
+
const tableId = expr.dataAttr("elementum_table", tableLabel, ["id"]);
|
|
124
|
+
ctx.orgRefs.rawLookup("elementum_table", tableLabel, tableName);
|
|
125
|
+
ctx.orgRefs.rawLookup("elementum_search_table", label, searchTableName, { table_id: tableId });
|
|
126
|
+
return expr.dataAttr("elementum_search_table", label, ["id"]);
|
|
127
|
+
},
|
|
128
|
+
tableColumnRef: (tableRefName, tableName, columnName) => {
|
|
129
|
+
const sibling = ctx.workspaceAspects?.get(workspaceAspectKey("table", tableRefName));
|
|
130
|
+
if (sibling !== undefined) {
|
|
131
|
+
return expr.resourceAttr("elementum_table", sibling.tfLabel, ["field_ids", { index: columnName }]);
|
|
132
|
+
}
|
|
133
|
+
const tableLabel = sanitizeName(tableRefName);
|
|
134
|
+
ctx.orgRefs.rawLookup("elementum_table", tableLabel, tableName);
|
|
135
|
+
return expr.dataAttr("elementum_table", tableLabel, ["field_ids", { index: columnName }]);
|
|
136
|
+
},
|
|
120
137
|
diagnostics: ctx.diagnostics,
|
|
121
138
|
});
|
|
122
139
|
if (tool !== undefined)
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
* Search/record fields require `name` + `description` (matching the v1 skill
|
|
10
10
|
* serializer, which always emits them).
|
|
11
11
|
*/
|
|
12
|
-
import type { AgentRef, AppCatalogRef, AutomationCatalogRef, ElementCatalogRef, FieldRef, SearchTableRef } from "../../catalog/index.js";
|
|
12
|
+
import type { AgentRef, AppCatalogRef, AutomationCatalogRef, ElementCatalogRef, FieldRef, SearchTableRef, TableColumnRef, TableOwnedSearchTableRef } from "../../catalog/index.js";
|
|
13
13
|
import type { UnsafePlatformId } from "../../core/platform-id.js";
|
|
14
|
-
import type { AgentToolRunAs, RunAutomationOptionalInput, RunAutomationOutput,
|
|
14
|
+
import type { AgentToolRunAs, OutputBagOf, RunAutomationOptionalInput, RunAutomationOutput, RunAutomationOutputs, TriggerBagOf } from "../agent/tools.js";
|
|
15
15
|
declare const skillToolBrand: unique symbol;
|
|
16
16
|
/** A closed factory result; arbitrary records cannot be added to a skill's tool list. */
|
|
17
17
|
export type SkillTool = Record<string, unknown> & {
|
|
@@ -47,6 +47,21 @@ export interface SkillSearchRawIdField {
|
|
|
47
47
|
readonly description: string;
|
|
48
48
|
}
|
|
49
49
|
export type SkillSearchFieldInput<Target extends ToolTarget = ToolTarget> = SkillSearchField<Target> | SkillSearchRawIdField;
|
|
50
|
+
/** A table-owned search field is a table column, not an aspect field. */
|
|
51
|
+
export interface SkillTableSearchField {
|
|
52
|
+
readonly field: TableColumnRef;
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly description: string;
|
|
55
|
+
}
|
|
56
|
+
export type SkillTableSearchFieldInput = SkillTableSearchField | SkillSearchRawIdField;
|
|
57
|
+
/** A runtime value supplied by the agent for a search filter variable. */
|
|
58
|
+
export interface SkillFilterVariable {
|
|
59
|
+
/** Stable platform identifier referenced by the filter JSON. */
|
|
60
|
+
readonly id: UnsafePlatformId;
|
|
61
|
+
readonly name: string;
|
|
62
|
+
readonly description: string;
|
|
63
|
+
readonly required: boolean;
|
|
64
|
+
}
|
|
50
65
|
export interface SkillRecordField<Target extends ToolTarget = ToolTarget> {
|
|
51
66
|
readonly field: FieldRef<Target["refName"]>;
|
|
52
67
|
readonly name: string;
|
|
@@ -70,13 +85,23 @@ interface CommonToolOptions {
|
|
|
70
85
|
readonly startMessage?: string;
|
|
71
86
|
readonly runAs?: AgentToolRunAs;
|
|
72
87
|
}
|
|
73
|
-
export type
|
|
88
|
+
export type SkillAutomationInputs<T> = [keyof T] extends [never] ? {
|
|
89
|
+
readonly [key: string]: never;
|
|
90
|
+
} : {
|
|
91
|
+
readonly [K in keyof T]?: RunAutomationOptionalInput;
|
|
92
|
+
};
|
|
93
|
+
export type AutomationToolV2<A extends AutomationCatalogRef = AutomationCatalogRef> = CommonToolOptions & {
|
|
94
|
+
readonly automation: A;
|
|
74
95
|
readonly status?: SkillToolStatus;
|
|
96
|
+
readonly inputs?: SkillAutomationInputs<TriggerBagOf<A>>;
|
|
97
|
+
readonly outputs?: RunAutomationOutputs<OutputBagOf<A>>;
|
|
75
98
|
};
|
|
76
99
|
/**
|
|
77
|
-
* Run an on-demand automation
|
|
78
|
-
*
|
|
79
|
-
*
|
|
100
|
+
* Run an on-demand automation as a skill tool.
|
|
101
|
+
*
|
|
102
|
+
* Unlike agent tools, skill tools on the platform derive execution parameters
|
|
103
|
+
* directly from the on-demand trigger at runtime and do not require tool-level
|
|
104
|
+
* input bindings. Input and output mappings remain optional.
|
|
80
105
|
*
|
|
81
106
|
* When ei exported a bare `automation_id` UUID (no in-stream automation
|
|
82
107
|
* resource), pass `unsafePlatformId(...)` so rebuild keeps that tool.
|
|
@@ -93,20 +118,31 @@ export type SkillSearchRecordsToolOptions<Target extends ToolTarget = ToolTarget
|
|
|
93
118
|
readonly fields?: readonly SkillSearchFieldInput<Target>[];
|
|
94
119
|
/** Maximum number of records the search returns. */
|
|
95
120
|
readonly limit?: number;
|
|
121
|
+
readonly filterVariables?: readonly SkillFilterVariable[];
|
|
96
122
|
};
|
|
97
123
|
export declare function skillSearchRecords<Target extends ToolTarget>(opts: SkillSearchRecordsToolOptions<Target>): SkillTool;
|
|
98
|
-
/**
|
|
99
|
-
* A search-table tool targets the ELEMENT that owns the search table — never an
|
|
100
|
-
* app. See `search-table/build.ts`'s `SearchTableOwner`: an app's backing
|
|
101
|
-
* Snowflake table is hybrid, which Cortex cannot index.
|
|
102
|
-
*/
|
|
124
|
+
/** A search-table tool over an element-owned index targets its owning ELEMENT. */
|
|
103
125
|
export type SkillSearchTableToolV2<Target extends ElementCatalogRef = ElementCatalogRef> = CommonToolOptions & TargetOption<Target> & {
|
|
104
|
-
readonly table: SearchTableRef
|
|
126
|
+
readonly table: SearchTableRef & {
|
|
127
|
+
readonly __variant?: "snowflake" | "linked";
|
|
128
|
+
};
|
|
105
129
|
readonly queryDescription: string;
|
|
106
130
|
readonly fields: readonly SkillSearchFieldInput<Target>[];
|
|
107
131
|
/** Maximum number of records the search returns. */
|
|
108
132
|
readonly limit?: number;
|
|
133
|
+
readonly filterVariables?: readonly SkillFilterVariable[];
|
|
134
|
+
};
|
|
135
|
+
/** A table-owned search-table tool has no target aspect on the platform wire. */
|
|
136
|
+
export type SkillTableOwnedSearchTableToolV2 = CommonToolOptions & {
|
|
137
|
+
readonly app?: never;
|
|
138
|
+
readonly element?: never;
|
|
139
|
+
readonly table: TableOwnedSearchTableRef;
|
|
140
|
+
readonly queryDescription: string;
|
|
141
|
+
readonly fields: readonly SkillTableSearchFieldInput[];
|
|
142
|
+
readonly limit?: number;
|
|
143
|
+
readonly filterVariables?: readonly SkillFilterVariable[];
|
|
109
144
|
};
|
|
145
|
+
export declare function skillSearchTable(opts: SkillTableOwnedSearchTableToolV2): SkillTool;
|
|
110
146
|
export declare function skillSearchTable<Target extends ElementCatalogRef>(opts: SkillSearchTableToolV2<Target>): SkillTool;
|
|
111
147
|
export type SkillCreateRecordToolV2<Target extends ToolTarget = ToolTarget> = CommonToolOptions & TargetOption<Target> & {
|
|
112
148
|
readonly fields?: readonly SkillRecordFieldInput<Target>[];
|
|
@@ -3,6 +3,14 @@ import { assertHandleDescriptionNotEmpty } from "../shared/handle-description.js
|
|
|
3
3
|
function targetOf(opts) {
|
|
4
4
|
return ("app" in opts && opts.app !== undefined ? opts.app : opts.element);
|
|
5
5
|
}
|
|
6
|
+
function filterVariableToken(variable) {
|
|
7
|
+
return {
|
|
8
|
+
id: variable.id.value,
|
|
9
|
+
name: variable.name,
|
|
10
|
+
description: variable.description,
|
|
11
|
+
required: variable.required,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
6
14
|
function serializeRunAs(runAs) {
|
|
7
15
|
if ("currentUser" in runAs)
|
|
8
16
|
return { currentUser: true };
|
|
@@ -95,18 +103,21 @@ export function skillSearchRecords(opts) {
|
|
|
95
103
|
queryDescription: opts.queryDescription,
|
|
96
104
|
...(opts.fields !== undefined ? { fields: opts.fields.map(searchFieldToken) } : {}),
|
|
97
105
|
...(opts.limit !== undefined ? { limit: opts.limit } : {}),
|
|
106
|
+
...(opts.filterVariables !== undefined ? { filterVariables: opts.filterVariables.map(filterVariableToken) } : {}),
|
|
98
107
|
},
|
|
99
108
|
});
|
|
100
109
|
}
|
|
101
110
|
export function skillSearchTable(opts) {
|
|
111
|
+
const target = "app" in opts && opts.app !== undefined ? opts.app : "element" in opts && opts.element !== undefined ? opts.element : undefined;
|
|
102
112
|
return tool({
|
|
103
113
|
searchTable: {
|
|
104
114
|
...common(opts),
|
|
105
|
-
aspectId:
|
|
115
|
+
...(target !== undefined ? { aspectId: target } : {}),
|
|
106
116
|
searchTableId: opts.table,
|
|
107
117
|
queryDescription: opts.queryDescription,
|
|
108
118
|
fields: opts.fields.map(searchFieldToken),
|
|
109
119
|
...(opts.limit !== undefined ? { limit: opts.limit } : {}),
|
|
120
|
+
...(opts.filterVariables !== undefined ? { filterVariables: opts.filterVariables.map(filterVariableToken) } : {}),
|
|
110
121
|
},
|
|
111
122
|
});
|
|
112
123
|
}
|
|
@@ -22,8 +22,18 @@ export interface NormalizedSkillToolField {
|
|
|
22
22
|
readonly required?: boolean;
|
|
23
23
|
readonly defaultValue?: string;
|
|
24
24
|
}
|
|
25
|
+
export interface NormalizedFilterVariable {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly description: string;
|
|
29
|
+
readonly required: boolean;
|
|
30
|
+
}
|
|
25
31
|
export type NormalizedSkillToolTarget = {
|
|
26
32
|
readonly kind: "self";
|
|
33
|
+
}
|
|
34
|
+
/** Table-owned search tables have no target aspect on the platform wire. */
|
|
35
|
+
| {
|
|
36
|
+
readonly kind: "tableOwned";
|
|
27
37
|
} | {
|
|
28
38
|
/** A foreign app via `data.elementum_app.<label>` — `name` from the stream's data block. */
|
|
29
39
|
readonly kind: "foreignApp";
|
|
@@ -56,6 +66,7 @@ export interface NormalizedSkillTool {
|
|
|
56
66
|
readonly startMessage?: string;
|
|
57
67
|
readonly target?: NormalizedSkillToolTarget;
|
|
58
68
|
readonly fields?: readonly NormalizedSkillToolField[];
|
|
69
|
+
readonly filterVariables?: readonly NormalizedFilterVariable[];
|
|
59
70
|
readonly queryDescription?: string;
|
|
60
71
|
readonly limit?: number;
|
|
61
72
|
readonly handleDescription?: string;
|
|
@@ -70,6 +81,10 @@ export interface NormalizedSkillTool {
|
|
|
70
81
|
readonly searchTableKey?: string;
|
|
71
82
|
/** Foreign table lookup name when search_table_id is data.elementum_search_table. */
|
|
72
83
|
readonly searchTableName?: string;
|
|
84
|
+
/** Display name of the owning organization table for a table-owned search table. */
|
|
85
|
+
readonly searchTableOwnerName?: string;
|
|
86
|
+
/** Canonical catalog refName of the owning organization table, when known. */
|
|
87
|
+
readonly searchTableOwnerRefName?: string;
|
|
73
88
|
readonly inputs?: readonly {
|
|
74
89
|
readonly parameterName: string;
|
|
75
90
|
readonly displayName?: string;
|
|
@@ -82,18 +97,6 @@ export interface NormalizedSkillTool {
|
|
|
82
97
|
readonly description?: string;
|
|
83
98
|
}[];
|
|
84
99
|
readonly runAs?: AgentToolRunAs;
|
|
85
|
-
/**
|
|
86
|
-
* Names of the target automation's REQUIRED onDemand trigger parameters
|
|
87
|
-
* that this tool's own `inputs` (above) has no mapping for — the platform
|
|
88
|
-
* doesn't enforce that binding at tool-creation time, so a live tool can
|
|
89
|
-
* genuinely have none (edk#483: a Deloitte "sentiment-analysis" skill hit
|
|
90
|
-
* this). `AutomationToolV2` requires every such parameter to be mapped, so
|
|
91
|
-
* the printer needs this to know a type-only escape hatch is required —
|
|
92
|
-
* but the escape hatch must NOT be confused with authored data: unlike
|
|
93
|
-
* `inputs`, this is never fed into `skillToTf`/round-tripped to HCL. See
|
|
94
|
-
* `printTool`'s handling of `typeKey === "automation"`.
|
|
95
|
-
*/
|
|
96
|
-
readonly missingRequiredInputs?: readonly string[];
|
|
97
100
|
}
|
|
98
101
|
export interface SkillToolOwner {
|
|
99
102
|
/** The owning app's resource type + tfLabel. */
|