@elementumai/edk 0.8.1 → 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 +166 -34
- package/dist-sdk/src/catalog/factories.js +18 -2
- package/dist-sdk/src/catalog/from-authoring.js +13 -1
- package/dist-sdk/src/catalog/org.js +51 -44
- package/dist-sdk/src/catalog/token.js +4 -0
- package/dist-sdk/src/catalog/types.d.ts +15 -0
- package/dist-sdk/src/core/types/app.d.ts +14 -8
- package/dist-sdk/src/engine/build/context.d.ts +40 -0
- package/dist-sdk/src/engine/build/context.js +11 -1
- 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 +29 -20
- package/dist-sdk/src/engine/tf/labels.js +32 -28
- 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/from-tf.d.ts +19 -1
- package/dist-sdk/src/entities/access-policy/from-tf.js +4 -6
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +12 -5
- package/dist-sdk/src/entities/access-policy/to-tf.js +21 -6
- 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.js +60 -2
- package/dist-sdk/src/entities/agent/from-tf.d.ts +12 -7
- package/dist-sdk/src/entities/agent/from-tf.js +22 -15
- package/dist-sdk/src/entities/agent/module.js +7 -3
- package/dist-sdk/src/entities/agent/to-tf.d.ts +46 -1
- package/dist-sdk/src/entities/agent/to-tf.js +102 -8
- 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/to-tf.d.ts +7 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +86 -26
- package/dist-sdk/src/entities/app/build.d.ts +35 -7
- package/dist-sdk/src/entities/app/build.js +19 -8
- package/dist-sdk/src/entities/app/from-tf.js +0 -7
- package/dist-sdk/src/entities/app/module.js +1 -0
- package/dist-sdk/src/entities/app/to-tf.js +13 -1
- package/dist-sdk/src/entities/automation/build.js +14 -6
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +27 -4
- package/dist-sdk/src/entities/automation/filter.d.ts +22 -0
- package/dist-sdk/src/entities/automation/filter.js +42 -1
- package/dist-sdk/src/entities/automation/from-tf.js +127 -11
- package/dist-sdk/src/entities/automation/to-tf.js +176 -18
- package/dist-sdk/src/entities/element/build.d.ts +26 -8
- package/dist-sdk/src/entities/element/build.js +44 -3
- package/dist-sdk/src/entities/element/from-tf.js +10 -11
- package/dist-sdk/src/entities/element/module.js +1 -0
- package/dist-sdk/src/entities/element/to-tf.js +5 -0
- package/dist-sdk/src/entities/field/build.d.ts +9 -5
- package/dist-sdk/src/entities/field/calc/runtime.js +2 -2
- package/dist-sdk/src/entities/field/from-tf.js +10 -10
- package/dist-sdk/src/entities/field/to-tf.d.ts +35 -18
- package/dist-sdk/src/entities/field/to-tf.js +110 -6
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +15 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +15 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +97 -8
- package/dist-sdk/src/entities/skill/module.js +1 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +26 -0
- package/dist-sdk/src/entities/skill/to-tf.js +63 -3
- package/dist-sdk/src/entities/skill/tools.d.ts +12 -5
- package/dist-sdk/src/entities/skill/tools.js +26 -1
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +19 -2
- package/dist-sdk/src/entities/skill-tool/from-tf.js +97 -8
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +11 -1
- package/dist-sdk/src/entities/skill-tool/to-tf.js +143 -27
- 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/to-tf.js +6 -0
- package/dist-sdk/src/graph/modules.js +2 -0
- package/dist-sdk/src/graph/types.d.ts +22 -2
- package/package.json +12 -7
|
@@ -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
10
|
import { optionalBoolean, optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
10
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";
|
|
@@ -27,15 +29,10 @@ const KNOWN_AGENT_ATTRS = new Set([
|
|
|
27
29
|
"jwt_authentication",
|
|
28
30
|
"conversation_idle_timeout",
|
|
29
31
|
"a2a_streaming",
|
|
32
|
+
"a2a_create_record_enabled",
|
|
30
33
|
]);
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
* pulled. `a2a_create_record_enabled` has no `defineAgent` option at all
|
|
34
|
-
* (issue #170) — decoding it needs a new authoring field, split from the
|
|
35
|
-
* other four run_as/jwt_authentication/conversation_idle_timeout/
|
|
36
|
-
* a2a_streaming attrs that issue fixed.
|
|
37
|
-
*/
|
|
38
|
-
const UNAUTHORABLE_AGENT_ATTRS = new Set(["starting_actions", "model", "a2a_create_record_enabled"]);
|
|
34
|
+
/** Dialect attrs with no authoring slot yet — reported by name, agent still pulled. */
|
|
35
|
+
const UNAUTHORABLE_AGENT_ATTRS = new Set(["starting_actions", "model"]);
|
|
39
36
|
/** Non-elementum agent variants (type + their config attrs) — the whole agent is skipped. */
|
|
40
37
|
const VARIANT_ATTRS = new Set([
|
|
41
38
|
"type",
|
|
@@ -182,11 +179,12 @@ function parseSkillAccessConfig(value, where, ownerTfLabel, ctx) {
|
|
|
182
179
|
return { mode: "CUSTOM", skills, ...preloadedProp };
|
|
183
180
|
}
|
|
184
181
|
/**
|
|
185
|
-
* The `elementum_agent` block + its tool blocks
|
|
186
|
-
*
|
|
187
|
-
* 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).
|
|
188
186
|
*/
|
|
189
|
-
export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx) {
|
|
187
|
+
export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx, a2aSkillBlocks = []) {
|
|
190
188
|
const label = agentBlock.label;
|
|
191
189
|
if (label === undefined || label === "") {
|
|
192
190
|
throw new EntityTfError("elementum_agent block is missing its label");
|
|
@@ -244,6 +242,12 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx)
|
|
|
244
242
|
if (tool !== undefined)
|
|
245
243
|
tools.push(tool);
|
|
246
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
|
+
}
|
|
247
251
|
let skillAccess;
|
|
248
252
|
const skillAccessAttr = attrs["skill_access_config"];
|
|
249
253
|
if (skillAccessAttr !== undefined) {
|
|
@@ -261,6 +265,7 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx)
|
|
|
261
265
|
}
|
|
262
266
|
const conversationIdleTimeout = optionalString(attrs, "conversation_idle_timeout", where, ctx);
|
|
263
267
|
const a2aStreaming = optionalBoolean(attrs, "a2a_streaming", where, ctx);
|
|
268
|
+
const a2aCreateRecordEnabled = optionalBoolean(attrs, "a2a_create_record_enabled", where, ctx);
|
|
264
269
|
const firstMessage = optionalString(attrs, "first_message", where, ctx);
|
|
265
270
|
const maxTokens = attrs["max_tokens"];
|
|
266
271
|
const maxLength = typeof maxTokens === "number" && Number.isSafeInteger(maxTokens) && maxTokens > 0
|
|
@@ -283,7 +288,9 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx)
|
|
|
283
288
|
...(agentAuthentication !== undefined && { agentAuthentication }),
|
|
284
289
|
...(conversationIdleTimeout !== undefined && { conversationIdleTimeout }),
|
|
285
290
|
...(a2aStreaming !== undefined && { a2aStreaming }),
|
|
291
|
+
...(a2aCreateRecordEnabled !== undefined && { a2aCreateRecordEnabled }),
|
|
286
292
|
tools,
|
|
293
|
+
...(a2aSkills.length > 0 && { a2aSkills }),
|
|
287
294
|
},
|
|
288
295
|
};
|
|
289
296
|
}
|
|
@@ -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) {
|
|
@@ -107,6 +110,7 @@ export const agentModule = {
|
|
|
107
110
|
appTfLabel: ctx.appTfLabel,
|
|
108
111
|
orgRefs: ctx.orgRefs,
|
|
109
112
|
diagnostics: ctx.diagnostics,
|
|
113
|
+
...(ctx.siblingEntities !== undefined && { siblingEntities: ctx.siblingEntities }),
|
|
110
114
|
}),
|
|
111
115
|
},
|
|
112
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
|
|
@@ -15,6 +17,7 @@
|
|
|
15
17
|
*/
|
|
16
18
|
import { EntityTfError } from "../../engine/entity.js";
|
|
17
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";
|
|
@@ -23,10 +26,11 @@ import { AGENT_RESOURCE_TYPE } from "./module.js";
|
|
|
23
26
|
/**
|
|
24
27
|
* Config knobs `defineAgent` accepts that the terraform dialect does not
|
|
25
28
|
* carry (yet). `runAs`/`agentAuthentication`/`a2aStreaming`/
|
|
26
|
-
* `conversationIdleTimeout` moved out of this list in issue #170
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
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.
|
|
30
34
|
*/
|
|
31
35
|
const UNSUPPORTED_AGENT_KNOBS = [
|
|
32
36
|
"temperature",
|
|
@@ -69,6 +73,71 @@ function jwtAuthenticationValue(auth) {
|
|
|
69
73
|
}
|
|
70
74
|
return value;
|
|
71
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
|
+
}
|
|
72
141
|
/**
|
|
73
142
|
* authoring SkillRef token → the skill's id value. Self-app skills resolve
|
|
74
143
|
* purely from the token (same discipline as agent-tool's field refs); a
|
|
@@ -137,6 +206,8 @@ export function agentToTf(entity, ctx) {
|
|
|
137
206
|
attrs["conversation_idle_timeout"] = elementum.conversationIdleTimeout;
|
|
138
207
|
if (elementum.a2aStreaming !== undefined)
|
|
139
208
|
attrs["a2a_streaming"] = elementum.a2aStreaming;
|
|
209
|
+
if (elementum.a2aCreateRecordEnabled !== undefined)
|
|
210
|
+
attrs["a2a_create_record_enabled"] = elementum.a2aCreateRecordEnabled;
|
|
140
211
|
const connector = elementum.aiProviderConnectorId;
|
|
141
212
|
if (connector === undefined) {
|
|
142
213
|
ctx.diagnostics.push(`${where}: no connector token — the platform will pick a default model`);
|
|
@@ -168,9 +239,6 @@ export function agentToTf(entity, ctx) {
|
|
|
168
239
|
}
|
|
169
240
|
attrs["skill_access_config"] = skillAccessValue;
|
|
170
241
|
}
|
|
171
|
-
if (payload.a2aSkills !== undefined) {
|
|
172
|
-
ctx.diagnostics.push(`${where}: a2aSkills are not carried by the terraform path yet; dropped`);
|
|
173
|
-
}
|
|
174
242
|
const blocks = [{ kind: "resource", type: AGENT_RESOURCE_TYPE, label: tfLabel, attrs }];
|
|
175
243
|
for (const entry of payload.tools ?? []) {
|
|
176
244
|
const tool = toolToTf(entry, {
|
|
@@ -179,10 +247,36 @@ export function agentToTf(entity, ctx) {
|
|
|
179
247
|
agentBareTfLabel,
|
|
180
248
|
foreignAppRef: (l, n) => ctx.orgRefs.foreignApp(l, n),
|
|
181
249
|
foreignElementRef: (l, n) => ctx.orgRefs.foreignElement(l, n),
|
|
250
|
+
foreignFieldRef: (t, l, o, n) => ctx.orgRefs.foreignField(t, l, o, n),
|
|
182
251
|
diagnostics: ctx.diagnostics,
|
|
183
252
|
});
|
|
184
253
|
if (tool !== undefined)
|
|
185
254
|
blocks.push(tool.block);
|
|
186
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
|
+
});
|
|
187
281
|
return { blocks, address: `${AGENT_RESOURCE_TYPE}.${tfLabel}` };
|
|
188
282
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
2
|
+
import type { TfBlock } from "../../engine/tf/index.js";
|
|
3
|
+
export interface NormalizedA2ASkill {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
readonly tags?: readonly string[];
|
|
7
|
+
readonly examples?: readonly string[];
|
|
8
|
+
readonly inputModes?: readonly string[];
|
|
9
|
+
readonly outputModes?: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
export interface A2ASkillOwner {
|
|
12
|
+
/** The owning agent's resource type + tfLabel. */
|
|
13
|
+
readonly agentType: string;
|
|
14
|
+
readonly agentLabel: string;
|
|
15
|
+
}
|
|
16
|
+
/** One a2a-skill block → its normalized shape; undefined = skipped with a diagnostic (wrong owner, missing required attr). */
|
|
17
|
+
export declare function a2aSkillFromTf(block: TfBlock, owner: A2ASkillOwner, ctx: FromTfContext): NormalizedA2ASkill | undefined;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2A skill extraction: one `elementum_agent_a2a_skill` block → its
|
|
3
|
+
* normalized shape. Pure metadata (no target/field refs, no `app_id` on
|
|
4
|
+
* the wire — see `provider/docs/resources/agent_a2a_skill.md`), so this is
|
|
5
|
+
* the simplest owned-child extractor in the agent family.
|
|
6
|
+
*/
|
|
7
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
8
|
+
import { optionalString, resourceRefLabel } from "../../engine/pull/context.js";
|
|
9
|
+
import { AGENT_A2A_SKILL_RESOURCE_TYPE } from "./module.js";
|
|
10
|
+
const KNOWN_A2A_SKILL_ATTRS = new Set(["agent_id", "name", "description", "tags", "examples", "input_modes", "output_modes"]);
|
|
11
|
+
function optionalStringArray(attrs, key, where, ctx) {
|
|
12
|
+
const v = attrs[key];
|
|
13
|
+
if (v === undefined)
|
|
14
|
+
return undefined;
|
|
15
|
+
if (!Array.isArray(v) || !v.every((item) => typeof item === "string")) {
|
|
16
|
+
ctx.diagnostics.push(`${where}: expected a list of strings "${key}", got ${JSON.stringify(v)}; dropped`);
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
return v;
|
|
20
|
+
}
|
|
21
|
+
/** One a2a-skill block → its normalized shape; undefined = skipped with a diagnostic (wrong owner, missing required attr). */
|
|
22
|
+
export function a2aSkillFromTf(block, owner, ctx) {
|
|
23
|
+
if (block.type !== AGENT_A2A_SKILL_RESOURCE_TYPE) {
|
|
24
|
+
ctx.diagnostics.push(`resource "${block.type}" is not a known a2a skill resource; skipped`);
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const label = block.label;
|
|
28
|
+
if (label === undefined || label === "") {
|
|
29
|
+
throw new EntityTfError(`${block.type} block is missing its label`);
|
|
30
|
+
}
|
|
31
|
+
const attrs = block.attrs;
|
|
32
|
+
const name = optionalString(attrs, "name", `a2a skill (${block.type}.${label})`, ctx) ?? "";
|
|
33
|
+
const where = `a2a skill "${name}" (${block.type}.${label})`;
|
|
34
|
+
for (const key of Object.keys(attrs)) {
|
|
35
|
+
if (!KNOWN_A2A_SKILL_ATTRS.has(key)) {
|
|
36
|
+
ctx.diagnostics.push(`${where}: unhandled attribute "${key}" — the export dialect grew; extend a2aSkillFromTf deliberately`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (resourceRefLabel(attrs["agent_id"], owner.agentType) !== owner.agentLabel) {
|
|
40
|
+
ctx.diagnostics.push(`${where}: agent_id does not reference ${owner.agentType}.${owner.agentLabel}; skipped`);
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
if (name === "") {
|
|
44
|
+
ctx.diagnostics.push(`${where}: name is required; skipped`);
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const description = optionalString(attrs, "description", where, ctx);
|
|
48
|
+
if (description === undefined || description === "") {
|
|
49
|
+
ctx.diagnostics.push(`${where}: description is required; skipped`);
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
const tags = optionalStringArray(attrs, "tags", where, ctx);
|
|
53
|
+
const examples = optionalStringArray(attrs, "examples", where, ctx);
|
|
54
|
+
const inputModes = optionalStringArray(attrs, "input_modes", where, ctx);
|
|
55
|
+
const outputModes = optionalStringArray(attrs, "output_modes", where, ctx);
|
|
56
|
+
return {
|
|
57
|
+
name,
|
|
58
|
+
description,
|
|
59
|
+
...(tags !== undefined && tags.length > 0 && { tags }),
|
|
60
|
+
...(examples !== undefined && examples.length > 0 && { examples }),
|
|
61
|
+
...(inputModes !== undefined && inputModes.length > 0 && { inputModes }),
|
|
62
|
+
...(outputModes !== undefined && outputModes.length > 0 && { outputModes }),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** The agent-a2a-skill entity's registry entry (see src/graph/). */
|
|
2
|
+
import { type EntityKindModule } from "../../graph/types.js";
|
|
3
|
+
export declare const AGENT_A2A_SKILL_RESOURCE_TYPE = "elementum_agent_a2a_skill";
|
|
4
|
+
export declare const agentA2ASkillModule: EntityKindModule;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The agent-a2a-skill entity's registry entry (see src/graph/). */
|
|
2
|
+
import { NO_CATALOG, NO_DATA, NO_LIFECYCLE } from "../../graph/types.js";
|
|
3
|
+
export const AGENT_A2A_SKILL_RESOURCE_TYPE = "elementum_agent_a2a_skill";
|
|
4
|
+
export const agentA2ASkillModule = {
|
|
5
|
+
kind: "agent-a2a-skill",
|
|
6
|
+
stream: { role: "streamMember" },
|
|
7
|
+
authoring: { unit: "inline", bag: "a2aSkills" },
|
|
8
|
+
parents: [{ parent: "agent", child: "agent-a2a-skill" }],
|
|
9
|
+
resource: { shape: "single", resourceType: AGENT_A2A_SKILL_RESOURCE_TYPE, adoptable: true },
|
|
10
|
+
data: NO_DATA,
|
|
11
|
+
lifecycle: NO_LIFECYCLE,
|
|
12
|
+
canvas: { participates: true, label: "A2A Skills", glyph: "⇄", component: "generic" },
|
|
13
|
+
catalog: NO_CATALOG,
|
|
14
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2A skill emission: one authored `A2ASkill` entry → its
|
|
3
|
+
* `elementum_agent_a2a_skill` resource block. Unlike agent tools, an A2A
|
|
4
|
+
* skill carries no `app_id` and no target/field references — it's pure
|
|
5
|
+
* metadata (name/description/tags/examples/input+output modes) describing
|
|
6
|
+
* what the agent offers to OTHER agents (provider/docs/resources/
|
|
7
|
+
* agent_a2a_skill.md). Owner passed in — this module never names the
|
|
8
|
+
* owning app.
|
|
9
|
+
*/
|
|
10
|
+
import { type TfBlock } from "../../engine/tf/index.js";
|
|
11
|
+
export interface A2ASkillWire {
|
|
12
|
+
readonly name?: string;
|
|
13
|
+
readonly description?: string;
|
|
14
|
+
readonly tags?: readonly string[];
|
|
15
|
+
readonly examples?: readonly string[];
|
|
16
|
+
readonly inputModes?: readonly string[];
|
|
17
|
+
readonly outputModes?: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
export interface A2ASkillToTfContext {
|
|
20
|
+
/** The owning app's tfLabel (namespace) — scopes the child label. */
|
|
21
|
+
readonly appTfLabel: string;
|
|
22
|
+
/** The owning agent's bare tfLabel (before the apps_ prefix). */
|
|
23
|
+
readonly agentBareTfLabel: string;
|
|
24
|
+
/**
|
|
25
|
+
* Cross-agent disambiguation suffix ("", "_1", "_2", …) — mirrors ei's
|
|
26
|
+
* own a2a-skill collision handling across different agents in the same
|
|
27
|
+
* app (board issue #294). Computed by the caller (`agentToTf`) via
|
|
28
|
+
* `computeA2ASkillLabelSuffixes`; empty when absent (single-agent
|
|
29
|
+
* contexts, most unit tests).
|
|
30
|
+
*/
|
|
31
|
+
readonly labelSuffix?: string;
|
|
32
|
+
/** Degradations land here — reported by the caller, never silent. */
|
|
33
|
+
readonly diagnostics: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface A2ASkillToTfResult {
|
|
36
|
+
readonly block: TfBlock;
|
|
37
|
+
readonly address: string;
|
|
38
|
+
}
|
|
39
|
+
/** One authored `A2ASkill` entry → its resource block; undefined = degraded (diagnostic already pushed). */
|
|
40
|
+
export declare function a2aSkillToTf(entry: A2ASkillWire, ctx: A2ASkillToTfContext): A2ASkillToTfResult | undefined;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2A skill emission: one authored `A2ASkill` entry → its
|
|
3
|
+
* `elementum_agent_a2a_skill` resource block. Unlike agent tools, an A2A
|
|
4
|
+
* skill carries no `app_id` and no target/field references — it's pure
|
|
5
|
+
* metadata (name/description/tags/examples/input+output modes) describing
|
|
6
|
+
* what the agent offers to OTHER agents (provider/docs/resources/
|
|
7
|
+
* agent_a2a_skill.md). Owner passed in — this module never names the
|
|
8
|
+
* owning app.
|
|
9
|
+
*/
|
|
10
|
+
import { appScopedResourceLabel, expr, sanitizeName } from "../../engine/tf/index.js";
|
|
11
|
+
import { AGENT_A2A_SKILL_RESOURCE_TYPE } from "./module.js";
|
|
12
|
+
/** One authored `A2ASkill` entry → its resource block; undefined = degraded (diagnostic already pushed). */
|
|
13
|
+
export function a2aSkillToTf(entry, ctx) {
|
|
14
|
+
const name = entry.name ?? "";
|
|
15
|
+
if (name === "") {
|
|
16
|
+
ctx.diagnostics.push("a2a skill entry has no name; dropped");
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
const where = `a2a skill "${name}"`;
|
|
20
|
+
if (entry.description === undefined || entry.description === "") {
|
|
21
|
+
ctx.diagnostics.push(`${where}: description is required; dropped`);
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
const agentTfLabel = appScopedResourceLabel(ctx.appTfLabel, ctx.agentBareTfLabel);
|
|
25
|
+
// edk#286: ei's own export scopes an a2a skill's label by the APP only
|
|
26
|
+
// (apps_<ns>_<ns>_<skill-name>) — no owning-agent segment, unlike agent
|
|
27
|
+
// tools. Confirmed live; a prior version of this line prefixed
|
|
28
|
+
// ctx.agentBareTfLabel here, which build-vs-export never actually
|
|
29
|
+
// matched (only became visible once a fully successful agent-adoption
|
|
30
|
+
// cycle reached that check).
|
|
31
|
+
const tfLabel = appScopedResourceLabel(ctx.appTfLabel, `${sanitizeName(name)}${ctx.labelSuffix ?? ""}`);
|
|
32
|
+
const attrs = {
|
|
33
|
+
agent_id: expr.resourceAttr("elementum_agent", agentTfLabel, ["id"]),
|
|
34
|
+
name,
|
|
35
|
+
description: entry.description,
|
|
36
|
+
};
|
|
37
|
+
if (entry.tags !== undefined && entry.tags.length > 0)
|
|
38
|
+
attrs["tags"] = entry.tags;
|
|
39
|
+
if (entry.examples !== undefined && entry.examples.length > 0)
|
|
40
|
+
attrs["examples"] = entry.examples;
|
|
41
|
+
if (entry.inputModes !== undefined && entry.inputModes.length > 0)
|
|
42
|
+
attrs["input_modes"] = entry.inputModes;
|
|
43
|
+
if (entry.outputModes !== undefined && entry.outputModes.length > 0)
|
|
44
|
+
attrs["output_modes"] = entry.outputModes;
|
|
45
|
+
const block = { kind: "resource", type: AGENT_A2A_SKILL_RESOURCE_TYPE, label: tfLabel, attrs };
|
|
46
|
+
return { block, address: `${AGENT_A2A_SKILL_RESOURCE_TYPE}.${tfLabel}` };
|
|
47
|
+
}
|
|
@@ -10,9 +10,12 @@
|
|
|
10
10
|
* - cross-app target → a name-keyed `data.elementum_app` lookup whose
|
|
11
11
|
* label derives from the app NAME (ei's sanitize rule);
|
|
12
12
|
* - tool fields → the field resource's ref (`elementum_*_field.<label>.id`),
|
|
13
|
-
* derivable purely from the FieldRef token (fieldType + refName)
|
|
13
|
+
* derivable purely from the FieldRef token (fieldType + refName); a field
|
|
14
|
+
* owned by a DIFFERENT app/element resolves via a `data.elementum_field`
|
|
15
|
+
* lookup instead (`parentKind`/`parentName` on the token — see
|
|
16
|
+
* `FieldRef`'s doc comment in `src/catalog/types.ts`).
|
|
14
17
|
*/
|
|
15
|
-
import { type TfBlock } from "../../engine/tf/index.js";
|
|
18
|
+
import { type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
16
19
|
export interface ToolToTfContext {
|
|
17
20
|
/** The owning app's refName + tfLabel (namespace) — self-target detection + app_id. */
|
|
18
21
|
readonly appRefName: string;
|
|
@@ -23,6 +26,8 @@ export interface ToolToTfContext {
|
|
|
23
26
|
foreignAppRef(tfLabel: string, name: string): void;
|
|
24
27
|
/** Records a foreign-ELEMENT data lookup for data.tf (board issue #42). */
|
|
25
28
|
foreignElementRef(tfLabel: string, name: string): void;
|
|
29
|
+
/** Records a `data.elementum_field` lookup for a field owned by a foreign app/element. */
|
|
30
|
+
foreignFieldRef(type: string, tfLabel: string, objectId: TfValue, name: string): void;
|
|
26
31
|
/** Degradations land here — reported by the caller, never silent. */
|
|
27
32
|
readonly diagnostics: string[];
|
|
28
33
|
}
|