@elementumai/edk 0.8.0-preview.11 → 0.8.2-alpha.5
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 +510 -324
- package/dist-sdk/src/catalog/ai-provider-models.d.ts +30 -0
- package/dist-sdk/src/catalog/ai-provider-models.js +63 -0
- package/dist-sdk/src/catalog/factories.d.ts +56 -3
- package/dist-sdk/src/catalog/factories.js +83 -4
- package/dist-sdk/src/catalog/from-authoring.js +19 -2
- package/dist-sdk/src/catalog/index.d.ts +3 -2
- package/dist-sdk/src/catalog/index.js +3 -2
- package/dist-sdk/src/catalog/org.d.ts +1 -1
- package/dist-sdk/src/catalog/org.js +134 -50
- package/dist-sdk/src/catalog/render.d.ts +13 -1
- package/dist-sdk/src/catalog/render.js +21 -4
- package/dist-sdk/src/catalog/token.js +18 -0
- package/dist-sdk/src/catalog/types.d.ts +75 -3
- package/dist-sdk/src/catalog/types.js +3 -0
- package/dist-sdk/src/core/system-fields.d.ts +2 -0
- package/dist-sdk/src/core/system-fields.js +2 -0
- package/dist-sdk/src/core/types/ai-provider.d.ts +10 -23
- package/dist-sdk/src/core/types/ai-provider.js +1 -25
- package/dist-sdk/src/core/types/app.d.ts +26 -1
- package/dist-sdk/src/engine/build/context.d.ts +58 -0
- package/dist-sdk/src/engine/build/context.js +11 -1
- package/dist-sdk/src/engine/build/source-context.d.ts +45 -0
- package/dist-sdk/src/engine/build/source-context.js +23 -0
- package/dist-sdk/src/engine/pull/context.d.ts +15 -0
- package/dist-sdk/src/engine/pull/org.d.ts +10 -0
- package/dist-sdk/src/engine/pull/org.js +34 -4
- package/dist-sdk/src/engine/tf/index.d.ts +2 -2
- package/dist-sdk/src/engine/tf/index.js +2 -2
- package/dist-sdk/src/engine/tf/labels.d.ts +54 -0
- package/dist-sdk/src/engine/tf/labels.js +75 -0
- package/dist-sdk/src/engine/tf/parse.d.ts +15 -0
- package/dist-sdk/src/engine/tf/parse.js +162 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +26 -0
- package/dist-sdk/src/entities/access-policy/build.js +7 -0
- package/dist-sdk/src/entities/access-policy/filter.d.ts +61 -0
- package/dist-sdk/src/entities/access-policy/filter.js +83 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +66 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +187 -0
- package/dist-sdk/src/entities/access-policy/module.d.ts +3 -0
- package/dist-sdk/src/entities/access-policy/module.js +17 -0
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +43 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +164 -0
- package/dist-sdk/src/entities/access-policy/types.d.ts +4 -0
- package/dist-sdk/src/entities/access-policy/types.js +10 -0
- package/dist-sdk/src/entities/agent/build.d.ts +2 -0
- package/dist-sdk/src/entities/agent/build.js +1 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +38 -3
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +257 -32
- package/dist-sdk/src/entities/agent/from-tf.d.ts +29 -9
- package/dist-sdk/src/entities/agent/from-tf.js +146 -19
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/module.js +14 -4
- package/dist-sdk/src/entities/agent/to-tf.d.ts +46 -1
- package/dist-sdk/src/entities/agent/to-tf.js +160 -14
- package/dist-sdk/src/entities/agent/tools.d.ts +88 -9
- package/dist-sdk/src/entities/agent/tools.js +46 -7
- package/dist-sdk/src/entities/agent-a2a-skill/from-tf.d.ts +17 -0
- package/dist-sdk/src/entities/agent-a2a-skill/from-tf.js +64 -0
- package/dist-sdk/src/entities/agent-a2a-skill/module.d.ts +4 -0
- package/dist-sdk/src/entities/agent-a2a-skill/module.js +14 -0
- package/dist-sdk/src/entities/agent-a2a-skill/to-tf.d.ts +40 -0
- package/dist-sdk/src/entities/agent-a2a-skill/to-tf.js +47 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +51 -4
- package/dist-sdk/src/entities/agent-tool/from-tf.js +131 -35
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +11 -4
- package/dist-sdk/src/entities/agent-tool/to-tf.js +176 -30
- package/dist-sdk/src/entities/agent-tool/types.d.ts +5 -4
- package/dist-sdk/src/entities/agent-tool/types.js +38 -6
- package/dist-sdk/src/entities/app/build.d.ts +91 -13
- package/dist-sdk/src/entities/app/build.js +63 -5
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +3 -0
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/app/from-tf.js +32 -22
- package/dist-sdk/src/entities/app/index.d.ts +4 -1
- package/dist-sdk/src/entities/app/index.js +2 -1
- package/dist-sdk/src/entities/app/module.js +10 -2
- package/dist-sdk/src/entities/app/to-tf.d.ts +5 -0
- package/dist-sdk/src/entities/app/to-tf.js +45 -4
- package/dist-sdk/src/entities/automation/build.d.ts +57 -13
- package/dist-sdk/src/entities/automation/build.js +62 -42
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +25 -8
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +16 -1
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +206 -47
- package/dist-sdk/src/entities/automation/filter.d.ts +37 -3
- package/dist-sdk/src/entities/automation/filter.js +54 -3
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -27
- package/dist-sdk/src/entities/automation/from-tf.js +1344 -222
- package/dist-sdk/src/entities/automation/index.d.ts +4 -0
- package/dist-sdk/src/entities/automation/index.js +4 -0
- package/dist-sdk/src/entities/automation/module.js +29 -32
- package/dist-sdk/src/entities/automation/operators.d.ts +29 -2
- package/dist-sdk/src/entities/automation/operators.js +27 -1
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +19 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +24 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +10 -21
- package/dist-sdk/src/entities/automation/script-code.js +272 -5
- package/dist-sdk/src/entities/automation/tasks.d.ts +125 -19
- package/dist-sdk/src/entities/automation/tasks.js +83 -15
- package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -29
- package/dist-sdk/src/entities/automation/to-tf.js +1291 -230
- package/dist-sdk/src/entities/automation/triggers.d.ts +9 -1
- package/dist-sdk/src/entities/automation/types.d.ts +29 -4
- package/dist-sdk/src/entities/automation/types.js +76 -46
- package/dist-sdk/src/entities/element/build.d.ts +44 -13
- package/dist-sdk/src/entities/element/build.js +45 -3
- package/dist-sdk/src/entities/element/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/element/from-tf.js +28 -14
- package/dist-sdk/src/entities/element/index.d.ts +4 -1
- package/dist-sdk/src/entities/element/index.js +2 -1
- package/dist-sdk/src/entities/element/module.js +4 -1
- package/dist-sdk/src/entities/element/to-tf.js +26 -3
- package/dist-sdk/src/entities/field/build.d.ts +61 -14
- package/dist-sdk/src/entities/field/build.js +10 -0
- package/dist-sdk/src/entities/field/calc/runtime.js +4 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +5 -3
- package/dist-sdk/src/entities/field/from-tf.js +118 -7
- package/dist-sdk/src/entities/field/module.js +3 -2
- package/dist-sdk/src/entities/field/to-tf.d.ts +46 -11
- package/dist-sdk/src/entities/field/to-tf.js +166 -17
- package/dist-sdk/src/entities/field/types.d.ts +26 -0
- package/dist-sdk/src/entities/field/types.js +34 -12
- package/dist-sdk/src/entities/file-reader/build.d.ts +108 -50
- package/dist-sdk/src/entities/file-reader/build.js +23 -23
- package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.d.ts +6 -0
- package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +109 -0
- package/dist-sdk/src/entities/file-reader/from-tf.d.ts +13 -0
- package/dist-sdk/src/entities/file-reader/from-tf.js +172 -0
- package/dist-sdk/src/entities/file-reader/index.d.ts +8 -3
- package/dist-sdk/src/entities/file-reader/index.js +7 -2
- package/dist-sdk/src/entities/file-reader/module.d.ts +3 -0
- package/dist-sdk/src/entities/file-reader/module.js +115 -0
- package/dist-sdk/src/entities/file-reader/to-tf.d.ts +14 -0
- package/dist-sdk/src/entities/file-reader/to-tf.js +84 -0
- package/dist-sdk/src/entities/file-reader/types.d.ts +32 -0
- package/dist-sdk/src/entities/file-reader/types.js +30 -0
- package/dist-sdk/src/entities/org/ai-provider.d.ts +13 -0
- package/dist-sdk/src/entities/org/ai-provider.js +46 -0
- package/dist-sdk/src/entities/org/connector.d.ts +8 -1
- package/dist-sdk/src/entities/org/connector.js +12 -14
- package/dist-sdk/src/entities/org/group.js +10 -1
- 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/user.js +10 -1
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +59 -9
- package/dist-sdk/src/entities/shared/filters/types.d.ts +1 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +17 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +46 -0
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -1
- package/dist-sdk/src/entities/shared/types/field-types.js +9 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +19 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +128 -11
- package/dist-sdk/src/entities/skill/from-tf.js +4 -3
- package/dist-sdk/src/entities/skill/index.d.ts +1 -1
- package/dist-sdk/src/entities/skill/module.js +7 -1
- package/dist-sdk/src/entities/skill/to-tf.d.ts +26 -0
- package/dist-sdk/src/entities/skill/to-tf.js +65 -4
- package/dist-sdk/src/entities/skill/tools.d.ts +37 -8
- package/dist-sdk/src/entities/skill/tools.js +43 -1
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +34 -4
- package/dist-sdk/src/entities/skill-tool/from-tf.js +128 -18
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +13 -1
- package/dist-sdk/src/entities/skill-tool/to-tf.js +164 -25
- package/dist-sdk/src/entities/skill-tool/types.d.ts +5 -7
- package/dist-sdk/src/entities/skill-tool/types.js +47 -11
- package/dist-sdk/src/entities/view/from-tf.d.ts +6 -2
- package/dist-sdk/src/entities/view/from-tf.js +11 -9
- package/dist-sdk/src/entities/view/to-tf.d.ts +9 -7
- package/dist-sdk/src/entities/view/to-tf.js +39 -18
- package/dist-sdk/src/entities/view/types.d.ts +1 -1
- package/dist-sdk/src/entities/view/types.js +1 -1
- package/dist-sdk/src/graph/deferred-catalog-render.d.ts +0 -5
- package/dist-sdk/src/graph/deferred-catalog-render.js +1 -20
- package/dist-sdk/src/graph/index.d.ts +8 -0
- package/dist-sdk/src/graph/index.js +13 -9
- package/dist-sdk/src/graph/modules.js +8 -1
- package/dist-sdk/src/graph/types.d.ts +98 -4
- package/package.json +49 -16
- package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +0 -76
- package/dist-sdk/src/entities/automation/value-ref-tf.js +0 -190
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent extraction (M3, plan §4.3): `agentFromTf` turns an
|
|
3
3
|
* `elementum_agent` block + its tool blocks (delegated to
|
|
4
|
-
* `entities/agent-tool/from-tf.ts`)
|
|
5
|
-
* `
|
|
6
|
-
*
|
|
4
|
+
* `entities/agent-tool/from-tf.ts`) + its a2a-skill blocks (delegated to
|
|
5
|
+
* `entities/agent-a2a-skill/from-tf.ts`, issue #68) into the normalized
|
|
6
|
+
* shape `printAgentV2` consumes. Platform ids come only from the stream's
|
|
7
|
+
* import blocks and stay data-side — they never reach printed source.
|
|
7
8
|
*/
|
|
8
9
|
import { EntityTfError } from "../../engine/entity.js";
|
|
9
|
-
import { optionalString, resourceRefLabel } from "../../engine/pull/context.js";
|
|
10
|
-
import { isTfExpr, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
10
|
+
import { optionalBoolean, optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
11
|
+
import { isTfExpr, isUuid, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
|
|
12
|
+
import { a2aSkillFromTf } from "../agent-a2a-skill/from-tf.js";
|
|
11
13
|
import { toolFromTf } from "../agent-tool/from-tf.js";
|
|
12
14
|
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
13
15
|
import { SKILL_RESOURCE_TYPE } from "../skill/module.js";
|
|
@@ -22,6 +24,12 @@ const KNOWN_AGENT_ATTRS = new Set([
|
|
|
22
24
|
"ai_provider_connector_id",
|
|
23
25
|
"skill_access_config",
|
|
24
26
|
"max_tokens",
|
|
27
|
+
"depends_on",
|
|
28
|
+
"run_as",
|
|
29
|
+
"jwt_authentication",
|
|
30
|
+
"conversation_idle_timeout",
|
|
31
|
+
"a2a_streaming",
|
|
32
|
+
"a2a_create_record_enabled",
|
|
25
33
|
]);
|
|
26
34
|
/** Dialect attrs with no authoring slot yet — reported by name, agent still pulled. */
|
|
27
35
|
const UNAUTHORABLE_AGENT_ATTRS = new Set(["starting_actions", "model"]);
|
|
@@ -41,9 +49,9 @@ const VARIANT_ATTRS = new Set([
|
|
|
41
49
|
* data-attr is a foreign app's skill, resolved to its name via the
|
|
42
50
|
* stream's data block.
|
|
43
51
|
*/
|
|
44
|
-
function parseSkillRef(item, where, ctx) {
|
|
52
|
+
function parseSkillRef(item, where, ownerTfLabel, ctx) {
|
|
45
53
|
if (isTfExpr(item) && item.$expr === "resource-attr" && item.type === SKILL_RESOURCE_TYPE) {
|
|
46
|
-
return { kind: "self", key:
|
|
54
|
+
return { kind: "self", key: scopedLabelToBagKey(ownerTfLabel, item.label) };
|
|
47
55
|
}
|
|
48
56
|
if (isTfExpr(item) && item.$expr === "data-attr" && item.type === SKILL_RESOURCE_TYPE) {
|
|
49
57
|
const name = ctx.dataName(SKILL_RESOURCE_TYPE, item.label);
|
|
@@ -53,10 +61,90 @@ function parseSkillRef(item, where, ctx) {
|
|
|
53
61
|
}
|
|
54
62
|
return { kind: "foreign", name };
|
|
55
63
|
}
|
|
64
|
+
// A bare UUID literal with no data block backing it at all - the platform
|
|
65
|
+
// lets skill_ids reference a skill this export can't otherwise name (e.g.
|
|
66
|
+
// an app outside this workspace's export scope). Round-trip the raw id
|
|
67
|
+
// rather than dropping it; a typo'd/genuinely-malformed non-UUID string
|
|
68
|
+
// still falls through to the diagnostic below.
|
|
69
|
+
if (typeof item === "string" && isUuid(item)) {
|
|
70
|
+
return { kind: "unresolved", id: item };
|
|
71
|
+
}
|
|
56
72
|
ctx.diagnostics.push(`${where}: skill_access_config entry has an unrecognized shape (${JSON.stringify(item)}); dropped`);
|
|
57
73
|
return undefined;
|
|
58
74
|
}
|
|
59
|
-
|
|
75
|
+
/**
|
|
76
|
+
* `run_as` is a bare string on the wire (`elementum_agent`'s schema: only
|
|
77
|
+
* `"current_user"` is documented; unset means "run as admin/publisher").
|
|
78
|
+
* `defineAgent`'s `runAs` option takes the opaque object shape shared with
|
|
79
|
+
* agent-tool's `runAs` (`{ currentUser: true }` / `{ publisher: true }` /
|
|
80
|
+
* `{ serviceAccount: { serviceAccount } }`) — board item B28(d) — so the
|
|
81
|
+
* string is translated into that shape for authoring; unrecognized values
|
|
82
|
+
* (not `"current_user"`) are reported and dropped rather than guessed at.
|
|
83
|
+
*/
|
|
84
|
+
function parseRunAs(value, where, ctx) {
|
|
85
|
+
if (value === "current_user")
|
|
86
|
+
return { currentUser: true };
|
|
87
|
+
ctx.diagnostics.push(`${where}: run_as ${JSON.stringify(value)} is not a recognized value; dropped`);
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
/** `jwt_authentication`'s nested `key_source` — exactly one of `jwks_url`/`plain_text_key` is set. */
|
|
91
|
+
function parseJwtKeySource(rec, where, ctx) {
|
|
92
|
+
const jwksUrl = rec["jwks_url"];
|
|
93
|
+
if (typeof jwksUrl === "string" && jwksUrl !== "")
|
|
94
|
+
return { jwks: { jwksUrl } };
|
|
95
|
+
const plainTextKey = rec["plain_text_key"];
|
|
96
|
+
if (typeof plainTextKey === "string" && plainTextKey !== "")
|
|
97
|
+
return { plainText: { plainTextKeyValuePem: plainTextKey } };
|
|
98
|
+
ctx.diagnostics.push(`${where}: jwt_authentication has neither jwks_url nor plain_text_key; dropped`);
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
function parseJwtAuthentication(value, where, ctx) {
|
|
102
|
+
const rec = plainObject(value);
|
|
103
|
+
if (rec === undefined) {
|
|
104
|
+
ctx.diagnostics.push(`${where}: jwt_authentication has an unrecognized shape; dropped`);
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
const enabled = rec["enabled"];
|
|
108
|
+
const headerName = rec["header_name"];
|
|
109
|
+
const emailAddressClaimName = rec["email_address_claim_name"];
|
|
110
|
+
if (typeof enabled !== "boolean" || typeof headerName !== "string" || typeof emailAddressClaimName !== "string") {
|
|
111
|
+
ctx.diagnostics.push(`${where}: jwt_authentication is missing required fields (enabled/header_name/email_address_claim_name); dropped`);
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
const keySource = parseJwtKeySource(rec, where, ctx);
|
|
115
|
+
if (keySource === undefined)
|
|
116
|
+
return undefined;
|
|
117
|
+
let requiredClaims;
|
|
118
|
+
const rawClaims = rec["required_claims"];
|
|
119
|
+
if (Array.isArray(rawClaims)) {
|
|
120
|
+
requiredClaims = [];
|
|
121
|
+
for (const item of rawClaims) {
|
|
122
|
+
const claimRec = plainObject(item);
|
|
123
|
+
const claimName = claimRec?.["claim_name"];
|
|
124
|
+
const acceptableValues = claimRec?.["acceptable_values"];
|
|
125
|
+
if (typeof claimName !== "string" || !Array.isArray(acceptableValues) || !acceptableValues.every((v) => typeof v === "string")) {
|
|
126
|
+
ctx.diagnostics.push(`${where}: jwt_authentication.required_claims entry has an unrecognized shape; dropped`);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
requiredClaims.push({ claimName, acceptableValues: acceptableValues });
|
|
130
|
+
}
|
|
131
|
+
if (requiredClaims.length === 0)
|
|
132
|
+
requiredClaims = undefined;
|
|
133
|
+
}
|
|
134
|
+
else if (rawClaims !== undefined) {
|
|
135
|
+
ctx.diagnostics.push(`${where}: jwt_authentication.required_claims is not a list; dropped`);
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
jwt: {
|
|
139
|
+
enabled,
|
|
140
|
+
headerName,
|
|
141
|
+
emailAddressClaimName,
|
|
142
|
+
keySource,
|
|
143
|
+
...(requiredClaims !== undefined && { requiredClaims }),
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function parseSkillAccessConfig(value, where, ownerTfLabel, ctx) {
|
|
60
148
|
if (typeof value !== "object" || value === null || Array.isArray(value) || isTfExpr(value)) {
|
|
61
149
|
ctx.diagnostics.push(`${where}: skill_access_config has an unrecognized shape; dropped`);
|
|
62
150
|
return undefined;
|
|
@@ -73,7 +161,7 @@ function parseSkillAccessConfig(value, where, ctx) {
|
|
|
73
161
|
return undefined;
|
|
74
162
|
const refs = [];
|
|
75
163
|
for (const item of raw) {
|
|
76
|
-
const ref = parseSkillRef(item, `${where}: ${attr}`, ctx);
|
|
164
|
+
const ref = parseSkillRef(item, `${where}: ${attr}`, ownerTfLabel, ctx);
|
|
77
165
|
if (ref !== undefined)
|
|
78
166
|
refs.push(ref);
|
|
79
167
|
}
|
|
@@ -91,11 +179,12 @@ function parseSkillAccessConfig(value, where, ctx) {
|
|
|
91
179
|
return { mode: "CUSTOM", skills, ...preloadedProp };
|
|
92
180
|
}
|
|
93
181
|
/**
|
|
94
|
-
* The `elementum_agent` block + its tool blocks
|
|
95
|
-
*
|
|
96
|
-
* caller partitions per-agent by agent_id, but stays
|
|
182
|
+
* The `elementum_agent` block + its tool blocks + its a2a-skill blocks →
|
|
183
|
+
* the normalized agent. Blocks belonging to OTHER agents are skipped with a
|
|
184
|
+
* diagnostic (the caller partitions per-agent by agent_id, but stays
|
|
185
|
+
* defensive).
|
|
97
186
|
*/
|
|
98
|
-
export function agentFromTf(agentBlock, toolBlocks, appLabel, ctx) {
|
|
187
|
+
export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx, a2aSkillBlocks = []) {
|
|
99
188
|
const label = agentBlock.label;
|
|
100
189
|
if (label === undefined || label === "") {
|
|
101
190
|
throw new EntityTfError("elementum_agent block is missing its label");
|
|
@@ -125,26 +214,58 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, ctx) {
|
|
|
125
214
|
const connectorAttr = attrs["ai_provider_connector_id"];
|
|
126
215
|
if (connectorAttr !== undefined) {
|
|
127
216
|
if (isTfExpr(connectorAttr) && connectorAttr.$expr === "data-attr" && connectorAttr.type === "elementum_ai_provider_connector") {
|
|
128
|
-
// The
|
|
129
|
-
//
|
|
130
|
-
|
|
217
|
+
// The connector's own block only carries model_name + a reference to
|
|
218
|
+
// its provider — the provider's own data block carries the name.
|
|
219
|
+
// Deriving providerKey/modelKey this way (not by splitting the
|
|
220
|
+
// connector's combined tfLabel) is the same derivation
|
|
221
|
+
// renderAiProvidersBag uses, so the printed token matches the catalog.
|
|
222
|
+
const modelName = ctx.dataName(connectorAttr.type, connectorAttr.label);
|
|
223
|
+
const providerRef = ctx.dataRef(connectorAttr.type, connectorAttr.label);
|
|
224
|
+
const providerName = providerRef !== undefined ? ctx.dataName(providerRef.resourceType, providerRef.tfLabel) : undefined;
|
|
225
|
+
if (modelName === undefined || providerName === undefined) {
|
|
226
|
+
ctx.diagnostics.push(`${where}: references data.${connectorAttr.type}.${connectorAttr.label} but the stream has no model_name/provider for it; dropped`);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
const providerKey = tfLabelToTsLabel(sanitizeName(providerName));
|
|
230
|
+
const modelKey = tfLabelToTsLabel(sanitizeName(modelName));
|
|
231
|
+
connectorKey = `${providerKey}.${modelKey}`;
|
|
232
|
+
}
|
|
131
233
|
}
|
|
132
234
|
else {
|
|
133
235
|
ctx.diagnostics.push(`${where}: ai_provider_connector_id is not a connector data reference; dropped`);
|
|
134
236
|
}
|
|
135
237
|
}
|
|
136
|
-
const owner = { appType: APP_RESOURCE_TYPE, appLabel, agentType: AGENT_RESOURCE_TYPE, agentLabel: label };
|
|
238
|
+
const owner = { appType: APP_RESOURCE_TYPE, appLabel, ownerTfLabel: appLabel, agentType: AGENT_RESOURCE_TYPE, agentLabel: label };
|
|
137
239
|
const tools = [];
|
|
138
240
|
for (const block of toolBlocks) {
|
|
139
241
|
const tool = toolFromTf(block, owner, ctx);
|
|
140
242
|
if (tool !== undefined)
|
|
141
243
|
tools.push(tool);
|
|
142
244
|
}
|
|
245
|
+
const a2aSkills = [];
|
|
246
|
+
for (const block of a2aSkillBlocks) {
|
|
247
|
+
const skill = a2aSkillFromTf(block, { agentType: AGENT_RESOURCE_TYPE, agentLabel: label }, ctx);
|
|
248
|
+
if (skill !== undefined)
|
|
249
|
+
a2aSkills.push(skill);
|
|
250
|
+
}
|
|
143
251
|
let skillAccess;
|
|
144
252
|
const skillAccessAttr = attrs["skill_access_config"];
|
|
145
253
|
if (skillAccessAttr !== undefined) {
|
|
146
|
-
skillAccess = parseSkillAccessConfig(skillAccessAttr, where, ctx);
|
|
254
|
+
skillAccess = parseSkillAccessConfig(skillAccessAttr, where, appLabel, ctx);
|
|
255
|
+
}
|
|
256
|
+
let runAs;
|
|
257
|
+
const runAsAttr = attrs["run_as"];
|
|
258
|
+
if (runAsAttr !== undefined) {
|
|
259
|
+
runAs = parseRunAs(runAsAttr, where, ctx);
|
|
260
|
+
}
|
|
261
|
+
let agentAuthentication;
|
|
262
|
+
const jwtAttr = attrs["jwt_authentication"];
|
|
263
|
+
if (jwtAttr !== undefined) {
|
|
264
|
+
agentAuthentication = parseJwtAuthentication(jwtAttr, where, ctx);
|
|
147
265
|
}
|
|
266
|
+
const conversationIdleTimeout = optionalString(attrs, "conversation_idle_timeout", where, ctx);
|
|
267
|
+
const a2aStreaming = optionalBoolean(attrs, "a2a_streaming", where, ctx);
|
|
268
|
+
const a2aCreateRecordEnabled = optionalBoolean(attrs, "a2a_create_record_enabled", where, ctx);
|
|
148
269
|
const firstMessage = optionalString(attrs, "first_message", where, ctx);
|
|
149
270
|
const maxTokens = attrs["max_tokens"];
|
|
150
271
|
const maxLength = typeof maxTokens === "number" && Number.isSafeInteger(maxTokens) && maxTokens > 0
|
|
@@ -155,7 +276,7 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, ctx) {
|
|
|
155
276
|
}
|
|
156
277
|
return {
|
|
157
278
|
agent: {
|
|
158
|
-
refName:
|
|
279
|
+
refName: scopedLabelToBagKey(appLabel, label),
|
|
159
280
|
name,
|
|
160
281
|
description: optionalString(attrs, "description", where, ctx) ?? "",
|
|
161
282
|
instructions: optionalString(attrs, "instructions", where, ctx) ?? "",
|
|
@@ -163,7 +284,13 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, ctx) {
|
|
|
163
284
|
...(maxLength !== undefined && { maxLength }),
|
|
164
285
|
...(connectorKey !== undefined && { connectorKey }),
|
|
165
286
|
...(skillAccess !== undefined && { skillAccess }),
|
|
287
|
+
...(runAs !== undefined && { runAs }),
|
|
288
|
+
...(agentAuthentication !== undefined && { agentAuthentication }),
|
|
289
|
+
...(conversationIdleTimeout !== undefined && { conversationIdleTimeout }),
|
|
290
|
+
...(a2aStreaming !== undefined && { a2aStreaming }),
|
|
291
|
+
...(a2aCreateRecordEnabled !== undefined && { a2aCreateRecordEnabled }),
|
|
166
292
|
tools,
|
|
293
|
+
...(a2aSkills.length > 0 && { a2aSkills }),
|
|
167
294
|
},
|
|
168
295
|
};
|
|
169
296
|
}
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* position. Standalone from v1.
|
|
5
5
|
*/
|
|
6
6
|
export { defineAgent, type A2ASkill, type AgentAuthentication, type AgentV2Options, type SkillAccess, } from "./build.js";
|
|
7
|
-
export { agentCreateRecord, agentExecuteWorkflow, agentMcp, agentRelateRecord, agentRunAgent, agentRunAutomation, agentSearchAspect, agentSearchTable, agentSelectBotRoute, agentUpdateRecord, type AgentExecuteWorkflowInput, type AgentExecuteWorkflowOutput, type RunAutomationInputs, type RunAutomationOptionalInput, type RunAutomationOutput, type RunAutomationOutputs, type RunAutomationRequiredInput, type RunAutomationToolV2, type AgentMcpHeader, type AgentRecordField, type AgentSearchField, type AgentToolRunAs, type AgentTool, } from "./tools.js";
|
|
7
|
+
export { agentCreateRecord, agentExecuteWorkflow, agentMcp, agentRelateRecord, agentRunAgent, agentRunAutomation, agentSearchAspect, agentSearchTable, agentSelectBotRoute, 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 AgentSearchRawIdField, type AgentToolRunAs, type AgentTool, } from "./tools.js";
|
|
@@ -42,16 +42,19 @@ function agentRefFromAuthoring(args) {
|
|
|
42
42
|
}
|
|
43
43
|
function extractAgents(ownBlocks, stream, ctx) {
|
|
44
44
|
const toolBlocks = stream.byKind.get("agent-tool") ?? [];
|
|
45
|
+
const a2aSkillBlocks = stream.byKind.get("agent-a2a-skill") ?? [];
|
|
45
46
|
const items = [];
|
|
46
47
|
const skipped = [];
|
|
47
48
|
const diagnostics = [];
|
|
48
49
|
for (const agentBlock of ownBlocks) {
|
|
49
50
|
const agentLabel = agentBlock.label ?? "";
|
|
50
|
-
const
|
|
51
|
+
const ownsBlock = (b) => {
|
|
51
52
|
const ref = b.attrs["agent_id"];
|
|
52
53
|
return isTfExpr(ref) && ref.$expr === "resource-attr" && ref.type === AGENT_RESOURCE_TYPE && ref.label === agentLabel;
|
|
53
|
-
}
|
|
54
|
-
const
|
|
54
|
+
};
|
|
55
|
+
const ownTools = toolBlocks.filter(ownsBlock);
|
|
56
|
+
const ownA2ASkills = a2aSkillBlocks.filter(ownsBlock);
|
|
57
|
+
const { agent, skippedReason } = agentFromTf(agentBlock, ownTools, ctx.appTfLabel, ctx.appRefName, ctx, ownA2ASkills);
|
|
55
58
|
if (agent !== undefined)
|
|
56
59
|
items.push(agent);
|
|
57
60
|
else if (skippedReason !== undefined) {
|
|
@@ -92,7 +95,13 @@ export const agentModule = {
|
|
|
92
95
|
refName: agent.refName,
|
|
93
96
|
source: printAgentV2(agent, {
|
|
94
97
|
appRefName: opts.appRefName,
|
|
95
|
-
|
|
98
|
+
...(opts.crossOrg !== undefined && { crossOrg: opts.crossOrg }),
|
|
99
|
+
...(opts.destinationConnectorKeys !== undefined && {
|
|
100
|
+
destinationConnectorKeys: opts.destinationConnectorKeys,
|
|
101
|
+
}),
|
|
102
|
+
...(opts.connectorKeyOverride !== undefined && { connectorKeyOverride: opts.connectorKeyOverride }),
|
|
103
|
+
...(opts.foreignAppRefNames !== undefined && { foreignAppRefNames: opts.foreignAppRefNames }),
|
|
104
|
+
...(opts.foreignElementRefNames !== undefined && { foreignElementRefNames: opts.foreignElementRefNames }),
|
|
96
105
|
}),
|
|
97
106
|
};
|
|
98
107
|
},
|
|
@@ -101,6 +110,7 @@ export const agentModule = {
|
|
|
101
110
|
appTfLabel: ctx.appTfLabel,
|
|
102
111
|
orgRefs: ctx.orgRefs,
|
|
103
112
|
diagnostics: ctx.diagnostics,
|
|
113
|
+
...(ctx.siblingEntities !== undefined && { siblingEntities: ctx.siblingEntities }),
|
|
104
114
|
}),
|
|
105
115
|
},
|
|
106
116
|
catalog: {
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Agent emission (M3, plan §4.3): `agentToTf` consumes the discovered
|
|
3
3
|
* `DeployableEntity` (the `defineAgent` def() payload) and emits
|
|
4
4
|
* `elementum_agent` + one tool resource per implemented tool (the tool pass
|
|
5
|
-
* delegates to `entities/agent-tool/to-tf.ts`)
|
|
5
|
+
* delegates to `entities/agent-tool/to-tf.ts`) + one `elementum_agent_a2a_skill`
|
|
6
|
+
* per a2aSkills entry (delegates to `entities/agent-a2a-skill/to-tf.ts`,
|
|
7
|
+
* issue #68).
|
|
6
8
|
*
|
|
7
9
|
* The dialect is ei's ACTUAL export (docs/design/m3-agent-dialect.md):
|
|
8
10
|
* app_id as the owning app's resource ref, the connector as a
|
|
@@ -23,11 +25,54 @@ export interface AgentToTfContext {
|
|
|
23
25
|
readonly orgRefs: OrgRefLookup;
|
|
24
26
|
/** Degradations land here — reported by the caller, never silent. */
|
|
25
27
|
readonly diagnostics: string[];
|
|
28
|
+
/**
|
|
29
|
+
* Every agent entity discovered for this app (self included) — forwarded
|
|
30
|
+
* by build.ts, unordered. Used to replicate ei's cross-agent a2a-skill
|
|
31
|
+
* label disambiguation (see {@link computeA2ASkillLabelSuffixes}). Absent
|
|
32
|
+
* in contexts that don't supply it (e.g. most unit tests): every a2a
|
|
33
|
+
* skill then gets the bare label, matching the pre-#294 single-agent
|
|
34
|
+
* behavior.
|
|
35
|
+
*/
|
|
36
|
+
readonly siblingEntities?: readonly DeployableEntity[];
|
|
26
37
|
}
|
|
27
38
|
export interface AgentToTfResult {
|
|
28
39
|
readonly blocks: readonly TfBlock[];
|
|
29
40
|
/** The agent's terraform address. */
|
|
30
41
|
readonly address: string;
|
|
31
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Mirrors ei's cross-agent a2a-skill-name disambiguation
|
|
45
|
+
* (`cmd/elementum/export/imports.go`'s `a2aNames` counting map over
|
|
46
|
+
* `app.AllAgents()`): a same-app, same-named a2a skill on two different
|
|
47
|
+
* agents is not a collision on the platform — ei's exporter gives the
|
|
48
|
+
* first occurrence of a sanitized name the bare label, each later
|
|
49
|
+
* occurrence `_1`, `_2`, …
|
|
50
|
+
*
|
|
51
|
+
* Ascending-by-agent-NAME confirmed live 2026-08-18 against real committed
|
|
52
|
+
* state on a deployed app (two identically-named a2a skills added via the
|
|
53
|
+
* platform UI to two different agents): "Default agent 2" landed at the
|
|
54
|
+
* bare label, "test agent" at `_1` — `D` < `t`, matching the assumed sort.
|
|
55
|
+
* A weaker signal than #310's skill-tool capture (that one deliberately
|
|
56
|
+
* reordered 3 skills' creation vs. name to rule out creation-order as an
|
|
57
|
+
* alternative explanation; this one only has 2 agents, so an
|
|
58
|
+
* agent-creation-order coincidence can't be fully excluded) — but real
|
|
59
|
+
* evidence from `ei`'s own exporter/import-address generation, not a
|
|
60
|
+
* guess. If a future capture contradicts it, only this function's sort
|
|
61
|
+
* needs to change — the suffix-assignment mechanics stay the same.
|
|
62
|
+
* Ordering of a2a skills WITHIN one agent is still assumed to be authored
|
|
63
|
+
* array order, unconfirmed live either way.
|
|
64
|
+
*
|
|
65
|
+
* Returns suffixes ("" for the first occurrence, "_1", "_2", … after)
|
|
66
|
+
* keyed by `${agentRefName}#${sanitizedName}` — NOT by skill index. Every
|
|
67
|
+
* entry on the SAME agent sharing a sanitized name maps to the identical
|
|
68
|
+
* suffix (only a name's first appearance on a given agent advances the
|
|
69
|
+
* cross-agent counter), so an intra-agent duplicate still collides on one
|
|
70
|
+
* address instead of silently acquiring a distinct label — that's a real
|
|
71
|
+
* authoring mistake (two skills with the identical name on ONE agent),
|
|
72
|
+
* still caught and dropped by `agentToTf`'s existing
|
|
73
|
+
* `seenA2ASkillAddresses` check. Only DIFFERENT agents reusing a name are
|
|
74
|
+
* the #294 case this disambiguates.
|
|
75
|
+
*/
|
|
76
|
+
export declare function computeA2ASkillLabelSuffixes(siblingAgents: readonly DeployableEntity[]): ReadonlyMap<string, string>;
|
|
32
77
|
/** `elementum_agent` + one tool resource per implemented tool, in ei's dialect. */
|
|
33
78
|
export declare function agentToTf(entity: DeployableEntity, ctx: AgentToTfContext): AgentToTfResult;
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Agent emission (M3, plan §4.3): `agentToTf` consumes the discovered
|
|
3
3
|
* `DeployableEntity` (the `defineAgent` def() payload) and emits
|
|
4
4
|
* `elementum_agent` + one tool resource per implemented tool (the tool pass
|
|
5
|
-
* delegates to `entities/agent-tool/to-tf.ts`)
|
|
5
|
+
* delegates to `entities/agent-tool/to-tf.ts`) + one `elementum_agent_a2a_skill`
|
|
6
|
+
* per a2aSkills entry (delegates to `entities/agent-a2a-skill/to-tf.ts`,
|
|
7
|
+
* issue #68).
|
|
6
8
|
*
|
|
7
9
|
* The dialect is ei's ACTUAL export (docs/design/m3-agent-dialect.md):
|
|
8
10
|
* app_id as the owning app's resource ref, the connector as a
|
|
@@ -14,25 +16,128 @@
|
|
|
14
16
|
* silent (plan §4.3).
|
|
15
17
|
*/
|
|
16
18
|
import { EntityTfError } from "../../engine/entity.js";
|
|
17
|
-
import { expr, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
19
|
+
import { appScopedResourceLabel, expr, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
20
|
+
import { a2aSkillToTf } from "../agent-a2a-skill/to-tf.js";
|
|
18
21
|
import { toolToTf } from "../agent-tool/to-tf.js";
|
|
19
22
|
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
20
23
|
import { CONNECTOR_ORG_BAG } from "../org/connector.js";
|
|
21
24
|
import { SKILL_RESOURCE_TYPE } from "../skill/module.js";
|
|
22
25
|
import { AGENT_RESOURCE_TYPE } from "./module.js";
|
|
23
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Config knobs `defineAgent` accepts that the terraform dialect does not
|
|
28
|
+
* carry (yet). `runAs`/`agentAuthentication`/`a2aStreaming`/
|
|
29
|
+
* `conversationIdleTimeout` moved out of this list in issue #170,
|
|
30
|
+
* `a2aCreateRecordEnabled` in issue #215 — they're now emitted (see the
|
|
31
|
+
* attrs assembly below); the encoders below still drop a value that
|
|
32
|
+
* doesn't fit the terraform-path shape, diagnosed individually rather
|
|
33
|
+
* than through this blanket list.
|
|
34
|
+
*/
|
|
24
35
|
const UNSUPPORTED_AGENT_KNOBS = [
|
|
25
36
|
"temperature",
|
|
26
37
|
"reasoningEffort",
|
|
27
|
-
"runAs",
|
|
28
38
|
"startingActions",
|
|
29
|
-
"agentAuthentication",
|
|
30
|
-
"a2aStreaming",
|
|
31
|
-
"conversationIdleTimeout",
|
|
32
39
|
"avatarAttachmentId",
|
|
33
40
|
"managedById",
|
|
34
41
|
"serviceAccountId",
|
|
35
42
|
];
|
|
43
|
+
/**
|
|
44
|
+
* `runAs` authoring is the opaque object shape shared with agent-tool's
|
|
45
|
+
* `runAs` (board item B28(d)); `elementum_agent.run_as` on the wire is a
|
|
46
|
+
* bare string and only `"current_user"` is documented for agents (unlike
|
|
47
|
+
* tools, which also accept `"publisher"`/`"service_account"`) — mirrors
|
|
48
|
+
* `parseRunAs` in `from-tf.ts`.
|
|
49
|
+
*/
|
|
50
|
+
function runAsValue(runAs, where, diagnostics) {
|
|
51
|
+
if (runAs["currentUser"] === true)
|
|
52
|
+
return "current_user";
|
|
53
|
+
diagnostics.push(`${where}: runAs ${JSON.stringify(runAs)} has no terraform-path encoding yet (only { currentUser: true } is supported); dropped`);
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
/** `agentAuthentication` → `jwt_authentication` — mirrors `parseJwtAuthentication` in `from-tf.ts`. */
|
|
57
|
+
function jwtAuthenticationValue(auth) {
|
|
58
|
+
const { jwt } = auth;
|
|
59
|
+
const keySourceAttrs = "jwks" in jwt.keySource
|
|
60
|
+
? { jwks_url: jwt.keySource.jwks.jwksUrl }
|
|
61
|
+
: { plain_text_key: jwt.keySource.plainText.plainTextKeyValuePem };
|
|
62
|
+
const value = {
|
|
63
|
+
enabled: jwt.enabled,
|
|
64
|
+
header_name: jwt.headerName,
|
|
65
|
+
email_address_claim_name: jwt.emailAddressClaimName,
|
|
66
|
+
...keySourceAttrs,
|
|
67
|
+
};
|
|
68
|
+
if (jwt.requiredClaims !== undefined && jwt.requiredClaims.length > 0) {
|
|
69
|
+
value["required_claims"] = jwt.requiredClaims.map((c) => ({
|
|
70
|
+
claim_name: c.claimName,
|
|
71
|
+
acceptable_values: [...c.acceptableValues],
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
76
|
+
function toSortableAgents(entities) {
|
|
77
|
+
const out = [];
|
|
78
|
+
for (const entity of entities) {
|
|
79
|
+
if (entity.kind !== "agent")
|
|
80
|
+
continue;
|
|
81
|
+
const payload = entity.payload;
|
|
82
|
+
out.push({
|
|
83
|
+
refName: entity.refName,
|
|
84
|
+
name: payload?.agent?.elementum?.name ?? "",
|
|
85
|
+
a2aSkills: payload?.a2aSkills ?? [],
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Mirrors ei's cross-agent a2a-skill-name disambiguation
|
|
92
|
+
* (`cmd/elementum/export/imports.go`'s `a2aNames` counting map over
|
|
93
|
+
* `app.AllAgents()`): a same-app, same-named a2a skill on two different
|
|
94
|
+
* agents is not a collision on the platform — ei's exporter gives the
|
|
95
|
+
* first occurrence of a sanitized name the bare label, each later
|
|
96
|
+
* occurrence `_1`, `_2`, …
|
|
97
|
+
*
|
|
98
|
+
* Ascending-by-agent-NAME confirmed live 2026-08-18 against real committed
|
|
99
|
+
* state on a deployed app (two identically-named a2a skills added via the
|
|
100
|
+
* platform UI to two different agents): "Default agent 2" landed at the
|
|
101
|
+
* bare label, "test agent" at `_1` — `D` < `t`, matching the assumed sort.
|
|
102
|
+
* A weaker signal than #310's skill-tool capture (that one deliberately
|
|
103
|
+
* reordered 3 skills' creation vs. name to rule out creation-order as an
|
|
104
|
+
* alternative explanation; this one only has 2 agents, so an
|
|
105
|
+
* agent-creation-order coincidence can't be fully excluded) — but real
|
|
106
|
+
* evidence from `ei`'s own exporter/import-address generation, not a
|
|
107
|
+
* guess. If a future capture contradicts it, only this function's sort
|
|
108
|
+
* needs to change — the suffix-assignment mechanics stay the same.
|
|
109
|
+
* Ordering of a2a skills WITHIN one agent is still assumed to be authored
|
|
110
|
+
* array order, unconfirmed live either way.
|
|
111
|
+
*
|
|
112
|
+
* Returns suffixes ("" for the first occurrence, "_1", "_2", … after)
|
|
113
|
+
* keyed by `${agentRefName}#${sanitizedName}` — NOT by skill index. Every
|
|
114
|
+
* entry on the SAME agent sharing a sanitized name maps to the identical
|
|
115
|
+
* suffix (only a name's first appearance on a given agent advances the
|
|
116
|
+
* cross-agent counter), so an intra-agent duplicate still collides on one
|
|
117
|
+
* address instead of silently acquiring a distinct label — that's a real
|
|
118
|
+
* authoring mistake (two skills with the identical name on ONE agent),
|
|
119
|
+
* still caught and dropped by `agentToTf`'s existing
|
|
120
|
+
* `seenA2ASkillAddresses` check. Only DIFFERENT agents reusing a name are
|
|
121
|
+
* the #294 case this disambiguates.
|
|
122
|
+
*/
|
|
123
|
+
export function computeA2ASkillLabelSuffixes(siblingAgents) {
|
|
124
|
+
const sorted = toSortableAgents(siblingAgents).sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
125
|
+
const counts = new Map();
|
|
126
|
+
const suffixes = new Map();
|
|
127
|
+
for (const agent of sorted) {
|
|
128
|
+
const namesOnThisAgent = new Set();
|
|
129
|
+
for (const entry of agent.a2aSkills) {
|
|
130
|
+
const base = sanitizeName(entry.name ?? "");
|
|
131
|
+
if (namesOnThisAgent.has(base))
|
|
132
|
+
continue;
|
|
133
|
+
namesOnThisAgent.add(base);
|
|
134
|
+
const count = counts.get(base) ?? 0;
|
|
135
|
+
counts.set(base, count + 1);
|
|
136
|
+
suffixes.set(`${agent.refName}#${base}`, count > 0 ? `_${count}` : "");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return suffixes;
|
|
140
|
+
}
|
|
36
141
|
/**
|
|
37
142
|
* authoring SkillRef token → the skill's id value. Self-app skills resolve
|
|
38
143
|
* purely from the token (same discipline as agent-tool's field refs); a
|
|
@@ -52,9 +157,11 @@ function skillIdValue(token, ctx) {
|
|
|
52
157
|
`renamed a skill file, the app's generated/catalog.ts may be stale; regenerate it (re-run \`edk pull ` +
|
|
53
158
|
`app\`, or the catalog-refresh step your workflow uses) before building again.`);
|
|
54
159
|
}
|
|
160
|
+
if (token.unresolvedId !== undefined)
|
|
161
|
+
return token.unresolvedId;
|
|
55
162
|
const refName = token.refName;
|
|
56
163
|
if (token.parent === ctx.appRefName) {
|
|
57
|
-
return expr.resourceAttr(SKILL_RESOURCE_TYPE, tsLabelToTfLabel(refName), ["id"]);
|
|
164
|
+
return expr.resourceAttr(SKILL_RESOURCE_TYPE, appScopedResourceLabel(ctx.appTfLabel, tsLabelToTfLabel(refName)), ["id"]);
|
|
58
165
|
}
|
|
59
166
|
const name = token.name ?? refName;
|
|
60
167
|
const tfLabel = sanitizeName(name);
|
|
@@ -73,7 +180,8 @@ export function agentToTf(entity, ctx) {
|
|
|
73
180
|
}
|
|
74
181
|
// The bag key IS the label (the stable naming contract) — the agent's
|
|
75
182
|
// refName comes from its file name, exactly like an app's.
|
|
76
|
-
const
|
|
183
|
+
const agentBareTfLabel = tsLabelToTfLabel(entity.refName);
|
|
184
|
+
const tfLabel = appScopedResourceLabel(ctx.appTfLabel, agentBareTfLabel);
|
|
77
185
|
const name = elementum.name ?? "";
|
|
78
186
|
const where = `agent "${name}"`;
|
|
79
187
|
const attrs = {
|
|
@@ -86,12 +194,26 @@ export function agentToTf(entity, ctx) {
|
|
|
86
194
|
attrs["first_message"] = elementum.firstMessage;
|
|
87
195
|
if (elementum.maxLength !== undefined)
|
|
88
196
|
attrs["max_tokens"] = elementum.maxLength;
|
|
197
|
+
if (elementum.runAs !== undefined) {
|
|
198
|
+
const value = runAsValue(elementum.runAs, where, ctx.diagnostics);
|
|
199
|
+
if (value !== undefined)
|
|
200
|
+
attrs["run_as"] = value;
|
|
201
|
+
}
|
|
202
|
+
if (elementum.agentAuthentication !== undefined) {
|
|
203
|
+
attrs["jwt_authentication"] = jwtAuthenticationValue(elementum.agentAuthentication);
|
|
204
|
+
}
|
|
205
|
+
if (elementum.conversationIdleTimeout !== undefined)
|
|
206
|
+
attrs["conversation_idle_timeout"] = elementum.conversationIdleTimeout;
|
|
207
|
+
if (elementum.a2aStreaming !== undefined)
|
|
208
|
+
attrs["a2a_streaming"] = elementum.a2aStreaming;
|
|
209
|
+
if (elementum.a2aCreateRecordEnabled !== undefined)
|
|
210
|
+
attrs["a2a_create_record_enabled"] = elementum.a2aCreateRecordEnabled;
|
|
89
211
|
const connector = elementum.aiProviderConnectorId;
|
|
90
212
|
if (connector === undefined) {
|
|
91
213
|
ctx.diagnostics.push(`${where}: no connector token — the platform will pick a default model`);
|
|
92
214
|
}
|
|
93
215
|
else {
|
|
94
|
-
const tsLabel = connector.refName ?? "";
|
|
216
|
+
const tsLabel = connector.parent !== undefined ? `${connector.parent}.${connector.refName ?? ""}` : (connector.refName ?? "");
|
|
95
217
|
const resolved = ctx.orgRefs.byTsLabel(CONNECTOR_ORG_BAG, tsLabel);
|
|
96
218
|
if (resolved === undefined) {
|
|
97
219
|
ctx.diagnostics.push(`${where}: connector token "${tsLabel}" is not in the org catalog — re-run \`elementum pull org --data-only\``);
|
|
@@ -117,20 +239,44 @@ export function agentToTf(entity, ctx) {
|
|
|
117
239
|
}
|
|
118
240
|
attrs["skill_access_config"] = skillAccessValue;
|
|
119
241
|
}
|
|
120
|
-
if (payload.a2aSkills !== undefined) {
|
|
121
|
-
ctx.diagnostics.push(`${where}: a2aSkills are not carried by the terraform path yet; dropped`);
|
|
122
|
-
}
|
|
123
242
|
const blocks = [{ kind: "resource", type: AGENT_RESOURCE_TYPE, label: tfLabel, attrs }];
|
|
124
243
|
for (const entry of payload.tools ?? []) {
|
|
125
244
|
const tool = toolToTf(entry, {
|
|
126
245
|
appRefName: ctx.appRefName,
|
|
127
246
|
appTfLabel: ctx.appTfLabel,
|
|
128
|
-
|
|
247
|
+
agentBareTfLabel,
|
|
129
248
|
foreignAppRef: (l, n) => ctx.orgRefs.foreignApp(l, n),
|
|
249
|
+
foreignElementRef: (l, n) => ctx.orgRefs.foreignElement(l, n),
|
|
250
|
+
foreignFieldRef: (t, l, o, n) => ctx.orgRefs.foreignField(t, l, o, n),
|
|
130
251
|
diagnostics: ctx.diagnostics,
|
|
131
252
|
});
|
|
132
253
|
if (tool !== undefined)
|
|
133
254
|
blocks.push(tool.block);
|
|
134
255
|
}
|
|
256
|
+
// Board issue #294: two agents in the same app can legitimately both
|
|
257
|
+
// author an a2a skill with the same display name — ei's own exporter
|
|
258
|
+
// disambiguates that case with a numeric suffix rather than rejecting it
|
|
259
|
+
// (see computeA2ASkillLabelSuffixes). A collision within THIS agent's own
|
|
260
|
+
// a2aSkills list (the same name twice on one agent) is a real authoring
|
|
261
|
+
// mistake, not a cross-agent scoping gap — still caught and dropped below.
|
|
262
|
+
const a2aSkillLabelSuffixes = computeA2ASkillLabelSuffixes(ctx.siblingEntities ?? [entity]);
|
|
263
|
+
const seenA2ASkillAddresses = new Set();
|
|
264
|
+
payload.a2aSkills?.forEach((entry) => {
|
|
265
|
+
const base = sanitizeName(entry.name ?? "");
|
|
266
|
+
const skill = a2aSkillToTf(entry, {
|
|
267
|
+
appTfLabel: ctx.appTfLabel,
|
|
268
|
+
agentBareTfLabel,
|
|
269
|
+
labelSuffix: a2aSkillLabelSuffixes.get(`${entity.refName}#${base}`) ?? "",
|
|
270
|
+
diagnostics: ctx.diagnostics,
|
|
271
|
+
});
|
|
272
|
+
if (skill === undefined)
|
|
273
|
+
return;
|
|
274
|
+
if (seenA2ASkillAddresses.has(skill.address)) {
|
|
275
|
+
ctx.diagnostics.push(`${where}: a2a skill "${entry.name}" collides with another skill's label (${skill.address}) — names must be unique per agent; dropped`);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
seenA2ASkillAddresses.add(skill.address);
|
|
279
|
+
blocks.push(skill.block);
|
|
280
|
+
});
|
|
135
281
|
return { blocks, address: `${AGENT_RESOURCE_TYPE}.${tfLabel}` };
|
|
136
282
|
}
|