@elementumai/edk 0.13.3 → 0.14.0
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/src/catalog/factories.d.ts +4 -2
- package/dist-sdk/src/catalog/factories.js +3 -1
- package/dist-sdk/src/catalog/from-authoring.d.ts +8 -3
- package/dist-sdk/src/catalog/from-authoring.js +21 -8
- package/dist-sdk/src/engine/build/context.d.ts +17 -0
- package/dist-sdk/src/engine/coverage-gaps.d.ts +13 -0
- package/dist-sdk/src/engine/coverage-gaps.js +21 -0
- package/dist-sdk/src/engine/pull/context.d.ts +57 -1
- package/dist-sdk/src/engine/pull/context.js +9 -1
- package/dist-sdk/src/engine/pull/pulled-roots.d.ts +14 -1
- package/dist-sdk/src/engine/pull/pulled-roots.js +23 -3
- package/dist-sdk/src/engine/pull/ref-only.d.ts +6 -1
- package/dist-sdk/src/engine/pull/ref-only.js +4 -1
- package/dist-sdk/src/engine/pull/stream-root.d.ts +17 -1
- package/dist-sdk/src/engine/pull/stream-root.js +57 -4
- package/dist-sdk/src/engine/tf/index.d.ts +1 -0
- package/dist-sdk/src/engine/tf/index.js +1 -0
- package/dist-sdk/src/engine/tf/jsonencode.d.ts +19 -0
- package/dist-sdk/src/engine/tf/jsonencode.js +49 -0
- package/dist-sdk/src/engine/validation.d.ts +36 -1
- package/dist-sdk/src/engine/validation.js +56 -2
- package/dist-sdk/src/engine/workspace/loader.d.ts +6 -0
- package/dist-sdk/src/engine/workspace/loader.js +87 -2
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +58 -17
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +3 -1
- package/dist-sdk/src/entities/access-policy/to-tf.js +1 -1
- package/dist-sdk/src/entities/agent/build.d.ts +15 -0
- package/dist-sdk/src/entities/agent/build.js +139 -16
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -3
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +39 -25
- package/dist-sdk/src/entities/agent/module.js +95 -3
- package/dist-sdk/src/entities/agent/to-tf.js +6 -4
- package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/agent-evaluation/from-tf.js +14 -5
- package/dist-sdk/src/entities/agent-evaluation/module.js +4 -2
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +11 -2
- package/dist-sdk/src/entities/agent-tool/from-tf.js +38 -40
- package/dist-sdk/src/entities/agent-tool/to-tf.js +12 -5
- package/dist-sdk/src/entities/app/build.d.ts +1 -1
- package/dist-sdk/src/entities/app/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/approval-trigger-refs.d.ts +20 -0
- package/dist-sdk/src/entities/automation/approval-trigger-refs.js +83 -0
- package/dist-sdk/src/entities/automation/build.d.ts +75 -42
- package/dist-sdk/src/entities/automation/build.js +18 -8
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +14 -2
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +9 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +64 -12
- package/dist-sdk/src/entities/automation/from-tf.d.ts +53 -0
- package/dist-sdk/src/entities/automation/from-tf.js +579 -106
- package/dist-sdk/src/entities/automation/index.d.ts +2 -2
- package/dist-sdk/src/entities/automation/index.js +1 -1
- package/dist-sdk/src/entities/automation/lookup-owner.d.ts +23 -0
- package/dist-sdk/src/entities/automation/lookup-owner.js +27 -0
- package/dist-sdk/src/entities/automation/module.js +265 -26
- package/dist-sdk/src/entities/automation/operators.d.ts +6 -2
- package/dist-sdk/src/entities/automation/operators.js +0 -2
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +8 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +11 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +37 -2
- package/dist-sdk/src/entities/automation/tasks.js +38 -1
- package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/automation/to-tf.js +576 -52
- package/dist-sdk/src/entities/automation/triggers.d.ts +47 -1
- package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +10 -5
- package/dist-sdk/src/entities/automation/unsafe-script-output.js +10 -5
- package/dist-sdk/src/entities/chart/to-tf.js +18 -5
- package/dist-sdk/src/entities/dashboard/from-tf.js +45 -11
- package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +5 -3
- package/dist-sdk/src/entities/dashboard-widget-order/order.js +6 -4
- package/dist-sdk/src/entities/datamine/from-tf.js +10 -3
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +38 -11
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +35 -7
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +101 -9
- package/dist-sdk/src/entities/element/build.d.ts +4 -1
- package/dist-sdk/src/entities/element/build.js +3 -4
- package/dist-sdk/src/entities/element/index.d.ts +1 -1
- package/dist-sdk/src/entities/field/from-tf.js +8 -1
- package/dist-sdk/src/entities/field/to-tf.d.ts +29 -2
- package/dist-sdk/src/entities/field/to-tf.js +106 -7
- package/dist-sdk/src/entities/phone-service/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/phone-service/from-tf.js +15 -7
- package/dist-sdk/src/entities/phone-service/module.js +4 -2
- package/dist-sdk/src/entities/portal/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/portal/to-tf.js +61 -2
- package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -1
- package/dist-sdk/src/entities/relationship/from-tf.js +34 -4
- package/dist-sdk/src/entities/relationship/to-tf.js +24 -6
- package/dist-sdk/src/entities/role/from-tf.js +3 -1
- package/dist-sdk/src/entities/search-table/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/search-table/from-tf.js +6 -3
- package/dist-sdk/src/entities/search-table/module.js +18 -2
- package/dist-sdk/src/entities/search-table/to-tf.js +10 -16
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +6 -1
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +6 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +21 -4
- package/dist-sdk/src/entities/shared/filters/index.js +27 -3
- package/dist-sdk/src/entities/shared/filters/print.js +23 -7
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +24 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +98 -3
- package/dist-sdk/src/entities/shared/filters/types.d.ts +8 -1
- package/dist-sdk/src/entities/shared/run-automation-requirement.d.ts +15 -0
- package/dist-sdk/src/entities/shared/run-automation-requirement.js +28 -0
- package/dist-sdk/src/entities/shared/search-table-address.d.ts +17 -0
- package/dist-sdk/src/entities/shared/search-table-address.js +24 -0
- package/dist-sdk/src/entities/shared/skip-release.d.ts +49 -0
- package/dist-sdk/src/entities/shared/skip-release.js +74 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -3
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +11 -5
- package/dist-sdk/src/entities/skill/module.js +3 -25
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +4 -2
- package/dist-sdk/src/entities/skill-tool/from-tf.js +28 -27
- package/dist-sdk/src/entities/skill-tool/to-tf.js +12 -5
- package/dist-sdk/src/entities/skill-tool/types.d.ts +1 -0
- package/dist-sdk/src/entities/skill-tool/types.js +2 -1
- package/dist-sdk/src/entities/table/catalog.d.ts +16 -0
- package/dist-sdk/src/entities/table/catalog.js +44 -2
- package/dist-sdk/src/entities/table/from-tf.js +30 -4
- package/dist-sdk/src/entities/table/keys.d.ts +27 -0
- package/dist-sdk/src/entities/table/keys.js +46 -0
- package/dist-sdk/src/entities/table/to-tf.js +2 -2
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +12 -1
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +9 -4
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +215 -10
- package/dist-sdk/src/entities/view/agent-view-layout.d.ts +10 -4
- package/dist-sdk/src/entities/view/custom-view-runtime-rules.d.ts +43 -0
- package/dist-sdk/src/entities/view/custom-view-runtime-rules.js +285 -0
- package/dist-sdk/src/entities/view/custom-view-validate.d.ts +3 -1
- package/dist-sdk/src/entities/view/custom-view-validate.js +24 -5
- package/dist-sdk/src/entities/view/from-tf.js +14 -1
- package/dist-sdk/src/entities/widget/from-tf.js +14 -7
- package/dist-sdk/src/entities/widget/to-tf.js +9 -6
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +4 -2
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +14 -1
- package/dist-sdk/src/graph/index.js +2 -0
- package/dist-sdk/src/graph/resource-types.d.ts +2 -0
- package/dist-sdk/src/graph/resource-types.js +3 -0
- package/dist-sdk/src/graph/types.d.ts +105 -0
- package/package.json +1 -1
|
@@ -43,7 +43,7 @@ function fieldValueToTf(token, where, ctx) {
|
|
|
43
43
|
if (foreign !== undefined)
|
|
44
44
|
return foreign;
|
|
45
45
|
}
|
|
46
|
-
const value = fieldRefToTfValue(token.fieldType ?? "", refName, ctx.ownerTfLabel, ctx.scope, ctx.fieldAddresses, token.resourceKey);
|
|
46
|
+
const value = fieldRefToTfValue(token.fieldType ?? "", refName, ctx.ownerTfLabel, ctx.scope, ctx.fieldAddresses, token.resourceKey, token.name);
|
|
47
47
|
if (value === undefined) {
|
|
48
48
|
throw new EntityTfError(`${where}: field token "${refName}" has no terraform field resource mapping`);
|
|
49
49
|
}
|
|
@@ -177,9 +177,24 @@ export interface AgentV2Options extends EntityDeployOptions {
|
|
|
177
177
|
readonly a2aSkills?: readonly A2ASkill[];
|
|
178
178
|
readonly tools?: readonly AgentTool[];
|
|
179
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* def()-time validation of run-automation (executeWorkflow) tools against
|
|
182
|
+
* the embedded automation token's trigger/outputs bags (see the comment
|
|
183
|
+
* above {@link runAutomationToolAddress}).
|
|
184
|
+
*
|
|
185
|
+
* Two findings are stale references, a live shape the platform accepts and
|
|
186
|
+
* runs: a required trigger parameter the tool doesn't map (the automation
|
|
187
|
+
* refuses the run) and a mapped output the automation doesn't declare (the
|
|
188
|
+
* agent gets no value for it). Pull reports them as warnings and prints the
|
|
189
|
+
* tool as it is live. Build/plan/apply settle them against state: a warning
|
|
190
|
+
* when state shows the tool and its automation already in that mismatch,
|
|
191
|
+
* otherwise fatal ({@link runAutomationToolStateCheck}). Every other
|
|
192
|
+
* mismatch is fatal.
|
|
193
|
+
*/
|
|
180
194
|
export declare function validateAgentTools(agentName: string, tools: readonly AgentTool[], identity?: {
|
|
181
195
|
readonly appTfLabel: string;
|
|
182
196
|
readonly agentRefName: string;
|
|
197
|
+
readonly appRefName?: string;
|
|
183
198
|
}): void;
|
|
184
199
|
/**
|
|
185
200
|
* The configured result of `agent` — its reference surface (`ref()`)
|
|
@@ -17,6 +17,7 @@ import { appScopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.
|
|
|
17
17
|
import { currentValidationMode, currentValidationScope, recordValidations, ValidationFailureError, } from "../../engine/validation.js";
|
|
18
18
|
import { agentToolBareLabel, agentToolLabelSuffixes } from "../agent-tool/to-tf.js";
|
|
19
19
|
import { RUN_AUTOMATION_TOOL_RESOURCE_TYPE } from "../agent-tool/types.js";
|
|
20
|
+
import { AUTOMATION_RESOURCE_TYPE, automationResourceLabel, TRIGGER_SUB_TYPES, WORKFLOW_PUBLISH_RESOURCE_TYPE, } from "../automation/types.js";
|
|
20
21
|
export const agentStartingActionVariableType = {
|
|
21
22
|
number: "NUMBER",
|
|
22
23
|
select: "SELECT",
|
|
@@ -111,6 +112,103 @@ function runAutomationToolAddress(appTfLabel, agentRefName, toolName, labelSuffi
|
|
|
111
112
|
const label = appScopedResourceLabel(appTfLabel, agentToolBareLabel(agentBare, toolName, labelSuffix));
|
|
112
113
|
return `${RUN_AUTOMATION_TOOL_RESOURCE_TYPE}.${label}`;
|
|
113
114
|
}
|
|
115
|
+
/** Sorted, de-duplicated strings: a mapping compared as a set. */
|
|
116
|
+
function mappingSet(values) {
|
|
117
|
+
return [...new Set(values.filter((value) => typeof value === "string"))].sort();
|
|
118
|
+
}
|
|
119
|
+
function sameMapping(a, b) {
|
|
120
|
+
return a.length === b.length && a.every((value, index) => value === b[index]);
|
|
121
|
+
}
|
|
122
|
+
function stateList(attributes, key) {
|
|
123
|
+
const value = attributes?.[key];
|
|
124
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "object" && item !== null) : [];
|
|
125
|
+
}
|
|
126
|
+
/** A run-automation tool's target runs on demand; its trigger resource shares the automation's label. */
|
|
127
|
+
const ON_DEMAND_TRIGGER_RESOURCE_TYPE = TRIGGER_SUB_TYPES.find((row) => row.typeKey === "onDemand").resourceType;
|
|
128
|
+
/**
|
|
129
|
+
* The state check behind one stale run-automation tool reference (edk#3230,
|
|
130
|
+
* #3231). The finding is a warning only when the workspace state shows the
|
|
131
|
+
* live tool and its automation already in that mismatch, so this build
|
|
132
|
+
* changes neither side of it:
|
|
133
|
+
*
|
|
134
|
+
* - the tool is unchanged: the trigger parameters it maps
|
|
135
|
+
* (`inputs[].parameter_name`) and the workflow outputs it maps
|
|
136
|
+
* (`outputs[].workflow_property_name`), each compared as a set, and its
|
|
137
|
+
* target (`automation_id` against the target automation's state id);
|
|
138
|
+
* - the automation already has the condition the finding names: for an
|
|
139
|
+
* unmapped required parameter, its on-demand trigger in state
|
|
140
|
+
* (`parameters[]`) has that parameter, required; for an undeclared output,
|
|
141
|
+
* its publish in state (`outputs[].name`) lacks that output.
|
|
142
|
+
*
|
|
143
|
+
* So a source edit to either side that creates the mismatch (a new or
|
|
144
|
+
* changed tool, a parameter made required, an output removed or renamed)
|
|
145
|
+
* is an error. A target automation that isn't in state, or whose trigger or
|
|
146
|
+
* publish isn't, fails closed the same way. Descriptions, display names,
|
|
147
|
+
* `required` flags, start message and run-as are not compared: editing them
|
|
148
|
+
* leaves the finding a warning, and the plan updates those settings.
|
|
149
|
+
*/
|
|
150
|
+
function runAutomationToolStateCheck(toolAddress, automation, inputNames, outputNames, condition) {
|
|
151
|
+
const inputs = mappingSet(inputNames);
|
|
152
|
+
const outputs = mappingSet(outputNames);
|
|
153
|
+
const fix = condition.kind === "unmappedRequiredParameter"
|
|
154
|
+
? `map "${condition.parameter}" on the tool in source, or change the automation`
|
|
155
|
+
: `remove "${condition.output}" from the tool's outputs in source, or change the automation`;
|
|
156
|
+
return (lookup) => {
|
|
157
|
+
const changed = (why, remedy = fix) => ({ unchanged: false, note: `an error: ${why}; ${remedy}` });
|
|
158
|
+
const live = lookup(toolAddress);
|
|
159
|
+
if (live === undefined)
|
|
160
|
+
return changed("this tool is new here");
|
|
161
|
+
const liveInputs = mappingSet(stateList(live, "inputs").map((item) => item["parameter_name"]));
|
|
162
|
+
const liveOutputs = mappingSet(stateList(live, "outputs").map((item) => item["workflow_property_name"]));
|
|
163
|
+
if (!sameMapping(inputs, liveInputs) || !sameMapping(outputs, liveOutputs)) {
|
|
164
|
+
return changed("this tool's inputs or outputs differ from the workspace state");
|
|
165
|
+
}
|
|
166
|
+
const target = automation === undefined ? undefined : lookup(automation.automation);
|
|
167
|
+
if (target === undefined)
|
|
168
|
+
return changed("the tool's automation isn't in this workspace's state");
|
|
169
|
+
if (target["id"] !== live["automation_id"]) {
|
|
170
|
+
return changed("this tool's automation differs from the one in the workspace state");
|
|
171
|
+
}
|
|
172
|
+
if (condition.kind === "unmappedRequiredParameter") {
|
|
173
|
+
const parameter = stateList(lookup(automation.trigger), "parameters").find((item) => item["name"] === condition.parameter);
|
|
174
|
+
if (parameter?.["required"] !== true) {
|
|
175
|
+
return changed(`"${condition.parameter}" isn't a required parameter of the automation in the workspace state, so this change makes it one`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
const publish = lookup(automation.publish);
|
|
180
|
+
if (publish === undefined)
|
|
181
|
+
return changed("the workspace state has no published outputs for the automation to compare");
|
|
182
|
+
if (stateList(publish, "outputs").some((item) => item["name"] === condition.output)) {
|
|
183
|
+
// Pull doesn't re-import a publish (its import resets the revision
|
|
184
|
+
// bookkeeping), so this is also what an output removed in Elementum
|
|
185
|
+
// after the state was written looks like.
|
|
186
|
+
return changed(`the automation still has output "${condition.output}" in the workspace state: this change removes it, ` +
|
|
187
|
+
"or it was removed in Elementum after this project's state was written (a pull doesn't re-read an automation's published outputs)", `remove "${condition.output}" from the tool's outputs in source; that edits the tool, so also fix any other ` +
|
|
188
|
+
"mapping this check reports on it, or change the automation");
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
unchanged: true,
|
|
193
|
+
note: "a warning: the workspace state shows the live tool and its automation already like this, " +
|
|
194
|
+
"and this change leaves both as they are; fix the tool or the automation in Elementum, or here",
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* def()-time validation of run-automation (executeWorkflow) tools against
|
|
200
|
+
* the embedded automation token's trigger/outputs bags (see the comment
|
|
201
|
+
* above {@link runAutomationToolAddress}).
|
|
202
|
+
*
|
|
203
|
+
* Two findings are stale references, a live shape the platform accepts and
|
|
204
|
+
* runs: a required trigger parameter the tool doesn't map (the automation
|
|
205
|
+
* refuses the run) and a mapped output the automation doesn't declare (the
|
|
206
|
+
* agent gets no value for it). Pull reports them as warnings and prints the
|
|
207
|
+
* tool as it is live. Build/plan/apply settle them against state: a warning
|
|
208
|
+
* when state shows the tool and its automation already in that mismatch,
|
|
209
|
+
* otherwise fatal ({@link runAutomationToolStateCheck}). Every other
|
|
210
|
+
* mismatch is fatal.
|
|
211
|
+
*/
|
|
114
212
|
export function validateAgentTools(agentName, tools, identity) {
|
|
115
213
|
const failures = [];
|
|
116
214
|
const labelSuffixes = agentToolLabelSuffixes(tsLabelToTfLabel(identity?.agentRefName ?? ""), tools);
|
|
@@ -121,18 +219,41 @@ export function validateAgentTools(agentName, tools, identity) {
|
|
|
121
219
|
const toolName = inner.name ?? "";
|
|
122
220
|
const auto = inner.automationId;
|
|
123
221
|
const autoName = auto?.refName ?? "";
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
222
|
+
const appTfLabel = identity?.appTfLabel ?? currentValidationScope().appTfLabel ?? "";
|
|
223
|
+
const agentRefName = identity?.agentRefName ?? "";
|
|
224
|
+
const toolAddress = appTfLabel !== "" && agentRefName !== ""
|
|
225
|
+
? runAutomationToolAddress(appTfLabel, agentRefName, toolName, labelSuffixes[index] ?? "")
|
|
226
|
+
: undefined;
|
|
227
|
+
// The same names and labels the HCL carries (agent-tool and automation
|
|
228
|
+
// to-tf.ts). Another app's or element's automation is checked against its
|
|
229
|
+
// own resources when they are in this workspace's state.
|
|
230
|
+
const ownerKind = auto?.parentKind === "element" ? "element" : "app";
|
|
231
|
+
const ownerTfLabel = auto?.parent === undefined || auto.parent === identity?.appRefName
|
|
232
|
+
? appTfLabel
|
|
233
|
+
: tsLabelToTfLabel(auto.parent);
|
|
234
|
+
const automationLabel = autoName !== "" && ownerTfLabel !== ""
|
|
235
|
+
? automationResourceLabel(ownerTfLabel, autoName, ownerKind)
|
|
236
|
+
: undefined;
|
|
237
|
+
const automationAddresses = automationLabel === undefined
|
|
238
|
+
? undefined
|
|
239
|
+
: {
|
|
240
|
+
automation: `${AUTOMATION_RESOURCE_TYPE}.${automationLabel}`,
|
|
241
|
+
publish: `${WORKFLOW_PUBLISH_RESOURCE_TYPE}.${automationLabel}`,
|
|
242
|
+
trigger: `${ON_DEMAND_TRIGGER_RESOURCE_TYPE}.${automationLabel}`,
|
|
243
|
+
};
|
|
244
|
+
const inputNames = (inner.inputs ?? []).map((input) => input.triggerParameterId?.name ?? "");
|
|
245
|
+
const outputNames = (inner.outputs ?? []).map((output) => output.workflowPropertyName ?? "");
|
|
246
|
+
const fail = (msg, condition) => {
|
|
247
|
+
const stateCheck = condition === undefined || toolAddress === undefined
|
|
248
|
+
? undefined
|
|
249
|
+
: runAutomationToolStateCheck(toolAddress, automationAddresses, inputNames, outputNames, condition);
|
|
127
250
|
failures.push({
|
|
128
251
|
severity: "fatal",
|
|
129
|
-
address:
|
|
130
|
-
? runAutomationToolAddress(appTfLabel, agentRefName, toolName, labelSuffixes[index] ?? "")
|
|
131
|
-
: `agent.${agentName}`,
|
|
252
|
+
address: toolAddress ?? `agent.${agentName}`,
|
|
132
253
|
name: agentName,
|
|
133
254
|
ownerKind: "agent",
|
|
134
255
|
message: `tool "${toolName}" — ${msg}`,
|
|
135
|
-
...(
|
|
256
|
+
...(condition !== undefined ? { staleReference: true, ...(stateCheck !== undefined ? { stateCheck } : {}) } : {}),
|
|
136
257
|
});
|
|
137
258
|
};
|
|
138
259
|
const trigger = auto?.trigger;
|
|
@@ -153,9 +274,7 @@ export function validateAgentTools(agentName, tools, identity) {
|
|
|
153
274
|
}
|
|
154
275
|
for (const [param, meta] of Object.entries(trigger)) {
|
|
155
276
|
if (meta?.required === true && !mapped.has(param)) {
|
|
156
|
-
|
|
157
|
-
// Every other mismatch is still a fatal authoring error.
|
|
158
|
-
fail(`required trigger parameter "${param}" of automation "${autoName}" is not mapped to a tool input`, true);
|
|
277
|
+
fail(`required trigger parameter "${param}" of automation "${autoName}" is not mapped to a tool input`, { kind: "unmappedRequiredParameter", parameter: param });
|
|
159
278
|
}
|
|
160
279
|
}
|
|
161
280
|
}
|
|
@@ -165,8 +284,10 @@ export function validateAgentTools(agentName, tools, identity) {
|
|
|
165
284
|
const prop = output.workflowPropertyName ?? "";
|
|
166
285
|
if (!(prop in outputsBag)) {
|
|
167
286
|
const declared = Object.keys(outputsBag);
|
|
287
|
+
// The platform stores and runs such a tool; the agent gets no value
|
|
288
|
+
// for the output (edk#3230), so this is a stale reference too.
|
|
168
289
|
fail(`output "${prop}" does not match a workflow output property of automation "${autoName}"` +
|
|
169
|
-
(declared.length > 0 ? ` (declared: ${declared.join(", ")})` : " (it declares none)"));
|
|
290
|
+
(declared.length > 0 ? ` (declared: ${declared.join(", ")})` : " (it declares none)"), { kind: "undeclaredOutput", output: prop });
|
|
170
291
|
}
|
|
171
292
|
}
|
|
172
293
|
}
|
|
@@ -176,10 +297,12 @@ export function validateAgentTools(agentName, tools, identity) {
|
|
|
176
297
|
const mode = currentValidationMode();
|
|
177
298
|
if (mode === "pull" || mode === "build")
|
|
178
299
|
recordValidations(failures);
|
|
179
|
-
//
|
|
180
|
-
//
|
|
181
|
-
// a
|
|
182
|
-
|
|
300
|
+
// When every finding is a stale reference, keep the agent: pull prints it
|
|
301
|
+
// as it is live, and build emits it while its findings wait to be settled
|
|
302
|
+
// against state (a fatal one still stops the build before .tf/out is
|
|
303
|
+
// written). Any other mismatch, or no session collecting the findings,
|
|
304
|
+
// throws and the agent is left out.
|
|
305
|
+
if (mode !== undefined && failures.every((failure) => failure.staleReference === true))
|
|
183
306
|
return;
|
|
184
307
|
throw new ValidationFailureError(failures);
|
|
185
308
|
}
|
|
@@ -222,7 +345,7 @@ export function agent(opts) {
|
|
|
222
345
|
},
|
|
223
346
|
def(refName) {
|
|
224
347
|
const appTfLabel = currentValidationScope().appTfLabel ?? tsLabelToTfLabel(opts.app.refName);
|
|
225
|
-
validateAgentTools(opts.name, opts.tools ?? [], { appTfLabel, agentRefName: refName });
|
|
348
|
+
validateAgentTools(opts.name, opts.tools ?? [], { appTfLabel, agentRefName: refName, appRefName: opts.app.refName });
|
|
226
349
|
return {
|
|
227
350
|
kind: "agent",
|
|
228
351
|
parent: opts.app.refName,
|
|
@@ -50,9 +50,9 @@ export interface PrintAgentV2Options {
|
|
|
50
50
|
*/
|
|
51
51
|
readonly foreignElementRefNames?: ReadonlyMap<string, string>;
|
|
52
52
|
/**
|
|
53
|
-
* Name → refName for every task already on disk in this workspace. A
|
|
54
|
-
* `foreignTask` tool target whose name is a key
|
|
55
|
-
*
|
|
53
|
+
* Name → refName for every task already on disk in this workspace. A task
|
|
54
|
+
* has no catalog entry, so a `foreignTask` tool target whose name is a key
|
|
55
|
+
* here still prints the inline stub, carrying this refName (#3148).
|
|
56
56
|
*/
|
|
57
57
|
readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
|
|
58
58
|
/** Terraform label → authored catalog ref. Field identities stay on the label. */
|
|
@@ -125,8 +125,12 @@ export function printAgentV2(agent, opts) {
|
|
|
125
125
|
lines.push("");
|
|
126
126
|
const agentImports = [...factories, "agent"];
|
|
127
127
|
lines.push(`import { ${[...new Set(agentImports)].sort().join(", ")} } from "${sdkPackageSpecifier("agents")}";`);
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
const catalogImports = [
|
|
129
|
+
...(agent.tools.some((tool) => tool.typeKey === "searchTable" && tool.searchTableOwnerRefName !== undefined) ? ["tableSearchTableRef"] : []),
|
|
130
|
+
...(agent.tools.some((tool) => (tool.staleMappings?.length ?? 0) > 0) ? ["type AutomationCatalogRef"] : []),
|
|
131
|
+
];
|
|
132
|
+
if (catalogImports.length > 0) {
|
|
133
|
+
lines.push(`import { ${catalogImports.join(", ")} } from "${sdkPackageSpecifier("catalog")}";`);
|
|
130
134
|
}
|
|
131
135
|
if (usesUnsafePlatformId)
|
|
132
136
|
lines.push(`import { unsafePlatformId } from "${sdkPackageSpecifier("core")}";`);
|
|
@@ -450,7 +454,7 @@ function printA2ASkill(skill) {
|
|
|
450
454
|
lines.push("},");
|
|
451
455
|
return lines;
|
|
452
456
|
}
|
|
453
|
-
function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames) {
|
|
457
|
+
function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames, foreignTaskRefNames) {
|
|
454
458
|
if (tool.target === undefined || tool.target.kind === "self")
|
|
455
459
|
return { kind: "catalog", expr: `catalog.${appRefName}` };
|
|
456
460
|
if (tool.target.kind === "unresolved")
|
|
@@ -462,7 +466,10 @@ function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNa
|
|
|
462
466
|
: { kind: "raw", entityType: "app", name: tool.target.name };
|
|
463
467
|
}
|
|
464
468
|
if (tool.target.kind === "foreignTask") {
|
|
465
|
-
|
|
469
|
+
// Same refName as the `task:` stub, or build reads the field as another
|
|
470
|
+
// task's and drops it (#3148).
|
|
471
|
+
const refName = foreignTaskRefNames?.get(tool.target.name);
|
|
472
|
+
return { kind: "raw", entityType: "task", name: tool.target.name, ...(refName !== undefined && { refName }) };
|
|
466
473
|
}
|
|
467
474
|
const foreignRefName = foreignElementRefNames?.get(tool.target.name);
|
|
468
475
|
return foreignRefName !== undefined
|
|
@@ -508,7 +515,18 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
508
515
|
// differs from the key — the fixed point for tools authored without a
|
|
509
516
|
// rename. Spec key order: name?, description, required?.
|
|
510
517
|
const auto = `catalog.${appRefName}.automations${safeMember(tool.automationKey ?? "")}`;
|
|
511
|
-
|
|
518
|
+
if (tool.staleMappings !== undefined && tool.staleMappings.length > 0) {
|
|
519
|
+
// The live tool is out of step with its automation (edk#3230, #3231).
|
|
520
|
+
// agentRunAutomation types the mappings by the automation's catalog
|
|
521
|
+
// ref, so the typed ref would reject the file. Widening the ref keeps
|
|
522
|
+
// the pulled file typechecking; build still reports the mismatch.
|
|
523
|
+
lines.push(` // Pulled as it is live, out of step with its automation: ${tool.staleMappings.join("; ")}.`);
|
|
524
|
+
lines.push(" // The cast lets this file typecheck; build reports the mismatch. Remove it once the tool or the automation is fixed.");
|
|
525
|
+
lines.push(` automation: ${auto} as AutomationCatalogRef,`);
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
lines.push(` automation: ${auto},`);
|
|
529
|
+
}
|
|
512
530
|
if (tool.inputs !== undefined && tool.inputs.length > 0) {
|
|
513
531
|
lines.push(" inputs: {");
|
|
514
532
|
for (const i of tool.inputs) {
|
|
@@ -604,13 +622,10 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
604
622
|
}
|
|
605
623
|
}
|
|
606
624
|
else if (tool.target !== undefined && tool.target.kind === "foreignTask") {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
}
|
|
611
|
-
else {
|
|
612
|
-
lines.push(` task: { __kind: "task", refName: ${quote(tool.target.name)}, name: ${quote(tool.target.name)} },`);
|
|
613
|
-
}
|
|
625
|
+
// A task-type app has no catalog entry, even once pulled (#3148): the
|
|
626
|
+
// stub carries the pulled task's refName so build binds it to that task.
|
|
627
|
+
const refName = foreignTaskRefNames?.get(tool.target.name) ?? tool.target.name;
|
|
628
|
+
lines.push(` task: { __kind: "task", refName: ${quote(refName)}, name: ${quote(tool.target.name)} },`);
|
|
614
629
|
}
|
|
615
630
|
if (tool.typeKey === "relateRecord" && tool.relatedTarget?.kind === "self") {
|
|
616
631
|
lines.push(` relatedApp: catalog.${appRefName},`);
|
|
@@ -647,13 +662,8 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
647
662
|
}
|
|
648
663
|
}
|
|
649
664
|
else if (tool.typeKey === "relateRecord" && tool.relatedTarget?.kind === "foreignTask") {
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
lines.push(` relatedTask: catalog.${foreignRefName},`);
|
|
653
|
-
}
|
|
654
|
-
else {
|
|
655
|
-
lines.push(` relatedTask: { __kind: "task", refName: ${quote(tool.relatedTarget.name)}, name: ${quote(tool.relatedTarget.name)} },`);
|
|
656
|
-
}
|
|
665
|
+
const refName = foreignTaskRefNames?.get(tool.relatedTarget.name) ?? tool.relatedTarget.name;
|
|
666
|
+
lines.push(` relatedTask: { __kind: "task", refName: ${quote(refName)}, name: ${quote(tool.relatedTarget.name)} },`);
|
|
657
667
|
}
|
|
658
668
|
if (tool.typeKey === "searchAspect" || tool.typeKey === "searchTable") {
|
|
659
669
|
lines.push(` queryDescription: ${quote(tool.queryDescription ?? "")},`);
|
|
@@ -701,12 +711,16 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
701
711
|
lines.push(` table: tableSearchTableRef({ name: ${quote(tool.searchTableName ?? "")}, parent: ${quote(tool.searchTableOwnerRefName)}, parentName: ${quote(ownerName)}${pinnedId} }),`);
|
|
702
712
|
}
|
|
703
713
|
else {
|
|
704
|
-
|
|
714
|
+
// Catalog identities are keyed by the owner's display name, but build
|
|
715
|
+
// checks the table's parent against the target's catalog refName: the
|
|
716
|
+
// one the element:/app: line above prints (edk#2880, as print-skill-v2.ts).
|
|
717
|
+
const lookupParent = tool.target?.kind === "self"
|
|
705
718
|
? appRefName
|
|
706
719
|
: tool.target?.kind === "unresolved" ? tool.target.uuid : tool.target?.name ?? "";
|
|
720
|
+
const parent = targetRefName ?? lookupParent;
|
|
707
721
|
const typedTable = tool.searchTableName === undefined
|
|
708
722
|
? undefined
|
|
709
|
-
: foreignSearchTableRefsByName?.get(JSON.stringify([
|
|
723
|
+
: foreignSearchTableRefsByName?.get(JSON.stringify([lookupParent, tool.searchTableName]));
|
|
710
724
|
if (typedTable !== undefined) {
|
|
711
725
|
const tableOwner = catalogRefForFieldOwner(typedTable.ownerRefName, foreignAppRefNamespaces, foreignElementRefNamespaces);
|
|
712
726
|
lines.push(` table: catalog.${tableOwner}.searchTables${safeMember(typedTable.tableKey)},`);
|
|
@@ -718,7 +732,7 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
718
732
|
}
|
|
719
733
|
}
|
|
720
734
|
if (tool.fields !== undefined && tool.fields.length > 0) {
|
|
721
|
-
const owner = fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames);
|
|
735
|
+
const owner = fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames, foreignTaskRefNames);
|
|
722
736
|
lines.push(" fields: [");
|
|
723
737
|
for (const f of tool.fields) {
|
|
724
738
|
// A foreign/out-of-scope aspect's field has no field resource ei can
|
|
@@ -735,7 +749,7 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
735
749
|
? [`field: ${owner.expr}.fields.${f.key}`]
|
|
736
750
|
: [
|
|
737
751
|
`field: { __kind: "field", refName: ${quote(f.key)}, name: ${quote(f.name ?? f.key)}, fieldType: "TEXT", ` +
|
|
738
|
-
`parent: ${quote(owner.name)}, parentKind: ${quote(owner.entityType)}, parentName: ${quote(owner.name)} }`,
|
|
752
|
+
`parent: ${quote(owner.refName ?? owner.name)}, parentKind: ${quote(owner.entityType)}, parentName: ${quote(owner.name)} }`,
|
|
739
753
|
];
|
|
740
754
|
if (f.name !== undefined)
|
|
741
755
|
parts.push(`name: ${quote(f.name)}`);
|
|
@@ -762,7 +776,7 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
762
776
|
if (tool.searchTableFields !== undefined && tool.searchTableFields.length > 0) {
|
|
763
777
|
const targetOwner = searchTableTargetOwnerRefName(tool, appRefName, foreignAppRefNames, foreignElementRefNames);
|
|
764
778
|
lines.push(" fields: [");
|
|
765
|
-
const keyOwner = fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames);
|
|
779
|
+
const keyOwner = fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames, foreignTaskRefNames);
|
|
766
780
|
for (const f of tool.searchTableFields) {
|
|
767
781
|
let parts;
|
|
768
782
|
let todo = "";
|
|
@@ -772,7 +786,7 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
772
786
|
? [`field: ${keyOwner.expr}.fields.${f.key}`]
|
|
773
787
|
: [
|
|
774
788
|
`field: { __kind: "field", refName: ${quote(f.key)}, name: ${quote(f.name ?? f.key)}, fieldType: "TEXT", ` +
|
|
775
|
-
`parent: ${quote(keyOwner.name)}, parentKind: ${quote(keyOwner.entityType)}, parentName: ${quote(keyOwner.name)} }`,
|
|
789
|
+
`parent: ${quote(keyOwner.refName ?? keyOwner.name)}, parentKind: ${quote(keyOwner.entityType)}, parentName: ${quote(keyOwner.name)} }`,
|
|
776
790
|
];
|
|
777
791
|
if (keyOwner.kind === "raw") {
|
|
778
792
|
todo = ` // TODO: foreign field — type unconfirmed and refName is a best-effort guess; verify against "${keyOwner.name}"`;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** The agent entity's registry entry + resource-type constant (see src/graph/). */
|
|
2
2
|
import { bareFactoryEntry } from "../../catalog/render-helpers.js";
|
|
3
3
|
import { isTfExpr } from "../../engine/tf/index.js";
|
|
4
|
+
import { requireRunAutomationTarget } from "../shared/run-automation-requirement.js";
|
|
5
|
+
import { TRIGGER_SUB_TYPES, WORKFLOW_PUBLISH_RESOURCE_TYPE } from "../automation/types.js";
|
|
4
6
|
import { printAgentV2 } from "./deserializer/print-agent-v2.js";
|
|
5
7
|
import { agentFromTf } from "./from-tf.js";
|
|
6
8
|
import { agentToTf } from "./to-tf.js";
|
|
@@ -39,12 +41,96 @@ function agentRefFromAuthoring(args) {
|
|
|
39
41
|
: entityRefName;
|
|
40
42
|
return { __kind: "agent", refName: entityRefName, name, parent: entityParent };
|
|
41
43
|
}
|
|
44
|
+
const ON_DEMAND_TRIGGER_RESOURCE_TYPE = TRIGGER_SUB_TYPES.find((row) => row.typeKey === "onDemand").resourceType;
|
|
45
|
+
function namesOf(value, key) {
|
|
46
|
+
if (!Array.isArray(value))
|
|
47
|
+
return [];
|
|
48
|
+
return value.flatMap((item) => {
|
|
49
|
+
const name = typeof item === "object" && item !== null && !isTfExpr(item) ? item[key] : undefined;
|
|
50
|
+
return typeof name === "string" && name !== "" ? [name] : [];
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* How a live run-automation tool is out of step with its automation in the
|
|
55
|
+
* same export (edk#3230, #3231): required on-demand parameters it doesn't
|
|
56
|
+
* map, and mapped outputs the automation's publish doesn't declare. These are
|
|
57
|
+
* the stale references `validateAgentTools` reports from the catalog bags;
|
|
58
|
+
* an automation with no parameters or no outputs is skipped there too.
|
|
59
|
+
*/
|
|
60
|
+
function staleRunAutomationMappings(toolBlock, resources) {
|
|
61
|
+
const autoRef = toolBlock.attrs["automation_id"];
|
|
62
|
+
if (!isTfExpr(autoRef) || autoRef.$expr !== "resource-attr")
|
|
63
|
+
return { reasons: [], unmappedRequired: false };
|
|
64
|
+
const label = autoRef.label;
|
|
65
|
+
const trigger = resources.find((block) => block.type === ON_DEMAND_TRIGGER_RESOURCE_TYPE && block.label === label);
|
|
66
|
+
const publish = resources.find((block) => block.type === WORKFLOW_PUBLISH_RESOURCE_TYPE && block.label === label);
|
|
67
|
+
const mappedInputs = new Set(namesOf(toolBlock.attrs["inputs"], "parameter_name"));
|
|
68
|
+
const reasons = [];
|
|
69
|
+
let unmappedRequired = false;
|
|
70
|
+
const parameters = Array.isArray(trigger?.attrs["parameters"]) ? trigger.attrs["parameters"] : [];
|
|
71
|
+
for (const parameter of parameters) {
|
|
72
|
+
if (typeof parameter !== "object" || parameter === null || isTfExpr(parameter))
|
|
73
|
+
continue;
|
|
74
|
+
const { name, required } = parameter;
|
|
75
|
+
if (typeof name === "string" && required === true && !mappedInputs.has(name)) {
|
|
76
|
+
reasons.push(`required input "${name}" is not mapped`);
|
|
77
|
+
unmappedRequired = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const declaredOutputs = new Set(namesOf(publish?.attrs["outputs"], "name"));
|
|
81
|
+
if (declaredOutputs.size > 0) {
|
|
82
|
+
for (const output of namesOf(toolBlock.attrs["outputs"], "workflow_property_name")) {
|
|
83
|
+
if (!declaredOutputs.has(output))
|
|
84
|
+
reasons.push(`output "${output}" is not one the automation declares`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return { reasons, unmappedRequired };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Mark each pulled run-automation tool that is out of step with its
|
|
91
|
+
* automation, and list the state its build-time check reads that an earlier
|
|
92
|
+
* pull or apply may have left behind live: the tool itself, and for an
|
|
93
|
+
* unmapped required parameter, its automation's on-demand trigger. Adoption
|
|
94
|
+
* re-imports those when already in state (edk#3230, #3231). The publish is
|
|
95
|
+
* never listed: its import resets the revision bookkeeping to
|
|
96
|
+
* `1.0.<version>`, so a project that authored a higher revision would plan
|
|
97
|
+
* a republish. An output removed in Elementum after the state was written
|
|
98
|
+
* is therefore not confirmed from state, and the check says so.
|
|
99
|
+
*/
|
|
100
|
+
function withStaleMappings(tools, toolBlocks, resources) {
|
|
101
|
+
const staleByName = new Map();
|
|
102
|
+
const reimportForLive = [];
|
|
103
|
+
for (const block of toolBlocks) {
|
|
104
|
+
const name = block.attrs["name"];
|
|
105
|
+
if (typeof name !== "string")
|
|
106
|
+
continue;
|
|
107
|
+
const { reasons, unmappedRequired } = staleRunAutomationMappings(block, resources);
|
|
108
|
+
if (reasons.length === 0)
|
|
109
|
+
continue;
|
|
110
|
+
staleByName.set(name, reasons);
|
|
111
|
+
reimportForLive.push(`${block.type}.${block.label}`);
|
|
112
|
+
const autoRef = block.attrs["automation_id"];
|
|
113
|
+
if (unmappedRequired && isTfExpr(autoRef) && autoRef.$expr === "resource-attr") {
|
|
114
|
+
if (resources.some((resource) => resource.type === ON_DEMAND_TRIGGER_RESOURCE_TYPE && resource.label === autoRef.label)) {
|
|
115
|
+
reimportForLive.push(`${ON_DEMAND_TRIGGER_RESOURCE_TYPE}.${autoRef.label}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
tools: tools.map((tool) => {
|
|
121
|
+
const reasons = tool.typeKey === "executeWorkflow" ? staleByName.get(tool.name) : undefined;
|
|
122
|
+
return reasons === undefined ? tool : { ...tool, staleMappings: reasons };
|
|
123
|
+
}),
|
|
124
|
+
reimportForLive,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
42
127
|
function extractAgents(ownBlocks, stream, ctx) {
|
|
43
128
|
const toolBlocks = stream.byKind.get("agent-tool") ?? [];
|
|
44
129
|
const a2aSkillBlocks = stream.byKind.get("agent-a2a-skill") ?? [];
|
|
45
130
|
const items = [];
|
|
46
131
|
const skipped = [];
|
|
47
132
|
const diagnostics = [];
|
|
133
|
+
const reimportForLive = [];
|
|
48
134
|
for (const agentBlock of ownBlocks) {
|
|
49
135
|
const agentLabel = agentBlock.label ?? "";
|
|
50
136
|
const ownsBlock = (b) => {
|
|
@@ -54,14 +140,20 @@ function extractAgents(ownBlocks, stream, ctx) {
|
|
|
54
140
|
const ownTools = toolBlocks.filter(ownsBlock);
|
|
55
141
|
const ownA2ASkills = a2aSkillBlocks.filter(ownsBlock);
|
|
56
142
|
const { agent, skippedReason } = agentFromTf(agentBlock, ownTools, ctx.appTfLabel, ctx.appRefName, ctx, ownA2ASkills);
|
|
57
|
-
if (agent !== undefined)
|
|
58
|
-
|
|
143
|
+
if (agent !== undefined) {
|
|
144
|
+
const marked = withStaleMappings(agent.tools, ownTools, stream.allResources);
|
|
145
|
+
items.push({ ...agent, tools: marked.tools });
|
|
146
|
+
reimportForLive.push(...marked.reimportForLive);
|
|
147
|
+
// edk#3151: an agent tool on a skipped automation is left out like a skill's.
|
|
148
|
+
for (const tool of ownTools)
|
|
149
|
+
requireRunAutomationTarget(tool, { kind: "agent", refName: agent.refName }, ctx);
|
|
150
|
+
}
|
|
59
151
|
else if (skippedReason !== undefined) {
|
|
60
152
|
skipped.push(`${AGENT_RESOURCE_TYPE}.${agentLabel}`);
|
|
61
153
|
diagnostics.push(skippedReason);
|
|
62
154
|
}
|
|
63
155
|
}
|
|
64
|
-
return { items, skipped, diagnostics };
|
|
156
|
+
return { items, skipped, diagnostics, reimportForLive };
|
|
65
157
|
}
|
|
66
158
|
export const agentModule = {
|
|
67
159
|
kind: "agent",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { typedCoverageGap } from "../../engine/coverage-gaps.js";
|
|
19
19
|
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
20
20
|
import { filterToTf } from "../access-policy/to-tf.js";
|
|
21
|
-
import {
|
|
21
|
+
import { fieldRefToTfValue, siblingFieldOwnership } from "../field/to-tf.js";
|
|
22
22
|
import { EntityTfError } from "../../engine/entity.js";
|
|
23
23
|
import { appScopedResourceLabel, expr, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
24
24
|
import { a2aSkillToTf } from "../agent-a2a-skill/to-tf.js";
|
|
@@ -383,7 +383,9 @@ function dropdownAspect(token, kind, where, ctx) {
|
|
|
383
383
|
return {
|
|
384
384
|
value: expr.resourceAttr(APP_RESOURCE_TYPE, ctx.appTfLabel, ["id"]),
|
|
385
385
|
localTfLabel: ctx.appTfLabel,
|
|
386
|
-
|
|
386
|
+
// The address each field's own build gives it, whatever type the
|
|
387
|
+
// reference carries (#3088).
|
|
388
|
+
fieldOwnership: siblingFieldOwnership(self?.streamRootEntity?.payload, ctx.appTfLabel, "app"),
|
|
387
389
|
};
|
|
388
390
|
}
|
|
389
391
|
const sibling = ctx.workspaceAspects?.get(workspaceAspectKey(kind, refName));
|
|
@@ -392,7 +394,7 @@ function dropdownAspect(token, kind, where, ctx) {
|
|
|
392
394
|
return {
|
|
393
395
|
value: expr.resourceAttr(resourceType, sibling.tfLabel, ["id"]),
|
|
394
396
|
localTfLabel: sibling.tfLabel,
|
|
395
|
-
fieldOwnership:
|
|
397
|
+
fieldOwnership: siblingFieldOwnership(sibling.streamRootEntity?.payload, sibling.tfLabel, kind),
|
|
396
398
|
};
|
|
397
399
|
}
|
|
398
400
|
const name = token.name ?? refName;
|
|
@@ -416,7 +418,7 @@ function dropdownFieldValue(field, aspect, where, ctx) {
|
|
|
416
418
|
throw new EntityTfError(`${where}: field "${refName}" belongs to ${field.parentKind ?? "app"} "${field.parent}", not ${aspect.kind} "${aspect.refName}"`);
|
|
417
419
|
}
|
|
418
420
|
if (aspect.localTfLabel !== undefined) {
|
|
419
|
-
const value = fieldRefToTfValue(field.fieldType ?? "", refName, aspect.localTfLabel, aspect.kind, aspect.fieldOwnership);
|
|
421
|
+
const value = fieldRefToTfValue(field.fieldType ?? "", refName, aspect.localTfLabel, aspect.kind, aspect.fieldOwnership, undefined, field.name);
|
|
420
422
|
if (value === undefined) {
|
|
421
423
|
throw new EntityTfError(`${where}: field "${refName}" has no terraform address on ${aspect.kind} "${aspect.refName}"`);
|
|
422
424
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
2
2
|
import { type TfBlock } from "../../engine/tf/index.js";
|
|
3
|
+
import type { QuarantinedOwnFile } from "../../graph/types.js";
|
|
3
4
|
export interface NormalizedAgentEvaluation {
|
|
4
5
|
readonly refName: string;
|
|
5
6
|
readonly name: string;
|
|
@@ -7,6 +8,12 @@ export interface NormalizedAgentEvaluation {
|
|
|
7
8
|
readonly connectorKey: string;
|
|
8
9
|
readonly passingThreshold: number;
|
|
9
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* One agent evaluation block → its normalized shape; undefined = skipped. An
|
|
13
|
+
* evaluation written to no source is also left out of adoption, or released
|
|
14
|
+
* if state has it, and its earlier file is archived (edk#3172).
|
|
15
|
+
*/
|
|
10
16
|
export declare function agentEvaluationFromTf(block: TfBlock, opts: {
|
|
11
17
|
readonly appLabel: string;
|
|
18
|
+
readonly quarantineOwnFiles: QuarantinedOwnFile[];
|
|
12
19
|
}, ctx: FromTfContext): NormalizedAgentEvaluation | undefined;
|
|
@@ -2,6 +2,7 @@ import { dataRefLabel, resourceRefLabel, } from "../../engine/pull/context.js";
|
|
|
2
2
|
import { scopedLabelToBagKey } from "../../engine/tf/index.js";
|
|
3
3
|
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
4
4
|
import { connectorIdentityFromTf } from "../shared/connector-from-tf.js";
|
|
5
|
+
import { skipOwnFileAndRelease, unresolvedReferenceName } from "../shared/skip-release.js";
|
|
5
6
|
const KNOWN_ATTRS = new Set([
|
|
6
7
|
"app_id",
|
|
7
8
|
"name",
|
|
@@ -9,9 +10,19 @@ const KNOWN_ATTRS = new Set([
|
|
|
9
10
|
"ai_provider_connector_id",
|
|
10
11
|
"passing_threshold",
|
|
11
12
|
]);
|
|
13
|
+
/**
|
|
14
|
+
* One agent evaluation block → its normalized shape; undefined = skipped. An
|
|
15
|
+
* evaluation written to no source is also left out of adoption, or released
|
|
16
|
+
* if state has it, and its earlier file is archived (edk#3172).
|
|
17
|
+
*/
|
|
12
18
|
export function agentEvaluationFromTf(block, opts, ctx) {
|
|
13
19
|
const label = block.label ?? "";
|
|
14
20
|
const where = `agent evaluation "${label}"`;
|
|
21
|
+
const refName = scopedLabelToBagKey(opts.appLabel, label, "app");
|
|
22
|
+
const skip = (why, fallback) => {
|
|
23
|
+
skipOwnFileAndRelease(ctx, `${block.type}.${label}`, why, fallback, { kind: "agent-evaluation", refName }, opts.quarantineOwnFiles);
|
|
24
|
+
return undefined;
|
|
25
|
+
};
|
|
15
26
|
for (const key of Object.keys(block.attrs)) {
|
|
16
27
|
if (!KNOWN_ATTRS.has(key)) {
|
|
17
28
|
ctx.diagnostics.push(`${where}: unhandled attribute "${key}" — extend agentEvaluationFromTf deliberately`);
|
|
@@ -26,18 +37,16 @@ export function agentEvaluationFromTf(block, opts, ctx) {
|
|
|
26
37
|
? undefined
|
|
27
38
|
: connectorIdentityFromTf("elementum_ai_provider_connector", connectorLabel, ctx).catalogKey;
|
|
28
39
|
if (connectorLabel === undefined || connectorKey === undefined) {
|
|
29
|
-
|
|
30
|
-
return undefined;
|
|
40
|
+
return skip({ reference: unresolvedReferenceName(block.attrs["ai_provider_connector_id"], "ai_provider_connector_id") }, `${where}: ai_provider_connector_id is not a resolvable AI-service data reference; skipped`);
|
|
31
41
|
}
|
|
32
42
|
const name = block.attrs["name"];
|
|
33
43
|
const prompt = block.attrs["prompt"];
|
|
34
44
|
const passingThreshold = block.attrs["passing_threshold"];
|
|
35
45
|
if (typeof name !== "string" || typeof prompt !== "string" || typeof passingThreshold !== "number") {
|
|
36
|
-
|
|
37
|
-
return undefined;
|
|
46
|
+
return skip({ problem: "its name, prompt or passing_threshold is not a literal value" }, `${where}: name, prompt, and passing_threshold must be literal values; skipped`);
|
|
38
47
|
}
|
|
39
48
|
return {
|
|
40
|
-
refName
|
|
49
|
+
refName,
|
|
41
50
|
name,
|
|
42
51
|
prompt,
|
|
43
52
|
connectorKey,
|