@aglyn/plugins-ai 1.0.0-beta.296 → 1.1.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.
- package/package.json +17 -17
- package/src/lib/components/ai-job-links.d.ts +2 -1
- package/src/lib/components/ai-job-links.js +8 -2
- package/src/lib/components/ai-job-links.js.map +1 -1
- package/src/lib/components/ai-site-start-card.component.d.ts +1 -1
- package/src/lib/components/ai-site-start-card.component.js +40 -13
- package/src/lib/components/ai-site-start-card.component.js.map +1 -1
- package/src/lib/components/ai-site-start-steps.component.d.ts +17 -1
- package/src/lib/components/ai-site-start-steps.component.js +30 -7
- package/src/lib/components/ai-site-start-steps.component.js.map +1 -1
- package/src/lib/components/assist-edit-canvas.d.ts +12 -6
- package/src/lib/components/assist-edit-canvas.js +86 -36
- package/src/lib/components/assist-edit-canvas.js.map +1 -1
- package/src/lib/components/assist-edit-card.component.js +9 -8
- package/src/lib/components/assist-edit-card.component.js.map +1 -1
- package/src/lib/components/assist-page-change-card.component.d.ts +1 -1
- package/src/lib/components/assist-page-change-card.component.js +2 -2
- package/src/lib/components/assist-page-change-card.component.js.map +1 -1
- package/src/lib/components/assist-panel.component.js +16 -9
- package/src/lib/components/assist-panel.component.js.map +1 -1
- package/src/lib/jobs/ai-job-drafts.d.ts +3 -0
- package/src/lib/jobs/ai-job-drafts.js +5 -0
- package/src/lib/jobs/ai-job-drafts.js.map +1 -1
- package/src/lib/jobs/ai-job-edit-step.d.ts +20 -0
- package/src/lib/jobs/ai-job-edit-step.js +39 -3
- package/src/lib/jobs/ai-job-edit-step.js.map +1 -1
- package/src/lib/jobs/ai-job-layout-language.d.ts +10 -0
- package/src/lib/jobs/ai-job-layout-language.js +38 -2
- package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
- package/src/lib/jobs/ai-job-layout-step.js +3 -3
- package/src/lib/jobs/ai-job-layout-step.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.js +15 -7
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.js +39 -1
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame.d.ts +6 -0
- package/src/lib/layout-language/ai-layout-frame.js +85 -30
- package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +5 -0
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/model/ai-edit-job.js +1 -1
- package/src/lib/model/ai-edit-job.js.map +1 -1
- package/src/lib/model/ai-job-notice.js +3 -1
- package/src/lib/model/ai-job-notice.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +175 -0
- package/src/lib/model/ai-site-import-fidelity.js +941 -0
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -0
- package/src/lib/model/ai-site-start.d.ts +27 -0
- package/src/lib/model/ai-site-start.js +41 -0
- package/src/lib/model/ai-site-start.js.map +1 -1
- package/src/lib/model/assist-edit.d.ts +8 -7
- package/src/lib/model/assist-edit.js +4 -4
- package/src/lib/model/assist-edit.js.map +1 -1
- package/src/lib/model/assist-page-change.d.ts +34 -0
- package/src/lib/model/assist-page-change.js +43 -0
- package/src/lib/model/assist-page-change.js.map +1 -1
- package/src/lib/runtime/ai-node-tree.js +18 -2
- package/src/lib/runtime/ai-node-tree.js.map +1 -1
- package/src/lib/server/assist-chat.d.ts +5 -0
- package/src/lib/server/assist-chat.js +16 -3
- package/src/lib/server/assist-chat.js.map +1 -1
- package/src/lib/server/assist-edit.d.ts +12 -7
- package/src/lib/server/assist-edit.js +43 -22
- package/src/lib/server/assist-edit.js.map +1 -1
- package/src/lib/server/assist-page-change.d.ts +12 -0
- package/src/lib/server/assist-page-change.js +24 -2
- package/src/lib/server/assist-page-change.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +62 -0
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +374 -0
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/assist-edit.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ScreenSeoTextField } from '@aglyn/aglyn/app-utils/screen-seo-fields'\nimport type { ReusableComponentProp } from '@aglyn/aglyn/foundation/definitions/platform.types'\nimport type { NodeInteraction } from '@aglyn/aglyn/app-utils/node-interactions'\n\n/**\n * Assist level 3, the edit contract (AGL-2906): what the chat door proposes\n * for a besigner canvas, and what the panel applies once the author says so.\n *\n * Shared by the server, which validates a model's proposal into these\n * shapes, and the client, which applies them. Pure data and pure functions,\n * so the panel imports it without pulling the palette or the runtime.\n *\n * ## The boundary\n *\n * A proposal is OPERATIONS, never a document. The server writes nothing: it\n * answers with ops that name elements already on the canvas, or a validated\n * subtree to insert, and the client applies them through the canvas's own\n * guarded mutators, on confirm, as one undoable step. Every change lands as\n * an unsaved edit on the version the editor has open — a draft — and on a\n * version the live site serves, the editor's own new-version flow runs first.\n */\n\n/** The nine operations a proposal may carry. */\nexport const ASSIST_EDIT_OP_KINDS = [\n 'insertSubtree',\n 'updateProps',\n 'updateSx',\n 'move',\n 'remove',\n 'setSeo',\n 'rename',\n 'saveAsComponent',\n 'addInteraction',\n] as const\n\nexport type AssistEditOpKind = (typeof ASSIST_EDIT_OP_KINDS)[number]\n\n/** The id of the besigner view's edit action — the one edit a view offers. */\nexport const ASSIST_EDIT_ACTION_ID = 'edit.canvas'\n\n/** The name of the structured-output tool a model proposes an edit through. */\nexport const ASSIST_EDIT_TOOL_NAME = 'propose_canvas_edit'\n\n/** The besigner documents the edit rung opens on: those that keep versions. */\nexport type AssistEditDocumentKind = 'screen' | 'component' | 'layout'\n\nexport const ASSIST_EDIT_DOCUMENT_KINDS: readonly AssistEditDocumentKind[] = [\n 'screen',\n 'component',\n 'layout',\n]\n\nconst COLLECTION_KINDS: Readonly<Record<string, AssistEditDocumentKind>> = {\n screens: 'screen',\n components: 'component',\n layouts: 'layout',\n}\n\nconst BESIGNER_DOCUMENT_ROUTE =\n /^\\/[^/]+\\/hosts\\/[^/]+\\/(screens|components|layouts)\\/([A-Za-z0-9_-]{1,64})\\/versions\\/([A-Za-z0-9_-]{1,64})\\/besigner\\/?$/\n\n/** The document a besigner route has open. */\nexport interface AssistEditDocument {\n kind: AssistEditDocumentKind\n documentId: string\n versionId: string\n}\n\n/**\n * The open document off a console path, or null off a route the edit rung\n * serves. Only the versioned editors qualify — a template or an email editor\n * has no version to make first, so the rung does not open there.\n */\nexport function assistEditDocumentOf(route: string): AssistEditDocument | null {\n const match = BESIGNER_DOCUMENT_ROUTE.exec(String(route ?? ''))\n if (!match) return null\n return {\n kind: COLLECTION_KINDS[match[1]],\n documentId: match[2],\n versionId: match[3],\n }\n}\n\n/* ------------------------------------------------------------------ *\n * What the client tells the server about the canvas\n * ------------------------------------------------------------------ */\n\n/** Elements a request describes at most — the selection, its surroundings, its subtree. */\nexport const ASSIST_EDIT_CONTEXT_MAX_NODES = 60\n/** Props described per element at most. */\nexport const ASSIST_EDIT_CONTEXT_MAX_PROPS = 16\n/** Characters of a string prop the selected element carries into a request. */\nexport const ASSIST_EDIT_SELECTED_TEXT_CHARS = 400\n/** Characters of a string prop every other element carries. */\nexport const ASSIST_EDIT_OUTLINE_TEXT_CHARS = 80\n/**\n * Elements a whole-document outline describes at most: one the server reads\n * from the stored document for an edit job, where nothing is selected and\n * nobody can be asked to select what the outline leaves out. Far past a page\n * an AI build or a starter makes (the starter home has 182), so in practice\n * the model sees every element it could be asked about.\n */\nexport const ASSIST_EDIT_WHOLE_MAX_NODES = 400\n\n/**\n * One element of the canvas outline a request carries. Ids, component ids\n * and short primitive values only — never a stored document, never markup.\n */\nexport interface AssistEditCanvasNode {\n id: string\n componentId: string\n /** Null for the document root. */\n parentId: string | null\n /** Position among the parent's children. */\n index: number\n childCount: number\n /** The layer name, when the author gave it one. */\n name?: string\n /** Primitive props, strings shortened. */\n props?: Record<string, string | number | boolean>\n /**\n * The element's own styles — carried for the selected element only, and\n * for every element of a whole-document outline.\n */\n sx?: Record<string, unknown>\n /**\n * Described by its place alone, without props: an element around the\n * selection, there so the model knows it exists and can ask for it.\n */\n brief?: boolean\n /**\n * An element described earlier whose contents this one's are built like,\n * the way the cards of a row are. Its own contents are left out.\n */\n like?: string\n /**\n * The interactions the element carries (AGL-3603), each by its name, the\n * event it listens for and its steps' kinds — carried for the selected\n * element only, so Assist can say what it does. Never a selector, a script\n * or HTML.\n */\n interactions?: AssistEditInteractionSummary[]\n}\n\n/** One interaction on an element, as an outline describes it. */\nexport interface AssistEditInteractionSummary {\n name: string\n event: string\n steps: string[]\n enabled: boolean\n}\n\n/* ------------------------------------------------------------------ *\n * The interactions Assist may add (AGL-3603)\n * ------------------------------------------------------------------ */\n\n/**\n * The events an interaction Assist adds may listen for: those that watch the\n * element it is added to, the way the Besigner's Interactions section offers\n * them on a selected element.\n */\nexport const ASSIST_EDIT_INTERACTION_EVENTS = [\n 'elementClick',\n 'elementHoverEnter',\n 'elementHoverLeave',\n 'elementVisible',\n 'scrollToElement',\n] as const\n\nexport type AssistEditInteractionEvent = (typeof ASSIST_EDIT_INTERACTION_EVENTS)[number]\n\n/**\n * The steps it may take: the platform's basic presentational client steps,\n * which run on every plan and touch no data. No script, no HTML, no\n * attribute, no overlay, no analytics event — and no server step.\n */\nexport const ASSIST_EDIT_INTERACTION_STEPS = [\n 'showElement',\n 'hideElement',\n 'toggleElement',\n 'addClass',\n 'removeClass',\n 'toggleClass',\n 'scrollTo',\n 'playVideo',\n 'openDrawer',\n 'closeDrawer',\n 'toggleDrawer',\n 'openMenu',\n 'closeMenu',\n 'toggleMenu',\n 'redirect',\n 'siteAlert',\n] as const\n\nexport type AssistEditInteractionStep = (typeof ASSIST_EDIT_INTERACTION_STEPS)[number]\n\nexport interface AssistEditCanvasContext {\n /** The element the author has selected, or null. */\n selectedId: string | null\n /**\n * Elements in the whole document, the root included, so the prompt can say\n * how much of it `nodes` leaves out. Absent from an outline sent by a panel\n * that predates it.\n */\n total?: number\n nodes: AssistEditCanvasNode[]\n /**\n * The document as stored, read on the server for a job: every element in\n * page order up to {@link ASSIST_EDIT_WHOLE_MAX_NODES}, each with its\n * settings and styles, and nobody to ask. Never read from a request body.\n */\n whole?: true\n}\n\n/* ------------------------------------------------------------------ *\n * What the server proposes\n * ------------------------------------------------------------------ */\n\n/** An element of a validated subtree, in the flat shape the canvas stores. */\nexport interface AssistEditNode {\n $id: string\n componentId: string\n pluginId?: string\n parentId: string | null\n nodes: string[]\n props: Record<string, unknown>\n sx?: Record<string, unknown>\n hidden?: boolean\n}\n\n/**\n * Every op that acts on an element names the component the server validated\n * it as, so the client can refuse an element that has changed since.\n */\ninterface AssistEditNodeOpBase {\n nodeId: string\n componentId: string\n}\n\nexport interface AssistEditInsertOp {\n op: 'insertSubtree'\n parentId: string\n /** The component the parent was validated as. */\n parentComponentId: string\n /** Position among the parent's children; null appends. */\n index: number | null\n rootId: string\n nodes: Record<string, AssistEditNode>\n}\n\nexport interface AssistEditUpdatePropsOp extends AssistEditNodeOpBase {\n op: 'updateProps'\n /** Merged over the props the element has; nothing else it carries changes. */\n props: Record<string, unknown>\n}\n\nexport interface AssistEditUpdateSxOp extends AssistEditNodeOpBase {\n op: 'updateSx'\n /** Merged over the element's own styles, one key at a time. */\n sx: Record<string, unknown>\n}\n\nexport interface AssistEditMoveOp extends AssistEditNodeOpBase {\n op: 'move'\n parentId: string\n /** The component the new parent was validated as. */\n parentComponentId: string\n index: number | null\n}\n\nexport interface AssistEditRemoveOp extends AssistEditNodeOpBase {\n op: 'remove'\n}\n\nexport interface AssistEditRenameOp extends AssistEditNodeOpBase {\n op: 'rename'\n name: string\n}\n\nexport interface AssistEditSetSeoOp {\n op: 'setSeo'\n fields: Partial<Record<ScreenSeoTextField, string>>\n}\n\n/**\n * A property the promoted subtree declares (AGL-2908), in the shape the\n * Properties dialog stores one — without a default.\n *\n * The server never sees a full value: the outline it read the selection from\n * shortens every string. So the default is read off the live canvas at apply\n * time, from the very field the token is about to replace, which is what\n * makes the instance render what was there a moment before.\n */\nexport type AssistEditComponentProp = Omit<ReusableComponentProp, 'defaultValue'>\n\n/** Where one property's token goes: an element of the selection, and a field of it. */\nexport interface AssistEditPropBinding {\n nodeId: string\n /** The component the element was validated as, so a changed one is refused. */\n componentId: string\n /** A prop of that element, or `hideIf` for a part a Yes / no hides. */\n field: string\n /** The property whose `{{prop.<name>}}` token the field takes. */\n prop: string\n}\n\n/**\n * Save the selection as a reusable component (AGL-2908), with the properties\n * the model proposed and the tokens bound into the tree.\n *\n * The only op that creates a document. It creates exactly the one the manual\n * Save as reusable component creates, through the same host resources route,\n * where the plan's entitlement and the route's allow-list are enforced — and\n * it changes the open canvas the same way that action does, by swapping the\n * promoted subtree for an instance. Nothing is published and nothing is\n * saved: the swap is an unsaved edit on the version the editor has open.\n */\nexport interface AssistEditSaveAsComponentOp extends AssistEditNodeOpBase {\n op: 'saveAsComponent'\n /** The name the component is created under. */\n name: string\n props: AssistEditComponentProp[]\n bindings: AssistEditPropBinding[]\n}\n\n/**\n * Add one interaction to an element (AGL-3603), in the shape the element\n * stores it — its trigger with no selector, which the element's id derives.\n * It never replaces or removes one the element already carries.\n */\nexport interface AssistEditAddInteractionOp extends AssistEditNodeOpBase {\n op: 'addInteraction'\n interaction: NodeInteraction\n /** Every other element a step acts on, each with the component it was validated as. */\n targets: Array<{ nodeId: string; componentId: string }>\n}\n\nexport type AssistEditOp =\n | AssistEditAddInteractionOp\n | AssistEditInsertOp\n | AssistEditUpdatePropsOp\n | AssistEditUpdateSxOp\n | AssistEditMoveOp\n | AssistEditRemoveOp\n | AssistEditRenameOp\n | AssistEditSetSeoOp\n | AssistEditSaveAsComponentOp\n\n/** Where a proposal applies, as the server read it off the request. */\nexport interface AssistEditTarget extends AssistEditDocument {\n hostId: string\n}\n\n/** The counts the card shows before the author decides. */\nexport interface AssistEditDiff {\n /** Elements added, every element of every inserted subtree counted. */\n added: number\n /** Elements removed — each with whatever it contains. */\n removed: number\n propsChanged: number\n stylesChanged: number\n moved: number\n renamed: number\n /** Search fields filled in. */\n seoFields: number\n /** Properties the selection declares once it is saved as a component. */\n componentProps: number\n /** Selections saved as a reusable component — at most one per proposal. */\n componentsSaved: number\n /** Interactions added to elements. */\n interactionsAdded: number\n}\n\n/** The most reasons a proposal carries for the changes validation left out. */\nexport const ASSIST_EDIT_MAX_DROPPED_REASONS = 10\n\nexport interface AssistEditProposal {\n id: typeof ASSIST_EDIT_ACTION_ID\n /** One line, in the model's words, of what the edit does. */\n summary: string\n ops: AssistEditOp[]\n diff: AssistEditDiff\n /** Why each change the model wrote and validation refused was left out. */\n dropped: string[]\n target: AssistEditTarget\n}\n\n/** The counts for a list of ops. */\nexport function summarizeAssistEditOps(ops: readonly AssistEditOp[]): AssistEditDiff {\n const diff: AssistEditDiff = {\n added: 0,\n removed: 0,\n propsChanged: 0,\n stylesChanged: 0,\n moved: 0,\n renamed: 0,\n seoFields: 0,\n componentProps: 0,\n componentsSaved: 0,\n interactionsAdded: 0,\n }\n for (const op of ops) {\n switch (op.op) {\n case 'insertSubtree':\n diff.added += Object.keys(op.nodes).length\n break\n case 'remove':\n diff.removed += 1\n break\n case 'updateProps':\n diff.propsChanged += 1\n break\n case 'updateSx':\n diff.stylesChanged += 1\n break\n case 'move':\n diff.moved += 1\n break\n case 'rename':\n diff.renamed += 1\n break\n case 'setSeo':\n diff.seoFields += Object.keys(op.fields).length\n break\n case 'saveAsComponent':\n diff.componentsSaved += 1\n diff.componentProps += op.props.length\n break\n case 'addInteraction':\n diff.interactionsAdded += 1\n break\n }\n }\n return diff\n}\n\nconst plural = (count: number, one: string, many: string): string =>\n `${count} ${count === 1 ? one : many}`\n\n/** The diff as the lines a person reads, zero counts omitted. */\nexport function describeAssistEditDiff(diff: AssistEditDiff): string[] {\n const lines: string[] = []\n if (diff.added) lines.push(`${plural(diff.added, 'element', 'elements')} added`)\n if (diff.removed) lines.push(`${plural(diff.removed, 'element', 'elements')} removed`)\n if (diff.propsChanged) {\n lines.push(`${plural(diff.propsChanged, 'element’s settings', 'elements’ settings')} changed`)\n }\n if (diff.stylesChanged) {\n lines.push(`${plural(diff.stylesChanged, 'element', 'elements')} restyled`)\n }\n if (diff.moved) lines.push(`${plural(diff.moved, 'element', 'elements')} moved`)\n if (diff.renamed) lines.push(`${plural(diff.renamed, 'layer', 'layers')} renamed`)\n if (diff.seoFields) {\n lines.push(`${plural(diff.seoFields, 'search field', 'search fields')} filled in`)\n }\n if (diff.interactionsAdded) {\n lines.push(`${plural(diff.interactionsAdded, 'interaction', 'interactions')} added`)\n }\n if (diff.componentsSaved) {\n lines.push(\n `saved as a reusable component with ${plural(diff.componentProps, 'property', 'properties')}`,\n )\n }\n return lines\n}\n\n/** The word each op kind is counted under in the activity row. */\nconst OP_COUNT_WORDS: Readonly<Record<AssistEditOpKind, string>> = {\n updateProps: 'set',\n updateSx: 'restyle',\n insertSubtree: 'insert',\n move: 'move',\n remove: 'remove',\n rename: 'rename',\n setSeo: 'seo',\n saveAsComponent: 'component',\n addInteraction: 'interaction',\n}\n\n/** The applied ops counted by kind, as the activity row names them (`{ set: 3, insert: 1 }`). */\nexport function assistEditOpCounts(ops: readonly AssistEditOp[]): Record<string, number> {\n const counts: Record<string, number> = {}\n for (const op of ops) {\n const word = OP_COUNT_WORDS[op.op]\n if (word) counts[word] = (counts[word] ?? 0) + 1\n }\n return counts\n}\n\n/** The words `assistEditOpCounts` counts under, for a door that reads them back. */\nexport const ASSIST_EDIT_OP_COUNT_WORDS: readonly string[] = Object.values(OP_COUNT_WORDS)\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\n/**\n * Whether a `done` event's `edit` field is a proposal this client can apply.\n * The server built it, so this is a shape check rather than a validation: it\n * keeps a malformed or foreign payload from reaching the canvas mutators.\n */\nexport function isAssistEditProposal(value: unknown): value is AssistEditProposal {\n if (!isRecord(value) || value['id'] !== ASSIST_EDIT_ACTION_ID) return false\n const target = value['target']\n if (!isRecord(target)) return false\n if (!ASSIST_EDIT_DOCUMENT_KINDS.includes(target['kind'] as AssistEditDocumentKind)) return false\n if (typeof target['documentId'] !== 'string' || !target['documentId']) return false\n const ops = value['ops']\n if (!Array.isArray(ops) || !ops.length) return false\n return ops.every(\n (op) => isRecord(op) && ASSIST_EDIT_OP_KINDS.includes(op['op'] as AssistEditOpKind),\n )\n}\n\n/* ------------------------------------------------------------------ *\n * What the client reports once the author applied a proposal\n * ------------------------------------------------------------------ */\n\n/** The body of `POST /api/assist/edit-applied`. */\nexport interface AssistEditAppliedReport {\n orgId: string\n hostId: string\n /** The exchange whose answer carried the proposal. */\n exchangeId: string\n documentKind: AssistEditDocumentKind\n documentId: string\n /** The version the edits landed on — a new one when the open one was live. */\n versionId: string\n opCounts: Record<string, number>\n}\n"],"names":["ASSIST_EDIT_OP_KINDS","ASSIST_EDIT_ACTION_ID","ASSIST_EDIT_TOOL_NAME","ASSIST_EDIT_DOCUMENT_KINDS","COLLECTION_KINDS","screens","components","layouts","BESIGNER_DOCUMENT_ROUTE","assistEditDocumentOf","route","match","exec","String","kind","documentId","versionId","ASSIST_EDIT_CONTEXT_MAX_NODES","ASSIST_EDIT_CONTEXT_MAX_PROPS","ASSIST_EDIT_SELECTED_TEXT_CHARS","ASSIST_EDIT_OUTLINE_TEXT_CHARS","ASSIST_EDIT_WHOLE_MAX_NODES","ASSIST_EDIT_INTERACTION_EVENTS","ASSIST_EDIT_INTERACTION_STEPS","ASSIST_EDIT_MAX_DROPPED_REASONS","summarizeAssistEditOps","ops","diff","added","removed","propsChanged","stylesChanged","moved","renamed","seoFields","componentProps","componentsSaved","interactionsAdded","op","Object","keys","nodes","length","fields","props","plural","count","one","many","describeAssistEditDiff","lines","push","OP_COUNT_WORDS","updateProps","updateSx","insertSubtree","move","remove","rename","setSeo","saveAsComponent","addInteraction","assistEditOpCounts","counts","word","ASSIST_EDIT_OP_COUNT_WORDS","values","isRecord","value","Array","isArray","isAssistEditProposal","target","includes","every"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAMD;;;;;;;;;;;;;;;;CAgBC,GAED,8CAA8C,GAC9C,OAAO,MAAMA,uBAAuB;IAClC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAS;AAIV,4EAA4E,GAC5E,OAAO,MAAMC,wBAAwB,cAAa;AAElD,6EAA6E,GAC7E,OAAO,MAAMC,wBAAwB,sBAAqB;AAK1D,OAAO,MAAMC,6BAAgE;IAC3E;IACA;IACA;CACD,CAAA;AAED,MAAMC,mBAAqE;IACzEC,SAAS;IACTC,YAAY;IACZC,SAAS;AACX;AAEA,MAAMC,0BACJ;AASF;;;;CAIC,GACD,OAAO,SAASC,qBAAqBC,KAAa;IAChD,MAAMC,QAAQH,wBAAwBI,IAAI,CAACC,OAAOH,gBAAAA,QAAS;IAC3D,IAAI,CAACC,OAAO,OAAO;IACnB,OAAO;QACLG,MAAMV,gBAAgB,CAACO,KAAK,CAAC,EAAE,CAAC;QAChCI,YAAYJ,KAAK,CAAC,EAAE;QACpBK,WAAWL,KAAK,CAAC,EAAE;IACrB;AACF;AAEA;;sEAEsE,GAEtE,yFAAyF,GACzF,OAAO,MAAMM,gCAAgC,GAAE;AAC/C,yCAAyC,GACzC,OAAO,MAAMC,gCAAgC,GAAE;AAC/C,6EAA6E,GAC7E,OAAO,MAAMC,kCAAkC,IAAG;AAClD,6DAA6D,GAC7D,OAAO,MAAMC,iCAAiC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,KAAK;AAElE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/assist-edit.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ScreenSeoTextField } from '@aglyn/aglyn/app-utils/screen-seo-fields'\nimport type { ReusableComponentProp } from '@aglyn/aglyn/foundation/definitions/platform.types'\nimport type { NodeInteraction } from '@aglyn/aglyn/app-utils/node-interactions'\n\n/**\n * Assist level 3, the edit contract (AGL-2906): what the chat door proposes\n * for a besigner canvas, and what the panel applies once the author says so.\n *\n * Shared by the server, which validates a model's proposal into these\n * shapes, and the client, which applies them. Pure data and pure functions,\n * so the panel imports it without pulling the palette or the runtime.\n *\n * ## The boundary\n *\n * A proposal is OPERATIONS, never a document. The server writes nothing: it\n * answers with ops that name elements already on the canvas, or a validated\n * subtree to insert, and the client applies them through the canvas's own\n * guarded mutators, on confirm, as one undoable step. Every change lands as\n * an unsaved edit on the version the editor has open — a draft — and on a\n * version the live site serves, the editor's own new-version flow runs first.\n */\n\n/** The nine operations a proposal may carry. */\nexport const ASSIST_EDIT_OP_KINDS = [\n 'insertSubtree',\n 'updateProps',\n 'updateSx',\n 'move',\n 'remove',\n 'setSeo',\n 'rename',\n 'saveAsComponent',\n 'addInteraction',\n] as const\n\nexport type AssistEditOpKind = (typeof ASSIST_EDIT_OP_KINDS)[number]\n\n/** The id of the besigner view's edit action — the one edit a view offers. */\nexport const ASSIST_EDIT_ACTION_ID = 'edit.canvas'\n\n/** The name of the structured-output tool a model proposes an edit through. */\nexport const ASSIST_EDIT_TOOL_NAME = 'propose_canvas_edit'\n\n/** The besigner documents the edit rung opens on: those that keep versions. */\nexport type AssistEditDocumentKind = 'screen' | 'component' | 'layout'\n\nexport const ASSIST_EDIT_DOCUMENT_KINDS: readonly AssistEditDocumentKind[] = [\n 'screen',\n 'component',\n 'layout',\n]\n\nconst COLLECTION_KINDS: Readonly<Record<string, AssistEditDocumentKind>> = {\n screens: 'screen',\n components: 'component',\n layouts: 'layout',\n}\n\nconst BESIGNER_DOCUMENT_ROUTE =\n /^\\/[^/]+\\/hosts\\/[^/]+\\/(screens|components|layouts)\\/([A-Za-z0-9_-]{1,64})\\/versions\\/([A-Za-z0-9_-]{1,64})\\/besigner\\/?$/\n\n/** The document a besigner route has open. */\nexport interface AssistEditDocument {\n kind: AssistEditDocumentKind\n documentId: string\n versionId: string\n}\n\n/**\n * The open document off a console path, or null off a route the edit rung\n * serves. Only the versioned editors qualify — a template or an email editor\n * has no version to make first, so the rung does not open there.\n */\nexport function assistEditDocumentOf(route: string): AssistEditDocument | null {\n const match = BESIGNER_DOCUMENT_ROUTE.exec(String(route ?? ''))\n if (!match) return null\n return {\n kind: COLLECTION_KINDS[match[1]],\n documentId: match[2],\n versionId: match[3],\n }\n}\n\n/* ------------------------------------------------------------------ *\n * What the client tells the server about the canvas\n * ------------------------------------------------------------------ */\n\n/** Elements a request describes at most — the selection, its surroundings, its subtree. */\nexport const ASSIST_EDIT_CONTEXT_MAX_NODES = 60\n/** Props described per element at most. */\nexport const ASSIST_EDIT_CONTEXT_MAX_PROPS = 16\n/** Characters of a string prop the selected element carries into a request. */\nexport const ASSIST_EDIT_SELECTED_TEXT_CHARS = 400\n/** Characters of a string prop every other element carries. */\nexport const ASSIST_EDIT_OUTLINE_TEXT_CHARS = 80\n/**\n * Elements a whole-document outline describes at most: one the server reads\n * from the stored document for an edit job, or the chat in the Besigner sends\n * of the open canvas (AGL-4116). Far past a page an AI build or a starter makes\n * (the starter home has 182), so in practice the model sees every element it\n * could be asked about.\n */\nexport const ASSIST_EDIT_WHOLE_MAX_NODES = 400\n\n/**\n * One element of the canvas outline a request carries. Ids, component ids\n * and short primitive values only — never a stored document, never markup.\n */\nexport interface AssistEditCanvasNode {\n id: string\n componentId: string\n /** Null for the document root. */\n parentId: string | null\n /** Position among the parent's children. */\n index: number\n childCount: number\n /** The layer name, when the author gave it one. */\n name?: string\n /** Primitive props, strings shortened. */\n props?: Record<string, string | number | boolean>\n /**\n * The element's own styles — carried for the selected element only, and\n * for every element of a whole-document outline.\n */\n sx?: Record<string, unknown>\n /**\n * Described by its place alone, without props: an element around the\n * selection, there so the model knows it exists and can ask for it.\n */\n brief?: boolean\n /**\n * An element described earlier whose contents this one's are built like,\n * the way the cards of a row are. Its own contents are left out.\n */\n like?: string\n /**\n * The interactions the element carries (AGL-3603), each by its name, the\n * event it listens for and its steps' kinds — carried for the selected\n * element only, so Assist can say what it does. Never a selector, a script\n * or HTML.\n */\n interactions?: AssistEditInteractionSummary[]\n}\n\n/** One interaction on an element, as an outline describes it. */\nexport interface AssistEditInteractionSummary {\n name: string\n event: string\n steps: string[]\n enabled: boolean\n}\n\n/* ------------------------------------------------------------------ *\n * The interactions Assist may add (AGL-3603)\n * ------------------------------------------------------------------ */\n\n/**\n * The events an interaction Assist adds may listen for: those that watch the\n * element it is added to, the way the Besigner's Interactions section offers\n * them on a selected element.\n */\nexport const ASSIST_EDIT_INTERACTION_EVENTS = [\n 'elementClick',\n 'elementHoverEnter',\n 'elementHoverLeave',\n 'elementVisible',\n 'scrollToElement',\n] as const\n\nexport type AssistEditInteractionEvent = (typeof ASSIST_EDIT_INTERACTION_EVENTS)[number]\n\n/**\n * The steps it may take: the platform's basic presentational client steps,\n * which run on every plan and touch no data. No script, no HTML, no\n * attribute, no overlay, no analytics event — and no server step.\n */\nexport const ASSIST_EDIT_INTERACTION_STEPS = [\n 'showElement',\n 'hideElement',\n 'toggleElement',\n 'addClass',\n 'removeClass',\n 'toggleClass',\n 'scrollTo',\n 'playVideo',\n 'openDrawer',\n 'closeDrawer',\n 'toggleDrawer',\n 'openMenu',\n 'closeMenu',\n 'toggleMenu',\n 'redirect',\n 'siteAlert',\n] as const\n\nexport type AssistEditInteractionStep = (typeof ASSIST_EDIT_INTERACTION_STEPS)[number]\n\nexport interface AssistEditCanvasContext {\n /** The element the author has selected, or null. */\n selectedId: string | null\n /**\n * Elements in the whole document, the root included, so the prompt can say\n * how much of it `nodes` leaves out. Absent from an outline sent by a panel\n * that predates it.\n */\n total?: number\n nodes: AssistEditCanvasNode[]\n /**\n * The whole document, every element in page order up to\n * {@link ASSIST_EDIT_WHOLE_MAX_NODES}, each with its settings and styles:\n * read from the store for a job, or from the open canvas for the chat in the\n * Besigner (AGL-4116).\n */\n whole?: true\n}\n\n/* ------------------------------------------------------------------ *\n * What the server proposes\n * ------------------------------------------------------------------ */\n\n/** An element of a validated subtree, in the flat shape the canvas stores. */\nexport interface AssistEditNode {\n $id: string\n componentId: string\n pluginId?: string\n parentId: string | null\n nodes: string[]\n props: Record<string, unknown>\n sx?: Record<string, unknown>\n hidden?: boolean\n}\n\n/**\n * Every op that acts on an element names the component the server validated\n * it as, so the client can refuse an element that has changed since.\n */\ninterface AssistEditNodeOpBase {\n nodeId: string\n componentId: string\n}\n\nexport interface AssistEditInsertOp {\n op: 'insertSubtree'\n parentId: string\n /** The component the parent was validated as. */\n parentComponentId: string\n /** Position among the parent's children; null appends. */\n index: number | null\n rootId: string\n nodes: Record<string, AssistEditNode>\n}\n\nexport interface AssistEditUpdatePropsOp extends AssistEditNodeOpBase {\n op: 'updateProps'\n /** Merged over the props the element has; nothing else it carries changes. */\n props: Record<string, unknown>\n}\n\nexport interface AssistEditUpdateSxOp extends AssistEditNodeOpBase {\n op: 'updateSx'\n /** Merged over the element's own styles, one key at a time. */\n sx: Record<string, unknown>\n}\n\nexport interface AssistEditMoveOp extends AssistEditNodeOpBase {\n op: 'move'\n parentId: string\n /** The component the new parent was validated as. */\n parentComponentId: string\n index: number | null\n}\n\nexport interface AssistEditRemoveOp extends AssistEditNodeOpBase {\n op: 'remove'\n}\n\nexport interface AssistEditRenameOp extends AssistEditNodeOpBase {\n op: 'rename'\n name: string\n}\n\nexport interface AssistEditSetSeoOp {\n op: 'setSeo'\n fields: Partial<Record<ScreenSeoTextField, string>>\n}\n\n/**\n * A property the promoted subtree declares (AGL-2908), in the shape the\n * Properties dialog stores one — without a default.\n *\n * The server never sees a full value: the outline it read the selection from\n * shortens every string. So the default is read off the live canvas at apply\n * time, from the very field the token is about to replace, which is what\n * makes the instance render what was there a moment before.\n */\nexport type AssistEditComponentProp = Omit<ReusableComponentProp, 'defaultValue'>\n\n/** Where one property's token goes: an element of the selection, and a field of it. */\nexport interface AssistEditPropBinding {\n nodeId: string\n /** The component the element was validated as, so a changed one is refused. */\n componentId: string\n /** A prop of that element, or `hideIf` for a part a Yes / no hides. */\n field: string\n /** The property whose `{{prop.<name>}}` token the field takes. */\n prop: string\n}\n\n/**\n * Save the selection as a reusable component (AGL-2908), with the properties\n * the model proposed and the tokens bound into the tree.\n *\n * The only op that creates a document. It creates exactly the one the manual\n * Save as reusable component creates, through the same host resources route,\n * where the plan's entitlement and the route's allow-list are enforced — and\n * it changes the open canvas the same way that action does, by swapping the\n * promoted subtree for an instance. Nothing is published and nothing is\n * saved: the swap is an unsaved edit on the version the editor has open.\n */\nexport interface AssistEditSaveAsComponentOp extends AssistEditNodeOpBase {\n op: 'saveAsComponent'\n /** The name the component is created under. */\n name: string\n props: AssistEditComponentProp[]\n bindings: AssistEditPropBinding[]\n}\n\n/**\n * Add one interaction to an element (AGL-3603), in the shape the element\n * stores it — its trigger with no selector, which the element's id derives.\n * It never replaces or removes one the element already carries.\n */\nexport interface AssistEditAddInteractionOp extends AssistEditNodeOpBase {\n op: 'addInteraction'\n interaction: NodeInteraction\n /** Every other element a step acts on, each with the component it was validated as. */\n targets: Array<{ nodeId: string; componentId: string }>\n}\n\nexport type AssistEditOp =\n | AssistEditAddInteractionOp\n | AssistEditInsertOp\n | AssistEditUpdatePropsOp\n | AssistEditUpdateSxOp\n | AssistEditMoveOp\n | AssistEditRemoveOp\n | AssistEditRenameOp\n | AssistEditSetSeoOp\n | AssistEditSaveAsComponentOp\n\n/** Where a proposal applies, as the server read it off the request. */\nexport interface AssistEditTarget extends AssistEditDocument {\n hostId: string\n}\n\n/** The counts the card shows before the author decides. */\nexport interface AssistEditDiff {\n /** Elements added, every element of every inserted subtree counted. */\n added: number\n /** Elements removed — each with whatever it contains. */\n removed: number\n propsChanged: number\n stylesChanged: number\n moved: number\n renamed: number\n /** Search fields filled in. */\n seoFields: number\n /** Properties the selection declares once it is saved as a component. */\n componentProps: number\n /** Selections saved as a reusable component — at most one per proposal. */\n componentsSaved: number\n /** Interactions added to elements. */\n interactionsAdded: number\n}\n\n/** The most reasons a proposal carries for the changes validation left out. */\nexport const ASSIST_EDIT_MAX_DROPPED_REASONS = 10\n\nexport interface AssistEditProposal {\n id: typeof ASSIST_EDIT_ACTION_ID\n /** One line, in the model's words, of what the edit does. */\n summary: string\n ops: AssistEditOp[]\n diff: AssistEditDiff\n /** Why each change the model wrote and validation refused was left out. */\n dropped: string[]\n target: AssistEditTarget\n}\n\n/** The counts for a list of ops. */\nexport function summarizeAssistEditOps(ops: readonly AssistEditOp[]): AssistEditDiff {\n const diff: AssistEditDiff = {\n added: 0,\n removed: 0,\n propsChanged: 0,\n stylesChanged: 0,\n moved: 0,\n renamed: 0,\n seoFields: 0,\n componentProps: 0,\n componentsSaved: 0,\n interactionsAdded: 0,\n }\n for (const op of ops) {\n switch (op.op) {\n case 'insertSubtree':\n diff.added += Object.keys(op.nodes).length\n break\n case 'remove':\n diff.removed += 1\n break\n case 'updateProps':\n diff.propsChanged += 1\n break\n case 'updateSx':\n diff.stylesChanged += 1\n break\n case 'move':\n diff.moved += 1\n break\n case 'rename':\n diff.renamed += 1\n break\n case 'setSeo':\n diff.seoFields += Object.keys(op.fields).length\n break\n case 'saveAsComponent':\n diff.componentsSaved += 1\n diff.componentProps += op.props.length\n break\n case 'addInteraction':\n diff.interactionsAdded += 1\n break\n }\n }\n return diff\n}\n\nconst plural = (count: number, one: string, many: string): string =>\n `${count} ${count === 1 ? one : many}`\n\n/** The diff as the lines a person reads, zero counts omitted. */\nexport function describeAssistEditDiff(diff: AssistEditDiff): string[] {\n const lines: string[] = []\n if (diff.added) lines.push(`${plural(diff.added, 'element', 'elements')} added`)\n if (diff.removed) lines.push(`${plural(diff.removed, 'element', 'elements')} removed`)\n if (diff.propsChanged) {\n lines.push(`${plural(diff.propsChanged, 'element’s settings', 'elements’ settings')} changed`)\n }\n if (diff.stylesChanged) {\n lines.push(`${plural(diff.stylesChanged, 'element', 'elements')} restyled`)\n }\n if (diff.moved) lines.push(`${plural(diff.moved, 'element', 'elements')} moved`)\n if (diff.renamed) lines.push(`${plural(diff.renamed, 'layer', 'layers')} renamed`)\n if (diff.seoFields) {\n lines.push(`${plural(diff.seoFields, 'search field', 'search fields')} filled in`)\n }\n if (diff.interactionsAdded) {\n lines.push(`${plural(diff.interactionsAdded, 'interaction', 'interactions')} added`)\n }\n if (diff.componentsSaved) {\n lines.push(\n `saved as a reusable component with ${plural(diff.componentProps, 'property', 'properties')}`,\n )\n }\n return lines\n}\n\n/** The word each op kind is counted under in the activity row. */\nconst OP_COUNT_WORDS: Readonly<Record<AssistEditOpKind, string>> = {\n updateProps: 'set',\n updateSx: 'restyle',\n insertSubtree: 'insert',\n move: 'move',\n remove: 'remove',\n rename: 'rename',\n setSeo: 'seo',\n saveAsComponent: 'component',\n addInteraction: 'interaction',\n}\n\n/** The applied ops counted by kind, as the activity row names them (`{ set: 3, insert: 1 }`). */\nexport function assistEditOpCounts(ops: readonly AssistEditOp[]): Record<string, number> {\n const counts: Record<string, number> = {}\n for (const op of ops) {\n const word = OP_COUNT_WORDS[op.op]\n if (word) counts[word] = (counts[word] ?? 0) + 1\n }\n return counts\n}\n\n/** The words `assistEditOpCounts` counts under, for a door that reads them back. */\nexport const ASSIST_EDIT_OP_COUNT_WORDS: readonly string[] = Object.values(OP_COUNT_WORDS)\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\n/**\n * Whether a `done` event's `edit` field is a proposal this client can apply.\n * The server built it, so this is a shape check rather than a validation: it\n * keeps a malformed or foreign payload from reaching the canvas mutators.\n */\nexport function isAssistEditProposal(value: unknown): value is AssistEditProposal {\n if (!isRecord(value) || value['id'] !== ASSIST_EDIT_ACTION_ID) return false\n const target = value['target']\n if (!isRecord(target)) return false\n if (!ASSIST_EDIT_DOCUMENT_KINDS.includes(target['kind'] as AssistEditDocumentKind)) return false\n if (typeof target['documentId'] !== 'string' || !target['documentId']) return false\n const ops = value['ops']\n if (!Array.isArray(ops) || !ops.length) return false\n return ops.every(\n (op) => isRecord(op) && ASSIST_EDIT_OP_KINDS.includes(op['op'] as AssistEditOpKind),\n )\n}\n\n/* ------------------------------------------------------------------ *\n * What the client reports once the author applied a proposal\n * ------------------------------------------------------------------ */\n\n/** The body of `POST /api/assist/edit-applied`. */\nexport interface AssistEditAppliedReport {\n orgId: string\n hostId: string\n /** The exchange whose answer carried the proposal. */\n exchangeId: string\n documentKind: AssistEditDocumentKind\n documentId: string\n /** The version the edits landed on — a new one when the open one was live. */\n versionId: string\n opCounts: Record<string, number>\n}\n"],"names":["ASSIST_EDIT_OP_KINDS","ASSIST_EDIT_ACTION_ID","ASSIST_EDIT_TOOL_NAME","ASSIST_EDIT_DOCUMENT_KINDS","COLLECTION_KINDS","screens","components","layouts","BESIGNER_DOCUMENT_ROUTE","assistEditDocumentOf","route","match","exec","String","kind","documentId","versionId","ASSIST_EDIT_CONTEXT_MAX_NODES","ASSIST_EDIT_CONTEXT_MAX_PROPS","ASSIST_EDIT_SELECTED_TEXT_CHARS","ASSIST_EDIT_OUTLINE_TEXT_CHARS","ASSIST_EDIT_WHOLE_MAX_NODES","ASSIST_EDIT_INTERACTION_EVENTS","ASSIST_EDIT_INTERACTION_STEPS","ASSIST_EDIT_MAX_DROPPED_REASONS","summarizeAssistEditOps","ops","diff","added","removed","propsChanged","stylesChanged","moved","renamed","seoFields","componentProps","componentsSaved","interactionsAdded","op","Object","keys","nodes","length","fields","props","plural","count","one","many","describeAssistEditDiff","lines","push","OP_COUNT_WORDS","updateProps","updateSx","insertSubtree","move","remove","rename","setSeo","saveAsComponent","addInteraction","assistEditOpCounts","counts","word","ASSIST_EDIT_OP_COUNT_WORDS","values","isRecord","value","Array","isArray","isAssistEditProposal","target","includes","every"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAMD;;;;;;;;;;;;;;;;CAgBC,GAED,8CAA8C,GAC9C,OAAO,MAAMA,uBAAuB;IAClC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAS;AAIV,4EAA4E,GAC5E,OAAO,MAAMC,wBAAwB,cAAa;AAElD,6EAA6E,GAC7E,OAAO,MAAMC,wBAAwB,sBAAqB;AAK1D,OAAO,MAAMC,6BAAgE;IAC3E;IACA;IACA;CACD,CAAA;AAED,MAAMC,mBAAqE;IACzEC,SAAS;IACTC,YAAY;IACZC,SAAS;AACX;AAEA,MAAMC,0BACJ;AASF;;;;CAIC,GACD,OAAO,SAASC,qBAAqBC,KAAa;IAChD,MAAMC,QAAQH,wBAAwBI,IAAI,CAACC,OAAOH,gBAAAA,QAAS;IAC3D,IAAI,CAACC,OAAO,OAAO;IACnB,OAAO;QACLG,MAAMV,gBAAgB,CAACO,KAAK,CAAC,EAAE,CAAC;QAChCI,YAAYJ,KAAK,CAAC,EAAE;QACpBK,WAAWL,KAAK,CAAC,EAAE;IACrB;AACF;AAEA;;sEAEsE,GAEtE,yFAAyF,GACzF,OAAO,MAAMM,gCAAgC,GAAE;AAC/C,yCAAyC,GACzC,OAAO,MAAMC,gCAAgC,GAAE;AAC/C,6EAA6E,GAC7E,OAAO,MAAMC,kCAAkC,IAAG;AAClD,6DAA6D,GAC7D,OAAO,MAAMC,iCAAiC,GAAE;AAChD;;;;;;CAMC,GACD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 +84,37 @@ export declare function assistPageChangeDraftVersion(changes: ReadonlyArray<{
|
|
|
84
84
|
pageChange?: AssistPageChangeProposal | null;
|
|
85
85
|
pageChangeJob?: AiJobSummary | null;
|
|
86
86
|
}>, pageId: string): string | null;
|
|
87
|
+
/** What a page change came to, as the turn that asked for it holds it. */
|
|
88
|
+
export interface AssistPageChangeTurn {
|
|
89
|
+
pageChange?: AssistPageChangeProposal | null;
|
|
90
|
+
pageChangeJob?: AiJobSummary | null;
|
|
91
|
+
pageChangeNotice?: string | null;
|
|
92
|
+
}
|
|
93
|
+
/** A turn of a thread, as far as what it changed goes. */
|
|
94
|
+
export interface AssistOutcomeTurn extends AssistPageChangeTurn {
|
|
95
|
+
edit?: {
|
|
96
|
+
summary: string;
|
|
97
|
+
} | null;
|
|
98
|
+
editOutcome?: {
|
|
99
|
+
kind: string;
|
|
100
|
+
message?: string;
|
|
101
|
+
} | null;
|
|
102
|
+
}
|
|
103
|
+
/** How many of a thread's outcomes ride a question, the newest kept. */
|
|
104
|
+
export declare const ASSIST_OUTCOMES_SENT = 12;
|
|
105
|
+
/**
|
|
106
|
+
* What became of a turn's page change, or null when the turn asked for none
|
|
107
|
+
* (AGL-4116).
|
|
108
|
+
*/
|
|
109
|
+
export declare function assistPageChangeOutcome(turn: AssistPageChangeTurn): string | null;
|
|
110
|
+
/**
|
|
111
|
+
* What a thread's changes came to, oldest first, for the next question to
|
|
112
|
+
* carry apart from the thread's words (AGL-4116).
|
|
113
|
+
*
|
|
114
|
+
* Apart, because a note added to the assistant's own turn reads as the model
|
|
115
|
+
* saying so: it is told never to say a change is made, so it took its record
|
|
116
|
+
* of a saved draft for its own mistake and took the change back, telling the
|
|
117
|
+
* person nothing had changed. The chat sees a thread's text and nothing else,
|
|
118
|
+
* so without these it cannot know what happened at all.
|
|
119
|
+
*/
|
|
120
|
+
export declare function assistThreadOutcomes(turns: readonly AssistOutcomeTurn[]): string[];
|
|
@@ -82,5 +82,48 @@ function isRecord(value) {
|
|
|
82
82
|
}
|
|
83
83
|
return null;
|
|
84
84
|
}
|
|
85
|
+
/** How many of a thread's outcomes ride a question, the newest kept. */ export const ASSIST_OUTCOMES_SENT = 12;
|
|
86
|
+
/**
|
|
87
|
+
* What became of a turn's page change, or null when the turn asked for none
|
|
88
|
+
* (AGL-4116).
|
|
89
|
+
*/ export function assistPageChangeOutcome(turn) {
|
|
90
|
+
var _turn_pageChangeJob, _output_note;
|
|
91
|
+
const proposal = turn.pageChange;
|
|
92
|
+
if (!proposal) return null;
|
|
93
|
+
const change = `Page change on ${proposal.pageName}`;
|
|
94
|
+
if (turn.pageChangeNotice) return `${change} not started: ${turn.pageChangeNotice}`;
|
|
95
|
+
const job = (_turn_pageChangeJob = turn.pageChangeJob) != null ? _turn_pageChangeJob : null;
|
|
96
|
+
const output = assistPageChangeOutput(job);
|
|
97
|
+
if (output) return `${change}: ${(_output_note = output.note) != null ? _output_note : 'saved, not published.'}`;
|
|
98
|
+
if ((job == null ? void 0 : job.status) === 'failed' || (job == null ? void 0 : job.status) === 'canceled') {
|
|
99
|
+
var _job_error;
|
|
100
|
+
return `${change} not made: ${(_job_error = job.error) != null ? _job_error : job.status}`;
|
|
101
|
+
}
|
|
102
|
+
return `${change} being made.`;
|
|
103
|
+
}
|
|
104
|
+
/** What became of a turn's edit card, or null while it waits for an answer. */ function assistEditOutcome(turn) {
|
|
105
|
+
var _turn_editOutcome, _turn_editOutcome1, _turn_editOutcome2;
|
|
106
|
+
if (!turn.edit) return null;
|
|
107
|
+
const summary = turn.edit.summary;
|
|
108
|
+
if (((_turn_editOutcome = turn.editOutcome) == null ? void 0 : _turn_editOutcome.kind) === 'applied') return `Applied to the open canvas as an unsaved change: ${summary}`;
|
|
109
|
+
if (((_turn_editOutcome1 = turn.editOutcome) == null ? void 0 : _turn_editOutcome1.kind) === 'dismissed') return `Not applied, they turned it down: ${summary}`;
|
|
110
|
+
if (((_turn_editOutcome2 = turn.editOutcome) == null ? void 0 : _turn_editOutcome2.kind) === 'failed') return `Could not be applied: ${summary}`;
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* What a thread's changes came to, oldest first, for the next question to
|
|
115
|
+
* carry apart from the thread's words (AGL-4116).
|
|
116
|
+
*
|
|
117
|
+
* Apart, because a note added to the assistant's own turn reads as the model
|
|
118
|
+
* saying so: it is told never to say a change is made, so it took its record
|
|
119
|
+
* of a saved draft for its own mistake and took the change back, telling the
|
|
120
|
+
* person nothing had changed. The chat sees a thread's text and nothing else,
|
|
121
|
+
* so without these it cannot know what happened at all.
|
|
122
|
+
*/ export function assistThreadOutcomes(turns) {
|
|
123
|
+
return turns.flatMap((turn)=>[
|
|
124
|
+
assistPageChangeOutcome(turn),
|
|
125
|
+
assistEditOutcome(turn)
|
|
126
|
+
]).filter((outcome)=>outcome !== null).slice(-ASSIST_OUTCOMES_SENT);
|
|
127
|
+
}
|
|
85
128
|
|
|
86
129
|
//# sourceMappingURL=assist-page-change.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/assist-page-change.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A change to a page the site already has, asked in the Assist chat\n * (AGL-4116). No plan and no new page: the panel starts one `edit` job on\n * that page, which saves the change into the page's draft — on every plan,\n * the draft the Besigner offers with Open draft — and the card links the\n * page in the Besigner, where the person checks it and publishes it. Only\n * when they ask for a new version, and the plan keeps version history, is\n * the change saved as a new unpublished version instead.\n *\n * Asked through a build, a change to the home page came back as a second\n * page at `/` the plan generated from scratch, and every follow-up made\n * another plan. This is the short way, for the request that only changes\n * what is there.\n *\n * Shared by the chat door that resolves it and the panel that starts it.\n * Pure: no request, no React.\n */\n\nimport type { AiJobOutput, AiJobSummary } from './ai-jobs.types'\n\n/** The strict tool the chat model asks for a change to a page through. */\nexport const ASSIST_PAGE_CHANGE_TOOL_NAME = 'change_page'\n\n/** The proposal's fixed id, as `assistant_proposal_shown` records it. */\nexport const ASSIST_PAGE_CHANGE_ACTION_ID = 'page-change'\n\n/** The longest one-line summary the card shows. */\nexport const ASSIST_PAGE_CHANGE_SUMMARY_MAX_CHARS = 200\n\nconst DOCUMENT_ID = /^[A-Za-z0-9_-]{1,100}$/\n\nexport interface AssistPageChangeProposal {\n id: typeof ASSIST_PAGE_CHANGE_ACTION_ID\n /** The site the request was asked on; the job is created for it. */\n hostId: string\n /** The page to change: one the site has, by its id. */\n pageId: string\n /** The page's name, as the site's list of pages gives it. */\n pageName: string\n /** What to change on it, in the person's words. */\n brief: string\n /** One line saying what will change. */\n summary: string\n /** They asked for a new version of the page; otherwise the change goes into its draft. */\n newVersion?: boolean\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** Shape-checks a page change before it can start a job. */\nexport function isAssistPageChangeProposal(value: unknown): value is AssistPageChangeProposal {\n if (!isRecord(value) || value['id'] !== ASSIST_PAGE_CHANGE_ACTION_ID) return false\n return (\n typeof value['hostId'] === 'string' &&\n DOCUMENT_ID.test(value['hostId']) &&\n typeof value['pageId'] === 'string' &&\n DOCUMENT_ID.test(value['pageId']) &&\n typeof value['pageName'] === 'string' &&\n typeof value['brief'] === 'string' &&\n value['brief'].trim().length > 0 &&\n typeof value['summary'] === 'string' &&\n (value['newVersion'] === undefined || typeof value['newVersion'] === 'boolean')\n )\n}\n\n/**\n * The body of `POST /api/ai/jobs` a page change starts: an `edit` of the\n * page. `versionId` is the version an earlier change in the same\n * conversation wrote to, so a follow-up changes that version's draft rather\n * than starting again from the published page.\n */\nexport function assistPageChangeJobRequest(\n orgId: string,\n proposal: AssistPageChangeProposal,\n versionId: string | null,\n): {\n orgId: string\n hostId: string\n kind: 'edit'\n brief: string\n inputs: { target: string; targetKind: 'screen'; versionId?: string; newVersion?: true }\n} {\n return {\n orgId,\n hostId: proposal.hostId,\n kind: 'edit',\n brief: proposal.brief,\n inputs: {\n target: proposal.pageId,\n targetKind: 'screen',\n ...(versionId ? { versionId } : {}),\n ...(proposal.newVersion ? { newVersion: true as const } : {}),\n },\n }\n}\n\n/** The version a finished change wrote to the page, or `null` before there is one. */\nexport function assistPageChangeOutput(job: Pick<AiJobSummary, 'status' | 'outputs'> | null): AiJobOutput | null {\n if (!job || job.status !== 'done') return null\n return job.outputs.find((output) => output.resource === 'screen' && Boolean(output.versionId)) ?? null\n}\n\n/**\n * The version a new change to `pageId` continues (AGL-4116): the one the\n * conversation's latest finished change to that page wrote to — its draft\n * holds that change — or `null` to start from the page as it is.\n */\nexport function assistPageChangeDraftVersion(\n changes: ReadonlyArray<{ pageChange?: AssistPageChangeProposal | null; pageChangeJob?: AiJobSummary | null }>,\n pageId: string,\n): string | null {\n for (let index = changes.length - 1; index >= 0; index -= 1) {\n const change = changes[index]\n if (change.pageChange?.pageId !== pageId) continue\n const output = assistPageChangeOutput(change.pageChangeJob ?? null)\n if (output?.versionId) return output.versionId\n }\n return null\n}\n"],"names":["ASSIST_PAGE_CHANGE_TOOL_NAME","ASSIST_PAGE_CHANGE_ACTION_ID","ASSIST_PAGE_CHANGE_SUMMARY_MAX_CHARS","DOCUMENT_ID","isRecord","value","Array","isArray","isAssistPageChangeProposal","test","trim","length","undefined","assistPageChangeJobRequest","orgId","proposal","versionId","hostId","kind","brief","inputs","target","pageId","targetKind","newVersion","assistPageChangeOutput","job","status","outputs","find","output","resource","Boolean","assistPageChangeDraftVersion","changes","index","change","pageChange","pageChangeJob"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;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;IADP,IAAI,CAACA,OAAOA,IAAIC,MAAM,KAAK,QAAQ,OAAO;IAC1C,QAAOD,oBAAAA,IAAIE,OAAO,CAACC,IAAI,CAAC,CAACC,SAAWA,OAAOC,QAAQ,KAAK,YAAYC,QAAQF,OAAOd,SAAS,cAArFU,oBAA2F;AACpG;AAEA;;;;CAIC,GACD,OAAO,SAASO,6BACdC,OAA6G,EAC7GZ,MAAc;IAEd,IAAK,IAAIa,QAAQD,QAAQvB,MAAM,GAAG,GAAGwB,SAAS,GAAGA,SAAS,EAAG;YAGrBC;YADlCA;QADJ,MAAMA,SAASF,OAAO,CAACC,MAAM;QAC7B,IAAIC,EAAAA,qBAAAA,OAAOC,UAAU,qBAAjBD,mBAAmBd,MAAM,MAAKA,QAAQ;QAC1C,MAAMQ,SAASL,wBAAuBW,wBAAAA,OAAOE,aAAa,YAApBF,wBAAwB;QAC9D,IAAIN,0BAAAA,OAAQd,SAAS,EAAE,OAAOc,OAAOd,SAAS;IAChD;IACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/assist-page-change.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A change to a page the site already has, asked in the Assist chat\n * (AGL-4116). No plan and no new page: the panel starts one `edit` job on\n * that page, which saves the change into the page's draft — on every plan,\n * the draft the Besigner offers with Open draft — and the card links the\n * page in the Besigner, where the person checks it and publishes it. Only\n * when they ask for a new version, and the plan keeps version history, is\n * the change saved as a new unpublished version instead.\n *\n * Asked through a build, a change to the home page came back as a second\n * page at `/` the plan generated from scratch, and every follow-up made\n * another plan. This is the short way, for the request that only changes\n * what is there.\n *\n * Shared by the chat door that resolves it and the panel that starts it.\n * Pure: no request, no React.\n */\n\nimport type { AiJobOutput, AiJobSummary } from './ai-jobs.types'\n\n/** The strict tool the chat model asks for a change to a page through. */\nexport const ASSIST_PAGE_CHANGE_TOOL_NAME = 'change_page'\n\n/** The proposal's fixed id, as `assistant_proposal_shown` records it. */\nexport const ASSIST_PAGE_CHANGE_ACTION_ID = 'page-change'\n\n/** The longest one-line summary the card shows. */\nexport const ASSIST_PAGE_CHANGE_SUMMARY_MAX_CHARS = 200\n\nconst DOCUMENT_ID = /^[A-Za-z0-9_-]{1,100}$/\n\nexport interface AssistPageChangeProposal {\n id: typeof ASSIST_PAGE_CHANGE_ACTION_ID\n /** The site the request was asked on; the job is created for it. */\n hostId: string\n /** The page to change: one the site has, by its id. */\n pageId: string\n /** The page's name, as the site's list of pages gives it. */\n pageName: string\n /** What to change on it, in the person's words. */\n brief: string\n /** One line saying what will change. */\n summary: string\n /** They asked for a new version of the page; otherwise the change goes into its draft. */\n newVersion?: boolean\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** Shape-checks a page change before it can start a job. */\nexport function isAssistPageChangeProposal(value: unknown): value is AssistPageChangeProposal {\n if (!isRecord(value) || value['id'] !== ASSIST_PAGE_CHANGE_ACTION_ID) return false\n return (\n typeof value['hostId'] === 'string' &&\n DOCUMENT_ID.test(value['hostId']) &&\n typeof value['pageId'] === 'string' &&\n DOCUMENT_ID.test(value['pageId']) &&\n typeof value['pageName'] === 'string' &&\n typeof value['brief'] === 'string' &&\n value['brief'].trim().length > 0 &&\n typeof value['summary'] === 'string' &&\n (value['newVersion'] === undefined || typeof value['newVersion'] === 'boolean')\n )\n}\n\n/**\n * The body of `POST /api/ai/jobs` a page change starts: an `edit` of the\n * page. `versionId` is the version an earlier change in the same\n * conversation wrote to, so a follow-up changes that version's draft rather\n * than starting again from the published page.\n */\nexport function assistPageChangeJobRequest(\n orgId: string,\n proposal: AssistPageChangeProposal,\n versionId: string | null,\n): {\n orgId: string\n hostId: string\n kind: 'edit'\n brief: string\n inputs: { target: string; targetKind: 'screen'; versionId?: string; newVersion?: true }\n} {\n return {\n orgId,\n hostId: proposal.hostId,\n kind: 'edit',\n brief: proposal.brief,\n inputs: {\n target: proposal.pageId,\n targetKind: 'screen',\n ...(versionId ? { versionId } : {}),\n ...(proposal.newVersion ? { newVersion: true as const } : {}),\n },\n }\n}\n\n/** The version a finished change wrote to the page, or `null` before there is one. */\nexport function assistPageChangeOutput(job: Pick<AiJobSummary, 'status' | 'outputs'> | null): AiJobOutput | null {\n if (!job || job.status !== 'done') return null\n return job.outputs.find((output) => output.resource === 'screen' && Boolean(output.versionId)) ?? null\n}\n\n/**\n * The version a new change to `pageId` continues (AGL-4116): the one the\n * conversation's latest finished change to that page wrote to — its draft\n * holds that change — or `null` to start from the page as it is.\n */\nexport function assistPageChangeDraftVersion(\n changes: ReadonlyArray<{ pageChange?: AssistPageChangeProposal | null; pageChangeJob?: AiJobSummary | null }>,\n pageId: string,\n): string | null {\n for (let index = changes.length - 1; index >= 0; index -= 1) {\n const change = changes[index]\n if (change.pageChange?.pageId !== pageId) continue\n const output = assistPageChangeOutput(change.pageChangeJob ?? null)\n if (output?.versionId) return output.versionId\n }\n return null\n}\n\n/** What a page change came to, as the turn that asked for it holds it. */\nexport interface AssistPageChangeTurn {\n pageChange?: AssistPageChangeProposal | null\n pageChangeJob?: AiJobSummary | null\n pageChangeNotice?: string | null\n}\n\n/** A turn of a thread, as far as what it changed goes. */\nexport interface AssistOutcomeTurn extends AssistPageChangeTurn {\n edit?: { summary: string } | null\n editOutcome?: { kind: string; message?: string } | null\n}\n\n/** How many of a thread's outcomes ride a question, the newest kept. */\nexport const ASSIST_OUTCOMES_SENT = 12\n\n/**\n * What became of a turn's page change, or null when the turn asked for none\n * (AGL-4116).\n */\nexport function assistPageChangeOutcome(turn: AssistPageChangeTurn): string | null {\n const proposal = turn.pageChange\n if (!proposal) return null\n const change = `Page change on ${proposal.pageName}`\n if (turn.pageChangeNotice) return `${change} not started: ${turn.pageChangeNotice}`\n const job = turn.pageChangeJob ?? null\n const output = assistPageChangeOutput(job)\n if (output) return `${change}: ${output.note ?? 'saved, not published.'}`\n if (job?.status === 'failed' || job?.status === 'canceled') {\n return `${change} not made: ${job.error ?? job.status}`\n }\n return `${change} being made.`\n}\n\n/** What became of a turn's edit card, or null while it waits for an answer. */\nfunction assistEditOutcome(turn: AssistOutcomeTurn): string | null {\n if (!turn.edit) return null\n const summary = turn.edit.summary\n if (turn.editOutcome?.kind === 'applied') return `Applied to the open canvas as an unsaved change: ${summary}`\n if (turn.editOutcome?.kind === 'dismissed') return `Not applied, they turned it down: ${summary}`\n if (turn.editOutcome?.kind === 'failed') return `Could not be applied: ${summary}`\n return null\n}\n\n/**\n * What a thread's changes came to, oldest first, for the next question to\n * carry apart from the thread's words (AGL-4116).\n *\n * Apart, because a note added to the assistant's own turn reads as the model\n * saying so: it is told never to say a change is made, so it took its record\n * of a saved draft for its own mistake and took the change back, telling the\n * person nothing had changed. The chat sees a thread's text and nothing else,\n * so without these it cannot know what happened at all.\n */\nexport function assistThreadOutcomes(turns: readonly AssistOutcomeTurn[]): string[] {\n return turns\n .flatMap((turn) => [assistPageChangeOutcome(turn), assistEditOutcome(turn)])\n .filter((outcome): outcome is string => outcome !== null)\n .slice(-ASSIST_OUTCOMES_SENT)\n}\n"],"names":["ASSIST_PAGE_CHANGE_TOOL_NAME","ASSIST_PAGE_CHANGE_ACTION_ID","ASSIST_PAGE_CHANGE_SUMMARY_MAX_CHARS","DOCUMENT_ID","isRecord","value","Array","isArray","isAssistPageChangeProposal","test","trim","length","undefined","assistPageChangeJobRequest","orgId","proposal","versionId","hostId","kind","brief","inputs","target","pageId","targetKind","newVersion","assistPageChangeOutput","job","status","outputs","find","output","resource","Boolean","assistPageChangeDraftVersion","changes","index","change","pageChange","pageChangeJob","ASSIST_OUTCOMES_SENT","assistPageChangeOutcome","turn","pageName","pageChangeNotice","note","error","assistEditOutcome","edit","summary","editOutcome","assistThreadOutcomes","turns","flatMap","filter","outcome","slice"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;CAgBC;AAID,wEAAwE,GACxE,OAAO,MAAMA,+BAA+B,cAAa;AAEzD,uEAAuE,GACvE,OAAO,MAAMC,+BAA+B,cAAa;AAEzD,iDAAiD,GACjD,OAAO,MAAMC,uCAAuC,IAAG;AAEvD,MAAMC,cAAc;AAkBpB,SAASC,SAASC,KAAc;IAC9B,OAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQ,CAACC,MAAMC,OAAO,CAACF;AACvE;AAEA,0DAA0D,GAC1D,OAAO,SAASG,2BAA2BH,KAAc;IACvD,IAAI,CAACD,SAASC,UAAUA,KAAK,CAAC,KAAK,KAAKJ,8BAA8B,OAAO;IAC7E,OACE,OAAOI,KAAK,CAAC,SAAS,KAAK,YAC3BF,YAAYM,IAAI,CAACJ,KAAK,CAAC,SAAS,KAChC,OAAOA,KAAK,CAAC,SAAS,KAAK,YAC3BF,YAAYM,IAAI,CAACJ,KAAK,CAAC,SAAS,KAChC,OAAOA,KAAK,CAAC,WAAW,KAAK,YAC7B,OAAOA,KAAK,CAAC,QAAQ,KAAK,YAC1BA,KAAK,CAAC,QAAQ,CAACK,IAAI,GAAGC,MAAM,GAAG,KAC/B,OAAON,KAAK,CAAC,UAAU,KAAK,YAC3BA,CAAAA,KAAK,CAAC,aAAa,KAAKO,aAAa,OAAOP,KAAK,CAAC,aAAa,KAAK,SAAQ;AAEjF;AAEA;;;;;CAKC,GACD,OAAO,SAASQ,2BACdC,KAAa,EACbC,QAAkC,EAClCC,SAAwB;IAQxB,OAAO;QACLF;QACAG,QAAQF,SAASE,MAAM;QACvBC,MAAM;QACNC,OAAOJ,SAASI,KAAK;QACrBC,QAAQ;YACNC,Q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,uBAAuBC;IACtC,IAAII,QAAQ,OAAO,GAAGM,OAAO,EAAE,GAAEN,eAAAA,OAAOc,IAAI,YAAXd,eAAe,yBAAyB;IACzE,IAAIJ,CAAAA,uBAAAA,IAAKC,MAAM,MAAK,YAAYD,CAAAA,uBAAAA,IAAKC,MAAM,MAAK,YAAY;YAC5BD;QAA9B,OAAO,GAAGU,OAAO,WAAW,GAAEV,aAAAA,IAAImB,KAAK,YAATnB,aAAaA,IAAIC,MAAM,EAAE;IACzD;IACA,OAAO,GAAGS,OAAO,YAAY,CAAC;AAChC;AAEA,6EAA6E,GAC7E,SAASU,kBAAkBL,IAAuB;QAG5CA,mBACAA,oBACAA;IAJJ,IAAI,CAACA,KAAKM,IAAI,EAAE,OAAO;IACvB,MAAMC,UAAUP,KAAKM,IAAI,CAACC,OAAO;IACjC,IAAIP,EAAAA,oBAAAA,KAAKQ,WAAW,qBAAhBR,kBAAkBvB,IAAI,MAAK,WAAW,OAAO,CAAC,iDAAiD,EAAE8B,SAAS;IAC9G,IAAIP,EAAAA,qBAAAA,KAAKQ,WAAW,qBAAhBR,mBAAkBvB,IAAI,MAAK,aAAa,OAAO,CAAC,kCAAkC,EAAE8B,SAAS;IACjG,IAAIP,EAAAA,qBAAAA,KAAKQ,WAAW,qBAAhBR,mBAAkBvB,IAAI,MAAK,UAAU,OAAO,CAAC,sBAAsB,EAAE8B,SAAS;IAClF,OAAO;AACT;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASE,qBAAqBC,KAAmC;IACtE,OAAOA,MACJC,OAAO,CAAC,CAACX,OAAS;YAACD,wBAAwBC;YAAOK,kBAAkBL;SAAM,EAC1EY,MAAM,CAAC,CAACC,UAA+BA,YAAY,MACnDC,KAAK,CAAC,CAAChB;AACZ"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
2
|
import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
|
|
3
|
+
import { _ as _to_property_key } from "@swc/helpers/_/_to_property_key";
|
|
3
4
|
/**
|
|
4
5
|
* @license
|
|
5
6
|
* Copyright 2026 Aglyn LLC
|
|
@@ -20,6 +21,7 @@ import { AI_NODE_CAPABILITIES, AI_PALETTE, AI_SURFACES, AI_SX_TOKENS } from "./a
|
|
|
20
21
|
import { linealRelationshipPermits } from "@aglyn/aglyn/app-utils/lineal-order";
|
|
21
22
|
import { NODE_MAP_MAX_BYTES, nodeMapBytes } from "@aglyn/aglyn/app-utils/measure-node-map";
|
|
22
23
|
import { parseMediaRef } from "@aglyn/aglyn/app-utils/media-ref";
|
|
24
|
+
import { SX_SCHEME_DARK_KEY } from "@aglyn/aglyn/app-utils/scheme-sx";
|
|
23
25
|
import { COMPONENT_PROP_NAME_PATTERN, REUSABLE_INSTANCE_COMPONENT_ID, REUSABLE_INSTANCE_PROP_VALUES_KEY } from "@aglyn/aglyn/app-utils/reusable-component-keys";
|
|
24
26
|
import { createIdUrlSafe } from "@aglyn/aglyn/foundation/constants/app";
|
|
25
27
|
import { CANVAS_ROOT_ELEMENT_ID } from "@aglyn/aglyn/foundation/constants/canvas";
|
|
@@ -877,7 +879,7 @@ function validate(input, surface, context) {
|
|
|
877
879
|
];
|
|
878
880
|
mint(rootId);
|
|
879
881
|
while(queue.length){
|
|
880
|
-
var _node_nodes;
|
|
882
|
+
var _node_nodes, _sxByNodeId_get;
|
|
881
883
|
const { id, parentId } = queue.shift();
|
|
882
884
|
const node = sanitized.nodes[id];
|
|
883
885
|
const entry = AI_PALETTE[node.componentId];
|
|
@@ -986,7 +988,21 @@ function validate(input, surface, context) {
|
|
|
986
988
|
error: `${entry.displayName} (${id}) is missing its required "${propsResult.missing}" prop`
|
|
987
989
|
};
|
|
988
990
|
}
|
|
989
|
-
|
|
991
|
+
// A logo code draws for one color scheme (AGL-4119): whether it shows, and
|
|
992
|
+
// nothing else. A model never writes this key, and its own sx never keeps it.
|
|
993
|
+
const _ref = (_sxByNodeId_get = sxByNodeId.get(id)) != null ? _sxByNodeId_get : {}, { [SX_SCHEME_DARK_KEY]: schemeSx } = _ref, ownSx = _object_without_properties_loose(_ref, [
|
|
994
|
+
_to_property_key(SX_SCHEME_DARK_KEY)
|
|
995
|
+
]);
|
|
996
|
+
const shownInDark = codeBuilt && isRecord(schemeSx) && [
|
|
997
|
+
'none',
|
|
998
|
+
'block'
|
|
999
|
+
].includes(String(schemeSx['display']));
|
|
1000
|
+
const kept = sanitizeSx(id, shownInDark ? ownSx : sxByNodeId.get(id), repairs);
|
|
1001
|
+
const sx = shownInDark ? _extends({}, kept, {
|
|
1002
|
+
[SX_SCHEME_DARK_KEY]: {
|
|
1003
|
+
display: schemeSx['display']
|
|
1004
|
+
}
|
|
1005
|
+
}) : kept;
|
|
990
1006
|
output[newId] = _extends({
|
|
991
1007
|
$id: newId,
|
|
992
1008
|
type: NodeType.NODE,
|