@elementumai/edk 0.9.14 → 0.9.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-sdk/pull/util.d.ts +0 -15
- package/dist-sdk/pull/util.js +44 -5
- package/dist-sdk/src/catalog/factories.d.ts +4 -2
- package/dist-sdk/src/catalog/factories.js +4 -0
- package/dist-sdk/src/catalog/from-authoring.js +5 -1
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/token.js +2 -2
- package/dist-sdk/src/catalog/types.d.ts +7 -2
- package/dist-sdk/src/core/types/app.d.ts +4 -4
- package/dist-sdk/src/engine/build/context.d.ts +5 -4
- package/dist-sdk/src/engine/build/source-context.d.ts +2 -0
- package/dist-sdk/src/engine/build/source-context.js +16 -0
- package/dist-sdk/src/engine/progress.d.ts +19 -1
- package/dist-sdk/src/engine/progress.js +33 -5
- package/dist-sdk/src/engine/pull/context.d.ts +9 -1
- package/dist-sdk/src/engine/pull/ref-only.d.ts +6 -2
- package/dist-sdk/src/engine/pull/ref-only.js +14 -3
- package/dist-sdk/src/engine/workspace/loader.js +23 -2
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/access-policy/from-tf.js +47 -12
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +5 -3
- package/dist-sdk/src/entities/access-policy/to-tf.js +23 -1
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +50 -4
- package/dist-sdk/src/entities/agent/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/agent/from-tf.js +18 -3
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.js +15 -0
- package/dist-sdk/src/entities/agent/tools.d.ts +98 -5
- package/dist-sdk/src/entities/agent/tools.js +12 -3
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +15 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +47 -4
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +9 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +82 -25
- package/dist-sdk/src/entities/app/build.d.ts +2 -2
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +4 -4
- package/dist-sdk/src/entities/app/module.js +8 -0
- package/dist-sdk/src/entities/app/to-tf.js +1 -0
- package/dist-sdk/src/entities/approval-chain/build.d.ts +8 -1
- package/dist-sdk/src/entities/approval-chain/build.js +3 -0
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +2 -1
- package/dist-sdk/src/entities/approval-chain/from-tf.js +20 -7
- package/dist-sdk/src/entities/approval-chain/printer.js +13 -2
- package/dist-sdk/src/entities/approval-chain/to-tf.js +3 -0
- package/dist-sdk/src/entities/automation/build.d.ts +19 -12
- package/dist-sdk/src/entities/automation/build.js +36 -13
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +4 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +19 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +222 -65
- package/dist-sdk/src/entities/automation/from-tf.d.ts +86 -6
- package/dist-sdk/src/entities/automation/from-tf.js +360 -63
- package/dist-sdk/src/entities/automation/index.d.ts +3 -2
- package/dist-sdk/src/entities/automation/index.js +3 -2
- package/dist-sdk/src/entities/automation/module.js +21 -16
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +5 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +12 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +20 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +22 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +32 -0
- package/dist-sdk/src/entities/automation/script-code.js +72 -5
- package/dist-sdk/src/entities/automation/tasks.d.ts +60 -24
- package/dist-sdk/src/entities/automation/tasks.js +33 -14
- package/dist-sdk/src/entities/automation/to-tf.d.ts +0 -2
- package/dist-sdk/src/entities/automation/to-tf.js +123 -46
- package/dist-sdk/src/entities/automation/triggers.d.ts +5 -2
- package/dist-sdk/src/entities/automation/types.d.ts +2 -0
- package/dist-sdk/src/entities/automation/types.js +5 -0
- package/dist-sdk/src/entities/automation/workflow-output.d.ts +35 -0
- package/dist-sdk/src/entities/automation/workflow-output.js +53 -0
- package/dist-sdk/src/entities/chart/build.d.ts +3 -3
- package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
- package/dist-sdk/src/entities/chart/from-tf.js +20 -13
- package/dist-sdk/src/entities/chart/to-tf.js +7 -5
- package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
- package/dist-sdk/src/entities/dashboard/to-tf.js +1 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +3 -2
- package/dist-sdk/src/entities/element/build.d.ts +11 -8
- package/dist-sdk/src/entities/element/build.js +14 -5
- package/dist-sdk/src/entities/element/locals.d.ts +2 -2
- package/dist-sdk/src/entities/element/locals.js +6 -2
- package/dist-sdk/src/entities/element/system-fields.d.ts +4 -0
- package/dist-sdk/src/entities/element/system-fields.js +12 -0
- package/dist-sdk/src/entities/element/to-tf.js +1 -0
- package/dist-sdk/src/entities/field/build.d.ts +2 -2
- package/dist-sdk/src/entities/field/from-tf.js +82 -4
- package/dist-sdk/src/entities/field/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/field/to-tf.js +11 -4
- package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -2
- package/dist-sdk/src/entities/relationship/from-tf.js +8 -5
- package/dist-sdk/src/entities/relationship/to-tf.js +13 -3
- package/dist-sdk/src/entities/search-table/from-tf.js +6 -6
- package/dist-sdk/src/entities/search-table/module.js +2 -2
- package/dist-sdk/src/entities/search-table/types.d.ts +1 -0
- package/dist-sdk/src/entities/search-table/types.js +1 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +3 -3
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +10 -6
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +4 -2
- package/dist-sdk/src/entities/shared/filters/index.d.ts +12 -2
- package/dist-sdk/src/entities/shared/filters/index.js +17 -1
- package/dist-sdk/src/entities/shared/filters/print.js +25 -11
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +39 -7
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +6 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +47 -18
- package/dist-sdk/src/entities/skill/module.js +10 -0
- package/dist-sdk/src/entities/skill/to-tf.js +19 -0
- package/dist-sdk/src/entities/skill/tools.d.ts +29 -7
- package/dist-sdk/src/entities/skill/tools.js +6 -2
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +18 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +77 -4
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +90 -46
- package/dist-sdk/src/entities/task/module.js +1 -1
- package/dist-sdk/src/entities/view/from-tf.js +30 -9
- package/dist-sdk/src/entities/view/to-tf.js +18 -10
- package/dist-sdk/src/entities/widget/from-tf.js +3 -3
- package/dist-sdk/src/entities/widget/to-tf.js +1 -0
- package/dist-sdk/src/graph/index.d.ts +15 -0
- package/dist-sdk/src/graph/index.js +19 -0
- package/dist-sdk/src/graph/types.d.ts +37 -1
- package/package.json +2 -1
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { EntityTfError } from "../../engine/entity.js";
|
|
14
14
|
import { dataRefLabel, resourceRefLabel } from "../../engine/pull/context.js";
|
|
15
|
-
import { appResourceLabelPrefix, elementResourceLabelPrefix, isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
|
|
15
|
+
import { appResourceLabelPrefix, elementResourceLabelPrefix, isTfExpr, scopedLabelToBagKey, scopedResourceLabel, tfLabelToTsLabel, } from "../../engine/tf/index.js";
|
|
16
16
|
import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-codec.js";
|
|
17
17
|
import { groupId, userId, } from "./principal.js";
|
|
18
18
|
import { KNOWN_ACCESS_POLICY_ATTRS } from "./types.js";
|
|
@@ -59,23 +59,58 @@ function fieldRef(value, owner, where) {
|
|
|
59
59
|
* collapse it back to its readable label, mirroring automation's own
|
|
60
60
|
* `picklistOptionLabel`.
|
|
61
61
|
*/
|
|
62
|
-
function picklistOptionLabel(value) {
|
|
63
|
-
if (value === undefined || !isTfExpr(value)
|
|
62
|
+
function picklistOptionLabel(value, owner) {
|
|
63
|
+
if (value === undefined || !isTfExpr(value))
|
|
64
64
|
return undefined;
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
// Locals are keyed by the Terraform resource label, like stage_ids_by_key,
|
|
66
|
+
// even when the caller's ownerTfLabel carries the public camelCase refName.
|
|
67
|
+
// A foreign label must not become this owner's option.
|
|
68
|
+
const ownedLocal = value.$expr === "local" && (value.name.startsWith(scopedResourceLabel(owner.label, "", owner.scope)) ||
|
|
69
|
+
["stage", "status"].some((field) => ["options_by_label", "option_ids_by_label"].some((suffix) => value.name === `${owner.label}_${field}_${suffix}`)));
|
|
70
|
+
const lookup = value.$expr === "local" && ownedLocal && value.path.length === 1 ? value.name
|
|
71
|
+
: value.$expr === "resource-attr" && value.type === owner.type && value.label === owner.label && value.path.length === 2 && typeof value.path[0] === "string" ? value.path[0] : undefined;
|
|
72
|
+
const segment = value.$expr === "local" ? value.path[0] : value.$expr === "resource-attr" ? value.path[1] : undefined;
|
|
73
|
+
const isOptionsLookup = lookup?.endsWith("_options_by_label") === true || lookup?.endsWith("_option_ids_by_label") === true;
|
|
67
74
|
return isOptionsLookup && typeof segment === "object" && segment !== null && "index" in segment && typeof segment.index === "string"
|
|
68
75
|
? segment.index
|
|
69
76
|
: undefined;
|
|
70
77
|
}
|
|
71
78
|
/** Decode one `filter` attribute through the shared exhaustive codec. */
|
|
72
|
-
export function filterFromTf(value, owner, where) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
export function filterFromTf(value, owner, where, ctx) {
|
|
80
|
+
try {
|
|
81
|
+
return deserializeFilterFromTf(value, {
|
|
82
|
+
field: (fieldValue) => fieldRef(fieldValue, owner, where),
|
|
83
|
+
reference: () => { throw new EntityTfError(`${where}: access-policy reference values are not supported`); },
|
|
84
|
+
literal: (literal) => picklistOptionLabel(literal, owner) ?? stageName(literal, owner, ctx) ?? literal,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (error instanceof EntityTfError && !error.message.startsWith(where)) {
|
|
89
|
+
throw new EntityTfError(`${where}: ${error.message}`);
|
|
90
|
+
}
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/** Stage IDs use keys, unlike option lookups whose index is already a label. */
|
|
95
|
+
function stageName(value, owner, ctx) {
|
|
96
|
+
if (!isTfExpr(value) || value.$expr !== "local" || value.name !== `${owner.label}_stage_ids_by_key` || value.path.length !== 1)
|
|
97
|
+
return undefined;
|
|
98
|
+
const index = value.path[0];
|
|
99
|
+
if (typeof index !== "object" || index === null || !("index" in index) || typeof index.index !== "string")
|
|
100
|
+
return undefined;
|
|
101
|
+
const stages = ctx?.resourceByAddress?.(`${owner.type}.${owner.label}`)?.attrs["stages"];
|
|
102
|
+
if (!Array.isArray(stages))
|
|
103
|
+
return undefined;
|
|
104
|
+
const entries = stages.flatMap((stage) => {
|
|
105
|
+
if (stage === null || typeof stage !== "object" || Array.isArray(stage) || isTfExpr(stage))
|
|
106
|
+
return [];
|
|
107
|
+
return typeof stage["key"] === "string" && typeof stage["name"] === "string" ? [{ key: stage["key"], name: stage["name"] }] : [];
|
|
77
108
|
});
|
|
78
|
-
|
|
109
|
+
const matches = entries.filter((stage) => stage.key === index.index);
|
|
110
|
+
const name = matches.length === 1 ? matches[0]?.name : undefined;
|
|
111
|
+
// Public option selections resolve by name. Do not turn a unique key into
|
|
112
|
+
// an ambiguous selection when two stage names are identical.
|
|
113
|
+
return name !== undefined && entries.filter((stage) => stage.name === name).length === 1 ? name : undefined;
|
|
79
114
|
}
|
|
80
115
|
function principalListItem(item, dataType, where, ctx, owner) {
|
|
81
116
|
const label = dataRefLabel(item, dataType);
|
|
@@ -154,7 +189,7 @@ export function accessPolicyFromTf(block, owner, ctx) {
|
|
|
154
189
|
const filterOwner = owner.foreignFieldRefsById !== undefined
|
|
155
190
|
? owner
|
|
156
191
|
: { ...owner, foreignFieldRefsById: ctx.foreignFieldRefsById };
|
|
157
|
-
const filter = attrs["filter"] !== undefined ? filterFromTf(attrs["filter"], filterOwner, where) : { type: "TRUE" };
|
|
192
|
+
const filter = attrs["filter"] !== undefined ? filterFromTf(attrs["filter"], filterOwner, where, ctx) : { type: "TRUE" };
|
|
158
193
|
const userIds = principalList(attrs["user_ids"], "elementum_user", `${where}: user_ids`, ctx);
|
|
159
194
|
const groupIds = principalList(attrs["group_ids"], "elementum_group", `${where}: group_ids`, ctx);
|
|
160
195
|
const serviceAccountIds = principalList(attrs["service_account_ids"], "elementum_service_account", `${where}: service_account_ids`, ctx, owner);
|
|
@@ -24,6 +24,8 @@ import type { AppServiceAccount } from "../service-account/build.js";
|
|
|
24
24
|
import type { AccessPolicyGroupRef, AccessPolicyServiceAccountRef, AccessPolicyUserRef } from "./principal.js";
|
|
25
25
|
export interface AccessPolicyToTfContext {
|
|
26
26
|
readonly ownerTfLabel: string;
|
|
27
|
+
/** App or element refName used to verify filter-field ownership. */
|
|
28
|
+
readonly ownerRefName?: string;
|
|
27
29
|
readonly scope: ChildResourceScope;
|
|
28
30
|
/** The owner's id reference, e.g. `elementum_app.<ns>.id` — computed by the owner's to-tf. */
|
|
29
31
|
readonly objectId: TfValue;
|
|
@@ -56,9 +58,9 @@ export interface AccessPolicyToTfContext {
|
|
|
56
58
|
export interface FilterToTfContext extends Omit<AccessPolicyToTfContext, "orgRefs"> {
|
|
57
59
|
readonly orgRefs?: OrgRefLookup;
|
|
58
60
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
61
|
+
* Preserve TEXT option labels on views. Resolving those labels to UUIDs
|
|
62
|
+
* plans changes to live views that still hold the label (Sanofi `submitted`).
|
|
63
|
+
* Explicit UUID selections retain their identity regardless of this flag.
|
|
62
64
|
*/
|
|
63
65
|
readonly resolvePicklistLiterals?: boolean;
|
|
64
66
|
}
|
|
@@ -55,6 +55,11 @@ function picklistLiteralToTf(literal, field, ctx) {
|
|
|
55
55
|
*/
|
|
56
56
|
export function filterToTf(f, where, ctx) {
|
|
57
57
|
return serializeFilterToTf(f, {
|
|
58
|
+
fieldFromLeftValue: (left) => {
|
|
59
|
+
if (left === null || typeof left !== "object" || !("type" in left) || left.type !== "FIELD")
|
|
60
|
+
return undefined;
|
|
61
|
+
return "value" in left ? left.value : undefined;
|
|
62
|
+
},
|
|
58
63
|
field: (field) => {
|
|
59
64
|
if (typeof field === "string" && isUuid(field))
|
|
60
65
|
return field;
|
|
@@ -65,8 +70,25 @@ export function filterToTf(f, where, ctx) {
|
|
|
65
70
|
return fieldValueToTf(field, where, ctx);
|
|
66
71
|
},
|
|
67
72
|
reference: () => { throw new EntityTfError(`${where}: access-policy filters do not support reference values`); },
|
|
68
|
-
literal: (value, field) => {
|
|
73
|
+
literal: (value, field, valueType) => {
|
|
69
74
|
if (typeof value === "string") {
|
|
75
|
+
// UUID option selections must remain identities, even on views where
|
|
76
|
+
// TEXT picklist labels intentionally stay literal (rather than IDs).
|
|
77
|
+
if (valueType === "uuid" && isFieldToken(field)) {
|
|
78
|
+
if (field.options?.includes(value)) {
|
|
79
|
+
const ownerRefName = ctx.ownerRefName ?? ctx.appRefName;
|
|
80
|
+
const sameOwner = (typeof field.parent === "string" && (field.parent === ctx.ownerTfLabel || field.parent === ownerRefName)) || field.parentNamespace === ctx.ownerTfLabel;
|
|
81
|
+
if (!sameOwner) {
|
|
82
|
+
if (!field.parent && !field.parentNamespace) {
|
|
83
|
+
throw new EntityTfError(`${where}: option selection has unresolved field ownership`);
|
|
84
|
+
}
|
|
85
|
+
throw new EntityTfError(`${where}: foreign option selections cannot use the current owner's lookup`);
|
|
86
|
+
}
|
|
87
|
+
return picklistLiteralToTf(value, field, ctx) ?? value;
|
|
88
|
+
}
|
|
89
|
+
if (field.tags?.includes("STAGE") && !isUuid(value))
|
|
90
|
+
throw new EntityTfError(`${where}: stage selection ${JSON.stringify(value)} has no declared option identity`);
|
|
91
|
+
}
|
|
70
92
|
if (ctx.resolvePicklistLiterals === false)
|
|
71
93
|
return value;
|
|
72
94
|
return picklistLiteralToTf(value, isFieldToken(field) ? field : undefined, ctx) ?? value;
|
|
@@ -49,6 +49,12 @@ export interface PrintAgentV2Options {
|
|
|
49
49
|
* key here prints `catalog.<refName>` instead of the literal stub.
|
|
50
50
|
*/
|
|
51
51
|
readonly foreignElementRefNames?: ReadonlyMap<string, string>;
|
|
52
|
+
/**
|
|
53
|
+
* Name → refName for every task already on disk in this workspace. A
|
|
54
|
+
* `foreignTask` tool target whose name is a key here prints
|
|
55
|
+
* `catalog.<refName>` instead of the literal stub.
|
|
56
|
+
*/
|
|
57
|
+
readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
|
|
52
58
|
/** Aspect/table display-name pair → typed search-table identity. */
|
|
53
59
|
readonly foreignSearchTableRefsByName?: ReadonlyMap<string, {
|
|
54
60
|
readonly ownerRefName: string;
|
|
@@ -110,7 +110,8 @@ export function printAgentV2(agent, opts) {
|
|
|
110
110
|
tool.searchTableFields?.some((field) => !searchTableFieldMatchesTarget(field.fieldId, targetOwner, opts.foreignFieldRefsById)) === true ||
|
|
111
111
|
tool.returnFields?.some((field) => !searchTableFieldMatchesTarget(field.fieldId, targetOwner, opts.foreignFieldRefsById)) === true ||
|
|
112
112
|
tool.target?.kind === "unresolved" ||
|
|
113
|
-
tool.relatedTarget?.kind === "unresolved"
|
|
113
|
+
tool.relatedTarget?.kind === "unresolved" ||
|
|
114
|
+
tool.searchTableRawId !== undefined);
|
|
114
115
|
});
|
|
115
116
|
const lines = [];
|
|
116
117
|
lines.push("/**");
|
|
@@ -122,6 +123,9 @@ export function printAgentV2(agent, opts) {
|
|
|
122
123
|
lines.push("");
|
|
123
124
|
const agentImports = [...factories, "agent"];
|
|
124
125
|
lines.push(`import { ${[...new Set(agentImports)].sort().join(", ")} } from "${sdkPackageSpecifier("agents")}";`);
|
|
126
|
+
if (agent.tools.some((tool) => tool.typeKey === "searchTable" && tool.searchTableOwnerRefName !== undefined)) {
|
|
127
|
+
lines.push(`import { tableSearchTableRef } from "${sdkPackageSpecifier("catalog")}";`);
|
|
128
|
+
}
|
|
125
129
|
if (usesUnsafePlatformId)
|
|
126
130
|
lines.push(`import { unsafePlatformId } from "${sdkPackageSpecifier("core")}";`);
|
|
127
131
|
// Always needed: `connector:` is required and always a catalog.aiProviders
|
|
@@ -193,7 +197,7 @@ export function printAgentV2(agent, opts) {
|
|
|
193
197
|
if (agent.tools.length > 0) {
|
|
194
198
|
lines.push(" tools: [");
|
|
195
199
|
for (const tool of agent.tools) {
|
|
196
|
-
lines.push(...printTool(tool, appRefName, crossOrg, opts.foreignAppRefNames, opts.foreignElementRefNames, opts.foreignSearchTableRefsByName, opts.foreignFieldRefsById).map((l) => ` ${l}`));
|
|
200
|
+
lines.push(...printTool(tool, appRefName, crossOrg, opts.foreignAppRefNames, opts.foreignElementRefNames, opts.foreignTaskRefNames, opts.foreignSearchTableRefsByName, opts.foreignFieldRefsById).map((l) => ` ${l}`));
|
|
197
201
|
}
|
|
198
202
|
lines.push(" ],");
|
|
199
203
|
}
|
|
@@ -228,6 +232,9 @@ function printSkillRefToken(ref, appRefName, crossOrg) {
|
|
|
228
232
|
// the raw id fills both slots, same as `refName`.
|
|
229
233
|
return `{ __kind: "skill", refName: ${quote(ref.id)}, name: ${quote(ref.id)}, unresolvedId: ${quote(ref.id)} }, // TODO: this skill isn't resolvable from the export (no name, no data block) - identify it manually and replace with a real catalog.<app>.skills.<key> token`;
|
|
230
234
|
}
|
|
235
|
+
if (ref.appRefName !== undefined && ref.key !== undefined) {
|
|
236
|
+
return `catalog.${ref.appRefName}.skills${safeMember(ref.key)},`;
|
|
237
|
+
}
|
|
231
238
|
// The foreign app's catalog may not exist in this workspace — a literal
|
|
232
239
|
// token compiles and deploys; swap for a catalog token when available.
|
|
233
240
|
const todo = crossOrg
|
|
@@ -384,6 +391,9 @@ function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNa
|
|
|
384
391
|
? { kind: "catalog", expr: `catalog.${foreignRefName}` }
|
|
385
392
|
: { kind: "raw", entityType: "app", name: tool.target.name };
|
|
386
393
|
}
|
|
394
|
+
if (tool.target.kind === "foreignTask") {
|
|
395
|
+
return { kind: "raw", entityType: "task", name: tool.target.name };
|
|
396
|
+
}
|
|
387
397
|
const foreignRefName = foreignElementRefNames?.get(tool.target.name);
|
|
388
398
|
return foreignRefName !== undefined
|
|
389
399
|
? { kind: "catalog", expr: `catalog.${foreignRefName}` }
|
|
@@ -408,7 +418,7 @@ function searchTableFieldMatchesTarget(fieldId, targetOwnerRefName, foreignField
|
|
|
408
418
|
const resolved = foreignFieldRefsById?.get(fieldId);
|
|
409
419
|
return resolved !== undefined && targetOwnerRefName !== undefined && resolved.ownerRefName === targetOwnerRefName;
|
|
410
420
|
}
|
|
411
|
-
function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElementRefNames, foreignSearchTableRefsByName, foreignFieldRefsById) {
|
|
421
|
+
function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElementRefNames, foreignTaskRefNames, foreignSearchTableRefsByName, foreignFieldRefsById) {
|
|
412
422
|
const factory = TOOL_FACTORY_BY_TYPE_KEY[tool.typeKey] ?? "agentSearchRecords";
|
|
413
423
|
const lines = [`${factory}({`];
|
|
414
424
|
lines.push(` name: ${quote(tool.name)},`);
|
|
@@ -518,6 +528,15 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
518
528
|
lines.push(` element: { __kind: "element", refName: ${quote(tool.target.name)}, name: ${quote(tool.target.name)} },${todo}`);
|
|
519
529
|
}
|
|
520
530
|
}
|
|
531
|
+
else if (tool.target !== undefined && tool.target.kind === "foreignTask") {
|
|
532
|
+
const foreignRefName = foreignTaskRefNames?.get(tool.target.name);
|
|
533
|
+
if (foreignRefName !== undefined) {
|
|
534
|
+
lines.push(` task: catalog.${foreignRefName},`);
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
lines.push(` task: { __kind: "task", refName: ${quote(tool.target.name)}, name: ${quote(tool.target.name)} },`);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
521
540
|
if (tool.typeKey === "relateRecord" && tool.relatedTarget?.kind === "self") {
|
|
522
541
|
lines.push(` relatedApp: catalog.${appRefName},`);
|
|
523
542
|
}
|
|
@@ -552,6 +571,15 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
552
571
|
lines.push(` relatedElement: { __kind: "element", refName: ${quote(tool.relatedTarget.name)}, name: ${quote(tool.relatedTarget.name)} },${todo}`);
|
|
553
572
|
}
|
|
554
573
|
}
|
|
574
|
+
else if (tool.typeKey === "relateRecord" && tool.relatedTarget?.kind === "foreignTask") {
|
|
575
|
+
const foreignRefName = foreignTaskRefNames?.get(tool.relatedTarget.name);
|
|
576
|
+
if (foreignRefName !== undefined) {
|
|
577
|
+
lines.push(` relatedTask: catalog.${foreignRefName},`);
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
lines.push(` relatedTask: { __kind: "task", refName: ${quote(tool.relatedTarget.name)}, name: ${quote(tool.relatedTarget.name)} },`);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
555
583
|
if (tool.typeKey === "searchAspect" || tool.typeKey === "searchTable") {
|
|
556
584
|
lines.push(` queryDescription: ${quote(tool.queryDescription ?? "")},`);
|
|
557
585
|
if (tool.limit !== undefined)
|
|
@@ -575,9 +603,27 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
575
603
|
: tool.target?.kind === "foreignElement"
|
|
576
604
|
? foreignElementRefNames?.get(tool.target.name)
|
|
577
605
|
: undefined;
|
|
578
|
-
if (tool.
|
|
606
|
+
if (tool.searchTableRawId !== undefined) {
|
|
607
|
+
// The search table itself has no portable lookup at all (not even a
|
|
608
|
+
// name) - round-trip the raw platform id instead of dropping a live
|
|
609
|
+
// tool, the same unsafePlatformId() escape used for an unresolved
|
|
610
|
+
// field/target elsewhere in this printer.
|
|
611
|
+
lines.push(` table: unsafePlatformId(${quote(tool.searchTableRawId)}), // TODO: this search table has no portable lookup (no name, no local resource) - verify/replace with a real table reference if one becomes available`);
|
|
612
|
+
}
|
|
613
|
+
else if (tool.searchTableKey !== undefined) {
|
|
579
614
|
lines.push(` table: catalog.${targetRefName ?? appRefName}.searchTables${safeMember(tool.searchTableKey)},`);
|
|
580
615
|
}
|
|
616
|
+
else if (tool.searchTableOwnerRefName !== undefined) {
|
|
617
|
+
// Table-owned: the search table's owner is a standalone Table entity,
|
|
618
|
+
// not an app/element aspect - the public tableSearchTableRef() factory
|
|
619
|
+
// (same one print-skill-v2.ts already uses) stamps __variant: "table"
|
|
620
|
+
// so to-tf.ts builds a table_id-scoped data source instead of an
|
|
621
|
+
// aspect-scoped one (live-confirmed: conciergeforfield/sanofi's "HCP
|
|
622
|
+
// Lookup v2" table). Pulled TypeScript must round-trip through the
|
|
623
|
+
// public typed API, not a raw wire-shaped object literal.
|
|
624
|
+
const ownerName = tool.searchTableOwnerName ?? tool.searchTableOwnerRefName;
|
|
625
|
+
lines.push(` table: tableSearchTableRef({ name: ${quote(tool.searchTableName ?? "")}, parent: ${quote(tool.searchTableOwnerRefName)}, parentName: ${quote(ownerName)} }),`);
|
|
626
|
+
}
|
|
581
627
|
else {
|
|
582
628
|
const parent = tool.target?.kind === "self"
|
|
583
629
|
? appRefName
|
|
@@ -62,14 +62,29 @@ function parseSkillRef(item, where, ownerTfLabel, ctx) {
|
|
|
62
62
|
ctx.diagnostics.push(`${where}: references data.${SKILL_RESOURCE_TYPE}.${item.label} but the stream has no such data block; dropped`);
|
|
63
63
|
return undefined;
|
|
64
64
|
}
|
|
65
|
-
const
|
|
66
|
-
const
|
|
65
|
+
const appId = ctx.dataAttrs?.(SKILL_RESOURCE_TYPE, item.label)?.["app_id"];
|
|
66
|
+
const appDataLabel = dataRefLabel(appId, APP_RESOURCE_TYPE);
|
|
67
|
+
const appResourceLabel = resourceRefLabel(appId, APP_RESOURCE_TYPE);
|
|
68
|
+
let appName = appDataLabel === undefined ? undefined : ctx.dataName(APP_RESOURCE_TYPE, appDataLabel);
|
|
69
|
+
if (appName === undefined && appResourceLabel !== undefined) {
|
|
70
|
+
const ownerId = ctx.importId(`${APP_RESOURCE_TYPE}.${appResourceLabel}`);
|
|
71
|
+
const owner = ownerId === undefined ? undefined : ctx.importedResource?.(ownerId);
|
|
72
|
+
appName = typeof owner?.attrs["name"] === "string" ? owner.attrs["name"] : undefined;
|
|
73
|
+
}
|
|
67
74
|
if (appName === undefined) {
|
|
68
75
|
ctx.diagnostics.push(`${where}: data.${SKILL_RESOURCE_TYPE}.${item.label} has no resolvable app_id owner; dropped`);
|
|
69
76
|
return undefined;
|
|
70
77
|
}
|
|
71
78
|
const appRefName = ctx.foreignAppRefNames?.get(appName);
|
|
72
|
-
|
|
79
|
+
const catalogSkill = ctx.foreignSkillRefsByOwnerName?.get(JSON.stringify([appName, name]));
|
|
80
|
+
return {
|
|
81
|
+
kind: "foreign",
|
|
82
|
+
name,
|
|
83
|
+
appName,
|
|
84
|
+
...(catalogSkill !== undefined
|
|
85
|
+
? { appRefName: catalogSkill.appRefName, key: catalogSkill.skillRefName }
|
|
86
|
+
: appRefName !== undefined ? { appRefName } : {}),
|
|
87
|
+
};
|
|
73
88
|
}
|
|
74
89
|
// A bare UUID literal with no data block backing it at all - the platform
|
|
75
90
|
// lets skill_ids reference a skill this export can't otherwise name (e.g.
|
|
@@ -101,6 +101,7 @@ export const agentModule = {
|
|
|
101
101
|
...(opts.connectorKeyOverride !== undefined && { connectorKeyOverride: opts.connectorKeyOverride }),
|
|
102
102
|
...(opts.foreignAppRefNames !== undefined && { foreignAppRefNames: opts.foreignAppRefNames }),
|
|
103
103
|
...(opts.foreignElementRefNames !== undefined && { foreignElementRefNames: opts.foreignElementRefNames }),
|
|
104
|
+
...(opts.foreignTaskRefNames !== undefined && { foreignTaskRefNames: opts.foreignTaskRefNames }),
|
|
104
105
|
...(opts.foreignFieldRefsById !== undefined && { foreignFieldRefsById: opts.foreignFieldRefsById }),
|
|
105
106
|
...(opts.foreignSearchTableRefsByName !== undefined && {
|
|
106
107
|
foreignSearchTableRefsByName: opts.foreignSearchTableRefsByName,
|
|
@@ -462,6 +462,7 @@ export function agentToTf(entity, ctx) {
|
|
|
462
462
|
activeAutomationRefNames: ctx.activeAutomationRefNames,
|
|
463
463
|
foreignAppRef: (l, n, ns) => ctx.orgRefs.foreignApp(l, n, ns),
|
|
464
464
|
foreignElementRef: (l, n, ns) => ctx.orgRefs.foreignElement(l, n, ns),
|
|
465
|
+
foreignTaskRef: (l, n) => ctx.orgRefs.rawLookup("elementum_task", l, n),
|
|
465
466
|
foreignAutomationRef: (l, n, owner) => {
|
|
466
467
|
const ownerKind = owner.kind === "element" ? "element" : "app";
|
|
467
468
|
const ownerRef = resolveForeignRef(ownerKind, { name: owner.name, namespace: owner.namespace }, ctx.orgRefs, ctx.diagnostics, `agent run-automation owner`);
|
|
@@ -472,6 +473,20 @@ export function agentToTf(entity, ctx) {
|
|
|
472
473
|
foreignFieldRef: (t, l, o, n) => ctx.orgRefs.foreignField(t, l, o, n),
|
|
473
474
|
workspaceAspects: ctx.workspaceAspects,
|
|
474
475
|
serviceAccountRef: (_label, serviceAccountName) => serviceAccountValue(serviceAccountName, ctx),
|
|
476
|
+
tableSearchTableRef: (label, _tableRefName, tableName, searchTableName) => {
|
|
477
|
+
// sanitizeName(tableName), not tableRefName: ei labels the export
|
|
478
|
+
// from the table's DISPLAY name (SanitizeName(displayName)), and
|
|
479
|
+
// sanitizeName doesn't split a capital before a digit the way a
|
|
480
|
+
// camelCase refName needs to reverse that - "hcpLookupV2" sanitizes
|
|
481
|
+
// to "hcp_lookupv2" while ei's own label for "HCP Lookup v2" is
|
|
482
|
+
// "hcp_lookup_v2", a perpetual plan diff (review feedback, PR
|
|
483
|
+
// #1095, msivraj).
|
|
484
|
+
const tableLabel = sanitizeName(tableName);
|
|
485
|
+
const tableId = expr.dataAttr("elementum_table", tableLabel, ["id"]);
|
|
486
|
+
ctx.orgRefs.rawLookup("elementum_table", tableLabel, tableName);
|
|
487
|
+
ctx.orgRefs.rawLookup("elementum_search_table", label, searchTableName, { table_id: tableId });
|
|
488
|
+
return expr.dataAttr("elementum_search_table", label, ["id"]);
|
|
489
|
+
},
|
|
475
490
|
diagnostics: ctx.diagnostics,
|
|
476
491
|
});
|
|
477
492
|
if (tool !== undefined)
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* object. Optional `startMessage` / `runAs` are emitted only when supplied,
|
|
11
11
|
* matching the v1 serializer's field-by-field discipline.
|
|
12
12
|
*/
|
|
13
|
-
import type { AutomationCatalogRef, AgentRef, AppCatalogRef, AutomationRef, ElementCatalogRef, FieldRef, OutputPropertyRef, SearchTableRef, TriggerParameterRef } from "../../catalog/index.js";
|
|
13
|
+
import type { AutomationCatalogRef, AgentRef, AppCatalogRef, AutomationRef, ElementCatalogRef, FieldRef, OutputPropertyRef, SearchTableRef, TableOwnedSearchTableRef, TaskCatalogRef, TriggerParameterRef } from "../../catalog/index.js";
|
|
14
14
|
import type { UnsafePlatformId } from "../../core/platform-id.js";
|
|
15
15
|
import type { AgentToolRunAs } from "./run-as.js";
|
|
16
16
|
import type { Filter } from "../automation/filter.js";
|
|
@@ -21,15 +21,23 @@ export type AgentTool = Record<string, unknown> & {
|
|
|
21
21
|
readonly [agentToolBrand]: "AgentTool";
|
|
22
22
|
};
|
|
23
23
|
/** A field exposed to a search tool. */
|
|
24
|
-
type ToolTarget = AppCatalogRef | ElementCatalogRef;
|
|
24
|
+
type ToolTarget = AppCatalogRef | ElementCatalogRef | TaskCatalogRef;
|
|
25
25
|
type TargetOption<Target extends ToolTarget> = Target extends {
|
|
26
26
|
readonly __kind: "app";
|
|
27
27
|
} ? {
|
|
28
28
|
readonly app: Target;
|
|
29
29
|
readonly element?: never;
|
|
30
|
-
|
|
30
|
+
readonly task?: never;
|
|
31
|
+
} : Target extends {
|
|
32
|
+
readonly __kind: "element";
|
|
33
|
+
} ? {
|
|
31
34
|
readonly app?: never;
|
|
32
35
|
readonly element: Target;
|
|
36
|
+
readonly task?: never;
|
|
37
|
+
} : {
|
|
38
|
+
readonly app?: never;
|
|
39
|
+
readonly element?: never;
|
|
40
|
+
readonly task: Target;
|
|
33
41
|
};
|
|
34
42
|
export interface AgentSearchField<Target extends ToolTarget = ToolTarget> {
|
|
35
43
|
readonly field: FieldRef<Target["refName"]>;
|
|
@@ -179,12 +187,89 @@ type SearchTableFieldDialect<Target extends ElementCatalogRef> = {
|
|
|
179
187
|
readonly returnFields?: readonly AgentSearchReturnFieldInput<Target>[];
|
|
180
188
|
};
|
|
181
189
|
export type SearchTableToolV2<Target extends ElementCatalogRef = ElementCatalogRef> = CommonToolOptions & TargetOption<Target> & {
|
|
182
|
-
|
|
190
|
+
/**
|
|
191
|
+
* The search table itself, or (pull-fidelity fallback, mirroring
|
|
192
|
+
* `fieldId`/`id` elsewhere in this file) a raw platform id when the
|
|
193
|
+
* search table's own identity has no portable lookup at all - the
|
|
194
|
+
* target aspect can still resolve fine even though the search table
|
|
195
|
+
* doesn't (live-confirmed on conciergeforfield, sanofi/us).
|
|
196
|
+
*
|
|
197
|
+
* Narrowed to exclude the table-owned variant (mirrors
|
|
198
|
+
* `SkillSearchTableToolV2`) - without this, a table-owned ref (which has
|
|
199
|
+
* no aspect target on the wire) also satisfies this aspect-targeted
|
|
200
|
+
* overload, so a caller could pair it with `element`/`app` and typecheck
|
|
201
|
+
* cleanly while the built HCL silently ignores the target (review
|
|
202
|
+
* feedback, PR #1095, msivraj).
|
|
203
|
+
*/
|
|
204
|
+
readonly table: (SearchTableRef & {
|
|
205
|
+
readonly __variant?: "snowflake" | "linked";
|
|
206
|
+
}) | UnsafePlatformId;
|
|
183
207
|
readonly queryDescription: string;
|
|
184
208
|
readonly filterVariables?: readonly AgentFilterVariable[];
|
|
185
209
|
readonly filter?: Filter;
|
|
186
210
|
readonly limit?: number;
|
|
187
211
|
} & SearchTableFieldDialect<Target>;
|
|
212
|
+
/**
|
|
213
|
+
* A table-owned search table has no target aspect on the platform wire (the
|
|
214
|
+
* search table's owner is a standalone Table entity, not an app/element) -
|
|
215
|
+
* mirrors `SkillTableOwnedSearchTableToolV2`. `fields`/`returnFields` aren't
|
|
216
|
+
* modeled yet for this variant (no live-captured example carries them);
|
|
217
|
+
* add a table-column field-ref dialect here if one turns up.
|
|
218
|
+
*/
|
|
219
|
+
export type TableOwnedSearchTableToolV2 = CommonToolOptions & {
|
|
220
|
+
readonly app?: never;
|
|
221
|
+
readonly element?: never;
|
|
222
|
+
readonly table: TableOwnedSearchTableRef;
|
|
223
|
+
readonly queryDescription: string;
|
|
224
|
+
readonly filterVariables?: readonly AgentFilterVariable[];
|
|
225
|
+
readonly filter?: Filter;
|
|
226
|
+
readonly limit?: number;
|
|
227
|
+
readonly fields?: never;
|
|
228
|
+
readonly returnFields?: never;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Raw-id only, not the full `AgentSearchTableFieldInput<Target>` union -
|
|
232
|
+
* with no target aspect on the wire at all, there is no `Target` to type
|
|
233
|
+
* a real `FieldRef` against, so a pulled field here can only be the
|
|
234
|
+
* platform-id fallback (review feedback, PR #1099, jj-deloitte: the
|
|
235
|
+
* printer emits `fields`/`returnFields` for a raw-id search table tool
|
|
236
|
+
* whenever the pulled resource carries them, independent of whether the
|
|
237
|
+
* target itself also resolved - the old `fields?: never` rejected that
|
|
238
|
+
* real, printer-emitted shape and failed the pulled workspace's own
|
|
239
|
+
* typecheck). Closed either/or union, mirroring `SearchTableFieldDialect`
|
|
240
|
+
* - `fields` and `returnFields` are still mutually exclusive provider wire
|
|
241
|
+
* dialects even with no target (review feedback, PR #1099, jj-deloitte:
|
|
242
|
+
* making both independently optional let a caller supply both at once,
|
|
243
|
+
* silently making `returnFields` ineffective).
|
|
244
|
+
*/
|
|
245
|
+
type UnresolvedTargetSearchTableFieldDialect = {
|
|
246
|
+
readonly fields?: readonly AgentSearchTableRawIdField[];
|
|
247
|
+
readonly returnFields?: never;
|
|
248
|
+
} | {
|
|
249
|
+
readonly fields?: never;
|
|
250
|
+
readonly returnFields?: readonly AgentSearchRawIdReturnField[];
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Neither the search table NOR the target aspect resolved to a portable
|
|
254
|
+
* reference (export couldn't recover either one) - `app`/`element` are
|
|
255
|
+
* absent from the wire entirely, not just unresolved, so unlike
|
|
256
|
+
* `SearchTableToolV2` there is no `Target` to type the overload against
|
|
257
|
+
* (review feedback, PR #1099, msivraj: the platform-id table shape with no
|
|
258
|
+
* target compiled against neither existing overload - `TableOwnedSearchTableToolV2`
|
|
259
|
+
* rejects a non-table-owned platform id, `SearchTableToolV2` requires
|
|
260
|
+
* `element`).
|
|
261
|
+
*/
|
|
262
|
+
export type UnresolvedTargetSearchTableToolV2 = CommonToolOptions & {
|
|
263
|
+
readonly app?: never;
|
|
264
|
+
readonly element?: never;
|
|
265
|
+
readonly table: UnsafePlatformId;
|
|
266
|
+
readonly queryDescription: string;
|
|
267
|
+
readonly filterVariables?: readonly AgentFilterVariable[];
|
|
268
|
+
readonly filter?: Filter;
|
|
269
|
+
readonly limit?: number;
|
|
270
|
+
} & UnresolvedTargetSearchTableFieldDialect;
|
|
271
|
+
export declare function agentSearchTable(opts: TableOwnedSearchTableToolV2): AgentTool;
|
|
272
|
+
export declare function agentSearchTable(opts: UnresolvedTargetSearchTableToolV2): AgentTool;
|
|
188
273
|
export declare function agentSearchTable<Target extends ElementCatalogRef = ElementCatalogRef>(opts: SearchTableToolV2<Target>): AgentTool;
|
|
189
274
|
export type CreateRecordToolV2<Target extends ToolTarget = ToolTarget> = CommonToolOptions & TargetOption<Target> & {
|
|
190
275
|
readonly fields?: readonly AgentRecordFieldInput<Target>[];
|
|
@@ -207,9 +292,17 @@ type RelatedTargetOption<Target extends ToolTarget> = Target extends {
|
|
|
207
292
|
} ? {
|
|
208
293
|
readonly relatedApp: Target;
|
|
209
294
|
readonly relatedElement?: never;
|
|
210
|
-
|
|
295
|
+
readonly relatedTask?: never;
|
|
296
|
+
} : Target extends {
|
|
297
|
+
readonly __kind: "element";
|
|
298
|
+
} ? {
|
|
211
299
|
readonly relatedApp?: never;
|
|
212
300
|
readonly relatedElement: Target;
|
|
301
|
+
readonly relatedTask?: never;
|
|
302
|
+
} : {
|
|
303
|
+
readonly relatedApp?: never;
|
|
304
|
+
readonly relatedElement?: never;
|
|
305
|
+
readonly relatedTask: Target;
|
|
213
306
|
};
|
|
214
307
|
export type RelateRecordToolV2<Target extends ToolTarget = ToolTarget, RelatedTarget extends ToolTarget = ToolTarget> = CommonToolOptions & TargetOption<Target> & RelatedTargetOption<RelatedTarget>;
|
|
215
308
|
export declare function agentRelateRecord<Target extends ToolTarget, RelatedTarget extends ToolTarget>(opts: RelateRecordToolV2<Target, RelatedTarget>): AgentTool;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { isValidToolName } from "../agent-tool/types.js";
|
|
2
2
|
import { assertHandleDescriptionNotEmpty } from "../shared/handle-description.js";
|
|
3
3
|
function targetOf(opts) {
|
|
4
|
-
return ("app" in opts && opts.app !== undefined
|
|
4
|
+
return ("app" in opts && opts.app !== undefined
|
|
5
|
+
? opts.app
|
|
6
|
+
: "element" in opts && opts.element !== undefined
|
|
7
|
+
? opts.element
|
|
8
|
+
: opts.task);
|
|
5
9
|
}
|
|
6
10
|
function filterVariableToken(variable) {
|
|
7
11
|
return {
|
|
@@ -126,10 +130,11 @@ export function agentSearchRecords(opts) {
|
|
|
126
130
|
});
|
|
127
131
|
}
|
|
128
132
|
export function agentSearchTable(opts) {
|
|
133
|
+
const target = "app" in opts && opts.app !== undefined ? opts.app : "element" in opts && opts.element !== undefined ? opts.element : undefined;
|
|
129
134
|
return tool({
|
|
130
135
|
searchTable: {
|
|
131
136
|
...common(opts),
|
|
132
|
-
aspectId:
|
|
137
|
+
...(target !== undefined ? { aspectId: target } : {}),
|
|
133
138
|
searchTableId: opts.table,
|
|
134
139
|
queryDescription: opts.queryDescription,
|
|
135
140
|
// Distinct internal keys preserve the provider's newer `fields` and
|
|
@@ -163,7 +168,11 @@ export function agentUpdateRecord(opts) {
|
|
|
163
168
|
});
|
|
164
169
|
}
|
|
165
170
|
export function agentRelateRecord(opts) {
|
|
166
|
-
const relatedTarget = "relatedApp" in opts && opts.relatedApp !== undefined
|
|
171
|
+
const relatedTarget = "relatedApp" in opts && opts.relatedApp !== undefined
|
|
172
|
+
? opts.relatedApp
|
|
173
|
+
: "relatedElement" in opts && opts.relatedElement !== undefined
|
|
174
|
+
? opts.relatedElement
|
|
175
|
+
: opts.relatedTask;
|
|
167
176
|
return tool({
|
|
168
177
|
relateRecord: {
|
|
169
178
|
...common(opts),
|
|
@@ -56,6 +56,10 @@ export type NormalizedToolTarget = {
|
|
|
56
56
|
/** A foreign ELEMENT via `data.elementum_element.<label>` — `name` from the stream's data block (board issue #42). */
|
|
57
57
|
readonly kind: "foreignElement";
|
|
58
58
|
readonly name: string;
|
|
59
|
+
} | {
|
|
60
|
+
/** A foreign TASK via `data.elementum_task.<label>` — `name` from the stream's data block. */
|
|
61
|
+
readonly kind: "foreignTask";
|
|
62
|
+
readonly name: string;
|
|
59
63
|
} | {
|
|
60
64
|
/**
|
|
61
65
|
* `target_id` didn't resolve to any portable reference at export
|
|
@@ -110,6 +114,17 @@ export interface NormalizedAgentTool {
|
|
|
110
114
|
readonly searchTableKey?: string;
|
|
111
115
|
/** Stable lookup name when the table is resolved through a data source. */
|
|
112
116
|
readonly searchTableName?: string;
|
|
117
|
+
/** Table-owned search table only: the owning Table entity's display name. */
|
|
118
|
+
readonly searchTableOwnerName?: string;
|
|
119
|
+
/** Table-owned search table only: the owning Table entity's authored refName. */
|
|
120
|
+
readonly searchTableOwnerRefName?: string;
|
|
121
|
+
/**
|
|
122
|
+
* The search table itself could not be resolved to a name or a local
|
|
123
|
+
* resource at all (export retained a raw UUID) - round-trip it as an
|
|
124
|
+
* unsafePlatformId() escape instead of dropping the tool outright. Mirrors
|
|
125
|
+
* PR #894's target-id fallback, extended to this separate field.
|
|
126
|
+
*/
|
|
127
|
+
readonly searchTableRawId?: string;
|
|
113
128
|
/** relateRecord: the aspect whose record is related to the primary target. */
|
|
114
129
|
readonly relatedTarget?: NormalizedToolTarget;
|
|
115
130
|
/** runAgent: target agent bag key within the owning app. */
|