@elementumai/edk 0.9.17 → 0.9.19

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 (130) hide show
  1. package/README.md +8 -3
  2. package/dist-sdk/src/catalog/factories.d.ts +11 -0
  3. package/dist-sdk/src/catalog/factories.js +6 -0
  4. package/dist-sdk/src/catalog/index.d.ts +2 -2
  5. package/dist-sdk/src/catalog/index.js +2 -2
  6. package/dist-sdk/src/catalog/org.d.ts +39 -1
  7. package/dist-sdk/src/catalog/org.js +460 -50
  8. package/dist-sdk/src/catalog/types.d.ts +12 -2
  9. package/dist-sdk/src/catalog/types.js +2 -0
  10. package/dist-sdk/src/engine/pull/ref-only.js +54 -20
  11. package/dist-sdk/src/engine/pull/result-output.d.ts +2 -0
  12. package/dist-sdk/src/engine/pull/result-output.js +1 -1
  13. package/dist-sdk/src/engine/tf/expr.js +38 -13
  14. package/dist-sdk/src/engine/tf/index.d.ts +2 -2
  15. package/dist-sdk/src/engine/tf/index.js +2 -2
  16. package/dist-sdk/src/engine/tf/labels.d.ts +2 -0
  17. package/dist-sdk/src/engine/tf/labels.js +4 -0
  18. package/dist-sdk/src/engine/tf/parse.d.ts +19 -0
  19. package/dist-sdk/src/engine/tf/parse.js +105 -6
  20. package/dist-sdk/src/engine/workspace/loader.js +49 -12
  21. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +11 -1
  22. package/dist-sdk/src/entities/access-policy/from-tf.js +6 -1
  23. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +11 -0
  24. package/dist-sdk/src/entities/access-policy/to-tf.js +11 -4
  25. package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -1
  26. package/dist-sdk/src/entities/app/build.d.ts +10 -0
  27. package/dist-sdk/src/entities/app/build.js +0 -13
  28. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +6 -1
  29. package/dist-sdk/src/entities/app/from-tf.js +4 -3
  30. package/dist-sdk/src/entities/app/index.d.ts +2 -0
  31. package/dist-sdk/src/entities/app/index.js +1 -0
  32. package/dist-sdk/src/entities/app/module.js +13 -0
  33. package/dist-sdk/src/entities/app/to-tf.js +2 -0
  34. package/dist-sdk/src/entities/automation/build.d.ts +2 -1
  35. package/dist-sdk/src/entities/automation/build.js +27 -0
  36. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +6 -0
  37. package/dist-sdk/src/entities/automation/from-tf.js +156 -26
  38. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  39. package/dist-sdk/src/entities/automation/module.d.ts +2 -0
  40. package/dist-sdk/src/entities/automation/module.js +56 -0
  41. package/dist-sdk/src/entities/automation/output-field-types.d.ts +5 -4
  42. package/dist-sdk/src/entities/automation/output-field-types.js +23 -5
  43. package/dist-sdk/src/entities/automation/system-ref-name.d.ts +16 -0
  44. package/dist-sdk/src/entities/automation/system-ref-name.js +44 -0
  45. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +15 -0
  46. package/dist-sdk/src/entities/automation/task-output-labels.js +38 -0
  47. package/dist-sdk/src/entities/automation/tasks.d.ts +37 -5
  48. package/dist-sdk/src/entities/automation/tasks.js +23 -1
  49. package/dist-sdk/src/entities/automation/to-tf.js +158 -84
  50. package/dist-sdk/src/entities/automation/types.js +1 -0
  51. package/dist-sdk/src/entities/chart/from-tf.js +33 -17
  52. package/dist-sdk/src/entities/chart/module.js +3 -1
  53. package/dist-sdk/src/entities/chart/printer.d.ts +1 -0
  54. package/dist-sdk/src/entities/chart/printer.js +26 -16
  55. package/dist-sdk/src/entities/chart/rebind-owner.d.ts +3 -0
  56. package/dist-sdk/src/entities/chart/rebind-owner.js +42 -0
  57. package/dist-sdk/src/entities/chart/to-tf.js +12 -10
  58. package/dist-sdk/src/entities/dashboard/build.d.ts +4 -0
  59. package/dist-sdk/src/entities/dashboard/from-tf.js +15 -4
  60. package/dist-sdk/src/entities/dashboard/to-tf.d.ts +2 -0
  61. package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
  62. package/dist-sdk/src/entities/dashboard-widget/module.js +4 -0
  63. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +51 -2
  64. package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +3 -0
  65. package/dist-sdk/src/entities/dynamic-layout/dialect.js +5 -0
  66. package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +9 -6
  67. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +188 -26
  68. package/dist-sdk/src/entities/dynamic-layout/module.js +4 -1
  69. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +5 -1
  70. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +254 -23
  71. package/dist-sdk/src/entities/element/build.d.ts +8 -0
  72. package/dist-sdk/src/entities/element/build.js +1 -0
  73. package/dist-sdk/src/entities/element/from-tf.d.ts +1 -0
  74. package/dist-sdk/src/entities/element/from-tf.js +6 -2
  75. package/dist-sdk/src/entities/element/index.d.ts +1 -0
  76. package/dist-sdk/src/entities/element/index.js +1 -0
  77. package/dist-sdk/src/entities/element/module.js +2 -0
  78. package/dist-sdk/src/entities/element/to-tf.js +12 -0
  79. package/dist-sdk/src/entities/field/from-tf.d.ts +2 -0
  80. package/dist-sdk/src/entities/field/from-tf.js +11 -0
  81. package/dist-sdk/src/entities/field/to-tf.js +13 -9
  82. package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -1
  83. package/dist-sdk/src/entities/relationship/from-tf.js +53 -10
  84. package/dist-sdk/src/entities/relationship/to-tf.d.ts +8 -0
  85. package/dist-sdk/src/entities/relationship/to-tf.js +19 -10
  86. package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -2
  87. package/dist-sdk/src/entities/shared/filters/index.d.ts +23 -2
  88. package/dist-sdk/src/entities/shared/filters/index.js +24 -1
  89. package/dist-sdk/src/entities/shared/filters/print.js +22 -4
  90. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +23 -3
  91. package/dist-sdk/src/entities/shared/filters/tf-codec.js +60 -18
  92. package/dist-sdk/src/entities/shared/filters/types.d.ts +13 -4
  93. package/dist-sdk/src/entities/shared/foreign-ref.d.ts +16 -0
  94. package/dist-sdk/src/entities/shared/foreign-ref.js +17 -1
  95. package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -9
  96. package/dist-sdk/src/entities/skill/access-policy.d.ts +17 -0
  97. package/dist-sdk/src/entities/skill/access-policy.js +101 -0
  98. package/dist-sdk/src/entities/skill/build.d.ts +3 -0
  99. package/dist-sdk/src/entities/skill/build.js +3 -0
  100. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +4 -1
  101. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +21 -0
  102. package/dist-sdk/src/entities/skill/from-tf.d.ts +2 -0
  103. package/dist-sdk/src/entities/skill/from-tf.js +4 -9
  104. package/dist-sdk/src/entities/skill/index.d.ts +2 -0
  105. package/dist-sdk/src/entities/skill/index.js +1 -0
  106. package/dist-sdk/src/entities/skill/module.js +1 -0
  107. package/dist-sdk/src/entities/skill/to-tf.d.ts +2 -2
  108. package/dist-sdk/src/entities/skill/to-tf.js +5 -2
  109. package/dist-sdk/src/entities/skill-tool/to-tf.js +2 -1
  110. package/dist-sdk/src/entities/table/to-tf.js +3 -3
  111. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +49 -0
  112. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +224 -0
  113. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +36 -0
  114. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +288 -0
  115. package/dist-sdk/src/entities/view/agent-view-layout.d.ts +121 -0
  116. package/dist-sdk/src/entities/view/agent-view-layout.js +21 -0
  117. package/dist-sdk/src/entities/view/from-tf.d.ts +3 -1
  118. package/dist-sdk/src/entities/view/from-tf.js +42 -7
  119. package/dist-sdk/src/entities/view/ragnarok.d.ts +7 -0
  120. package/dist-sdk/src/entities/view/ragnarok.js +1 -0
  121. package/dist-sdk/src/entities/view/to-tf.d.ts +10 -1
  122. package/dist-sdk/src/entities/view/to-tf.js +30 -1
  123. package/dist-sdk/src/entities/view/types.js +2 -0
  124. package/dist-sdk/src/entities/widget/to-tf.js +2 -2
  125. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +815 -0
  126. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +5 -0
  127. package/dist-sdk/src/graph/index.d.ts +43 -0
  128. package/dist-sdk/src/graph/index.js +9 -0
  129. package/dist-sdk/src/graph/types.d.ts +78 -0
  130. package/package.json +11 -1
@@ -0,0 +1,21 @@
1
+ /** Font families the agent view renders. */
2
+ export const agentViewFontFamily = {
3
+ system: "system",
4
+ sans: "sans",
5
+ serif: "serif",
6
+ mono: "mono",
7
+ };
8
+ /**
9
+ * Per block type, the top-level props that hold platform ids. Ids are scoped
10
+ * per block, not by prop name: DetailsFieldsBlock's `fields[].fieldId` is a
11
+ * render identity, not a field lookup.
12
+ */
13
+ export const AGENT_VIEW_SPEC_ID_PROPS = {
14
+ DataTableBlock: { aspectId: "app", selectedAspectId: "app" },
15
+ ListCollectionBlock: { aspectId: "app", selectedAspectId: "app" },
16
+ ListControlsBlock: { filterAspectId: "app" },
17
+ ChartBlock: { aspectId: "app", fieldId: "field", groupByFieldId: "field" },
18
+ MetricsRowBlock: { aspectId: "app" },
19
+ };
20
+ /** Props holding nested filter structures, where references may sit at any depth. */
21
+ export const AGENT_VIEW_SPEC_FILTER_PROPS = ["filterJson", "filterFields", "quickFilters"];
@@ -6,7 +6,8 @@
6
6
  * module never names the app's own resource type.
7
7
  */
8
8
  import { type FromTfContext } from "../../engine/pull/context.js";
9
- import { type ChildResourceScope, type TfBlock } from "../../engine/tf/index.js";
9
+ import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
10
+ import { type NormalizedManagedViewSort } from "./build.js";
10
11
  import type { NormalizedAgentView, NormalizedCalendarView, NormalizedDashboardView, NormalizedKanbanView, NormalizedLayout, NormalizedListView } from "../app/deserializer/normalize.js";
11
12
  /** Report every attribute key not in `known` as dialect growth — shared by all four view/section passes below. */
12
13
  export interface ViewOwner {
@@ -32,3 +33,4 @@ export interface ViewsFromTfResult {
32
33
  }
33
34
  /** All three view resource kinds → the normalized shapes the app printer consumes. */
34
35
  export declare function viewsFromTf(layoutBlocks: readonly TfBlock[], listViewBlocks: readonly TfBlock[], calendarViewBlocks: readonly TfBlock[], kanbanViewBlocks: readonly TfBlock[], dashboardViewBlocks: readonly TfBlock[], agentViewBlocks: readonly TfBlock[], managedViewOrderBlocks: readonly TfBlock[], owner: ViewOwner, ctx: FromTfContext): ViewsFromTfResult;
36
+ export declare function managedViewSortFromTf(value: TfValue | undefined, owner: ViewOwner, where: string, ctx: FromTfContext): NormalizedManagedViewSort | undefined;
@@ -5,9 +5,10 @@
5
5
  * owning app's from-tf drives this pass and says who the owner is — this
6
6
  * module never names the app's own resource type.
7
7
  */
8
+ import { agentViewLayoutFromTf } from "./agent-view-layout-from-tf.js";
8
9
  import { optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
9
10
  import { reportUnknownAttrs } from "../../engine/pull/attrs.js";
10
- import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
11
+ import { isTfExpr, isTfLabel, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
11
12
  import { fieldKeyFromTfValue } from "../field/from-tf.js";
12
13
  import { DASHBOARD_RESOURCE_TYPE } from "../dashboard/module.js";
13
14
  import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
@@ -22,7 +23,7 @@ function viewFilter(value, owner, where, ctx) {
22
23
  ownerTfLabel: owner.ownerTfLabel,
23
24
  scope: owner.scope ?? "app",
24
25
  foreignFieldRefsById: ctx.foreignFieldRefsById,
25
- }, `${where}.filter`, ctx);
26
+ }, `${where}.filter`, ctx, { optionLookupsAreIdentities: true });
26
27
  }
27
28
  /** All three view resource kinds → the normalized shapes the app printer consumes. */
28
29
  export function viewsFromTf(layoutBlocks, listViewBlocks, calendarViewBlocks, kanbanViewBlocks, dashboardViewBlocks, agentViewBlocks, managedViewOrderBlocks, owner, ctx) {
@@ -206,10 +207,26 @@ function agentViewFromTf(block, owner, ctx) {
206
207
  const emptyUserIds = Array.isArray(attrs["user_ids"]) && attrs["user_ids"].length === 0;
207
208
  const emptyGroupIds = Array.isArray(attrs["group_ids"]) && attrs["group_ids"].length === 0;
208
209
  const filter = viewFilter(attrs["filter"], owner, where, ctx);
210
+ let layout;
211
+ if (attrs["layout"] !== undefined && attrs["layout"] !== null) {
212
+ const decoded = agentViewLayoutFromTf(attrs["layout"], {
213
+ isOwnApp: (value) => resourceRefLabel(value, owner.type) === owner.label,
214
+ fieldKey: (value) => fieldRefFromTf(value, owner.label, owner.ownerTfLabel, scope, ctx),
215
+ });
216
+ if (!decoded.ok) {
217
+ // The code owns the layout: printing the view without it would make the
218
+ // next apply clear the live customization. Leave the view unmanaged.
219
+ ctx.diagnostics.push(`${where}: ${decoded.reason}; the view is left unmanaged so its live layout is not cleared`);
220
+ ctx.skipped.push(`${AGENT_VIEW_RESOURCE_TYPE}.${label}`);
221
+ return undefined;
222
+ }
223
+ layout = decoded.layout;
224
+ }
209
225
  return {
210
226
  key: scopedLabelToBagKey(owner.ownerTfLabel, label, scope),
211
227
  name: optionalString(attrs, "name", where, ctx) ?? "",
212
228
  agentKey: scopedLabelToBagKey(owner.ownerTfLabel, agentLabel, scope),
229
+ ...(layout !== undefined && { layout }),
213
230
  ...(typeof attrs["allow_record_creation"] === "boolean" && { allowRecordCreation: attrs["allow_record_creation"] }),
214
231
  ...(filter !== undefined && { filter }),
215
232
  ...(sort !== undefined && { sort }),
@@ -232,7 +249,7 @@ function layoutFromTf(block, owner, ctx) {
232
249
  // Elements carry no stage_ids_by_key at all (see element/locals.ts) - an
233
250
  // element's stage_id is always "" (build-side, see view/to-tf.ts's
234
251
  // layoutToTf) or the platform's own Initiate stage id (a live pull) -
235
- // neither resolves through stageKeyFromTf. But an element has exactly one
252
+ // neither resolves through stageIndexFromTf. But an element has exactly one
236
253
  // possible layout, so "which stage" is never actually ambiguous the way
237
254
  // it is for apps: always use the synthetic "layout" key, deterministically,
238
255
  // with no diagnostic - matching both elementToTf's own bag key and the
@@ -254,10 +271,16 @@ function layoutFromTf(block, owner, ctx) {
254
271
  }
255
272
  return { stageKey: "layout", sections };
256
273
  }
257
- const stageKey = stageKeyFromTf(attrs["stage_id"], owner.label);
274
+ const stageIndex = stageIndexFromTf(attrs["stage_id"], owner.label);
258
275
  const labelStageKey = scopedLabelToBagKey(owner.ownerTfLabel, label, scope);
276
+ // Layout bag keys are tsLabels; an index outside the tfLabel alphabet keeps
277
+ // the key derived from the resource label instead.
278
+ const stageKey = stageIndex !== undefined && isTfLabel(stageIndex) ? tfLabelToTsLabel(stageIndex) : undefined;
259
279
  const canInferStageKey = typeof attrs["stage_id"] === "string" && owner.stageKeys?.has(labelStageKey) === true;
260
- if (stageKey === undefined && !canInferStageKey) {
280
+ if (stageIndex !== undefined && stageKey === undefined) {
281
+ ctx.diagnostics.push(`${where}: stage key ${JSON.stringify(stageIndex)} is outside the terraform label alphabet; using the layout's own label "${label}" as the stage key`);
282
+ }
283
+ else if (stageKey === undefined && !canInferStageKey) {
261
284
  ctx.diagnostics.push(`${where}: stage_id is not a "local.${owner.label}_stage_ids_by_key[...]" reference; using the layout's own label "${label}" as the stage key (may not match the platform's real stage key)`);
262
285
  }
263
286
  const sectionsAttr = attrs["sections"];
@@ -274,7 +297,7 @@ function layoutFromTf(block, owner, ctx) {
274
297
  }
275
298
  return { stageKey: stageKey ?? labelStageKey, sections };
276
299
  }
277
- function stageKeyFromTf(v, ownerLabel) {
300
+ function stageIndexFromTf(v, ownerLabel) {
278
301
  if (v === undefined || !isTfExpr(v) || v.$expr !== "local")
279
302
  return undefined;
280
303
  if (v.name !== `${ownerLabel}_stage_ids_by_key`)
@@ -311,6 +334,18 @@ function sectionFromTf(raw, ownerLabel, ownerTfLabel, scope, where, ctx) {
311
334
  section.color = rec["color"];
312
335
  if (typeof rec["max_columns"] === "number")
313
336
  section.maxColumns = rec["max_columns"];
337
+ if (rec["agent_id"] !== undefined) {
338
+ const agentLabel = resourceRefLabel(rec["agent_id"], "elementum_agent");
339
+ if (agentLabel === undefined) {
340
+ ctx.diagnostics.push(`${where}: section agent_id is not an elementum_agent resource reference; agent dropped`);
341
+ }
342
+ else if (scope !== "app") {
343
+ ctx.diagnostics.push(`${where}: agent-assisted sections are only supported on app-owned layouts; agent dropped`);
344
+ }
345
+ else {
346
+ section.agentKey = scopedLabelToBagKey(ownerTfLabel, agentLabel, "app");
347
+ }
348
+ }
314
349
  const fieldIds = rec["field_ids"];
315
350
  if (Array.isArray(fieldIds)) {
316
351
  const fields = [];
@@ -428,7 +463,7 @@ function listViewFromTf(block, owner, ctx) {
428
463
  function jsonencodeValue(v) {
429
464
  return v !== undefined && isTfExpr(v) && v.$expr === "jsonencode" ? v.value : undefined;
430
465
  }
431
- function managedViewSortFromTf(value, owner, where, ctx) {
466
+ export function managedViewSortFromTf(value, owner, where, ctx) {
432
467
  if (value === undefined)
433
468
  return undefined;
434
469
  const decoded = jsonencodeValue(value);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Elementum Blocks Spec — the document behind a managed view's custom JSON
3
+ * view. Generated from asgard's public schema into the ignored
4
+ * `src/generated/ragnarok/` by `npm run generate:ragnarok`; refresh with
5
+ * `npm run refresh:ragnarok` when asgard ships a new schema version.
6
+ */
7
+ export type { ElementumBlocksElement, ElementumBlocksSpec, } from "../../generated/ragnarok/ragnarok-spec.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -9,12 +9,13 @@
9
9
  * reported, never silent. Invalid authored filter trees fail at build time
10
10
  * with the same `EntityTfError` path used by access-policy row filters.
11
11
  */
12
+ import { type AppAgentViewLayoutWire } from "./agent-view-layout-to-tf.js";
12
13
  import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
13
14
  import type { Filter } from "../shared/filters/types.js";
14
15
  import type { ManagedViewSharing } from "./sharing.js";
15
16
  import type { ListViewDensity, ManagedViewSort } from "./build.js";
16
17
  import type { UnsafePlatformId } from "../../core/platform-id.js";
17
- import type { OrgRefLookup } from "../../engine/build/context.js";
18
+ import type { OrgRefLookup, WorkspaceAspect } from "../../engine/build/context.js";
18
19
  /** The authored field-ref shape post-`slimTokens`: a system key string, or a slimmed `FieldRef` token. */
19
20
  export type ViewFieldRefWire = string | {
20
21
  readonly __kind?: string;
@@ -30,6 +31,10 @@ export interface AppLayoutSectionWire {
30
31
  readonly icon?: string;
31
32
  readonly color?: string;
32
33
  readonly maxColumns?: number;
34
+ readonly agent?: {
35
+ readonly refName?: string;
36
+ readonly parent?: string;
37
+ };
33
38
  readonly fields?: readonly ViewFieldRefWire[];
34
39
  readonly widgets?: readonly {
35
40
  readonly __kind?: string;
@@ -60,6 +65,7 @@ export interface AppAgentViewWire extends ManagedViewSharing {
60
65
  readonly filter?: Filter;
61
66
  readonly sort?: ManagedViewSort;
62
67
  readonly displayOrder?: number;
68
+ readonly layout?: AppAgentViewLayoutWire;
63
69
  }
64
70
  export interface AppCalendarViewWire extends ManagedViewSharing {
65
71
  readonly name?: string;
@@ -104,6 +110,8 @@ export interface ViewToTfOptions {
104
110
  /** Declared sibling dashboard keys, for fail-fast dashboard-view references. */
105
111
  readonly dashboardKeys?: ReadonlySet<string>;
106
112
  readonly orgRefs?: OrgRefLookup;
113
+ /** Sibling workspace apps/elements, for agent view custom-view app references. */
114
+ readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
107
115
  /** Known emitted field addresses keyed by field bag key, for robust reference resolution. */
108
116
  readonly fieldAddresses?: ReadonlyMap<string, string>;
109
117
  /** Declared sibling widget keys, for typed classic-layout placement. */
@@ -116,3 +124,4 @@ export interface ViewToTfResult {
116
124
  }
117
125
  /** `layouts`/`listViews`/`viewOrder` → their resource blocks, in ei's dialect. */
118
126
  export declare function viewToTf(layouts: Readonly<Record<string, AppLayoutWire>> | undefined, listViews: Readonly<Record<string, AppListViewWire>> | undefined, calendarViews: Readonly<Record<string, AppCalendarViewWire>> | undefined, kanbanViews: Readonly<Record<string, AppKanbanViewWire>> | undefined, dashboardViews: Readonly<Record<string, AppDashboardViewWire>> | undefined, agentViews: Readonly<Record<string, AppAgentViewWire>> | undefined, viewOrder: readonly string[] | undefined, opts: ViewToTfOptions): ViewToTfResult;
127
+ export declare function managedViewSortToTf(sort: ManagedViewSort, ownerTfLabel: string, scope: ChildResourceScope, where: string, diagnostics: string[], fieldAddresses?: ReadonlyMap<string, string>): TfValue;
@@ -9,6 +9,7 @@
9
9
  * reported, never silent. Invalid authored filter trees fail at build time
10
10
  * with the same `EntityTfError` path used by access-policy row filters.
11
11
  */
12
+ import { agentViewLayoutToTf } from "./agent-view-layout-to-tf.js";
12
13
  import { expr, isCanonicalTsLabel, sanitizeName, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
13
14
  import { fieldRefToTfValue as customFieldRefToTfValue } from "../field/to-tf.js";
14
15
  import { ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
@@ -208,6 +209,19 @@ export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboa
208
209
  appendViewSharingAttrs(attrs, view, `agentViews.${viewKey}`, principalCtx);
209
210
  if (view.displayOrder !== undefined)
210
211
  attrs["display_order"] = view.displayOrder;
212
+ if (view.layout !== undefined) {
213
+ attrs["layout"] = agentViewLayoutToTf(view.layout, `agentViews.${viewKey}.layout`, {
214
+ ownerRefName,
215
+ ownerTfLabel,
216
+ scope,
217
+ objectId,
218
+ diagnostics,
219
+ fieldAddresses,
220
+ orgRefs: opts.orgRefs,
221
+ workspaceAspects: opts.workspaceAspects,
222
+ resolveField: (ref, where) => fieldRefToTfValue(ref, ownerTfLabel, scope, where, diagnostics, fieldAddresses),
223
+ });
224
+ }
211
225
  blocks.push({ kind: "resource", type: AGENT_VIEW_RESOURCE_TYPE, label: tfLabel, attrs });
212
226
  viewAddressByKey.set(viewKey, { type: AGENT_VIEW_RESOURCE_TYPE, label: tfLabel });
213
227
  }
@@ -250,7 +264,7 @@ export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboa
250
264
  }
251
265
  return { blocks };
252
266
  }
253
- function managedViewSortToTf(sort, ownerTfLabel, scope, where, diagnostics, fieldAddresses) {
267
+ export function managedViewSortToTf(sort, ownerTfLabel, scope, where, diagnostics, fieldAddresses) {
254
268
  const orders = [];
255
269
  for (const [index, order] of sort.orders.entries()) {
256
270
  const field = fieldRefToTfValue(order.field, ownerTfLabel, scope, `${where}.orders[${index}].field`, diagnostics, fieldAddresses);
@@ -292,6 +306,21 @@ function layoutToTf(stageKey, layout, ownerRefName, ownerTfLabel, scope, objectI
292
306
  if (section.maxColumns !== undefined)
293
307
  sec.max_columns = section.maxColumns;
294
308
  const where = `layouts.${stageKey} section "${section.name ?? ""}"`;
309
+ if (section.agent !== undefined) {
310
+ const agentRefName = section.agent.refName ?? "";
311
+ if (scope !== "app") {
312
+ diagnostics.push(`${where}: agent-assisted sections are only resolvable for app-owned agents; agent dropped`);
313
+ }
314
+ else if (section.agent.parent !== ownerRefName) {
315
+ diagnostics.push(`${where}: agent belongs to ${JSON.stringify(section.agent.parent)}, not ${JSON.stringify(ownerRefName)}; agent dropped`);
316
+ }
317
+ else if (!isCanonicalTsLabel(agentRefName)) {
318
+ diagnostics.push(`${where}: agent key "${agentRefName}" is not a canonical tsLabel; agent dropped`);
319
+ }
320
+ else {
321
+ sec.agent_id = expr.resourceAttr("elementum_agent", scopedResourceLabel(ownerTfLabel, tsLabelToTfLabel(agentRefName), "app"), ["id"]);
322
+ }
323
+ }
295
324
  const fields = (section.fields ?? []).filter((f) => {
296
325
  if (typeof f === "string" && LAYOUT_RESTRICTED_SYSTEM_FIELD_KEYS.has(f)) {
297
326
  diagnostics.push(`${where}: system field "${f}" is platform-managed and cannot be placed in a layout section; dropped`);
@@ -78,6 +78,7 @@ export const KNOWN_LAYOUT_SECTION_ATTRS = new Set([
78
78
  "max_columns",
79
79
  "field_ids",
80
80
  "modules",
81
+ "agent_id",
81
82
  ]);
82
83
  /** Attributes `listViewFromTf` understands. */
83
84
  export const KNOWN_LIST_VIEW_ATTRS = new Set([
@@ -102,6 +103,7 @@ export const KNOWN_AGENT_VIEW_ATTRS = new Set([
102
103
  "user_ids",
103
104
  "group_ids",
104
105
  "display_order",
106
+ "layout",
105
107
  ]);
106
108
  const COMMON_TYPED_VIEW_ATTRS = [
107
109
  "aspect_id",
@@ -1,5 +1,5 @@
1
1
  import { workspaceAspectKey } from "../../engine/build/context.js";
2
- import { resolveForeignRef } from "../shared/foreign-ref.js";
2
+ import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
3
3
  import { appScopedResourceLabel, expr, isCanonicalTsLabel, sanitizeName, scopedResourceLabel, tfLabelToTsLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
4
4
  import { AUTOMATION_RESOURCE_TYPE } from "../automation/types.js";
5
5
  import { fieldMetadataFromEntries } from "../field/metadata.js";
@@ -224,7 +224,7 @@ function resolveColumns(columns, target, where, opts) {
224
224
  }
225
225
  }
226
226
  if (target.kind !== undefined) {
227
- const label = sanitizeName(`${target.kind}_${target.tfLabel ?? target.refName ?? "target"}_${value.name ?? refName}`);
227
+ const label = foreignFieldDataLabel(target.kind, target.tfLabel ?? target.refName ?? "target", value.name ?? refName);
228
228
  opts.orgRefs.foreignField("elementum_field", label, target.value, value.name ?? refName);
229
229
  out.push(expr.dataAttr("elementum_field", label, ["id"]));
230
230
  continue;