@aglyn/plugins-ai 1.0.0-beta.296 → 1.0.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.
Files changed (34) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-job-links.d.ts +2 -1
  3. package/src/lib/components/ai-job-links.js +8 -2
  4. package/src/lib/components/ai-job-links.js.map +1 -1
  5. package/src/lib/components/assist-edit-canvas.d.ts +12 -6
  6. package/src/lib/components/assist-edit-canvas.js +86 -36
  7. package/src/lib/components/assist-edit-canvas.js.map +1 -1
  8. package/src/lib/components/assist-edit-card.component.js +9 -8
  9. package/src/lib/components/assist-edit-card.component.js.map +1 -1
  10. package/src/lib/components/assist-page-change-card.component.d.ts +1 -1
  11. package/src/lib/components/assist-page-change-card.component.js +2 -2
  12. package/src/lib/components/assist-page-change-card.component.js.map +1 -1
  13. package/src/lib/components/assist-panel.component.js +19 -8
  14. package/src/lib/components/assist-panel.component.js.map +1 -1
  15. package/src/lib/jobs/ai-job-edit-step.d.ts +20 -0
  16. package/src/lib/jobs/ai-job-edit-step.js +39 -3
  17. package/src/lib/jobs/ai-job-edit-step.js.map +1 -1
  18. package/src/lib/model/ai-edit-job.js +1 -1
  19. package/src/lib/model/ai-edit-job.js.map +1 -1
  20. package/src/lib/model/ai-job-notice.js +3 -1
  21. package/src/lib/model/ai-job-notice.js.map +1 -1
  22. package/src/lib/model/assist-edit.d.ts +8 -7
  23. package/src/lib/model/assist-edit.js +4 -4
  24. package/src/lib/model/assist-edit.js.map +1 -1
  25. package/src/lib/model/assist-page-change.d.ts +14 -0
  26. package/src/lib/model/assist-page-change.js +21 -0
  27. package/src/lib/model/assist-page-change.js.map +1 -1
  28. package/src/lib/server/assist-chat.js +5 -1
  29. package/src/lib/server/assist-chat.js.map +1 -1
  30. package/src/lib/server/assist-edit.d.ts +12 -7
  31. package/src/lib/server/assist-edit.js +43 -22
  32. package/src/lib/server/assist-edit.js.map +1 -1
  33. package/src/lib/server/assist-page-change.js +1 -1
  34. package/src/lib/server/assist-page-change.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/plugins-ai",
3
- "version": "1.0.0-beta.296",
3
+ "version": "1.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -25,22 +25,22 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@aglyn/aglyn": "1.0.0-beta.296",
29
- "@aglyn/shared-data-enums": "1.0.0-beta.296",
30
- "@aglyn/shared-data-mdi": "1.0.0-beta.296",
31
- "@aglyn/shared-data-types": "1.0.0-beta.296",
32
- "@aglyn/shared-ui-email-campaigns": "1.0.0-beta.296",
33
- "@aglyn/shared-ui-jsx": "1.0.0-beta.296",
34
- "@aglyn/shared-ui-snackstack": "1.0.0-beta.296",
35
- "@aglyn/shared-ui-theme": "1.0.0-beta.296",
36
- "@aglyn/shared-util-email": "1.0.0-beta.296",
37
- "@aglyn/shared-util-errors": "1.0.0-beta.296",
38
- "@aglyn/shared-util-http": "1.0.0-beta.296",
39
- "@aglyn/shared-util-timestamp": "1.0.0-beta.296",
40
- "@aglyn/shared-util-tools": "1.0.0-beta.296",
41
- "@aglyn/tenant-data-admin": "1.0.0-beta.296",
42
- "@aglyn/tenant-feature-instance": "1.0.0-beta.296",
43
- "@aglyn/tenant-runtime": "1.0.0-beta.296",
28
+ "@aglyn/aglyn": "1.0.0",
29
+ "@aglyn/shared-data-enums": "1.0.0",
30
+ "@aglyn/shared-data-mdi": "1.0.0",
31
+ "@aglyn/shared-data-types": "1.0.0",
32
+ "@aglyn/shared-ui-email-campaigns": "1.0.0",
33
+ "@aglyn/shared-ui-jsx": "1.0.0",
34
+ "@aglyn/shared-ui-snackstack": "1.0.0",
35
+ "@aglyn/shared-ui-theme": "1.0.0",
36
+ "@aglyn/shared-util-email": "1.0.0",
37
+ "@aglyn/shared-util-errors": "1.0.0",
38
+ "@aglyn/shared-util-http": "1.0.0",
39
+ "@aglyn/shared-util-timestamp": "1.0.0",
40
+ "@aglyn/shared-util-tools": "1.0.0",
41
+ "@aglyn/tenant-data-admin": "1.0.0",
42
+ "@aglyn/tenant-feature-instance": "1.0.0",
43
+ "@aglyn/tenant-runtime": "1.0.0",
44
44
  "@swc/helpers": "0.5.23"
45
45
  },
46
46
  "peerDependencies": {
@@ -4,7 +4,8 @@ import { type AiStoreFinishStep } from '../model/ai-site-store-pages';
4
4
  /**
5
5
  * Where "open draft" goes, or `null` when the output has no page of its
6
6
  * own — a `text` output carries its copy on the job and is shown inline.
7
- * A versioned resource opens in the besigner on the version the job wrote;
7
+ * A versioned resource opens in the besigner on the version the job wrote,
8
+ * on its draft when that is where the change went;
8
9
  * one the console lists without a detail page opens its list; a `theme`
9
10
  * proposal opens the site's Theme section, where it is put in the editor.
10
11
  *
@@ -15,6 +15,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */ import { buildRoute, Route } from "@aglyn/aglyn/app-utils/console-routes";
18
+ import { besignerOpenDraftHref } from "@aglyn/aglyn/app-utils/version-draft";
18
19
  import { pluginRecordHref, pluginRecordListHref } from "@aglyn/aglyn/plugin-manager/plugin-record-routes";
19
20
  import { AI_JOB_BESIGNER_SEGMENT as BESIGNER_SEGMENT, AI_SITE_BUILD_HREF } from "../model/ai-job-notice.js";
20
21
  import { AI_STORE_FINISH_STEPS } from "../model/ai-site-store-pages.js";
@@ -24,7 +25,8 @@ import { AI_BUILD_STORE_LINKS_DRAFT_STEP, AI_BUILD_STORE_LINKS_MISSING_STEP } fr
24
25
  /**
25
26
  * Where "open draft" goes, or `null` when the output has no page of its
26
27
  * own — a `text` output carries its copy on the job and is shown inline.
27
- * A versioned resource opens in the besigner on the version the job wrote;
28
+ * A versioned resource opens in the besigner on the version the job wrote,
29
+ * on its draft when that is where the change went;
28
30
  * one the console lists without a detail page opens its list; a `theme`
29
31
  * proposal opens the site's Theme section, where it is put in the editor.
30
32
  *
@@ -38,7 +40,11 @@ import { AI_BUILD_STORE_LINKS_DRAFT_STEP, AI_BUILD_STORE_LINKS_MISSING_STEP } fr
38
40
  const segment = BESIGNER_SEGMENT[output.resource];
39
41
  if (segment) {
40
42
  const base = `/${orgSlug}/hosts/${host}/${segment}/${output.id}`;
41
- return output.versionId ? `${base}/versions/${output.versionId}/besigner` : base;
43
+ if (!output.versionId) return base;
44
+ const besigner = `${base}/versions/${output.versionId}/besigner`;
45
+ // A change in the version's draft opens on that draft (AGL-4116), so the
46
+ // person lands on what they asked for rather than on the live version.
47
+ return output.inDraft ? besignerOpenDraftHref(besigner) : besigner;
42
48
  }
43
49
  if (output.resource === 'product') {
44
50
  // The catalog a drafted product lands in: the commerce plugin's address
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-job-links.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 */\nimport { buildRoute, Route } from '@aglyn/aglyn/app-utils/console-routes'\nimport {\n pluginRecordHref,\n pluginRecordListHref,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-routes'\nimport { AI_JOB_BESIGNER_SEGMENT as BESIGNER_SEGMENT, AI_SITE_BUILD_HREF } from '../model/ai-job-notice'\nimport type { AiJobOutput, AiJobSummary } from '../model/ai-jobs.types'\nimport { AI_STORE_FINISH_STEPS, type AiStoreFinishStep } from '../model/ai-site-store-pages'\nimport { AI_BUILD_STORE_LINKS_DRAFT_STEP, AI_BUILD_STORE_LINKS_MISSING_STEP } from '../model/ai-build-store-pages'\n\n// Where a job's work opens in the console (AGL-2904), shared by the AI jobs\n// drawer and every dialog that follows the job it started (AGL-3593).\n\n/**\n * Where \"open draft\" goes, or `null` when the output has no page of its\n * own — a `text` output carries its copy on the job and is shown inline.\n * A versioned resource opens in the besigner on the version the job wrote;\n * one the console lists without a detail page opens its list; a `theme`\n * proposal opens the site's Theme section, where it is put in the editor.\n *\n * A console URL names a site by its SUBDOMAIN: the `[host]` segment resolves\n * through the member's host projection by subdomain, never by document id.\n * So an output that carries no `hostSubdomain` gets no link rather than one\n * that opens no site.\n */\nexport function aiJobOutputHref(output: AiJobOutput, orgSlug: string): string | null {\n const host = output.hostSubdomain\n if (!orgSlug || !host) return null\n const segment = BESIGNER_SEGMENT[output.resource]\n if (segment) {\n const base = `/${orgSlug}/hosts/${host}/${segment}/${output.id}`\n return output.versionId ? `${base}/versions/${output.versionId}/besigner` : base\n }\n if (output.resource === 'product') {\n // The catalog a drafted product lands in: the commerce plugin's address\n // for it (AGL-3080), or no link where commerce is not loaded.\n return pluginRecordListHref('product', { orgSlug, host })\n }\n if (output.resource === 'workflow') {\n // A drafted automation is an action (AGL-2919), listed switched off on\n // the workflows plugin's list of actions, or no link where it is not loaded.\n return pluginRecordListHref('action', { orgSlug, host })\n }\n if (output.resource === 'entry') {\n // A post a guided start wrote (AGL-3676) opens in its blog's list in Content.\n const collectionSlug = output.proposal?.['collectionSlug']\n return typeof collectionSlug === 'string' && collectionSlug\n ? buildRoute(Route.HOST_CONTENT_COLLECTION, { orgSlug, host, collectionSlug })\n : buildRoute(Route.HOST_CONTENT, { orgSlug, host })\n }\n if (output.resource === 'theme') {\n return buildRoute(Route.HOST_SETUP_THEME, { orgSlug, host })\n }\n if (output.resource === 'media') {\n // Files a build organized (AGL-3752) open in the site's media library.\n return buildRoute(Route.HOST_MEDIA, { orgSlug, host })\n }\n if (output.resource === 'settings') {\n // Settings a build saved (AGL-3748) open where most of them are edited.\n return buildRoute(Route.HOST_SETUP_SEO, { orgSlug, host })\n }\n if (output.resource === 'tracking') {\n // Tags a build saved (AGL-3751) open on the card that edits them.\n return buildRoute(Route.HOST_SETUP_TRACKING, { orgSlug, host })\n }\n if (output.resource === 'privacy') {\n // Who can see the site (AGL-4033), each change on the card that makes it.\n if (output.id === 'maintenance') return buildRoute(Route.HOST_ADMIN_ERROR_PAGES, { orgSlug, host })\n if (output.id === 'search') return buildRoute(Route.HOST_SETUP_SEO, { orgSlug, host })\n return buildRoute(Route.HOST_SCREENS, { orgSlug, host })\n }\n if (output.resource === 'draft' && output.draftResource) {\n // A draft another plugin wrote — a dataset a site start or a build made\n // (AGL-3616) — opens where its owner lists it, or nowhere it is not loaded.\n return pluginRecordListHref(output.draftResource, { orgSlug, host })\n }\n if (output.resource === 'form') {\n // A new form has no version for the besigner to open: its own page — the\n // forms plugin's address for it — mints the first one, and holds the\n // routing and consent it declares.\n return pluginRecordHref('form', { orgSlug, host }, output.id)\n }\n if (output.resource === 'campaign') {\n // A campaign's page is the marketing plugin's, under the site: its\n // address for the campaign (AGL-3080), or no link where it is not loaded.\n return pluginRecordHref('campaign', { orgSlug, host }, output.id)\n }\n return null\n}\n\n/**\n * The ONE action a finished job's row, its notification and the dialog that\n * started it lead with (AGL-3593): what the job built. Several pages from one\n * job — a site's — open the site's Pages list, where they wait as drafts; one\n * output with a page of its own opens that page; anything else has no single\n * place to go, and the row's own links stand. `null` until the job is done.\n */\nexport function aiJobPrimaryLink(\n job: Pick<AiJobSummary, 'status' | 'outputs'>,\n orgSlug: string,\n): { href: string; label: string } | null {\n if (job.status !== 'done' || !orgSlug) return null\n const screens = job.outputs.filter(\n (output) => output.resource === 'screen' && output.hostSubdomain,\n )\n if (screens.length > 1) {\n return {\n href: buildRoute(Route.HOST_SCREENS, { orgSlug, host: String(screens[0].hostSubdomain) }),\n label: 'Open your draft pages',\n }\n }\n for (const output of job.outputs) {\n const href = aiJobOutputHref(output, orgSlug)\n if (href) {\n return {\n href,\n label: output.resource === 'screen' ? 'Open the draft page' : `Open ${output.label}`,\n }\n }\n }\n return null\n}\n\nexport { AI_SITE_BUILD_HREF }\n\n/**\n * The \"Building your site\" page for one site job (AGL-3594): linkable, so the\n * guided start lands on it, a reload keeps it and a notification opens it.\n * `null` without the org slug or the site's subdomain a console URL needs.\n */\nexport function aiSiteBuildHref(\n orgSlug: string | null | undefined,\n hostSubdomain: string | null | undefined,\n jobId: string,\n): string | null {\n if (!orgSlug || !hostSubdomain || !jobId) return null\n return `/${orgSlug}/hosts/${hostSubdomain}${AI_SITE_BUILD_HREF}/${encodeURIComponent(jobId)}`\n}\n\n/** A page version's own address under a site, for the console route named by `leaf`. */\nfunction screenVersionHref(orgSlug: string, output: AiJobOutput, leaf: 'preview' | 'besigner'): string {\n return `/${orgSlug}/hosts/${String(output.hostSubdomain)}/screens/${output.id}/versions/${output.versionId}/${leaf}`\n}\n\n/**\n * A finished site's two ways in (AGL-3594): its first page's draft, opened in\n * the console's preview of that version — the page as a visitor will see it,\n * never its details — and the Pages list every draft waits in. Either is\n * `null` where the job reported nothing to open.\n */\nexport function aiSiteBuildDoneLinks(\n job: Pick<AiJobSummary, 'outputs'>,\n orgSlug: string,\n): { view: string | null; pages: string | null } {\n const screens = job.outputs.filter((output) => output.resource === 'screen' && output.hostSubdomain)\n const first = screens[0]\n if (!first || !orgSlug) return { view: null, pages: null }\n const host = String(first.hostSubdomain)\n return {\n // A change in a page's draft is not in its version's preview (AGL-4116).\n view: first.versionId && !first.inDraft ? screenVersionHref(orgSlug, first, 'preview') : null,\n pages: buildRoute(Route.HOST_SCREENS, { orgSlug, host }),\n }\n}\n\n/**\n * The two ways to look at the one page a job changed (AGL-3616): its new\n * version in the preview, where it can be published, and in the Besigner.\n * A change saved into the page's draft (AGL-4116) has no preview of its own\n * — a version's preview shows the version, not its draft — so only the\n * Besigner, where Open draft shows it. `null` where the job wrote no page\n * version, or more than one page — those wait in Pages.\n */\nexport function aiJobReviewLinks(\n job: Pick<AiJobSummary, 'outputs'>,\n orgSlug: string,\n): { preview: string | null; besigner: string } | null {\n if (!orgSlug) return null\n const pages = job.outputs.filter((output) => output.resource === 'screen' && output.hostSubdomain && output.versionId)\n if (new Set(pages.map((page) => page.id)).size !== 1) return null\n return {\n preview: pages[0].inDraft ? null : screenVersionHref(orgSlug, pages[0], 'preview'),\n besigner: screenVersionHref(orgSlug, pages[0], 'besigner'),\n }\n}\n\n/**\n * Where a person gets more AI credits (AGL-3660): the workspace's Billing\n * page at its plans, where an upgrade and the AI add-on are both sold — the\n * door the AI credits meter's own upgrade link opens.\n */\nexport function aiCreditsBillingHref(orgSlug: string): string {\n return `${buildRoute(Route.MANAGE_BILLING, { orgSlug })}#plans`\n}\n\n/** One thing left to finish an AI-built store, with where it is done. */\nexport interface AiStoreFinishLink extends AiStoreFinishStep {\n /** The console page it is done on; `null` where the owner of that page is not loaded. */\n href: string | null\n}\n\n/**\n * What is left to finish a store a site start built (AGL-3676), or `null`\n * where the start built no store's own pages: its account, cart and policy\n * pages are written, so payments, products, shipping and tax, and the\n * policies' brackets are all that remain. Each links the exact console page:\n * the store's settings and its catalog, as the commerce plugin publishes\n * them, and the site's Pages.\n */\nexport function aiStoreFinishLinks(\n job: Pick<AiJobSummary, 'kind' | 'status' | 'items' | 'outputs'> & Partial<Pick<AiJobSummary, 'sitePublish'>>,\n orgSlug: string,\n): AiStoreFinishLink[] | null {\n // A site start's store, or an Assist build that made the site a store (AGL-3676).\n if ((job.kind !== 'site' && job.kind !== 'build') || job.status !== 'done' || !orgSlug) return null\n const row = (job.items ?? []).find((one) => one.slot === 'store')\n if (!row || (row.status !== 'succeeded' && row.status !== 'degraded')) return null\n const host = job.outputs.find((output) => output.resource === 'screen' && output.hostSubdomain)?.hostSubdomain\n if (!host) return null\n const context = { orgSlug, host: String(host) }\n // A build's products are drafts with no price unless asked, and it may\n // have written none of the policies (the site had them): its list says so.\n const build = job.kind === 'build'\n const mine = job.outputs.filter((output) => row.outputs.includes(output.id))\n const written = new Set(mine.map((output) => output.proposal?.['storePage']))\n const policies = !build || ['shipping', 'privacy', 'terms'].some((key) => written.has(key))\n const steps: AiStoreFinishLink[] = AI_STORE_FINISH_STEPS.filter((step) => step.id !== 'policies' || policies).map((step) => ({\n ...step,\n ...(build && step.id === 'products' ? { text: AI_BUILD_STORE_PRODUCTS_TEXT } : {}),\n href:\n step.opens === 'pages'\n ? buildRoute(Route.HOST_SCREENS, context)\n : step.opens === 'layouts' || step.opens === 'layout'\n ? buildRoute(Route.HOST_LAYOUTS, context)\n : step.record\n ? pluginRecordHref(step.opens, context, step.record)\n : pluginRecordListHref(step.opens, context),\n }))\n if (!build) return steps\n // The site's own header and footer (AGL-3676): links it had no list for are\n // the owner's to add; links drafted into it wait for its publish.\n if (mine.some((output) => output.proposal?.['storeLinks'] === 'missing')) {\n steps.push({ ...AI_BUILD_STORE_LINKS_MISSING_STEP, href: buildRoute(Route.HOST_LAYOUTS, context) })\n }\n const draft = mine.find((output) => output.resource === 'layout' && output.proposal?.['storeLinks'] === 'draft')\n const live = draft && job.sitePublish?.published.length\n if (draft && !live) steps.push({ ...AI_BUILD_STORE_LINKS_DRAFT_STEP, href: aiJobOutputHref(draft, orgSlug) })\n return steps\n}\n\n/**\n * The site an AI-built store is on — the one {@link aiStoreFinishLinks}\n * links — so \"Finish your store\" can read whether its workspace already takes\n * payments (AGL-3982). `null` where no output names a site.\n */\nexport function aiStoreFinishHostId(job: Pick<AiJobSummary, 'outputs'>): string | null {\n return job.outputs.find((output) => output.resource === 'screen' && output.hostSubdomain)?.hostId ?? null\n}\n\n/** What a build's \"Review your products\" step says: its products are drafts, priced only where the request said. */\nexport const AI_BUILD_STORE_PRODUCTS_TEXT =\n 'Your new products are drafts. Set their prices, photos and stock, then make them active so they show in your store.'\n"],"names":["buildRoute","Route","pluginRecordHref","pluginRecordListHref","AI_JOB_BESIGNER_SEGMENT","BESIGNER_SEGMENT","AI_SITE_BUILD_HREF","AI_STORE_FINISH_STEPS","AI_BUILD_STORE_LINKS_DRAFT_STEP","AI_BUILD_STORE_LINKS_MISSING_STEP","aiJobOutputHref","output","orgSlug","host","hostSubdomain","segment","resource","base","id","versionId","collectionSlug","proposal","HOST_CONTENT_COLLECTION","HOST_CONTENT","HOST_SETUP_THEME","HOST_MEDIA","HOST_SETUP_SEO","HOST_SETUP_TRACKING","HOST_ADMIN_ERROR_PAGES","HOST_SCREENS","draftResource","aiJobPrimaryLink","job","status","screens","outputs","filter","length","href","String","label","aiSiteBuildHref","jobId","encodeURIComponent","screenVersionHref","leaf","aiSiteBuildDoneLinks","first","view","pages","inDraft","aiJobReviewLinks","Set","map","page","size","preview","besigner","aiCreditsBillingHref","MANAGE_BILLING","aiStoreFinishLinks","kind","row","items","find","one","slot","context","build","mine","includes","written","policies","some","key","has","steps","step","text","AI_BUILD_STORE_PRODUCTS_TEXT","opens","HOST_LAYOUTS","record","push","draft","live","sitePublish","published","aiStoreFinishHostId","hostId"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GACD,SAASA,UAAU,EAAEC,KAAK,QAAQ,wCAAuC;AACzE,SACEC,gBAAgB,EAChBC,oBAAoB,QACf,mDAAkD;AACzD,SAASC,2BAA2BC,gBAAgB,EAAEC,kBAAkB,QAAQ,4BAAwB;AAExG,SAASC,qBAAqB,QAAgC,kCAA8B;AAC5F,SAASC,+BAA+B,EAAEC,iCAAiC,QAAQ,mCAA+B;AAElH,4EAA4E;AAC5E,sEAAsE;AAEtE;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,gBAAgBC,MAAmB,EAAEC,OAAe;IAClE,MAAMC,OAAOF,OAAOG,aAAa;IACjC,IAAI,CAACF,WAAW,CAACC,MAAM,OAAO;IAC9B,MAAME,UAAUV,gBAAgB,CAACM,OAAOK,QAAQ,CAAC;IACjD,IAAID,SAAS;QACX,MAAME,OAAO,CAAC,CAAC,EAAEL,QAAQ,OAAO,EAAEC,KAAK,CAAC,EAAEE,QAAQ,CAAC,EAAEJ,OAAOO,EAAE,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F,YAAY,EAAEd;;IAC1F;IACA,MAAMiB,QAAQf,KAAKL,IAAI,CAAC,CAACrD;YAA2CA;eAAhCA,OAAOK,QAAQ,KAAK,YAAYL,EAAAA,mBAAAA,OAAOU,QAAQ,qBAAfV,gBAAiB,CAAC,aAAa,MAAK;;IACxG,MAAM0E,OAAOD,WAASpD,mBAAAA,IAAIsD,WAAW,qBAAftD,iBAAiBuD,SAAS,CAAClD,MAAM;IACvD,IAAI+C,SAAS,CAACC,MAAMT,MAAMO,IAAI,CAAC,aAAK3E;QAAiC8B,MAAM5B,gBAAgB0E,OAAOxE;;IAClG,OAAOgE;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASY,oBAAoBxD,GAAkC;;QAC7DA;IAAP,gBAAOA,oBAAAA,IAAIG,OAAO,CAAC6B,IAAI,CAAC,CAACrD,SAAWA,OAAOK,QAAQ,KAAK,YAAYL,OAAOG,aAAa,sBAAjFkB,kBAAoFyD,MAAM,mBAAI;AACvG;AAEA,kHAAkH,GAClH,OAAO,MAAMV,+BACX,sHAAqH"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-job-links.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 */\nimport { buildRoute, Route } from '@aglyn/aglyn/app-utils/console-routes'\nimport { besignerOpenDraftHref } from '@aglyn/aglyn/app-utils/version-draft'\nimport {\n pluginRecordHref,\n pluginRecordListHref,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-routes'\nimport { AI_JOB_BESIGNER_SEGMENT as BESIGNER_SEGMENT, AI_SITE_BUILD_HREF } from '../model/ai-job-notice'\nimport type { AiJobOutput, AiJobSummary } from '../model/ai-jobs.types'\nimport { AI_STORE_FINISH_STEPS, type AiStoreFinishStep } from '../model/ai-site-store-pages'\nimport { AI_BUILD_STORE_LINKS_DRAFT_STEP, AI_BUILD_STORE_LINKS_MISSING_STEP } from '../model/ai-build-store-pages'\n\n// Where a job's work opens in the console (AGL-2904), shared by the AI jobs\n// drawer and every dialog that follows the job it started (AGL-3593).\n\n/**\n * Where \"open draft\" goes, or `null` when the output has no page of its\n * own — a `text` output carries its copy on the job and is shown inline.\n * A versioned resource opens in the besigner on the version the job wrote,\n * on its draft when that is where the change went;\n * one the console lists without a detail page opens its list; a `theme`\n * proposal opens the site's Theme section, where it is put in the editor.\n *\n * A console URL names a site by its SUBDOMAIN: the `[host]` segment resolves\n * through the member's host projection by subdomain, never by document id.\n * So an output that carries no `hostSubdomain` gets no link rather than one\n * that opens no site.\n */\nexport function aiJobOutputHref(output: AiJobOutput, orgSlug: string): string | null {\n const host = output.hostSubdomain\n if (!orgSlug || !host) return null\n const segment = BESIGNER_SEGMENT[output.resource]\n if (segment) {\n const base = `/${orgSlug}/hosts/${host}/${segment}/${output.id}`\n if (!output.versionId) return base\n const besigner = `${base}/versions/${output.versionId}/besigner`\n // A change in the version's draft opens on that draft (AGL-4116), so the\n // person lands on what they asked for rather than on the live version.\n return output.inDraft ? besignerOpenDraftHref(besigner) : besigner\n }\n if (output.resource === 'product') {\n // The catalog a drafted product lands in: the commerce plugin's address\n // for it (AGL-3080), or no link where commerce is not loaded.\n return pluginRecordListHref('product', { orgSlug, host })\n }\n if (output.resource === 'workflow') {\n // A drafted automation is an action (AGL-2919), listed switched off on\n // the workflows plugin's list of actions, or no link where it is not loaded.\n return pluginRecordListHref('action', { orgSlug, host })\n }\n if (output.resource === 'entry') {\n // A post a guided start wrote (AGL-3676) opens in its blog's list in Content.\n const collectionSlug = output.proposal?.['collectionSlug']\n return typeof collectionSlug === 'string' && collectionSlug\n ? buildRoute(Route.HOST_CONTENT_COLLECTION, { orgSlug, host, collectionSlug })\n : buildRoute(Route.HOST_CONTENT, { orgSlug, host })\n }\n if (output.resource === 'theme') {\n return buildRoute(Route.HOST_SETUP_THEME, { orgSlug, host })\n }\n if (output.resource === 'media') {\n // Files a build organized (AGL-3752) open in the site's media library.\n return buildRoute(Route.HOST_MEDIA, { orgSlug, host })\n }\n if (output.resource === 'settings') {\n // Settings a build saved (AGL-3748) open where most of them are edited.\n return buildRoute(Route.HOST_SETUP_SEO, { orgSlug, host })\n }\n if (output.resource === 'tracking') {\n // Tags a build saved (AGL-3751) open on the card that edits them.\n return buildRoute(Route.HOST_SETUP_TRACKING, { orgSlug, host })\n }\n if (output.resource === 'privacy') {\n // Who can see the site (AGL-4033), each change on the card that makes it.\n if (output.id === 'maintenance') return buildRoute(Route.HOST_ADMIN_ERROR_PAGES, { orgSlug, host })\n if (output.id === 'search') return buildRoute(Route.HOST_SETUP_SEO, { orgSlug, host })\n return buildRoute(Route.HOST_SCREENS, { orgSlug, host })\n }\n if (output.resource === 'draft' && output.draftResource) {\n // A draft another plugin wrote — a dataset a site start or a build made\n // (AGL-3616) — opens where its owner lists it, or nowhere it is not loaded.\n return pluginRecordListHref(output.draftResource, { orgSlug, host })\n }\n if (output.resource === 'form') {\n // A new form has no version for the besigner to open: its own page — the\n // forms plugin's address for it — mints the first one, and holds the\n // routing and consent it declares.\n return pluginRecordHref('form', { orgSlug, host }, output.id)\n }\n if (output.resource === 'campaign') {\n // A campaign's page is the marketing plugin's, under the site: its\n // address for the campaign (AGL-3080), or no link where it is not loaded.\n return pluginRecordHref('campaign', { orgSlug, host }, output.id)\n }\n return null\n}\n\n/**\n * The ONE action a finished job's row, its notification and the dialog that\n * started it lead with (AGL-3593): what the job built. Several pages from one\n * job — a site's — open the site's Pages list, where they wait as drafts; one\n * output with a page of its own opens that page; anything else has no single\n * place to go, and the row's own links stand. `null` until the job is done.\n */\nexport function aiJobPrimaryLink(\n job: Pick<AiJobSummary, 'status' | 'outputs'>,\n orgSlug: string,\n): { href: string; label: string } | null {\n if (job.status !== 'done' || !orgSlug) return null\n const screens = job.outputs.filter(\n (output) => output.resource === 'screen' && output.hostSubdomain,\n )\n if (screens.length > 1) {\n return {\n href: buildRoute(Route.HOST_SCREENS, { orgSlug, host: String(screens[0].hostSubdomain) }),\n label: 'Open your draft pages',\n }\n }\n for (const output of job.outputs) {\n const href = aiJobOutputHref(output, orgSlug)\n if (href) {\n return {\n href,\n label: output.resource === 'screen' ? 'Open the draft page' : `Open ${output.label}`,\n }\n }\n }\n return null\n}\n\nexport { AI_SITE_BUILD_HREF }\n\n/**\n * The \"Building your site\" page for one site job (AGL-3594): linkable, so the\n * guided start lands on it, a reload keeps it and a notification opens it.\n * `null` without the org slug or the site's subdomain a console URL needs.\n */\nexport function aiSiteBuildHref(\n orgSlug: string | null | undefined,\n hostSubdomain: string | null | undefined,\n jobId: string,\n): string | null {\n if (!orgSlug || !hostSubdomain || !jobId) return null\n return `/${orgSlug}/hosts/${hostSubdomain}${AI_SITE_BUILD_HREF}/${encodeURIComponent(jobId)}`\n}\n\n/** A page version's own address under a site, for the console route named by `leaf`. */\nfunction screenVersionHref(orgSlug: string, output: AiJobOutput, leaf: 'preview' | 'besigner'): string {\n return `/${orgSlug}/hosts/${String(output.hostSubdomain)}/screens/${output.id}/versions/${output.versionId}/${leaf}`\n}\n\n/**\n * A finished site's two ways in (AGL-3594): its first page's draft, opened in\n * the console's preview of that version — the page as a visitor will see it,\n * never its details — and the Pages list every draft waits in. Either is\n * `null` where the job reported nothing to open.\n */\nexport function aiSiteBuildDoneLinks(\n job: Pick<AiJobSummary, 'outputs'>,\n orgSlug: string,\n): { view: string | null; pages: string | null } {\n const screens = job.outputs.filter((output) => output.resource === 'screen' && output.hostSubdomain)\n const first = screens[0]\n if (!first || !orgSlug) return { view: null, pages: null }\n const host = String(first.hostSubdomain)\n return {\n // A change in a page's draft is not in its version's preview (AGL-4116).\n view: first.versionId && !first.inDraft ? screenVersionHref(orgSlug, first, 'preview') : null,\n pages: buildRoute(Route.HOST_SCREENS, { orgSlug, host }),\n }\n}\n\n/**\n * The two ways to look at the one page a job changed (AGL-3616): its new\n * version in the preview, where it can be published, and in the Besigner.\n * A change saved into the page's draft (AGL-4116) has no preview of its own\n * — a version's preview shows the version, not its draft — so only the\n * Besigner, where Open draft shows it. `null` where the job wrote no page\n * version, or more than one page — those wait in Pages.\n */\nexport function aiJobReviewLinks(\n job: Pick<AiJobSummary, 'outputs'>,\n orgSlug: string,\n): { preview: string | null; besigner: string } | null {\n if (!orgSlug) return null\n const pages = job.outputs.filter((output) => output.resource === 'screen' && output.hostSubdomain && output.versionId)\n if (new Set(pages.map((page) => page.id)).size !== 1) return null\n return {\n preview: pages[0].inDraft ? null : screenVersionHref(orgSlug, pages[0], 'preview'),\n besigner: screenVersionHref(orgSlug, pages[0], 'besigner'),\n }\n}\n\n/**\n * Where a person gets more AI credits (AGL-3660): the workspace's Billing\n * page at its plans, where an upgrade and the AI add-on are both sold — the\n * door the AI credits meter's own upgrade link opens.\n */\nexport function aiCreditsBillingHref(orgSlug: string): string {\n return `${buildRoute(Route.MANAGE_BILLING, { orgSlug })}#plans`\n}\n\n/** One thing left to finish an AI-built store, with where it is done. */\nexport interface AiStoreFinishLink extends AiStoreFinishStep {\n /** The console page it is done on; `null` where the owner of that page is not loaded. */\n href: string | null\n}\n\n/**\n * What is left to finish a store a site start built (AGL-3676), or `null`\n * where the start built no store's own pages: its account, cart and policy\n * pages are written, so payments, products, shipping and tax, and the\n * policies' brackets are all that remain. Each links the exact console page:\n * the store's settings and its catalog, as the commerce plugin publishes\n * them, and the site's Pages.\n */\nexport function aiStoreFinishLinks(\n job: Pick<AiJobSummary, 'kind' | 'status' | 'items' | 'outputs'> & Partial<Pick<AiJobSummary, 'sitePublish'>>,\n orgSlug: string,\n): AiStoreFinishLink[] | null {\n // A site start's store, or an Assist build that made the site a store (AGL-3676).\n if ((job.kind !== 'site' && job.kind !== 'build') || job.status !== 'done' || !orgSlug) return null\n const row = (job.items ?? []).find((one) => one.slot === 'store')\n if (!row || (row.status !== 'succeeded' && row.status !== 'degraded')) return null\n const host = job.outputs.find((output) => output.resource === 'screen' && output.hostSubdomain)?.hostSubdomain\n if (!host) return null\n const context = { orgSlug, host: String(host) }\n // A build's products are drafts with no price unless asked, and it may\n // have written none of the policies (the site had them): its list says so.\n const build = job.kind === 'build'\n const mine = job.outputs.filter((output) => row.outputs.includes(output.id))\n const written = new Set(mine.map((output) => output.proposal?.['storePage']))\n const policies = !build || ['shipping', 'privacy', 'terms'].some((key) => written.has(key))\n const steps: AiStoreFinishLink[] = AI_STORE_FINISH_STEPS.filter((step) => step.id !== 'policies' || policies).map((step) => ({\n ...step,\n ...(build && step.id === 'products' ? { text: AI_BUILD_STORE_PRODUCTS_TEXT } : {}),\n href:\n step.opens === 'pages'\n ? buildRoute(Route.HOST_SCREENS, context)\n : step.opens === 'layouts' || step.opens === 'layout'\n ? buildRoute(Route.HOST_LAYOUTS, context)\n : step.record\n ? pluginRecordHref(step.opens, context, step.record)\n : pluginRecordListHref(step.opens, context),\n }))\n if (!build) return steps\n // The site's own header and footer (AGL-3676): links it had no list for are\n // the owner's to add; links drafted into it wait for its publish.\n if (mine.some((output) => output.proposal?.['storeLinks'] === 'missing')) {\n steps.push({ ...AI_BUILD_STORE_LINKS_MISSING_STEP, href: buildRoute(Route.HOST_LAYOUTS, context) })\n }\n const draft = mine.find((output) => output.resource === 'layout' && output.proposal?.['storeLinks'] === 'draft')\n const live = draft && job.sitePublish?.published.length\n if (draft && !live) steps.push({ ...AI_BUILD_STORE_LINKS_DRAFT_STEP, href: aiJobOutputHref(draft, orgSlug) })\n return steps\n}\n\n/**\n * The site an AI-built store is on — the one {@link aiStoreFinishLinks}\n * links — so \"Finish your store\" can read whether its workspace already takes\n * payments (AGL-3982). `null` where no output names a site.\n */\nexport function aiStoreFinishHostId(job: Pick<AiJobSummary, 'outputs'>): string | null {\n return job.outputs.find((output) => output.resource === 'screen' && output.hostSubdomain)?.hostId ?? null\n}\n\n/** What a build's \"Review your products\" step says: its products are drafts, priced only where the request said. */\nexport const AI_BUILD_STORE_PRODUCTS_TEXT =\n 'Your new products are drafts. Set their prices, photos and stock, then make them active so they show in your store.'\n"],"names":["buildRoute","Route","besignerOpenDraftHref","pluginRecordHref","pluginRecordListHref","AI_JOB_BESIGNER_SEGMENT","BESIGNER_SEGMENT","AI_SITE_BUILD_HREF","AI_STORE_FINISH_STEPS","AI_BUILD_STORE_LINKS_DRAFT_STEP","AI_BUILD_STORE_LINKS_MISSING_STEP","aiJobOutputHref","output","orgSlug","host","hostSubdomain","segment","resource","base","id","versionId","besigner","inDraft","collectionSlug","proposal","HOST_CONTENT_COLLECTION","HOST_CONTENT","HOST_SETUP_THEME","HOST_MEDIA","HOST_SETUP_SEO","HOST_SETUP_TRACKING","HOST_ADMIN_ERROR_PAGES","HOST_SCREENS","draftResource","aiJobPrimaryLink","job","status","screens","outputs","filter","length","href","String","label","aiSiteBuildHref","jobId","encodeURIComponent","screenVersionHref","leaf","aiSiteBuildDoneLinks","first","view","pages","aiJobReviewLinks","Set","map","page","size","preview","aiCreditsBillingHref","MANAGE_BILLING","aiStoreFinishLinks","kind","row","items","find","one","slot","context","build","mine","includes","written","policies","some","key","has","steps","step","text","AI_BUILD_STORE_PRODUCTS_TEXT","opens","HOST_LAYOUTS","record","push","draft","live","sitePublish","published","aiStoreFinishHostId","hostId"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GACD,SAASA,UAAU,EAAEC,KAAK,QAAQ,wCAAuC;AACzE,SAASC,qBAAqB,QAAQ,uCAAsC;AAC5E,SACEC,gBAAgB,EAChBC,oBAAoB,QACf,mDAAkD;AACzD,SAASC,2BAA2BC,gBAAgB,EAAEC,kBAAkB,QAAQ,4BAAwB;AAExG,SAASC,qBAAqB,QAAgC,kCAA8B;AAC5F,SAASC,+BAA+B,EAAEC,iCAAiC,QAAQ,mCAA+B;AAElH,4EA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Y,EAAEoC,WAC/BU,KAAKG,KAAK,KAAK,aAAaH,KAAKG,KAAK,KAAK,WACzCjF,WAAWC,MAAMiF,YAAY,EAAEd,WAC/BU,KAAKK,MAAM,GACThF,iBAAiB2E,KAAKG,KAAK,EAAEb,SAASU,KAAKK,MAAM,IACjD/E,qBAAqB0E,KAAKG,KAAK,EAAEb;;IAE7C,IAAI,CAACC,OAAO,OAAOQ;IACnB,4EAA4E;IAC5E,kEAAkE;IAClE,IAAIP,KAAKI,IAAI,CAAC,CAAC9D;YAAWA;eAAAA,EAAAA,mBAAAA,OAAOY,QAAQ,qBAAfZ,gBAAiB,CAAC,aAAa,MAAK;QAAY;QACxEiE,MAAMO,IAAI,CAAC,aAAK1E;YAAmC+B,MAAMzC,WAAWC,MAAMiF,YAAY,EAAEd;;IAC1F;IACA,MAAMiB,QAAQf,KAAKL,IAAI,CAAC,CAACrD;YAA2CA;eAAhCA,OAAOK,QAAQ,KAAK,YAAYL,EAAAA,mBAAAA,OAAOY,QAAQ,qBAAfZ,gBAAiB,CAAC,aAAa,MAAK;;IACxG,MAAM0E,OAAOD,WAASlD,mBAAAA,IAAIoD,WAAW,qBAAfpD,iBAAiBqD,SAAS,CAAChD,MAAM;IACvD,IAAI6C,SAAS,CAACC,MAAMT,MAAMO,IAAI,CAAC,aAAK3E;QAAiCgC,MAAM9B,gBAAgB0E,OAAOxE;;IAClG,OAAOgE;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASY,oBAAoBtD,GAAkC;;QAC7DA;IAAP,gBAAOA,oBAAAA,IAAIG,OAAO,CAAC2B,IAAI,CAAC,CAACrD,SAAWA,OAAOK,QAAQ,KAAK,YAAYL,OAAOG,aAAa,sBAAjFoB,kBAAoFuD,MAAM,mBAAI;AACvG;AAEA,kHAAkH,GAClH,OAAO,MAAMV,+BACX,sHAAqH"}
@@ -26,9 +26,9 @@ import { type AssistEditCanvasContext, type AssistEditProposal } from '../model/
26
26
  * `batch`, so the whole proposal is one undo step and a guard that refuses
27
27
  * part-way leaves nothing behind. Every change is an unsaved edit on the
28
28
  * version the editor has open; saving it stays the author's act, with the
29
- * editor's own control. A version the live site serves is never edited:
30
- * the check refuses it, and the card offers the editor's own new-version
31
- * flow instead.
29
+ * editor's own control. On a version the live site serves, that save writes
30
+ * the page's draft and never the version, so a change lands there too and
31
+ * reaches visitors only when the author publishes (AGL-4116).
32
32
  */
33
33
  /** A node as the canvas holds it — the fields this module reads. */
34
34
  export interface AssistEditCanvasNodeLike {
@@ -87,21 +87,27 @@ export interface AssistEditCanvas {
87
87
  * inside each: enough for a change to the page as a whole, and the prompt asks
88
88
  * for a selection before anything more specific.
89
89
  *
90
+ * With `whole`, it is the whole document instead (AGL-4116), up to
91
+ * `ASSIST_EDIT_WHOLE_MAX_NODES`: every element, in the order it reads on the
92
+ * page, with its settings and its styles. That is what the chat in the
93
+ * Besigner sends, so "change the Get in touch button" finds the button with
94
+ * nothing selected. A document past the cap falls back to the two tiers.
95
+ *
90
96
  * An element is only ever described after its parent, so every ancestor chain
91
97
  * the server checks is whole. `total` counts the document, and each element's
92
98
  * `childCount` stays its real one, so the server can tell the model what the
93
99
  * outline leaves out. The server holds this to its own limits before it quotes
94
100
  * a byte of it; null when the canvas has no document root loaded.
95
101
  */
96
- export declare function describeAssistEditCanvas(canvas: Pick<AssistEditCanvas, 'getNode'>, selectedId: string | null): AssistEditCanvasContext | null;
102
+ export declare function describeAssistEditCanvas(canvas: Pick<AssistEditCanvas, 'getNode'>, selectedId: string | null, options?: {
103
+ whole?: boolean;
104
+ }): AssistEditCanvasContext | null;
97
105
  /** Why a proposal cannot land on the open editor as it stands. */
98
106
  export type AssistEditRefusal =
99
107
  /** No editor is open. */
100
108
  'no-editor'
101
109
  /** The editor open is not the document the proposal was made for. */
102
110
  | 'other-document'
103
- /** The open version is the one the live site serves. */
104
- | 'live-version'
105
111
  /** An element the proposal names has gone or changed since. */
106
112
  | 'stale'
107
113
  /** The canvas's own guards refused part of the change. */
@@ -19,7 +19,7 @@ import { NODE_HIDE_IF_PROP, replaceSubtreeWithInstance, reusableComponentDefinit
19
19
  import { CANVAS_ROOT_ELEMENT_ID } from "@aglyn/aglyn/foundation/constants/canvas";
20
20
  import { NODE_MAX_INTERACTIONS, upsertNodeInteraction } from "@aglyn/aglyn/app-utils/node-interactions";
21
21
  import { stageEditorSessionFields } from "@aglyn/aglyn/plugin-manager/editor-sessions";
22
- import { ASSIST_EDIT_CONTEXT_MAX_NODES, ASSIST_EDIT_CONTEXT_MAX_PROPS, ASSIST_EDIT_OUTLINE_TEXT_CHARS, ASSIST_EDIT_SELECTED_TEXT_CHARS, assistEditOpCounts } from "../model/assist-edit.js";
22
+ import { ASSIST_EDIT_CONTEXT_MAX_NODES, ASSIST_EDIT_CONTEXT_MAX_PROPS, ASSIST_EDIT_OUTLINE_TEXT_CHARS, ASSIST_EDIT_SELECTED_TEXT_CHARS, ASSIST_EDIT_WHOLE_MAX_NODES, assistEditOpCounts } from "../model/assist-edit.js";
23
23
  const UNDESCRIBED_PROP = /^(html|sx|style|className|dangerouslySetInnerHTML|on[A-Z].*)$/;
24
24
  const isRecord = (value)=>typeof value === 'object' && value !== null && !Array.isArray(value);
25
25
  /**
@@ -145,14 +145,22 @@ function describeSx(raw) {
145
145
  * inside each: enough for a change to the page as a whole, and the prompt asks
146
146
  * for a selection before anything more specific.
147
147
  *
148
+ * With `whole`, it is the whole document instead (AGL-4116), up to
149
+ * `ASSIST_EDIT_WHOLE_MAX_NODES`: every element, in the order it reads on the
150
+ * page, with its settings and its styles. That is what the chat in the
151
+ * Besigner sends, so "change the Get in touch button" finds the button with
152
+ * nothing selected. A document past the cap falls back to the two tiers.
153
+ *
148
154
  * An element is only ever described after its parent, so every ancestor chain
149
155
  * the server checks is whole. `total` counts the document, and each element's
150
156
  * `childCount` stays its real one, so the server can tell the model what the
151
157
  * outline leaves out. The server holds this to its own limits before it quotes
152
158
  * a byte of it; null when the canvas has no document root loaded.
153
- */ export function describeAssistEditCanvas(canvas, selectedId) {
159
+ */ export function describeAssistEditCanvas(canvas, selectedId, options = {}) {
154
160
  const root = canvas.getNode(CANVAS_ROOT_ELEMENT_ID);
155
161
  if (!root) return null;
162
+ const whole = options.whole ? describeWholeCanvas(canvas, selectedId) : null;
163
+ if (whole) return whole;
156
164
  const order = [];
157
165
  const seen = new Set();
158
166
  const brief = new Set();
@@ -242,34 +250,14 @@ function describeSx(raw) {
242
250
  }
243
251
  }
244
252
  const nodes = order.map((id)=>{
245
- var _node_parentId, _node_componentId, _ref, _ref1;
246
- var _parent_nodes, _node_nodes;
247
- const node = canvas.getNode(id);
248
- const isRoot = id === CANVAS_ROOT_ELEMENT_ID;
249
- const parentId = isRoot ? null : (_node_parentId = node.parentId) != null ? _node_parentId : null;
250
- const parent = parentId ? canvas.getNode(parentId) : undefined;
251
253
  const isSelected = id === (selected == null ? void 0 : selected.$id);
252
- const isBrief = brief.has(id);
253
- const props = isBrief ? undefined : describeProps(node.props, isSelected ? ASSIST_EDIT_SELECTED_TEXT_CHARS : ASSIST_EDIT_OUTLINE_TEXT_CHARS);
254
- const sx = isSelected ? describeSx(node.sx) : undefined;
255
- const model = like.get(id);
256
- return _extends({
257
- id,
258
- componentId: String((_node_componentId = node.componentId) != null ? _node_componentId : ''),
259
- parentId,
260
- index: Math.max(0, (_ref = parent == null ? void 0 : (_parent_nodes = parent.nodes) == null ? void 0 : _parent_nodes.indexOf(id)) != null ? _ref : 0),
261
- childCount: (_ref1 = (_node_nodes = node.nodes) == null ? void 0 : _node_nodes.length) != null ? _ref1 : 0
262
- }, node.name ? {
263
- name: String(node.name)
264
- } : {}, props ? {
265
- props
266
- } : {}, sx ? {
267
- sx
268
- } : {}, isBrief ? {
269
- brief: true
270
- } : {}, model ? {
271
- like: model
272
- } : {}, isSelected ? summarizeInteractions(node.interactions) : {});
254
+ return outlineElement(canvas, id, {
255
+ selected: isSelected,
256
+ brief: brief.has(id),
257
+ like: like.get(id),
258
+ textChars: isSelected ? ASSIST_EDIT_SELECTED_TEXT_CHARS : ASSIST_EDIT_OUTLINE_TEXT_CHARS,
259
+ styles: isSelected
260
+ });
273
261
  });
274
262
  return {
275
263
  selectedId: (selected == null ? void 0 : selected.$id) && seen.has(selected.$id) ? selected.$id : null,
@@ -277,6 +265,71 @@ function describeSx(raw) {
277
265
  nodes
278
266
  };
279
267
  }
268
+ /** One element as an outline carries it, at the tier it was described in. */ function outlineElement(canvas, id, tier) {
269
+ var _node_parentId, _node_componentId, _ref, _ref1;
270
+ var _parent_nodes, _node_nodes;
271
+ const node = canvas.getNode(id);
272
+ const parentId = id === CANVAS_ROOT_ELEMENT_ID ? null : (_node_parentId = node.parentId) != null ? _node_parentId : null;
273
+ const parent = parentId ? canvas.getNode(parentId) : undefined;
274
+ const props = tier.brief ? undefined : describeProps(node.props, tier.textChars);
275
+ const sx = tier.styles ? describeSx(node.sx) : undefined;
276
+ return _extends({
277
+ id,
278
+ componentId: String((_node_componentId = node.componentId) != null ? _node_componentId : ''),
279
+ parentId,
280
+ index: Math.max(0, (_ref = parent == null ? void 0 : (_parent_nodes = parent.nodes) == null ? void 0 : _parent_nodes.indexOf(id)) != null ? _ref : 0),
281
+ childCount: (_ref1 = (_node_nodes = node.nodes) == null ? void 0 : _node_nodes.length) != null ? _ref1 : 0
282
+ }, node.name ? {
283
+ name: String(node.name)
284
+ } : {}, props ? {
285
+ props
286
+ } : {}, sx ? {
287
+ sx
288
+ } : {}, tier.brief ? {
289
+ brief: true
290
+ } : {}, tier.like ? {
291
+ like: tier.like
292
+ } : {}, tier.selected ? summarizeInteractions(node.interactions) : {});
293
+ }
294
+ /**
295
+ * The whole document as the chat in the Besigner sends it (AGL-4116): every
296
+ * element depth first, children in their stored order, so the outline reads
297
+ * as the page does and each element follows its parent. Null past the cap.
298
+ */ function describeWholeCanvas(canvas, selectedId) {
299
+ const total = countElements(canvas);
300
+ if (total > ASSIST_EDIT_WHOLE_MAX_NODES) return null;
301
+ const selected = selectedId !== CANVAS_ROOT_ELEMENT_ID ? selectedId : null;
302
+ const nodes = [];
303
+ const seen = new Set([
304
+ CANVAS_ROOT_ELEMENT_ID
305
+ ]);
306
+ const pending = [
307
+ CANVAS_ROOT_ELEMENT_ID
308
+ ];
309
+ while(pending.length){
310
+ var _node_nodes;
311
+ const id = pending.pop();
312
+ const node = canvas.getNode(id);
313
+ if (!node) continue;
314
+ nodes.push(outlineElement(canvas, id, {
315
+ selected: id === selected,
316
+ textChars: ASSIST_EDIT_SELECTED_TEXT_CHARS,
317
+ styles: true
318
+ }));
319
+ const children = (_node_nodes = node.nodes) != null ? _node_nodes : [];
320
+ for(let index = children.length - 1; index >= 0; index -= 1){
321
+ if (seen.has(children[index])) continue;
322
+ seen.add(children[index]);
323
+ pending.push(children[index]);
324
+ }
325
+ }
326
+ return {
327
+ selectedId: selected && nodes.some((node)=>node.id === selected) ? selected : null,
328
+ total,
329
+ nodes,
330
+ whole: true
331
+ };
332
+ }
280
333
  /**
281
334
  * The selected element's interactions as the outline carries them
282
335
  * (AGL-3603): name, event and the kinds of its steps — never a selector.
@@ -340,13 +393,10 @@ const STALE = {
340
393
  message: 'This change was proposed for a different document than the one open.'
341
394
  };
342
395
  }
343
- if (session.isLiveVersion()) {
344
- return {
345
- ok: false,
346
- reason: 'live-version',
347
- message: 'This is the version your live site shows. Make a new version first, then apply the change there.'
348
- };
349
- }
396
+ // The version the live site shows takes the change too (AGL-4116): it lands
397
+ // as unsaved edits on the canvas, exactly as the author's own would, and the
398
+ // Besigner's Save on that version writes the page's draft, never the version
399
+ // visitors see. Publishing stays its own deliberate step.
350
400
  for (const op of proposal.ops){
351
401
  switch(op.op){
352
402
  case 'setSeo':