@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
@@ -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";
@@ -51,7 +51,7 @@ function extractAgents(ownBlocks, stream, ctx) {
51
51
  const ref = b.attrs["agent_id"];
52
52
  return isTfExpr(ref) && ref.$expr === "resource-attr" && ref.type === AGENT_RESOURCE_TYPE && ref.label === agentLabel;
53
53
  });
54
- const { agent, skippedReason } = agentFromTf(agentBlock, ownTools, ctx.appTfLabel, ctx);
54
+ const { agent, skippedReason } = agentFromTf(agentBlock, ownTools, ctx.appTfLabel, ctx.appRefName, ctx);
55
55
  if (agent !== undefined)
56
56
  items.push(agent);
57
57
  else if (skippedReason !== undefined) {
@@ -92,7 +92,13 @@ export const agentModule = {
92
92
  refName: agent.refName,
93
93
  source: printAgentV2(agent, {
94
94
  appRefName: opts.appRefName,
95
- orgImportPath: opts.orgImportPath,
95
+ ...(opts.crossOrg !== undefined && { crossOrg: opts.crossOrg }),
96
+ ...(opts.destinationConnectorKeys !== undefined && {
97
+ destinationConnectorKeys: opts.destinationConnectorKeys,
98
+ }),
99
+ ...(opts.connectorKeyOverride !== undefined && { connectorKeyOverride: opts.connectorKeyOverride }),
100
+ ...(opts.foreignAppRefNames !== undefined && { foreignAppRefNames: opts.foreignAppRefNames }),
101
+ ...(opts.foreignElementRefNames !== undefined && { foreignElementRefNames: opts.foreignElementRefNames }),
96
102
  }),
97
103
  };
98
104
  },
@@ -14,25 +14,61 @@
14
14
  * silent (plan §4.3).
15
15
  */
16
16
  import { EntityTfError } from "../../engine/entity.js";
17
- import { expr, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
17
+ import { appScopedResourceLabel, expr, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
18
18
  import { toolToTf } from "../agent-tool/to-tf.js";
19
19
  import { APP_RESOURCE_TYPE } from "../app/module.js";
20
20
  import { CONNECTOR_ORG_BAG } from "../org/connector.js";
21
21
  import { SKILL_RESOURCE_TYPE } from "../skill/module.js";
22
22
  import { AGENT_RESOURCE_TYPE } from "./module.js";
23
- /** Config knobs `defineAgent` accepts that the terraform dialect does not carry (yet). */
23
+ /**
24
+ * Config knobs `defineAgent` accepts that the terraform dialect does not
25
+ * carry (yet). `runAs`/`agentAuthentication`/`a2aStreaming`/
26
+ * `conversationIdleTimeout` moved out of this list in issue #170 — they're
27
+ * now emitted (see the attrs assembly below); the encoders below still drop
28
+ * a value that doesn't fit the terraform-path shape, diagnosed individually
29
+ * rather than through this blanket list.
30
+ */
24
31
  const UNSUPPORTED_AGENT_KNOBS = [
25
32
  "temperature",
26
33
  "reasoningEffort",
27
- "runAs",
28
34
  "startingActions",
29
- "agentAuthentication",
30
- "a2aStreaming",
31
- "conversationIdleTimeout",
32
35
  "avatarAttachmentId",
33
36
  "managedById",
34
37
  "serviceAccountId",
35
38
  ];
39
+ /**
40
+ * `runAs` authoring is the opaque object shape shared with agent-tool's
41
+ * `runAs` (board item B28(d)); `elementum_agent.run_as` on the wire is a
42
+ * bare string and only `"current_user"` is documented for agents (unlike
43
+ * tools, which also accept `"publisher"`/`"service_account"`) — mirrors
44
+ * `parseRunAs` in `from-tf.ts`.
45
+ */
46
+ function runAsValue(runAs, where, diagnostics) {
47
+ if (runAs["currentUser"] === true)
48
+ return "current_user";
49
+ diagnostics.push(`${where}: runAs ${JSON.stringify(runAs)} has no terraform-path encoding yet (only { currentUser: true } is supported); dropped`);
50
+ return undefined;
51
+ }
52
+ /** `agentAuthentication` → `jwt_authentication` — mirrors `parseJwtAuthentication` in `from-tf.ts`. */
53
+ function jwtAuthenticationValue(auth) {
54
+ const { jwt } = auth;
55
+ const keySourceAttrs = "jwks" in jwt.keySource
56
+ ? { jwks_url: jwt.keySource.jwks.jwksUrl }
57
+ : { plain_text_key: jwt.keySource.plainText.plainTextKeyValuePem };
58
+ const value = {
59
+ enabled: jwt.enabled,
60
+ header_name: jwt.headerName,
61
+ email_address_claim_name: jwt.emailAddressClaimName,
62
+ ...keySourceAttrs,
63
+ };
64
+ if (jwt.requiredClaims !== undefined && jwt.requiredClaims.length > 0) {
65
+ value["required_claims"] = jwt.requiredClaims.map((c) => ({
66
+ claim_name: c.claimName,
67
+ acceptable_values: [...c.acceptableValues],
68
+ }));
69
+ }
70
+ return value;
71
+ }
36
72
  /**
37
73
  * authoring SkillRef token → the skill's id value. Self-app skills resolve
38
74
  * purely from the token (same discipline as agent-tool's field refs); a
@@ -52,9 +88,11 @@ function skillIdValue(token, ctx) {
52
88
  `renamed a skill file, the app's generated/catalog.ts may be stale; regenerate it (re-run \`edk pull ` +
53
89
  `app\`, or the catalog-refresh step your workflow uses) before building again.`);
54
90
  }
91
+ if (token.unresolvedId !== undefined)
92
+ return token.unresolvedId;
55
93
  const refName = token.refName;
56
94
  if (token.parent === ctx.appRefName) {
57
- return expr.resourceAttr(SKILL_RESOURCE_TYPE, tsLabelToTfLabel(refName), ["id"]);
95
+ return expr.resourceAttr(SKILL_RESOURCE_TYPE, appScopedResourceLabel(ctx.appTfLabel, tsLabelToTfLabel(refName)), ["id"]);
58
96
  }
59
97
  const name = token.name ?? refName;
60
98
  const tfLabel = sanitizeName(name);
@@ -73,7 +111,8 @@ export function agentToTf(entity, ctx) {
73
111
  }
74
112
  // The bag key IS the label (the stable naming contract) — the agent's
75
113
  // refName comes from its file name, exactly like an app's.
76
- const tfLabel = tsLabelToTfLabel(entity.refName);
114
+ const agentBareTfLabel = tsLabelToTfLabel(entity.refName);
115
+ const tfLabel = appScopedResourceLabel(ctx.appTfLabel, agentBareTfLabel);
77
116
  const name = elementum.name ?? "";
78
117
  const where = `agent "${name}"`;
79
118
  const attrs = {
@@ -86,12 +125,24 @@ export function agentToTf(entity, ctx) {
86
125
  attrs["first_message"] = elementum.firstMessage;
87
126
  if (elementum.maxLength !== undefined)
88
127
  attrs["max_tokens"] = elementum.maxLength;
128
+ if (elementum.runAs !== undefined) {
129
+ const value = runAsValue(elementum.runAs, where, ctx.diagnostics);
130
+ if (value !== undefined)
131
+ attrs["run_as"] = value;
132
+ }
133
+ if (elementum.agentAuthentication !== undefined) {
134
+ attrs["jwt_authentication"] = jwtAuthenticationValue(elementum.agentAuthentication);
135
+ }
136
+ if (elementum.conversationIdleTimeout !== undefined)
137
+ attrs["conversation_idle_timeout"] = elementum.conversationIdleTimeout;
138
+ if (elementum.a2aStreaming !== undefined)
139
+ attrs["a2a_streaming"] = elementum.a2aStreaming;
89
140
  const connector = elementum.aiProviderConnectorId;
90
141
  if (connector === undefined) {
91
142
  ctx.diagnostics.push(`${where}: no connector token — the platform will pick a default model`);
92
143
  }
93
144
  else {
94
- const tsLabel = connector.refName ?? "";
145
+ const tsLabel = connector.parent !== undefined ? `${connector.parent}.${connector.refName ?? ""}` : (connector.refName ?? "");
95
146
  const resolved = ctx.orgRefs.byTsLabel(CONNECTOR_ORG_BAG, tsLabel);
96
147
  if (resolved === undefined) {
97
148
  ctx.diagnostics.push(`${where}: connector token "${tsLabel}" is not in the org catalog — re-run \`elementum pull org --data-only\``);
@@ -125,8 +176,9 @@ export function agentToTf(entity, ctx) {
125
176
  const tool = toolToTf(entry, {
126
177
  appRefName: ctx.appRefName,
127
178
  appTfLabel: ctx.appTfLabel,
128
- agentTfLabel: tfLabel,
179
+ agentBareTfLabel,
129
180
  foreignAppRef: (l, n) => ctx.orgRefs.foreignApp(l, n),
181
+ foreignElementRef: (l, n) => ctx.orgRefs.foreignElement(l, n),
130
182
  diagnostics: ctx.diagnostics,
131
183
  });
132
184
  if (tool !== undefined)
@@ -10,7 +10,7 @@
10
10
  * object. Optional `startMessage` / `runAs` are emitted only when supplied,
11
11
  * matching the v1 serializer's field-by-field discipline.
12
12
  */
13
- import type { AutomationCatalogRef, AgentRef, AspectRef, AutomationRef, FieldRef, OutputPropertyRef, SearchTableRef, TriggerParameterRef } from "../../catalog/index.js";
13
+ import type { AutomationCatalogRef, AgentRef, AspectRef, AutomationRef, FieldRef, OutputPropertyRef, TriggerParameterRef } from "../../catalog/index.js";
14
14
  /** A handle-form agent tool: a Hydra `AgentToolCreateInput` with ref tokens. */
15
15
  export type AgentTool = Record<string, unknown>;
16
16
  /** Opaque run-as config (Hydra's `AgentConversationRunAsInput`). */
@@ -19,16 +19,73 @@ export type AgentToolRunAs = Record<string, unknown>;
19
19
  export interface AgentSearchField {
20
20
  readonly field: FieldRef;
21
21
  readonly name?: string;
22
+ /** Required by the provider on every tool field. */
23
+ readonly description: string;
24
+ }
25
+ /**
26
+ * A search-tool field identified by a raw platform id rather than a
27
+ * FieldRef token — the field belongs to a foreign/out-of-scope aspect ei
28
+ * can't resolve to a resource reference (board issue #169; confirmed live,
29
+ * same fallback convention as `AgentSearchTableField`). The platform id, not
30
+ * a live reference — it never updates if the field is later renamed
31
+ * upstream, and there's no way to author one directly; it only arises from
32
+ * `edk pull app` round-tripping an existing tool.
33
+ */
34
+ export interface AgentSearchRawIdField {
35
+ readonly fieldId: string;
36
+ readonly name?: string;
37
+ readonly description: string;
38
+ }
39
+ export type AgentSearchFieldInput = AgentSearchField | AgentSearchRawIdField;
40
+ /**
41
+ * A field exposed to a searchTable tool's newer `fields` wire shape
42
+ * (field_id/name/description). Unlike every other tool's `fields`,
43
+ * field_id here is a raw platform id, not a catalog token — confirmed
44
+ * live, searchTable's fields describe columns of the search table's own
45
+ * schema, not app/element fields, so there's no `elementum_*_field`
46
+ * resource to reference (same raw-id convention as
47
+ * `TableRecordsSearchOptions.table`).
48
+ */
49
+ export interface AgentSearchTableField {
50
+ readonly fieldId: string;
51
+ readonly name?: string;
22
52
  readonly description?: string;
23
53
  }
54
+ /**
55
+ * A field exposed to a searchTable tool's legacy `return_fields` wire shape
56
+ * (field_id/name/display_name, no description) — the dialect most existing
57
+ * elementum_agent_ai_search_tool resources still use; the provider is
58
+ * deprecating it in favor of the same shape as {@link AgentSearchTableField},
59
+ * but both are live on the platform today (see `agentSearchTable`'s doc
60
+ * comment). Same raw field_id convention as `AgentSearchTableField`.
61
+ */
62
+ export interface AgentSearchReturnField {
63
+ readonly fieldId: string;
64
+ readonly name?: string;
65
+ readonly displayName?: string;
66
+ }
24
67
  /** A field the agent can populate/modify via a create/update record tool. */
25
68
  export interface AgentRecordField {
26
69
  readonly field: FieldRef;
27
70
  readonly name?: string;
28
- readonly description?: string;
71
+ /** Required by the provider on every tool field. */
72
+ readonly description: string;
29
73
  readonly required?: boolean;
30
74
  readonly defaultValue?: string;
31
75
  }
76
+ /**
77
+ * A create/update-record field identified by a raw platform id rather than
78
+ * a FieldRef token — same raw-id fallback as {@link AgentSearchRawIdField}
79
+ * (board issue #169), for createRecord/updateRecord tools instead of search.
80
+ */
81
+ export interface AgentRecordRawIdField {
82
+ readonly fieldId: string;
83
+ readonly name?: string;
84
+ /** Required by the provider on every tool field. */
85
+ readonly description: string;
86
+ readonly required?: boolean;
87
+ }
88
+ export type AgentRecordFieldInput = AgentRecordField | AgentRecordRawIdField;
32
89
  /** Input-parameter mapping for an execute-workflow tool. */
33
90
  export interface AgentExecuteWorkflowInput {
34
91
  readonly name: string;
@@ -57,7 +114,7 @@ interface CommonToolOptions {
57
114
  export interface SearchAspectToolV2 extends CommonToolOptions {
58
115
  readonly aspect: AspectRef;
59
116
  readonly queryDescription: string;
60
- readonly fields?: readonly AgentSearchField[];
117
+ readonly fields?: readonly AgentSearchFieldInput[];
61
118
  /** Pre-built wire `Filter` (may embed `FieldRef` tokens — resolved at deploy). */
62
119
  readonly filter?: Record<string, unknown>;
63
120
  /** Pre-built wire `Sort` (`{ orders: [{ field, direction }] }`). */
@@ -65,24 +122,46 @@ export interface SearchAspectToolV2 extends CommonToolOptions {
65
122
  readonly limit?: number;
66
123
  }
67
124
  export declare function agentSearchAspect(opts: SearchAspectToolV2): AgentTool;
125
+ /**
126
+ * Unlike the other search tools, a search table has no import/reference
127
+ * mechanism yet (mirrors `TableRecordsSearchOptions.table`'s same raw-id
128
+ * convention): `table` is the platform's raw search table id, not a catalog
129
+ * token — confirmed live, ei's own export never resolves `search_table_id`
130
+ * to a reference for any of these tools. `aspect` is also optional here
131
+ * (unlike searchAspect) — a search table tool doesn't always need a live
132
+ * record target. `fields`/`returnFields` are mutually exclusive: most
133
+ * existing tools use the legacy `return_fields` wire shape (`returnFields`,
134
+ * field_id/name/displayName), which the provider is deprecating in favor of
135
+ * the same shape searchAspect already uses (`fields`, field_id/name/
136
+ * description) — both are live on the platform today, so both round-trip.
137
+ */
68
138
  export interface SearchTableToolV2 extends CommonToolOptions {
69
- readonly aspect: AspectRef;
70
- readonly table: SearchTableRef;
139
+ readonly aspect?: AspectRef;
140
+ readonly table: string;
71
141
  readonly queryDescription: string;
72
- readonly fields?: readonly AgentSearchField[];
142
+ /** searchTable's newer field shape — mutually exclusive with `returnFields`. */
143
+ readonly fields?: readonly AgentSearchTableField[];
144
+ /** searchTable's legacy field shape — mutually exclusive with `fields`. */
145
+ readonly returnFields?: readonly AgentSearchReturnField[];
73
146
  readonly filter?: Record<string, unknown>;
74
147
  readonly limit?: number;
75
148
  }
76
149
  export declare function agentSearchTable(opts: SearchTableToolV2): AgentTool;
77
150
  export interface CreateRecordToolV2 extends CommonToolOptions {
78
151
  readonly aspect: AspectRef;
79
- readonly fields?: readonly AgentRecordField[];
152
+ readonly fields?: readonly AgentRecordFieldInput[];
80
153
  }
81
154
  export declare function agentCreateRecord(opts: CreateRecordToolV2): AgentTool;
82
155
  export interface UpdateRecordToolV2 extends CommonToolOptions {
83
156
  readonly aspect: AspectRef;
84
- readonly fields?: readonly AgentRecordField[];
85
- readonly handleDescription?: string;
157
+ readonly fields?: readonly AgentRecordFieldInput[];
158
+ /**
159
+ * How the agent should identify which record to update — the provider
160
+ * requires this (there's no way to infer it) and rejects an empty value
161
+ * at apply with an opaque "Unable to validate" error, so it's required
162
+ * here instead. Example: "Identify the ticket by its ID or subject line."
163
+ */
164
+ readonly handleDescription: string;
86
165
  }
87
166
  export declare function agentUpdateRecord(opts: UpdateRecordToolV2): AgentTool;
88
167
  export interface RelateRecordToolV2 extends CommonToolOptions {
@@ -20,19 +20,56 @@ function common(opts) {
20
20
  };
21
21
  }
22
22
  function searchFieldToken(f) {
23
+ if ("fieldId" in f) {
24
+ // Raw platform id fallback — see AgentSearchRawIdField's comment.
25
+ return {
26
+ fieldId: f.fieldId,
27
+ ...(f.name !== undefined ? { name: f.name } : {}),
28
+ description: f.description,
29
+ };
30
+ }
31
+ // Provider requires `name` on every tool field — default to the field's
32
+ // display name when the author omits an override. `description` is required
33
+ // on the authoring type and always emitted.
23
34
  return {
24
35
  fieldId: f.field, // token → resolved to the field id at deploy
25
36
  clientHandle: f.field, // token → resolved to the field clientHandle at deploy
37
+ name: f.name ?? f.field.name,
38
+ description: f.description,
39
+ };
40
+ }
41
+ function searchTableFieldToken(f) {
42
+ return {
43
+ fieldId: f.fieldId, // raw platform id - not a catalog token, see AgentSearchTableField's comment
26
44
  ...(f.name !== undefined ? { name: f.name } : {}),
27
45
  ...(f.description !== undefined ? { description: f.description } : {}),
28
46
  };
29
47
  }
48
+ function returnFieldToken(f) {
49
+ return {
50
+ fieldId: f.fieldId, // raw platform id - not a catalog token, see AgentSearchReturnField's comment
51
+ ...(f.name !== undefined ? { name: f.name } : {}),
52
+ ...(f.displayName !== undefined ? { displayName: f.displayName } : {}),
53
+ };
54
+ }
30
55
  function recordFieldToken(f) {
56
+ if ("fieldId" in f) {
57
+ // Raw platform id fallback — see AgentRecordRawIdField's comment.
58
+ return {
59
+ fieldId: f.fieldId,
60
+ ...(f.name !== undefined ? { name: f.name } : {}),
61
+ description: f.description,
62
+ ...(f.required !== undefined ? { required: f.required } : {}),
63
+ };
64
+ }
65
+ // Provider requires `name` on every tool field — default to the field's
66
+ // display name when the author omits an override. `description` is required
67
+ // on the authoring type and always emitted.
31
68
  return {
32
69
  fieldId: f.field,
33
70
  clientHandle: f.field,
34
- ...(f.name !== undefined ? { name: f.name } : {}),
35
- ...(f.description !== undefined ? { description: f.description } : {}),
71
+ name: f.name ?? f.field.name,
72
+ description: f.description,
36
73
  ...(f.required !== undefined ? { required: f.required } : {}),
37
74
  ...(f.defaultValue !== undefined ? { defaultValue: f.defaultValue } : {}),
38
75
  };
@@ -54,10 +91,14 @@ export function agentSearchTable(opts) {
54
91
  return {
55
92
  searchTable: {
56
93
  ...common(opts),
57
- aspectId: opts.aspect,
94
+ ...(opts.aspect !== undefined ? { aspectId: opts.aspect } : {}),
58
95
  searchTableId: opts.table,
59
96
  queryDescription: opts.queryDescription,
60
- ...(opts.fields !== undefined ? { fields: opts.fields.map(searchFieldToken) } : {}),
97
+ // Distinct wire key from every other tool's `fields` (which carries
98
+ // FieldRef tokens) - searchTable's own field/returnField shapes carry
99
+ // raw platform ids instead, see AgentSearchTableField's comment.
100
+ ...(opts.fields !== undefined ? { searchTableFields: opts.fields.map(searchTableFieldToken) } : {}),
101
+ ...(opts.returnFields !== undefined ? { returnFields: opts.returnFields.map(returnFieldToken) } : {}),
61
102
  ...(opts.filter !== undefined ? { filter: opts.filter } : {}),
62
103
  ...(opts.limit !== undefined ? { limit: opts.limit } : {}),
63
104
  },
@@ -78,9 +119,7 @@ export function agentUpdateRecord(opts) {
78
119
  ...common(opts),
79
120
  aspectId: opts.aspect,
80
121
  ...(opts.fields !== undefined ? { fields: opts.fields.map(recordFieldToken) } : {}),
81
- ...(opts.handleDescription !== undefined
82
- ? { handleDescription: opts.handleDescription }
83
- : {}),
122
+ handleDescription: opts.handleDescription,
84
123
  },
85
124
  };
86
125
  }
@@ -7,18 +7,49 @@
7
7
  import { type FromTfContext } from "../../engine/pull/context.js";
8
8
  import { type TfBlock } from "../../engine/tf/index.js";
9
9
  export interface NormalizedToolField {
10
- /** The field's bag key in the owning app's `fields: {}` (bijective image of its label). */
11
- readonly key: string;
10
+ /** The field's bag key in the TARGET aspect's `fields: {}` (bijective image of its label). Mutually exclusive with `rawFieldId`. */
11
+ readonly key?: string;
12
+ /**
13
+ * Raw platform field id — board issue #169. When the tool's target is a
14
+ * foreign/out-of-scope aspect (not recursively exported), ei has no field
15
+ * resource to reference and falls back to a bare id, same convention as
16
+ * `NormalizedAgentTool.searchTableId`. Mutually exclusive with `key`;
17
+ * exactly one is always set.
18
+ */
19
+ readonly rawFieldId?: string;
12
20
  readonly name?: string;
13
21
  readonly description?: string;
14
22
  readonly required?: boolean;
15
23
  }
24
+ /**
25
+ * searchTable's own field shapes. Unlike createRecord/searchAspect/
26
+ * updateRecord, field_id here is NEVER a resource reference — confirmed
27
+ * live, 161/161 field_id values across every real elementum_agent_ai_search_tool
28
+ * capture are raw strings. These describe columns of the search table's own
29
+ * schema, not app/element fields, so there's no `elementum_*_field` resource
30
+ * (and therefore no catalog bag key) to resolve them to.
31
+ */
32
+ export interface NormalizedSearchTableField {
33
+ readonly fieldId: string;
34
+ readonly name?: string;
35
+ readonly description?: string;
36
+ }
37
+ /** searchTable's legacy return_fields shape (field_id/name/display_name) — no description, no required. */
38
+ export interface NormalizedSearchTableReturnField {
39
+ readonly fieldId: string;
40
+ readonly name?: string;
41
+ readonly displayName?: string;
42
+ }
16
43
  export type NormalizedToolTarget = {
17
44
  readonly kind: "self";
18
45
  } | {
19
46
  /** A foreign app via `data.elementum_app.<label>` — `name` from the stream's data block. */
20
47
  readonly kind: "foreignApp";
21
48
  readonly name: string;
49
+ } | {
50
+ /** A foreign ELEMENT via `data.elementum_element.<label>` — `name` from the stream's data block (board issue #42). */
51
+ readonly kind: "foreignElement";
52
+ readonly name: string;
22
53
  };
23
54
  export interface NormalizedExecuteWorkflowInput {
24
55
  /** The published workflow's declared trigger parameter name. */
@@ -34,24 +65,40 @@ export interface NormalizedExecuteWorkflowOutput {
34
65
  readonly description?: string;
35
66
  }
36
67
  export interface NormalizedAgentTool {
37
- readonly typeKey: "createRecord" | "searchAspect" | "executeWorkflow";
68
+ readonly typeKey: "createRecord" | "searchAspect" | "updateRecord" | "executeWorkflow" | "searchTable";
38
69
  readonly name: string;
39
70
  readonly description: string;
40
71
  readonly startMessage?: string;
41
- /** absent for executeWorkflow — its target is an automation, not an aspect. */
72
+ /** absent for executeWorkflow — its target is an automation, not an aspect. searchTable's target is also optional. */
42
73
  readonly target?: NormalizedToolTarget;
74
+ /** createRecord/searchAspect/updateRecord only — searchTable's own field shapes never resolve to a catalog key, see below. */
43
75
  readonly fields?: readonly NormalizedToolField[];
76
+ /** searchTable's newer field shape (field_id/name/description) — mutually exclusive with `returnFields`. */
77
+ readonly searchTableFields?: readonly NormalizedSearchTableField[];
78
+ /** searchTable's legacy field shape (field_id/name/display_name) — mutually exclusive with `searchTableFields`. */
79
+ readonly returnFields?: readonly NormalizedSearchTableReturnField[];
44
80
  readonly queryDescription?: string;
45
81
  readonly limit?: number;
82
+ /** updateRecord: how the agent should identify the record to update. */
83
+ readonly handleDescription?: string;
46
84
  /** executeWorkflow: the target automation's bag key (bijective image of its tf label). */
47
85
  readonly automationKey?: string;
48
86
  readonly inputs?: readonly NormalizedExecuteWorkflowInput[];
49
87
  readonly outputs?: readonly NormalizedExecuteWorkflowOutput[];
88
+ /**
89
+ * searchTable's search_table_id. Always a raw platform id on the wire —
90
+ * confirmed live, ei's own export never resolves it to a reference (it
91
+ * writes a bare id with a "# TODO: Replace with data source or variable"
92
+ * comment), so there is no data-source lookup to reconstruct here.
93
+ */
94
+ readonly searchTableId?: string;
50
95
  }
51
96
  export interface ToolOwner {
52
97
  /** The owning app's resource type + tfLabel. */
53
98
  readonly appType: string;
54
99
  readonly appLabel: string;
100
+ /** Namespace tf label for stripping `apps_<ns>_` child labels. */
101
+ readonly ownerTfLabel: string;
55
102
  /** The owning agent's resource type + tfLabel. */
56
103
  readonly agentType: string;
57
104
  readonly agentLabel: string;