@elementumai/edk 0.11.0 → 0.13.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/README.md +40 -6
- package/dist-sdk/src/catalog/factories.d.ts +7 -1
- package/dist-sdk/src/catalog/factories.js +2 -0
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/org.js +79 -34
- package/dist-sdk/src/catalog/token.js +5 -0
- package/dist-sdk/src/catalog/types.d.ts +7 -1
- package/dist-sdk/src/catalog/types.js +3 -0
- package/dist-sdk/src/core/system-fields.d.ts +1 -1
- package/dist-sdk/src/core/system-fields.js +1 -1
- package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -0
- package/dist-sdk/src/core/triggers/on-demand.js +3 -0
- package/dist-sdk/src/core/types/app.d.ts +6 -0
- package/dist-sdk/src/engine/build/context.d.ts +3 -0
- package/dist-sdk/src/engine/coverage-gaps.d.ts +5 -0
- package/dist-sdk/src/engine/coverage-gaps.js +9 -0
- package/dist-sdk/src/engine/ei/run.d.ts +20 -1
- package/dist-sdk/src/engine/ei/run.js +102 -14
- package/dist-sdk/src/engine/pull/authored-address.js +42 -6
- package/dist-sdk/src/engine/pull/authored-root.d.ts +88 -0
- package/dist-sdk/src/engine/pull/authored-root.js +306 -0
- package/dist-sdk/src/engine/pull/context.d.ts +10 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.d.ts +114 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.js +501 -0
- package/dist-sdk/src/engine/pull/org.d.ts +1 -0
- package/dist-sdk/src/engine/pull/org.js +2 -0
- package/dist-sdk/src/engine/pull/partition.d.ts +8 -0
- package/dist-sdk/src/engine/pull/partition.js +43 -0
- package/dist-sdk/src/engine/pull/pulled-roots.d.ts +89 -0
- package/dist-sdk/src/engine/pull/pulled-roots.js +203 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +22 -0
- package/dist-sdk/src/engine/pull/ref-only.js +59 -1
- package/dist-sdk/src/engine/pull/source-resources.d.ts +39 -0
- package/dist-sdk/src/engine/pull/source-resources.js +110 -0
- package/dist-sdk/src/engine/pull/stream-root.d.ts +148 -0
- package/dist-sdk/src/engine/pull/stream-root.js +563 -0
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.d.ts +47 -0
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.js +115 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +2 -1
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +9 -1
- package/dist-sdk/src/entities/access-policy/from-tf.js +25 -4
- package/dist-sdk/src/entities/access-policy/module.js +5 -0
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +19 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +65 -8
- package/dist-sdk/src/entities/agent/build.d.ts +52 -1
- package/dist-sdk/src/entities/agent/build.js +34 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +68 -0
- package/dist-sdk/src/entities/agent/from-tf.d.ts +34 -1
- package/dist-sdk/src/entities/agent/from-tf.js +262 -2
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/to-tf.d.ts +8 -10
- package/dist-sdk/src/entities/agent/to-tf.js +158 -14
- package/dist-sdk/src/entities/agent-tool/from-tf.js +6 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -2
- package/dist-sdk/src/entities/app/build.d.ts +34 -14
- package/dist-sdk/src/entities/app/build.js +93 -16
- package/dist-sdk/src/entities/app/from-tf.js +25 -11
- package/dist-sdk/src/entities/app/index.d.ts +1 -0
- package/dist-sdk/src/entities/app/index.js +1 -0
- package/dist-sdk/src/entities/app/module.js +1 -0
- package/dist-sdk/src/entities/app/stage-keys.d.ts +20 -5
- package/dist-sdk/src/entities/app/stage-keys.js +43 -9
- package/dist-sdk/src/entities/app/to-tf.js +2 -0
- package/dist-sdk/src/entities/approval-chain/build.d.ts +46 -11
- package/dist-sdk/src/entities/approval-chain/build.js +120 -8
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +24 -2
- package/dist-sdk/src/entities/approval-chain/from-tf.js +148 -6
- package/dist-sdk/src/entities/approval-chain/index.d.ts +4 -1
- package/dist-sdk/src/entities/approval-chain/index.js +4 -1
- package/dist-sdk/src/entities/approval-chain/module.js +23 -5
- package/dist-sdk/src/entities/approval-chain/printer.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/printer.js +91 -5
- package/dist-sdk/src/entities/approval-chain/steps-tf.d.ts +77 -0
- package/dist-sdk/src/entities/approval-chain/steps-tf.js +255 -0
- package/dist-sdk/src/entities/approval-chain/steps.d.ts +71 -0
- package/dist-sdk/src/entities/approval-chain/steps.js +83 -0
- package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +16 -6
- package/dist-sdk/src/entities/approval-chain/to-tf.js +37 -4
- package/dist-sdk/src/entities/automation/build.d.ts +50 -24
- package/dist-sdk/src/entities/automation/build.js +86 -33
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +52 -8
- package/dist-sdk/src/entities/automation/from-tf.d.ts +38 -6
- package/dist-sdk/src/entities/automation/from-tf.js +855 -157
- package/dist-sdk/src/entities/automation/index.d.ts +2 -1
- package/dist-sdk/src/entities/automation/index.js +1 -0
- package/dist-sdk/src/entities/automation/module.d.ts +4 -3
- package/dist-sdk/src/entities/automation/module.js +33 -12
- package/dist-sdk/src/entities/automation/refs-read.d.ts +19 -0
- package/dist-sdk/src/entities/automation/refs-read.js +48 -0
- package/dist-sdk/src/entities/automation/run-target.d.ts +2 -0
- package/dist-sdk/src/entities/automation/run-target.js +5 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +2 -1
- package/dist-sdk/src/entities/automation/script-code.js +82 -1
- package/dist-sdk/src/entities/automation/script-lint.d.ts +13 -0
- package/dist-sdk/src/entities/automation/script-lint.js +418 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.d.ts +9 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.js +75 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +12 -1
- package/dist-sdk/src/entities/automation/task-output-labels.js +32 -1
- package/dist-sdk/src/entities/automation/tasks.d.ts +76 -18
- package/dist-sdk/src/entities/automation/tasks.js +52 -15
- package/dist-sdk/src/entities/automation/to-tf.d.ts +3 -0
- package/dist-sdk/src/entities/automation/to-tf.js +585 -97
- package/dist-sdk/src/entities/automation/triggers.d.ts +48 -23
- package/dist-sdk/src/entities/automation/triggers.js +27 -12
- package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +50 -0
- package/dist-sdk/src/entities/automation/unsafe-script-output.js +92 -0
- package/dist-sdk/src/entities/chart/build.d.ts +18 -2
- package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
- package/dist-sdk/src/entities/chart/from-tf.js +28 -1
- package/dist-sdk/src/entities/chart/index.d.ts +1 -1
- package/dist-sdk/src/entities/chart/printer.js +5 -2
- package/dist-sdk/src/entities/chart/to-tf.js +38 -3
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/condition-keys.d.ts +48 -0
- package/dist-sdk/src/entities/dynamic-layout/condition-keys.js +261 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +45 -6
- package/dist-sdk/src/entities/dynamic-layout/module.js +2 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +46 -12
- package/dist-sdk/src/entities/element/audit-field-guard.d.ts +9 -0
- package/dist-sdk/src/entities/element/audit-field-guard.js +88 -0
- package/dist-sdk/src/entities/element/build.js +2 -1
- package/dist-sdk/src/entities/element/from-tf.js +15 -2
- package/dist-sdk/src/entities/element/module.js +3 -0
- package/dist-sdk/src/entities/element/system-fields.d.ts +13 -0
- package/dist-sdk/src/entities/element/system-fields.js +23 -0
- package/dist-sdk/src/entities/element/to-tf.js +2 -0
- package/dist-sdk/src/entities/field/build.d.ts +9 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +29 -1
- package/dist-sdk/src/entities/field/from-tf.js +99 -6
- package/dist-sdk/src/entities/field/module.js +12 -2
- package/dist-sdk/src/entities/field/to-tf.d.ts +13 -3
- package/dist-sdk/src/entities/field/to-tf.js +90 -46
- package/dist-sdk/src/entities/org/category.js +1 -0
- package/dist-sdk/src/entities/org/index.d.ts +1 -0
- package/dist-sdk/src/entities/org/index.js +1 -0
- package/dist-sdk/src/entities/org/role.js +5 -0
- package/dist-sdk/src/entities/org/voice-auth.d.ts +5 -0
- package/dist-sdk/src/entities/org/voice-auth.js +33 -0
- package/dist-sdk/src/entities/organization/build.d.ts +3 -0
- package/dist-sdk/src/entities/organization/build.js +2 -0
- package/dist-sdk/src/entities/organization/index.d.ts +1 -0
- package/dist-sdk/src/entities/organization/index.js +1 -0
- package/dist-sdk/src/entities/organization/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/organization/to-tf.js +59 -1
- package/dist-sdk/src/entities/organization/voice-auth.d.ts +60 -0
- package/dist-sdk/src/entities/organization/voice-auth.js +60 -0
- package/dist-sdk/src/entities/phone-service/build.d.ts +9 -1
- package/dist-sdk/src/entities/phone-service/build.js +1 -0
- package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +3 -0
- package/dist-sdk/src/entities/phone-service/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/phone-service/from-tf.js +8 -1
- package/dist-sdk/src/entities/phone-service/to-tf.js +16 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +2 -2
- package/dist-sdk/src/entities/relationship/from-tf.js +7 -2
- package/dist-sdk/src/entities/relationship/module.js +2 -2
- package/dist-sdk/src/entities/relationship/pair-check.d.ts +6 -2
- package/dist-sdk/src/entities/relationship/pair-check.js +105 -18
- package/dist-sdk/src/entities/relationship/to-tf.js +5 -2
- package/dist-sdk/src/entities/role/permission-levels.d.ts +7 -0
- package/dist-sdk/src/entities/role/permission-levels.js +78 -0
- package/dist-sdk/src/entities/role/to-tf.js +32 -2
- package/dist-sdk/src/entities/service-account/module.d.ts +2 -1
- package/dist-sdk/src/entities/service-account/module.js +9 -1
- package/dist-sdk/src/entities/service-account/resource-type.d.ts +2 -0
- package/dist-sdk/src/entities/service-account/resource-type.js +2 -0
- package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +5 -5
- package/dist-sdk/src/entities/service-account/role-fidelity.js +21 -13
- package/dist-sdk/src/entities/service-account/role-membership-check.d.ts +20 -0
- package/dist-sdk/src/entities/service-account/role-membership-check.js +80 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +15 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +36 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +4 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +85 -14
- package/dist-sdk/src/entities/shared/filters/index.js +18 -6
- package/dist-sdk/src/entities/shared/filters/option-lookups.d.ts +57 -0
- package/dist-sdk/src/entities/shared/filters/option-lookups.js +108 -0
- package/dist-sdk/src/entities/shared/filters/print.js +9 -5
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +12 -7
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +9 -5
- package/dist-sdk/src/entities/shared/raw-option-id.d.ts +30 -0
- package/dist-sdk/src/entities/shared/raw-option-id.js +41 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -3
- package/dist-sdk/src/entities/shared/types/field-types.js +3 -1
- package/dist-sdk/src/entities/skill/input-coverage.js +5 -2
- package/dist-sdk/src/entities/skill/module.js +2 -0
- package/dist-sdk/src/entities/sla/build.d.ts +96 -0
- package/dist-sdk/src/entities/sla/build.js +124 -0
- package/dist-sdk/src/entities/sla/from-tf.d.ts +40 -0
- package/dist-sdk/src/entities/sla/from-tf.js +164 -0
- package/dist-sdk/src/entities/sla/index.d.ts +1 -0
- package/dist-sdk/src/entities/sla/index.js +1 -0
- package/dist-sdk/src/entities/sla/module.d.ts +4 -0
- package/dist-sdk/src/entities/sla/module.js +73 -0
- package/dist-sdk/src/entities/sla/printer.d.ts +2 -0
- package/dist-sdk/src/entities/sla/printer.js +84 -0
- package/dist-sdk/src/entities/sla/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/sla/to-tf.js +81 -0
- package/dist-sdk/src/entities/table/build.d.ts +7 -2
- package/dist-sdk/src/entities/table/build.js +22 -1
- package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +4 -1
- package/dist-sdk/src/entities/table/from-tf.js +89 -14
- package/dist-sdk/src/entities/table/index.d.ts +1 -1
- package/dist-sdk/src/entities/table/to-tf.js +41 -2
- package/dist-sdk/src/entities/task/from-tf.js +2 -1
- package/dist-sdk/src/entities/task/to-tf.js +1 -0
- package/dist-sdk/src/entities/view/from-tf.d.ts +8 -4
- package/dist-sdk/src/entities/view/from-tf.js +10 -9
- package/dist-sdk/src/entities/view/module.js +5 -0
- package/dist-sdk/src/entities/widget/from-tf.js +15 -4
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +51 -4
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +20 -2
- package/dist-sdk/src/graph/index.js +19 -0
- package/dist-sdk/src/graph/modules.js +11 -1
- package/dist-sdk/src/graph/resource-types.d.ts +47 -0
- package/dist-sdk/src/graph/resource-types.js +62 -0
- package/dist-sdk/src/graph/types.d.ts +116 -6
- package/package.json +6 -3
|
@@ -10,6 +10,8 @@ import { type FromTfContext } from "../../engine/pull/context.js";
|
|
|
10
10
|
import { type TfBlock } from "../../engine/tf/index.js";
|
|
11
11
|
import { type NormalizedA2ASkill } from "../agent-a2a-skill/from-tf.js";
|
|
12
12
|
import { type NormalizedAgentTool } from "../agent-tool/from-tf.js";
|
|
13
|
+
import type { RefExpr } from "../shared/filters/ast.js";
|
|
14
|
+
import type { Filter } from "../shared/filters/types.js";
|
|
13
15
|
import type { AgentAuthentication, AgentStartingAction } from "./build.js";
|
|
14
16
|
import type { AgentToolRunAs } from "./tools.js";
|
|
15
17
|
/**
|
|
@@ -57,6 +59,7 @@ export interface NormalizedAgent {
|
|
|
57
59
|
readonly a2aStreaming?: boolean;
|
|
58
60
|
readonly a2aCreateRecordEnabled?: boolean;
|
|
59
61
|
readonly startingActions?: readonly AgentStartingAction[];
|
|
62
|
+
readonly systemSkillsConfig?: NormalizedSystemSkillsConfig;
|
|
60
63
|
readonly tools: readonly NormalizedAgentTool[];
|
|
61
64
|
readonly a2aSkills?: readonly NormalizedA2ASkill[];
|
|
62
65
|
}
|
|
@@ -71,4 +74,34 @@ export interface AgentFromTfResult {
|
|
|
71
74
|
* diagnostic (the caller partitions per-agent by agent_id, but stays
|
|
72
75
|
* defensive).
|
|
73
76
|
*/
|
|
74
|
-
export declare function agentFromTf(agentBlock: TfBlock, toolBlocks: readonly TfBlock[], appLabel: string,
|
|
77
|
+
export declare function agentFromTf(agentBlock: TfBlock, toolBlocks: readonly TfBlock[], appLabel: string, appRefName: string, ctx: FromTfContext, a2aSkillBlocks?: readonly TfBlock[]): AgentFromTfResult;
|
|
78
|
+
export interface NormalizedDropdownOwner {
|
|
79
|
+
readonly kind: "app" | "element";
|
|
80
|
+
readonly refName: string;
|
|
81
|
+
/** Display name. A cross-org clone prints this instead of the catalog key. */
|
|
82
|
+
readonly name?: string;
|
|
83
|
+
/** This agent's owning app. The printer uses the pull's app refName. */
|
|
84
|
+
readonly self?: boolean;
|
|
85
|
+
}
|
|
86
|
+
export interface NormalizedDynamicDropdown {
|
|
87
|
+
readonly owner: NormalizedDropdownOwner;
|
|
88
|
+
readonly fieldKey: string;
|
|
89
|
+
/** Platform display name (`field` on the wire). */
|
|
90
|
+
readonly fieldName: string;
|
|
91
|
+
/** Set when the stored name is not the field's name in this export. */
|
|
92
|
+
readonly storedFieldName?: string;
|
|
93
|
+
readonly multiple: boolean;
|
|
94
|
+
/** Present when the dropdown limits its records. */
|
|
95
|
+
readonly filter?: Filter<RefExpr, RefExpr>;
|
|
96
|
+
}
|
|
97
|
+
export interface NormalizedSystemSkill {
|
|
98
|
+
readonly enabled: boolean;
|
|
99
|
+
readonly description?: string;
|
|
100
|
+
}
|
|
101
|
+
export interface NormalizedAskUserQuestion extends NormalizedSystemSkill {
|
|
102
|
+
readonly dynamicDropdowns?: readonly NormalizedDynamicDropdown[];
|
|
103
|
+
}
|
|
104
|
+
export interface NormalizedSystemSkillsConfig {
|
|
105
|
+
readonly askUserQuestion?: NormalizedAskUserQuestion;
|
|
106
|
+
readonly approvals?: NormalizedSystemSkill;
|
|
107
|
+
}
|
|
@@ -9,11 +9,14 @@
|
|
|
9
9
|
import { typedCoverageGap } from "../../engine/coverage-gaps.js";
|
|
10
10
|
import { EntityTfError } from "../../engine/entity.js";
|
|
11
11
|
import { dataRefLabel, optionalBoolean, optionalString, ownerMismatchBlocker, plainObject, reportAuthoringBlocker, resourceRefLabel } from "../../engine/pull/context.js";
|
|
12
|
-
import { appScopedResourceLabel, exportLabelSuffix, isTfExpr, isUuid, scopedLabelToBagKey, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
12
|
+
import { appScopedResourceLabel, exportLabelSuffix, isTfExpr, isUuid, sanitizeName, scopedLabelToBagKey, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
13
|
+
import { filterFromTf } from "../access-policy/from-tf.js";
|
|
13
14
|
import { a2aSkillFromTf } from "../agent-a2a-skill/from-tf.js";
|
|
14
15
|
import { toolFromTf } from "../agent-tool/from-tf.js";
|
|
15
16
|
import { agentToolBareLabel } from "../agent-tool/to-tf.js";
|
|
17
|
+
import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
|
|
16
18
|
import { connectorIdentityFromTf } from "../shared/connector-from-tf.js";
|
|
19
|
+
import { resolveToolFieldKey } from "../shared/tool-field-ref.js";
|
|
17
20
|
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
18
21
|
import { SKILL_RESOURCE_TYPE } from "../skill/module.js";
|
|
19
22
|
import { AGENT_RESOURCE_TYPE } from "./module.js";
|
|
@@ -36,6 +39,7 @@ const KNOWN_AGENT_ATTRS = new Set([
|
|
|
36
39
|
"type",
|
|
37
40
|
"bedrock_agent_arn",
|
|
38
41
|
"starting_actions",
|
|
42
|
+
"system_skills_config",
|
|
39
43
|
]);
|
|
40
44
|
/** Dialect attrs with no authoring slot yet — reported by name, agent still pulled. */
|
|
41
45
|
const UNAUTHORABLE_AGENT_ATTRS = new Set(["model"]);
|
|
@@ -362,7 +366,7 @@ function parseSkillAccessConfig(value, where, ownerTfLabel, ctx) {
|
|
|
362
366
|
* diagnostic (the caller partitions per-agent by agent_id, but stays
|
|
363
367
|
* defensive).
|
|
364
368
|
*/
|
|
365
|
-
export function agentFromTf(agentBlock, toolBlocks, appLabel,
|
|
369
|
+
export function agentFromTf(agentBlock, toolBlocks, appLabel, appRefName, ctx, a2aSkillBlocks = []) {
|
|
366
370
|
const label = agentBlock.label;
|
|
367
371
|
if (label === undefined || label === "") {
|
|
368
372
|
throw new EntityTfError("elementum_agent block is missing its label");
|
|
@@ -419,6 +423,9 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx,
|
|
|
419
423
|
if (attrs["starting_actions"] !== undefined) {
|
|
420
424
|
ctx.diagnostics.push(`${where}: starting_actions has no authoring slot on bedrock agents yet; a rebuilt stream will omit it`);
|
|
421
425
|
}
|
|
426
|
+
if (attrs["system_skills_config"] !== undefined) {
|
|
427
|
+
ctx.diagnostics.push(`${where}: system_skills_config is only authored on elementum agents; a rebuilt stream will omit it`);
|
|
428
|
+
}
|
|
422
429
|
return {
|
|
423
430
|
agent: {
|
|
424
431
|
refName: scopedLabelToBagKey(appLabel, label),
|
|
@@ -474,6 +481,9 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx,
|
|
|
474
481
|
const a2aStreaming = optionalBoolean(attrs, "a2a_streaming", where, ctx);
|
|
475
482
|
const a2aCreateRecordEnabled = optionalBoolean(attrs, "a2a_create_record_enabled", where, ctx);
|
|
476
483
|
const startingActions = attrs["starting_actions"] === undefined ? undefined : parseStartingActions(attrs["starting_actions"], where, ctx);
|
|
484
|
+
const systemSkillsConfig = attrs["system_skills_config"] === undefined
|
|
485
|
+
? undefined
|
|
486
|
+
: parseSystemSkillsConfig(attrs["system_skills_config"], where, `${AGENT_RESOURCE_TYPE}.${label}`, appLabel, appRefName, ctx);
|
|
477
487
|
const firstMessage = optionalString(attrs, "first_message", where, ctx);
|
|
478
488
|
const maxTokens = attrs["max_tokens"];
|
|
479
489
|
const maxLength = typeof maxTokens === "number" && Number.isSafeInteger(maxTokens) && maxTokens > 0
|
|
@@ -498,8 +508,258 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx,
|
|
|
498
508
|
...(a2aStreaming !== undefined && { a2aStreaming }),
|
|
499
509
|
...(a2aCreateRecordEnabled !== undefined && { a2aCreateRecordEnabled }),
|
|
500
510
|
...(startingActions !== undefined && { startingActions }),
|
|
511
|
+
...(systemSkillsConfig !== undefined && { systemSkillsConfig }),
|
|
501
512
|
tools,
|
|
502
513
|
...(a2aSkills.length > 0 && { a2aSkills }),
|
|
503
514
|
},
|
|
504
515
|
};
|
|
505
516
|
}
|
|
517
|
+
function blockUnresolvableId(ctx, address, description) {
|
|
518
|
+
reportAuthoringBlocker(ctx, {
|
|
519
|
+
address,
|
|
520
|
+
description,
|
|
521
|
+
remedy: "Point each dynamic dropdown at an app or element and a field this export resolved to a reference, then pull again.",
|
|
522
|
+
ownFileKind: "agent",
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
function catalogRefForResourceLabel(label, kind, ctx) {
|
|
526
|
+
const byNamespace = kind === "app" ? ctx.foreignAppRefNamespaces : ctx.foreignElementRefNamespaces;
|
|
527
|
+
if (byNamespace === undefined)
|
|
528
|
+
return undefined;
|
|
529
|
+
const direct = byNamespace.get(label);
|
|
530
|
+
if (direct !== undefined)
|
|
531
|
+
return direct;
|
|
532
|
+
const matches = [...new Set([...byNamespace.entries()].filter(([namespace]) => sanitizeName(namespace) === label).map(([, refName]) => refName))];
|
|
533
|
+
return matches.length === 1 ? matches[0] : undefined;
|
|
534
|
+
}
|
|
535
|
+
function dropdownOwnerFromValue(value, appLabel, address, where, ctx) {
|
|
536
|
+
if (value === undefined) {
|
|
537
|
+
blockUnresolvableId(ctx, address, `${where}: aspect_id is missing, so pull cannot reproduce this dynamic dropdown.`);
|
|
538
|
+
return undefined;
|
|
539
|
+
}
|
|
540
|
+
if (resourceRefLabel(value, APP_RESOURCE_TYPE) === appLabel) {
|
|
541
|
+
return { owner: { kind: "app", refName: "", self: true }, fieldScopeLabel: appLabel, fieldScope: "app" };
|
|
542
|
+
}
|
|
543
|
+
for (const [type, kind] of [["elementum_app", "app"], ["elementum_element", "element"]]) {
|
|
544
|
+
const resourceLabel = resourceRefLabel(value, type);
|
|
545
|
+
if (resourceLabel === undefined)
|
|
546
|
+
continue;
|
|
547
|
+
const refName = catalogRefForResourceLabel(resourceLabel, kind, ctx);
|
|
548
|
+
if (refName === undefined) {
|
|
549
|
+
blockUnresolvableId(ctx, address, `${where}: aspect_id references ${type}.${resourceLabel}, which is not an app or element in this workspace.`);
|
|
550
|
+
return undefined;
|
|
551
|
+
}
|
|
552
|
+
const name = importedAspectName(ctx, kind, resourceLabel);
|
|
553
|
+
return {
|
|
554
|
+
owner: { kind, refName, ...(name !== undefined ? { name } : {}) },
|
|
555
|
+
fieldScopeLabel: resourceLabel,
|
|
556
|
+
fieldScope: kind,
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
if (isTfExpr(value) && value.$expr === "data-attr" && (value.type === "elementum_app" || value.type === "elementum_element")) {
|
|
560
|
+
const kind = value.type === "elementum_element" ? "element" : "app";
|
|
561
|
+
const target = resolveDataAspectTarget(ctx, kind, value.label);
|
|
562
|
+
if (target.catalogRef !== true) {
|
|
563
|
+
blockUnresolvableId(ctx, address, `${where}: aspect_id references data.${value.type}.${value.label}, which pull cannot name.`);
|
|
564
|
+
return undefined;
|
|
565
|
+
}
|
|
566
|
+
return {
|
|
567
|
+
owner: { kind, refName: target.key, ...(target.name !== "" ? { name: target.name } : {}) },
|
|
568
|
+
fieldScopeLabel: value.label,
|
|
569
|
+
fieldScope: kind,
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
const shown = typeof value === "string" ? value : JSON.stringify(value);
|
|
573
|
+
blockUnresolvableId(ctx, address, `${where}: aspect_id ${shown} is not a reference to an app or element.`);
|
|
574
|
+
return undefined;
|
|
575
|
+
}
|
|
576
|
+
function parseSystemSkillsConfig(value, where, address, appLabel, appRefName, ctx) {
|
|
577
|
+
const rec = plainObject(value);
|
|
578
|
+
if (rec === undefined) {
|
|
579
|
+
blockUnresolvableId(ctx, address, `${where}: system_skills_config has an unrecognized shape, so pull cannot reproduce it.`);
|
|
580
|
+
return undefined;
|
|
581
|
+
}
|
|
582
|
+
const ask = rec["ask_user_question"] === undefined
|
|
583
|
+
? undefined
|
|
584
|
+
: parseAskUserQuestion(rec["ask_user_question"], `${where} ask_user_question`, address, appLabel, appRefName, ctx);
|
|
585
|
+
const approvals = rec["approvals"] === undefined
|
|
586
|
+
? undefined
|
|
587
|
+
: parseSystemSkill(rec["approvals"], `${where} approvals`, address, ctx);
|
|
588
|
+
if (ask === null || approvals === null)
|
|
589
|
+
return undefined;
|
|
590
|
+
if (ask === undefined && approvals === undefined)
|
|
591
|
+
return undefined;
|
|
592
|
+
return {
|
|
593
|
+
...(ask !== undefined ? { askUserQuestion: ask } : {}),
|
|
594
|
+
...(approvals !== undefined ? { approvals } : {}),
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
function parseSystemSkill(value, where, address, ctx) {
|
|
598
|
+
const rec = plainObject(value);
|
|
599
|
+
if (rec === undefined) {
|
|
600
|
+
blockUnresolvableId(ctx, address, `${where} has an unrecognized shape, so pull cannot reproduce it.`);
|
|
601
|
+
return null;
|
|
602
|
+
}
|
|
603
|
+
if (typeof rec["enabled"] !== "boolean") {
|
|
604
|
+
blockUnresolvableId(ctx, address, `${where}.enabled is missing, so pull cannot reproduce it.`);
|
|
605
|
+
return null;
|
|
606
|
+
}
|
|
607
|
+
const description = typeof rec["description"] === "string" ? rec["description"] : undefined;
|
|
608
|
+
return { enabled: rec["enabled"], ...(description !== undefined ? { description } : {}) };
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* The field's name in this export. A resource block and a
|
|
612
|
+
* `data.elementum_field` lookup both carry it; a system-field local does not.
|
|
613
|
+
* This is the name the same pull writes into the catalog, including a
|
|
614
|
+
* `--no-adopt` pull whose name index still has the pre-rename name.
|
|
615
|
+
*/
|
|
616
|
+
function exportedDropdownFieldName(fieldRef, ctx) {
|
|
617
|
+
if (fieldRef === undefined || !isTfExpr(fieldRef))
|
|
618
|
+
return undefined;
|
|
619
|
+
if (fieldRef.$expr === "resource-attr") {
|
|
620
|
+
const name = ctx.resourceByAddress?.(`${fieldRef.type}.${fieldRef.label}`)?.attrs["name"];
|
|
621
|
+
return typeof name === "string" && name !== "" ? name : undefined;
|
|
622
|
+
}
|
|
623
|
+
if (fieldRef.$expr === "data-attr" && fieldRef.type === "elementum_field") {
|
|
624
|
+
const name = ctx.dataAttrs?.("elementum_field", fieldRef.label)?.["name"];
|
|
625
|
+
return typeof name === "string" && name !== "" ? name : undefined;
|
|
626
|
+
}
|
|
627
|
+
return undefined;
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* True when build would send `storedName` anyway. The name in this export
|
|
631
|
+
* wins, compared exactly, so a case-only rename still prints `fieldName`.
|
|
632
|
+
* The name index is the fallback for a field with no name in the export.
|
|
633
|
+
* An owning-app dropdown stores its ref as `""`; looking that key up misses
|
|
634
|
+
* and must not count as a difference.
|
|
635
|
+
*/
|
|
636
|
+
function storedNameIsCurrentDisplay(storedName, fieldKey, fieldRef, ownerRefName, ctx) {
|
|
637
|
+
const exported = exportedDropdownFieldName(fieldRef, ctx);
|
|
638
|
+
if (exported !== undefined)
|
|
639
|
+
return exported === storedName;
|
|
640
|
+
if (ownerRefName === "")
|
|
641
|
+
return true;
|
|
642
|
+
return ctx.fieldNamesByOwnerRefName?.get(ownerRefName)?.get(storedName.toLowerCase()) === fieldKey;
|
|
643
|
+
}
|
|
644
|
+
function unresolvedFilterId(value) {
|
|
645
|
+
if (value === null || typeof value !== "object")
|
|
646
|
+
return undefined;
|
|
647
|
+
if (Array.isArray(value)) {
|
|
648
|
+
for (const item of value) {
|
|
649
|
+
const found = unresolvedFilterId(item);
|
|
650
|
+
if (found !== undefined)
|
|
651
|
+
return found;
|
|
652
|
+
}
|
|
653
|
+
return undefined;
|
|
654
|
+
}
|
|
655
|
+
const record = value;
|
|
656
|
+
if (record.kind === "unresolved")
|
|
657
|
+
return typeof record.uuid === "string" ? record.uuid : "unknown";
|
|
658
|
+
for (const item of Object.values(record)) {
|
|
659
|
+
const found = unresolvedFilterId(item);
|
|
660
|
+
if (found !== undefined)
|
|
661
|
+
return found;
|
|
662
|
+
}
|
|
663
|
+
return undefined;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* A `data.elementum_field` label back to the dropdown aspect's field key.
|
|
667
|
+
* `resolveToolFieldKey` already reads the dropdown's own `field_id` in this
|
|
668
|
+
* shape; a filter field on the same aspect arrives the same way, and without
|
|
669
|
+
* this the shared codec throws and the whole agent is dropped.
|
|
670
|
+
*/
|
|
671
|
+
function dropdownFilterDataField(label, scope, ownerTfLabel, ownerRefName, ctx) {
|
|
672
|
+
const fieldKey = resolveToolFieldKey({ $expr: "data-attr", type: "elementum_field", label, path: ["id"] }, ownerTfLabel, scope, ctx);
|
|
673
|
+
return fieldKey === undefined ? undefined : { kind: "field", appHandle: ownerRefName, fieldKey };
|
|
674
|
+
}
|
|
675
|
+
/** A stored dropdown filter, or null when pull must stop rather than print a platform id. */
|
|
676
|
+
function dropdownFilterFromValue(value, scope, ownerTfLabel, ownerRefName, address, where, ctx) {
|
|
677
|
+
if (value === undefined)
|
|
678
|
+
return undefined;
|
|
679
|
+
let filter;
|
|
680
|
+
try {
|
|
681
|
+
filter = filterFromTf(value, {
|
|
682
|
+
type: scope === "element" ? "elementum_element" : "elementum_app",
|
|
683
|
+
label: ownerTfLabel,
|
|
684
|
+
ownerRefName,
|
|
685
|
+
ownerTfLabel,
|
|
686
|
+
scope,
|
|
687
|
+
foreignFieldRefsById: ctx.foreignFieldRefsById,
|
|
688
|
+
dataField: (label) => dropdownFilterDataField(label, scope, ownerTfLabel, ownerRefName, ctx),
|
|
689
|
+
}, `${where}.filter`, ctx, { optionLookupsAreIdentities: true });
|
|
690
|
+
}
|
|
691
|
+
catch (error) {
|
|
692
|
+
const message = error instanceof EntityTfError ? error.message : String(error);
|
|
693
|
+
blockUnresolvableId(ctx, address, `${where}.filter cannot be reproduced: ${message}`);
|
|
694
|
+
return null;
|
|
695
|
+
}
|
|
696
|
+
const unresolved = unresolvedFilterId(filter);
|
|
697
|
+
if (unresolved !== undefined) {
|
|
698
|
+
blockUnresolvableId(ctx, address, `${where}.filter field ${unresolved} is not a reference this export resolved, so pull cannot reproduce it.`);
|
|
699
|
+
return null;
|
|
700
|
+
}
|
|
701
|
+
return filter;
|
|
702
|
+
}
|
|
703
|
+
function parseAskUserQuestion(value, where, address, appLabel, appRefName, ctx) {
|
|
704
|
+
const skill = parseSystemSkill(value, where, address, ctx);
|
|
705
|
+
if (skill === null || skill === undefined)
|
|
706
|
+
return skill;
|
|
707
|
+
const rec = plainObject(value);
|
|
708
|
+
if (rec === undefined || rec["dynamic_dropdowns"] === undefined)
|
|
709
|
+
return skill;
|
|
710
|
+
if (!Array.isArray(rec["dynamic_dropdowns"])) {
|
|
711
|
+
blockUnresolvableId(ctx, address, `${where}.dynamic_dropdowns is not a list, so pull cannot reproduce it.`);
|
|
712
|
+
return null;
|
|
713
|
+
}
|
|
714
|
+
const dropdowns = [];
|
|
715
|
+
for (let i = 0; i < rec["dynamic_dropdowns"].length; i++) {
|
|
716
|
+
const item = rec["dynamic_dropdowns"][i];
|
|
717
|
+
if (item === undefined)
|
|
718
|
+
continue;
|
|
719
|
+
const rowWhere = `${where}.dynamic_dropdowns[${i}]`;
|
|
720
|
+
const row = plainObject(item);
|
|
721
|
+
if (row === undefined) {
|
|
722
|
+
blockUnresolvableId(ctx, address, `${rowWhere} has an unrecognized shape, so pull cannot reproduce it.`);
|
|
723
|
+
return null;
|
|
724
|
+
}
|
|
725
|
+
const owner = dropdownOwnerFromValue(row["aspect_id"], appLabel, address, rowWhere, ctx);
|
|
726
|
+
if (owner === undefined)
|
|
727
|
+
return null;
|
|
728
|
+
const fieldKey = resolveToolFieldKey(row["field_id"], owner.fieldScopeLabel, owner.fieldScope, ctx);
|
|
729
|
+
if (fieldKey === undefined) {
|
|
730
|
+
const shown = typeof row["field_id"] === "string" ? row["field_id"] : JSON.stringify(row["field_id"]);
|
|
731
|
+
blockUnresolvableId(ctx, address, `${rowWhere}.field_id ${shown} is not a reference to a field of that app or element, so pull cannot reproduce it.`);
|
|
732
|
+
return null;
|
|
733
|
+
}
|
|
734
|
+
if (typeof row["multiple"] !== "boolean" || typeof row["field"] !== "string" || row["field"] === "") {
|
|
735
|
+
blockUnresolvableId(ctx, address, `${rowWhere} is missing field or multiple, so pull cannot reproduce it.`);
|
|
736
|
+
return null;
|
|
737
|
+
}
|
|
738
|
+
if (isUuid(row["field"])) {
|
|
739
|
+
blockUnresolvableId(ctx, address, `${rowWhere}.field is a platform id, so pull cannot reproduce it.`);
|
|
740
|
+
return null;
|
|
741
|
+
}
|
|
742
|
+
const storedName = row["field"];
|
|
743
|
+
const ownerRefName = owner.owner.self === true ? appRefName : owner.owner.refName;
|
|
744
|
+
const matchesDisplayName = storedNameIsCurrentDisplay(storedName, fieldKey, row["field_id"], ownerRefName, ctx);
|
|
745
|
+
const filter = dropdownFilterFromValue(row["filter"], owner.fieldScope, owner.fieldScopeLabel, ownerRefName, address, rowWhere, ctx);
|
|
746
|
+
if (filter === null)
|
|
747
|
+
return null;
|
|
748
|
+
dropdowns.push({
|
|
749
|
+
owner: owner.owner,
|
|
750
|
+
fieldKey,
|
|
751
|
+
fieldName: storedName,
|
|
752
|
+
...(matchesDisplayName ? {} : { storedFieldName: storedName }),
|
|
753
|
+
multiple: row["multiple"],
|
|
754
|
+
...(filter !== undefined ? { filter } : {}),
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
return { ...skill, dynamicDropdowns: dropdowns };
|
|
758
|
+
}
|
|
759
|
+
function importedAspectName(ctx, kind, label) {
|
|
760
|
+
const type = kind === "element" ? "elementum_element" : "elementum_app";
|
|
761
|
+
const id = ctx.importId(`${type}.${label}`);
|
|
762
|
+
const imported = id === undefined ? undefined : ctx.importedResource?.(id);
|
|
763
|
+
const name = imported?.attrs["name"];
|
|
764
|
+
return typeof name === "string" && name !== "" ? name : undefined;
|
|
765
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* the deploy wire client injects) with `CatalogRef` tokens at every reference
|
|
4
4
|
* position. Standalone from v1.
|
|
5
5
|
*/
|
|
6
|
-
export { agent, bedrockAgent, type A2ASkill, type AgentAuthentication, type AgentConfigured, type AgentV2Options, type BedrockAgentOptions, agentStartingActionVariableType, type AgentStartingAction, type AgentStartingActionVariable, type AgentStartingActionVariableType, type SkillAccess, } from "./build.js";
|
|
6
|
+
export { agent, bedrockAgent, type A2ASkill, type AgentAuthentication, type AgentConfigured, type AgentV2Options, type BedrockAgentOptions, agentStartingActionVariableType, type AgentStartingAction, type AgentStartingActionVariable, type AgentStartingActionVariableType, type SkillAccess, type AgentAskUserQuestion, type AgentDynamicDropdown, type AgentSystemSkill, type AgentSystemSkillsConfig, } from "./build.js";
|
|
7
7
|
export { agentCreateRecord, agentExecuteWorkflow, agentMcp, agentRelateRecord, agentRunAgent, agentRunAutomation, agentSearchRecords, agentSearchTable, agentUpdateRecord, type AgentExecuteWorkflowInput, type AgentExecuteWorkflowOutput, type RunAutomationInputs, type RunAutomationOptionalInput, type RunAutomationOutput, type RunAutomationOutputs, type RunAutomationRequiredInput, type RunAutomationToolV2, type AgentMcpHeader, type AgentRecordField, type AgentRecordFieldInput, type AgentRecordRawIdField, type AgentSearchField, type AgentSearchFieldInput, type AgentFilterVariable, type AgentSearchRawIdField, type AgentSearchReturnField, type AgentSearchReturnFieldInput, type AgentSearchRawIdReturnField, type AgentSearchTableField, type AgentSearchTableFieldInput, type AgentSearchTableRawIdField, type SearchTableToolV2, type AgentToolRunAs, type AgentTool, } from "./tools.js";
|
|
8
8
|
export { serviceAccountRef, type ServiceAccountRef } from "./run-as.js";
|
|
9
9
|
export * as filter from "../shared/filters/index.js";
|
|
@@ -46,17 +46,16 @@ export interface AgentToTfResult {
|
|
|
46
46
|
readonly address: string;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
50
|
-
* (`cmd/elementum/export/imports.go
|
|
51
|
-
*
|
|
52
|
-
* agents is not a collision on the platform —
|
|
53
|
-
*
|
|
54
|
-
* occurrence `_1`, `_2`, …
|
|
49
|
+
* The cross-agent a2a-skill-name numbering that ei's export copies
|
|
50
|
+
* (`a2aSkillImportBlocks` in `cmd/elementum/export/imports.go`, over one
|
|
51
|
+
* app's own agents only, edk#2508): a same-app, same-named a2a skill on two
|
|
52
|
+
* different agents is not a collision on the platform — the first agent to
|
|
53
|
+
* use a sanitized name gets the bare label, each later agent `_1`, `_2`, …
|
|
55
54
|
*
|
|
56
55
|
* The order is shared with ei: agent name by UTF-16 code unit, then (for
|
|
57
56
|
* identical names) refName here and the agent's own label in ei, whose `_N`
|
|
58
|
-
* tails sort alike. The Go comparator is in
|
|
59
|
-
*
|
|
57
|
+
* tails sort alike. The Go comparator is in `a2aSkillImportBlocks`
|
|
58
|
+
* (`compareUTF16`, `agentChildParts`),
|
|
60
59
|
* and the two must stay in sync; changing one without the other moves
|
|
61
60
|
* `agent_id` and replaces skills on the first plan after a pull (edk#1728).
|
|
62
61
|
* Before edk#1728 ei walked agents in id order.
|
|
@@ -76,8 +75,7 @@ export interface AgentToTfResult {
|
|
|
76
75
|
* cross-agent counter), so an intra-agent duplicate still collides on one
|
|
77
76
|
* address instead of silently acquiring a distinct label — that's a real
|
|
78
77
|
* authoring mistake (two skills with the identical name on ONE agent),
|
|
79
|
-
*
|
|
80
|
-
* `seenA2ASkillAddresses` check. Only DIFFERENT agents reusing a name are
|
|
78
|
+
* a build error from `agentToTf`'s `seenA2ASkillAddresses` check. Only DIFFERENT agents reusing a name are
|
|
81
79
|
* the #294 case this disambiguates.
|
|
82
80
|
*/
|
|
83
81
|
export declare function computeA2ASkillLabelSuffixes(siblingAgents: readonly DeployableEntity[]): ReadonlyMap<string, string>;
|
|
@@ -17,13 +17,15 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { typedCoverageGap } from "../../engine/coverage-gaps.js";
|
|
19
19
|
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
20
|
+
import { filterToTf } from "../access-policy/to-tf.js";
|
|
21
|
+
import { authoredFieldKeysFromPayload, fieldRefToTfValue } from "../field/to-tf.js";
|
|
20
22
|
import { EntityTfError } from "../../engine/entity.js";
|
|
21
23
|
import { appScopedResourceLabel, expr, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
22
24
|
import { a2aSkillToTf } from "../agent-a2a-skill/to-tf.js";
|
|
23
25
|
import { agentToolLabelSuffixes, assertUniqueToolAddresses, toolName, toolToTf } from "../agent-tool/to-tf.js";
|
|
24
26
|
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
25
27
|
import { CONNECTOR_ORG_BAG } from "../org/connector.js";
|
|
26
|
-
import { resolveForeignRef } from "../shared/foreign-ref.js";
|
|
28
|
+
import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
|
|
27
29
|
import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "../service-account/module.js";
|
|
28
30
|
import { SKILL_RESOURCE_TYPE } from "../skill/module.js";
|
|
29
31
|
import { AGENT_RESOURCE_TYPE } from "./module.js";
|
|
@@ -248,17 +250,16 @@ function toSortableAgents(entities) {
|
|
|
248
250
|
return out;
|
|
249
251
|
}
|
|
250
252
|
/**
|
|
251
|
-
*
|
|
252
|
-
* (`cmd/elementum/export/imports.go
|
|
253
|
-
*
|
|
254
|
-
* agents is not a collision on the platform —
|
|
255
|
-
*
|
|
256
|
-
* occurrence `_1`, `_2`, …
|
|
253
|
+
* The cross-agent a2a-skill-name numbering that ei's export copies
|
|
254
|
+
* (`a2aSkillImportBlocks` in `cmd/elementum/export/imports.go`, over one
|
|
255
|
+
* app's own agents only, edk#2508): a same-app, same-named a2a skill on two
|
|
256
|
+
* different agents is not a collision on the platform — the first agent to
|
|
257
|
+
* use a sanitized name gets the bare label, each later agent `_1`, `_2`, …
|
|
257
258
|
*
|
|
258
259
|
* The order is shared with ei: agent name by UTF-16 code unit, then (for
|
|
259
260
|
* identical names) refName here and the agent's own label in ei, whose `_N`
|
|
260
|
-
* tails sort alike. The Go comparator is in
|
|
261
|
-
*
|
|
261
|
+
* tails sort alike. The Go comparator is in `a2aSkillImportBlocks`
|
|
262
|
+
* (`compareUTF16`, `agentChildParts`),
|
|
262
263
|
* and the two must stay in sync; changing one without the other moves
|
|
263
264
|
* `agent_id` and replaces skills on the first plan after a pull (edk#1728).
|
|
264
265
|
* Before edk#1728 ei walked agents in id order.
|
|
@@ -278,8 +279,7 @@ function toSortableAgents(entities) {
|
|
|
278
279
|
* cross-agent counter), so an intra-agent duplicate still collides on one
|
|
279
280
|
* address instead of silently acquiring a distinct label — that's a real
|
|
280
281
|
* authoring mistake (two skills with the identical name on ONE agent),
|
|
281
|
-
*
|
|
282
|
-
* `seenA2ASkillAddresses` check. Only DIFFERENT agents reusing a name are
|
|
282
|
+
* a build error from `agentToTf`'s `seenA2ASkillAddresses` check. Only DIFFERENT agents reusing a name are
|
|
283
283
|
* the #294 case this disambiguates.
|
|
284
284
|
*/
|
|
285
285
|
export function computeA2ASkillLabelSuffixes(siblingAgents) {
|
|
@@ -354,6 +354,145 @@ function skillIdValue(token, ctx) {
|
|
|
354
354
|
ctx.orgRefs.foreignSkill(tfLabel, name, appId);
|
|
355
355
|
return expr.dataAttr(SKILL_RESOURCE_TYPE, tfLabel, ["id"]);
|
|
356
356
|
}
|
|
357
|
+
const ELEMENT_RESOURCE_TYPE = "elementum_element";
|
|
358
|
+
function dropdownAspect(token, kind, where, ctx) {
|
|
359
|
+
const refName = token.refName ?? "";
|
|
360
|
+
if (refName === "") {
|
|
361
|
+
throw new EntityTfError(`${where}: dynamic dropdown aspect has no refName`);
|
|
362
|
+
}
|
|
363
|
+
if (kind === "app" && refName === ctx.appRefName) {
|
|
364
|
+
const self = ctx.workspaceAspects?.get(workspaceAspectKey("app", refName));
|
|
365
|
+
return {
|
|
366
|
+
value: expr.resourceAttr(APP_RESOURCE_TYPE, ctx.appTfLabel, ["id"]),
|
|
367
|
+
localTfLabel: ctx.appTfLabel,
|
|
368
|
+
fieldOwnership: authoredFieldKeysFromPayload(self?.streamRootEntity?.payload),
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
const sibling = ctx.workspaceAspects?.get(workspaceAspectKey(kind, refName));
|
|
372
|
+
if (sibling !== undefined) {
|
|
373
|
+
const resourceType = kind === "element" ? ELEMENT_RESOURCE_TYPE : APP_RESOURCE_TYPE;
|
|
374
|
+
return {
|
|
375
|
+
value: expr.resourceAttr(resourceType, sibling.tfLabel, ["id"]),
|
|
376
|
+
localTfLabel: sibling.tfLabel,
|
|
377
|
+
fieldOwnership: authoredFieldKeysFromPayload(sibling.streamRootEntity?.payload),
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
const name = token.name ?? refName;
|
|
381
|
+
if (name === "") {
|
|
382
|
+
throw new EntityTfError(`${where}: dynamic dropdown ${kind} "${refName}" has no name to look up`);
|
|
383
|
+
}
|
|
384
|
+
const tfLabel = sanitizeName(token.namespace ?? name);
|
|
385
|
+
if (kind === "element") {
|
|
386
|
+
ctx.orgRefs.foreignElement(tfLabel, name, token.namespace);
|
|
387
|
+
return { value: expr.dataAttr(ELEMENT_RESOURCE_TYPE, tfLabel, ["id"]), foreignTfLabel: tfLabel };
|
|
388
|
+
}
|
|
389
|
+
ctx.orgRefs.foreignApp(tfLabel, name, token.namespace);
|
|
390
|
+
return { value: expr.dataAttr(APP_RESOURCE_TYPE, tfLabel, ["id"]), foreignTfLabel: tfLabel };
|
|
391
|
+
}
|
|
392
|
+
function dropdownFieldValue(field, aspect, where, ctx) {
|
|
393
|
+
const refName = field.refName ?? "";
|
|
394
|
+
if (refName === "") {
|
|
395
|
+
throw new EntityTfError(`${where}: dynamic dropdown field has no refName`);
|
|
396
|
+
}
|
|
397
|
+
if (field.parent !== undefined && (field.parent !== aspect.refName || (field.parentKind ?? "app") !== aspect.kind)) {
|
|
398
|
+
throw new EntityTfError(`${where}: field "${refName}" belongs to ${field.parentKind ?? "app"} "${field.parent}", not ${aspect.kind} "${aspect.refName}"`);
|
|
399
|
+
}
|
|
400
|
+
if (aspect.localTfLabel !== undefined) {
|
|
401
|
+
const value = fieldRefToTfValue(field.fieldType ?? "", refName, aspect.localTfLabel, aspect.kind, aspect.fieldOwnership);
|
|
402
|
+
if (value === undefined) {
|
|
403
|
+
throw new EntityTfError(`${where}: field "${refName}" has no terraform address on ${aspect.kind} "${aspect.refName}"`);
|
|
404
|
+
}
|
|
405
|
+
return value;
|
|
406
|
+
}
|
|
407
|
+
const fieldName = field.name ?? refName;
|
|
408
|
+
const ownerLabel = aspect.foreignTfLabel;
|
|
409
|
+
if (ownerLabel === undefined) {
|
|
410
|
+
throw new EntityTfError(`${where}: field "${refName}" has no lookup address on ${aspect.kind} "${aspect.refName}"`);
|
|
411
|
+
}
|
|
412
|
+
const dataLabel = foreignFieldDataLabel(aspect.kind, ownerLabel, fieldName);
|
|
413
|
+
ctx.orgRefs.foreignField("elementum_field", dataLabel, aspect.value, fieldName);
|
|
414
|
+
return expr.dataAttr("elementum_field", dataLabel, ["id"]);
|
|
415
|
+
}
|
|
416
|
+
function systemSkillValue(skill, where, ctx, withDropdowns) {
|
|
417
|
+
if (typeof skill.enabled !== "boolean") {
|
|
418
|
+
throw new EntityTfError(`${where}: enabled must be a boolean`);
|
|
419
|
+
}
|
|
420
|
+
const value = { enabled: skill.enabled };
|
|
421
|
+
if (skill.description !== undefined)
|
|
422
|
+
value["description"] = skill.description;
|
|
423
|
+
if (!withDropdowns)
|
|
424
|
+
return value;
|
|
425
|
+
if (skill.dynamicDropdowns === undefined)
|
|
426
|
+
return value;
|
|
427
|
+
value["dynamic_dropdowns"] = skill.dynamicDropdowns.map((row, index) => {
|
|
428
|
+
const rowWhere = `${where} dynamic dropdown ${index + 1}`;
|
|
429
|
+
const app = row.app;
|
|
430
|
+
const element = row.element;
|
|
431
|
+
if ((app === undefined) === (element === undefined)) {
|
|
432
|
+
throw new EntityTfError(`${rowWhere}: set exactly one of app or element`);
|
|
433
|
+
}
|
|
434
|
+
const kind = app !== undefined ? "app" : "element";
|
|
435
|
+
const token = app ?? element;
|
|
436
|
+
if (token === undefined)
|
|
437
|
+
throw new EntityTfError(`${rowWhere}: set exactly one of app or element`);
|
|
438
|
+
const aspect = dropdownAspect(token, kind, rowWhere, ctx);
|
|
439
|
+
const field = row.field;
|
|
440
|
+
if (field === undefined)
|
|
441
|
+
throw new EntityTfError(`${rowWhere}: field is required`);
|
|
442
|
+
if (typeof row.multiple !== "boolean")
|
|
443
|
+
throw new EntityTfError(`${rowWhere}: multiple must be a boolean`);
|
|
444
|
+
const fieldName = row.fieldName ?? field.name ?? field.refName ?? "";
|
|
445
|
+
if (fieldName === "")
|
|
446
|
+
throw new EntityTfError(`${rowWhere}: field has no name`);
|
|
447
|
+
const aspectRef = {
|
|
448
|
+
refName: token.refName ?? "",
|
|
449
|
+
kind,
|
|
450
|
+
value: aspect.value,
|
|
451
|
+
localTfLabel: aspect.localTfLabel,
|
|
452
|
+
foreignTfLabel: aspect.foreignTfLabel,
|
|
453
|
+
fieldOwnership: aspect.fieldOwnership,
|
|
454
|
+
};
|
|
455
|
+
const dropdown = {
|
|
456
|
+
aspect_id: aspect.value,
|
|
457
|
+
field: fieldName,
|
|
458
|
+
field_id: dropdownFieldValue(field, aspectRef, rowWhere, ctx),
|
|
459
|
+
multiple: row.multiple,
|
|
460
|
+
};
|
|
461
|
+
if (row.filter !== undefined) {
|
|
462
|
+
const local = aspect.localTfLabel !== undefined;
|
|
463
|
+
// An in-workspace aspect addresses its own fields as resources and
|
|
464
|
+
// system-field locals. A data-source aspect has neither: its fields go
|
|
465
|
+
// through foreignField (`ownerFieldsThroughForeign`) and come out as
|
|
466
|
+
// `data.elementum_field` lookups, while `ownerRefName` stays the real
|
|
467
|
+
// refName so `filter.textOption` still sees them as this aspect's.
|
|
468
|
+
dropdown["filter"] = filterToTf(row.filter, `${rowWhere} filter`, {
|
|
469
|
+
ownerTfLabel: local ? aspect.localTfLabel ?? "" : aspect.foreignTfLabel ?? aspectRef.refName,
|
|
470
|
+
ownerRefName: aspectRef.refName,
|
|
471
|
+
scope: kind,
|
|
472
|
+
objectId: aspect.value,
|
|
473
|
+
diagnostics: ctx.diagnostics,
|
|
474
|
+
fieldAddresses: aspect.fieldOwnership,
|
|
475
|
+
...(local ? {} : { resolvePicklistLiterals: false, ownerFieldsThroughForeign: true }),
|
|
476
|
+
foreignField: (_fieldToken, fieldWhere) => dropdownFieldValue(_fieldToken, aspectRef, fieldWhere, ctx),
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
return dropdown;
|
|
480
|
+
});
|
|
481
|
+
return value;
|
|
482
|
+
}
|
|
483
|
+
function systemSkillsValue(config, where, ctx) {
|
|
484
|
+
const value = {};
|
|
485
|
+
if (config.askUserQuestion !== undefined) {
|
|
486
|
+
value["ask_user_question"] = systemSkillValue(config.askUserQuestion, `${where} askUserQuestion`, ctx, true);
|
|
487
|
+
}
|
|
488
|
+
if (config.approvals !== undefined) {
|
|
489
|
+
value["approvals"] = systemSkillValue(config.approvals, `${where} approvals`, ctx, false);
|
|
490
|
+
}
|
|
491
|
+
if (Object.keys(value).length === 0) {
|
|
492
|
+
throw new EntityTfError(`${where}: systemSkillsConfig has neither askUserQuestion nor approvals`);
|
|
493
|
+
}
|
|
494
|
+
return value;
|
|
495
|
+
}
|
|
357
496
|
/** `elementum_agent` + one tool resource per implemented tool, in ei's dialect. */
|
|
358
497
|
export function agentToTf(entity, ctx) {
|
|
359
498
|
if (entity.kind !== "agent") {
|
|
@@ -457,6 +596,9 @@ export function agentToTf(entity, ctx) {
|
|
|
457
596
|
ctx.diagnostics.push(`${where}: ${knob} is not carried by the terraform path yet; dropped (apply leaves the agent's live ${knob} unchanged)`);
|
|
458
597
|
}
|
|
459
598
|
}
|
|
599
|
+
if (elementum.systemSkillsConfig !== undefined) {
|
|
600
|
+
attrs["system_skills_config"] = systemSkillsValue(elementum.systemSkillsConfig, where, ctx);
|
|
601
|
+
}
|
|
460
602
|
const skillAccess = elementum.skillAccessConfig;
|
|
461
603
|
if (skillAccess !== undefined) {
|
|
462
604
|
const mode = skillAccess.mode ?? "NONE";
|
|
@@ -522,7 +664,7 @@ export function agentToTf(entity, ctx) {
|
|
|
522
664
|
// disambiguates that case with a numeric suffix rather than rejecting it
|
|
523
665
|
// (see computeA2ASkillLabelSuffixes). A collision within THIS agent's own
|
|
524
666
|
// a2aSkills list (the same name twice on one agent) is a real authoring
|
|
525
|
-
// mistake, not a cross-agent scoping gap —
|
|
667
|
+
// mistake, not a cross-agent scoping gap — a build error below.
|
|
526
668
|
const a2aSkillLabelSuffixes = computeA2ASkillLabelSuffixes(ctx.siblingEntities ?? [entity]);
|
|
527
669
|
const seenA2ASkillAddresses = new Set();
|
|
528
670
|
payload.a2aSkills?.forEach((entry) => {
|
|
@@ -536,8 +678,10 @@ export function agentToTf(entity, ctx) {
|
|
|
536
678
|
if (skill === undefined)
|
|
537
679
|
return;
|
|
538
680
|
if (seenA2ASkillAddresses.has(skill.address)) {
|
|
539
|
-
|
|
540
|
-
|
|
681
|
+
// Dropping it would delete a live skill on the next apply (edk#2508).
|
|
682
|
+
throw new EntityTfError(`${where}: two a2a skills named like ${JSON.stringify(entry.name)} both get the address ${skill.address} ` +
|
|
683
|
+
"(the label lowercases a name, splits camelCase and turns spaces, hyphens and other punctuation into `_`, so names such as \"AskBot\" and \"Ask Bot\" share one). " +
|
|
684
|
+
"A2A skill names must be unique per agent; rename one of them.");
|
|
541
685
|
}
|
|
542
686
|
seenA2ASkillAddresses.add(skill.address);
|
|
543
687
|
blocks.push(skill.block);
|
|
@@ -441,6 +441,12 @@ function executeWorkflowFromTf(block, name, where, owner, ctx) {
|
|
|
441
441
|
: undefined;
|
|
442
442
|
if (autoLabel === undefined) {
|
|
443
443
|
ctx.diagnostics.push(`${where}: automation_id is not an automation/workflow_publish resource reference (${JSON.stringify(autoRef)}); skipped`);
|
|
444
|
+
if (typeof autoRef === "string" && block.type !== undefined && block.label !== undefined) {
|
|
445
|
+
// A raw id: the export left the automation out, so no source can manage
|
|
446
|
+
// the tool. Release an earlier adoption rather than destroy it (#2525).
|
|
447
|
+
ctx.skipped.push(`${block.type}.${block.label}`);
|
|
448
|
+
ctx.releaseIfManaged?.push(`${block.type}.${block.label}`);
|
|
449
|
+
}
|
|
444
450
|
return undefined;
|
|
445
451
|
}
|
|
446
452
|
const inputs = [];
|