@elementumai/edk 0.8.0-preview.11 → 0.8.1

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.
Files changed (165) hide show
  1. package/README.md +378 -324
  2. package/dist-sdk/src/catalog/ai-provider-models.d.ts +30 -0
  3. package/dist-sdk/src/catalog/ai-provider-models.js +63 -0
  4. package/dist-sdk/src/catalog/factories.d.ts +56 -3
  5. package/dist-sdk/src/catalog/factories.js +65 -2
  6. package/dist-sdk/src/catalog/from-authoring.js +6 -1
  7. package/dist-sdk/src/catalog/index.d.ts +3 -2
  8. package/dist-sdk/src/catalog/index.js +3 -2
  9. package/dist-sdk/src/catalog/org.d.ts +1 -1
  10. package/dist-sdk/src/catalog/org.js +83 -6
  11. package/dist-sdk/src/catalog/render.d.ts +13 -1
  12. package/dist-sdk/src/catalog/render.js +21 -4
  13. package/dist-sdk/src/catalog/token.js +14 -0
  14. package/dist-sdk/src/catalog/types.d.ts +60 -3
  15. package/dist-sdk/src/catalog/types.js +3 -0
  16. package/dist-sdk/src/core/system-fields.d.ts +2 -0
  17. package/dist-sdk/src/core/system-fields.js +2 -0
  18. package/dist-sdk/src/core/types/ai-provider.d.ts +10 -23
  19. package/dist-sdk/src/core/types/ai-provider.js +1 -25
  20. package/dist-sdk/src/core/types/app.d.ts +20 -1
  21. package/dist-sdk/src/engine/build/context.d.ts +18 -0
  22. package/dist-sdk/src/engine/build/source-context.d.ts +45 -0
  23. package/dist-sdk/src/engine/build/source-context.js +23 -0
  24. package/dist-sdk/src/engine/pull/context.d.ts +15 -0
  25. package/dist-sdk/src/engine/pull/org.d.ts +10 -0
  26. package/dist-sdk/src/engine/pull/org.js +34 -4
  27. package/dist-sdk/src/engine/tf/index.d.ts +1 -1
  28. package/dist-sdk/src/engine/tf/index.js +1 -1
  29. package/dist-sdk/src/engine/tf/labels.d.ts +45 -0
  30. package/dist-sdk/src/engine/tf/labels.js +71 -0
  31. package/dist-sdk/src/entities/access-policy/build.d.ts +26 -0
  32. package/dist-sdk/src/entities/access-policy/build.js +7 -0
  33. package/dist-sdk/src/entities/access-policy/filter.d.ts +61 -0
  34. package/dist-sdk/src/entities/access-policy/filter.js +83 -0
  35. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +48 -0
  36. package/dist-sdk/src/entities/access-policy/from-tf.js +189 -0
  37. package/dist-sdk/src/entities/access-policy/module.d.ts +3 -0
  38. package/dist-sdk/src/entities/access-policy/module.js +17 -0
  39. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +36 -0
  40. package/dist-sdk/src/entities/access-policy/to-tf.js +149 -0
  41. package/dist-sdk/src/entities/access-policy/types.d.ts +4 -0
  42. package/dist-sdk/src/entities/access-policy/types.js +10 -0
  43. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +38 -3
  44. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +199 -32
  45. package/dist-sdk/src/entities/agent/from-tf.d.ts +18 -3
  46. package/dist-sdk/src/entities/agent/from-tf.js +135 -15
  47. package/dist-sdk/src/entities/agent/index.d.ts +1 -1
  48. package/dist-sdk/src/entities/agent/module.js +8 -2
  49. package/dist-sdk/src/entities/agent/to-tf.js +62 -10
  50. package/dist-sdk/src/entities/agent/tools.d.ts +88 -9
  51. package/dist-sdk/src/entities/agent/tools.js +46 -7
  52. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +51 -4
  53. package/dist-sdk/src/entities/agent-tool/from-tf.js +131 -35
  54. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +4 -2
  55. package/dist-sdk/src/entities/agent-tool/to-tf.js +103 -17
  56. package/dist-sdk/src/entities/agent-tool/types.d.ts +5 -4
  57. package/dist-sdk/src/entities/agent-tool/types.js +38 -6
  58. package/dist-sdk/src/entities/app/build.d.ts +63 -13
  59. package/dist-sdk/src/entities/app/build.js +48 -1
  60. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +3 -0
  61. package/dist-sdk/src/entities/app/from-tf.d.ts +1 -1
  62. package/dist-sdk/src/entities/app/from-tf.js +32 -15
  63. package/dist-sdk/src/entities/app/index.d.ts +4 -1
  64. package/dist-sdk/src/entities/app/index.js +2 -1
  65. package/dist-sdk/src/entities/app/module.js +9 -2
  66. package/dist-sdk/src/entities/app/to-tf.d.ts +5 -0
  67. package/dist-sdk/src/entities/app/to-tf.js +33 -4
  68. package/dist-sdk/src/entities/automation/build.d.ts +57 -13
  69. package/dist-sdk/src/entities/automation/build.js +48 -36
  70. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +25 -8
  71. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +16 -1
  72. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +179 -43
  73. package/dist-sdk/src/entities/automation/filter.d.ts +15 -3
  74. package/dist-sdk/src/entities/automation/filter.js +12 -2
  75. package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -27
  76. package/dist-sdk/src/entities/automation/from-tf.js +1229 -223
  77. package/dist-sdk/src/entities/automation/index.d.ts +4 -0
  78. package/dist-sdk/src/entities/automation/index.js +4 -0
  79. package/dist-sdk/src/entities/automation/module.js +29 -32
  80. package/dist-sdk/src/entities/automation/operators.d.ts +29 -2
  81. package/dist-sdk/src/entities/automation/operators.js +27 -1
  82. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +19 -0
  83. package/dist-sdk/src/entities/automation/output-key-wire-name.js +24 -0
  84. package/dist-sdk/src/entities/automation/script-code.d.ts +10 -21
  85. package/dist-sdk/src/entities/automation/script-code.js +272 -5
  86. package/dist-sdk/src/entities/automation/tasks.d.ts +125 -19
  87. package/dist-sdk/src/entities/automation/tasks.js +83 -15
  88. package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -29
  89. package/dist-sdk/src/entities/automation/to-tf.js +1134 -231
  90. package/dist-sdk/src/entities/automation/triggers.d.ts +9 -1
  91. package/dist-sdk/src/entities/automation/types.d.ts +29 -4
  92. package/dist-sdk/src/entities/automation/types.js +76 -46
  93. package/dist-sdk/src/entities/element/build.d.ts +23 -10
  94. package/dist-sdk/src/entities/element/build.js +1 -0
  95. package/dist-sdk/src/entities/element/from-tf.d.ts +1 -1
  96. package/dist-sdk/src/entities/element/from-tf.js +18 -3
  97. package/dist-sdk/src/entities/element/index.d.ts +4 -1
  98. package/dist-sdk/src/entities/element/index.js +2 -1
  99. package/dist-sdk/src/entities/element/module.js +3 -1
  100. package/dist-sdk/src/entities/element/to-tf.js +21 -3
  101. package/dist-sdk/src/entities/field/build.d.ts +56 -13
  102. package/dist-sdk/src/entities/field/build.js +10 -0
  103. package/dist-sdk/src/entities/field/calc/runtime.js +4 -0
  104. package/dist-sdk/src/entities/field/from-tf.d.ts +5 -3
  105. package/dist-sdk/src/entities/field/from-tf.js +118 -7
  106. package/dist-sdk/src/entities/field/module.js +3 -2
  107. package/dist-sdk/src/entities/field/to-tf.d.ts +27 -9
  108. package/dist-sdk/src/entities/field/to-tf.js +62 -17
  109. package/dist-sdk/src/entities/field/types.d.ts +26 -0
  110. package/dist-sdk/src/entities/field/types.js +34 -12
  111. package/dist-sdk/src/entities/file-reader/build.d.ts +108 -50
  112. package/dist-sdk/src/entities/file-reader/build.js +23 -23
  113. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.d.ts +6 -0
  114. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +109 -0
  115. package/dist-sdk/src/entities/file-reader/from-tf.d.ts +13 -0
  116. package/dist-sdk/src/entities/file-reader/from-tf.js +172 -0
  117. package/dist-sdk/src/entities/file-reader/index.d.ts +8 -3
  118. package/dist-sdk/src/entities/file-reader/index.js +7 -2
  119. package/dist-sdk/src/entities/file-reader/module.d.ts +3 -0
  120. package/dist-sdk/src/entities/file-reader/module.js +115 -0
  121. package/dist-sdk/src/entities/file-reader/to-tf.d.ts +14 -0
  122. package/dist-sdk/src/entities/file-reader/to-tf.js +84 -0
  123. package/dist-sdk/src/entities/file-reader/types.d.ts +32 -0
  124. package/dist-sdk/src/entities/file-reader/types.js +30 -0
  125. package/dist-sdk/src/entities/org/ai-provider.d.ts +13 -0
  126. package/dist-sdk/src/entities/org/ai-provider.js +46 -0
  127. package/dist-sdk/src/entities/org/connector.d.ts +8 -1
  128. package/dist-sdk/src/entities/org/connector.js +12 -14
  129. package/dist-sdk/src/entities/org/group.js +10 -1
  130. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  131. package/dist-sdk/src/entities/org/index.js +1 -0
  132. package/dist-sdk/src/entities/org/user.js +10 -1
  133. package/dist-sdk/src/entities/shared/filters/ast.d.ts +44 -9
  134. package/dist-sdk/src/entities/shared/filters/types.d.ts +1 -1
  135. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +17 -0
  136. package/dist-sdk/src/entities/shared/tool-field-ref.js +31 -0
  137. package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -1
  138. package/dist-sdk/src/entities/shared/types/field-types.js +9 -0
  139. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +19 -0
  140. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +36 -8
  141. package/dist-sdk/src/entities/skill/from-tf.js +4 -3
  142. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  143. package/dist-sdk/src/entities/skill/module.js +6 -1
  144. package/dist-sdk/src/entities/skill/to-tf.js +3 -2
  145. package/dist-sdk/src/entities/skill/tools.d.ts +25 -3
  146. package/dist-sdk/src/entities/skill/tools.js +17 -0
  147. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +15 -2
  148. package/dist-sdk/src/entities/skill-tool/from-tf.js +32 -11
  149. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -0
  150. package/dist-sdk/src/entities/skill-tool/to-tf.js +32 -9
  151. package/dist-sdk/src/entities/view/from-tf.d.ts +6 -2
  152. package/dist-sdk/src/entities/view/from-tf.js +11 -9
  153. package/dist-sdk/src/entities/view/to-tf.d.ts +9 -7
  154. package/dist-sdk/src/entities/view/to-tf.js +33 -18
  155. package/dist-sdk/src/entities/view/types.d.ts +1 -1
  156. package/dist-sdk/src/entities/view/types.js +1 -1
  157. package/dist-sdk/src/graph/deferred-catalog-render.d.ts +0 -5
  158. package/dist-sdk/src/graph/deferred-catalog-render.js +1 -20
  159. package/dist-sdk/src/graph/index.d.ts +8 -0
  160. package/dist-sdk/src/graph/index.js +13 -9
  161. package/dist-sdk/src/graph/modules.js +6 -1
  162. package/dist-sdk/src/graph/types.d.ts +77 -3
  163. package/package.json +42 -14
  164. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +0 -76
  165. package/dist-sdk/src/entities/automation/value-ref-tf.js +0 -190
@@ -2,7 +2,9 @@
2
2
  * printAgentV2 — pulled agent rendering for the terraform path (M3).
3
3
  * Consumes the `NormalizedAgent` that `agentFromTf` produces and emits an
4
4
  * `apps/<app>/agents/<refName>.ts` authoring file: `defineAgent` with the
5
- * connector as an `org.connectors` token, tool targets as `catalog` tokens
5
+ * connector as a `catalog.aiProviders.<provider>.models.<model>` token (the
6
+ * generated org-root barrel re-exports `org.aiProviders`, so this file needs
7
+ * no separate relative `org.js` import), tool targets as `catalog` tokens
6
8
  * (self-app) or a TODO literal (foreign apps — their catalog may not exist
7
9
  * in this workspace), and tool fields as `catalog.<app>.fields.<key>`.
8
10
  *
@@ -12,7 +14,40 @@ import type { NormalizedAgent } from "../from-tf.js";
12
14
  export interface PrintAgentV2Options {
13
15
  /** The owning app's refName — `parent:` and the catalog token root. */
14
16
  readonly appRefName: string;
15
- /** Module specifier for the workspace org bags (e.g. "../../../org.js"). */
16
- readonly orgImportPath: string;
17
+ /**
18
+ * Set for a cross-org clone: the connector and any foreign-app tool
19
+ * target were resolved against the SOURCE org, so — absent a same-name
20
+ * match in {@link destinationConnectorKeys} — they're flagged as TODOs
21
+ * for manual review instead of printed as resolved references.
22
+ */
23
+ readonly crossOrg?: boolean;
24
+ /**
25
+ * The destination org's connector compound keys (`"<provider>.<model>"`,
26
+ * cross-org only). When the source's `connectorKey` is a member, that
27
+ * means the destination org ALSO has that provider/model pair (keys are
28
+ * name-derived, see `src/engine/tf/labels.ts`) — printed as a resolved
29
+ * reference instead of a TODO.
30
+ */
31
+ readonly destinationConnectorKeys?: ReadonlySet<string>;
32
+ /**
33
+ * A destination-org connector compound key (`"<provider>.<model>"`) the
34
+ * caller already confirmed (e.g. `edk clone app --target-root` prompting
35
+ * the user interactively when the source connector — or the absence of
36
+ * one — has no automatic match). When set, takes priority over both the
37
+ * TODO paths below — printed directly, uncommented.
38
+ */
39
+ readonly connectorKeyOverride?: string;
40
+ /**
41
+ * Name → refName for every app already on disk in this workspace (board
42
+ * issue #40). A `foreignApp` tool target whose name is a key here prints
43
+ * `catalog.<refName>` instead of the always-safe literal stub.
44
+ */
45
+ readonly foreignAppRefNames?: ReadonlyMap<string, string>;
46
+ /**
47
+ * Name → refName for every element already on disk in this workspace
48
+ * (board issue #42/#40). A `foreignElement` tool target whose name is a
49
+ * key here prints `catalog.<refName>` instead of the literal stub.
50
+ */
51
+ readonly foreignElementRefNames?: ReadonlyMap<string, string>;
17
52
  }
18
53
  export declare function printAgentV2(agent: NormalizedAgent, opts: PrintAgentV2Options): string;
@@ -2,7 +2,9 @@
2
2
  * printAgentV2 — pulled agent rendering for the terraform path (M3).
3
3
  * Consumes the `NormalizedAgent` that `agentFromTf` produces and emits an
4
4
  * `apps/<app>/agents/<refName>.ts` authoring file: `defineAgent` with the
5
- * connector as an `org.connectors` token, tool targets as `catalog` tokens
5
+ * connector as a `catalog.aiProviders.<provider>.models.<model>` token (the
6
+ * generated org-root barrel re-exports `org.aiProviders`, so this file needs
7
+ * no separate relative `org.js` import), tool targets as `catalog` tokens
6
8
  * (self-app) or a TODO literal (foreign apps — their catalog may not exist
7
9
  * in this workspace), and tool fields as `catalog.<app>.fields.<key>`.
8
10
  *
@@ -13,17 +15,36 @@ import { sdkPackageSpecifier } from "../../../internal/sdk-package.js";
13
15
  const TOOL_FACTORY_BY_TYPE_KEY = {
14
16
  createRecord: "agentCreateRecord",
15
17
  searchAspect: "agentSearchAspect",
18
+ updateRecord: "agentUpdateRecord",
16
19
  executeWorkflow: "agentRunAutomation",
20
+ searchTable: "agentSearchTable",
17
21
  };
22
+ /**
23
+ * A safe placeholder `ConnectorRef` literal (board issue — a property-access
24
+ * chain like `catalog.aiProviders.TODO_PROVIDER.models.TODO_CONNECTOR` looks
25
+ * like a TODO but ISN'T one: `TODO_PROVIDER` is never a real catalog key, so
26
+ * evaluating that expression throws the moment ANYTHING loads the file (a
27
+ * build, `edk pull org --data-only`'s catalog-regen bootstrap, …) instead of
28
+ * failing with the intended "needs manual review" diagnostic. A plain
29
+ * `ConnectorRef`-shaped object literal — the same pattern `foreignApp`/
30
+ * `foreignSkill` stubs already use — loads safely; `agentToTf`'s org-catalog
31
+ * lookup then degrades it to a clear build-time diagnostic instead
32
+ * ("connector token ... is not in the org catalog"), exactly like an
33
+ * unresolved foreignApp/foreignSkill token does.
34
+ */
35
+ const TODO_CONNECTOR_TOKEN = '{ __kind: "connector", refName: "TODO_CONNECTOR", name: "TODO_CONNECTOR", parent: "TODO_PROVIDER" }';
36
+ /** A connector's compound "<provider>.<model>" key → its catalog token path. */
37
+ function printConnectorToken(connectorKey) {
38
+ const [providerKey, modelKey] = connectorKey.split(".");
39
+ if (providerKey === undefined || modelKey === undefined) {
40
+ return `${TODO_CONNECTOR_TOKEN} /* TODO: unrecognized connector key "${connectorKey}" */`;
41
+ }
42
+ return `catalog.aiProviders.${providerKey}.models.${modelKey}`;
43
+ }
18
44
  export function printAgentV2(agent, opts) {
19
- const { appRefName, orgImportPath } = opts;
45
+ const { appRefName } = opts;
46
+ const crossOrg = opts.crossOrg === true;
20
47
  const factories = [...new Set(agent.tools.map((t) => TOOL_FACTORY_BY_TYPE_KEY[t.typeKey]).filter(Boolean))].sort();
21
- const usesCatalog = agent.tools.some((t) => t.target?.kind === "self" || (t.fields !== undefined && t.fields.length > 0) || t.typeKey === "executeWorkflow") ||
22
- (agent.skillAccess !== undefined &&
23
- [
24
- ...(agent.skillAccess.mode === "CUSTOM" ? agent.skillAccess.skills : []),
25
- ...(agent.skillAccess.preloadedSkills ?? []),
26
- ].some((s) => s.kind === "self"));
27
48
  const lines = [];
28
49
  lines.push("/**");
29
50
  lines.push(` * ${agent.name}`);
@@ -33,21 +54,35 @@ export function printAgentV2(agent, opts) {
33
54
  lines.push(" */");
34
55
  lines.push("");
35
56
  lines.push(`import { ${[...factories, "defineAgent"].sort().join(", ")} } from "${sdkPackageSpecifier("agents")}";`);
36
- if (usesCatalog)
37
- lines.push(`import catalog from "@catalog";`);
38
- if (agent.connectorKey !== undefined)
39
- lines.push(`import { org } from ${quote(orgImportPath)};`);
57
+ // Always needed: `connector:` is required and always a catalog.aiProviders
58
+ // token (or the TODO placeholder), and the barrel already re-exports
59
+ // org.aiProviders — no separate relative org.js import is needed here.
60
+ lines.push(`import catalog from "@catalog";`);
40
61
  lines.push("");
41
62
  lines.push(`const ${agent.refName} = defineAgent({`);
42
63
  lines.push(` name: ${quote(agent.name)},`);
43
64
  lines.push(` parent: ${quote(appRefName)},`);
44
- if (agent.connectorKey !== undefined) {
45
- lines.push(` connector: org.connectors.${agent.connectorKey},`);
65
+ const connectorMatchesDestination = agent.connectorKey !== undefined && (opts.destinationConnectorKeys?.has(agent.connectorKey) ?? false);
66
+ if (opts.connectorKeyOverride !== undefined) {
67
+ // Interactively confirmed by the caller — print directly, uncommented,
68
+ // regardless of which TODO path this would otherwise have taken.
69
+ lines.push(` connector: ${printConnectorToken(opts.connectorKeyOverride)},`);
70
+ }
71
+ else if (agent.connectorKey !== undefined && crossOrg && !connectorMatchesDestination) {
72
+ // Resolved, but against the SOURCE org's catalog, and no same-named
73
+ // connector was found in the destination — flag for manual review
74
+ // rather than carry over a token that doesn't exist there.
75
+ lines.push(` connector: ${TODO_CONNECTOR_TOKEN}, // TODO: cross-org clone — connector "${agent.connectorKey}" was resolved in the SOURCE org; verify/replace with the destination org's catalog.aiProviders.<provider>.models.<model>`);
76
+ }
77
+ else if (agent.connectorKey !== undefined) {
78
+ // Either same-org, or cross-org with a same-named connector confirmed
79
+ // present in the destination org.
80
+ lines.push(` connector: ${printConnectorToken(agent.connectorKey)},`);
46
81
  }
47
82
  else {
48
83
  // No connector in the stream — the platform defaulted the model. There
49
84
  // is no token to print; the author picks one (connector is required).
50
- lines.push(` connector: org.connectors.TODO_CONNECTOR, // TODO: no connector in the export — pick one`);
85
+ lines.push(` connector: ${TODO_CONNECTOR_TOKEN}, // TODO: no connector in the export — pick one`);
51
86
  }
52
87
  lines.push(` description: ${quote(agent.description)},`);
53
88
  lines.push(` instructions: ${quote(agent.instructions)},`);
@@ -56,12 +91,22 @@ export function printAgentV2(agent, opts) {
56
91
  if (agent.maxLength !== undefined)
57
92
  lines.push(` maxLength: ${String(agent.maxLength)},`);
58
93
  if (agent.skillAccess !== undefined) {
59
- lines.push(...printSkillAccess(agent.skillAccess, appRefName).map((l) => ` ${l}`));
94
+ lines.push(...printSkillAccess(agent.skillAccess, appRefName, crossOrg).map((l) => ` ${l}`));
95
+ }
96
+ if (agent.runAs !== undefined)
97
+ lines.push(` runAs: ${printRunAs(agent.runAs)},`);
98
+ if (agent.agentAuthentication !== undefined) {
99
+ lines.push(...printAgentAuthentication(agent.agentAuthentication).map((l) => ` ${l}`));
100
+ }
101
+ if (agent.conversationIdleTimeout !== undefined) {
102
+ lines.push(` conversationIdleTimeout: ${quote(agent.conversationIdleTimeout)},`);
60
103
  }
104
+ if (agent.a2aStreaming !== undefined)
105
+ lines.push(` a2aStreaming: ${String(agent.a2aStreaming)},`);
61
106
  if (agent.tools.length > 0) {
62
107
  lines.push(" tools: [");
63
108
  for (const tool of agent.tools) {
64
- lines.push(...printTool(tool, appRefName).map((l) => ` ${l}`));
109
+ lines.push(...printTool(tool, appRefName, crossOrg, opts.foreignAppRefNames, opts.foreignElementRefNames).map((l) => ` ${l}`));
65
110
  }
66
111
  lines.push(" ],");
67
112
  }
@@ -79,14 +124,31 @@ function safeMember(name) {
79
124
  function safeKey(name) {
80
125
  return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) ? name : quote(name);
81
126
  }
82
- function printSkillRefToken(ref, appRefName) {
127
+ /**
128
+ * A skill reference line, INCLUDING its trailing comma (and, cross-org, a
129
+ * trailing TODO comment) — the comma must precede the comment or it gets
130
+ * swallowed into commented-out text and silently drops the array separator,
131
+ * same failure mode as a manually-mistyped `,/ TODO` comment marker.
132
+ */
133
+ function printSkillRefToken(ref, appRefName, crossOrg) {
83
134
  if (ref.kind === "self")
84
- return `catalog.${appRefName}.skills.${ref.key}`;
135
+ return `catalog.${appRefName}.skills.${ref.key},`;
136
+ if (ref.kind === "unresolved") {
137
+ // No name, no data block - nothing to build a real token from. Round-trips
138
+ // the exact raw id via `unresolvedId`, the same escape ApprovalChainRef
139
+ // already uses for its own no-data-lookup case. `name` is required by
140
+ // SkillRef's shape even though there's no real display name to put there;
141
+ // the raw id fills both slots, same as `refName`.
142
+ return `{ __kind: "skill", refName: ${quote(ref.id)}, name: ${quote(ref.id)}, unresolvedId: ${quote(ref.id)} }, // TODO: this skill isn't resolvable from the export (no name, no data block) - identify it manually and replace with a real catalog.<app>.skills.<key> token`;
143
+ }
85
144
  // The foreign app's catalog may not exist in this workspace — a literal
86
145
  // token compiles and deploys; swap for a catalog token when available.
87
- return `{ __kind: "skill", refName: ${quote(ref.name)}, name: ${quote(ref.name)} }`;
146
+ const todo = crossOrg
147
+ ? ` // TODO: cross-org clone — "${ref.name}" was resolved in the SOURCE org; verify it exists (with this name) in the destination org`
148
+ : "";
149
+ return `{ __kind: "skill", refName: ${quote(ref.name)}, name: ${quote(ref.name)} },${todo}`;
88
150
  }
89
- function printSkillAccess(access, appRefName) {
151
+ function printSkillAccess(access, appRefName, crossOrg) {
90
152
  const hasPreloaded = access.preloadedSkills !== undefined && access.preloadedSkills.length > 0;
91
153
  if (access.mode !== "CUSTOM" && !hasPreloaded) {
92
154
  return [`skillAccess: { mode: ${quote(access.mode)} },`];
@@ -95,19 +157,55 @@ function printSkillAccess(access, appRefName) {
95
157
  if (access.mode === "CUSTOM") {
96
158
  lines.push(` skills: [`);
97
159
  for (const ref of access.skills)
98
- lines.push(` ${printSkillRefToken(ref, appRefName)},`);
160
+ lines.push(` ${printSkillRefToken(ref, appRefName, crossOrg)}`);
99
161
  lines.push(` ],`);
100
162
  }
101
163
  if (hasPreloaded) {
102
164
  lines.push(` preloadedSkills: [`);
103
165
  for (const ref of access.preloadedSkills)
104
- lines.push(` ${printSkillRefToken(ref, appRefName)},`);
166
+ lines.push(` ${printSkillRefToken(ref, appRefName, crossOrg)}`);
105
167
  lines.push(` ],`);
106
168
  }
107
169
  lines.push(`},`);
108
170
  return lines;
109
171
  }
110
- function printTool(tool, appRefName) {
172
+ /** `AgentToolRunAs` is opaque — `agentFromTf` only ever produces `{ currentUser: true }` today. */
173
+ function printRunAs(runAs) {
174
+ if (runAs["currentUser"] !== undefined)
175
+ return `{ currentUser: ${String(runAs["currentUser"])} }`;
176
+ if (runAs["publisher"] !== undefined)
177
+ return `{ publisher: ${String(runAs["publisher"])} }`;
178
+ const serviceAccount = runAs["serviceAccount"];
179
+ if (serviceAccount?.serviceAccount !== undefined) {
180
+ return `{ serviceAccount: { serviceAccount: ${quote(String(serviceAccount.serviceAccount))} } }`;
181
+ }
182
+ return JSON.stringify(runAs);
183
+ }
184
+ function printAgentAuthentication(auth) {
185
+ const { jwt } = auth;
186
+ const lines = [
187
+ `agentAuthentication: {`,
188
+ ` jwt: {`,
189
+ ` enabled: ${String(jwt.enabled)},`,
190
+ ` headerName: ${quote(jwt.headerName)},`,
191
+ ` emailAddressClaimName: ${quote(jwt.emailAddressClaimName)},`,
192
+ ];
193
+ const keySource = "jwks" in jwt.keySource
194
+ ? `{ jwks: { jwksUrl: ${quote(jwt.keySource.jwks.jwksUrl)} } }`
195
+ : `{ plainText: { plainTextKeyValuePem: ${quote(jwt.keySource.plainText.plainTextKeyValuePem)} } }`;
196
+ lines.push(` keySource: ${keySource},`);
197
+ if (jwt.requiredClaims !== undefined && jwt.requiredClaims.length > 0) {
198
+ lines.push(` requiredClaims: [`);
199
+ for (const claim of jwt.requiredClaims) {
200
+ lines.push(` { claimName: ${quote(claim.claimName)}, acceptableValues: [${claim.acceptableValues.map(quote).join(", ")}] },`);
201
+ }
202
+ lines.push(` ],`);
203
+ }
204
+ lines.push(` },`);
205
+ lines.push(`},`);
206
+ return lines;
207
+ }
208
+ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElementRefNames) {
111
209
  const factory = TOOL_FACTORY_BY_TYPE_KEY[tool.typeKey] ?? "agentSearchAspect";
112
210
  const lines = [`${factory}({`];
113
211
  lines.push(` name: ${quote(tool.name)},`);
@@ -149,26 +247,95 @@ function printTool(tool, appRefName) {
149
247
  lines.push(` aspect: catalog.${appRefName},`);
150
248
  }
151
249
  else if (tool.target !== undefined && tool.target.kind === "foreignApp") {
152
- // The foreign app's catalog may not exist in this workspace — a literal
153
- // token compiles and deploys; swap for a catalog token when available.
154
- lines.push(` aspect: { __kind: "app", refName: ${quote(tool.target.name)}, name: ${quote(tool.target.name)} },`);
250
+ const foreignRefName = foreignAppRefNames?.get(tool.target.name);
251
+ if (foreignRefName !== undefined) {
252
+ // The dependency is already pulled into this workspace (board issue
253
+ // #40) — a typed token, not a stub, so tsc catches drift if the
254
+ // foreign app's fields change out from under this tool.
255
+ lines.push(` aspect: catalog.${foreignRefName},`);
256
+ }
257
+ else {
258
+ // The foreign app's catalog may not exist in this workspace — a literal
259
+ // token compiles and deploys; swap for a catalog token when available
260
+ // (\`edk pull app\` reports missing dependencies like this one).
261
+ const todo = crossOrg
262
+ ? ` // TODO: cross-org clone — "${tool.target.name}" was resolved in the SOURCE org; verify it exists (with this name) in the destination org`
263
+ : "";
264
+ lines.push(` aspect: { __kind: "app", refName: ${quote(tool.target.name)}, name: ${quote(tool.target.name)} },${todo}`);
265
+ }
155
266
  }
156
- if (tool.typeKey === "searchAspect") {
267
+ else if (tool.target !== undefined && tool.target.kind === "foreignElement") {
268
+ // Board issue #42: an aspect target can be an element, not just an app —
269
+ // same treatment as foreignApp, distinct stub `__kind`.
270
+ const foreignRefName = foreignElementRefNames?.get(tool.target.name);
271
+ if (foreignRefName !== undefined) {
272
+ lines.push(` aspect: catalog.${foreignRefName},`);
273
+ }
274
+ else {
275
+ const todo = crossOrg
276
+ ? ` // TODO: cross-org clone — "${tool.target.name}" was resolved in the SOURCE org; verify it exists (with this name) in the destination org`
277
+ : "";
278
+ lines.push(` aspect: { __kind: "element", refName: ${quote(tool.target.name)}, name: ${quote(tool.target.name)} },${todo}`);
279
+ }
280
+ }
281
+ if (tool.typeKey === "searchAspect" || tool.typeKey === "searchTable") {
157
282
  lines.push(` queryDescription: ${quote(tool.queryDescription ?? "")},`);
158
283
  if (tool.limit !== undefined)
159
284
  lines.push(` limit: ${tool.limit},`);
160
285
  }
286
+ if (tool.typeKey === "updateRecord" && tool.handleDescription !== undefined) {
287
+ lines.push(` handleDescription: ${quote(tool.handleDescription)},`);
288
+ }
289
+ if (tool.typeKey === "searchTable" && tool.searchTableId !== undefined) {
290
+ // Always a raw platform id — see NormalizedAgentTool.searchTableId's
291
+ // comment; ei never exports a resolvable reference for this attribute.
292
+ lines.push(` table: ${quote(tool.searchTableId)}, // TODO: raw search table id - ei's export never resolves this to a reference`);
293
+ }
161
294
  if (tool.fields !== undefined && tool.fields.length > 0) {
162
295
  lines.push(" fields: [");
163
296
  for (const f of tool.fields) {
164
- const parts = [`field: catalog.${appRefName}.fields.${f.key}`];
297
+ // A foreign/out-of-scope aspect's field has no field resource ei can
298
+ // reference — it falls back to a bare platform id (board issue #169);
299
+ // print the raw-id shape (AgentSearchRawIdField/AgentRecordRawIdField)
300
+ // instead of a catalog token.
301
+ const isRaw = f.key === undefined;
302
+ const parts = isRaw ? [`fieldId: ${quote(f.rawFieldId ?? "")}`] : [`field: catalog.${appRefName}.fields.${f.key}`];
165
303
  if (f.name !== undefined)
166
304
  parts.push(`name: ${quote(f.name)}`);
167
- if (f.description !== undefined)
168
- parts.push(`description: ${quote(f.description)}`);
305
+ // Always emit description (backfill "") so pulled source satisfies
306
+ // AgentSearchField / AgentRecordField's required description.
307
+ parts.push(`description: ${quote(f.description ?? "")}`);
169
308
  if (f.required !== undefined)
170
309
  parts.push(`required: ${f.required}`);
171
- lines.push(` { ${parts.join(", ")} },`);
310
+ const todo = isRaw ? " // TODO: raw platform field id - the field belongs to a foreign/out-of-scope aspect ei can't resolve to a reference" : "";
311
+ lines.push(` { ${parts.join(", ")} },${todo}`);
312
+ }
313
+ lines.push(" ],");
314
+ }
315
+ // searchTable's own field shapes: field_id is always a raw platform id
316
+ // (see NormalizedSearchTableField's comment), so these print as `fieldId:`
317
+ // literals rather than `field: catalog....` tokens.
318
+ if (tool.searchTableFields !== undefined && tool.searchTableFields.length > 0) {
319
+ lines.push(" fields: [");
320
+ for (const f of tool.searchTableFields) {
321
+ const parts = [`fieldId: ${quote(f.fieldId)}`];
322
+ if (f.name !== undefined)
323
+ parts.push(`name: ${quote(f.name)}`);
324
+ if (f.description !== undefined)
325
+ parts.push(`description: ${quote(f.description)}`);
326
+ lines.push(` { ${parts.join(", ")} }, // TODO: raw search table field id - ei's export never resolves this to a reference`);
327
+ }
328
+ lines.push(" ],");
329
+ }
330
+ if (tool.returnFields !== undefined && tool.returnFields.length > 0) {
331
+ lines.push(" returnFields: [");
332
+ for (const f of tool.returnFields) {
333
+ const parts = [`fieldId: ${quote(f.fieldId)}`];
334
+ if (f.name !== undefined)
335
+ parts.push(`name: ${quote(f.name)}`);
336
+ if (f.displayName !== undefined)
337
+ parts.push(`displayName: ${quote(f.displayName)}`);
338
+ lines.push(` { ${parts.join(", ")} }, // TODO: raw search table field id - ei's export never resolves this to a reference`);
172
339
  }
173
340
  lines.push(" ],");
174
341
  }
@@ -8,13 +8,24 @@
8
8
  import { type FromTfContext } from "../../engine/pull/context.js";
9
9
  import { type TfBlock } from "../../engine/tf/index.js";
10
10
  import { type NormalizedAgentTool } from "../agent-tool/from-tf.js";
11
- /** A resolved skill reference: this app's own skill (by catalog key) or a foreign app's (by name only). */
11
+ import type { AgentAuthentication } from "./build.js";
12
+ import type { AgentToolRunAs } from "./tools.js";
13
+ /**
14
+ * A resolved skill reference: this app's own skill (by catalog key), a
15
+ * foreign app's (by name only), or a raw platform id the export carries with
16
+ * no way to resolve it further at all — confirmed live: a `skill_ids` entry
17
+ * can be a bare UUID literal with neither a resource ref into this stream
18
+ * nor a `data.elementum_agentic_skill` block backing it anywhere in the export.
19
+ */
12
20
  export type NormalizedSkillRef = {
13
21
  readonly kind: "self";
14
22
  readonly key: string;
15
23
  } | {
16
24
  readonly kind: "foreign";
17
25
  readonly name: string;
26
+ } | {
27
+ readonly kind: "unresolved";
28
+ readonly id: string;
18
29
  };
19
30
  export type NormalizedSkillAccess = {
20
31
  readonly mode: "NONE" | "ALL" | "ALL_APP";
@@ -32,9 +43,13 @@ export interface NormalizedAgent {
32
43
  readonly instructions: string;
33
44
  readonly firstMessage?: string;
34
45
  readonly maxLength?: number;
35
- /** org.ts `connectors` bag key (the data label's tsLabel image), when pinned. */
46
+ /** org.ts `aiProviders.<provider>.models.<model>` compound key ("<provider>.<model>"), when pinned. */
36
47
  readonly connectorKey?: string;
37
48
  readonly skillAccess?: NormalizedSkillAccess;
49
+ readonly runAs?: AgentToolRunAs;
50
+ readonly agentAuthentication?: AgentAuthentication;
51
+ readonly conversationIdleTimeout?: string;
52
+ readonly a2aStreaming?: boolean;
38
53
  readonly tools: readonly NormalizedAgentTool[];
39
54
  }
40
55
  export interface AgentFromTfResult {
@@ -47,4 +62,4 @@ export interface AgentFromTfResult {
47
62
  * Tool blocks belonging to OTHER agents are skipped with a diagnostic (the
48
63
  * caller partitions per-agent by agent_id, but stays defensive).
49
64
  */
50
- export declare function agentFromTf(agentBlock: TfBlock, toolBlocks: readonly TfBlock[], appLabel: string, ctx: FromTfContext): AgentFromTfResult;
65
+ export declare function agentFromTf(agentBlock: TfBlock, toolBlocks: readonly TfBlock[], appLabel: string, _appRefName: string, ctx: FromTfContext): AgentFromTfResult;
@@ -6,8 +6,8 @@
6
6
  * blocks and stay data-side — they never reach printed source.
7
7
  */
8
8
  import { EntityTfError } from "../../engine/entity.js";
9
- import { optionalString, resourceRefLabel } from "../../engine/pull/context.js";
10
- import { isTfExpr, tfLabelToTsLabel } from "../../engine/tf/index.js";
9
+ import { optionalBoolean, optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
10
+ import { isTfExpr, isUuid, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
11
11
  import { toolFromTf } from "../agent-tool/from-tf.js";
12
12
  import { APP_RESOURCE_TYPE } from "../app/module.js";
13
13
  import { SKILL_RESOURCE_TYPE } from "../skill/module.js";
@@ -22,9 +22,20 @@ const KNOWN_AGENT_ATTRS = new Set([
22
22
  "ai_provider_connector_id",
23
23
  "skill_access_config",
24
24
  "max_tokens",
25
+ "depends_on",
26
+ "run_as",
27
+ "jwt_authentication",
28
+ "conversation_idle_timeout",
29
+ "a2a_streaming",
25
30
  ]);
26
- /** Dialect attrs with no authoring slot yet — reported by name, agent still pulled. */
27
- const UNAUTHORABLE_AGENT_ATTRS = new Set(["starting_actions", "model"]);
31
+ /**
32
+ * Dialect attrs with no authoring slot yet — reported by name, agent still
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"]);
28
39
  /** Non-elementum agent variants (type + their config attrs) — the whole agent is skipped. */
29
40
  const VARIANT_ATTRS = new Set([
30
41
  "type",
@@ -41,9 +52,9 @@ const VARIANT_ATTRS = new Set([
41
52
  * data-attr is a foreign app's skill, resolved to its name via the
42
53
  * stream's data block.
43
54
  */
44
- function parseSkillRef(item, where, ctx) {
55
+ function parseSkillRef(item, where, ownerTfLabel, ctx) {
45
56
  if (isTfExpr(item) && item.$expr === "resource-attr" && item.type === SKILL_RESOURCE_TYPE) {
46
- return { kind: "self", key: tfLabelToTsLabel(item.label) };
57
+ return { kind: "self", key: scopedLabelToBagKey(ownerTfLabel, item.label) };
47
58
  }
48
59
  if (isTfExpr(item) && item.$expr === "data-attr" && item.type === SKILL_RESOURCE_TYPE) {
49
60
  const name = ctx.dataName(SKILL_RESOURCE_TYPE, item.label);
@@ -53,10 +64,90 @@ function parseSkillRef(item, where, ctx) {
53
64
  }
54
65
  return { kind: "foreign", name };
55
66
  }
67
+ // A bare UUID literal with no data block backing it at all - the platform
68
+ // lets skill_ids reference a skill this export can't otherwise name (e.g.
69
+ // an app outside this workspace's export scope). Round-trip the raw id
70
+ // rather than dropping it; a typo'd/genuinely-malformed non-UUID string
71
+ // still falls through to the diagnostic below.
72
+ if (typeof item === "string" && isUuid(item)) {
73
+ return { kind: "unresolved", id: item };
74
+ }
56
75
  ctx.diagnostics.push(`${where}: skill_access_config entry has an unrecognized shape (${JSON.stringify(item)}); dropped`);
57
76
  return undefined;
58
77
  }
59
- function parseSkillAccessConfig(value, where, ctx) {
78
+ /**
79
+ * `run_as` is a bare string on the wire (`elementum_agent`'s schema: only
80
+ * `"current_user"` is documented; unset means "run as admin/publisher").
81
+ * `defineAgent`'s `runAs` option takes the opaque object shape shared with
82
+ * agent-tool's `runAs` (`{ currentUser: true }` / `{ publisher: true }` /
83
+ * `{ serviceAccount: { serviceAccount } }`) — board item B28(d) — so the
84
+ * string is translated into that shape for authoring; unrecognized values
85
+ * (not `"current_user"`) are reported and dropped rather than guessed at.
86
+ */
87
+ function parseRunAs(value, where, ctx) {
88
+ if (value === "current_user")
89
+ return { currentUser: true };
90
+ ctx.diagnostics.push(`${where}: run_as ${JSON.stringify(value)} is not a recognized value; dropped`);
91
+ return undefined;
92
+ }
93
+ /** `jwt_authentication`'s nested `key_source` — exactly one of `jwks_url`/`plain_text_key` is set. */
94
+ function parseJwtKeySource(rec, where, ctx) {
95
+ const jwksUrl = rec["jwks_url"];
96
+ if (typeof jwksUrl === "string" && jwksUrl !== "")
97
+ return { jwks: { jwksUrl } };
98
+ const plainTextKey = rec["plain_text_key"];
99
+ if (typeof plainTextKey === "string" && plainTextKey !== "")
100
+ return { plainText: { plainTextKeyValuePem: plainTextKey } };
101
+ ctx.diagnostics.push(`${where}: jwt_authentication has neither jwks_url nor plain_text_key; dropped`);
102
+ return undefined;
103
+ }
104
+ function parseJwtAuthentication(value, where, ctx) {
105
+ const rec = plainObject(value);
106
+ if (rec === undefined) {
107
+ ctx.diagnostics.push(`${where}: jwt_authentication has an unrecognized shape; dropped`);
108
+ return undefined;
109
+ }
110
+ const enabled = rec["enabled"];
111
+ const headerName = rec["header_name"];
112
+ const emailAddressClaimName = rec["email_address_claim_name"];
113
+ if (typeof enabled !== "boolean" || typeof headerName !== "string" || typeof emailAddressClaimName !== "string") {
114
+ ctx.diagnostics.push(`${where}: jwt_authentication is missing required fields (enabled/header_name/email_address_claim_name); dropped`);
115
+ return undefined;
116
+ }
117
+ const keySource = parseJwtKeySource(rec, where, ctx);
118
+ if (keySource === undefined)
119
+ return undefined;
120
+ let requiredClaims;
121
+ const rawClaims = rec["required_claims"];
122
+ if (Array.isArray(rawClaims)) {
123
+ requiredClaims = [];
124
+ for (const item of rawClaims) {
125
+ const claimRec = plainObject(item);
126
+ const claimName = claimRec?.["claim_name"];
127
+ const acceptableValues = claimRec?.["acceptable_values"];
128
+ if (typeof claimName !== "string" || !Array.isArray(acceptableValues) || !acceptableValues.every((v) => typeof v === "string")) {
129
+ ctx.diagnostics.push(`${where}: jwt_authentication.required_claims entry has an unrecognized shape; dropped`);
130
+ continue;
131
+ }
132
+ requiredClaims.push({ claimName, acceptableValues: acceptableValues });
133
+ }
134
+ if (requiredClaims.length === 0)
135
+ requiredClaims = undefined;
136
+ }
137
+ else if (rawClaims !== undefined) {
138
+ ctx.diagnostics.push(`${where}: jwt_authentication.required_claims is not a list; dropped`);
139
+ }
140
+ return {
141
+ jwt: {
142
+ enabled,
143
+ headerName,
144
+ emailAddressClaimName,
145
+ keySource,
146
+ ...(requiredClaims !== undefined && { requiredClaims }),
147
+ },
148
+ };
149
+ }
150
+ function parseSkillAccessConfig(value, where, ownerTfLabel, ctx) {
60
151
  if (typeof value !== "object" || value === null || Array.isArray(value) || isTfExpr(value)) {
61
152
  ctx.diagnostics.push(`${where}: skill_access_config has an unrecognized shape; dropped`);
62
153
  return undefined;
@@ -73,7 +164,7 @@ function parseSkillAccessConfig(value, where, ctx) {
73
164
  return undefined;
74
165
  const refs = [];
75
166
  for (const item of raw) {
76
- const ref = parseSkillRef(item, `${where}: ${attr}`, ctx);
167
+ const ref = parseSkillRef(item, `${where}: ${attr}`, ownerTfLabel, ctx);
77
168
  if (ref !== undefined)
78
169
  refs.push(ref);
79
170
  }
@@ -95,7 +186,7 @@ function parseSkillAccessConfig(value, where, ctx) {
95
186
  * Tool blocks belonging to OTHER agents are skipped with a diagnostic (the
96
187
  * caller partitions per-agent by agent_id, but stays defensive).
97
188
  */
98
- export function agentFromTf(agentBlock, toolBlocks, appLabel, ctx) {
189
+ export function agentFromTf(agentBlock, toolBlocks, appLabel, _appRefName, ctx) {
99
190
  const label = agentBlock.label;
100
191
  if (label === undefined || label === "") {
101
192
  throw new EntityTfError("elementum_agent block is missing its label");
@@ -125,15 +216,28 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, ctx) {
125
216
  const connectorAttr = attrs["ai_provider_connector_id"];
126
217
  if (connectorAttr !== undefined) {
127
218
  if (isTfExpr(connectorAttr) && connectorAttr.$expr === "data-attr" && connectorAttr.type === "elementum_ai_provider_connector") {
128
- // The org.ts key is the data label's bijective image — same derivation
129
- // the org extractor used, so the printed token matches the catalog.
130
- connectorKey = tfLabelToTsLabel(connectorAttr.label);
219
+ // The connector's own block only carries model_name + a reference to
220
+ // its provider — the provider's own data block carries the name.
221
+ // Deriving providerKey/modelKey this way (not by splitting the
222
+ // connector's combined tfLabel) is the same derivation
223
+ // renderAiProvidersBag uses, so the printed token matches the catalog.
224
+ const modelName = ctx.dataName(connectorAttr.type, connectorAttr.label);
225
+ const providerRef = ctx.dataRef(connectorAttr.type, connectorAttr.label);
226
+ const providerName = providerRef !== undefined ? ctx.dataName(providerRef.resourceType, providerRef.tfLabel) : undefined;
227
+ if (modelName === undefined || providerName === undefined) {
228
+ ctx.diagnostics.push(`${where}: references data.${connectorAttr.type}.${connectorAttr.label} but the stream has no model_name/provider for it; dropped`);
229
+ }
230
+ else {
231
+ const providerKey = tfLabelToTsLabel(sanitizeName(providerName));
232
+ const modelKey = tfLabelToTsLabel(sanitizeName(modelName));
233
+ connectorKey = `${providerKey}.${modelKey}`;
234
+ }
131
235
  }
132
236
  else {
133
237
  ctx.diagnostics.push(`${where}: ai_provider_connector_id is not a connector data reference; dropped`);
134
238
  }
135
239
  }
136
- const owner = { appType: APP_RESOURCE_TYPE, appLabel, agentType: AGENT_RESOURCE_TYPE, agentLabel: label };
240
+ const owner = { appType: APP_RESOURCE_TYPE, appLabel, ownerTfLabel: appLabel, agentType: AGENT_RESOURCE_TYPE, agentLabel: label };
137
241
  const tools = [];
138
242
  for (const block of toolBlocks) {
139
243
  const tool = toolFromTf(block, owner, ctx);
@@ -143,8 +247,20 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, ctx) {
143
247
  let skillAccess;
144
248
  const skillAccessAttr = attrs["skill_access_config"];
145
249
  if (skillAccessAttr !== undefined) {
146
- skillAccess = parseSkillAccessConfig(skillAccessAttr, where, ctx);
250
+ skillAccess = parseSkillAccessConfig(skillAccessAttr, where, appLabel, ctx);
251
+ }
252
+ let runAs;
253
+ const runAsAttr = attrs["run_as"];
254
+ if (runAsAttr !== undefined) {
255
+ runAs = parseRunAs(runAsAttr, where, ctx);
256
+ }
257
+ let agentAuthentication;
258
+ const jwtAttr = attrs["jwt_authentication"];
259
+ if (jwtAttr !== undefined) {
260
+ agentAuthentication = parseJwtAuthentication(jwtAttr, where, ctx);
147
261
  }
262
+ const conversationIdleTimeout = optionalString(attrs, "conversation_idle_timeout", where, ctx);
263
+ const a2aStreaming = optionalBoolean(attrs, "a2a_streaming", where, ctx);
148
264
  const firstMessage = optionalString(attrs, "first_message", where, ctx);
149
265
  const maxTokens = attrs["max_tokens"];
150
266
  const maxLength = typeof maxTokens === "number" && Number.isSafeInteger(maxTokens) && maxTokens > 0
@@ -155,7 +271,7 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, ctx) {
155
271
  }
156
272
  return {
157
273
  agent: {
158
- refName: tfLabelToTsLabel(label),
274
+ refName: scopedLabelToBagKey(appLabel, label),
159
275
  name,
160
276
  description: optionalString(attrs, "description", where, ctx) ?? "",
161
277
  instructions: optionalString(attrs, "instructions", where, ctx) ?? "",
@@ -163,6 +279,10 @@ export function agentFromTf(agentBlock, toolBlocks, appLabel, ctx) {
163
279
  ...(maxLength !== undefined && { maxLength }),
164
280
  ...(connectorKey !== undefined && { connectorKey }),
165
281
  ...(skillAccess !== undefined && { skillAccess }),
282
+ ...(runAs !== undefined && { runAs }),
283
+ ...(agentAuthentication !== undefined && { agentAuthentication }),
284
+ ...(conversationIdleTimeout !== undefined && { conversationIdleTimeout }),
285
+ ...(a2aStreaming !== undefined && { a2aStreaming }),
166
286
  tools,
167
287
  },
168
288
  };