@aglyn/plugins-ai 1.5.0 → 1.6.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-seo-audit-card.component.d.ts +7 -0
- package/src/lib/components/ai-seo-audit-card.component.js +32 -4
- package/src/lib/components/ai-seo-audit-card.component.js.map +1 -1
- package/src/lib/jobs/ai-job-seo-step.d.ts +4 -0
- package/src/lib/jobs/ai-job-seo-step.js +9 -4
- package/src/lib/jobs/ai-job-seo-step.js.map +1 -1
- package/src/lib/jobs/ai-job-settings-step.d.ts +6 -2
- package/src/lib/jobs/ai-job-settings-step.js +45 -6
- package/src/lib/jobs/ai-job-settings-step.js.map +1 -1
- package/src/lib/jobs/ai-site-publish.js +1 -1
- package/src/lib/jobs/ai-site-publish.js.map +1 -1
- package/src/lib/model/ai-site-entity.d.ts +4 -4
- package/src/lib/model/ai-site-entity.js +3 -3
- package/src/lib/model/ai-site-entity.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-ai",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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.
|
|
29
|
-
"@aglyn/shared-data-enums": "1.
|
|
30
|
-
"@aglyn/shared-data-mdi": "1.
|
|
31
|
-
"@aglyn/shared-data-types": "1.
|
|
32
|
-
"@aglyn/shared-ui-email-campaigns": "1.
|
|
33
|
-
"@aglyn/shared-ui-jsx": "1.
|
|
34
|
-
"@aglyn/shared-ui-snackstack": "1.
|
|
35
|
-
"@aglyn/shared-ui-theme": "1.
|
|
36
|
-
"@aglyn/shared-util-email": "1.
|
|
37
|
-
"@aglyn/shared-util-errors": "1.
|
|
38
|
-
"@aglyn/shared-util-http": "1.
|
|
39
|
-
"@aglyn/shared-util-timestamp": "1.
|
|
40
|
-
"@aglyn/shared-util-tools": "1.
|
|
41
|
-
"@aglyn/tenant-data-admin": "1.
|
|
42
|
-
"@aglyn/tenant-feature-instance": "1.
|
|
43
|
-
"@aglyn/tenant-runtime": "1.
|
|
28
|
+
"@aglyn/aglyn": "1.6.0",
|
|
29
|
+
"@aglyn/shared-data-enums": "1.6.0",
|
|
30
|
+
"@aglyn/shared-data-mdi": "1.6.0",
|
|
31
|
+
"@aglyn/shared-data-types": "1.6.0",
|
|
32
|
+
"@aglyn/shared-ui-email-campaigns": "1.6.0",
|
|
33
|
+
"@aglyn/shared-ui-jsx": "1.6.0",
|
|
34
|
+
"@aglyn/shared-ui-snackstack": "1.6.0",
|
|
35
|
+
"@aglyn/shared-ui-theme": "1.6.0",
|
|
36
|
+
"@aglyn/shared-util-email": "1.6.0",
|
|
37
|
+
"@aglyn/shared-util-errors": "1.6.0",
|
|
38
|
+
"@aglyn/shared-util-http": "1.6.0",
|
|
39
|
+
"@aglyn/shared-util-timestamp": "1.6.0",
|
|
40
|
+
"@aglyn/shared-util-tools": "1.6.0",
|
|
41
|
+
"@aglyn/tenant-data-admin": "1.6.0",
|
|
42
|
+
"@aglyn/tenant-feature-instance": "1.6.0",
|
|
43
|
+
"@aglyn/tenant-runtime": "1.6.0",
|
|
44
44
|
"@swc/helpers": "0.5.23"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
@@ -2,6 +2,13 @@ import type { ConsoleHostSeoZoneProps } from '@aglyn/aglyn/plugin-manager/featur
|
|
|
2
2
|
import { type AiSeoSiteFormField } from '../model/ai-seo';
|
|
3
3
|
/** What each site SEO form field is called where the proposal lists it. */
|
|
4
4
|
export declare const AI_SEO_SITE_FIELD_LABELS: Record<AiSeoSiteFormField, string>;
|
|
5
|
+
/**
|
|
6
|
+
* The proposed fields that live on Setup → Business profile's Business details card
|
|
7
|
+
* rather than on this section (AGL-4136). The settings route each to the card
|
|
8
|
+
* that owns it, so they are staged there, and the note under "Put in the
|
|
9
|
+
* form" has to say where they went.
|
|
10
|
+
*/
|
|
11
|
+
export declare const AI_SEO_BUSINESS_DETAILS_FIELDS: readonly AiSeoSiteFormField[];
|
|
5
12
|
export declare function AiSeoAuditCard(props: ConsoleHostSeoZoneProps): import("react").JSX.Element;
|
|
6
13
|
export declare namespace AiSeoAuditCard {
|
|
7
14
|
var displayName: string;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/ 'use client';
|
|
17
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
18
|
import { lockdownRefusalText, parseLockdownRefusal } from "@aglyn/aglyn";
|
|
19
19
|
import { pluginDocsHelp } from "@aglyn/aglyn/app-utils/docs-help";
|
|
20
20
|
import { AppLink, CardDisplay } from "@aglyn/shared-ui-jsx";
|
|
@@ -39,7 +39,9 @@ import { readEventFrames } from "./assist-jobs-drawer.component.js";
|
|
|
39
39
|
* keywords are the ones the check was last run with (`check.keywords`).
|
|
40
40
|
*
|
|
41
41
|
* Nothing it shows is saved. "Put in the form" stages the site-wide proposal
|
|
42
|
-
* in the SEO
|
|
42
|
+
* in the SEO forms below as unsaved edits — the name, email and phone in
|
|
43
|
+
* Setup → Business profile's Business details, where they are entered (AGL-4136) —
|
|
44
|
+
* and each form's Update is the write.
|
|
43
45
|
* "Apply all" does that too, and asks the apply door to open a new
|
|
44
46
|
* unpublished version for each page's content fixes and to stage each page's
|
|
45
47
|
* listing for its SEO card — the live site serves none of it until a person
|
|
@@ -60,6 +62,16 @@ const ENTITY_TYPE_WORDS = {
|
|
|
60
62
|
'1': 'An organization',
|
|
61
63
|
'2': 'A person'
|
|
62
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* The proposed fields that live on Setup → Business profile's Business details card
|
|
67
|
+
* rather than on this section (AGL-4136). The settings route each to the card
|
|
68
|
+
* that owns it, so they are staged there, and the note under "Put in the
|
|
69
|
+
* form" has to say where they went.
|
|
70
|
+
*/ export const AI_SEO_BUSINESS_DETAILS_FIELDS = [
|
|
71
|
+
'seo.entity.name',
|
|
72
|
+
'seo.entity.email',
|
|
73
|
+
'seo.entity.telephone'
|
|
74
|
+
];
|
|
63
75
|
/** One page's proposed fix, in a sentence a table cell can hold. */ function fixSummary(fix) {
|
|
64
76
|
if (!fix) return '';
|
|
65
77
|
const parts = [];
|
|
@@ -217,6 +229,9 @@ export function AiSeoAuditCard(props) {
|
|
|
217
229
|
]);
|
|
218
230
|
const siteValues = (_ref2 = view == null ? void 0 : (_view_site = view.site) == null ? void 0 : _view_site.values) != null ? _ref2 : {};
|
|
219
231
|
const siteFields = Object.keys(siteValues);
|
|
232
|
+
// Where "Put in the form" staged each proposed field (AGL-4136).
|
|
233
|
+
const stagedOnBusiness = siteFields.some((field)=>AI_SEO_BUSINESS_DETAILS_FIELDS.includes(field));
|
|
234
|
+
const stagedHere = siteFields.some((field)=>!AI_SEO_BUSINESS_DETAILS_FIELDS.includes(field));
|
|
220
235
|
const stageSite = useCallback(()=>{
|
|
221
236
|
if (!job || !siteFields.length) return;
|
|
222
237
|
proposeDraft(siteValues, `${job.id}:site`);
|
|
@@ -413,9 +428,22 @@ export function AiSeoAuditCard(props) {
|
|
|
413
428
|
onClick: stageSite,
|
|
414
429
|
children: 'Put in the form'
|
|
415
430
|
}),
|
|
416
|
-
siteStaged === job.id ? /*#__PURE__*/
|
|
431
|
+
siteStaged === job.id ? /*#__PURE__*/ _jsxs(Alert, {
|
|
417
432
|
severity: "success",
|
|
418
|
-
children:
|
|
433
|
+
children: [
|
|
434
|
+
stagedHere ? 'In the SEO forms below as unsaved changes. Review them, then press Update.' : null,
|
|
435
|
+
stagedOnBusiness ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
436
|
+
children: [
|
|
437
|
+
stagedHere ? ' ' : '',
|
|
438
|
+
'The name, email and phone are in Business details on ',
|
|
439
|
+
host ? /*#__PURE__*/ _jsx(AppLink, {
|
|
440
|
+
href: `/${orgSlug}/hosts/${host}/setup/business`,
|
|
441
|
+
children: 'Setup → Business profile'
|
|
442
|
+
}) : 'Setup → Business profile',
|
|
443
|
+
' as unsaved changes. Review them there, then press Update.'
|
|
444
|
+
]
|
|
445
|
+
}) : null
|
|
446
|
+
]
|
|
419
447
|
}) : null
|
|
420
448
|
]
|
|
421
449
|
}) : null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-seo-audit-card.component.tsx"],"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'use client'\n\nimport { lockdownRefusalText, parseLockdownRefusal } from '@aglyn/aglyn'\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport type { ConsoleHostSeoZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { AppLink, CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport { ScrollTable } from '@aglyn/shared-ui-jsx/components/scroll-table.component'\nimport { TABLE_PAGE_SIZE_DEFAULT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n CircularProgress,\n Collapse,\n Stack,\n TableBody,\n TableCell,\n TableHead,\n TableRow,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { AI_JOB_TERMINAL_STATUSES, type AiJobSummary } from '../model/ai-jobs.types'\nimport {\n aiSeoApplyCounts,\n aiSeoAuditView,\n type AiSeoPageFix,\n type AiSeoSiteFormField,\n} from '../model/ai-seo'\nimport { readEventFrames } from './assist-jobs-drawer.component'\n\n/**\n * SEO fixes (AGL-2910), on the site's SEO section through the `hostSeo` zone,\n * under the platform's SEO check. The check lists what is wrong for every\n * site owner; this card adds what only a model can: a person asks, and an\n * `seo` job audits the same pages through the same check, proposes a fix per\n * finding, and drafts the structured data and the agent guidance\n * `/llms.txt` leads with. The findings are never listed here — the check\n * above draws them — so this card shows the fixes, page by page. The target\n * keywords are the ones the check was last run with (`check.keywords`).\n *\n * Nothing it shows is saved. \"Put in the form\" stages the site-wide proposal\n * in the SEO form below as unsaved edits, and the form's Update is the write.\n * \"Apply all\" does that too, and asks the apply door to open a new\n * unpublished version for each page's content fixes and to stage each page's\n * listing for its SEO card — the live site serves none of it until a person\n * saves or publishes.\n */\n\n/** How many recent jobs the card reads to find this site's last audit. */\nconst RECENT_JOBS_READ = 20\n\ntype Verdict = 'checking' | 'ready' | 'hidden'\n\ninterface ApplyResult {\n versions: Array<{ screenId: string; versionId: string; name: string; fixes: number }>\n staged: string[]\n skipped: Array<{ screenId: string; reason: string }>\n}\n\nconst isTerminal = (job: AiJobSummary) => AI_JOB_TERMINAL_STATUSES.includes(job.status)\n\n/** What each site SEO form field is called where the proposal lists it. */\nexport const AI_SEO_SITE_FIELD_LABELS: Record<AiSeoSiteFormField, string> = {\n 'seo.entity.type': 'Published by',\n 'seo.entity.name': 'Name',\n 'seo.entity.description': 'Description',\n 'seo.entity.email': 'Contact email',\n 'seo.entity.telephone': 'Contact phone',\n 'seo.entity.contactType': 'Contact is for',\n 'seo.agent.whenToUse': 'When to use this site',\n 'seo.agent.howToUse': 'How an agent should call you',\n}\n\nconst ENTITY_TYPE_WORDS: Record<string, string> = { '1': 'An organization', '2': 'A person' }\n\n/** One page's proposed fix, in a sentence a table cell can hold. */\nfunction fixSummary(fix: AiSeoPageFix | undefined): string {\n if (!fix) return ''\n const parts: string[] = []\n if (fix.values.title) parts.push(`Title: ${fix.values.title}`)\n if (fix.values.description) parts.push(`Description: ${fix.values.description}`)\n const alts = fix.content.filter((entry) => entry.kind === 'image-alt').length\n if (alts) parts.push(`${alts} image ${alts === 1 ? 'description' : 'descriptions'}`)\n if (fix.content.some((entry) => entry.kind !== 'image-alt')) parts.push('One main heading')\n parts.push(...fix.guidance)\n return parts.join(' · ')\n}\n\nexport function AiSeoAuditCard(props: ConsoleHostSeoZoneProps) {\n const { hostId, orgId, orgSlug, host, proposeDraft, check } = props\n const keywords = check?.keywords ?? ''\n const { data: user } = useUser()\n const userRef = useRef(user)\n userRef.current = user\n const uid = user?.uid ?? null\n\n const [verdict, setVerdict] = useState<Verdict>('checking')\n const [notice, setNotice] = useState<string | null>(null)\n const [busy, setBusy] = useState(false)\n const [job, setJob] = useState<AiJobSummary | null>(null)\n const [siteStaged, setSiteStaged] = useState<string | null>(null)\n const [applying, setApplying] = useState(false)\n const [applied, setApplied] = useState<ApplyResult | null>(null)\n const [previewOpen, setPreviewOpen] = useState(false)\n const [page, setPage] = useState(0)\n const [pageSize, setPageSize] = useState(TABLE_PAGE_SIZE_DEFAULT)\n const watchRef = useRef<AbortController | null>(null)\n\n useEffect(() => () => watchRef.current?.abort(), [])\n\n useEffect(() => {\n if (!orgId || !hostId || !uid) return\n let active = true\n setVerdict('checking')\n void (async () => {\n try {\n const response = await authorizedFetch(\n userRef.current,\n `/api/ai/jobs?orgId=${encodeURIComponent(orgId)}&limit=${RECENT_JOBS_READ}`,\n )\n if (!active) return\n if (response.status === 404 || response.status === 403) {\n setVerdict('hidden')\n return\n }\n const payload = await response.json().catch(() => null)\n if (!active) return\n if (!response.ok) {\n const locked = parseLockdownRefusal(response.status, payload)\n setNotice(\n locked\n ? lockdownRefusalText(locked)\n : String(payload?.error ?? 'The last SEO audit could not be loaded.'),\n )\n } else {\n // An audit is the SEO job whose outputs carry a report; the summary\n // does not carry a job's inputs.\n const latest = ((payload?.jobs ?? []) as AiJobSummary[]).find(\n (entry) => entry.kind === 'seo' && entry.hostId === hostId && aiSeoAuditView(entry.outputs) !== null,\n )\n if (latest) setJob(latest)\n }\n setVerdict('ready')\n } catch {\n if (!active) return\n setNotice('The last SEO audit could not be loaded.')\n setVerdict('ready')\n }\n })()\n return () => {\n active = false\n }\n }, [orgId, hostId, uid])\n\n /** Follows a job through the events route until it settles. */\n const watch = useCallback(async (jobId: string, org: string) => {\n watchRef.current?.abort()\n const controller = new AbortController()\n watchRef.current = controller\n let again = true\n while (again && !controller.signal.aborted) {\n again = false\n try {\n const response = await authorizedFetch(\n userRef.current,\n `/api/ai/jobs/${encodeURIComponent(jobId)}/events?orgId=${encodeURIComponent(org)}`,\n { signal: controller.signal },\n )\n if (!response.ok || !response.body) return\n await readEventFrames(response.body, (event) => {\n if (event['type'] === 'state') setJob(event['job'] as AiJobSummary)\n else if (event['type'] === 'reconnect') again = true\n })\n } catch {\n return\n }\n }\n }, [])\n\n // A job the card did not start, still moving, is followed too.\n const followId = job && !isTerminal(job) && !busy ? job.id : null\n useEffect(() => {\n if (followId && orgId) void watch(followId, orgId)\n }, [followId, orgId, watch])\n\n const run = useCallback(async () => {\n if (!orgId) return\n setBusy(true)\n setNotice(null)\n setApplied(null)\n setSiteStaged(null)\n setPage(0)\n try {\n const response = await authorizedFetch(userRef.current, '/api/ai/jobs', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n orgId,\n hostId,\n kind: 'seo',\n brief: 'Propose fixes for the SEO of this site',\n inputs: { target: 'site', keywords: keywords.trim() },\n }),\n })\n const payload = await response.json().catch(() => null)\n if (!response.ok) {\n const locked = parseLockdownRefusal(response.status, payload)\n setNotice(\n locked\n ? lockdownRefusalText(locked)\n : String(payload?.error ?? 'The SEO audit could not be started — try again.'),\n )\n return\n }\n const next = payload?.job as AiJobSummary | undefined\n if (!next) return\n setJob(next)\n if (!isTerminal(next)) await watch(next.id, orgId)\n } catch {\n setNotice('The SEO audit could not be started — try again.')\n } finally {\n setBusy(false)\n }\n }, [orgId, hostId, keywords, watch])\n\n const view = useMemo(() => (job ? aiSeoAuditView(job.outputs) : null), [job])\n const siteValues = view?.site?.values ?? {}\n const siteFields = Object.keys(siteValues) as AiSeoSiteFormField[]\n\n const stageSite = useCallback(() => {\n if (!job || !siteFields.length) return\n proposeDraft(siteValues as Record<string, string>, `${job.id}:site`)\n setSiteStaged(job.id)\n }, [job, siteFields.length, siteValues, proposeDraft])\n\n const applyAll = useCallback(async () => {\n if (!job || !orgId) return\n setApplying(true)\n setNotice(null)\n stageSite()\n try {\n const response = await authorizedFetch(userRef.current, '/api/ai/seo/apply', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ orgId, hostId, jobId: job.id }),\n })\n const payload = await response.json().catch(() => null)\n if (!response.ok) {\n const locked = parseLockdownRefusal(response.status, payload)\n setNotice(\n locked ? lockdownRefusalText(locked) : String(payload?.error ?? 'The fixes could not be applied — try again.'),\n )\n return\n }\n if (payload?.job) setJob(payload.job as AiJobSummary)\n setApplied({\n versions: payload?.versions ?? [],\n staged: payload?.staged ?? [],\n skipped: payload?.skipped ?? [],\n })\n } catch {\n setNotice('The fixes could not be applied — try again.')\n } finally {\n setApplying(false)\n }\n }, [job, orgId, hostId, stageSite])\n\n if (verdict !== 'ready') return null\n\n const running = Boolean(job && !isTerminal(job))\n const report = view?.report ?? null\n const owedBatches = report ? Math.ceil(report.queue.length / Math.max(1, report.batchSize)) : 0\n const counts = view ? aiSeoApplyCounts(view) : { pagesWithContent: 0, pagesWithValues: 0 }\n const somethingToApply = counts.pagesWithContent + counts.pagesWithValues + siteFields.length > 0\n // The pages a fix was proposed for, or is still owed to; the check above lists the rest.\n const fixRows = report\n ? report.pages.filter((entry) => view?.fixes[entry.screenId] || report.queue.includes(entry.screenId))\n : []\n const pageRows = fixRows.slice(page * pageSize, (page + 1) * pageSize)\n const names = new Map((report?.pages ?? []).map((entry) => [entry.screenId, entry]))\n const pageLink = (screenId: string, versionId: string | null, surface: 'view' | 'besigner') =>\n host && versionId\n ? `/${orgSlug}/hosts/${host}/screens/${screenId}/versions/${versionId}/${surface}`\n : null\n\n return (\n <CardDisplay\n contentGutterX\n contentGutterY\n header=\"SEO fixes\"\n help={pluginDocsHelp('aiSeo', {\n anchor: '#fix-what-the-seo-check-finds',\n excerpt:\n 'Get a proposed fix for each finding of the SEO check. Nothing changes on your live site until you save or publish.',\n })}\n >\n <Stack spacing={2}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {keywords\n ? 'Proposes a fix for each finding of the SEO check above, using the target keywords it was run with. Nothing changes on your live site until you save or publish it.'\n : 'Proposes a fix for each finding of the SEO check above. Nothing changes on your live site until you save or publish it.'}\n </Typography>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Button variant=\"contained\" disabled={busy || running || !orgId} onClick={() => void run()}>\n {report ? 'Propose fixes again' : 'Propose fixes'}\n </Button>\n {running ? <CircularProgress size={18} aria-label=\"Proposing fixes\" /> : null}\n {running && report ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Proposing fixes: ${view?.batches ?? 0} of ${owedBatches} batches`}\n </Typography>\n ) : null}\n </Stack>\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n {job?.error ? <Alert severity={job.status === 'failed' ? 'error' : 'warning'}>{job.error}</Alert> : null}\n\n {report && job ? (\n <Stack spacing={2} aria-label=\"SEO fixes\">\n {job.creditsSpent > 0 ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`These fixes used ${job.creditsSpent} ${job.creditsSpent === 1 ? 'credit' : 'credits'}.`}\n </Typography>\n ) : null}\n\n {view?.site ? (\n <Stack spacing={1} aria-label=\"Structured data and agent guidance\">\n <Typography variant=\"subtitle2\">{'Structured data and AI agent guidance'}</Typography>\n {siteFields.length ? (\n siteFields.map((field) => (\n <Stack key={field} spacing={0.25}>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {AI_SEO_SITE_FIELD_LABELS[field]}\n </Typography>\n <Typography variant=\"body2\" sx={{ wordBreak: 'break-word' }}>\n {field === 'seo.entity.type' ? (ENTITY_TYPE_WORDS[siteValues[field] ?? ''] ?? siteValues[field]) : siteValues[field]}\n </Typography>\n </Stack>\n ))\n ) : (\n <Typography variant=\"body2\">{'Nothing to add: the site’s structured data and guidance are already filled in.'}</Typography>\n )}\n {view.site.notes.map((note) => (\n <Typography key={note} variant=\"caption\" color=\"text.secondary\">\n {note}\n </Typography>\n ))}\n <Button size=\"small\" sx={{ alignSelf: 'flex-start' }} onClick={() => setPreviewOpen((open) => !open)}>\n {previewOpen ? 'Hide the /llms.txt preview' : 'Preview /llms.txt'}\n </Button>\n <Collapse in={previewOpen} unmountOnExit>\n <Box\n component=\"pre\"\n sx={{ m: 0, p: 1.5, bgcolor: 'action.hover', borderRadius: 1, whiteSpace: 'pre-wrap', fontSize: 12 }}\n >\n {view.site.llmsPreview}\n </Box>\n </Collapse>\n <Button\n size=\"small\"\n variant=\"outlined\"\n sx={{ alignSelf: 'flex-start' }}\n disabled={!siteFields.length || siteStaged === job.id}\n onClick={stageSite}\n >\n {'Put in the form'}\n </Button>\n {siteStaged === job.id ? (\n <Alert severity=\"success\">{'In the SEO form below as unsaved changes. Review them, then press Update.'}</Alert>\n ) : null}\n </Stack>\n ) : null}\n\n {fixRows.length ? (\n <Box>\n <ScrollTable size=\"small\" aria-label=\"Proposed fixes\">\n <TableHead>\n <TableRow>\n <TableCell>{'Page'}</TableCell>\n <TableCell>{'Proposed'}</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {pageRows.map((row) => (\n <TableRow key={row.screenId}>\n <TableCell>\n <Typography variant=\"body2\">{row.name}</Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {row.path}\n </Typography>\n </TableCell>\n <TableCell>\n <Typography variant=\"body2\" sx={{ wordBreak: 'break-word' }}>\n {fixSummary(view?.fixes[row.screenId]) || (running ? 'Being proposed…' : '')}\n </Typography>\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </ScrollTable>\n <ListPagination\n page={page}\n pageSize={pageSize}\n rowCount={pageRows.length}\n count={fixRows.length}\n onPageChange={setPage}\n onPageSizeChange={(size) => {\n setPageSize(size)\n setPage(0)\n }}\n />\n </Box>\n ) : (\n <Typography variant=\"body2\">\n {report.pages.length\n ? 'No page needs a written fix.'\n : 'This site has no published public pages to fix.'}\n </Typography>\n )}\n\n <Stack spacing={1}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Apply all opens a new draft version of each page with content fixes, puts proposed titles and descriptions in each page’s SEO card, and puts the structured data and guidance in the form below. You review and save or publish each of them.'}\n </Typography>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Button\n variant=\"contained\"\n disabled={applying || running || job.status !== 'done' || !view?.complete || !somethingToApply}\n onClick={() => void applyAll()}\n >\n {'Apply all as drafts'}\n </Button>\n {applying ? <CircularProgress size={18} aria-label=\"Applying the fixes\" /> : null}\n </Stack>\n </Stack>\n\n {applied ? (\n <Stack spacing={1} aria-label=\"Applied fixes\">\n {applied.versions.map((entry) => {\n const href = pageLink(entry.screenId, entry.versionId, 'besigner')\n return (\n <Typography key={entry.screenId} variant=\"body2\">\n {href ? (\n <AppLink componentVariant=\"naked\" href={href}>\n {`Open the draft of ${entry.name}`}\n </AppLink>\n ) : (\n `A draft of ${entry.name} is ready`\n )}\n </Typography>\n )\n })}\n {applied.staged.map((screenId) => {\n const audited = names.get(screenId)\n const href = pageLink(screenId, audited?.versionId ?? null, 'view')\n return (\n <Typography key={`staged:${screenId}`} variant=\"body2\">\n {href ? (\n <AppLink componentVariant=\"naked\" href={href}>\n {`Review the listing for ${audited?.name ?? screenId}`}\n </AppLink>\n ) : (\n `A listing for ${audited?.name ?? screenId} waits in its SEO card`\n )}\n </Typography>\n )\n })}\n {applied.skipped.map((entry) => (\n <Typography key={`skipped:${entry.screenId}`} variant=\"caption\" color=\"text.secondary\">\n {`${names.get(entry.screenId)?.name ?? entry.screenId}: ${entry.reason}`}\n </Typography>\n ))}\n </Stack>\n ) : null}\n </Stack>\n ) : null}\n </Stack>\n </CardDisplay>\n )\n}\nAiSeoAuditCard.displayName = 'AiSeoAuditCard'\n\nexport default AiSeoAuditCard\n"],"names":["lockdownRefusalText","parseLockdownRefusal","pluginDocsHelp","AppLink","CardDisplay","ListPagination","ScrollTable","TABLE_PAGE_SIZE_DEFAULT","authorizedFetch","useUser","Alert","Box","Button","CircularProgress","Collapse","Stack","TableBody","TableCell","TableHead","TableRow","Typography","useCallback","useEffect","useMemo","useRef","useState","AI_JOB_TERMINAL_STATUSES","aiSeoApplyCounts","aiSeoAuditView","readEventFrames","RECENT_JOBS_READ","isTerminal","job","includes","status","AI_SEO_SITE_FIELD_LABELS","ENTITY_TYPE_WORDS","fixSummary","fix","parts","values","title","push","description","alts","content","filter","entry","kind","length","some","guidance","join","AiSeoAuditCard","props","view","hostId","orgId","orgSlug","host","proposeDraft","check","keywords","data","user","userRef","current","uid","verdict","setVerdict","notice","setNotice","busy","setBusy","setJob","siteStaged","setSiteStaged","applying","setApplying","applied","setApplied","previewOpen","setPreviewOpen","page","setPage","pageSize","setPageSize","watchRef","abort","active","response","encodeURIComponent","payload","json","catch","ok","locked","String","error","latest","jobs","find","outputs","watch","jobId","org","controller","AbortController","again","signal","aborted","body","event","followId","id","run","method","headers","JSON","stringify","brief","inputs","target","trim","next","siteValues","site","siteFields","Object","keys","stageSite","applyAll","versions","staged","skipped","running","Boolean","report","owedBatches","Math","ceil","queue","max","batchSize","counts","pagesWithContent","pagesWithValues","somethingToApply","fixRows","pages","fixes","screenId","pageRows","slice","names","Map","map","pageLink","versionId","surface","contentGutterX","contentGutterY","header","help","anchor","excerpt","spacing","variant","color","direction","sx","alignItems","disabled","onClick","size","aria-label","batches","severity","creditsSpent","field","wordBreak","notes","note","alignSelf","open","in","unmountOnExit","component","m","p","bgcolor","borderRadius","whiteSpace","fontSize","llmsPreview","row","name","path","rowCount","count","onPageChange","onPageSizeChange","complete","href","componentVariant","audited","get","reason","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,mBAAmB,EAAEC,oBAAoB,QAAQ,eAAc;AACxE,SAASC,cAAc,QAAQ,mCAAkC;AAEjE,SAASC,OAAO,EAAEC,WAAW,QAAQ,uBAAsB;AAC3D,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,yDAAwD;AACpF,SAASC,uBAAuB,QAAQ,8CAA6C;AACrF,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,gBAAgB,EAChBC,QAAQ,EACRC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,SAAS,EACTC,QAAQ,EACRC,UAAU,QACL,gBAAe;AACtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AACzE,SAASC,wBAAwB,QAA2B,4BAAwB;AACpF,SACEC,gBAAgB,EAChBC,cAAc,QAGT,qBAAiB;AACxB,SAASC,eAAe,QAAQ,oCAAgC;AAEhE;;;;;;;;;;;;;;;;CAgBC,GAED,wEAAwE,GACxE,MAAMC,mBAAmB;AAUzB,MAAMC,aAAa,CAACC,MAAsBN,yBAAyBO,QAAQ,CAACD,IAAIE,MAAM;AAEtF,yEAAyE,GACzE,OAAO,MAAMC,2BAA+D;IAC1E,mBAAmB;IACnB,mBAAmB;IACnB,0BAA0B;IAC1B,oBAAoB;IACpB,wBAAwB;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;AAE7B,eAAe3J,eAAc"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-seo-audit-card.component.tsx"],"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'use client'\n\nimport { lockdownRefusalText, parseLockdownRefusal } from '@aglyn/aglyn'\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport type { ConsoleHostSeoZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { AppLink, CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport { ScrollTable } from '@aglyn/shared-ui-jsx/components/scroll-table.component'\nimport { TABLE_PAGE_SIZE_DEFAULT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n CircularProgress,\n Collapse,\n Stack,\n TableBody,\n TableCell,\n TableHead,\n TableRow,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { AI_JOB_TERMINAL_STATUSES, type AiJobSummary } from '../model/ai-jobs.types'\nimport {\n aiSeoApplyCounts,\n aiSeoAuditView,\n type AiSeoPageFix,\n type AiSeoSiteFormField,\n} from '../model/ai-seo'\nimport { readEventFrames } from './assist-jobs-drawer.component'\n\n/**\n * SEO fixes (AGL-2910), on the site's SEO section through the `hostSeo` zone,\n * under the platform's SEO check. The check lists what is wrong for every\n * site owner; this card adds what only a model can: a person asks, and an\n * `seo` job audits the same pages through the same check, proposes a fix per\n * finding, and drafts the structured data and the agent guidance\n * `/llms.txt` leads with. The findings are never listed here — the check\n * above draws them — so this card shows the fixes, page by page. The target\n * keywords are the ones the check was last run with (`check.keywords`).\n *\n * Nothing it shows is saved. \"Put in the form\" stages the site-wide proposal\n * in the SEO forms below as unsaved edits — the name, email and phone in\n * Setup → Business profile's Business details, where they are entered (AGL-4136) —\n * and each form's Update is the write.\n * \"Apply all\" does that too, and asks the apply door to open a new\n * unpublished version for each page's content fixes and to stage each page's\n * listing for its SEO card — the live site serves none of it until a person\n * saves or publishes.\n */\n\n/** How many recent jobs the card reads to find this site's last audit. */\nconst RECENT_JOBS_READ = 20\n\ntype Verdict = 'checking' | 'ready' | 'hidden'\n\ninterface ApplyResult {\n versions: Array<{ screenId: string; versionId: string; name: string; fixes: number }>\n staged: string[]\n skipped: Array<{ screenId: string; reason: string }>\n}\n\nconst isTerminal = (job: AiJobSummary) => AI_JOB_TERMINAL_STATUSES.includes(job.status)\n\n/** What each site SEO form field is called where the proposal lists it. */\nexport const AI_SEO_SITE_FIELD_LABELS: Record<AiSeoSiteFormField, string> = {\n 'seo.entity.type': 'Published by',\n 'seo.entity.name': 'Name',\n 'seo.entity.description': 'Description',\n 'seo.entity.email': 'Contact email',\n 'seo.entity.telephone': 'Contact phone',\n 'seo.entity.contactType': 'Contact is for',\n 'seo.agent.whenToUse': 'When to use this site',\n 'seo.agent.howToUse': 'How an agent should call you',\n}\n\nconst ENTITY_TYPE_WORDS: Record<string, string> = { '1': 'An organization', '2': 'A person' }\n\n/**\n * The proposed fields that live on Setup → Business profile's Business details card\n * rather than on this section (AGL-4136). The settings route each to the card\n * that owns it, so they are staged there, and the note under \"Put in the\n * form\" has to say where they went.\n */\nexport const AI_SEO_BUSINESS_DETAILS_FIELDS: readonly AiSeoSiteFormField[] = [\n 'seo.entity.name',\n 'seo.entity.email',\n 'seo.entity.telephone',\n]\n\n/** One page's proposed fix, in a sentence a table cell can hold. */\nfunction fixSummary(fix: AiSeoPageFix | undefined): string {\n if (!fix) return ''\n const parts: string[] = []\n if (fix.values.title) parts.push(`Title: ${fix.values.title}`)\n if (fix.values.description) parts.push(`Description: ${fix.values.description}`)\n const alts = fix.content.filter((entry) => entry.kind === 'image-alt').length\n if (alts) parts.push(`${alts} image ${alts === 1 ? 'description' : 'descriptions'}`)\n if (fix.content.some((entry) => entry.kind !== 'image-alt')) parts.push('One main heading')\n parts.push(...fix.guidance)\n return parts.join(' · ')\n}\n\nexport function AiSeoAuditCard(props: ConsoleHostSeoZoneProps) {\n const { hostId, orgId, orgSlug, host, proposeDraft, check } = props\n const keywords = check?.keywords ?? ''\n const { data: user } = useUser()\n const userRef = useRef(user)\n userRef.current = user\n const uid = user?.uid ?? null\n\n const [verdict, setVerdict] = useState<Verdict>('checking')\n const [notice, setNotice] = useState<string | null>(null)\n const [busy, setBusy] = useState(false)\n const [job, setJob] = useState<AiJobSummary | null>(null)\n const [siteStaged, setSiteStaged] = useState<string | null>(null)\n const [applying, setApplying] = useState(false)\n const [applied, setApplied] = useState<ApplyResult | null>(null)\n const [previewOpen, setPreviewOpen] = useState(false)\n const [page, setPage] = useState(0)\n const [pageSize, setPageSize] = useState(TABLE_PAGE_SIZE_DEFAULT)\n const watchRef = useRef<AbortController | null>(null)\n\n useEffect(() => () => watchRef.current?.abort(), [])\n\n useEffect(() => {\n if (!orgId || !hostId || !uid) return\n let active = true\n setVerdict('checking')\n void (async () => {\n try {\n const response = await authorizedFetch(\n userRef.current,\n `/api/ai/jobs?orgId=${encodeURIComponent(orgId)}&limit=${RECENT_JOBS_READ}`,\n )\n if (!active) return\n if (response.status === 404 || response.status === 403) {\n setVerdict('hidden')\n return\n }\n const payload = await response.json().catch(() => null)\n if (!active) return\n if (!response.ok) {\n const locked = parseLockdownRefusal(response.status, payload)\n setNotice(\n locked\n ? lockdownRefusalText(locked)\n : String(payload?.error ?? 'The last SEO audit could not be loaded.'),\n )\n } else {\n // An audit is the SEO job whose outputs carry a report; the summary\n // does not carry a job's inputs.\n const latest = ((payload?.jobs ?? []) as AiJobSummary[]).find(\n (entry) => entry.kind === 'seo' && entry.hostId === hostId && aiSeoAuditView(entry.outputs) !== null,\n )\n if (latest) setJob(latest)\n }\n setVerdict('ready')\n } catch {\n if (!active) return\n setNotice('The last SEO audit could not be loaded.')\n setVerdict('ready')\n }\n })()\n return () => {\n active = false\n }\n }, [orgId, hostId, uid])\n\n /** Follows a job through the events route until it settles. */\n const watch = useCallback(async (jobId: string, org: string) => {\n watchRef.current?.abort()\n const controller = new AbortController()\n watchRef.current = controller\n let again = true\n while (again && !controller.signal.aborted) {\n again = false\n try {\n const response = await authorizedFetch(\n userRef.current,\n `/api/ai/jobs/${encodeURIComponent(jobId)}/events?orgId=${encodeURIComponent(org)}`,\n { signal: controller.signal },\n )\n if (!response.ok || !response.body) return\n await readEventFrames(response.body, (event) => {\n if (event['type'] === 'state') setJob(event['job'] as AiJobSummary)\n else if (event['type'] === 'reconnect') again = true\n })\n } catch {\n return\n }\n }\n }, [])\n\n // A job the card did not start, still moving, is followed too.\n const followId = job && !isTerminal(job) && !busy ? job.id : null\n useEffect(() => {\n if (followId && orgId) void watch(followId, orgId)\n }, [followId, orgId, watch])\n\n const run = useCallback(async () => {\n if (!orgId) return\n setBusy(true)\n setNotice(null)\n setApplied(null)\n setSiteStaged(null)\n setPage(0)\n try {\n const response = await authorizedFetch(userRef.current, '/api/ai/jobs', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n orgId,\n hostId,\n kind: 'seo',\n brief: 'Propose fixes for the SEO of this site',\n inputs: { target: 'site', keywords: keywords.trim() },\n }),\n })\n const payload = await response.json().catch(() => null)\n if (!response.ok) {\n const locked = parseLockdownRefusal(response.status, payload)\n setNotice(\n locked\n ? lockdownRefusalText(locked)\n : String(payload?.error ?? 'The SEO audit could not be started — try again.'),\n )\n return\n }\n const next = payload?.job as AiJobSummary | undefined\n if (!next) return\n setJob(next)\n if (!isTerminal(next)) await watch(next.id, orgId)\n } catch {\n setNotice('The SEO audit could not be started — try again.')\n } finally {\n setBusy(false)\n }\n }, [orgId, hostId, keywords, watch])\n\n const view = useMemo(() => (job ? aiSeoAuditView(job.outputs) : null), [job])\n const siteValues = view?.site?.values ?? {}\n const siteFields = Object.keys(siteValues) as AiSeoSiteFormField[]\n // Where \"Put in the form\" staged each proposed field (AGL-4136).\n const stagedOnBusiness = siteFields.some((field) => AI_SEO_BUSINESS_DETAILS_FIELDS.includes(field))\n const stagedHere = siteFields.some((field) => !AI_SEO_BUSINESS_DETAILS_FIELDS.includes(field))\n\n const stageSite = useCallback(() => {\n if (!job || !siteFields.length) return\n proposeDraft(siteValues as Record<string, string>, `${job.id}:site`)\n setSiteStaged(job.id)\n }, [job, siteFields.length, siteValues, proposeDraft])\n\n const applyAll = useCallback(async () => {\n if (!job || !orgId) return\n setApplying(true)\n setNotice(null)\n stageSite()\n try {\n const response = await authorizedFetch(userRef.current, '/api/ai/seo/apply', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ orgId, hostId, jobId: job.id }),\n })\n const payload = await response.json().catch(() => null)\n if (!response.ok) {\n const locked = parseLockdownRefusal(response.status, payload)\n setNotice(\n locked ? lockdownRefusalText(locked) : String(payload?.error ?? 'The fixes could not be applied — try again.'),\n )\n return\n }\n if (payload?.job) setJob(payload.job as AiJobSummary)\n setApplied({\n versions: payload?.versions ?? [],\n staged: payload?.staged ?? [],\n skipped: payload?.skipped ?? [],\n })\n } catch {\n setNotice('The fixes could not be applied — try again.')\n } finally {\n setApplying(false)\n }\n }, [job, orgId, hostId, stageSite])\n\n if (verdict !== 'ready') return null\n\n const running = Boolean(job && !isTerminal(job))\n const report = view?.report ?? null\n const owedBatches = report ? Math.ceil(report.queue.length / Math.max(1, report.batchSize)) : 0\n const counts = view ? aiSeoApplyCounts(view) : { pagesWithContent: 0, pagesWithValues: 0 }\n const somethingToApply = counts.pagesWithContent + counts.pagesWithValues + siteFields.length > 0\n // The pages a fix was proposed for, or is still owed to; the check above lists the rest.\n const fixRows = report\n ? report.pages.filter((entry) => view?.fixes[entry.screenId] || report.queue.includes(entry.screenId))\n : []\n const pageRows = fixRows.slice(page * pageSize, (page + 1) * pageSize)\n const names = new Map((report?.pages ?? []).map((entry) => [entry.screenId, entry]))\n const pageLink = (screenId: string, versionId: string | null, surface: 'view' | 'besigner') =>\n host && versionId\n ? `/${orgSlug}/hosts/${host}/screens/${screenId}/versions/${versionId}/${surface}`\n : null\n\n return (\n <CardDisplay\n contentGutterX\n contentGutterY\n header=\"SEO fixes\"\n help={pluginDocsHelp('aiSeo', {\n anchor: '#fix-what-the-seo-check-finds',\n excerpt:\n 'Get a proposed fix for each finding of the SEO check. Nothing changes on your live site until you save or publish.',\n })}\n >\n <Stack spacing={2}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {keywords\n ? 'Proposes a fix for each finding of the SEO check above, using the target keywords it was run with. Nothing changes on your live site until you save or publish it.'\n : 'Proposes a fix for each finding of the SEO check above. Nothing changes on your live site until you save or publish it.'}\n </Typography>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Button variant=\"contained\" disabled={busy || running || !orgId} onClick={() => void run()}>\n {report ? 'Propose fixes again' : 'Propose fixes'}\n </Button>\n {running ? <CircularProgress size={18} aria-label=\"Proposing fixes\" /> : null}\n {running && report ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Proposing fixes: ${view?.batches ?? 0} of ${owedBatches} batches`}\n </Typography>\n ) : null}\n </Stack>\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n {job?.error ? <Alert severity={job.status === 'failed' ? 'error' : 'warning'}>{job.error}</Alert> : null}\n\n {report && job ? (\n <Stack spacing={2} aria-label=\"SEO fixes\">\n {job.creditsSpent > 0 ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`These fixes used ${job.creditsSpent} ${job.creditsSpent === 1 ? 'credit' : 'credits'}.`}\n </Typography>\n ) : null}\n\n {view?.site ? (\n <Stack spacing={1} aria-label=\"Structured data and agent guidance\">\n <Typography variant=\"subtitle2\">{'Structured data and AI agent guidance'}</Typography>\n {siteFields.length ? (\n siteFields.map((field) => (\n <Stack key={field} spacing={0.25}>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {AI_SEO_SITE_FIELD_LABELS[field]}\n </Typography>\n <Typography variant=\"body2\" sx={{ wordBreak: 'break-word' }}>\n {field === 'seo.entity.type' ? (ENTITY_TYPE_WORDS[siteValues[field] ?? ''] ?? siteValues[field]) : siteValues[field]}\n </Typography>\n </Stack>\n ))\n ) : (\n <Typography variant=\"body2\">{'Nothing to add: the site’s structured data and guidance are already filled in.'}</Typography>\n )}\n {view.site.notes.map((note) => (\n <Typography key={note} variant=\"caption\" color=\"text.secondary\">\n {note}\n </Typography>\n ))}\n <Button size=\"small\" sx={{ alignSelf: 'flex-start' }} onClick={() => setPreviewOpen((open) => !open)}>\n {previewOpen ? 'Hide the /llms.txt preview' : 'Preview /llms.txt'}\n </Button>\n <Collapse in={previewOpen} unmountOnExit>\n <Box\n component=\"pre\"\n sx={{ m: 0, p: 1.5, bgcolor: 'action.hover', borderRadius: 1, whiteSpace: 'pre-wrap', fontSize: 12 }}\n >\n {view.site.llmsPreview}\n </Box>\n </Collapse>\n <Button\n size=\"small\"\n variant=\"outlined\"\n sx={{ alignSelf: 'flex-start' }}\n disabled={!siteFields.length || siteStaged === job.id}\n onClick={stageSite}\n >\n {'Put in the form'}\n </Button>\n {siteStaged === job.id ? (\n <Alert severity=\"success\">\n {stagedHere\n ? 'In the SEO forms below as unsaved changes. Review them, then press Update.'\n : null}\n {stagedOnBusiness ? (\n <>\n {stagedHere ? ' ' : ''}\n {'The name, email and phone are in Business details on '}\n {host ? (\n <AppLink href={`/${orgSlug}/hosts/${host}/setup/business`}>{'Setup → Business profile'}</AppLink>\n ) : (\n 'Setup → Business profile'\n )}\n {' as unsaved changes. Review them there, then press Update.'}\n </>\n ) : null}\n </Alert>\n ) : null}\n </Stack>\n ) : null}\n\n {fixRows.length ? (\n <Box>\n <ScrollTable size=\"small\" aria-label=\"Proposed fixes\">\n <TableHead>\n <TableRow>\n <TableCell>{'Page'}</TableCell>\n <TableCell>{'Proposed'}</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {pageRows.map((row) => (\n <TableRow key={row.screenId}>\n <TableCell>\n <Typography variant=\"body2\">{row.name}</Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {row.path}\n </Typography>\n </TableCell>\n <TableCell>\n <Typography variant=\"body2\" sx={{ wordBreak: 'break-word' }}>\n {fixSummary(view?.fixes[row.screenId]) || (running ? 'Being proposed…' : '')}\n </Typography>\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </ScrollTable>\n <ListPagination\n page={page}\n pageSize={pageSize}\n rowCount={pageRows.length}\n count={fixRows.length}\n onPageChange={setPage}\n onPageSizeChange={(size) => {\n setPageSize(size)\n setPage(0)\n }}\n />\n </Box>\n ) : (\n <Typography variant=\"body2\">\n {report.pages.length\n ? 'No page needs a written fix.'\n : 'This site has no published public pages to fix.'}\n </Typography>\n )}\n\n <Stack spacing={1}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Apply all opens a new draft version of each page with content fixes, puts proposed titles and descriptions in each page’s SEO card, and puts the structured data and guidance in the form below. You review and save or publish each of them.'}\n </Typography>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Button\n variant=\"contained\"\n disabled={applying || running || job.status !== 'done' || !view?.complete || !somethingToApply}\n onClick={() => void applyAll()}\n >\n {'Apply all as drafts'}\n </Button>\n {applying ? <CircularProgress size={18} aria-label=\"Applying the fixes\" /> : null}\n </Stack>\n </Stack>\n\n {applied ? (\n <Stack spacing={1} aria-label=\"Applied fixes\">\n {applied.versions.map((entry) => {\n const href = pageLink(entry.screenId, entry.versionId, 'besigner')\n return (\n <Typography key={entry.screenId} variant=\"body2\">\n {href ? (\n <AppLink componentVariant=\"naked\" href={href}>\n {`Open the draft of ${entry.name}`}\n </AppLink>\n ) : (\n `A draft of ${entry.name} is ready`\n )}\n </Typography>\n )\n })}\n {applied.staged.map((screenId) => {\n const audited = names.get(screenId)\n const href = pageLink(screenId, audited?.versionId ?? null, 'view')\n return (\n <Typography key={`staged:${screenId}`} variant=\"body2\">\n {href ? (\n <AppLink componentVariant=\"naked\" href={href}>\n {`Review the listing for ${audited?.name ?? screenId}`}\n </AppLink>\n ) : (\n `A listing for ${audited?.name ?? screenId} waits in its SEO card`\n )}\n </Typography>\n )\n })}\n {applied.skipped.map((entry) => (\n <Typography key={`skipped:${entry.screenId}`} variant=\"caption\" color=\"text.secondary\">\n {`${names.get(entry.screenId)?.name ?? entry.screenId}: ${entry.reason}`}\n </Typography>\n ))}\n </Stack>\n ) : null}\n </Stack>\n ) : null}\n </Stack>\n </CardDisplay>\n )\n}\nAiSeoAuditCard.displayName = 'AiSeoAuditCard'\n\nexport default AiSeoAuditCard\n"],"names":["lockdownRefusalText","parseLockdownRefusal","pluginDocsHelp","AppLink","CardDisplay","ListPagination","ScrollTable","TABLE_PAGE_SIZE_DEFAULT","authorizedFetch","useUser","Alert","Box","Button","CircularProgress","Collapse","Stack","TableBody","TableCell","TableHead","TableRow","Typography","useCallback","useEffect","useMemo","useRef","useState","AI_JOB_TERMINAL_STATUSES","aiSeoApplyCounts","aiSeoAuditView","readEventFrames","RECENT_JOBS_READ","isTerminal","job","includes","status","AI_SEO_SITE_FIELD_LABELS","ENTITY_TYPE_WORDS","AI_SEO_BUSINESS_DETAILS_FIELDS","fixSummary","fix","parts","values","title","push","description","alts","content","filter","entry","kind","length","some","guidance","join","AiSeoAuditCard","props","view","hostId","orgId","orgSlug","host","proposeDraft","check","keywords","data","user","userRef","current","uid","verdict","setVerdict","notice","setNotice","busy","setBusy","setJob","siteStaged","setSiteStaged","applying","setApplying","applied","setApplied","previewOpen","setPreviewOpen","page","setPage","pageSize","setPageSize","watchRef","abort","active","response","encodeURIComponent","payload","json","catch","ok","locked","String","error","latest","jobs","find","outputs","watch","jobId","org","controller","AbortController","again","signal","aborted","body","event","followId","id","run","method","headers","JSON","stringify","brief","inputs","target","trim","next","siteValues","site","siteFields","Object","keys","stagedOnBusiness","field","stagedHere","stageSite","applyAll","versions","staged","skipped","running","Boolean","report","owedBatches","Math","ceil","queue","max","batchSize","counts","pagesWithContent","pagesWithValues","somethingToApply","fixRows","pages","fixes","screenId","pageRows","slice","names","Map","map","pageLink","versionId","surface","contentGutterX","contentGutterY","header","help","anchor","excerpt","spacing","variant","color","direction","sx","alignItems","disabled","onClick","size","aria-label","batches","severity","creditsSpent","wordBreak","notes","note","alignSelf","open","in","unmountOnExit","component","m","p","bgcolor","borderRadius","whiteSpace","fontSize","llmsPreview","href","row","name","path","rowCount","count","onPageChange","onPageSizeChange","complete","componentVariant","audited","get","reason","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,mBAAmB,EAAEC,oBAAoB,QAAQ,eAAc;AACxE,SAASC,cAAc,QAAQ,mCAAkC;AAEjE,SAASC,OAAO,EAAEC,WAAW,QAAQ,uBAAsB;AAC3D,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,yDAAwD;AACpF,SAASC,uBAAuB,QAAQ,8CAA6C;AACrF,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,gBAAgB,EAChBC,QAAQ,EACRC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,SAAS,EACTC,QAAQ,EACRC,UAAU,QACL,gBAAe;AACtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AACzE,SAASC,wBAAwB,QAA2B,4BAAwB;AACpF,SACEC,gBAAgB,EAChBC,cAAc,QAG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;oCAC1B,MAAM2C,OAAOrC,SAASN,kBAAUqD,2BAAAA,QAAS9C,SAAS,mBAAI,MAAM;oCAC5D,qBACE,KAAC9I;wCAAsCuJ,SAAQ;kDAC5C2B,qBACC,KAACnM;4CAAQ4M,kBAAiB;4CAAQT,MAAMA;sDACrC,CAAC,uBAAuB,WAAEU,2BAAAA,QAASR,IAAI,oBAAI7C,UAAU;6CAGxD,CAAC,cAAc,WAAEqD,2BAAAA,QAASR,IAAI,oBAAI7C,SAAS,sBAAsB,CAAC;uCANrD,CAAC,OAAO,EAAEA,UAAU;gCAUzC;gCACC3E,QAAQ0D,OAAO,CAACsB,GAAG,CAAC,CAAChH;;wCAEd8G;yDADN,KAAC1I;wCAA6CuJ,SAAQ;wCAAUC,OAAM;kDACnE,YAAGd,aAAAA,MAAMmD,GAAG,CAACjK,MAAM2G,QAAQ,sBAAxBG,WAA2B0C,IAAI,mBAAIxJ,MAAM2G,QAAQ,CAAC,EAAE,EAAE3G,MAAMkK,MAAM,EAAE;uCADzD,CAAC,QAAQ,EAAElK,MAAM2G,QAAQ,EAAE;;;6BAK9C;;qBAEJ;;;;AAId;AACArG,eAAe6J,WAAW,GAAG;AAE7B,eAAe7J,eAAc"}
|
|
@@ -94,6 +94,10 @@ export interface SeoHostDocument {
|
|
|
94
94
|
howToUse?: string;
|
|
95
95
|
};
|
|
96
96
|
};
|
|
97
|
+
/** The one-block copy of the site's email, read when the entity has none (AGL-4136). */
|
|
98
|
+
business?: {
|
|
99
|
+
supportEmail?: string;
|
|
100
|
+
};
|
|
97
101
|
}
|
|
98
102
|
/**
|
|
99
103
|
* The fields a listing job writes: the ones the editor named (`inputs.fields`,
|
|
@@ -403,14 +403,17 @@ async function runProductListing(context, host) {
|
|
|
403
403
|
];
|
|
404
404
|
/** The site SEO form fields blank on the site now. */ export function aiSeoBlankSiteFields(host) {
|
|
405
405
|
var _ref, _ref1;
|
|
406
|
-
var _host_seo, _host_seo1;
|
|
406
|
+
var _host_seo, _host_seo1, _host_business;
|
|
407
407
|
const entity = (_ref = (_host_seo = host.seo) == null ? void 0 : _host_seo.entity) != null ? _ref : {};
|
|
408
408
|
const agent = (_ref1 = (_host_seo1 = host.seo) == null ? void 0 : _host_seo1.agent) != null ? _ref1 : {};
|
|
409
409
|
const blank = new Set();
|
|
410
410
|
if (entity.type === undefined || entity.type === null || entity.type === '') blank.add('seo.entity.type');
|
|
411
411
|
if (!str(entity.name)) blank.add('seo.entity.name');
|
|
412
412
|
if (!str(entity.description)) blank.add('seo.entity.description');
|
|
413
|
-
|
|
413
|
+
// The site's one email is the entity's, else the older one-block copy
|
|
414
|
+
// (AGL-4136); Setup → Business profile shows the copy in its Email field, so a
|
|
415
|
+
// site with only the copy has an email, and a proposal would replace it.
|
|
416
|
+
if (!str(entity.email) && !str((_host_business = host.business) == null ? void 0 : _host_business.supportEmail)) blank.add('seo.entity.email');
|
|
414
417
|
if (!str(entity.telephone)) blank.add('seo.entity.telephone');
|
|
415
418
|
if (!str(entity.contactType)) blank.add('seo.entity.contactType');
|
|
416
419
|
if (!str(agent.whenToUse)) blank.add('seo.agent.whenToUse');
|
|
@@ -431,7 +434,7 @@ async function runProductListing(context, host) {
|
|
|
431
434
|
}
|
|
432
435
|
/** `/llms.txt` as it reads with `values` saved over what the site stores now. */ export function aiSeoLlmsPreview(host, values, pages, collections) {
|
|
433
436
|
var _hostPublicOrigin, _values_seoagentwhenToUse, _values_seoagenthowToUse, _values_seoentityemail;
|
|
434
|
-
var _host_seo, _host_seo1, _host_seo_agent, _host_seo2, _host_seo_agent1, _host_seo3, _host_seo_entity, _host_seo4;
|
|
437
|
+
var _host_seo, _host_seo1, _host_seo_agent, _host_seo2, _host_seo_agent1, _host_seo3, _host_seo_entity, _host_seo4, _host_business;
|
|
435
438
|
return buildLlmsTxt({
|
|
436
439
|
siteName: str((_host_seo = host.seo) == null ? void 0 : _host_seo.title) || str(host.displayName) || 'Site',
|
|
437
440
|
origin: (_hostPublicOrigin = hostPublicOrigin(host)) != null ? _hostPublicOrigin : '',
|
|
@@ -443,7 +446,9 @@ async function runProductListing(context, host) {
|
|
|
443
446
|
pages,
|
|
444
447
|
collections,
|
|
445
448
|
hasSearch: true,
|
|
446
|
-
|
|
449
|
+
// As the site's own /llms.txt names it (AGL-4136): the entity's email,
|
|
450
|
+
// else the older one-block copy.
|
|
451
|
+
contactEmail: (_values_seoentityemail = values['seo.entity.email']) != null ? _values_seoentityemail : str((_host_seo4 = host.seo) == null ? void 0 : (_host_seo_entity = _host_seo4.entity) == null ? void 0 : _host_seo_entity.email) || str((_host_business = host.business) == null ? void 0 : _host_business.supportEmail) || undefined
|
|
447
452
|
});
|
|
448
453
|
}
|
|
449
454
|
async function proposeSite(context, host, scan) {
|