@inf-monkeys-tech/monkeys 1.1.61 → 1.1.63

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 (84) hide show
  1. package/lib/contracts/agent-data.d.ts +2 -2
  2. package/lib/contracts/agent.d.ts +3 -3
  3. package/lib/contracts/artifact-platform.d.ts +6 -263
  4. package/lib/contracts/artifact-platform.d.ts.map +1 -1
  5. package/lib/contracts/artifact-platform.js +14 -113
  6. package/lib/contracts/artifact-platform.js.map +1 -1
  7. package/lib/contracts/bento-block.d.ts +616 -0
  8. package/lib/contracts/bento-block.d.ts.map +1 -0
  9. package/lib/contracts/bento-block.js +505 -0
  10. package/lib/contracts/bento-block.js.map +1 -0
  11. package/lib/contracts/declarative-control-http.d.ts +5167 -814
  12. package/lib/contracts/declarative-control-http.d.ts.map +1 -1
  13. package/lib/contracts/declarative-control.d.ts +483 -113
  14. package/lib/contracts/declarative-control.d.ts.map +1 -1
  15. package/lib/contracts/declarative-document-import.d.ts +15 -15
  16. package/lib/contracts/declarative-publication-job.d.ts +1104 -208
  17. package/lib/contracts/declarative-publication-job.d.ts.map +1 -1
  18. package/lib/contracts/index.d.ts +1 -0
  19. package/lib/contracts/index.d.ts.map +1 -1
  20. package/lib/contracts/index.js +1 -0
  21. package/lib/contracts/index.js.map +1 -1
  22. package/lib/contracts/menu.d.ts +4 -4
  23. package/lib/contracts/page-expression.d.ts +5 -5
  24. package/lib/contracts/page.d.ts +14 -14
  25. package/lib/contracts/render.d.ts +363 -66
  26. package/lib/contracts/render.d.ts.map +1 -1
  27. package/lib/contracts/render.js +60 -5
  28. package/lib/contracts/render.js.map +1 -1
  29. package/lib/contracts/semantic.d.ts +4 -4
  30. package/lib/contracts/tenant.d.ts +26 -26
  31. package/lib/contracts/trend.d.ts +1 -1
  32. package/lib/contracts/unified-view.d.ts +26 -533
  33. package/lib/contracts/unified-view.d.ts.map +1 -1
  34. package/lib/contracts/unified-view.js +17 -316
  35. package/lib/contracts/unified-view.js.map +1 -1
  36. package/lib/contracts/workflow-definition.d.ts +10 -10
  37. package/lib/esm/{chunk-NKTRUUOP.mjs → chunk-766TRFRH.mjs} +3548 -3406
  38. package/lib/esm/chunk-766TRFRH.mjs.map +1 -0
  39. package/lib/esm/{chunk-DPHV7ES3.mjs → chunk-BTJGKWPM.mjs} +327 -143
  40. package/lib/esm/chunk-BTJGKWPM.mjs.map +1 -0
  41. package/lib/esm/{chunk-7MUE4GTZ.mjs → chunk-MP4OJWJ3.mjs} +2 -2
  42. package/lib/esm/{chunk-43N4Q3U7.mjs → chunk-SDA2NWFB.mjs} +4 -2
  43. package/lib/esm/chunk-SDA2NWFB.mjs.map +1 -0
  44. package/lib/esm/contracts/index.mjs +44 -28
  45. package/lib/esm/index.mjs +54 -36
  46. package/lib/esm/index.mjs.map +1 -1
  47. package/lib/esm/runtime/index.mjs +11 -9
  48. package/lib/esm/schemas/index.mjs +26 -28
  49. package/lib/json-schema/bento-node.schema.json +1446 -0
  50. package/lib/json-schema/index.json +1 -0
  51. package/lib/json-schema/overlay-node.schema.json +1092 -49
  52. package/lib/json-schema/page-runtime-bundle.schema.json +1996 -424
  53. package/lib/json-schema/page.schema.json +24 -0
  54. package/lib/json-schema/render-node.schema.json +1317 -274
  55. package/lib/json-schema/render-tree.schema.json +1686 -114
  56. package/lib/json-schema/view-ontology-record.schema.json +1141 -145
  57. package/lib/runtime/artifact-session.d.ts +5 -10
  58. package/lib/runtime/artifact-session.d.ts.map +1 -1
  59. package/lib/runtime/artifact-session.js +91 -78
  60. package/lib/runtime/artifact-session.js.map +1 -1
  61. package/lib/runtime/bento-render-tree.d.ts +22 -0
  62. package/lib/runtime/bento-render-tree.d.ts.map +1 -0
  63. package/lib/runtime/bento-render-tree.js +194 -0
  64. package/lib/runtime/bento-render-tree.js.map +1 -0
  65. package/lib/runtime/index.d.ts +1 -0
  66. package/lib/runtime/index.d.ts.map +1 -1
  67. package/lib/runtime/index.js +1 -0
  68. package/lib/runtime/index.js.map +1 -1
  69. package/lib/runtime/native-page-composition.d.ts +2 -2
  70. package/lib/runtime/runtime-definition-wire.d.ts +526 -78
  71. package/lib/runtime/runtime-definition-wire.d.ts.map +1 -1
  72. package/lib/runtime/unified-view-compiler.d.ts +12 -16
  73. package/lib/runtime/unified-view-compiler.d.ts.map +1 -1
  74. package/lib/runtime/unified-view-compiler.js +69 -77
  75. package/lib/runtime/unified-view-compiler.js.map +1 -1
  76. package/lib/schemas/index.d.ts +1523 -3082
  77. package/lib/schemas/index.d.ts.map +1 -1
  78. package/lib/schemas/index.js +32 -30
  79. package/lib/schemas/index.js.map +1 -1
  80. package/package.json +2 -2
  81. package/lib/esm/chunk-43N4Q3U7.mjs.map +0 -1
  82. package/lib/esm/chunk-DPHV7ES3.mjs.map +0 -1
  83. package/lib/esm/chunk-NKTRUUOP.mjs.map +0 -1
  84. /package/lib/esm/{chunk-7MUE4GTZ.mjs.map → chunk-MP4OJWJ3.mjs.map} +0 -0
@@ -4,7 +4,7 @@ import {
4
4
  PAGE_STREAM_MAX_FRAME_BYTES,
5
5
  PageStreamDescriptorSchema,
6
6
  PageStreamEventSchema
7
- } from "./chunk-7MUE4GTZ.mjs";
7
+ } from "./chunk-MP4OJWJ3.mjs";
8
8
  import {
9
9
  AccessPolicySchema,
10
10
  ActionProgramDefinitionSchema,
@@ -12,6 +12,8 @@ import {
12
12
  AgentSessionViewModelSchema,
13
13
  ApplicationHandoffSchema,
14
14
  ArtifactProfileSchema,
15
+ ArtifactViewSchema,
16
+ BENTO_GRID_COLUMNS,
15
17
  CapabilityManifestSchema,
16
18
  CapabilityRegistryDocumentSchema,
17
19
  CapabilityRegistrySourceSchema,
@@ -90,7 +92,6 @@ import {
90
92
  VIEW_ONTOLOGY_ID,
91
93
  ViewOntologyRecordSchema,
92
94
  ViewProviderDescriptorSchema,
93
- ViewSpecSchema,
94
95
  WorkbenchReleaseSchema,
95
96
  WorkbenchRuntimeBundleSchema,
96
97
  WorkbenchSchema,
@@ -119,7 +120,7 @@ import {
119
120
  require_validation,
120
121
  require_validation_error,
121
122
  resolveThemeTokens
122
- } from "./chunk-NKTRUUOP.mjs";
123
+ } from "./chunk-766TRFRH.mjs";
123
124
  import {
124
125
  __commonJS,
125
126
  __toESM
@@ -1082,12 +1083,12 @@ function buildArtifactCollabRoomId(key) {
1082
1083
  const tenant = key.tenantId ? `${key.tenantId}:` : "";
1083
1084
  return `artifact:${tenant}${key.teamId}:${key.ontologyId}:${key.artifactKind}:${key.recordId}`;
1084
1085
  }
1085
- function compileViewSpecToRenderTree(specInput, options = {}) {
1086
- const spec = ViewSpecSchema.parse(specInput);
1086
+ function compileBentoTreeToRenderTree(viewInput, options = {}) {
1087
+ const view = ArtifactViewSchema.parse(viewInput);
1087
1088
  const product = options.product ?? "studio";
1088
1089
  const ownerRepo = options.ownerRepo ?? "monkeys-studio";
1089
- const rootNodeId = `view.${spec.viewId}`;
1090
- const pageRef = { kind: "page", id: rootNodeId, ownerRepo };
1090
+ const rootPrefix = `bento.${view.viewId}`;
1091
+ const pageRef = { kind: "page", id: rootPrefix, ownerRepo };
1091
1092
  const defaultSurface = { frameOwner: "host", density: "default" };
1092
1093
  const defaultScroll = { owner: "surface", axis: "y", virtualizationBoundary: false };
1093
1094
  const defaultLifecycle = {
@@ -1097,73 +1098,87 @@ function compileViewSpecToRenderTree(specInput, options = {}) {
1097
1098
  deepLink: true,
1098
1099
  focusReturn: false
1099
1100
  };
1100
- const blockNodes = spec.blocks.map((block) => ({
1101
- contract: "RenderNode",
1102
- nodeId: `${rootNodeId}.block.${block.blockId}`,
1103
- kind: block.dataSource.kind === "artifact.body" ? "professional-provider" : block.dataSource.kind === "record.fields" ? "record" : "view",
1104
- version: 1,
1105
- ownerRepo,
1106
- parentNodeId: rootNodeId,
1107
- children: [],
1108
- slot: block.slot,
1109
- pageRef,
1110
- capabilityRef: {
1111
- kind: "capability",
1112
- id: block.capability,
1113
- version: 1,
1114
- ownerRepo
1115
- },
1116
- surface: defaultSurface,
1117
- scroll: block.dataSource.kind === "artifact.body" ? { owner: "provider", axis: "none", virtualizationBoundary: false } : defaultScroll,
1118
- activation: { activationId: `${rootNodeId}.activate.${block.blockId}`, mode: "inline" },
1119
- lifecycle: defaultLifecycle,
1120
- layout: { mode: "flex", direction: "column" },
1121
- responsive: [],
1122
- state: "idle",
1123
- renderModel: {
1124
- blockId: block.blockId,
1125
- dataSource: block.dataSource,
1126
- config: block.config,
1127
- ...block.title ? { title: block.title } : {}
1101
+ const nodes = [];
1102
+ const lowerNode = (node, parentNodeId) => {
1103
+ const nodeId = parentNodeId ? `${rootPrefix}.${node.id}` : `${rootPrefix}.root`;
1104
+ if (node.kind === "leaf") {
1105
+ const dsKind = node.block.dataSource?.kind;
1106
+ nodes.push({
1107
+ contract: "RenderNode",
1108
+ nodeId,
1109
+ kind: dsKind === "artifact.body" ? "professional-provider" : dsKind === "record.fields" ? "record" : "view",
1110
+ version: 1,
1111
+ ownerRepo,
1112
+ ...parentNodeId ? { parentNodeId } : {},
1113
+ children: [],
1114
+ slot: node.id,
1115
+ pageRef,
1116
+ capabilityRef: {
1117
+ kind: "capability",
1118
+ id: `monkeys.block.${node.block.customType ?? node.block.type}`,
1119
+ version: 1,
1120
+ ownerRepo
1121
+ },
1122
+ surface: defaultSurface,
1123
+ scroll: dsKind === "artifact.body" ? { owner: "provider", axis: "none", virtualizationBoundary: false } : defaultScroll,
1124
+ activation: { activationId: `${nodeId}.activate`, mode: "inline" },
1125
+ lifecycle: defaultLifecycle,
1126
+ layout: { mode: "flex", direction: "column" },
1127
+ responsive: [],
1128
+ state: "idle",
1129
+ renderModel: {
1130
+ bentoId: node.id,
1131
+ chrome: node.chrome ?? "panel",
1132
+ ...node.placement ? { placement: node.placement } : {},
1133
+ block: node.block
1134
+ }
1135
+ });
1136
+ return nodeId;
1128
1137
  }
1129
- }));
1130
- const rootLayout = spec.layout.mode === "split-horizontal" || spec.layout.mode === "three-pane" ? { mode: "flex", direction: "row" } : { mode: "flex", direction: "column" };
1131
- const rootNode = {
1132
- contract: "RenderNode",
1133
- nodeId: rootNodeId,
1134
- kind: "view",
1135
- version: 1,
1136
- ownerRepo,
1137
- children: blockNodes.map((node) => node.nodeId),
1138
- pageRef,
1139
- capabilityRef: {
1140
- kind: "capability",
1141
- id: "monkeys.view.host",
1138
+ const childIds = node.children.map((child) => lowerNode(child, nodeId));
1139
+ const isHorizontal = node.layout === "split" && (node.direction ?? "horizontal") === "horizontal";
1140
+ nodes.unshift({
1141
+ contract: "RenderNode",
1142
+ nodeId,
1143
+ kind: "view",
1142
1144
  version: 1,
1143
- ownerRepo
1144
- },
1145
- surface: defaultSurface,
1146
- scroll: { owner: "page", axis: "none", virtualizationBoundary: false },
1147
- activation: { activationId: `${rootNodeId}.activate`, mode: "inline" },
1148
- lifecycle: defaultLifecycle,
1149
- layout: rootLayout,
1150
- responsive: [],
1151
- state: "idle",
1152
- renderModel: {
1153
- viewId: spec.viewId,
1154
- title: spec.title,
1155
- subject: spec.subject,
1156
- ...spec.query ? { query: spec.query } : {},
1157
- layout: spec.layout,
1158
- wiring: spec.wiring
1159
- }
1145
+ ownerRepo,
1146
+ ...parentNodeId ? { parentNodeId } : {},
1147
+ children: childIds,
1148
+ pageRef,
1149
+ capabilityRef: {
1150
+ kind: "capability",
1151
+ id: `monkeys.bento.${node.layout}`,
1152
+ version: 1,
1153
+ ownerRepo
1154
+ },
1155
+ surface: defaultSurface,
1156
+ scroll: { owner: "page", axis: "none", virtualizationBoundary: false },
1157
+ activation: { activationId: `${nodeId}.activate`, mode: "inline" },
1158
+ lifecycle: defaultLifecycle,
1159
+ layout: isHorizontal ? { mode: "flex", direction: "row" } : { mode: "flex", direction: "column" },
1160
+ responsive: [],
1161
+ state: "idle",
1162
+ renderModel: {
1163
+ bentoId: node.id,
1164
+ layout: node.layout,
1165
+ ...node.direction ? { direction: node.direction } : {},
1166
+ ...node.columns ? { columns: node.columns } : {},
1167
+ ...node.chrome ? { chrome: node.chrome } : {},
1168
+ ...node.placement ? { placement: node.placement } : {},
1169
+ ...node.data ? { data: node.data } : {},
1170
+ ...node.wiring ? { wiring: node.wiring } : {}
1171
+ }
1172
+ });
1173
+ return nodeId;
1160
1174
  };
1175
+ const rootNodeId = lowerNode(view.root);
1161
1176
  return RenderTreeSchema.parse({
1162
1177
  contract: "RenderTree",
1163
- treeId: `tree.${spec.viewId}`,
1178
+ treeId: `tree.${view.viewId}`,
1164
1179
  product,
1165
1180
  rootNodeId,
1166
- nodes: [rootNode, ...blockNodes]
1181
+ nodes
1167
1182
  });
1168
1183
  }
1169
1184
  function createArtifactRegistry(initialProfiles = []) {
@@ -1171,7 +1186,9 @@ function createArtifactRegistry(initialProfiles = []) {
1171
1186
  const registerProfile = (profileInput, options = {}) => {
1172
1187
  const profile = ArtifactProfileSchema.parse(profileInput);
1173
1188
  if (profiles.has(profile.artifactKind) && !options.replace) {
1174
- throw new Error(`ArtifactProfile for kind "${profile.artifactKind}" is already registered.`);
1189
+ throw new Error(
1190
+ `ArtifactProfile for kind "${profile.artifactKind}" is already registered.`
1191
+ );
1175
1192
  }
1176
1193
  profiles.set(profile.artifactKind, profile);
1177
1194
  return profile;
@@ -1194,7 +1211,7 @@ function createArtifactRegistry(initialProfiles = []) {
1194
1211
  resolveView,
1195
1212
  compileView: (artifactKind, viewId, options) => {
1196
1213
  const view = resolveView(artifactKind, viewId);
1197
- return view ? compileViewSpecToRenderTree(view, options) : void 0;
1214
+ return view ? compileBentoTreeToRenderTree(view, options) : void 0;
1198
1215
  }
1199
1216
  });
1200
1217
  }
@@ -7765,21 +7782,21 @@ function nativePageMountPlan(page, catalogRevision) {
7765
7782
 
7766
7783
  // src/runtime/unified-view-compiler.ts
7767
7784
  var VIEW_LORO_KEYED_COLLECTIONS = [
7768
- { path: "ui.bentos", keyField: "bentoId" }
7785
+ { path: "root.children", keyField: "id" }
7769
7786
  ];
7770
7787
  function computeCanonicalViewHash(input) {
7771
7788
  return canonicalContentHash({
7772
7789
  boundOntologyId: input.boundOntologyId.trim(),
7773
7790
  data: input.data,
7774
- ui: input.ui
7791
+ root: input.root
7775
7792
  });
7776
7793
  }
7777
7794
  function buildDeterministicViewId(input) {
7778
7795
  return `view-${computeCanonicalViewHash(input).slice(0, 24)}`;
7779
7796
  }
7780
- function createSingleBentoViewRecord(params) {
7797
+ function createSingleBlockViewRecord(params) {
7781
7798
  const boundOntologyId = params.ontologyId.trim();
7782
- const bentoType = params.bentoType ?? "card";
7799
+ const blockType = params.blockType ?? "gallery";
7783
7800
  const data = {
7784
7801
  statements: {
7785
7802
  primary: {
@@ -7796,24 +7813,18 @@ function createSingleBentoViewRecord(params) {
7796
7813
  }
7797
7814
  }
7798
7815
  };
7799
- const ui = {
7800
- columns: 12,
7801
- rowHeight: 72,
7802
- bentos: [
7803
- {
7804
- bentoId: "primary",
7805
- bentoType,
7806
- x: 0,
7807
- y: 0,
7808
- w: 12,
7809
- h: 10,
7810
- statementId: "primary",
7811
- ...params.name ? { title: params.name } : {},
7812
- ...params.bentoProps ? { props: params.bentoProps } : {}
7813
- }
7814
- ]
7816
+ const root = {
7817
+ id: "primary",
7818
+ kind: "leaf",
7819
+ chrome: "none",
7820
+ block: {
7821
+ type: blockType,
7822
+ dataSource: { kind: "statement", statementId: "primary" },
7823
+ ...params.name ? { title: params.name } : {},
7824
+ ...params.blockConfig ? { config: params.blockConfig } : {}
7825
+ }
7815
7826
  };
7816
- const viewId = params.viewId?.trim() || buildDeterministicViewId({ boundOntologyId, data, ui });
7827
+ const viewId = params.viewId?.trim() || buildDeterministicViewId({ boundOntologyId, data, root });
7817
7828
  return ViewOntologyRecordSchema.parse({
7818
7829
  contract: "ViewOntologyRecord",
7819
7830
  schemaVersion: 1,
@@ -7823,7 +7834,7 @@ function createSingleBentoViewRecord(params) {
7823
7834
  ...params.description ? { description: params.description } : {},
7824
7835
  ...params.parentViewId ? { parentViewId: params.parentViewId } : {},
7825
7836
  data,
7826
- ui
7837
+ root
7827
7838
  });
7828
7839
  }
7829
7840
  function createSelectionShareViewRecord(params) {
@@ -7834,14 +7845,14 @@ function createSelectionShareViewRecord(params) {
7834
7845
  throw new Error("Selection share View requires at least one assetId.");
7835
7846
  }
7836
7847
  const where = uniqueIds.length === 1 ? { op: "field", field: "id", cmp: "eq", value: uniqueIds[0] } : { op: "field", field: "id", cmp: "in", value: uniqueIds };
7837
- const resolvedBentoType = params.bentoType ?? (uniqueIds.length === 1 ? "record-detail" : "card");
7838
- return createSingleBentoViewRecord({
7848
+ const resolvedBlockType = params.blockType ?? (uniqueIds.length === 1 ? "record-detail" : "gallery");
7849
+ return createSingleBlockViewRecord({
7839
7850
  viewId: params.viewId,
7840
7851
  ontologyId: params.ontologyId,
7841
7852
  name: params.name,
7842
7853
  where,
7843
7854
  select: params.select,
7844
- bentoType: resolvedBentoType
7855
+ blockType: resolvedBlockType
7845
7856
  });
7846
7857
  }
7847
7858
  function createWorkflowViewRecord(params) {
@@ -7868,31 +7879,44 @@ function createWorkflowViewRecord(params) {
7868
7879
  }
7869
7880
  }
7870
7881
  };
7871
- const ui2 = {
7872
- columns: 12,
7873
- rowHeight: 72,
7874
- bentos: [
7882
+ const root2 = {
7883
+ id: "workflow-preview",
7884
+ kind: "container",
7885
+ layout: "split",
7886
+ direction: "horizontal",
7887
+ chrome: "none",
7888
+ children: [
7875
7889
  {
7876
- bentoId: "form",
7877
- bentoType: "workflow-form",
7878
- x: 0,
7879
- y: 0,
7880
- w: 4,
7881
- h: 10,
7882
- actionStatementIds: ["execute_workflow"]
7890
+ id: "form",
7891
+ kind: "leaf",
7892
+ chrome: "panel",
7893
+ placement: { split: { size: "34%", minSize: 280 } },
7894
+ block: {
7895
+ type: "workflow-form",
7896
+ actionStatementIds: ["execute_workflow"]
7897
+ }
7883
7898
  },
7884
7899
  {
7885
- bentoId: "results",
7886
- bentoType: "workflow-waterfall",
7887
- x: 4,
7888
- y: 0,
7889
- w: 8,
7890
- h: 10,
7891
- statementId: "workflow_outputs"
7900
+ id: "results",
7901
+ kind: "leaf",
7902
+ chrome: "panel",
7903
+ placement: { split: { size: "66%" } },
7904
+ block: {
7905
+ type: "workflow-waterfall",
7906
+ dataSource: { kind: "statement", statementId: "workflow_outputs" }
7907
+ }
7908
+ }
7909
+ ],
7910
+ wiring: [
7911
+ {
7912
+ sourceNodeId: "form",
7913
+ event: "workflow.executed",
7914
+ targetNodeId: "results",
7915
+ action: "refresh"
7892
7916
  }
7893
7917
  ]
7894
7918
  };
7895
- const viewId2 = params.viewId?.trim() || buildDeterministicViewId({ boundOntologyId, data: data2, ui: ui2 });
7919
+ const viewId2 = params.viewId?.trim() || buildDeterministicViewId({ boundOntologyId, data: data2, root: root2 });
7896
7920
  return ViewOntologyRecordSchema.parse({
7897
7921
  contract: "ViewOntologyRecord",
7898
7922
  schemaVersion: 1,
@@ -7900,10 +7924,10 @@ function createWorkflowViewRecord(params) {
7900
7924
  boundOntologyId,
7901
7925
  ...params.name ? { name: params.name } : {},
7902
7926
  data: data2,
7903
- ui: ui2
7927
+ root: root2
7904
7928
  });
7905
7929
  }
7906
- const bentoTypeByPageType = {
7930
+ const blockTypeByPageType = {
7907
7931
  process: "workflow-canvas",
7908
7932
  log: "workflow-log",
7909
7933
  chat: "workflow-chat",
@@ -7918,22 +7942,16 @@ function createWorkflowViewRecord(params) {
7918
7942
  }
7919
7943
  }
7920
7944
  };
7921
- const ui = {
7922
- columns: 12,
7923
- rowHeight: 72,
7924
- bentos: [
7925
- {
7926
- bentoId: "main",
7927
- bentoType: bentoTypeByPageType[pageType],
7928
- x: 0,
7929
- y: 0,
7930
- w: 12,
7931
- h: 10,
7932
- actionStatementIds: ["workflow_binding"]
7933
- }
7934
- ]
7945
+ const root = {
7946
+ id: "main",
7947
+ kind: "leaf",
7948
+ chrome: "none",
7949
+ block: {
7950
+ type: blockTypeByPageType[pageType],
7951
+ actionStatementIds: ["workflow_binding"]
7952
+ }
7935
7953
  };
7936
- const viewId = params.viewId?.trim() || buildDeterministicViewId({ boundOntologyId, data, ui });
7954
+ const viewId = params.viewId?.trim() || buildDeterministicViewId({ boundOntologyId, data, root });
7937
7955
  return ViewOntologyRecordSchema.parse({
7938
7956
  contract: "ViewOntologyRecord",
7939
7957
  schemaVersion: 1,
@@ -7941,14 +7959,9 @@ function createWorkflowViewRecord(params) {
7941
7959
  boundOntologyId,
7942
7960
  ...params.name ? { name: params.name } : {},
7943
7961
  data,
7944
- ui
7962
+ root
7945
7963
  });
7946
7964
  }
7947
- function resolveViewHostShell(context) {
7948
- if (context.surface === "route") return "app-shell";
7949
- if (context.surface === "share") return context.linkPolicy?.shell ?? "share-shell";
7950
- return "none";
7951
- }
7952
7965
  var CAPABILITY_ORDER = [
7953
7966
  "read",
7954
7967
  "execute",
@@ -7958,10 +7971,180 @@ var CAPABILITY_ORDER = [
7958
7971
  function attenuateViewCapabilities(parentCapabilities, requestedCapabilities) {
7959
7972
  const allowed = new Set(parentCapabilities);
7960
7973
  if (!allowed.has("read")) return [];
7961
- const attenuated = CAPABILITY_ORDER.filter(
7974
+ return CAPABILITY_ORDER.filter(
7962
7975
  (cap) => cap === "read" || allowed.has(cap) && requestedCapabilities.includes(cap)
7963
7976
  );
7964
- return attenuated;
7977
+ }
7978
+
7979
+ // src/runtime/bento-render-tree.ts
7980
+ function mapContainerLayout(node) {
7981
+ const gap = typeof node.gap === "number" ? node.gap : void 0;
7982
+ if (node.layout === "grid") {
7983
+ return {
7984
+ mode: "grid",
7985
+ columns: node.columns ?? BENTO_GRID_COLUMNS,
7986
+ ...typeof node.rowHeight === "number" ? { rowHeight: node.rowHeight } : {},
7987
+ ...gap !== void 0 ? { gap } : {}
7988
+ };
7989
+ }
7990
+ if (node.layout === "split") {
7991
+ return {
7992
+ mode: "split",
7993
+ direction: node.direction === "vertical" ? "column" : "row",
7994
+ ...gap !== void 0 ? { gap } : {}
7995
+ };
7996
+ }
7997
+ if (node.layout === "tabs") {
7998
+ return {
7999
+ mode: "tabs",
8000
+ ...gap !== void 0 ? { gap } : {}
8001
+ };
8002
+ }
8003
+ return {
8004
+ mode: "flex",
8005
+ direction: node.direction === "horizontal" ? "row" : "column",
8006
+ ...gap !== void 0 ? { gap } : {}
8007
+ };
8008
+ }
8009
+ function buildPlacementStyle(node) {
8010
+ const style = {};
8011
+ const grid = node.placement?.grid;
8012
+ if (grid) {
8013
+ style.gridColumn = `${grid.x + 1} / span ${grid.w}`;
8014
+ style.gridRow = `${grid.y + 1} / span ${grid.h}`;
8015
+ }
8016
+ const split = node.placement?.split;
8017
+ if (split?.size !== void 0) {
8018
+ style.flex = typeof split.size === "number" ? `0 0 ${split.size}%` : `0 0 ${split.size}`;
8019
+ }
8020
+ if (split?.minSize !== void 0) {
8021
+ style.minWidth = typeof split.minSize === "number" ? `${split.minSize}px` : split.minSize;
8022
+ }
8023
+ if (split?.maxSize !== void 0) {
8024
+ style.maxWidth = typeof split.maxSize === "number" ? `${split.maxSize}px` : split.maxSize;
8025
+ }
8026
+ return Object.keys(style).length > 0 ? style : void 0;
8027
+ }
8028
+ function mapLeafDataBinding(node, data) {
8029
+ const source = node.block.dataSource;
8030
+ if (!source || source.kind === "static") return void 0;
8031
+ if (source.kind === "statement") {
8032
+ const inlineStatement = data?.statements?.[source.statementId];
8033
+ return inlineStatement ?? { kind: "statement", statementId: source.statementId };
8034
+ }
8035
+ return void 0;
8036
+ }
8037
+ function compileBentoNodeToRenderTree(root, options) {
8038
+ const product = options.product ?? "studio";
8039
+ const ownerRepo = options.ownerRepo ?? "monkeys-sdk";
8040
+ const pageId = options.pageId ?? options.treeId;
8041
+ const nodes = [];
8042
+ const visit = (node, parentNodeId, inheritedData) => {
8043
+ const effectiveData = node.kind === "container" && node.data ? node.data : inheritedData;
8044
+ const chrome = node.chrome ?? (node.kind === "leaf" ? "panel" : "none");
8045
+ const style = buildPlacementStyle(node);
8046
+ const common = {
8047
+ contract: "RenderNode",
8048
+ nodeId: node.id,
8049
+ version: 1,
8050
+ ownerRepo,
8051
+ ...parentNodeId ? { parentNodeId } : {},
8052
+ pageRef: { kind: "page", id: pageId },
8053
+ capabilityRef: {
8054
+ kind: "capability",
8055
+ id: node.kind === "leaf" ? `monkeys.bento.block.${node.block.customType ?? node.block.type}` : `monkeys.bento.container.${node.layout}`,
8056
+ version: 1,
8057
+ ownerRepo
8058
+ },
8059
+ surface: {
8060
+ frameOwner: chrome === "none" ? "none" : "host",
8061
+ density: "default",
8062
+ ...chrome !== "none" ? { bento: { chrome } } : {}
8063
+ },
8064
+ scroll: {
8065
+ owner: "surface",
8066
+ axis: "none",
8067
+ virtualizationBoundary: false
8068
+ },
8069
+ activation: {
8070
+ activationId: node.id,
8071
+ mode: "inline"
8072
+ },
8073
+ lifecycle: {
8074
+ mountPolicy: "always",
8075
+ queryPolicy: "always",
8076
+ retainOnDeactivate: true,
8077
+ deepLink: false,
8078
+ focusReturn: false
8079
+ },
8080
+ ...node.placement ? { placement: node.placement } : {},
8081
+ ...style ? { style } : {},
8082
+ responsive: [],
8083
+ state: "idle"
8084
+ };
8085
+ if (node.kind === "container") {
8086
+ nodes.push({
8087
+ ...common,
8088
+ kind: parentNodeId ? "view" : "page",
8089
+ children: node.children.map((child) => child.id),
8090
+ layout: mapContainerLayout(node),
8091
+ renderModel: {
8092
+ bentoKind: "container",
8093
+ layout: node.layout,
8094
+ ...node.direction ? { direction: node.direction } : {},
8095
+ ...node.title ? { title: node.title } : {},
8096
+ ...node.description ? { description: node.description } : {},
8097
+ ...node.wiring ? { wiring: node.wiring } : {}
8098
+ }
8099
+ });
8100
+ for (const child of node.children) {
8101
+ visit(child, node.id, effectiveData);
8102
+ }
8103
+ return;
8104
+ }
8105
+ const dataBinding = mapLeafDataBinding(node, effectiveData);
8106
+ const moduleId = node.block.customType ?? node.block.type;
8107
+ nodes.push({
8108
+ ...common,
8109
+ kind: "view",
8110
+ children: [],
8111
+ layout: { mode: "block" },
8112
+ ...dataBinding ? { dataBinding } : {},
8113
+ module: {
8114
+ id: moduleId,
8115
+ granularity: "atomic",
8116
+ ...node.block.title ? { title: node.block.title } : {},
8117
+ ...node.block.config ? { props: node.block.config } : {}
8118
+ },
8119
+ renderModel: {
8120
+ bentoKind: "leaf",
8121
+ blockType: node.block.type,
8122
+ ...node.block.customType ? { customType: node.block.customType } : {},
8123
+ ...node.block.title ? { title: node.block.title } : {},
8124
+ ...node.block.dataSource ? { dataSource: node.block.dataSource } : {},
8125
+ ...node.block.actionStatementIds ? { actionStatementIds: node.block.actionStatementIds } : {},
8126
+ ...node.block.config ? { config: node.block.config } : {}
8127
+ }
8128
+ });
8129
+ };
8130
+ visit(root, void 0, options.data);
8131
+ return RenderTreeSchema.parse({
8132
+ contract: "RenderTree",
8133
+ treeId: options.treeId,
8134
+ product,
8135
+ rootNodeId: root.id,
8136
+ ...options.data ? { data: options.data } : {},
8137
+ nodes
8138
+ });
8139
+ }
8140
+ function compileViewRecordToRenderTree(record2, options) {
8141
+ return compileBentoNodeToRenderTree(record2.root, {
8142
+ treeId: record2.viewId,
8143
+ pageId: record2.viewId,
8144
+ product: options?.product ?? "studio",
8145
+ ownerRepo: options?.ownerRepo ?? "monkeys-sdk",
8146
+ data: record2.data
8147
+ });
7965
8148
  }
7966
8149
 
7967
8150
  export {
@@ -7971,7 +8154,7 @@ export {
7971
8154
  createWorkflowCapabilityManifest,
7972
8155
  compileCapabilityRegistry,
7973
8156
  buildArtifactCollabRoomId,
7974
- compileViewSpecToRenderTree,
8157
+ compileBentoTreeToRenderTree,
7975
8158
  createArtifactRegistry,
7976
8159
  createAgentSessionEventProjection,
7977
8160
  projectAgentSessionEvents,
@@ -8110,10 +8293,11 @@ export {
8110
8293
  VIEW_LORO_KEYED_COLLECTIONS,
8111
8294
  computeCanonicalViewHash,
8112
8295
  buildDeterministicViewId,
8113
- createSingleBentoViewRecord,
8296
+ createSingleBlockViewRecord,
8114
8297
  createSelectionShareViewRecord,
8115
8298
  createWorkflowViewRecord,
8116
- resolveViewHostShell,
8117
- attenuateViewCapabilities
8299
+ attenuateViewCapabilities,
8300
+ compileBentoNodeToRenderTree,
8301
+ compileViewRecordToRenderTree
8118
8302
  };
8119
- //# sourceMappingURL=chunk-DPHV7ES3.mjs.map
8303
+ //# sourceMappingURL=chunk-BTJGKWPM.mjs.map