@vectoriox/iox-ui 5.113.0 → 5.115.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.
@@ -1,4 +1,4 @@
1
- import { AiStep, JsonSchema } from '@vectoriox/iox-ui/generation-core';
1
+ import { AiStep, JsonSchema, PlanWordContext, SerializedNode } from '@vectoriox/iox-ui/generation-core';
2
2
 
3
3
  /**
4
4
  * The surfaces AI Assist runs on (ai-assist-plan §2, §4): each screen that offers a prompt registers ONE spec — what it
@@ -182,7 +182,11 @@ declare enum AssistIssueCode {
182
182
  EmptySentence = "emptySentence",
183
183
  SentenceTooLong = "sentenceTooLong",
184
184
  MissingHandles = "missingHandles",
185
- MissingValues = "missingValues"
185
+ MissingValues = "missingValues",
186
+ /** Looks like an e-mail, phone, price or time nobody gave (generation-core `factIssues`, R-H2). */
187
+ InventedFact = "inventedFact",
188
+ /** A word this site must not use. */
189
+ AvoidWord = "avoidWord"
186
190
  }
187
191
  interface AssistIssue {
188
192
  readonly code: AssistIssueCode;
@@ -300,6 +304,8 @@ declare function titleField(schema: ContentTypeSchema, fields?: ReadonlyArray<As
300
304
  */
301
305
  /** A stored rich-text value (HTML, or plain text) as its non-empty paragraphs. */
302
306
  declare function richTextParagraphs(value: unknown): string[];
307
+ /** One line of plain text as stored HTML: every character escaped (a heading's or a button's words). */
308
+ declare const escapeText: (text: string) => string;
303
309
  /** Paragraphs as the editor's HTML: one `<p>` each, escaped. */
304
310
  declare function paragraphsToRichText(paragraphs: ReadonlyArray<string>): string;
305
311
  /** True when a text written by the model carries markup — refused, never stripped. */
@@ -456,6 +462,24 @@ interface AssistRoute {
456
462
  /** A route answer, checked against its surface: a family the surface does not have is refused, repeats dropped. */
457
463
  declare function readRoute(surface: AssistSurface, answer: unknown): AssistRoute;
458
464
 
465
+ /**
466
+ * The fact gate of every Assist family (ai-assist-plan §3c rule 4, R-H2): generation-core's `factIssues` — the SAME judge
467
+ * the plan uses — over the words a model wrote. What counts as the owner's: their reading's facts, the sentence they
468
+ * typed, and the words already on what they are editing (a phone already on their page is theirs to keep or move).
469
+ */
470
+ /** The owner's words to avoid and own facts (the business reading); absent → none beyond the known texts. */
471
+ type AssistWordContext = Partial<PlanWordContext>;
472
+ interface WrittenWords {
473
+ readonly handle: string;
474
+ readonly text: string;
475
+ }
476
+ declare function assistFactIssues(written: ReadonlyArray<WrittenWords>, ctx: {
477
+ readonly words?: AssistWordContext;
478
+ readonly sentence?: string;
479
+ /** The texts already on the thing being edited. */
480
+ readonly existing: ReadonlyArray<string>;
481
+ }): AssistIssue[];
482
+
459
483
  /**
460
484
  * Family `fields`, applied (plan §3c rule 6): the SAME pure check runs on the server (on a copy, before the turn is
461
485
  * shown) and in the client (the trial in the form). All or none — one refused edit refuses the turn, which is re-asked
@@ -477,6 +501,8 @@ interface FieldEditContext {
477
501
  /** Fields (keys or handles) the sentence names. Default: read from `sentence` by `fieldsNamedIn`. */
478
502
  readonly named?: ReadonlyArray<string>;
479
503
  readonly sentence?: string;
504
+ /** The owner's words to avoid and own facts (R-H2) — a fact in the sentence or already in the item is theirs. */
505
+ readonly words?: AssistWordContext;
480
506
  }
481
507
  interface FieldChange {
482
508
  readonly handle: string;
@@ -501,6 +527,190 @@ interface FieldEditsOutcome {
501
527
  declare function fieldsNamedIn(sentence: string, fields: ReadonlyArray<AssistField>): string[];
502
528
  declare function applyFieldEdits(values: ContentRecord, edits: ReadonlyArray<FieldEdit>, ctx: FieldEditContext): FieldEditsOutcome;
503
529
 
530
+ /**
531
+ * Surface S1 (the builder, this page), family `words` (ai-assist-plan §4, ai-session-panel-plan §3b–§3d): the page as
532
+ * the model sees it — sections in order, each a handle (`s0`), the parts that carry words as handles (`s0.heading1`,
533
+ * `s2.button1`) with their kind and words — never a node id, a style value or the tree. The SAME pure functions run on
534
+ * the server (the brief it trusts, the check on a copy) and in the builder (the trial on the canvas):
535
+ * - `summarizePage` — the brief + the handle map (handle → node id + prop), sized by distance from the selection;
536
+ * - `wordsJsonSchema` — the strict format, one property per writable handle of the focus, ≤ 40 a request;
537
+ * - `applyWordEdits` — all or none on a COPY: unknown or bound handles, markup, an empty text, a word to avoid or a fact
538
+ * nobody gave are refused (re-asked once by the server, never repaired here).
539
+ */
540
+ /** What a part is, as the owner and the model call it. */
541
+ declare enum PagePartKind {
542
+ Heading = "heading",
543
+ Text = "text",
544
+ Button = "button",
545
+ Link = "link",
546
+ Image = "image",
547
+ Field = "field",
548
+ Slide = "slide",
549
+ Video = "video"
550
+ }
551
+ interface WordSlot {
552
+ readonly prop: string;
553
+ readonly kind: PagePartKind;
554
+ /** A second words prop of the same node (`s0.field1.placeholder`). */
555
+ readonly suffix?: string;
556
+ /** What these words are, for the model. */
557
+ readonly says: string;
558
+ }
559
+ /** Which saved prop holds a type's words (node baselines). One table — ARIA labels are left to the author. */
560
+ declare const PAGE_WORD_SLOTS: Readonly<Record<string, ReadonlyArray<WordSlot>>>;
561
+ /** Focus words are sent whole up to this; Around words are summaries (`AROUND_TEXT_CHARS`). */
562
+ declare const FOCUS_TEXT_CHARS = 1200;
563
+ /** A stored words value as the owner reads it. */
564
+ declare function readableWords(value: unknown): string;
565
+ interface PagePart {
566
+ readonly handle: string;
567
+ readonly kind: PagePartKind;
568
+ /** "Heading 1", "Button 2" — how the change card names it. */
569
+ readonly label: string;
570
+ readonly words: string;
571
+ /** Written as paragraphs (a list) rather than one line. */
572
+ readonly paragraphs?: boolean;
573
+ /** `Projects ▸ title`: bound words change with their item, never here. */
574
+ readonly bound?: string;
575
+ readonly style?: string;
576
+ readonly role?: string;
577
+ }
578
+ interface PageSectionSummary {
579
+ readonly handle: string;
580
+ /** The section's own name ("Hero", "Our work") or "Section 3". */
581
+ readonly label: string;
582
+ readonly parts: ReadonlyArray<PagePart>;
583
+ }
584
+ interface PageFocus {
585
+ readonly scope: AssistScope;
586
+ readonly page: {
587
+ readonly name: string;
588
+ readonly route: string;
589
+ };
590
+ readonly sections: ReadonlyArray<PageSectionSummary>;
591
+ /** The selection's handles (the node and the parts inside it) — "this". Empty on a page focus. */
592
+ readonly selected: ReadonlyArray<string>;
593
+ /** The selection as the owner sees it ("Hero ▸ Heading 1"). */
594
+ readonly selectedLabel?: string;
595
+ }
596
+ interface PageAround {
597
+ /** The other sections, one line each. */
598
+ readonly sections: ReadonlyArray<{
599
+ readonly handle: string;
600
+ readonly label: string;
601
+ readonly headline: string;
602
+ }>;
603
+ /** The site's other pages, by name. */
604
+ readonly pages: ReadonlyArray<string>;
605
+ }
606
+ type PageBrief = Brief<PageFocus, PageAround>;
607
+ interface PageBriefContext {
608
+ readonly locale: string;
609
+ readonly page: {
610
+ readonly name: string;
611
+ readonly route: string;
612
+ };
613
+ /** The selected node, when there is one. */
614
+ readonly selectedId?: string | null;
615
+ /** A rung wider than the selection (the chip's ✕). Default: node when something is selected, else page. */
616
+ readonly scope?: AssistScope;
617
+ readonly pages?: ReadonlyArray<string>;
618
+ readonly owner?: string | null;
619
+ readonly memory?: ReadonlyArray<string>;
620
+ }
621
+ interface SummarizedPage {
622
+ readonly brief: PageBrief;
623
+ /** Every WRITABLE words handle of the page → its node id and prop. Bound parts are not in it. */
624
+ readonly handles: HandleMap;
625
+ /** The writable handles of the focus — what a words request carries. */
626
+ readonly focusHandles: ReadonlyArray<string>;
627
+ /** Every part of the page with its node id (for the client to outline a change) — never sent. */
628
+ readonly nodes: Readonly<Record<string, string>>;
629
+ }
630
+ /**
631
+ * The page as the model sees it. The selection decides the focus: a node → its section in full, its own parts as
632
+ * "this"; a section → that section; nothing (or the page rung) → every section. The other sections are one line each.
633
+ */
634
+ declare function summarizePage(layout: ReadonlyArray<SerializedNode>, ctx: PageBriefContext): SummarizedPage;
635
+ declare enum WordsAnswerKey {
636
+ Words = "words",
637
+ Note = "note"
638
+ }
639
+ /** How many words handles one request carries. */
640
+ declare const WORDS_PER_PART: number;
641
+ interface WordsSchemas {
642
+ readonly parts: JsonSchema[];
643
+ readonly handles: string[][];
644
+ }
645
+ /** The strict format of family `words` for the focus: every writable handle answered (new words, or its leave value). */
646
+ declare function wordsJsonSchema(summary: SummarizedPage): WordsSchemas;
647
+ /** One part's answer as the model wrote it: a line, or paragraphs. */
648
+ interface WordEdit {
649
+ readonly handle: string;
650
+ readonly value: string | ReadonlyArray<string>;
651
+ }
652
+ /** The parts' answers → the edits they make (every leave value dropped). */
653
+ declare function decodeWordsAnswers(answers: ReadonlyArray<unknown>): WordEdit[];
654
+ interface WordChange {
655
+ readonly handle: string;
656
+ /** The node the change is on — the builder outlines it; never sent to the model. */
657
+ readonly nodeId: string;
658
+ readonly kind: PagePartKind;
659
+ readonly label: string;
660
+ readonly before: string;
661
+ readonly after: string;
662
+ }
663
+ interface WordEditContext {
664
+ readonly handles: HandleMap;
665
+ /** Handles the brief says are never written (bound words). */
666
+ readonly never?: ReadonlyArray<NeverWrite>;
667
+ /** The owner's sentence — a fact in it is theirs. */
668
+ readonly sentence?: string;
669
+ /** The owner's words to avoid and own facts (the business reading); none known → none allowed beyond the page's. */
670
+ readonly words?: AssistWordContext;
671
+ }
672
+ interface WordEditsOutcome {
673
+ readonly ok: boolean;
674
+ /** The layout with every change applied — the input untouched; a copy of it when refused. */
675
+ readonly result: SerializedNode[];
676
+ readonly changes: ReadonlyArray<WordChange>;
677
+ readonly issues: ReadonlyArray<AssistIssue>;
678
+ }
679
+ /**
680
+ * Family `words`, applied — the SAME check on the server (before a turn is shown) and in the builder (the trial). All
681
+ * or none; never mutates its input. A part written as paragraphs takes paragraphs (stored as escaped `<p>`), a line
682
+ * takes one line (stored escaped). An edit that changes nothing is dropped.
683
+ */
684
+ declare function applyWordEdits(layout: ReadonlyArray<SerializedNode>, edits: ReadonlyArray<WordEdit>, ctx: WordEditContext): WordEditsOutcome;
685
+ declare enum PageSuggestionKind {
686
+ /** The selection's words, rewritten as the owner asks. */
687
+ Rewrite = "rewrite",
688
+ Shorten = "shorten",
689
+ FillEmpty = "fillEmpty",
690
+ /** Pictures with no description for people who cannot see them. */
691
+ DescribePictures = "describePictures"
692
+ }
693
+ /** A quick action the Ask box offers, built from the brief (never canned text — the client words it). */
694
+ interface PageSuggestion {
695
+ readonly kind: PageSuggestionKind;
696
+ readonly handles: ReadonlyArray<string>;
697
+ }
698
+ /** A heading this long, or a text this long, is worth a "Shorten". */
699
+ declare const SHORTEN_HEADING_FROM_CHARS = 60;
700
+ declare const SHORTEN_TEXT_FROM_CHARS = 280;
701
+ /** S1's quick actions — each only when it applies to the focus. */
702
+ declare function pageSuggestions(summary: SummarizedPage): PageSuggestion[];
703
+ /**
704
+ * The ONE locale a page turn writes in (ai-session-panel-plan §3h) — the server's and the builder's: a language the
705
+ * sentence names ("translate this to English") → the page's own locale → the script its words are written in (a Hebrew
706
+ * page edited in English still gets Hebrew words) → the admin's language.
707
+ */
708
+ declare function pageWriteLocale(layout: ReadonlyArray<SerializedNode>, ctx: {
709
+ readonly sentence: string;
710
+ readonly stored?: string | null;
711
+ readonly uiLang: string;
712
+ }): string;
713
+
504
714
  /**
505
715
  * The turn wire (plan §3d) — what cms-client posts and polls and iox-cms stores and answers, ONE definition both sides
506
716
  * import (generation-core `ai-run.ts` is the precedent for generations). A turn is a document on the jobs runner:
@@ -535,7 +745,24 @@ interface AssistTurnRequest {
535
745
  readonly values?: ContentRecord;
536
746
  /** Field keys the owner changed since the last AI turn — kept unless the sentence names them (rule 9). */
537
747
  readonly ownerEdited?: ReadonlyArray<string>;
748
+ /** A builder surface: the page the turn is about. */
749
+ readonly pageId?: string;
750
+ /** A builder surface: the page's layout as the canvas holds it now (it may be unsaved) — the saved shape. */
751
+ readonly layout?: ReadonlyArray<SerializedNode>;
752
+ /** A builder surface: the selected node ("this"), or none. */
753
+ readonly selectedId?: string | null;
754
+ /** The focus rung the owner widened to (the chip's ✕); absent = what the selection gives. */
755
+ readonly scope?: AssistScope;
756
+ /** A builder surface: the page as the owner names it. */
757
+ readonly page?: {
758
+ readonly name: string;
759
+ readonly route: string;
760
+ };
538
761
  }
762
+ /** What a turn proposes, per family: a field's value (`fields`) or a part's words (`words`). */
763
+ type AssistEdit = FieldEdit | WordEdit;
764
+ /** What a turn changed, as the card says it. */
765
+ type AssistChange = FieldChange | WordChange;
539
766
  /** POST's 202 answer. */
540
767
  interface AssistTurnAccepted {
541
768
  readonly turnId: string;
@@ -574,9 +801,9 @@ interface AssistTurn {
574
801
  readonly model?: string;
575
802
  readonly families?: ReadonlyArray<EditFamily>;
576
803
  readonly reply?: string;
577
- readonly edits?: ReadonlyArray<FieldEdit>;
578
- readonly changes?: ReadonlyArray<FieldChange>;
579
- readonly kept?: ReadonlyArray<FieldChange>;
804
+ readonly edits?: ReadonlyArray<AssistEdit>;
805
+ readonly changes?: ReadonlyArray<AssistChange>;
806
+ readonly kept?: ReadonlyArray<AssistChange>;
580
807
  readonly issues?: ReadonlyArray<AssistIssue>;
581
808
  readonly refusal?: AssistTurnRefusal;
582
809
  readonly credits?: number;
@@ -646,5 +873,5 @@ declare function turnLocale(sentence: string, fields: ReadonlyArray<AssistField>
646
873
  /** The language's own name in the admin's language (`en` → "English" / "אנגלית"). */
647
874
  declare const languageName: (locale: string, uiLang: string) => string;
648
875
 
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 };
876
+ 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, FOCUS_TEXT_CHARS, FieldsAnswerKey, ItemSuggestionKind, LOCALE_NAME_LANGUAGES, MAX_ASSIST_PROPERTIES, MAX_ROUTE_PROPERTIES, MAX_SENTENCE_CHARS, MEMORY_TURNS, NEW_TARGET, NONE_TEXT, NeverWriteReason, PAGE_WORD_SLOTS, PagePartKind, PageSuggestionKind, RouteAnswerKey, SHORTEN_FROM_CHARS, SHORTEN_HEADING_FROM_CHARS, SHORTEN_TEXT_FROM_CHARS, SIBLING_HANDLE_PREFIX, SURFACES, SurfaceStatus, WORDS_PER_PART, WordsAnswerKey, applyFieldEdits, applyWordEdits, assertAssistBudget, assistBudgetIssues, assistFactIssues, assistFields, assistPath, assistSession, assistSessionKey, builtSurfaces, clipText, commitOf, containsHtml, decodeFieldsAnswers, decodeWordsAnswers, escapeText, fieldHandle, fieldsJsonSchema, fieldsNamedIn, isEmptyFieldValue, isPlainRecord, isSessionOf, isTerminalTurn, isWritable, itemLocales, itemSuggestions, languageName, memoryLine, namedLocale, pageSuggestions, pageWriteLocale, paragraphsToRichText, primaryLocale, readFieldValue, readLocaleValues, readRoute, readableWords, resolveHandle, richTextParagraphs, routeJsonSchema, sessionMemory, summarizeItem, summarizePage, surfacePermissions, surfaceSpec, titleField, turnLocale, unknownHandles, validateTurnRequest, wordsJsonSchema };
877
+ export type { AssistChange, AssistEdit, AssistField, AssistIssue, AssistMemoryLine, AssistModelChoice, AssistRoute, AssistSession, AssistTarget, AssistTurn, AssistTurnAccepted, AssistTurnRefusal, AssistTurnRequest, AssistWordContext, Brief, BriefRules, BriefValue, ContentControllerDef, ContentPropertyDef, ContentRecord, ContentTypeSchema, FieldChange, FieldEdit, FieldEditContext, FieldEditsOutcome, FieldsSchemaOptions, FieldsSchemas, HandleMap, HandleResolution, HandleTarget, ItemAround, ItemBrief, ItemBriefContext, ItemBriefField, ItemFocus, ItemSuggestion, ItemSummary, NeverWrite, PageAround, PageBrief, PageBriefContext, PageFocus, PagePart, PageSectionSummary, PageSuggestion, SummarizedItem, SummarizedPage, SurfaceSpec, WordChange, WordEdit, WordEditContext, WordEditsOutcome, WordsSchemas, WrittenWords };