@vectoriox/iox-ui 5.110.0 → 5.112.0

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.
@@ -0,0 +1,650 @@
1
+ import { AiStep, JsonSchema } from '@vectoriox/iox-ui/generation-core';
2
+
3
+ /**
4
+ * The surfaces AI Assist runs on (ai-assist-plan §2, §4): each screen that offers a prompt registers ONE spec — what it
5
+ * may change (families), how an accepted change is committed, which model steps a turn uses, the role actions the
6
+ * server re-checks, whether it reads photos and the focus ladder its chip widens along.
7
+ */
8
+ declare enum AssistSurface {
9
+ BuilderPage = "builderPage",
10
+ ContentItem = "contentItem",
11
+ ContentFromPhotos = "contentFromPhotos",
12
+ ContentList = "contentList",
13
+ SchemaType = "schemaType",
14
+ ShopProduct = "shopProduct",
15
+ Media = "media",
16
+ BuilderSite = "builderSite",
17
+ FormInbox = "formInbox"
18
+ }
19
+ /** How an accepted turn reaches the studio (plan §3e). */
20
+ declare enum CommitKind {
21
+ /** One builder history step. */
22
+ BuilderStep = "builderStep",
23
+ /** Written into the screen's form; Save stays the owner's. */
24
+ FormFill = "formFill",
25
+ /** A server run that writes drafts, with its own Undo. */
26
+ Run = "run",
27
+ /** Nothing is written: filters, a copied reply. */
28
+ View = "view"
29
+ }
30
+ /** The closed edit families a sentence may be answered in — one strict request each. */
31
+ declare enum EditFamily {
32
+ Words = "words",
33
+ Sections = "sections",
34
+ Style = "style",
35
+ Look = "look",
36
+ Fields = "fields",
37
+ Items = "items",
38
+ View = "view",
39
+ Schema = "schema",
40
+ Media = "media",
41
+ Plan = "plan"
42
+ }
43
+ /** The model steps of a turn — generation-core's `AiStep` rows (Settings ▸ AI ▸ Models), never a second spelling. */
44
+ declare const AssistStep: {
45
+ readonly AssistRoute: AiStep.AssistRoute;
46
+ readonly AssistEdit: AiStep.AssistEdit;
47
+ readonly AssistRead: AiStep.AssistRead;
48
+ };
49
+ type AssistStep = typeof AssistStep[keyof typeof AssistStep];
50
+ /** One rung of a surface's focus ladder — the chip's ✕ widens to the next rung. */
51
+ declare enum AssistScope {
52
+ Field = "field",
53
+ Item = "item",
54
+ Type = "type",
55
+ Types = "types",
56
+ Node = "node",
57
+ Section = "section",
58
+ Page = "page",
59
+ Site = "site",
60
+ Photo = "photo",
61
+ Photos = "photos",
62
+ Rows = "rows",
63
+ Slot = "slot",
64
+ Library = "library",
65
+ Submission = "submission"
66
+ }
67
+ /** iox-cms role actions (`roles/enums.ts` `Permissions`) a surface needs — the server re-checks them, never only the client. */
68
+ declare enum AssistPermission {
69
+ SchemaAll = "schema_all",
70
+ ContentRead = "content_read",
71
+ ContentCreate = "content_create",
72
+ ContentUpdate = "content_update",
73
+ PageRead = "page_read",
74
+ PageCreate = "page_create",
75
+ PageUpdate = "page_update",
76
+ PageDelete = "page_delete",
77
+ StorageAll = "storage_all",
78
+ ProductsAll = "products_all"
79
+ }
80
+ declare enum SurfaceStatus {
81
+ Built = "built",
82
+ Planned = "planned"
83
+ }
84
+ interface SurfaceSpec {
85
+ readonly surface: AssistSurface;
86
+ readonly families: ReadonlyArray<EditFamily>;
87
+ readonly commit: CommitKind;
88
+ /** A family committed differently from the surface (the list's items are a Run; its filters a View). */
89
+ readonly familyCommits?: Readonly<Partial<Record<EditFamily, CommitKind>>>;
90
+ /** Model steps a turn may use. Media (S7) uses the picture steps of generation-core, none of these. */
91
+ readonly steps: ReadonlyArray<AssistStep>;
92
+ /** Every one is required. `content_<action>` is specialised per content type when `perContentType`. */
93
+ readonly permissions: ReadonlyArray<AssistPermission>;
94
+ /** A family that needs more than the surface does. */
95
+ readonly familyPermissions?: Readonly<Partial<Record<EditFamily, ReadonlyArray<AssistPermission>>>>;
96
+ /** The content permissions name a type (`content_<type>_<action>`), as the iox-cms guard specialises them. */
97
+ readonly perContentType: boolean;
98
+ readonly readsPhotos: boolean;
99
+ /** The focus ladder, narrowest first. */
100
+ readonly scopes: ReadonlyArray<AssistScope>;
101
+ readonly status: SurfaceStatus;
102
+ }
103
+ declare const SURFACES: Readonly<Record<AssistSurface, SurfaceSpec>>;
104
+ declare const surfaceSpec: (surface: AssistSurface) => SurfaceSpec;
105
+ declare const builtSurfaces: () => AssistSurface[];
106
+ declare const commitOf: (surface: AssistSurface, family: EditFamily) => CommitKind;
107
+ /**
108
+ * The permission strings the server checks for a turn on this surface (and these families): `content_<action>` becomes
109
+ * `content_<type>_<action>` on a per-type surface — the same specialisation iox-cms's AuthorizationGuard applies to a
110
+ * `:resource` route, so a user granted only `content_posts_update` may assist on posts and nowhere else.
111
+ */
112
+ declare function surfacePermissions(surface: AssistSurface, contentType?: string, families?: ReadonlyArray<EditFamily>): string[];
113
+
114
+ /** The house budget every Assist request is held to (plan F6, trap T7) — generation-core's, never a copy and never raised. */
115
+ declare const MAX_ASSIST_PROPERTIES: 40;
116
+ /** The route request is small and fast (plan §3a). */
117
+ declare const MAX_ROUTE_PROPERTIES = 12;
118
+ /** Around-layer text is a summary: at most this many characters per value (plan §3c). */
119
+ declare const AROUND_TEXT_CHARS = 160;
120
+ /** Sibling items sent as examples of voice (plan §3c: 3–5). */
121
+ declare const AROUND_ITEMS_MAX = 5;
122
+ /** The session memory sent with a turn: the last turns, one line each (plan §3c). */
123
+ declare const MEMORY_TURNS = 6;
124
+ declare class AssistBudgetError extends Error {
125
+ }
126
+ /** What a request's strict schemas break of the house budget — empty when it fits. */
127
+ declare function assistBudgetIssues(schemas: ReadonlyArray<JsonSchema>, maxProperties?: number): string[];
128
+ declare function assertAssistBudget(name: string, schemas: ReadonlyArray<JsonSchema>, maxProperties?: number): void;
129
+
130
+ /**
131
+ * The brief (plan §3c): what the model is told, built by CODE from what the screen holds, sized by distance from the
132
+ * focus. It names things by HANDLE (`f.summary`, `s2`), never by id (rule 3); the handle map that goes with it is
133
+ * kept by the caller and the server, never sent.
134
+ */
135
+ interface Brief<TFocus = unknown, TAround = unknown> {
136
+ readonly surface: AssistSurface;
137
+ /** The thing the sentence is about, in full. */
138
+ readonly focus: TFocus;
139
+ /** Its neighbourhood, summarised. */
140
+ readonly around: TAround;
141
+ /** The business reading (kind, voice, facts, languages) — the caller passes it; null when there is none. */
142
+ readonly owner: string | null;
143
+ readonly rules: BriefRules;
144
+ /** The session's last turns, one line each, oldest first. */
145
+ readonly memory: ReadonlyArray<string>;
146
+ }
147
+ interface BriefRules {
148
+ /** The families a turn on this focus may answer in. */
149
+ readonly families: ReadonlyArray<EditFamily>;
150
+ /** The locale words are written in (a multiLang field gets this one key). */
151
+ readonly locale: string;
152
+ /** What is never written here, each with why — the model leaves it and says it "needs you". */
153
+ readonly never: ReadonlyArray<NeverWrite>;
154
+ /** The focus rung and the rungs it can widen to. */
155
+ readonly scope: AssistScope;
156
+ readonly widensTo: ReadonlyArray<AssistScope>;
157
+ }
158
+ interface NeverWrite {
159
+ readonly handle: string;
160
+ readonly label: string;
161
+ readonly reason: string;
162
+ }
163
+ /** What a handle stands for. `path` is the key path inside the target; `id` a record the handle names (never sent). */
164
+ interface HandleTarget {
165
+ readonly key: string;
166
+ readonly path: ReadonlyArray<string>;
167
+ readonly id?: string;
168
+ }
169
+ type HandleMap = Readonly<Record<string, HandleTarget>>;
170
+ declare enum AssistIssueCode {
171
+ UnknownHandle = "unknownHandle",
172
+ NeverWrite = "neverWrite",
173
+ WrongType = "wrongType",
174
+ NotAnOption = "notAnOption",
175
+ Duplicate = "duplicate",
176
+ WrongLocale = "wrongLocale",
177
+ HtmlNotAllowed = "htmlNotAllowed",
178
+ UnknownFamily = "unknownFamily",
179
+ BadRequest = "badRequest",
180
+ UnknownSurface = "unknownSurface",
181
+ SurfaceNotBuilt = "surfaceNotBuilt",
182
+ EmptySentence = "emptySentence",
183
+ SentenceTooLong = "sentenceTooLong",
184
+ MissingHandles = "missingHandles",
185
+ MissingValues = "missingValues"
186
+ }
187
+ interface AssistIssue {
188
+ readonly code: AssistIssueCode;
189
+ readonly handle?: string;
190
+ readonly message: string;
191
+ }
192
+ /** A caller's mistake building a brief (a focus that is not on the screen) — never a model answer. */
193
+ declare class AssistBriefError extends Error {
194
+ readonly code: AssistIssueCode;
195
+ constructor(code: AssistIssueCode, message: string);
196
+ }
197
+ type HandleResolution = {
198
+ ok: true;
199
+ target: HandleTarget;
200
+ } | {
201
+ ok: false;
202
+ issue: AssistIssue;
203
+ };
204
+ /** The one way a handle becomes a key: an unknown handle is refused, never guessed (trap T1). */
205
+ declare function resolveHandle(handles: HandleMap, handle: string): HandleResolution;
206
+ /** Every handle of the list that the brief does not know. */
207
+ declare function unknownHandles(handles: HandleMap, list: ReadonlyArray<string>): AssistIssue[];
208
+ declare const FIELD_HANDLE_PREFIX = "f.";
209
+ declare const SIBLING_HANDLE_PREFIX = "s";
210
+ declare const fieldHandle: (key: string) => string;
211
+
212
+ /**
213
+ * A content type's fields as Assist sees them, read from the REAL stored schema (iox-cms `schemas` row:
214
+ * `{ name, metaData, schemaObject: { properties } }`; each property `{ type, label, controller: { type, options } }` —
215
+ * cms-client `schema-doc/property-def.model.ts`). A multiLang field is `type: 'object'` + `controller.type: 'multiLang'`
216
+ * whose `properties` are its locales (`{ en: {…}, he: {…} }`), each with the inner control.
217
+ *
218
+ * Every field is either WRITABLE (one of the kinds below) or NEVER written, with a reason. Never written:
219
+ * - by what it is: relations, media (ids / URLs), secrets, dates, e-mail, nested structures, a select with no options;
220
+ * - by what it is about — a closed word list over the key and the label (English + Hebrew): money (price, cost, fee,
221
+ * currency, discount, VAT…), stock (quantity, inventory…), product codes (SKU, barcode…), contact facts (phone, e-mail,
222
+ * address, location, hours…), dates and web addresses (slug, URL, link). A field whose controller or type is `money`
223
+ * / `price` / `currency` is money, ready for "money as a field type" (AI plan) the day it exists.
224
+ * The model never sees the value of a never-written field, only whether it is filled; the owner fills it ("needs you").
225
+ */
226
+ interface ContentControllerDef {
227
+ readonly type?: string;
228
+ readonly options?: unknown;
229
+ }
230
+ interface ContentPropertyDef {
231
+ readonly type: string;
232
+ readonly label?: string;
233
+ readonly controller?: ContentControllerDef;
234
+ readonly properties?: Readonly<Record<string, ContentPropertyDef>>;
235
+ readonly items?: ContentPropertyDef;
236
+ readonly required?: boolean;
237
+ readonly rel?: unknown;
238
+ }
239
+ interface ContentTypeSchema {
240
+ readonly name: string;
241
+ readonly metaData?: {
242
+ readonly label?: string;
243
+ readonly previewTextField?: string;
244
+ readonly previewImageField?: string;
245
+ };
246
+ readonly schemaObject: {
247
+ readonly properties: Readonly<Record<string, ContentPropertyDef>>;
248
+ };
249
+ }
250
+ declare enum AssistFieldKind {
251
+ Text = "text",
252
+ Textarea = "textarea",
253
+ /** Written as plain paragraphs, never HTML (trap T6). */
254
+ RichText = "richText",
255
+ Number = "number",
256
+ Boolean = "boolean",
257
+ /** One of the field's options. */
258
+ Choice = "choice",
259
+ /** Some of the field's options. */
260
+ Choices = "choices",
261
+ /** A list of words. */
262
+ Tags = "tags",
263
+ /** Not writable — `never` says why. */
264
+ Other = "other"
265
+ }
266
+ declare enum NeverWriteReason {
267
+ Money = "money",
268
+ Stock = "stock",
269
+ ProductCode = "productCode",
270
+ Contact = "contact",
271
+ Date = "date",
272
+ WebAddress = "webAddress",
273
+ Relation = "relation",
274
+ Media = "media",
275
+ Secret = "secret",
276
+ Structure = "structure"
277
+ }
278
+ interface AssistField {
279
+ readonly key: string;
280
+ readonly handle: string;
281
+ readonly label: string;
282
+ readonly kind: AssistFieldKind;
283
+ readonly required: boolean;
284
+ /** Choice / Choices: the option values the field accepts. */
285
+ readonly options?: ReadonlyArray<string>;
286
+ /** multiLang: the locales the field holds, in schema order. */
287
+ readonly locales?: ReadonlyArray<string>;
288
+ readonly never?: NeverWriteReason;
289
+ }
290
+ /** Every form field of the type, in schema order, writable or with the reason it is never written. */
291
+ declare function assistFields(schema: ContentTypeSchema): AssistField[];
292
+ declare const isWritable: (field: AssistField) => boolean;
293
+ /** The type's title field: its `@title` role (`metaData.previewTextField`), else its first text field. */
294
+ declare function titleField(schema: ContentTypeSchema, fields?: ReadonlyArray<AssistField>): AssistField | undefined;
295
+
296
+ /**
297
+ * Rich text crosses the model boundary as PLAIN PARAGRAPHS in both directions (trap T6): the brief reads the stored
298
+ * value (the item editor's Quill writes HTML) as paragraphs, and an answer's paragraphs become HTML only here, every
299
+ * character escaped — the model never writes markup that reaches a page.
300
+ */
301
+ /** A stored rich-text value (HTML, or plain text) as its non-empty paragraphs. */
302
+ declare function richTextParagraphs(value: unknown): string[];
303
+ /** Paragraphs as the editor's HTML: one `<p>` each, escaped. */
304
+ declare function paragraphsToRichText(paragraphs: ReadonlyArray<string>): string;
305
+ /** True when a text written by the model carries markup — refused, never stripped. */
306
+ declare const containsHtml: (text: string) => boolean;
307
+
308
+ /** A field's value as the model reads it: text, paragraphs, a number, yes/no, options, words, or per locale. */
309
+ type BriefValue = string | number | boolean | ReadonlyArray<string> | Readonly<Record<string, string | ReadonlyArray<string>>> | null;
310
+ declare const isPlainRecord: (v: unknown) => v is Record<string, unknown>;
311
+ /** One stored value (a plain field, or one locale of a multiLang field) in its kind's readable form. */
312
+ declare function readFieldValue(kind: AssistFieldKind, raw: unknown): BriefValue;
313
+ declare function isEmptyFieldValue(v: unknown): boolean;
314
+ /** A multiLang value's locales, each read in the field's kind. */
315
+ declare function readLocaleValues(kind: AssistFieldKind, locales: ReadonlyArray<string>, raw: unknown): Record<string, BriefValue>;
316
+
317
+ /**
318
+ * The brief of surface S2 — one content item (plan §3c, §4 S2). Focus = the item (every field as a handle `f.<key>`,
319
+ * its kind, label, full value, which locales a multiLang field has filled) or ONE field when the owner opened the
320
+ * field's sparkle; around = the rest of the item (when the focus is a field) and up to five sibling items of the type,
321
+ * each value clipped to 160 characters — examples of the studio's voice, never something to copy.
322
+ */
323
+ type ContentRecord = Readonly<Record<string, unknown>>;
324
+ interface ItemBriefField {
325
+ readonly handle: string;
326
+ readonly label: string;
327
+ readonly kind: AssistFieldKind;
328
+ readonly required: boolean;
329
+ /** In the write locale for a multiLang field. */
330
+ readonly empty: boolean;
331
+ /** Absent on a never-written field: the model only learns whether it is filled. */
332
+ readonly value?: BriefValue;
333
+ readonly options?: ReadonlyArray<string>;
334
+ readonly locales?: {
335
+ readonly filled: ReadonlyArray<string>;
336
+ readonly empty: ReadonlyArray<string>;
337
+ };
338
+ readonly never?: NeverWriteReason;
339
+ }
340
+ interface ItemFocus {
341
+ readonly scope: AssistScope;
342
+ readonly type: {
343
+ readonly name: string;
344
+ readonly label: string;
345
+ };
346
+ /** The item's name as the list shows it ('' for a new item). */
347
+ readonly title: string;
348
+ /** The `@title` field's handle, when the type has one. */
349
+ readonly titleHandle: string | null;
350
+ readonly fields: ReadonlyArray<ItemBriefField>;
351
+ }
352
+ interface ItemSummary {
353
+ readonly handle: string;
354
+ readonly title: string;
355
+ /** handle → value, ≤ 160 characters. */
356
+ readonly fields: Readonly<Record<string, string>>;
357
+ }
358
+ interface ItemAround {
359
+ /** The item's other fields, summarised — only when the focus is one field. */
360
+ readonly item: Readonly<Record<string, string>> | null;
361
+ readonly siblings: ReadonlyArray<ItemSummary>;
362
+ }
363
+ type ItemBrief = Brief<ItemFocus, ItemAround>;
364
+ interface ItemBriefContext {
365
+ /** The locale the turn writes in. */
366
+ readonly locale: string;
367
+ /** One field's key or handle: the per-field sparkle. */
368
+ readonly focusField?: string;
369
+ /** Other items of the type (the item itself is skipped); the first five are sent. */
370
+ readonly siblings?: ReadonlyArray<ContentRecord>;
371
+ readonly owner?: string | null;
372
+ readonly memory?: ReadonlyArray<string>;
373
+ }
374
+ interface SummarizedItem {
375
+ readonly brief: ItemBrief;
376
+ readonly handles: HandleMap;
377
+ }
378
+ declare const clipText: (text: string, max?: number) => string;
379
+ /** S2's brief and its handle map: `f.<key>` per field, `s<n>` per sibling (its id stays in the map, never sent). */
380
+ declare function summarizeItem(schema: ContentTypeSchema, item: ContentRecord, ctx: ItemBriefContext): SummarizedItem;
381
+ declare enum ItemSuggestionKind {
382
+ FillEmpty = "fillEmpty",
383
+ Translate = "translate",
384
+ Shorten = "shorten",
385
+ WriteSeo = "writeSeo"
386
+ }
387
+ /** A quick action the box offers, built from the brief (never canned text — the client words it). */
388
+ interface ItemSuggestion {
389
+ readonly kind: ItemSuggestionKind;
390
+ readonly handles: ReadonlyArray<string>;
391
+ /** Translate: the locale to fill. */
392
+ readonly locale?: string;
393
+ }
394
+ /** A text this long is worth a "Shorten". */
395
+ declare const SHORTEN_FROM_CHARS = 280;
396
+ /** S2's quick actions: Fill empty fields, Translate to <locale>, Shorten, Write SEO — each only when it applies. */
397
+ declare function itemSuggestions(brief: ItemBrief): ItemSuggestion[];
398
+
399
+ /**
400
+ * The strict output format of family `fields` for one content type (plan §3b): one property per WRITABLE field, keyed
401
+ * by its handle, every key required, every object closed. "Leave it as it is" is the kind's NONE value — `''` for a
402
+ * text, a number (written in digits), a yes/no or a choice, `[]` for paragraphs and lists — never `null`: the house
403
+ * budget allows 8 unions a request, so nullable fields would cap a part at 8 fields; the house wire (plan-edits) uses
404
+ * the same "every key required, each with its none". So Assist never EMPTIES a field — clearing one is the owner's.
405
+ * Rich text is a list of plain paragraphs (trap T6); a multiLang field is written in ONE locale (trap T5). A type with
406
+ * more writable fields than one request holds is split into parts, each ≤ 40 properties (trap T7 — never raised).
407
+ */
408
+ declare enum FieldsAnswerKey {
409
+ Fields = "fields",
410
+ Note = "note"
411
+ }
412
+ /** How many fields one request carries. */
413
+ declare const FIELDS_PER_PART: number;
414
+ declare const NONE_TEXT = "";
415
+ declare const BOOLEAN_TRUE = "true";
416
+ declare const BOOLEAN_FALSE = "false";
417
+ interface FieldsSchemaOptions {
418
+ /** The locale a multiLang field is written in. */
419
+ readonly locale: string;
420
+ /** Only these fields (keys or handles) — the focus. Default: every writable field. */
421
+ readonly fields?: ReadonlyArray<string>;
422
+ }
423
+ interface FieldsSchemas {
424
+ /** One strict format per request. Empty when nothing is writable. */
425
+ readonly parts: JsonSchema[];
426
+ /** Per part, the handles it carries. */
427
+ readonly handles: string[][];
428
+ }
429
+ declare function fieldsJsonSchema(schema: ContentTypeSchema, options: FieldsSchemaOptions): FieldsSchemas;
430
+ /** One field's answer as the model wrote it. */
431
+ interface FieldEdit {
432
+ readonly handle: string;
433
+ readonly value: unknown;
434
+ }
435
+ /** The parts' answers → the edits they make (every leave value dropped). */
436
+ declare function decodeFieldsAnswers(answers: ReadonlyArray<unknown>): FieldEdit[];
437
+
438
+ /**
439
+ * The route request (plan §3c rule 5): the first, small, fast question of every turn — which of THIS surface's
440
+ * families the sentence needs, or `cannot` with one line for the owner. Its family enum is the surface's, so the model
441
+ * cannot route a content-item sentence to the builder's Style.
442
+ */
443
+ declare enum RouteAnswerKey {
444
+ Families = "families",
445
+ Cannot = "cannot",
446
+ Reply = "reply"
447
+ }
448
+ declare function routeJsonSchema(surface: AssistSurface): JsonSchema;
449
+ interface AssistRoute {
450
+ readonly ok: boolean;
451
+ readonly families: ReadonlyArray<EditFamily>;
452
+ readonly cannot: string | null;
453
+ readonly reply: string;
454
+ readonly issues: ReadonlyArray<AssistIssue>;
455
+ }
456
+ /** A route answer, checked against its surface: a family the surface does not have is refused, repeats dropped. */
457
+ declare function readRoute(surface: AssistSurface, answer: unknown): AssistRoute;
458
+
459
+ /**
460
+ * Family `fields`, applied (plan §3c rule 6): the SAME pure check runs on the server (on a copy, before the turn is
461
+ * shown) and in the client (the trial in the form). All or none — one refused edit refuses the turn, which is re-asked
462
+ * once with the issues, never repaired in code. Never mutates its input.
463
+ * - a handle maps back through the brief's map; an unknown one is refused (T1);
464
+ * - a never-written field, a wrong type, a choice outside the options, markup in a text: refused;
465
+ * - a multiLang field gets ONE locale key, the others kept (T5);
466
+ * - rich text is stored as escaped `<p>` paragraphs; the change carries the paragraphs (T6);
467
+ * - a field the owner edited since the last turn is KEPT unless the sentence names it (rule 9);
468
+ * - an edit that changes nothing is dropped.
469
+ */
470
+ interface FieldEditContext {
471
+ readonly schema: ContentTypeSchema;
472
+ readonly handles: HandleMap;
473
+ /** The locale a multiLang field is written in. */
474
+ readonly locale: string;
475
+ /** Fields (keys or handles) the owner changed since the last AI turn. */
476
+ readonly ownerEdited?: ReadonlyArray<string>;
477
+ /** Fields (keys or handles) the sentence names. Default: read from `sentence` by `fieldsNamedIn`. */
478
+ readonly named?: ReadonlyArray<string>;
479
+ readonly sentence?: string;
480
+ }
481
+ interface FieldChange {
482
+ readonly handle: string;
483
+ readonly key: string;
484
+ readonly label: string;
485
+ readonly kind: AssistFieldKind;
486
+ /** Readable: text, paragraphs, a number, yes/no, options, words. */
487
+ readonly before: BriefValue;
488
+ readonly after: BriefValue;
489
+ readonly locale?: string;
490
+ }
491
+ interface FieldEditsOutcome {
492
+ readonly ok: boolean;
493
+ /** The record with every change applied (stored form) — a copy of the input when refused. */
494
+ readonly result: ContentRecord;
495
+ readonly changes: ReadonlyArray<FieldChange>;
496
+ /** Proposed, but the owner edited the field since and the sentence did not name it. */
497
+ readonly kept: ReadonlyArray<FieldChange>;
498
+ readonly issues: ReadonlyArray<AssistIssue>;
499
+ }
500
+ /** The fields a sentence names by label, key or handle (case-insensitive) — rule 9's "unless the sentence names it". */
501
+ declare function fieldsNamedIn(sentence: string, fields: ReadonlyArray<AssistField>): string[];
502
+ declare function applyFieldEdits(values: ContentRecord, edits: ReadonlyArray<FieldEdit>, ctx: FieldEditContext): FieldEditsOutcome;
503
+
504
+ /**
505
+ * The turn wire (plan §3d) — what cms-client posts and polls and iox-cms stores and answers, ONE definition both sides
506
+ * import (generation-core `ai-run.ts` is the precedent for generations). A turn is a document on the jobs runner:
507
+ * POST answers 202 `{ turnId }`, the client polls the turn every 750 ms until it is terminal.
508
+ */
509
+ declare enum AssistTurnStatus {
510
+ Queued = "queued",
511
+ Routing = "routing",
512
+ Editing = "editing",
513
+ Done = "done",
514
+ Refused = "refused",
515
+ Failed = "failed"
516
+ }
517
+ declare const isTerminalTurn: (status: AssistTurnStatus) => boolean;
518
+ /** Auto = the step's model from Settings ▸ AI ▸ Models (A-D14). */
519
+ declare const ASSIST_MODEL_AUTO = "auto";
520
+ /** `'auto'` or a model id. */
521
+ type AssistModelChoice = typeof ASSIST_MODEL_AUTO | string;
522
+ declare const ASSIST_POLL_MS = 750;
523
+ declare const MAX_SENTENCE_CHARS = 2000;
524
+ interface AssistTurnRequest {
525
+ readonly surface: AssistSurface;
526
+ /** `assistSessionKey(surface, target)`; the server adds the user. */
527
+ readonly sessionKey: string;
528
+ readonly sentence: string;
529
+ readonly model: AssistModelChoice;
530
+ readonly contentType?: string;
531
+ readonly itemId?: string;
532
+ readonly brief: Brief;
533
+ readonly handles: HandleMap;
534
+ /** A form-fill surface: the form's current values (it may be unsaved) — the edits are checked against them. */
535
+ readonly values?: ContentRecord;
536
+ /** Field keys the owner changed since the last AI turn — kept unless the sentence names them (rule 9). */
537
+ readonly ownerEdited?: ReadonlyArray<string>;
538
+ }
539
+ /** POST's 202 answer. */
540
+ interface AssistTurnAccepted {
541
+ readonly turnId: string;
542
+ }
543
+ /** A turn's own refusals and failures, beside generation-core's `AiRefusalCode`s (credits, plan, key), which a turn returns as they are. */
544
+ declare enum AssistRefusalCode {
545
+ /** The turn machinery runs, no model is connected yet. */
546
+ NotConnected = "ai.assistNotConnected",
547
+ /** The turn spent its own credit cap (trap T8) before a call it still needed. */
548
+ TurnBudget = "ai.assistTurnBudget",
549
+ /** The routed families need a permission the person who asked does not hold. */
550
+ Permission = "ai.assistPermission",
551
+ /** A process died during this turn's call more often than one resume allows. */
552
+ Interrupted = "ai.assistInterrupted",
553
+ /** The provider call threw — the turn ends; the owner may ask again. */
554
+ CallFailed = "ai.assistCallFailed",
555
+ /** The model's answer broke the check twice (the first time it was re-asked with the issues). */
556
+ InvalidAnswer = "ai.assistInvalidAnswer",
557
+ /** The chosen model is not on the vetted list for this step, and the turn runs on IOX credits. */
558
+ ModelNotOffered = "ai.assistModelNotOffered",
559
+ /** The chosen model cannot do the step (on the studio's own key any model may be typed; this one lacks a need). */
560
+ ModelDeclined = "ai.assistModelDeclined"
561
+ }
562
+ interface AssistTurnRefusal {
563
+ /** An `AssistRefusalCode` or an `AiRefusalCode` — a string, so both fit. */
564
+ readonly code: string;
565
+ readonly message: string;
566
+ }
567
+ interface AssistTurn {
568
+ readonly id: string;
569
+ readonly surface: AssistSurface;
570
+ readonly sessionKey: string;
571
+ readonly status: AssistTurnStatus;
572
+ readonly sentence: string;
573
+ /** The model it ran on (Auto resolved) — the one the ledger row names (R-H11). */
574
+ readonly model?: string;
575
+ readonly families?: ReadonlyArray<EditFamily>;
576
+ readonly reply?: string;
577
+ readonly edits?: ReadonlyArray<FieldEdit>;
578
+ readonly changes?: ReadonlyArray<FieldChange>;
579
+ readonly kept?: ReadonlyArray<FieldChange>;
580
+ readonly issues?: ReadonlyArray<AssistIssue>;
581
+ readonly refusal?: AssistTurnRefusal;
582
+ readonly credits?: number;
583
+ /** ISO time. */
584
+ readonly createdAt: string;
585
+ }
586
+ declare enum AssistRouteKey {
587
+ Turns = "turns",
588
+ Turn = "turn",
589
+ Session = "session"
590
+ }
591
+ /** The path templates, `:param` filled by `assistPath` — neither side hand-types a URL. */
592
+ declare const ASSIST_ROUTES: Readonly<Record<AssistRouteKey, string>>;
593
+ declare class AssistPathError extends Error {
594
+ }
595
+ /** A route with its params filled, each URL-encoded; a missing param throws. */
596
+ declare function assistPath(route: AssistRouteKey, params: Readonly<Record<string, string>>): string;
597
+ /** What a session is about, beside its surface (A-D9: per user × surface × target). */
598
+ interface AssistTarget {
599
+ readonly contentType?: string;
600
+ readonly itemId?: string | null;
601
+ readonly pageId?: string;
602
+ readonly submissionId?: string;
603
+ }
604
+ /** A target not saved yet. */
605
+ declare const NEW_TARGET = "new";
606
+ /** `contentItem:projects:<itemId|new>` — each part encoded, so a value never carries the separator. */
607
+ declare function assistSessionKey(surface: AssistSurface, target?: AssistTarget): string;
608
+ interface AssistMemoryLine {
609
+ readonly turnId: string;
610
+ readonly createdAt: string;
611
+ readonly line: string;
612
+ }
613
+ /** One line the next turn reads as memory — never a tree, a record or a value. */
614
+ declare function memoryLine(turn: AssistTurn): AssistMemoryLine;
615
+ /** `GET …/ai/assist/sessions/:sessionKey` — the memory the next turn is sent. */
616
+ interface AssistSession {
617
+ readonly sessionKey: string;
618
+ readonly lines: ReadonlyArray<AssistMemoryLine>;
619
+ }
620
+ /** A session's answer from its stored turns (those of another session are ignored). */
621
+ declare function assistSession(sessionKey: string, turns: ReadonlyArray<AssistTurn>): AssistSession;
622
+ /** A session's memory: its last `MEMORY_TURNS` finished turns, oldest first. */
623
+ declare function sessionMemory(turns: ReadonlyArray<AssistTurn>): AssistMemoryLine[];
624
+ /** A key `assistSessionKey` made for this surface. */
625
+ declare const isSessionOf: (key: unknown, surface: AssistSurface) => boolean;
626
+ /** What the server refuses in a posted turn before anything runs. Empty = accepted. */
627
+ declare function validateTurnRequest(req: unknown): AssistIssue[];
628
+
629
+ /**
630
+ * The ONE locale a content-item turn writes in (plan §3c rule 8, trap T5) — decided the same way by the server and the
631
+ * client: a multiLang field gets this key and no other. The sentence decides when it names a language ("translate the
632
+ * summary to English", "תרגם לאנגלית") — matched against the runtime's own language names (`Intl.DisplayNames`) in the
633
+ * languages the admin speaks, never a hand-kept list; the last one named wins. Otherwise the item's own language: the
634
+ * locale most of its multiLang fields are filled in (schema order breaks a tie); else the admin's; else the first.
635
+ */
636
+ /** The languages whose names a sentence may use — the admin's two UI languages. */
637
+ declare const LOCALE_NAME_LANGUAGES: ReadonlyArray<string>;
638
+ /** Every locale the type's multiLang fields hold, in schema order. */
639
+ declare function itemLocales(fields: ReadonlyArray<AssistField>): string[];
640
+ /** The locale the sentence names; the last one named wins ("the Hebrew summary to English" → en). */
641
+ declare function namedLocale(sentence: string, locales: ReadonlyArray<string>, languages?: ReadonlyArray<string>): string | null;
642
+ /** The locale most of the item's multiLang fields are filled in (schema order breaks a tie); else the UI's; else the first. */
643
+ declare function primaryLocale(fields: ReadonlyArray<AssistField>, values: ContentRecord, uiLang: string): string;
644
+ /** The write locale of a content-item turn. */
645
+ declare function turnLocale(sentence: string, fields: ReadonlyArray<AssistField>, values: ContentRecord, uiLang: string): string;
646
+ /** The language's own name in the admin's language (`en` → "English" / "אנגלית"). */
647
+ declare const languageName: (locale: string, uiLang: string) => string;
648
+
649
+ export { AROUND_ITEMS_MAX, AROUND_TEXT_CHARS, ASSIST_MODEL_AUTO, ASSIST_POLL_MS, ASSIST_ROUTES, AssistBriefError, AssistBudgetError, AssistFieldKind, AssistIssueCode, AssistPathError, AssistPermission, AssistRefusalCode, AssistRouteKey, AssistScope, AssistStep, AssistSurface, AssistTurnStatus, BOOLEAN_FALSE, BOOLEAN_TRUE, CommitKind, EditFamily, FIELDS_PER_PART, FIELD_HANDLE_PREFIX, FieldsAnswerKey, ItemSuggestionKind, LOCALE_NAME_LANGUAGES, MAX_ASSIST_PROPERTIES, MAX_ROUTE_PROPERTIES, MAX_SENTENCE_CHARS, MEMORY_TURNS, NEW_TARGET, NONE_TEXT, NeverWriteReason, RouteAnswerKey, SHORTEN_FROM_CHARS, SIBLING_HANDLE_PREFIX, SURFACES, SurfaceStatus, applyFieldEdits, assertAssistBudget, assistBudgetIssues, assistFields, assistPath, assistSession, assistSessionKey, builtSurfaces, clipText, commitOf, containsHtml, decodeFieldsAnswers, fieldHandle, fieldsJsonSchema, fieldsNamedIn, isEmptyFieldValue, isPlainRecord, isSessionOf, isTerminalTurn, isWritable, itemLocales, itemSuggestions, languageName, memoryLine, namedLocale, paragraphsToRichText, primaryLocale, readFieldValue, readLocaleValues, readRoute, resolveHandle, richTextParagraphs, routeJsonSchema, sessionMemory, summarizeItem, surfacePermissions, surfaceSpec, titleField, turnLocale, unknownHandles, validateTurnRequest };
650
+ export type { AssistField, AssistIssue, AssistMemoryLine, AssistModelChoice, AssistRoute, AssistSession, AssistTarget, AssistTurn, AssistTurnAccepted, AssistTurnRefusal, AssistTurnRequest, Brief, BriefRules, BriefValue, ContentControllerDef, ContentPropertyDef, ContentRecord, ContentTypeSchema, FieldChange, FieldEdit, FieldEditContext, FieldEditsOutcome, FieldsSchemaOptions, FieldsSchemas, HandleMap, HandleResolution, HandleTarget, ItemAround, ItemBrief, ItemBriefContext, ItemBriefField, ItemFocus, ItemSuggestion, ItemSummary, NeverWrite, SummarizedItem, SurfaceSpec };
@@ -0,0 +1,3 @@
1
+ {
2
+ "module": "../fesm2022/vectoriox-iox-ui-assist-core.mjs"
3
+ }