@elementumai/edk 0.9.19 → 0.9.20

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 (176) hide show
  1. package/README.md +146 -6
  2. package/dist-sdk/src/catalog/factories.d.ts +24 -1
  3. package/dist-sdk/src/catalog/factories.js +30 -0
  4. package/dist-sdk/src/catalog/from-authoring.d.ts +13 -8
  5. package/dist-sdk/src/catalog/from-authoring.js +34 -9
  6. package/dist-sdk/src/catalog/index.d.ts +2 -2
  7. package/dist-sdk/src/catalog/index.js +2 -2
  8. package/dist-sdk/src/catalog/render.js +6 -6
  9. package/dist-sdk/src/catalog/token.js +7 -0
  10. package/dist-sdk/src/catalog/types.d.ts +34 -1
  11. package/dist-sdk/src/catalog/types.js +11 -0
  12. package/dist-sdk/src/core/triggers/on-demand.d.ts +39 -3
  13. package/dist-sdk/src/core/triggers/on-demand.js +10 -2
  14. package/dist-sdk/src/engine/build/context.d.ts +1 -1
  15. package/dist-sdk/src/engine/ei/run.d.ts +149 -0
  16. package/dist-sdk/src/engine/ei/run.js +1132 -0
  17. package/dist-sdk/src/engine/logging.d.ts +17 -0
  18. package/dist-sdk/src/engine/logging.js +18 -0
  19. package/dist-sdk/src/engine/pull/ref-only.d.ts +5 -0
  20. package/dist-sdk/src/engine/pull/ref-only.js +10 -7
  21. package/dist-sdk/src/engine/pull/result-output.d.ts +6 -0
  22. package/dist-sdk/src/engine/pull/result-output.js +87 -3
  23. package/dist-sdk/src/engine/tf/expr.js +1 -1
  24. package/dist-sdk/src/engine/tf/index.d.ts +2 -2
  25. package/dist-sdk/src/engine/tf/index.js +1 -1
  26. package/dist-sdk/src/engine/tf/labels.d.ts +6 -0
  27. package/dist-sdk/src/engine/tf/labels.js +9 -0
  28. package/dist-sdk/src/engine/tf/model.d.ts +22 -1
  29. package/dist-sdk/src/engine/tf/parse.js +92 -4
  30. package/dist-sdk/src/engine/tf/render.d.ts +4 -2
  31. package/dist-sdk/src/engine/tf/render.js +41 -7
  32. package/dist-sdk/src/engine/validation.d.ts +39 -0
  33. package/dist-sdk/src/engine/validation.js +85 -0
  34. package/dist-sdk/src/entities/access-policy/to-tf.js +5 -2
  35. package/dist-sdk/src/entities/agent/build.d.ts +4 -16
  36. package/dist-sdk/src/entities/agent/build.js +40 -5
  37. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +4 -2
  38. package/dist-sdk/src/entities/agent/to-tf.js +6 -3
  39. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
  40. package/dist-sdk/src/entities/agent-tool/from-tf.js +7 -1
  41. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
  42. package/dist-sdk/src/entities/agent-tool/to-tf.js +27 -5
  43. package/dist-sdk/src/entities/app/build.d.ts +89 -20
  44. package/dist-sdk/src/entities/app/build.js +51 -6
  45. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +16 -0
  46. package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
  47. package/dist-sdk/src/entities/app/from-tf.js +7 -2
  48. package/dist-sdk/src/entities/app/index.d.ts +6 -6
  49. package/dist-sdk/src/entities/app/index.js +1 -0
  50. package/dist-sdk/src/entities/app/module.js +5 -2
  51. package/dist-sdk/src/entities/app/to-tf.js +19 -11
  52. package/dist-sdk/src/entities/automation/build.d.ts +47 -5
  53. package/dist-sdk/src/entities/automation/build.js +137 -20
  54. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +24 -1
  55. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +314 -39
  56. package/dist-sdk/src/entities/automation/from-tf.d.ts +28 -6
  57. package/dist-sdk/src/entities/automation/from-tf.js +428 -48
  58. package/dist-sdk/src/entities/automation/generated/task-output-contracts.d.ts +33 -0
  59. package/dist-sdk/src/entities/automation/generated/task-output-contracts.js +183 -0
  60. package/dist-sdk/src/entities/automation/index.d.ts +2 -2
  61. package/dist-sdk/src/entities/automation/index.js +1 -1
  62. package/dist-sdk/src/entities/automation/module.js +37 -8
  63. package/dist-sdk/src/entities/automation/output-field-types.d.ts +7 -0
  64. package/dist-sdk/src/entities/automation/output-field-types.js +36 -0
  65. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +9 -0
  66. package/dist-sdk/src/entities/automation/output-key-wire-name.js +13 -0
  67. package/dist-sdk/src/entities/automation/script-code.d.ts +17 -0
  68. package/dist-sdk/src/entities/automation/script-code.js +91 -5
  69. package/dist-sdk/src/entities/automation/system-ref-name.js +4 -0
  70. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +2 -0
  71. package/dist-sdk/src/entities/automation/task-output-labels.js +9 -0
  72. package/dist-sdk/src/entities/automation/tasks.d.ts +24 -2
  73. package/dist-sdk/src/entities/automation/tasks.js +38 -9
  74. package/dist-sdk/src/entities/automation/to-tf.d.ts +4 -0
  75. package/dist-sdk/src/entities/automation/to-tf.js +489 -83
  76. package/dist-sdk/src/entities/automation/triggers.d.ts +4 -2
  77. package/dist-sdk/src/entities/automation/triggers.js +4 -0
  78. package/dist-sdk/src/entities/chart/to-tf.js +10 -3
  79. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +24 -31
  80. package/dist-sdk/src/entities/element/build.d.ts +25 -13
  81. package/dist-sdk/src/entities/element/build.js +4 -1
  82. package/dist-sdk/src/entities/element/from-tf.d.ts +11 -0
  83. package/dist-sdk/src/entities/element/from-tf.js +58 -1
  84. package/dist-sdk/src/entities/element/index.d.ts +5 -3
  85. package/dist-sdk/src/entities/element/index.js +1 -0
  86. package/dist-sdk/src/entities/element/module.js +9 -3
  87. package/dist-sdk/src/entities/element/to-tf.js +8 -2
  88. package/dist-sdk/src/entities/field/build.d.ts +14 -1
  89. package/dist-sdk/src/entities/field/build.js +3 -0
  90. package/dist-sdk/src/entities/field/from-tf.d.ts +1 -0
  91. package/dist-sdk/src/entities/field/from-tf.js +39 -1
  92. package/dist-sdk/src/entities/field/media-types.d.ts +6 -0
  93. package/dist-sdk/src/entities/field/media-types.js +30 -0
  94. package/dist-sdk/src/entities/field/module.js +1 -0
  95. package/dist-sdk/src/entities/field/to-tf.d.ts +23 -2
  96. package/dist-sdk/src/entities/field/to-tf.js +130 -14
  97. package/dist-sdk/src/entities/file-reader/from-tf.js +14 -5
  98. package/dist-sdk/src/entities/file-reader/module.js +1 -0
  99. package/dist-sdk/src/entities/file-reader/types.d.ts +2 -0
  100. package/dist-sdk/src/entities/file-reader/types.js +1 -1
  101. package/dist-sdk/src/entities/portal/build.d.ts +26 -0
  102. package/dist-sdk/src/entities/portal/build.js +37 -0
  103. package/dist-sdk/src/entities/portal/from-tf.d.ts +27 -0
  104. package/dist-sdk/src/entities/portal/from-tf.js +75 -0
  105. package/dist-sdk/src/entities/portal/index.d.ts +1 -0
  106. package/dist-sdk/src/entities/portal/index.js +1 -0
  107. package/dist-sdk/src/entities/portal/module.d.ts +3 -0
  108. package/dist-sdk/src/entities/portal/module.js +28 -0
  109. package/dist-sdk/src/entities/portal/to-tf.d.ts +12 -0
  110. package/dist-sdk/src/entities/portal/to-tf.js +73 -0
  111. package/dist-sdk/src/entities/portal/types.d.ts +1 -0
  112. package/dist-sdk/src/entities/portal/types.js +1 -0
  113. package/dist-sdk/src/entities/relationship/module.js +2 -0
  114. package/dist-sdk/src/entities/relationship/pair-check.d.ts +7 -0
  115. package/dist-sdk/src/entities/relationship/pair-check.js +68 -0
  116. package/dist-sdk/src/entities/relationship/to-tf.d.ts +2 -0
  117. package/dist-sdk/src/entities/relationship/to-tf.js +12 -3
  118. package/dist-sdk/src/entities/search-table/module.js +1 -0
  119. package/dist-sdk/src/entities/search-table/to-tf.d.ts +1 -0
  120. package/dist-sdk/src/entities/search-table/to-tf.js +1 -1
  121. package/dist-sdk/src/entities/service-account/build.d.ts +15 -2
  122. package/dist-sdk/src/entities/service-account/from-tf.d.ts +2 -4
  123. package/dist-sdk/src/entities/service-account/from-tf.js +17 -5
  124. package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +56 -0
  125. package/dist-sdk/src/entities/service-account/role-fidelity.js +243 -0
  126. package/dist-sdk/src/entities/service-account/to-tf.d.ts +14 -0
  127. package/dist-sdk/src/entities/service-account/to-tf.js +17 -0
  128. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +1 -1
  129. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +5 -2
  130. package/dist-sdk/src/entities/shared/filters/ast.d.ts +8 -0
  131. package/dist-sdk/src/entities/shared/filters/index.d.ts +2 -0
  132. package/dist-sdk/src/entities/shared/filters/index.js +14 -4
  133. package/dist-sdk/src/entities/shared/filters/print.js +17 -1
  134. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +2 -0
  135. package/dist-sdk/src/entities/shared/filters/tf-codec.js +5 -1
  136. package/dist-sdk/src/entities/shared/filters/types.d.ts +9 -1
  137. package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -5
  138. package/dist-sdk/src/entities/shared/types/field-types.js +4 -0
  139. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +2 -1
  140. package/dist-sdk/src/entities/skill/from-tf.js +66 -13
  141. package/dist-sdk/src/entities/skill/input-coverage.d.ts +7 -0
  142. package/dist-sdk/src/entities/skill/input-coverage.js +11 -0
  143. package/dist-sdk/src/entities/skill/to-tf.js +14 -4
  144. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
  145. package/dist-sdk/src/entities/skill-tool/from-tf.js +8 -2
  146. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -2
  147. package/dist-sdk/src/entities/skill-tool/to-tf.js +27 -5
  148. package/dist-sdk/src/entities/table/catalog.d.ts +14 -0
  149. package/dist-sdk/src/entities/table/catalog.js +66 -0
  150. package/dist-sdk/src/entities/table/module.js +2 -1
  151. package/dist-sdk/src/entities/table/to-tf.js +2 -2
  152. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +49 -9
  153. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +71 -18
  154. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +19 -4
  155. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +82 -10
  156. package/dist-sdk/src/entities/view/agent-view-layout.d.ts +53 -23
  157. package/dist-sdk/src/entities/view/agent-view-layout.js +1 -1
  158. package/dist-sdk/src/entities/view/from-tf.d.ts +3 -2
  159. package/dist-sdk/src/entities/view/from-tf.js +124 -12
  160. package/dist-sdk/src/entities/view/module.js +30 -3
  161. package/dist-sdk/src/entities/view/to-tf.d.ts +14 -1
  162. package/dist-sdk/src/entities/view/to-tf.js +67 -10
  163. package/dist-sdk/src/entities/view/types.d.ts +4 -15
  164. package/dist-sdk/src/entities/view/types.js +15 -15
  165. package/dist-sdk/src/entities/widget/build.d.ts +16 -1
  166. package/dist-sdk/src/entities/widget/build.js +11 -1
  167. package/dist-sdk/src/entities/widget/to-tf.js +34 -8
  168. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +16 -5
  169. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  170. package/dist-sdk/src/graph/index.d.ts +11 -0
  171. package/dist-sdk/src/graph/index.js +21 -0
  172. package/dist-sdk/src/graph/modules.js +2 -0
  173. package/dist-sdk/src/graph/types.d.ts +55 -2
  174. package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
  175. package/dist-sdk/src/internal/sdk-package.js +1 -0
  176. package/package.json +10 -1
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Collects validation failures across a pull or build instead of stopping at
3
+ * the first one. A stale reference is fatal while authoring (build/plan/apply)
4
+ * and a warning on pull, which is a read of live configuration.
5
+ */
6
+ import { AsyncLocalStorage } from "node:async_hooks";
7
+ export function formatValidationFailure(failure) {
8
+ return `${failure.address}: ${failure.ownerKind} "${failure.name}": ${failure.message}`;
9
+ }
10
+ export class ValidationFailureError extends Error {
11
+ failures;
12
+ constructor(failures) {
13
+ super(failures.map(formatValidationFailure).join("\n"));
14
+ this.name = "ValidationFailureError";
15
+ this.failures = failures;
16
+ }
17
+ }
18
+ /**
19
+ * The workspace loader evaluates authored files through a second module
20
+ * graph (native import with a generation query, or jiti with
21
+ * `moduleCache: false`). A storage local to this module would be invisible
22
+ * to `def()` in that copy, and `instanceof` against this class would miss.
23
+ * One process-wide store keeps the async context shared.
24
+ */
25
+ const STORAGE_KEY = Symbol.for("edk.validationStorage");
26
+ function storage() {
27
+ const host = globalThis;
28
+ host[STORAGE_KEY] ??= new AsyncLocalStorage();
29
+ return host[STORAGE_KEY];
30
+ }
31
+ /** True for this module's class and for the same-shaped error from a loader copy. */
32
+ export function isValidationFailureError(error) {
33
+ if (error instanceof ValidationFailureError)
34
+ return true;
35
+ if (!(error instanceof Error) || error.name !== "ValidationFailureError")
36
+ return false;
37
+ return Array.isArray(error.failures);
38
+ }
39
+ export function withValidationSession(mode, run) {
40
+ if (storage().getStore() !== undefined)
41
+ return run();
42
+ return storage().run({ mode, failures: [], seen: new Set() }, run);
43
+ }
44
+ export function withValidationSessionAsync(mode, run) {
45
+ if (storage().getStore() !== undefined)
46
+ return run();
47
+ return storage().run({ mode, failures: [], seen: new Set() }, run);
48
+ }
49
+ export function currentValidationMode() {
50
+ return storage().getStore()?.mode;
51
+ }
52
+ export function currentValidationScope() {
53
+ const session = storage().getStore();
54
+ return { appTfLabel: session?.appTfLabel, parentScope: session?.parentScope };
55
+ }
56
+ export function setValidationScope(scope) {
57
+ const session = storage().getStore();
58
+ if (session === undefined)
59
+ return;
60
+ if (scope.appTfLabel !== undefined)
61
+ session.appTfLabel = scope.appTfLabel;
62
+ if (scope.parentScope !== undefined)
63
+ session.parentScope = scope.parentScope;
64
+ }
65
+ export function sessionValidationFailures() {
66
+ return storage().getStore()?.failures ?? [];
67
+ }
68
+ /** Record failures into the active session. No-op when nothing is collecting. */
69
+ export function recordValidations(incoming) {
70
+ const session = storage().getStore();
71
+ if (session === undefined)
72
+ return;
73
+ for (const failure of incoming) {
74
+ const severity = failure.staleReference === true && session.mode === "pull" ? "warning" : failure.severity;
75
+ const recorded = severity === failure.severity ? failure : { ...failure, severity };
76
+ const key = `${recorded.severity}\0${recorded.address}\0${recorded.message}`;
77
+ if (session.seen.has(key))
78
+ continue;
79
+ session.seen.add(key);
80
+ session.failures.push(recorded);
81
+ }
82
+ }
83
+ export function hasFatalValidation(failures) {
84
+ return failures.some((failure) => failure.severity === "fatal");
85
+ }
@@ -45,9 +45,12 @@ function fieldValueToTf(token, where, ctx) {
45
45
  function picklistLiteralToTf(literal, field, ctx) {
46
46
  if (field?.options === undefined || !field.options.includes(literal))
47
47
  return undefined;
48
- const localName = field.tags?.includes("STATUS")
48
+ // Hand-built refs to an app's system status/stage carry no tags; match them
49
+ // by key, as field resolution does. Elements have no status/stage system fields.
50
+ const systemKey = ctx.scope === "element" ? undefined : field.refName;
51
+ const localName = ctx.scope === "app" && (field.tags?.includes("STATUS") || systemKey === "status")
49
52
  ? `${ctx.ownerTfLabel}_status_options_by_label`
50
- : field.tags?.includes("STAGE")
53
+ : ctx.scope === "app" && (field.tags?.includes("STAGE") || systemKey === "stage")
51
54
  ? `${ctx.ownerTfLabel}_stage_options_by_label`
52
55
  : undefined;
53
56
  // Non-status/stage picklists: the field's own options-by-label local, keyed
@@ -126,22 +126,10 @@ export interface AgentV2Options extends EntityDeployOptions {
126
126
  readonly a2aSkills?: readonly A2ASkill[];
127
127
  readonly tools?: readonly AgentTool[];
128
128
  }
129
- /**
130
- * def()-time validation of run-automation (executeWorkflow) tools against
131
- * the embedded automation token's trigger/outputs bags — the runtime
132
- * backstop behind `agentRunAutomation`'s typed inputs (the app
133
- * handle/namespace pattern: throw with the full story, at def() time).
134
- *
135
- * MUST run before `slimTokens` — slimming strips the automation token's
136
- * `trigger`/`outputs` bags. Bags that are absent OR EMPTY are skipped:
137
- * absent = a hand-written/foreign token (the printer's foreign-token
138
- * policy — platform stays the backstop); empty `{}` = the catalog regen's
139
- * STUB pass, which builds the defs bag (and therefore calls def()) against
140
- * stub tokens whose bags are empty objects. A real catalog token is either
141
- * bag-less (paramless automation → undefined) or non-empty, so skipping
142
- * empty costs no real coverage.
143
- */
144
- export declare function validateAgentTools(agentName: string, tools: readonly AgentTool[]): void;
129
+ export declare function validateAgentTools(agentName: string, tools: readonly AgentTool[], identity?: {
130
+ readonly appTfLabel: string;
131
+ readonly agentRefName: string;
132
+ }): void;
145
133
  /**
146
134
  * The configured result of `agent` — its reference surface (`ref()`)
147
135
  * and its deployable entity (`def()`). Both take `refName` as a **call-time
@@ -13,6 +13,9 @@
13
13
  * the typed `app` reference, exactly like `automation`.
14
14
  */
15
15
  import { slimTokens } from "../../catalog/index.js";
16
+ import { appScopedResourceLabel, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
17
+ import { currentValidationMode, currentValidationScope, recordValidations, ValidationFailureError, } from "../../engine/validation.js";
18
+ import { RUN_AUTOMATION_TOOL_RESOURCE_TYPE } from "../agent-tool/types.js";
16
19
  export const agentStartingActionVariableType = {
17
20
  number: "NUMBER",
18
21
  select: "SELECT",
@@ -71,7 +74,13 @@ function serializeA2ASkill(s) {
71
74
  * bag-less (paramless automation → undefined) or non-empty, so skipping
72
75
  * empty costs no real coverage.
73
76
  */
74
- export function validateAgentTools(agentName, tools) {
77
+ function runAutomationToolAddress(appTfLabel, agentRefName, toolName) {
78
+ const agentBare = tsLabelToTfLabel(agentRefName);
79
+ const label = appScopedResourceLabel(appTfLabel, sanitizeName(`${agentBare}_${toolName}`));
80
+ return `${RUN_AUTOMATION_TOOL_RESOURCE_TYPE}.${label}`;
81
+ }
82
+ export function validateAgentTools(agentName, tools, identity) {
83
+ const failures = [];
75
84
  for (const tool of tools) {
76
85
  const inner = tool["executeWorkflow"];
77
86
  if (inner === undefined || typeof inner !== "object")
@@ -79,8 +88,19 @@ export function validateAgentTools(agentName, tools) {
79
88
  const toolName = inner.name ?? "";
80
89
  const auto = inner.automationId;
81
90
  const autoName = auto?.refName ?? "";
82
- const fail = (msg) => {
83
- throw new Error(`agent "${agentName}": tool "${toolName}" — ${msg}`);
91
+ const fail = (msg, staleReference = false) => {
92
+ const appTfLabel = identity?.appTfLabel ?? currentValidationScope().appTfLabel ?? "";
93
+ const agentRefName = identity?.agentRefName ?? "";
94
+ failures.push({
95
+ severity: "fatal",
96
+ address: appTfLabel !== "" && agentRefName !== ""
97
+ ? runAutomationToolAddress(appTfLabel, agentRefName, toolName)
98
+ : `agent.${agentName}`,
99
+ name: agentName,
100
+ ownerKind: "agent",
101
+ message: `tool "${toolName}" — ${msg}`,
102
+ ...(staleReference ? { staleReference: true } : {}),
103
+ });
84
104
  };
85
105
  const trigger = auto?.trigger;
86
106
  if (trigger !== undefined && typeof trigger === "object" && Object.keys(trigger).length > 0) {
@@ -91,6 +111,7 @@ export function validateAgentTools(agentName, tools) {
91
111
  if (!(param in trigger)) {
92
112
  fail(`input "${param}" does not match a trigger parameter of automation "${autoName}"` +
93
113
  (declared.length > 0 ? ` (declared: ${declared.join(", ")})` : " (it declares none)"));
114
+ continue;
94
115
  }
95
116
  mapped.add(param);
96
117
  if (trigger[param]?.required === true && input.required !== true) {
@@ -99,7 +120,9 @@ export function validateAgentTools(agentName, tools) {
99
120
  }
100
121
  for (const [param, meta] of Object.entries(trigger)) {
101
122
  if (meta?.required === true && !mapped.has(param)) {
102
- fail(`required trigger parameter "${param}" of automation "${autoName}" is not mapped to a tool input`);
123
+ // A newly required trigger parameter is a stale reference on pull.
124
+ // Every other mismatch is still a fatal authoring error.
125
+ fail(`required trigger parameter "${param}" of automation "${autoName}" is not mapped to a tool input`, true);
103
126
  }
104
127
  }
105
128
  }
@@ -115,6 +138,17 @@ export function validateAgentTools(agentName, tools) {
115
138
  }
116
139
  }
117
140
  }
141
+ if (failures.length === 0)
142
+ return;
143
+ const mode = currentValidationMode();
144
+ if (mode === "pull" || mode === "build")
145
+ recordValidations(failures);
146
+ // Pull keeps the agent when every finding is the unmapped-parameter warning.
147
+ // Any other mismatch stays fatal, so the agent is omitted instead of planning
148
+ // a tool the platform would reject.
149
+ if (mode === "pull" && failures.every((failure) => failure.staleReference === true))
150
+ return;
151
+ throw new ValidationFailureError(failures);
118
152
  }
119
153
  /** Build a v2 agent entity: identity + app from the flat options, exposing `.ref(refName)` and `.def(refName)`. */
120
154
  export function agent(opts) {
@@ -151,7 +185,8 @@ export function agent(opts) {
151
185
  return { __kind: "agent", refName: refName, name: opts.name, parent: opts.app.refName };
152
186
  },
153
187
  def(refName) {
154
- validateAgentTools(opts.name, opts.tools ?? []);
188
+ const appTfLabel = currentValidationScope().appTfLabel ?? tsLabelToTfLabel(opts.app.refName);
189
+ validateAgentTools(opts.name, opts.tools ?? [], { appTfLabel, agentRefName: refName });
155
190
  return {
156
191
  kind: "agent",
157
192
  parent: opts.app.refName,
@@ -622,7 +622,8 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
622
622
  // Lookup v2" table). Pulled TypeScript must round-trip through the
623
623
  // public typed API, not a raw wire-shaped object literal.
624
624
  const ownerName = tool.searchTableOwnerName ?? tool.searchTableOwnerRefName;
625
- lines.push(` table: tableSearchTableRef({ name: ${quote(tool.searchTableName ?? "")}, parent: ${quote(tool.searchTableOwnerRefName)}, parentName: ${quote(ownerName)} }),`);
625
+ const pinnedId = tool.searchTableId !== undefined ? `, id: ${quote(tool.searchTableId)}` : "";
626
+ lines.push(` table: tableSearchTableRef({ name: ${quote(tool.searchTableName ?? "")}, parent: ${quote(tool.searchTableOwnerRefName)}, parentName: ${quote(ownerName)}${pinnedId} }),`);
626
627
  }
627
628
  else {
628
629
  const parent = tool.target?.kind === "self"
@@ -635,7 +636,8 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
635
636
  lines.push(` table: catalog.${typedTable.ownerRefName}.searchTables${safeMember(typedTable.tableKey)},`);
636
637
  }
637
638
  else {
638
- lines.push(` table: { __kind: "searchTable", refName: ${quote(tool.searchTableName ?? "")}, name: ${quote(tool.searchTableName ?? "")}, parent: ${quote(parent)} },`);
639
+ const pinnedId = tool.searchTableId !== undefined ? `, id: ${quote(tool.searchTableId)}` : "";
640
+ lines.push(` table: { __kind: "searchTable", refName: ${quote(tool.searchTableName ?? "")}, name: ${quote(tool.searchTableName ?? "")}, parent: ${quote(parent)}${pinnedId} },`);
639
641
  }
640
642
  }
641
643
  }
@@ -470,10 +470,10 @@ export function agentToTf(entity, ctx) {
470
470
  app_id: ownerRef.value,
471
471
  });
472
472
  },
473
- foreignFieldRef: (t, l, o, n) => ctx.orgRefs.foreignField(t, l, o, n),
473
+ foreignFieldRef: (t, l, o, n, extra) => ctx.orgRefs.foreignField(t, l, o, n, extra),
474
474
  workspaceAspects: ctx.workspaceAspects,
475
475
  serviceAccountRef: (_label, serviceAccountName) => serviceAccountValue(serviceAccountName, ctx),
476
- tableSearchTableRef: (label, _tableRefName, tableName, searchTableName) => {
476
+ tableSearchTableRef: (label, _tableRefName, tableName, searchTableName, searchTableId) => {
477
477
  // sanitizeName(tableName), not tableRefName: ei labels the export
478
478
  // from the table's DISPLAY name (SanitizeName(displayName)), and
479
479
  // sanitizeName doesn't split a capital before a digit the way a
@@ -484,7 +484,10 @@ export function agentToTf(entity, ctx) {
484
484
  const tableLabel = sanitizeName(tableName);
485
485
  const tableId = expr.dataAttr("elementum_table", tableLabel, ["id"]);
486
486
  ctx.orgRefs.rawLookup("elementum_table", tableLabel, tableName);
487
- ctx.orgRefs.rawLookup("elementum_search_table", label, searchTableName, { table_id: tableId });
487
+ ctx.orgRefs.rawLookup("elementum_search_table", label, searchTableName, {
488
+ table_id: tableId,
489
+ ...(searchTableId !== undefined && searchTableId !== "" ? { id: searchTableId } : {}),
490
+ });
488
491
  return expr.dataAttr("elementum_search_table", label, ["id"]);
489
492
  },
490
493
  diagnostics: ctx.diagnostics,
@@ -114,6 +114,8 @@ export interface NormalizedAgentTool {
114
114
  readonly searchTableKey?: string;
115
115
  /** Stable lookup name when the table is resolved through a data source. */
116
116
  readonly searchTableName?: string;
117
+ /** Pinned search-table id when the data source names more than one row. */
118
+ readonly searchTableId?: string;
117
119
  /** Table-owned search table only: the owning Table entity's display name. */
118
120
  readonly searchTableOwnerName?: string;
119
121
  /** Table-owned search table only: the owning Table entity's authored refName. */
@@ -290,6 +290,7 @@ export function toolFromTf(block, owner, ctx) {
290
290
  }
291
291
  let searchTableKey;
292
292
  let searchTableName;
293
+ let searchTableId;
293
294
  let searchTableOwnerName;
294
295
  let searchTableOwnerRefName;
295
296
  let searchTableRawId;
@@ -310,11 +311,15 @@ export function toolFromTf(block, owner, ctx) {
310
311
  }
311
312
  else if (isTfExpr(value) && value.$expr === "data-attr" && value.type === "elementum_search_table") {
312
313
  searchTableName = ctx.dataName(value.type, value.label);
314
+ const dataAttrs = ctx.dataAttrs?.(value.type, value.label);
315
+ const pinnedId = dataAttrs?.["id"];
316
+ if (typeof pinnedId === "string" && pinnedId !== "")
317
+ searchTableId = pinnedId;
313
318
  // The generic search-table data source is used for both aspect-owned
314
319
  // and table-owned tables. The presence of table_id is the only
315
320
  // portable discriminator available in the HCL stream (mirrors
316
321
  // skill-tool/from-tf.ts's identical handling).
317
- const tableLabel = dataRefLabel(ctx.dataAttrs?.(value.type, value.label)?.["table_id"], "elementum_table");
322
+ const tableLabel = dataRefLabel(dataAttrs?.["table_id"], "elementum_table");
318
323
  if (tableLabel !== undefined) {
319
324
  searchTableOwnerName = ctx.dataName("elementum_table", tableLabel);
320
325
  if (searchTableOwnerName !== undefined) {
@@ -376,6 +381,7 @@ export function toolFromTf(block, owner, ctx) {
376
381
  }),
377
382
  ...(searchTableKey !== undefined && { searchTableKey }),
378
383
  ...(searchTableName !== undefined && { searchTableName }),
384
+ ...(searchTableId !== undefined && { searchTableId }),
379
385
  ...(searchTableOwnerName !== undefined && { searchTableOwnerName }),
380
386
  ...(searchTableOwnerRefName !== undefined && { searchTableOwnerRefName }),
381
387
  ...(searchTableRawId !== undefined && { searchTableRawId }),
@@ -33,7 +33,7 @@ export interface ToolToTfContext {
33
33
  readonly namespace?: string;
34
34
  }): void;
35
35
  /** Records a `data.elementum_field` lookup for a field owned by a foreign app/element. */
36
- foreignFieldRef(type: string, tfLabel: string, objectId: TfValue, name: string): void;
36
+ foreignFieldRef(type: string, tfLabel: string, objectId: TfValue, name: string, extraAttrs?: Readonly<Record<string, TfValue>>): void;
37
37
  /** App/element roots authored in this same workspace. */
38
38
  readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
39
39
  /** Records an app-scoped service-account lookup by name. */
@@ -44,7 +44,7 @@ export interface ToolToTfContext {
44
44
  * entry): records the `data.elementum_table`/`data.elementum_search_table`
45
45
  * lookups and returns the search table's id reference.
46
46
  */
47
- tableSearchTableRef?(tfLabel: string, tableRefName: string, tableName: string, searchTableName: string): TfValue | void;
47
+ tableSearchTableRef?(tfLabel: string, tableRefName: string, tableName: string, searchTableName: string, searchTableId?: string): TfValue | void;
48
48
  /** App-local automations whose publish resource will be emitted in this build. */
49
49
  readonly activeAutomationRefNames?: ReadonlySet<string>;
50
50
  /** Degradations land here — reported by the caller, never silent. */
@@ -14,8 +14,8 @@
14
14
  */
15
15
  import { workspaceAspectKey } from "../../engine/build/context.js";
16
16
  import { automationRunTargetResourceAttr } from "../automation/to-tf.js";
17
- import { appScopedResourceLabel, expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
18
- import { fieldRefToTfValue } from "../field/to-tf.js";
17
+ import { appScopedResourceLabel, expr, sanitizeName, scopedResourceLabel, stableIdSuffix, tsLabelToTfLabel } from "../../engine/tf/index.js";
18
+ import { authoredFieldKeysFromPayload, fieldRefToTfValue, } from "../field/to-tf.js";
19
19
  import { foreignFieldDataLabel } from "../shared/foreign-ref.js";
20
20
  import { encodeOptionalHandleDescription } from "../shared/handle-description.js";
21
21
  import { TOOL_SUB_TYPE_BY_TYPE_KEY } from "./types.js";
@@ -69,6 +69,7 @@ function resolveTarget(token, ctx) {
69
69
  refName,
70
70
  kind,
71
71
  localTfLabel: sibling.tfLabel,
72
+ fieldOwnership: authoredFieldKeysFromPayload(sibling.streamRootEntity?.payload),
72
73
  };
73
74
  }
74
75
  // ei derives foreign-app/foreign-element data labels from the display NAME.
@@ -157,7 +158,7 @@ function fieldRefValue(token, where, ctx, target) {
157
158
  // vs. real field resource, by authoring type) rather than reimplementing
158
159
  // it here — see fieldRefToTfValue's doc comment for the system-field
159
160
  // ordering rationale.
160
- const value = fieldRefToTfValue(token.fieldType ?? "", refName, target?.localTfLabel ?? ctx.appTfLabel, target?.kind === "element" ? "element" : "app");
161
+ const value = fieldRefToTfValue(token.fieldType ?? "", refName, target?.localTfLabel ?? ctx.appTfLabel, target?.kind === "element" ? "element" : "app", target?.fieldOwnership);
161
162
  if (value === undefined) {
162
163
  ctx.diagnostics.push(`${where}: field token "${refName}" has no terraform field resource mapping (fieldType ${JSON.stringify(token.fieldType ?? "")}); dropped`);
163
164
  }
@@ -344,6 +345,7 @@ export function toolToTf(entry, ctx) {
344
345
  }
345
346
  if (typeKey === "searchTable") {
346
347
  const table = inner.searchTableId;
348
+ const pinnedSearchTableId = typeof table?.id === "string" && table.id !== "" ? table.id : undefined;
347
349
  // The search table itself (not its owner - that's the __variant/parent
348
350
  // fallback below) has no portable lookup at all: unsafePlatformId()
349
351
  // round-trips it as a raw id directly, before the refName check below,
@@ -373,7 +375,21 @@ export function toolToTf(entry, ctx) {
373
375
  const workspaceTable = table.parent === undefined
374
376
  ? undefined
375
377
  : ctx.workspaceAspects?.get(workspaceAspectKey("table", table.parent));
376
- if (workspaceTable !== undefined) {
378
+ const searchName = table.name ?? table.refName;
379
+ const tableLookupLabel = `${sanitizeName(table.parentName ?? table.parent ?? "")}_${sanitizeName(searchName)}`;
380
+ const tableLookup = pinnedSearchTableId === undefined
381
+ ? tableLookupLabel
382
+ : `${tableLookupLabel}_${stableIdSuffix(pinnedSearchTableId)}`;
383
+ if (pinnedSearchTableId !== undefined && ctx.tableSearchTableRef !== undefined && table.parent !== undefined && table.parent !== "") {
384
+ const lookup = ctx.tableSearchTableRef(tableLookup, table.parent, table.parentName ?? table.parent, searchName, pinnedSearchTableId);
385
+ if (lookup !== undefined)
386
+ attrs["search_table_id"] = lookup;
387
+ else {
388
+ ctx.diagnostics.push(`${where}: table-owned search table lookup could not be materialized; dropped`);
389
+ return undefined;
390
+ }
391
+ }
392
+ else if (workspaceTable !== undefined) {
377
393
  // sanitizeName, not tsLabelToTfLabel: table.refName here always comes
378
394
  // from a search-table token factory (searchTableRef/
379
395
  // tableSearchTableRef), which sets refName straight from the raw
@@ -390,7 +406,7 @@ export function toolToTf(entry, ctx) {
390
406
  // sanitizes to "hcp_lookupv2" while ei's own label for "HCP Lookup
391
407
  // v2" is "hcp_lookup_v2", a perpetual plan diff (review feedback,
392
408
  // PR #1095, msivraj).
393
- const lookup = ctx.tableSearchTableRef(`${sanitizeName(table.parentName ?? table.parent)}_${sanitizeName(table.name ?? table.refName)}`, table.parent, table.parentName ?? table.parent, table.name ?? table.refName);
409
+ const lookup = ctx.tableSearchTableRef(tableLookup, table.parent, table.parentName ?? table.parent, searchName);
394
410
  if (lookup !== undefined)
395
411
  attrs["search_table_id"] = lookup;
396
412
  else {
@@ -407,6 +423,12 @@ export function toolToTf(entry, ctx) {
407
423
  return undefined;
408
424
  }
409
425
  }
426
+ else if (pinnedSearchTableId !== undefined) {
427
+ const ownerPart = target.localTfLabel ?? target.foreignTfLabel ?? sanitizeName(target.refName);
428
+ const lookupLabel = `${sanitizeName(`${ownerPart}_${table.name ?? table.refName}`)}_${stableIdSuffix(pinnedSearchTableId)}`;
429
+ ctx.foreignFieldRef("elementum_search_table", lookupLabel, target.value, table.name ?? table.refName, { id: pinnedSearchTableId });
430
+ attrs["search_table_id"] = expr.dataAttr("elementum_search_table", lookupLabel, ["id"]);
431
+ }
410
432
  else if (target.localTfLabel !== undefined) {
411
433
  const resourceType = table.__variant === "linked"
412
434
  ? "elementum_linked_ai_search_table"
@@ -11,8 +11,8 @@
11
11
  * Includes typed scalar, Dropdown/Multi-Select, relation, calculation, and
12
12
  * record-experience configuration with build/pull round-trip support.
13
13
  */
14
- import type { AppAgentViewLayout } from "../view/agent-view-layout.js";
15
- import { type AgentRef, type AppOrElementOrTaskRef, type AppOrElementRef, type AutomationCatalogRef, type CatalogRef, type ChartRef, type CloudLinkRef, type DashboardRef, type FieldRef, type WidgetRef } from "../../catalog/index.js";
14
+ import type { AppAgentViewLayout, ViewBlocksLayout } from "../view/agent-view-layout.js";
15
+ import { type AgentRef, type AppOrElementOrTaskRef, type AppOrElementRef, type AutomationCatalogRef, type CatalogRef, type ChartRef, type CloudLinkRef, type DashboardRef, type FieldRef, type ViewRef, type WidgetRef } from "../../catalog/index.js";
16
16
  import type { WorkflowFieldType } from "../shared/types/field-types.js";
17
17
  import { type SystemFieldKey } from "../../core/system-fields.js";
18
18
  import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
@@ -132,6 +132,17 @@ export interface AppField {
132
132
  readonly numericFormat?: AspectNumericFieldFormat;
133
133
  /** `DECIMAL` only — display/storage precision (`elementum_decimal_field.decimal_places`). */
134
134
  readonly decimalPlaces?: number;
135
+ /**
136
+ * `ATTACHMENT` only — MIME types this field accepts (`application/pdf`,
137
+ * `image/*`, `image/png`). `*` is allowed only as the subtype. Always set
138
+ * this on a new attachment field.
139
+ *
140
+ * Omitting it on a newly created field leaves the live value null, and the
141
+ * platform rejects every upload. An existing field keeps its live value
142
+ * when this is omitted (provider UseStateForNullSet; EDK neither sets nor
143
+ * clears it).
144
+ */
145
+ readonly mediaTypes?: readonly string[];
135
146
  /** QR format (`TEXT` / `HANDLE`) — pure config, no refs. */
136
147
  readonly qrFormat?: AspectFieldQrFormat;
137
148
  /**
@@ -315,6 +326,29 @@ export interface AppAgentView extends ManagedViewSharing {
315
326
  */
316
327
  readonly layout?: AppAgentViewLayout;
317
328
  }
329
+ /**
330
+ * A Custom view: a page composed of Elementum Blocks (lists, tables, charts,
331
+ * metrics, text and actions) — the views the admin UI's view builder creates.
332
+ */
333
+ export interface AppCustomView extends ManagedViewSharing {
334
+ readonly name: string;
335
+ /** An agent of this app attached to the view. */
336
+ readonly agent?: AgentRef;
337
+ readonly allowRecordCreation?: boolean;
338
+ /** Provider-native filter object; pulled values round-trip verbatim. */
339
+ readonly filter?: Filter;
340
+ /** Ordered, typed field sorts using the platform's managed-view Sort contract. */
341
+ readonly sort?: ManagedViewSort;
342
+ readonly displayOrder?: number;
343
+ /**
344
+ * The view's blocks: a root element key and the elements it composes.
345
+ * Apps, elements and fields are typed references. The code owns the
346
+ * layout: omitting it leaves the view with no layout, and an apply then
347
+ * removes a live one. Run `elementum pull app` to bring a layout built in
348
+ * the admin UI into code before applying.
349
+ */
350
+ readonly layout?: ViewBlocksLayout;
351
+ }
318
352
  /** A calendar view positioned by a date/datetime field (`elementum_calendar_view`). */
319
353
  export interface AppCalendarView extends ManagedViewSharing {
320
354
  readonly name: string;
@@ -368,7 +402,42 @@ export interface AppRecordCreateFormSection {
368
402
  export interface AppRecordCreateForm {
369
403
  readonly sections: readonly AppRecordCreateFormSection[];
370
404
  }
371
- export interface AppV2Options<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>> extends EntityDeployOptions {
405
+ /** An app's managed views, one bag per view type, keyed by view ref name. */
406
+ export interface AppViewBags {
407
+ /** Saved list views, keyed by view ref name. */
408
+ readonly listViews?: Readonly<Record<string, AppListView>>;
409
+ /** Calendar views, keyed by stable view ref name. */
410
+ readonly calendarViews?: Readonly<Record<string, AppCalendarView>>;
411
+ /** Kanban views, keyed by stable view ref name. */
412
+ readonly kanbanViews?: Readonly<Record<string, AppKanbanView>>;
413
+ /** Dashboard-backed views, keyed by stable view ref name. */
414
+ readonly dashboardViews?: Readonly<Record<string, AppDashboardView>>;
415
+ /** Agent-powered views, keyed by view ref name. */
416
+ readonly agentViews?: Readonly<Record<string, AppAgentView>>;
417
+ /** Custom views (pages of Elementum Blocks), keyed by view ref name. */
418
+ readonly customViews?: Readonly<Record<string, AppCustomView>>;
419
+ }
420
+ /** The view bag each authoring property holds (see {@link ViewRef.viewType}). */
421
+ export declare const APP_VIEW_BAGS: {
422
+ readonly listViews: "list";
423
+ readonly calendarViews: "calendar";
424
+ readonly kanbanViews: "kanban";
425
+ readonly dashboardViews: "dashboard";
426
+ readonly agentViews: "agent";
427
+ readonly customViews: "custom";
428
+ };
429
+ type BagKeys<B> = B extends Readonly<Record<infer K, unknown>> ? Extract<K, string> : never;
430
+ /** Every view key an app's view bags declare. */
431
+ export type AppViewKeys<V extends AppViewBags> = {
432
+ [P in keyof AppViewBags]-?: BagKeys<NonNullable<V[P]>>;
433
+ }[keyof AppViewBags];
434
+ /** The `views` bag of an app's ref, keyed exactly like its view bags. */
435
+ export type AppViewRefs<V extends AppViewBags, RefName extends string> = {
436
+ readonly [K in AppViewKeys<V>]: ViewRef<RefName, K>;
437
+ };
438
+ /** App options; `V` carries the view bags so `ref().views` keeps their keys. */
439
+ export type AppV2Options<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, V extends AppViewBags = AppViewBags> = AppV2OptionsBase<F, R> & V;
440
+ interface AppV2OptionsBase<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>> extends EntityDeployOptions {
372
441
  readonly name: string;
373
442
  readonly category: AppCategory;
374
443
  readonly namespace?: string;
@@ -423,20 +492,10 @@ export interface AppV2Options<F extends Record<string, AppField> = Record<string
423
492
  * `ei export` doesn't surface at all).
424
493
  */
425
494
  readonly layouts?: Readonly<Record<string, AppLayout>>;
426
- /** Saved list views, keyed by view ref name. */
427
- readonly listViews?: Readonly<Record<string, AppListView>>;
428
- /** Calendar views, keyed by stable view ref name. */
429
- readonly calendarViews?: Readonly<Record<string, AppCalendarView>>;
430
- /** Kanban views, keyed by stable view ref name. */
431
- readonly kanbanViews?: Readonly<Record<string, AppKanbanView>>;
432
495
  /** Dashboards owned by this app. */
433
496
  readonly dashboards?: Readonly<Record<string, AppDashboard>>;
434
497
  /** Record-layout widgets keyed by a stable authoring name. */
435
498
  readonly widgets?: Readonly<Record<string, AppWidget>>;
436
- /** Dashboard-backed views, keyed by stable view ref name. */
437
- readonly dashboardViews?: Readonly<Record<string, AppDashboardView>>;
438
- /** Agent-powered views, keyed by view ref name. */
439
- readonly agentViews?: Readonly<Record<string, AppAgentView>>;
440
499
  /** Typed new-record form, distinct from legacy compose-only `recordCreateDisplayBlocks`. */
441
500
  readonly recordCreateForm?: AppRecordCreateForm;
442
501
  /** Typed V2 DASHBOARD layouts, keyed by stable EDK ref name. */
@@ -558,17 +617,18 @@ export type SystemFieldRefs<Parent extends string = string> = {
558
617
  * the same reason — `Record<string, never>` would reintroduce it even when
559
618
  * no `readonlyFields` are declared.
560
619
  */
561
- export type AppRef<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, RefName extends string = string> = Extract<AppOrElementRef<RefName>, {
620
+ export type AppRef<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, RefName extends string = string, V extends AppViewBags = AppViewBags> = Extract<AppOrElementRef<RefName>, {
562
621
  readonly __kind: "app";
563
622
  }> & {
564
623
  readonly fields: AppFieldRefs<F, RefName> & SystemFieldRefs<RefName> & R;
624
+ readonly views: AppViewRefs<V, RefName>;
565
625
  };
566
626
  /**
567
627
  * The app reference available while configuring options that point back into
568
628
  * the app itself. Child helpers preserve both the literal child key and owner,
569
629
  * without forcing the app file to import its generated catalog (a cycle).
570
630
  */
571
- export type AppSelfRef<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, RefName extends string = string> = AppRef<F, R, RefName> & {
631
+ export type AppSelfRef<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, RefName extends string = string, V extends AppViewBags = AppViewBags> = AppRef<F, R, RefName, V> & {
572
632
  agent<const Name extends string>(refName: Name, name?: string): CatalogRef<"agent", Name, RefName>;
573
633
  automation<const Name extends string>(refName: Name, name?: string): AutomationCatalogRef & CatalogRef<"automation", Name, RefName>;
574
634
  chart<const Name extends string>(refName: Name, name?: string): ChartRef<RefName, Name>;
@@ -576,7 +636,7 @@ export type AppSelfRef<F extends Record<string, AppField> = Record<string, AppFi
576
636
  widget<const Name extends string>(refName: Name, name?: string): AppLayoutWidgetRef<RefName, Name>;
577
637
  };
578
638
  /** Reference-bearing app options that can safely be authored from `withRefs`. */
579
- export type AppReferenceConfiguration = Pick<AppV2Options, "layouts" | "listViews" | "calendarViews" | "kanbanViews" | "dashboards" | "widgets" | "dashboardViews" | "agentViews" | "recordCreateForm" | "dynamicLayouts" | "relationships" | "viewOrder" | "accessPolicies">;
639
+ export type AppReferenceConfiguration = Pick<AppV2Options, "layouts" | "listViews" | "calendarViews" | "kanbanViews" | "dashboards" | "widgets" | "dashboardViews" | "agentViews" | "customViews" | "recordCreateForm" | "dynamicLayouts" | "relationships" | "viewOrder" | "accessPolicies">;
580
640
  /**
581
641
  * The configured result of `app` — its reference surface (`ref()`) and
582
642
  * its deployable entity (`def()`). Both take `refName` as a **call-time
@@ -587,11 +647,11 @@ export type AppReferenceConfiguration = Pick<AppV2Options, "layouts" | "listView
587
647
  * inside `app({...})` would be the same redundant property the rest of
588
648
  * the system avoids, just one level up.
589
649
  */
590
- export interface AppConfigured<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>> {
591
- ref<const RefName extends string>(refName: RefName): AppRef<F, R, RefName>;
650
+ export interface AppConfigured<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, V extends AppViewBags = AppViewBags> {
651
+ ref<const RefName extends string>(refName: RefName): AppRef<F, R, RefName, V>;
592
652
  def(refName: string): DeployableEntity;
593
653
  /** Configure self-referential record experiences without hand-building ref tokens. */
594
- withRefs(configure: (app: AppSelfRef<F, R>) => AppReferenceConfiguration): AppConfigured<F, R>;
654
+ withRefs(configure: (app: AppSelfRef<F, R, string, V>) => AppReferenceConfiguration): AppConfigured<F, R, V>;
595
655
  }
596
656
  /**
597
657
  * Build a v2 app entity: org-owned, compose-body payload. Exposes
@@ -610,4 +670,13 @@ export interface AppConfigured<F extends Record<string, AppField> = Record<strin
610
670
  */
611
671
  export declare const APP_HANDLE_RE: RegExp;
612
672
  export declare function picklistOptionLabels(options: readonly (string | PicklistOption)[]): readonly string[];
613
- export declare function app<F extends Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>>(opts: AppV2Options<F, R>): AppConfigured<F, R>;
673
+ /**
674
+ * One `ViewRef` per authored view, keyed by its bag key and stamped with the
675
+ * owner's identity, so other stream roots (a portal's menu) can reference it.
676
+ */
677
+ export declare function appViewRefs(bags: AppViewBags, owner: {
678
+ readonly refName: string;
679
+ readonly name: string;
680
+ readonly namespace?: string;
681
+ }, parentKind: "app" | "element"): Record<string, ViewRef>;
682
+ export declare function app<F extends Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, const V extends AppViewBags = AppViewBags>(opts: AppV2Options<F, R, V>): AppConfigured<F, R, V>;