@elytracms/studio 0.0.92 → 0.0.93

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 (241) hide show
  1. package/convex/asset-alt-migration.test.ts +127 -0
  2. package/convex/asset-replace.test.ts +168 -0
  3. package/convex/asset-revalidate.test.ts +6 -6
  4. package/convex/assets.ts +41 -5
  5. package/convex/cms.ts +25 -11
  6. package/convex/contract-parity.test.ts +18 -3
  7. package/convex/document-revalidate.test.ts +10 -12
  8. package/convex/orphan-hydration.test.ts +116 -0
  9. package/convex/rail-write-parity.test.ts +11 -8
  10. package/convex/schema.ts +6 -0
  11. package/dist/components/ai/proposal-card.js +2 -1
  12. package/dist/components/ai/proposal-card.js.map +1 -1
  13. package/dist/components/ai/translate-document-dialog.js +4 -2
  14. package/dist/components/ai/translate-document-dialog.js.map +1 -1
  15. package/dist/components/ai/translate-skipped.d.ts +19 -0
  16. package/dist/components/ai/translate-skipped.js +46 -0
  17. package/dist/components/ai/translate-skipped.js.map +1 -0
  18. package/dist/components/assets/asset-detail.js +18 -8
  19. package/dist/components/assets/asset-detail.js.map +1 -1
  20. package/dist/components/assets/asset-metadata.d.ts +15 -4
  21. package/dist/components/assets/asset-metadata.js +15 -2
  22. package/dist/components/assets/asset-metadata.js.map +1 -1
  23. package/dist/components/assets/asset-search.js +4 -1
  24. package/dist/components/assets/asset-search.js.map +1 -1
  25. package/dist/components/assets/asset-selection.d.ts +0 -8
  26. package/dist/components/assets/asset-selection.js +4 -23
  27. package/dist/components/assets/asset-selection.js.map +1 -1
  28. package/dist/components/assets/asset-thumb.js +3 -2
  29. package/dist/components/assets/asset-thumb.js.map +1 -1
  30. package/dist/components/assets/assets-collection-view-source.d.ts +3 -3
  31. package/dist/components/assets/assets-collection-view-source.js +9 -5
  32. package/dist/components/assets/assets-collection-view-source.js.map +1 -1
  33. package/dist/components/assets/assets-store.d.ts +14 -0
  34. package/dist/components/assets/assets-store.js +23 -1
  35. package/dist/components/assets/assets-store.js.map +1 -1
  36. package/dist/components/assets/replace-file.d.ts +22 -0
  37. package/dist/components/assets/replace-file.js +59 -0
  38. package/dist/components/assets/replace-file.js.map +1 -0
  39. package/dist/components/builder/blocks-model.d.ts +14 -26
  40. package/dist/components/builder/blocks-model.js +35 -41
  41. package/dist/components/builder/blocks-model.js.map +1 -1
  42. package/dist/components/builder/blocks-panel.d.ts +7 -3
  43. package/dist/components/builder/blocks-panel.js +6 -5
  44. package/dist/components/builder/blocks-panel.js.map +1 -1
  45. package/dist/components/builder/builder-store.d.ts +104 -15
  46. package/dist/components/builder/builder-store.js +156 -31
  47. package/dist/components/builder/builder-store.js.map +1 -1
  48. package/dist/components/builder/canvas-body.d.ts +30 -0
  49. package/dist/components/builder/canvas-body.js +38 -0
  50. package/dist/components/builder/canvas-body.js.map +1 -0
  51. package/dist/components/builder/canvas-chrome-css.js +7 -0
  52. package/dist/components/builder/canvas-chrome-css.js.map +1 -1
  53. package/dist/components/builder/canvas-dnd.d.ts +7 -7
  54. package/dist/components/builder/canvas-dnd.js +5 -5
  55. package/dist/components/builder/canvas-dnd.js.map +1 -1
  56. package/dist/components/builder/canvas-render-context.d.ts +27 -19
  57. package/dist/components/builder/canvas-render-context.js +42 -43
  58. package/dist/components/builder/canvas-render-context.js.map +1 -1
  59. package/dist/components/builder/canvas-runs.d.ts +45 -0
  60. package/dist/components/builder/canvas-runs.js +51 -0
  61. package/dist/components/builder/canvas-runs.js.map +1 -0
  62. package/dist/components/builder/canvas.js +32 -5
  63. package/dist/components/builder/canvas.js.map +1 -1
  64. package/dist/components/builder/clipboard-actions.d.ts +15 -0
  65. package/dist/components/builder/clipboard-actions.js +44 -7
  66. package/dist/components/builder/clipboard-actions.js.map +1 -1
  67. package/dist/components/builder/composition-field-editor.d.ts +3 -15
  68. package/dist/components/builder/composition-field-editor.js +29 -40
  69. package/dist/components/builder/composition-field-editor.js.map +1 -1
  70. package/dist/components/builder/delete-key.d.ts +5 -0
  71. package/dist/components/builder/delete-key.js +4 -0
  72. package/dist/components/builder/delete-key.js.map +1 -1
  73. package/dist/components/builder/insert-context.d.ts +17 -25
  74. package/dist/components/builder/insert-context.js +45 -92
  75. package/dist/components/builder/insert-context.js.map +1 -1
  76. package/dist/components/builder/page-tree.d.ts +3 -3
  77. package/dist/components/builder/page-tree.js +3 -3
  78. package/dist/components/builder/page-tree.js.map +1 -1
  79. package/dist/components/builder/placement-refusal.d.ts +18 -0
  80. package/dist/components/builder/placement-refusal.js +46 -0
  81. package/dist/components/builder/placement-refusal.js.map +1 -0
  82. package/dist/components/builder/property-inspector.js +4 -0
  83. package/dist/components/builder/property-inspector.js.map +1 -1
  84. package/dist/components/builder/reuse-context.js +65 -27
  85. package/dist/components/builder/reuse-context.js.map +1 -1
  86. package/dist/components/builder/reuse.d.ts +79 -1
  87. package/dist/components/builder/reuse.js +69 -2
  88. package/dist/components/builder/reuse.js.map +1 -1
  89. package/dist/components/builder/run-inspector.d.ts +11 -0
  90. package/dist/components/builder/run-inspector.js +33 -0
  91. package/dist/components/builder/run-inspector.js.map +1 -0
  92. package/dist/components/cms/asset-field.d.ts +38 -1
  93. package/dist/components/cms/asset-field.js +182 -58
  94. package/dist/components/cms/asset-field.js.map +1 -1
  95. package/dist/components/cms/asset-picker-core.d.ts +16 -0
  96. package/dist/components/cms/asset-picker-core.js +20 -0
  97. package/dist/components/cms/asset-picker-core.js.map +1 -1
  98. package/dist/components/cms/asset-picker.js +12 -18
  99. package/dist/components/cms/asset-picker.js.map +1 -1
  100. package/dist/components/cms/bulk-actions.d.ts +3 -19
  101. package/dist/components/cms/bulk-actions.js +3 -24
  102. package/dist/components/cms/bulk-actions.js.map +1 -1
  103. package/dist/components/cms/cell.js.map +1 -1
  104. package/dist/components/cms/cms-store.d.ts +5 -4
  105. package/dist/components/cms/cms-store.js +16 -36
  106. package/dist/components/cms/cms-store.js.map +1 -1
  107. package/dist/components/cms/detail-editor.js +0 -1
  108. package/dist/components/cms/detail-editor.js.map +1 -1
  109. package/dist/components/cms/document-diff-view.d.ts +3 -1
  110. package/dist/components/cms/document-diff-view.js +12 -7
  111. package/dist/components/cms/document-diff-view.js.map +1 -1
  112. package/dist/components/cms/field-anchors.d.ts +7 -4
  113. package/dist/components/cms/field-anchors.js +9 -7
  114. package/dist/components/cms/field-anchors.js.map +1 -1
  115. package/dist/components/cms/field-control-lib.d.ts +15 -1
  116. package/dist/components/cms/field-control-lib.js +22 -3
  117. package/dist/components/cms/field-control-lib.js.map +1 -1
  118. package/dist/components/cms/gate-validation.d.ts +21 -30
  119. package/dist/components/cms/gate-validation.js +11 -32
  120. package/dist/components/cms/gate-validation.js.map +1 -1
  121. package/dist/components/cms/object-array-field.js +4 -4
  122. package/dist/components/cms/object-array-field.js.map +1 -1
  123. package/dist/components/cms/prop-fields.d.ts +7 -2
  124. package/dist/components/cms/prop-fields.js +13 -6
  125. package/dist/components/cms/prop-fields.js.map +1 -1
  126. package/dist/components/cms/rich-text/embed-picker.d.ts +1 -1
  127. package/dist/components/cms/rich-text/embed-picker.js.map +1 -1
  128. package/dist/components/cms/rich-text/insert.d.ts +20 -9
  129. package/dist/components/cms/rich-text/insert.js +25 -17
  130. package/dist/components/cms/rich-text/insert.js.map +1 -1
  131. package/dist/components/cms/use-publish-controller.d.ts +1 -2
  132. package/dist/components/cms/use-publish-controller.js +7 -19
  133. package/dist/components/cms/use-publish-controller.js.map +1 -1
  134. package/dist/components/cms/versions-pane.js +8 -1
  135. package/dist/components/cms/versions-pane.js.map +1 -1
  136. package/dist/components/collection-view/cms-collection-view-source.js +3 -1
  137. package/dist/components/collection-view/cms-collection-view-source.js.map +1 -1
  138. package/dist/components/components/transfer-dialog.js +2 -1
  139. package/dist/components/components/transfer-dialog.js.map +1 -1
  140. package/dist/components/components/transfer.d.ts +10 -10
  141. package/dist/components/components/transfer.js +13 -12
  142. package/dist/components/components/transfer.js.map +1 -1
  143. package/dist/lib/ai/apply-content.js +56 -116
  144. package/dist/lib/ai/apply-content.js.map +1 -1
  145. package/dist/lib/ai/chat-context.d.ts +8 -0
  146. package/dist/lib/ai/chat-context.js +37 -6
  147. package/dist/lib/ai/chat-context.js.map +1 -1
  148. package/dist/lib/ai/chat-state.d.ts +6 -0
  149. package/dist/lib/ai/chat-state.js.map +1 -1
  150. package/dist/lib/ai/constraints.d.ts +20 -5
  151. package/dist/lib/ai/constraints.js +125 -33
  152. package/dist/lib/ai/constraints.js.map +1 -1
  153. package/dist/lib/ai/fake-provider.d.ts +16 -3
  154. package/dist/lib/ai/fake-provider.js +22 -6
  155. package/dist/lib/ai/fake-provider.js.map +1 -1
  156. package/dist/lib/ai/index.d.ts +2 -0
  157. package/dist/lib/ai/index.js +2 -0
  158. package/dist/lib/ai/index.js.map +1 -1
  159. package/dist/lib/ai/leash.d.ts +34 -0
  160. package/dist/lib/ai/leash.js +28 -0
  161. package/dist/lib/ai/leash.js.map +1 -0
  162. package/dist/lib/ai/rich-text-input.d.ts +8 -8
  163. package/dist/lib/ai/rich-text-input.js +2 -1
  164. package/dist/lib/ai/rich-text-input.js.map +1 -1
  165. package/dist/lib/ai/rich-text-translate.d.ts +27 -4
  166. package/dist/lib/ai/rich-text-translate.js +28 -10
  167. package/dist/lib/ai/rich-text-translate.js.map +1 -1
  168. package/dist/lib/ai/shape.d.ts +13 -13
  169. package/dist/lib/ai/shape.js +69 -93
  170. package/dist/lib/ai/shape.js.map +1 -1
  171. package/dist/lib/ai/tools.d.ts +36 -41
  172. package/dist/lib/ai/tools.js +83 -87
  173. package/dist/lib/ai/tools.js.map +1 -1
  174. package/dist/lib/ai/translate-document.d.ts +32 -4
  175. package/dist/lib/ai/translate-document.js +144 -46
  176. package/dist/lib/ai/translate-document.js.map +1 -1
  177. package/dist/lib/ai/types.d.ts +34 -23
  178. package/dist/lib/ai/types.js.map +1 -1
  179. package/dist/lib/ai/update-fields.d.ts +15 -12
  180. package/dist/lib/ai/update-fields.js +112 -188
  181. package/dist/lib/ai/update-fields.js.map +1 -1
  182. package/dist/lib/ai/writer-form.d.ts +116 -0
  183. package/dist/lib/ai/writer-form.js +429 -0
  184. package/dist/lib/ai/writer-form.js.map +1 -0
  185. package/dist/lib/assets/upload.d.ts +31 -2
  186. package/dist/lib/assets/upload.js +61 -6
  187. package/dist/lib/assets/upload.js.map +1 -1
  188. package/dist/lib/clipboard/os-clipboard.d.ts +10 -2
  189. package/dist/lib/clipboard/os-clipboard.js +8 -4
  190. package/dist/lib/clipboard/os-clipboard.js.map +1 -1
  191. package/dist/lib/clipboard/paste-target.d.ts +18 -9
  192. package/dist/lib/clipboard/paste-target.js +8 -7
  193. package/dist/lib/clipboard/paste-target.js.map +1 -1
  194. package/dist/lib/cms/field-patch.d.ts +0 -10
  195. package/dist/lib/cms/field-patch.js +4 -30
  196. package/dist/lib/cms/field-patch.js.map +1 -1
  197. package/dist/lib/cms-views/view-model.d.ts +3 -3
  198. package/dist/lib/collection-view/collection-view-source.d.ts +7 -3
  199. package/dist/lib/collection-view/collection-view-source.js.map +1 -1
  200. package/dist/lib/data/collection-content.js +3 -2
  201. package/dist/lib/data/collection-content.js.map +1 -1
  202. package/dist/lib/dnd/drop-rules.d.ts +25 -31
  203. package/dist/lib/dnd/drop-rules.js +53 -59
  204. package/dist/lib/dnd/drop-rules.js.map +1 -1
  205. package/dist/lib/engine-version.d.ts +1 -1
  206. package/dist/lib/engine-version.js +1 -1
  207. package/dist/lib/engine-version.js.map +1 -1
  208. package/dist/lib/i18n/messages.de.js +40 -3
  209. package/dist/lib/i18n/messages.de.js.map +1 -1
  210. package/dist/lib/i18n/messages.en.d.ts +34 -2
  211. package/dist/lib/i18n/messages.en.js +43 -3
  212. package/dist/lib/i18n/messages.en.js.map +1 -1
  213. package/dist/lib/operations/project-runtime-config.d.ts +25 -6
  214. package/dist/lib/operations/project-runtime-config.js +37 -10
  215. package/dist/lib/operations/project-runtime-config.js.map +1 -1
  216. package/dist/lib/operations/publish-with-revision.d.ts +33 -1
  217. package/dist/lib/operations/publish-with-revision.js +32 -0
  218. package/dist/lib/operations/publish-with-revision.js.map +1 -1
  219. package/dist/lib/operations/runtime-validator.d.ts +19 -68
  220. package/dist/lib/operations/runtime-validator.js +12 -138
  221. package/dist/lib/operations/runtime-validator.js.map +1 -1
  222. package/dist/lib/operations/studio-operations.d.ts +9 -2
  223. package/dist/lib/operations/studio-operations.js +13 -11
  224. package/dist/lib/operations/studio-operations.js.map +1 -1
  225. package/dist/lib/persistence/convex-adapter.js +6 -1
  226. package/dist/lib/persistence/convex-adapter.js.map +1 -1
  227. package/dist/lib/persona/labels.js +3 -1
  228. package/dist/lib/persona/labels.js.map +1 -1
  229. package/dist/lib/workspace/index.d.ts +8 -11
  230. package/dist/lib/workspace/index.js +12 -24
  231. package/dist/lib/workspace/index.js.map +1 -1
  232. package/package.json +3 -3
  233. package/dist/components/cms/cms-composition-validators.d.ts +0 -16
  234. package/dist/components/cms/cms-composition-validators.js +0 -133
  235. package/dist/components/cms/cms-composition-validators.js.map +0 -1
  236. package/dist/components/cms/publish-clean.d.ts +0 -28
  237. package/dist/components/cms/publish-clean.js +0 -38
  238. package/dist/components/cms/publish-clean.js.map +0 -1
  239. package/dist/lib/assets/asset-placements.d.ts +0 -28
  240. package/dist/lib/assets/asset-placements.js +0 -83
  241. package/dist/lib/assets/asset-placements.js.map +0 -1
@@ -2,24 +2,28 @@
2
2
  * Target-shape derivation for `applyContentWithShape` (EC-331).
3
3
  *
4
4
  * Reuses the existing collection→JSON-Schema derivation (`collectionJsonSchema`,
5
- * cms-core) rather than writing a new one, then applies the three leashes the AI
6
- * engine adds on top:
5
+ * cms-core) rather than writing a new one, then applies the leashes the AI engine
6
+ * adds on top:
7
7
  *
8
8
  * - `ai.exclude` fields are removed entirely (the model never sees them → cannot
9
9
  * write them).
10
- * - relation fields become an ENUM over the provided candidate ids (or are omitted
11
- * when no candidates exist) — so a hallucinated relation id is not representable
12
- * as valid structured output.
13
- * - asset/image fields become an ENUM over the searched library asset ids (or are
14
- * omitted when none were searched) — EC-381, the SAME leash as relations: a
15
- * proposed asset id must be a real, `listAssets`-returned library asset, and a
16
- * create shape with no searched assets simply has no asset property (empty beats
17
- * wrong; the assistant never generates or uploads).
10
+ * - relation ids become an ENUM over the searched candidates of the relation's
11
+ * target (or the position is omitted when none were searched) — so a hallucinated
12
+ * relation id is not representable as valid structured output.
13
+ * - asset ids become an ENUM over the searched library assets that fit the
14
+ * position's `accept` (or the position is omitted when none fit) — EC-381, the SAME
15
+ * leash as relations: a proposed asset id must be a real, `listAssets`-returned
16
+ * library asset (empty beats wrong; the assistant never generates or uploads).
17
+ * EC-593: both leashes hold at EVERY depth — a relation in an object, an asset in a
18
+ * repeater item — not only on a top-level field (`writerFieldSchema(field, leash)`).
18
19
  * - rich-text fields are MARKDOWN STRINGS (EC-379): the description names the
19
- * allowed subset, and the engine converts md → the `{ version, doc }` storage
20
- * envelope at proposal-build time. The field's `allow` config leashes component
21
- * EMBEDS only — markdown cannot express an embed, so the leash is satisfied by
22
- * construction (and still enforced downstream by `validateRichTextEmbeds`).
20
+ * allowed subset, and the engine converts md → the `{ version: 2, content }` storage
21
+ * value at proposal-build time (`writer-form.ts`). The field's `allow` config leashes
22
+ * component EMBEDS only — markdown cannot express an embed, so the leash is
23
+ * satisfied by construction (and still enforced downstream by `validateRichTextEmbeds`).
24
+ * - a composition (`blocks`) has NO writer form (ratified 4c, EC-593): it is omitted,
25
+ * and the schema's own description says so — the omission is visible, never a field
26
+ * the model simply never hears of.
23
27
  *
24
28
  * Localized fields stay flat in the shape (the model authors one locale at a time);
25
29
  * the engine routes their values under `localized[locale]`.
@@ -46,12 +50,12 @@
46
50
  * EC-556 — the projection is VALIDATOR-facing (the value at rest: asset/relation
47
51
  * envelopes, the v2 rich-text object). Every property here is its WRITER form
48
52
  * (`writerFieldSchema`), derived from that projection at every depth — a bare asset
49
- * id, a `{ collection, id }` reference, a markdown string — so an asset, relation or
50
- * rich-text SUBFIELD of an `object` is told the same form as a top-level one. The
51
- * top-level relation/asset id enums (EC-381) override the writer form there.
53
+ * id, a relation id, a markdown string — so an asset, relation or rich-text SUBFIELD of
54
+ * an `object` is told the same form as a top-level one.
52
55
  */
53
56
  import { collectionJsonSchema, resolveLabel } from '@elytracms/core/cms-core';
54
57
  import { constraintSentence, toModelFacingSchema, writerFieldSchema } from './constraints.js';
58
+ import { NO_SEARCHED_IDS } from './leash.js';
55
59
  /**
56
60
  * A field's model-facing description: resolved label + optional `ai.hint` + the
57
61
  * constraint clause (EC-473). The constraints are stated in PROSE because that is
@@ -66,17 +70,19 @@ function describe(field, locale) {
66
70
  return parts.length > 0 ? parts.join(' — ') : undefined;
67
71
  }
68
72
  /**
69
- * Build the leash-aware target shape from a collection + candidates. Deterministic;
70
- * never throws. Reuses `collectionJsonSchema` as the base (its `required` list), then
71
- * gives every property its writer form (EC-556) or its id-enum leash, and strips
72
- * excluded fields.
73
+ * Build the leash-aware target shape from a collection + what the model searched.
74
+ * Deterministic; never throws. Reuses `collectionJsonSchema` as the base (its
75
+ * `required` list), then gives every property its writer form (EC-556) — id enums at
76
+ * every depth (EC-593) — and strips excluded fields and compositions.
73
77
  */
74
78
  export function buildTargetShape(input) {
79
+ const leash = input.leash ?? NO_SEARCHED_IDS;
75
80
  const base = collectionJsonSchema(input.collection);
76
81
  const properties = {
77
82
  ...(base.properties ?? {}),
78
83
  };
79
84
  const excluded = [];
85
+ const compositions = [];
80
86
  const localizedFields = [];
81
87
  const relationFields = [];
82
88
  const assetFields = [];
@@ -88,82 +94,46 @@ export function buildTargetShape(input) {
88
94
  delete properties[field.name];
89
95
  continue;
90
96
  }
97
+ // EC-556: the writer form at every depth (rich text → markdown, EC-379 / D2;
98
+ // nested asset / relation → the bare forms the write-time lens wraps); EC-593:
99
+ // every id an enum over what was searched for that position.
100
+ const written = writerFieldSchema(field, leash);
101
+ if (written === undefined) {
102
+ // No writer form: a composition (4c), or a relation / asset with nothing
103
+ // searched for it — the model cannot emit a value, so a hallucinated id is
104
+ // structurally impossible (empty beats wrong).
105
+ if (field.type === 'blocks')
106
+ compositions.push(field.name);
107
+ delete properties[field.name];
108
+ continue;
109
+ }
91
110
  if (field.type === 'relation') {
92
- const candidates = input.candidates?.[field.name] ?? [];
93
- if (candidates.length === 0) {
94
- // No candidate ids ⇒ omit the field: the model cannot emit a relation value
95
- // at all, so a hallucinated id is structurally impossible.
96
- delete properties[field.name];
97
- continue;
98
- }
99
- const ids = candidates.map((c) => c.id);
100
- const label = candidates
101
- .map((c) => (c.label ? `${c.id} (${c.label})` : c.id))
102
- .join(', ');
103
- const idSchema = {
104
- type: 'string',
105
- enum: ids,
106
- description: `Choose one of: ${label}`,
107
- };
108
- properties[field.name] = field.multiple ? { type: 'array', items: idSchema } : idSchema;
109
- relationFields.push({
110
- fieldName: field.name,
111
- target: field.target,
112
- multiple: field.multiple,
113
- candidateIds: ids,
114
- });
111
+ const candidateIds = leash.relationCandidates(field.target).map((c) => c.id);
112
+ relationFields.push({ fieldName: field.name, target: field.target, multiple: field.multiple, candidateIds });
115
113
  }
116
114
  else if (field.type === 'asset') {
117
- // EC-381 — same leash as relations: an asset field is an enum over the ids
118
- // the model actually searched in the media library (`listAssets`). No
119
- // searched assets ⇒ omit the field, so the proposal simply leaves it empty
120
- // (an invented / to-be-uploaded id is structurally unrepresentable).
121
- const candidates = input.assetCandidates?.[field.name] ?? [];
122
- if (candidates.length === 0) {
123
- delete properties[field.name];
124
- continue;
125
- }
126
- const ids = candidates.map((c) => c.id);
127
- const label = candidates
128
- .map((c) => (c.label ? `${c.id} (${c.label})` : c.id))
129
- .join(', ');
130
- const idSchema = {
131
- type: 'string',
132
- enum: ids,
133
- description: `Choose an EXISTING library asset id, one of: ${label}. Leave empty if none fits.`,
134
- };
135
- properties[field.name] = field.multiple ? { type: 'array', items: idSchema } : idSchema;
136
- assetFields.push({ fieldName: field.name, multiple: field.multiple, candidateIds: ids });
137
- }
138
- else {
139
- // EC-556: the writer form at every depth (rich text → markdown, EC-379 / D2;
140
- // nested asset / relation → the bare forms the write-time lens wraps).
141
- properties[field.name] = writerFieldSchema(field);
115
+ const candidateIds = leash.assetCandidates(field).map((c) => c.id);
116
+ assetFields.push({ fieldName: field.name, multiple: field.multiple, candidateIds });
142
117
  }
143
- const prop = properties[field.name];
144
- if (prop) {
145
- // EC-473: a `pattern` next to a `format` is 200+ characters that teach the
146
- // model nothing — the format (and the prose constraints below) say it better.
147
- // EC-505: and a `date`'s `['string','number']` union becomes the ISO string
148
- // the model is actually asked to author.
149
- const stripped = toModelFacingSchema(prop);
150
- const desc = describe(field, input.locale);
151
- // Preserve an existing description (e.g. relation enum / rich-text note), but
152
- // append the constraint clause to it — the enum leash and the value rules are
153
- // different facts and the model needs both.
154
- const next = stripped === prop ? prop : { ...stripped };
155
- if (desc !== undefined) {
156
- const existing = typeof next.description === 'string' ? next.description : undefined;
157
- const constraints = constraintSentence(field);
158
- next.description =
159
- existing === undefined
160
- ? desc
161
- : constraints !== undefined
162
- ? `${existing} — ${constraints}`
163
- : existing;
164
- }
165
- properties[field.name] = next;
118
+ // EC-473: a `pattern` next to a `format` is 200+ characters that teach the
119
+ // model nothing — the format (and the prose constraints below) say it better.
120
+ const stripped = toModelFacingSchema(written);
121
+ const desc = describe(field, input.locale);
122
+ // Preserve an existing description (e.g. relation enum / rich-text note), but
123
+ // append the constraint clause to it — the enum leash and the value rules are
124
+ // different facts and the model needs both.
125
+ const next = stripped === written ? { ...written } : { ...stripped };
126
+ if (desc !== undefined) {
127
+ const existing = typeof next.description === 'string' ? next.description : undefined;
128
+ const constraints = constraintSentence(field);
129
+ next.description =
130
+ existing === undefined
131
+ ? desc
132
+ : constraints !== undefined
133
+ ? `${existing} — ${constraints}`
134
+ : existing;
166
135
  }
136
+ properties[field.name] = next;
167
137
  }
168
138
  const requiredIn = Array.isArray(base.required) ? base.required : [];
169
139
  const required = requiredIn.filter((n) => !excluded.includes(n) && properties[n] !== undefined);
@@ -172,7 +142,13 @@ export function buildTargetShape(input) {
172
142
  properties,
173
143
  additionalProperties: false,
174
144
  ...(required.length > 0 ? { required } : {}),
145
+ // 4c (EC-593): the omission is said, not silent.
146
+ ...(compositions.length > 0
147
+ ? {
148
+ description: `Not part of this object: ${compositions.join(', ')} — page-builder composition${compositions.length > 1 ? 's' : ''} whose components are added, moved and removed on the canvas, never by the assistant.`,
149
+ }
150
+ : {}),
175
151
  };
176
- return { schema, excluded, localizedFields, relationFields, assetFields };
152
+ return { schema, excluded, compositions, localizedFields, relationFields, assetFields };
177
153
  }
178
154
  //# sourceMappingURL=shape.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shape.js","sourceRoot":"","sources":["../../../src/lib/ai/shape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE7E,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AA6C1F;;;;;GAKG;AACH,SAAS,QAAQ,CAAC,KAAe,EAAE,MAAe;IAChD,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAA;IACnE,MAAM,IAAI,GAAG,KAAK,CAAC,EAAE,EAAE,IAAI,CAAA;IAC3B,MAAM,WAAW,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAA;IAC7C,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,MAAM,CAC7C,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAC1D,CAAA;IACD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACzD,CAAC;AAED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KAAK,SAAS,EAAE,CAAC;gBACvB,MAAM,QAAQ,GAAG,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAA;gBACpF,MAAM,WAAW,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAA;gBAC7C,IAAI,CAAC,WAAW;oBACd,QAAQ,KAAK,SAAS;wBACpB,CAAC,CAAC,IAAI;wBACN,CAAC,CAAC,WAAW,KAAK,SAAS;4BACzB,CAAC,CAAC,GAAG,QAAQ,MAAM,WAAW,EAAE;4BAChC,CAAC,CAAC,QAAQ,CAAA;YAClB,CAAC;YACD,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;QAC/B,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAE,IAAI,CAAC,QAAqB,CAAC,CAAC,CAAC,EAAE,CAAA;IAClF,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAA;IAE/F,MAAM,MAAM,GAAe;QACzB,IAAI,EAAE,QAAQ;QACd,UAAU;QACV,oBAAoB,EAAE,KAAK;QAC3B,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7C,CAAA;IACD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,CAAA;AAC3E,CAAC","sourcesContent":["/**\n * Target-shape derivation for `applyContentWithShape` (EC-331).\n *\n * Reuses the existing collection→JSON-Schema derivation (`collectionJsonSchema`,\n * cms-core) rather than writing a new one, then applies the three leashes the AI\n * engine adds on top:\n *\n * - `ai.exclude` fields are removed entirely (the model never sees them → cannot\n * write them).\n * - relation fields become an ENUM over the provided candidate ids (or are omitted\n * when no candidates exist) — so a hallucinated relation id is not representable\n * as valid structured output.\n * - asset/image fields become an ENUM over the searched library asset ids (or are\n * omitted when none were searched) — EC-381, the SAME leash as relations: a\n * proposed asset id must be a real, `listAssets`-returned library asset, and a\n * create shape with no searched assets simply has no asset property (empty beats\n * wrong; the assistant never generates or uploads).\n * - rich-text fields are MARKDOWN STRINGS (EC-379): the description names the\n * allowed subset, and the engine converts md → the `{ version, doc }` storage\n * envelope at proposal-build time. The field's `allow` config leashes component\n * EMBEDS only — markdown cannot express an embed, so the leash is satisfied by\n * construction (and still enforced downstream by `validateRichTextEmbeds`).\n *\n * Localized fields stay flat in the shape (the model authors one locale at a time);\n * the engine routes their values under `localized[locale]`.\n *\n * EC-473 — the shape now consumes the ONE constraint projection, so a rule declared\n * in config actually reaches the model:\n *\n * - `collectionJsonSchema` merges declarative rules with the fragment derived from\n * a schema-form `validation.validate`, so `{ min: 2 }` and `z.string().min(2)`\n * arrive identically (and a declared DATE RANGE arrives at all — it previously\n * reached no consumer whatsoever);\n * - a rich-text field no longer OVERWRITES its constraints: the markdown schema is\n * merged over them instead of replacing them (measured drift, EC-474 §2);\n * - a `pattern` is dropped wherever a `format` explains the same thing (a\n * 200-character email regex teaches a model nothing and costs real tokens);\n * - a field whose projection is knowingly partial (`schemaComplete: false`) SAYS SO\n * in its description rather than presenting the partial rule as the whole rule.\n *\n * EC-505 — one further narrowing of what the model is TOLD (never of what the engine\n * accepts): a `date` property is `type: 'string'` + `format: 'date-time'` rather than\n * the `['string','number']` union the general projection carries, because the model is\n * asked to author an ISO instant (EC-472) and some providers reject a union `type`.\n *\n * EC-556 — the projection is VALIDATOR-facing (the value at rest: asset/relation\n * envelopes, the v2 rich-text object). Every property here is its WRITER form\n * (`writerFieldSchema`), derived from that projection at every depth — a bare asset\n * id, a `{ collection, id }` reference, a markdown string — so an asset, relation or\n * rich-text SUBFIELD of an `object` is told the same form as a top-level one. The\n * top-level relation/asset id enums (EC-381) override the writer form there.\n */\nimport { collectionJsonSchema, resolveLabel } from '@elytracms/core/cms-core'\nimport type { CollectionDef, FieldDef, JsonSchema } from '@elytracms/core/cms-core'\nimport { constraintSentence, toModelFacingSchema, writerFieldSchema } from './constraints'\nimport type { AssetCandidates, RelationCandidates } from './types'\n\n/** A relation field's resolved candidate set — how the engine maps ids → reference envelopes. */\nexport interface TargetRelationField {\n fieldName: string\n /** The relation's target collection id. */\n target: string\n multiple: boolean\n /** The allowed candidate ids (the enum the model chose from). */\n candidateIds: string[]\n}\n\n/** An asset field's resolved candidate set — how the engine maps ids → asset envelopes (EC-381). */\nexport interface TargetAssetField {\n fieldName: string\n multiple: boolean\n /** The allowed library asset ids (the enum the model chose from). */\n candidateIds: string[]\n}\n\n/** The derived target shape + the metadata the engine needs to post-process the output. */\nexport interface TargetShape {\n /** The JSON Schema the structured output must satisfy. */\n schema: JsonSchema\n /** Field names removed by `ai.exclude` (untouchable). */\n excluded: string[]\n /** Field names whose values route under `localized[locale]`. */\n localizedFields: string[]\n /** Relation fields with their candidate enums. */\n relationFields: TargetRelationField[]\n /** Asset fields with their candidate enums (EC-381). */\n assetFields: TargetAssetField[]\n}\n\nexport interface BuildTargetShapeInput {\n collection: CollectionDef\n /** Relation candidate ids by field — a relation field with none is omitted from the shape. */\n candidates?: RelationCandidates\n /** Asset candidate ids by field — an asset field with none is omitted from the shape (EC-381). */\n assetCandidates?: AssetCandidates\n /** UI locale for resolving field labels into descriptions. */\n locale?: string\n}\n\n/**\n * A field's model-facing description: resolved label + optional `ai.hint` + the\n * constraint clause (EC-473). The constraints are stated in PROSE because that is\n * what a model acts on — the same facts also ride as JSON-Schema keywords for the\n * structured-output validator, which is a different reader.\n */\nfunction describe(field: FieldDef, locale?: string): string | undefined {\n const label = resolveLabel(field.form?.label, locale) ?? field.name\n const hint = field.ai?.hint\n const constraints = constraintSentence(field)\n const parts = [label, hint, constraints].filter(\n (p): p is string => typeof p === 'string' && p.length > 0,\n )\n return parts.length > 0 ? parts.join(' — ') : undefined\n}\n\n/**\n * Build the leash-aware target shape from a collection + candidates. Deterministic;\n * never throws. Reuses `collectionJsonSchema` as the base (its `required` list), then\n * gives every property its writer form (EC-556) or its id-enum leash, and strips\n * excluded fields.\n */\nexport function buildTargetShape(input: BuildTargetShapeInput): TargetShape {\n const base = collectionJsonSchema(input.collection)\n const properties: Record<string, JsonSchema> = {\n ...((base.properties as Record<string, JsonSchema>) ?? {}),\n }\n const excluded: string[] = []\n const localizedFields: string[] = []\n const relationFields: TargetRelationField[] = []\n const assetFields: TargetAssetField[] = []\n\n for (const field of input.collection.fields) {\n if (field.localized) localizedFields.push(field.name)\n\n if (field.ai?.exclude) {\n excluded.push(field.name)\n delete properties[field.name]\n continue\n }\n\n if (field.type === 'relation') {\n const candidates = input.candidates?.[field.name] ?? []\n if (candidates.length === 0) {\n // No candidate ids ⇒ omit the field: the model cannot emit a relation value\n // at all, so a hallucinated id is structurally impossible.\n delete properties[field.name]\n continue\n }\n const ids = candidates.map((c) => c.id)\n const label = candidates\n .map((c) => (c.label ? `${c.id} (${c.label})` : c.id))\n .join(', ')\n const idSchema: JsonSchema = {\n type: 'string',\n enum: ids,\n description: `Choose one of: ${label}`,\n }\n properties[field.name] = field.multiple ? { type: 'array', items: idSchema } : idSchema\n relationFields.push({\n fieldName: field.name,\n target: field.target,\n multiple: field.multiple,\n candidateIds: ids,\n })\n } else if (field.type === 'asset') {\n // EC-381 — same leash as relations: an asset field is an enum over the ids\n // the model actually searched in the media library (`listAssets`). No\n // searched assets ⇒ omit the field, so the proposal simply leaves it empty\n // (an invented / to-be-uploaded id is structurally unrepresentable).\n const candidates = input.assetCandidates?.[field.name] ?? []\n if (candidates.length === 0) {\n delete properties[field.name]\n continue\n }\n const ids = candidates.map((c) => c.id)\n const label = candidates\n .map((c) => (c.label ? `${c.id} (${c.label})` : c.id))\n .join(', ')\n const idSchema: JsonSchema = {\n type: 'string',\n enum: ids,\n description: `Choose an EXISTING library asset id, one of: ${label}. Leave empty if none fits.`,\n }\n properties[field.name] = field.multiple ? { type: 'array', items: idSchema } : idSchema\n assetFields.push({ fieldName: field.name, multiple: field.multiple, candidateIds: ids })\n } else {\n // EC-556: the writer form at every depth (rich text → markdown, EC-379 / D2;\n // nested asset / relation → the bare forms the write-time lens wraps).\n properties[field.name] = writerFieldSchema(field)\n }\n\n const prop = properties[field.name]\n if (prop) {\n // EC-473: a `pattern` next to a `format` is 200+ characters that teach the\n // model nothing — the format (and the prose constraints below) say it better.\n // EC-505: and a `date`'s `['string','number']` union becomes the ISO string\n // the model is actually asked to author.\n const stripped = toModelFacingSchema(prop)\n const desc = describe(field, input.locale)\n // Preserve an existing description (e.g. relation enum / rich-text note), but\n // append the constraint clause to it — the enum leash and the value rules are\n // different facts and the model needs both.\n const next: JsonSchema = stripped === prop ? prop : { ...stripped }\n if (desc !== undefined) {\n const existing = typeof next.description === 'string' ? next.description : undefined\n const constraints = constraintSentence(field)\n next.description =\n existing === undefined\n ? desc\n : constraints !== undefined\n ? `${existing} — ${constraints}`\n : existing\n }\n properties[field.name] = next\n }\n }\n\n const requiredIn = Array.isArray(base.required) ? (base.required as string[]) : []\n const required = requiredIn.filter((n) => !excluded.includes(n) && properties[n] !== undefined)\n\n const schema: JsonSchema = {\n type: 'object',\n properties,\n additionalProperties: false,\n ...(required.length > 0 ? { required } : {}),\n }\n return { schema, excluded, localizedFields, relationFields, assetFields }\n}\n"]}
1
+ {"version":3,"file":"shape.js","sourceRoot":"","sources":["../../../src/lib/ai/shape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE7E,OAAO,EAAE,kBAAkB,EAAE,mB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MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAA;IAE/F,MAAM,MAAM,GAAe;QACzB,IAAI,EAAE,QAAQ;QACd,UAAU;QACV,oBAAoB,EAAE,KAAK;QAC3B,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5C,iDAAiD;QACjD,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;YACzB,CAAC,CAAC;gBACE,WAAW,EAAE,4BAA4B,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,8BAA8B,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,uFAAuF;aACxN;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAA;IACD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,CAAA;AACzF,CAAC","sourcesContent":["/**\n * Target-shape derivation for `applyContentWithShape` (EC-331).\n *\n * Reuses the existing collection→JSON-Schema derivation (`collectionJsonSchema`,\n * cms-core) rather than writing a new one, then applies the leashes the AI engine\n * adds on top:\n *\n * - `ai.exclude` fields are removed entirely (the model never sees them → cannot\n * write them).\n * - relation ids become an ENUM over the searched candidates of the relation's\n * target (or the position is omitted when none were searched) — so a hallucinated\n * relation id is not representable as valid structured output.\n * - asset ids become an ENUM over the searched library assets that fit the\n * position's `accept` (or the position is omitted when none fit) — EC-381, the SAME\n * leash as relations: a proposed asset id must be a real, `listAssets`-returned\n * library asset (empty beats wrong; the assistant never generates or uploads).\n * EC-593: both leashes hold at EVERY depth — a relation in an object, an asset in a\n * repeater item — not only on a top-level field (`writerFieldSchema(field, leash)`).\n * - rich-text fields are MARKDOWN STRINGS (EC-379): the description names the\n * allowed subset, and the engine converts md → the `{ version: 2, content }` storage\n * value at proposal-build time (`writer-form.ts`). The field's `allow` config leashes\n * component EMBEDS only — markdown cannot express an embed, so the leash is\n * satisfied by construction (and still enforced downstream by `validateRichTextEmbeds`).\n * - a composition (`blocks`) has NO writer form (ratified 4c, EC-593): it is omitted,\n * and the schema's own description says so — the omission is visible, never a field\n * the model simply never hears of.\n *\n * Localized fields stay flat in the shape (the model authors one locale at a time);\n * the engine routes their values under `localized[locale]`.\n *\n * EC-473 — the shape now consumes the ONE constraint projection, so a rule declared\n * in config actually reaches the model:\n *\n * - `collectionJsonSchema` merges declarative rules with the fragment derived from\n * a schema-form `validation.validate`, so `{ min: 2 }` and `z.string().min(2)`\n * arrive identically (and a declared DATE RANGE arrives at all — it previously\n * reached no consumer whatsoever);\n * - a rich-text field no longer OVERWRITES its constraints: the markdown schema is\n * merged over them instead of replacing them (measured drift, EC-474 §2);\n * - a `pattern` is dropped wherever a `format` explains the same thing (a\n * 200-character email regex teaches a model nothing and costs real tokens);\n * - a field whose projection is knowingly partial (`schemaComplete: false`) SAYS SO\n * in its description rather than presenting the partial rule as the whole rule.\n *\n * EC-505 — one further narrowing of what the model is TOLD (never of what the engine\n * accepts): a `date` property is `type: 'string'` + `format: 'date-time'` rather than\n * the `['string','number']` union the general projection carries, because the model is\n * asked to author an ISO instant (EC-472) and some providers reject a union `type`.\n *\n * EC-556 — the projection is VALIDATOR-facing (the value at rest: asset/relation\n * envelopes, the v2 rich-text object). Every property here is its WRITER form\n * (`writerFieldSchema`), derived from that projection at every depth — a bare asset\n * id, a relation id, a markdown string — so an asset, relation or rich-text SUBFIELD of\n * an `object` is told the same form as a top-level one.\n */\nimport { collectionJsonSchema, resolveLabel } from '@elytracms/core/cms-core'\nimport type { CollectionDef, FieldDef, JsonSchema } from '@elytracms/core/cms-core'\nimport { constraintSentence, toModelFacingSchema, writerFieldSchema } from './constraints'\nimport { NO_SEARCHED_IDS } from './leash'\nimport type { WriterLeash } from './types'\n\n/** A top-level relation field's resolved candidate set (the enum the model chose from). */\nexport interface TargetRelationField {\n fieldName: string\n /** The relation's target collection id. */\n target: string\n multiple: boolean\n /** The allowed candidate ids (the enum the model chose from). */\n candidateIds: string[]\n}\n\n/** A top-level asset field's resolved candidate set (EC-381). */\nexport interface TargetAssetField {\n fieldName: string\n multiple: boolean\n /** The allowed library asset ids (the enum the model chose from). */\n candidateIds: string[]\n}\n\n/** The derived target shape + the metadata the engine needs to post-process the output. */\nexport interface TargetShape {\n /** The JSON Schema the structured output must satisfy. */\n schema: JsonSchema\n /** Field names removed by `ai.exclude` (untouchable). */\n excluded: string[]\n /** Field names omitted because a writer never writes them — a composition (4c). */\n compositions: string[]\n /** Field names whose values route under `localized[locale]`. */\n localizedFields: string[]\n /** Top-level relation fields with their candidate enums. */\n relationFields: TargetRelationField[]\n /** Top-level asset fields with their candidate enums (EC-381). */\n assetFields: TargetAssetField[]\n}\n\nexport interface BuildTargetShapeInput {\n collection: CollectionDef\n /** What the model searched — the id leash at every position (absent → nothing searched). */\n leash?: WriterLeash\n /** UI locale for resolving field labels into descriptions. */\n locale?: string\n}\n\n/**\n * A field's model-facing description: resolved label + optional `ai.hint` + the\n * constraint clause (EC-473). The constraints are stated in PROSE because that is\n * what a model acts on — the same facts also ride as JSON-Schema keywords for the\n * structured-output validator, which is a different reader.\n */\nfunction describe(field: FieldDef, locale?: string): string | undefined {\n const label = resolveLabel(field.form?.label, locale) ?? field.name\n const hint = field.ai?.hint\n const constraints = constraintSentence(field)\n const parts = [label, hint, constraints].filter(\n (p): p is string => typeof p === 'string' && p.length > 0,\n )\n return parts.length > 0 ? parts.join(' — ') : undefined\n}\n\n/**\n * Build the leash-aware target shape from a collection + what the model searched.\n * Deterministic; never throws. Reuses `collectionJsonSchema` as the base (its\n * `required` list), then gives every property its writer form (EC-556) — id enums at\n * every depth (EC-593) — and strips excluded fields and compositions.\n */\nexport function buildTargetShape(input: BuildTargetShapeInput): TargetShape {\n const leash = input.leash ?? NO_SEARCHED_IDS\n const base = collectionJsonSchema(input.collection)\n const properties: Record<string, JsonSchema> = {\n ...((base.properties as Record<string, JsonSchema>) ?? {}),\n }\n const excluded: string[] = []\n const compositions: string[] = []\n const localizedFields: string[] = []\n const relationFields: TargetRelationField[] = []\n const assetFields: TargetAssetField[] = []\n\n for (const field of input.collection.fields) {\n if (field.localized) localizedFields.push(field.name)\n\n if (field.ai?.exclude) {\n excluded.push(field.name)\n delete properties[field.name]\n continue\n }\n\n // EC-556: the writer form at every depth (rich text → markdown, EC-379 / D2;\n // nested asset / relation → the bare forms the write-time lens wraps); EC-593:\n // every id an enum over what was searched for that position.\n const written = writerFieldSchema(field, leash)\n if (written === undefined) {\n // No writer form: a composition (4c), or a relation / asset with nothing\n // searched for it — the model cannot emit a value, so a hallucinated id is\n // structurally impossible (empty beats wrong).\n if (field.type === 'blocks') compositions.push(field.name)\n delete properties[field.name]\n continue\n }\n if (field.type === 'relation') {\n const candidateIds = leash.relationCandidates(field.target).map((c) => c.id)\n relationFields.push({ fieldName: field.name, target: field.target, multiple: field.multiple, candidateIds })\n } else if (field.type === 'asset') {\n const candidateIds = leash.assetCandidates(field).map((c) => c.id)\n assetFields.push({ fieldName: field.name, multiple: field.multiple, candidateIds })\n }\n\n // EC-473: a `pattern` next to a `format` is 200+ characters that teach the\n // model nothing — the format (and the prose constraints below) say it better.\n const stripped = toModelFacingSchema(written)\n const desc = describe(field, input.locale)\n // Preserve an existing description (e.g. relation enum / rich-text note), but\n // append the constraint clause to it — the enum leash and the value rules are\n // different facts and the model needs both.\n const next: JsonSchema = stripped === written ? { ...written } : { ...stripped }\n if (desc !== undefined) {\n const existing = typeof next.description === 'string' ? next.description : undefined\n const constraints = constraintSentence(field)\n next.description =\n existing === undefined\n ? desc\n : constraints !== undefined\n ? `${existing} — ${constraints}`\n : existing\n }\n properties[field.name] = next\n }\n\n const requiredIn = Array.isArray(base.required) ? (base.required as string[]) : []\n const required = requiredIn.filter((n) => !excluded.includes(n) && properties[n] !== undefined)\n\n const schema: JsonSchema = {\n type: 'object',\n properties,\n additionalProperties: false,\n ...(required.length > 0 ? { required } : {}),\n // 4c (EC-593): the omission is said, not silent.\n ...(compositions.length > 0\n ? {\n description: `Not part of this object: ${compositions.join(', ')} — page-builder composition${compositions.length > 1 ? 's' : ''} whose components are added, moved and removed on the canvas, never by the assistant.`,\n }\n : {}),\n }\n return { schema, excluded, compositions, localizedFields, relationFields, assetFields }\n}\n"]}
@@ -33,25 +33,18 @@
33
33
  */
34
34
  import { z } from 'zod';
35
35
  import type { CmsDocument, CollectionDef, CollectionRegistry, LocaleConfig, ValidateDocumentOptions } from '@elytracms/core/cms-core';
36
- import type { ComponentManifest } from '@elytracms/core/component-registry';
36
+ import type { SearchedAsset, SearchedDocument } from './leash.js';
37
+ import type { TranslateSkip } from './translate-document.js';
37
38
  import type { ChatProposal } from './chat-state.js';
38
- import type { AiProvider, AssetCandidates, RelationCandidates, ResolvedKnowledge } from './types.js';
39
+ import type { AiProvider, ResolvedKnowledge, WriterLeash } from './types.js';
39
40
  /** A document the model may reference as a relation target (from a `searchDocuments` read). */
40
- export interface DocumentSearchResult {
41
- id: string;
42
- title?: string;
43
- }
41
+ export type DocumentSearchResult = SearchedDocument;
44
42
  /**
45
43
  * An asset the model may reference (from a `listAssets` read). EC-588: it carries the
46
- * two facts a field's `accept` is judged on, so each asset field's candidates can be
47
- * filtered to what that field takes — and the model can see what each asset is.
44
+ * two facts a field's `accept` is judged on, so each asset position's candidates can be
45
+ * filtered to what that position takes — and the model can see what each asset is.
48
46
  */
49
- export interface AssetSearchResult {
50
- id: string;
51
- title?: string;
52
- contentType: string;
53
- filename: string;
54
- }
47
+ export type AssetSearchResult = SearchedAsset;
55
48
  /**
56
49
  * The client-side, operations-backed readers the executor calls. The studio binds
57
50
  * these to the user's authenticated operations client; tests bind an in-memory fake.
@@ -201,26 +194,18 @@ export type ChatToolOutcome = {
201
194
  };
202
195
  /**
203
196
  * The per-conversation candidate store: every `searchDocuments` result is recorded
204
- * per relation target collection, every `listAssets` result into one flat library
205
- * pool (EC-381), and the terminal tools may only reference the ids gathered here
206
- * (the `applyContentWithShape` / `buildUpdateProposal` enum + drop/loud leash makes
207
- * a hallucinated relation OR asset id structurally unrepresentable / fail loud).
208
- * Held by the panel per conversation — a new conversation (EC-380 clear) starts an
209
- * empty store.
197
+ * per collection, every `listAssets` result into one flat library pool (EC-381), and
198
+ * the terminal tools may only reference the ids gathered here. The store IS the
199
+ * {@link WriterLeash} the engines ask per position (EC-593): a relation by its target
200
+ * collection, an asset by its declaration's `accept` (EC-588) — so a nested relation, a
201
+ * component's asset prop and a top-level field are leashed by the same two questions
202
+ * (the create enum + drop, the update loud refusal). Held by the panel per
203
+ * conversation — a new conversation (EC-380 clear) starts an empty store.
210
204
  */
211
- export interface ChatCandidateStore {
205
+ export interface ChatCandidateStore extends WriterLeash {
212
206
  record(collection: string, results: readonly DocumentSearchResult[]): void;
213
207
  /** Record every `listAssets` result into the flat library pool (EC-381). */
214
208
  recordAssets(results: readonly AssetSearchResult[]): void;
215
- /** Candidates for a target collection's relation fields, keyed by field name. */
216
- candidatesFor(collection: CollectionDef): RelationCandidates;
217
- /**
218
- * Candidates for a target collection's asset/image fields (EC-381), keyed by
219
- * field name — the one flat searched-asset pool (`listAssets` has no field
220
- * dimension), filtered per field by that field's `accept` (EC-588). A field with no
221
- * fitting candidate is absent, so it is omitted from the shape (empty beats wrong).
222
- */
223
- assetCandidatesFor(collection: CollectionDef): AssetCandidates;
224
209
  }
225
210
  export declare function createChatCandidateStore(): ChatCandidateStore;
226
211
  export interface ChatToolExecutorOptions {
@@ -249,8 +234,6 @@ export interface ChatToolExecutorOptions {
249
234
  currentDocument?: () => CurrentDocumentRef | null | undefined;
250
235
  /** Current knowledge snapshot (thunk — the body thunk refreshes it per request). */
251
236
  knowledge?: () => ResolvedKnowledge | undefined;
252
- /** Component manifests — context for `allow`-leashed richText/blocks fields. */
253
- components?: readonly ComponentManifest[];
254
237
  /** Target locale for localized fields. */
255
238
  locale?: string;
256
239
  /** Locale config — required for `translateDocument`. */
@@ -260,7 +243,9 @@ export interface ChatToolExecutorOptions {
260
243
  * `gateValidateOptions(...)`, forwarded whole to every engine below. EC-473
261
244
  * made the assistant's gate the editor's gate; passing one bag instead of five
262
245
  * keys makes it stay that way, because a key can no longer be dropped by being
263
- * forgotten at one of the three call sites this replaced.
246
+ * forgotten at one of the three call sites this replaced. Its `lookupManifest` is
247
+ * also how the writer-form converter and the read form reach component props
248
+ * (EC-593) — the props the validator judges, no second component source.
264
249
  */
265
250
  validateOptions?: ValidateDocumentOptions;
266
251
  /** Max repair attempts inside `applyContentWithShape`. */
@@ -272,16 +257,26 @@ export interface ChatToolExecutorOptions {
272
257
  export interface ChatToolExecutor {
273
258
  execute(call: ChatToolCall): Promise<ChatToolOutcome>;
274
259
  }
260
+ /** A translate skip as one model-facing phrase: `menu[1].label (de): the provider returned no text`. */
261
+ export declare function describeTranslateSkip(skip: TranslateSkip): string;
275
262
  /**
276
- * The MODEL-facing view of a document (EC-379): rich-text field values are
277
- * projected to markdown strings — but ONLY when the engine's loss-guarded
278
- * inverse can express them faithfully (subset-only content, round-trip proven).
279
- * A document carrying embeds, internal `ref` links, or out-of-subset marks keeps
280
- * its `{ version, doc }` envelope, so nothing the model later echoes back can
281
- * silently lose structure. Applies to the `getDocument` TOOL OUTPUT only; the
282
- * proposal/apply paths always read the raw stored document.
263
+ * The `getDocument` output (EC-379 → EC-593): the document in the form the model reads
264
+ * — the ONE converter's read side (`toWriterDocument`), so rich text is a markdown
265
+ * string at EVERY depth where the engine's loss-guarded inverse can express it
266
+ * faithfully (a top-level field, an object sub-field, a repeater item, a component's
267
+ * rich-text prop), and keeps its stored `{ version: 2, content }` value otherwise (embeds,
268
+ * internal `ref` links, out-of-subset marks), so nothing the model later echoes back can
269
+ * silently lose structure. It used to project TOP-LEVEL rich text only (SHAPES #29: a
270
+ * nested value read as v2 while every writer was told markdown).
271
+ *
272
+ * `components` is the catalog's prop half (RULES F3d): for every component on the
273
+ * document, the props `updateFields` may change and the rules each value must satisfy,
274
+ * read off the same declarations the validator judges (`lookupManifest`). Applies to
275
+ * the TOOL OUTPUT only; the proposal/apply paths always read the raw stored document.
283
276
  */
284
- export declare function projectRichTextAsMarkdown(document: CmsDocument, collection: CollectionDef): CmsDocument;
277
+ export declare function modelFacingDocument(document: CmsDocument, collection: CollectionDef, validateOptions?: ValidateDocumentOptions): CmsDocument & {
278
+ components?: Record<string, string[]>;
279
+ };
285
280
  /**
286
281
  * Build the client executor map. Every entry validates its input against
287
282
  * {@link chatToolDefinitions}' zod schema (the route validates UIMessages only