@aglyn/plugins-ai 1.29.1 → 1.29.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/plugins-ai",
3
- "version": "1.29.1",
3
+ "version": "1.29.2",
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.1",
29
- "@aglyn/shared-data-enums": "1.29.1",
30
- "@aglyn/shared-data-mdi": "1.29.1",
31
- "@aglyn/shared-data-types": "1.29.1",
32
- "@aglyn/shared-ui-email-campaigns": "1.29.1",
33
- "@aglyn/shared-ui-jsx": "1.29.1",
34
- "@aglyn/shared-ui-snackstack": "1.29.1",
35
- "@aglyn/shared-ui-theme": "1.29.1",
36
- "@aglyn/shared-util-email": "1.29.1",
37
- "@aglyn/shared-util-errors": "1.29.1",
38
- "@aglyn/shared-util-http": "1.29.1",
39
- "@aglyn/shared-util-timestamp": "1.29.1",
40
- "@aglyn/shared-util-tools": "1.29.1",
41
- "@aglyn/tenant-data-admin": "1.29.1",
42
- "@aglyn/tenant-feature-instance": "1.29.1",
43
- "@aglyn/tenant-runtime": "1.29.1",
28
+ "@aglyn/aglyn": "1.29.2",
29
+ "@aglyn/shared-data-enums": "1.29.2",
30
+ "@aglyn/shared-data-mdi": "1.29.2",
31
+ "@aglyn/shared-data-types": "1.29.2",
32
+ "@aglyn/shared-ui-email-campaigns": "1.29.2",
33
+ "@aglyn/shared-ui-jsx": "1.29.2",
34
+ "@aglyn/shared-ui-snackstack": "1.29.2",
35
+ "@aglyn/shared-ui-theme": "1.29.2",
36
+ "@aglyn/shared-util-email": "1.29.2",
37
+ "@aglyn/shared-util-errors": "1.29.2",
38
+ "@aglyn/shared-util-http": "1.29.2",
39
+ "@aglyn/shared-util-timestamp": "1.29.2",
40
+ "@aglyn/shared-util-tools": "1.29.2",
41
+ "@aglyn/tenant-data-admin": "1.29.2",
42
+ "@aglyn/tenant-feature-instance": "1.29.2",
43
+ "@aglyn/tenant-runtime": "1.29.2",
44
44
  "@swc/helpers": "0.5.24"
45
45
  },
46
46
  "peerDependencies": {
@@ -77,3 +77,9 @@ export declare function startAssistBuildRequest(user: MaybeTokenSource, orgId: s
77
77
  export declare function startAssistPageChangeRequest(user: MaybeTokenSource, orgId: string, proposal: AssistPageChangeProposal, versionId: string | null): Promise<AiJobDecision>;
78
78
  /** Cancels a job that has not settled. */
79
79
  export declare function cancelAiJobRequest(user: MaybeTokenSource, orgId: string, jobId: string): Promise<AiJobDecision>;
80
+ /**
81
+ * Adds the redirects a Bring my site import's old addresses are missing
82
+ * (AGL-4245): for pages published since its waves, or once the plan has room
83
+ * or redirects are on. Spends nothing; safe to ask again.
84
+ */
85
+ export declare function addAiSiteImportRedirectsRequest(user: MaybeTokenSource, orgId: string, job: Pick<AiJobSummary, 'id' | 'hostId'>): Promise<AiJobDecision>;
@@ -171,5 +171,37 @@ import { publishAiJob } from "./ai-jobs-store.js";
171
171
  };
172
172
  }
173
173
  }
174
+ /**
175
+ * Adds the redirects a Bring my site import's old addresses are missing
176
+ * (AGL-4245): for pages published since its waves, or once the plan has room
177
+ * or redirects are on. Spends nothing; safe to ask again.
178
+ */ export async function addAiSiteImportRedirectsRequest(user, orgId, job) {
179
+ const failed = 'The redirects could not be added. Try again.';
180
+ try {
181
+ var _ref, _ref1;
182
+ const response = await authorizedFetch(user, `/api/ai/jobs/${encodeURIComponent(job.id)}/redirects`, {
183
+ method: 'POST',
184
+ headers: {
185
+ 'Content-Type': 'application/json'
186
+ },
187
+ body: JSON.stringify({
188
+ orgId,
189
+ hostId: job.hostId
190
+ })
191
+ });
192
+ const payload = await response.json().catch(()=>null);
193
+ const next = (_ref = payload == null ? void 0 : payload.job) != null ? _ref : null;
194
+ publishAiJob(next);
195
+ return {
196
+ job: next,
197
+ error: response.ok ? null : String((_ref1 = payload == null ? void 0 : payload.error) != null ? _ref1 : failed)
198
+ };
199
+ } catch (unused) {
200
+ return {
201
+ job: null,
202
+ error: failed
203
+ };
204
+ }
205
+ }
174
206
 
175
207
  //# sourceMappingURL=ai-job-requests.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-job-requests.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { authorizedFetch, type MaybeTokenSource } from '@aglyn/shared-util-http/authorized-token'\nimport { AI_CREDITS_CONFIRM_CODE, type AiCreditsPrompt } from '../model/ai-credit-estimate'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport type { AiSiteImportFinish, AiSiteImportPlanChoice } from '../model/ai-site-import'\nimport { assistBuildJobRequest, type AssistBuildProposal } from '../model/assist-build'\nimport { assistPageChangeJobRequest, type AssistPageChangeProposal } from '../model/assist-page-change'\nimport { publishAiJob } from './ai-jobs-store'\n\n/**\n * The two decisions a person makes about a job — confirm its plan (or try a\n * refused step again), and cancel it — as ONE request each, whichever\n * surface they press it on (AGL-3593). The AI jobs drawer and the dialog that\n * started the job both call these, so confirming in the dialog is the same\n * door, the same body and the same answer as confirming in the drawer.\n *\n * Each hands the job it gets back to every counting surface, so the top-bar\n * indicator stops saying \"plan ready\" the moment the plan is confirmed.\n */\n\n/** A door's answer: the job as it now stands, and the refusal when there is one. */\nexport interface AiJobDecision {\n job: AiJobSummary | null\n error: string | null\n /**\n * A Free job past what is left (AGL-3722): the door's 409 asks for the\n * person's go-ahead with these figures and choices instead of starting it.\n */\n credits?: AiCreditsPrompt | null\n /**\n * The usage strip's envelope the job door answered with, when it ran a step\n * inline (AGL-3722): what the plan just spent, so the strip moves with it.\n */\n meter?: unknown\n /** Why each answer a `needs_input` job asked for cannot be used, by field (AGL-3978). */\n fieldErrors?: Record<string, string> | null\n}\n\n/**\n * What a resume asks beyond confirming (AGL-3616): a build's plan confirmed\n * with its publish box ticked, or a finished build's failed items tried again.\n */\nexport interface AiJobResumeOptions {\n publish?: boolean\n retry?: 'failed-items'\n /** \"Build what fits\" (AGL-3722): a Free job past what is left, started on the person's go-ahead. */\n creditsConfirmed?: boolean\n /** \"Build the home page first\" (AGL-3722): the plan narrowed to its home page and what it needs. */\n reduce?: 'first-page'\n /** The answers a job waiting in `needs_input` asks for (AGL-3978), by `aiJobInputKey`. */\n input?: Record<string, string>\n /** \"Start every remaining wave\" (AGL-4084): an import starts its next wave and every one after it. */\n startAll?: boolean\n /** Keep my site or Improve it (AGL-4152): how an import's waves not yet started are built. */\n finish?: AiSiteImportFinish\n /** Under Improve it, whether its main pages' wording is improved too (AGL-4152). */\n wording?: boolean\n /** The owner's answer to a generative plan (AGL-4152): whether its proposed page and generated pictures are in. */\n plan?: AiSiteImportPlanChoice\n}\n\n/** The plan answer the resume door reads (AGL-4152): only the switches the owner set. */\nexport function aiJobResumePlan(plan: AiSiteImportPlanChoice): AiSiteImportPlanChoice {\n return {\n ...(typeof plan.addPage === 'boolean' ? { addPage: plan.addPage } : {}),\n ...(typeof plan.pictures === 'boolean' ? { pictures: plan.pictures } : {}),\n }\n}\n\n/**\n * Confirms a plan, or tries again a step whose answer broke a building rule\n * (AGL-2935). The door runs the next step inline and answers with the job.\n */\nexport async function resumeAiJobRequest(\n user: MaybeTokenSource,\n orgId: string,\n job: Pick<AiJobSummary, 'id' | 'hostId'>,\n options: AiJobResumeOptions = {},\n): Promise<AiJobDecision> {\n try {\n const response = await authorizedFetch(\n user,\n `/api/ai/jobs/${encodeURIComponent(job.id)}/resume`,\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n orgId,\n hostId: job.hostId,\n ...(options.publish ? { publish: true } : {}),\n ...(options.retry ? { retry: options.retry } : {}),\n ...(options.creditsConfirmed ? { creditsConfirmed: true } : {}),\n ...(options.reduce ? { reduce: options.reduce } : {}),\n ...(options.input ? { input: options.input } : {}),\n ...(options.startAll ? { startAll: true } : {}),\n ...(options.finish ? { finish: options.finish } : {}),\n ...(typeof options.wording === 'boolean' ? { wording: options.wording } : {}),\n // The plan's two switches: left out, the door keeps the proposed page and generated pictures on.\n ...(options.plan ? { plan: aiJobResumePlan(options.plan) } : {}),\n }),\n },\n )\n const payload = await response.json().catch(() => null)\n const next = (payload?.job as AiJobSummary | undefined) ?? null\n publishAiJob(next)\n const credits =\n response.status === 409 && payload?.code === AI_CREDITS_CONFIRM_CODE\n ? ((payload?.credits as AiCreditsPrompt | undefined) ?? null)\n : null\n return {\n job: next,\n error: response.ok\n ? null\n : String(payload?.error ?? 'The job could not be resumed — try again.'),\n ...(credits ? { credits } : {}),\n ...(payload?.fieldErrors ? { fieldErrors: payload.fieldErrors as Record<string, string> } : {}),\n }\n } catch {\n return { job: null, error: 'The job could not be resumed — try again.' }\n }\n}\n\n/**\n * Starts the build a chat turn proposed (AGL-3616): one `build` job on the\n * proposal's site, through the same door every job is created by, which\n * climbs its own gates and plans inline. What comes back stops at its plan\n * card; nothing is built until the person confirms it.\n */\nexport async function startAssistBuildRequest(\n user: MaybeTokenSource,\n orgId: string,\n proposal: AssistBuildProposal,\n): Promise<AiJobDecision> {\n const failed = 'The build could not be planned — try asking again.'\n try {\n const response = await authorizedFetch(user, '/api/ai/jobs', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(assistBuildJobRequest(orgId, proposal)),\n })\n const payload = await response.json().catch(() => null)\n const next = (payload?.job as AiJobSummary | undefined) ?? null\n if (response.ok && next) publishAiJob(next)\n return {\n job: response.ok ? next : null,\n error: response.ok && next ? null : String(payload?.error ?? failed),\n ...(payload?.meter ? { meter: payload.meter } : {}),\n }\n } catch {\n return { job: null, error: failed }\n }\n}\n\n/**\n * Starts the change to a page a chat turn asked for (AGL-4116): one `edit`\n * job on that page, through the door every job is created by, which checks\n * the page and the plan again. There is no plan to confirm: what comes back\n * is the job making the draft, or the reason it could not start.\n * `versionId` continues the draft an earlier change in the conversation made.\n */\nexport async function startAssistPageChangeRequest(\n user: MaybeTokenSource,\n orgId: string,\n proposal: AssistPageChangeProposal,\n versionId: string | null,\n): Promise<AiJobDecision> {\n const failed = 'The change could not be started — try asking again.'\n try {\n const response = await authorizedFetch(user, '/api/ai/jobs', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(assistPageChangeJobRequest(orgId, proposal, versionId)),\n })\n const payload = await response.json().catch(() => null)\n const next = (payload?.job as AiJobSummary | undefined) ?? null\n if (response.ok && next) publishAiJob(next)\n return {\n job: response.ok ? next : null,\n error: response.ok && next ? null : String(payload?.error ?? failed),\n ...(payload?.meter ? { meter: payload.meter } : {}),\n }\n } catch {\n return { job: null, error: failed }\n }\n}\n\n/** Cancels a job that has not settled. */\nexport async function cancelAiJobRequest(\n user: MaybeTokenSource,\n orgId: string,\n jobId: string,\n): Promise<AiJobDecision> {\n try {\n const response = await authorizedFetch(\n user,\n `/api/ai/jobs/${encodeURIComponent(jobId)}/cancel`,\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ orgId }),\n },\n )\n const payload = await response.json().catch(() => null)\n const next = (payload?.job as AiJobSummary | undefined) ?? null\n publishAiJob(next)\n return {\n job: next,\n error: response.ok\n ? null\n : String(payload?.error ?? 'The job could not be canceled — try again.'),\n }\n } catch {\n return { job: null, error: 'The job could not be canceled — try again.' }\n }\n}\n"],"names":["authorizedFetch","AI_CREDITS_CONFIRM_CODE","assistBuildJobRequest","assistPageChangeJobRequest","publishAiJob","aiJobResumePlan","plan","addPage","pictures","resumeAiJobRequest","user","orgId","job","options","response","encodeURIComponent","id","method","headers","body","JSON","stringify","hostId","publish","retry","creditsConfirmed","reduce","input","startAll","finish","wording","payload","json","catch","next","credits","status","code","error","ok","String","fieldErrors","startAssistBuildRequest","proposal","failed","meter","startAssistPageChangeRequest","versionId","cancelAiJobRequest","jobId"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,eAAe,QAA+B,2CAA0C;AACjG,SAASC,uBAAuB,QAA8B,iCAA6B;AAG3F,SAASC,qBAAqB,QAAkC,2BAAuB;AACvF,SAASC,0BAA0B,QAAuC,iCAA6B;AACvG,SAASC,YAAY,QAAQ,qBAAiB;AAsD9C,uFAAuF,GACvF,OAAO,SAASC,gBAAgBC,IAA4B;IAC1D,OAAO,aACD,OAAOA,KAAKC,OAAO,KAAK,YAAY;QAAEA,SAASD,KAAKC,OAAO;IAAC,IAAI,CAAC,GACjE,OAAOD,KAAKE,QAAQ,KAAK,YAAY;QAAEA,UAAUF,KAAKE,QAAQ;IAAC,IAAI,CAAC;AAE5E;AAEA;;;CAGC,GACD,OAAO,eAAeC,mBACpBC,IAAsB,EACtBC,KAAa,EACbC,GAAwC,EACxCC,UAA8B,CAAC,CAAC;IAEhC,IAAI;;QACF,MAAMC,WAAW,MAAMd,gBACrBU,MACA,CAAC,aAAa,EAAEK,mBAAmBH,IAAII,EAAE,EAAE,OAAO,CAAC,EACnD;YACEC,QAAQ;YACRC,SAAS;gBAAE,gBAAgB;YAAmB;YAC9CC,MAAMC,KAAKC,SAAS,CAAC;gBACnBV;gBACAW,QAAQV,IAAIU,MAAM;eACdT,QAAQU,OAAO,GAAG;gBAAEA,SAAS;YAAK,IAAI,CAAC,GACvCV,QAAQW,KAAK,GAAG;gBAAEA,OAAOX,QAAQW,KAAK;YAAC,IAAI,CAAC,GAC5CX,QAAQY,gBAAgB,GAAG;gBAAEA,kBAAkB;YAAK,IAAI,CAAC,G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IAAI,CAAC;IAErD,EAAE,eAAM;QACN,OAAO;YAAEjC,KAAK;YAAM0B,OAAOM;QAAO;IACpC;AACF;AAEA,wCAAwC,GACxC,OAAO,eAAeI,mBACpBtC,IAAsB,EACtBC,KAAa,EACbsC,KAAa;IAEb,IAAI;;QACF,MAAMnC,WAAW,MAAMd,gBACrBU,MACA,CAAC,aAAa,EAAEK,mBAAmBkC,OAAO,OAAO,CAAC,EAClD;YACEhC,QAAQ;YACRC,SAAS;gBAAE,gBAAgB;YAAmB;YAC9CC,MAAMC,KAAKC,SAAS,CAAC;gBAAEV;YAAM;QAC/B;QAEF,MAAMoB,UAAU,MAAMjB,SAASkB,IAAI,GAAGC,KAAK,CAAC,IAAM;QAClD,MAAMC,eAAQH,2BAAAA,QAASnB,GAAG,mBAAiC;QAC3DR,aAAa8B;QACb,OAAO;YACLtB,KAAKsB;YACLI,OAAOxB,SAASyB,EAAE,GACd,OACAC,gBAAOT,2BAAAA,QAASO,KAAK,oBAAI;QAC/B;IACF,EAAE,eAAM;QACN,OAAO;YAAE1B,KAAK;YAAM0B,OAAO;QAA6C;IAC1E;AACF"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-job-requests.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { authorizedFetch, type MaybeTokenSource } from '@aglyn/shared-util-http/authorized-token'\nimport { AI_CREDITS_CONFIRM_CODE, type AiCreditsPrompt } from '../model/ai-credit-estimate'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport type { AiSiteImportFinish, AiSiteImportPlanChoice } from '../model/ai-site-import'\nimport { assistBuildJobRequest, type AssistBuildProposal } from '../model/assist-build'\nimport { assistPageChangeJobRequest, type AssistPageChangeProposal } from '../model/assist-page-change'\nimport { publishAiJob } from './ai-jobs-store'\n\n/**\n * The two decisions a person makes about a job — confirm its plan (or try a\n * refused step again), and cancel it — as ONE request each, whichever\n * surface they press it on (AGL-3593). The AI jobs drawer and the dialog that\n * started the job both call these, so confirming in the dialog is the same\n * door, the same body and the same answer as confirming in the drawer.\n *\n * Each hands the job it gets back to every counting surface, so the top-bar\n * indicator stops saying \"plan ready\" the moment the plan is confirmed.\n */\n\n/** A door's answer: the job as it now stands, and the refusal when there is one. */\nexport interface AiJobDecision {\n job: AiJobSummary | null\n error: string | null\n /**\n * A Free job past what is left (AGL-3722): the door's 409 asks for the\n * person's go-ahead with these figures and choices instead of starting it.\n */\n credits?: AiCreditsPrompt | null\n /**\n * The usage strip's envelope the job door answered with, when it ran a step\n * inline (AGL-3722): what the plan just spent, so the strip moves with it.\n */\n meter?: unknown\n /** Why each answer a `needs_input` job asked for cannot be used, by field (AGL-3978). */\n fieldErrors?: Record<string, string> | null\n}\n\n/**\n * What a resume asks beyond confirming (AGL-3616): a build's plan confirmed\n * with its publish box ticked, or a finished build's failed items tried again.\n */\nexport interface AiJobResumeOptions {\n publish?: boolean\n retry?: 'failed-items'\n /** \"Build what fits\" (AGL-3722): a Free job past what is left, started on the person's go-ahead. */\n creditsConfirmed?: boolean\n /** \"Build the home page first\" (AGL-3722): the plan narrowed to its home page and what it needs. */\n reduce?: 'first-page'\n /** The answers a job waiting in `needs_input` asks for (AGL-3978), by `aiJobInputKey`. */\n input?: Record<string, string>\n /** \"Start every remaining wave\" (AGL-4084): an import starts its next wave and every one after it. */\n startAll?: boolean\n /** Keep my site or Improve it (AGL-4152): how an import's waves not yet started are built. */\n finish?: AiSiteImportFinish\n /** Under Improve it, whether its main pages' wording is improved too (AGL-4152). */\n wording?: boolean\n /** The owner's answer to a generative plan (AGL-4152): whether its proposed page and generated pictures are in. */\n plan?: AiSiteImportPlanChoice\n}\n\n/** The plan answer the resume door reads (AGL-4152): only the switches the owner set. */\nexport function aiJobResumePlan(plan: AiSiteImportPlanChoice): AiSiteImportPlanChoice {\n return {\n ...(typeof plan.addPage === 'boolean' ? { addPage: plan.addPage } : {}),\n ...(typeof plan.pictures === 'boolean' ? { pictures: plan.pictures } : {}),\n }\n}\n\n/**\n * Confirms a plan, or tries again a step whose answer broke a building rule\n * (AGL-2935). The door runs the next step inline and answers with the job.\n */\nexport async function resumeAiJobRequest(\n user: MaybeTokenSource,\n orgId: string,\n job: Pick<AiJobSummary, 'id' | 'hostId'>,\n options: AiJobResumeOptions = {},\n): Promise<AiJobDecision> {\n try {\n const response = await authorizedFetch(\n user,\n `/api/ai/jobs/${encodeURIComponent(job.id)}/resume`,\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n orgId,\n hostId: job.hostId,\n ...(options.publish ? { publish: true } : {}),\n ...(options.retry ? { retry: options.retry } : {}),\n ...(options.creditsConfirmed ? { creditsConfirmed: true } : {}),\n ...(options.reduce ? { reduce: options.reduce } : {}),\n ...(options.input ? { input: options.input } : {}),\n ...(options.startAll ? { startAll: true } : {}),\n ...(options.finish ? { finish: options.finish } : {}),\n ...(typeof options.wording === 'boolean' ? { wording: options.wording } : {}),\n // The plan's two switches: left out, the door keeps the proposed page and generated pictures on.\n ...(options.plan ? { plan: aiJobResumePlan(options.plan) } : {}),\n }),\n },\n )\n const payload = await response.json().catch(() => null)\n const next = (payload?.job as AiJobSummary | undefined) ?? null\n publishAiJob(next)\n const credits =\n response.status === 409 && payload?.code === AI_CREDITS_CONFIRM_CODE\n ? ((payload?.credits as AiCreditsPrompt | undefined) ?? null)\n : null\n return {\n job: next,\n error: response.ok\n ? null\n : String(payload?.error ?? 'The job could not be resumed — try again.'),\n ...(credits ? { credits } : {}),\n ...(payload?.fieldErrors ? { fieldErrors: payload.fieldErrors as Record<string, string> } : {}),\n }\n } catch {\n return { job: null, error: 'The job could not be resumed — try again.' }\n }\n}\n\n/**\n * Starts the build a chat turn proposed (AGL-3616): one `build` job on the\n * proposal's site, through the same door every job is created by, which\n * climbs its own gates and plans inline. What comes back stops at its plan\n * card; nothing is built until the person confirms it.\n */\nexport async function startAssistBuildRequest(\n user: MaybeTokenSource,\n orgId: string,\n proposal: AssistBuildProposal,\n): Promise<AiJobDecision> {\n const failed = 'The build could not be planned — try asking again.'\n try {\n const response = await authorizedFetch(user, '/api/ai/jobs', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(assistBuildJobRequest(orgId, proposal)),\n })\n const payload = await response.json().catch(() => null)\n const next = (payload?.job as AiJobSummary | undefined) ?? null\n if (response.ok && next) publishAiJob(next)\n return {\n job: response.ok ? next : null,\n error: response.ok && next ? null : String(payload?.error ?? failed),\n ...(payload?.meter ? { meter: payload.meter } : {}),\n }\n } catch {\n return { job: null, error: failed }\n }\n}\n\n/**\n * Starts the change to a page a chat turn asked for (AGL-4116): one `edit`\n * job on that page, through the door every job is created by, which checks\n * the page and the plan again. There is no plan to confirm: what comes back\n * is the job making the draft, or the reason it could not start.\n * `versionId` continues the draft an earlier change in the conversation made.\n */\nexport async function startAssistPageChangeRequest(\n user: MaybeTokenSource,\n orgId: string,\n proposal: AssistPageChangeProposal,\n versionId: string | null,\n): Promise<AiJobDecision> {\n const failed = 'The change could not be started — try asking again.'\n try {\n const response = await authorizedFetch(user, '/api/ai/jobs', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(assistPageChangeJobRequest(orgId, proposal, versionId)),\n })\n const payload = await response.json().catch(() => null)\n const next = (payload?.job as AiJobSummary | undefined) ?? null\n if (response.ok && next) publishAiJob(next)\n return {\n job: response.ok ? next : null,\n error: response.ok && next ? null : String(payload?.error ?? failed),\n ...(payload?.meter ? { meter: payload.meter } : {}),\n }\n } catch {\n return { job: null, error: failed }\n }\n}\n\n/** Cancels a job that has not settled. */\nexport async function cancelAiJobRequest(\n user: MaybeTokenSource,\n orgId: string,\n jobId: string,\n): Promise<AiJobDecision> {\n try {\n const response = await authorizedFetch(\n user,\n `/api/ai/jobs/${encodeURIComponent(jobId)}/cancel`,\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ orgId }),\n },\n )\n const payload = await response.json().catch(() => null)\n const next = (payload?.job as AiJobSummary | undefined) ?? null\n publishAiJob(next)\n return {\n job: next,\n error: response.ok\n ? null\n : String(payload?.error ?? 'The job could not be canceled — try again.'),\n }\n } catch {\n return { job: null, error: 'The job could not be canceled — try again.' }\n }\n}\n\n/**\n * Adds the redirects a Bring my site import's old addresses are missing\n * (AGL-4245): for pages published since its waves, or once the plan has room\n * or redirects are on. Spends nothing; safe to ask again.\n */\nexport async function addAiSiteImportRedirectsRequest(\n user: MaybeTokenSource,\n orgId: string,\n job: Pick<AiJobSummary, 'id' | 'hostId'>,\n): Promise<AiJobDecision> {\n const failed = 'The redirects could not be added. Try again.'\n try {\n const response = await authorizedFetch(user, `/api/ai/jobs/${encodeURIComponent(job.id)}/redirects`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ orgId, hostId: job.hostId }),\n })\n const payload = await response.json().catch(() => null)\n const next = (payload?.job as AiJobSummary | undefined) ?? null\n publishAiJob(next)\n return { job: next, error: response.ok ? null : String(payload?.error ?? failed) }\n } catch {\n return { job: null, error: failed }\n }\n}\n"],"names":["authorizedFetch","AI_CREDITS_CONFIRM_CODE","assistBuildJobRequest","assistPageChangeJobRequest","publishAiJob","aiJobResumePlan","plan","addPage","pictures","resumeAiJobRequest","user","orgId","job","options","response","encodeURIComponent","id","method","headers","body","JSON","stringify","hostId","publish","retry","creditsConfirmed","reduce","input","startAll","finish","wording","payload","json","catch","next","credits","status","code","error","ok","String","fieldErrors","startAssistBuildRequest","proposal","failed","meter","startAssistPageChangeRequest","versionId","cancelAiJobRequest","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sxs as _jsxs } from "react/jsx-runtime";
19
19
  import { PageHeaderRecord } from "@aglyn/aglyn/app-utils/page-header-record-context";
20
20
  import { buildRoute, Route } from "@aglyn/aglyn/app-utils/console-routes";
21
+ import { pluginRecordListHref } from "@aglyn/aglyn/plugin-manager/plugin-record-routes";
21
22
  import { mdiAlertCircle, mdiCheckCircle, mdiChevronDown, mdiClockOutline, mdiMinusCircleOutline, mdiOpenInNew } from "@aglyn/shared-data-mdi";
22
23
  import { AppLink, HelpTip, MdiIcon } from "@aglyn/shared-ui-jsx";
23
24
  import { useBuyingHidden } from "@aglyn/shared-ui-jsx/contexts/buying-hidden.context";
@@ -25,7 +26,9 @@ import { Accordion, AccordionDetails, AccordionSummary, Alert, Box, Button, Card
25
26
  import { useCallback, useEffect, useState } from "react";
26
27
  import { aiSiteImportPlanAwaits, aiSiteImportReviewWave, aiSiteImportRunningWave, aiSiteImportWaveChoice } from "../model/ai-site-import.js";
27
28
  import { AI_SITE_IMPORT_FINISH_COPY, AI_SITE_IMPORT_PLAN_COPY_TEXT, aiSiteImportChoiceText, aiSiteImportFieldChoice, aiSiteImportFinishFieldOf, aiSiteImportFoundText, aiSiteImportHeldCopy, aiSiteImportLeftOutLines, aiSiteImportPhaseOf, aiSiteImportPlanFellBackText, aiSiteImportPlanFieldOf, aiSiteImportPlanQuote, aiSiteImportPlanText, aiSiteImportRunningLede, aiSiteImportStartAction, aiSiteImportStartAllAction, aiSiteImportStoppedCopy, aiSiteImportVerdictNote, aiSiteImportWaveHeading, aiSiteImportWaveRows, aiSiteImportWaveSpent, aiSiteImportWordingCreditsText } from "../model/ai-site-import-view.js";
29
+ import { AI_SITE_IMPORT_REDIRECT_RECORD, AI_SITE_IMPORT_REDIRECTS_RETRY_COPY, AI_SITE_IMPORT_REDIRECTS_WHEN, aiSiteImportRedirectsRetryable, aiSiteImportRedirectText, aiSiteImportRedirectsSummary } from "../model/ai-site-import-redirects.js";
28
30
  import { AiJobCancelButton } from "./ai-job-cancel.component.js";
31
+ import { addAiSiteImportRedirectsRequest } from "./ai-job-requests.js";
29
32
  import { aiCreditsBillingHref, aiJobOutputHref } from "./ai-job-links.js";
30
33
  import { AiSiteImportFinish } from "./ai-site-import-finish.component.js";
31
34
  import { AiSiteImportPlanPanel, AiSiteImportWhatsNewList } from "./ai-site-import-plan.component.js";
@@ -194,6 +197,11 @@ function RowIcon({ state }) {
194
197
  color: "text.secondary",
195
198
  children: row.pictures
196
199
  }) : null,
200
+ row.redirect ? /*#__PURE__*/ _jsx(Typography, {
201
+ variant: "body2",
202
+ color: "text.secondary",
203
+ children: row.redirect
204
+ }) : null,
197
205
  row.note && row.state !== 'done' ? /*#__PURE__*/ _jsx(Typography, {
198
206
  variant: "body2",
199
207
  color: "text.secondary",
@@ -263,7 +271,7 @@ function Frame({ siteName, heading, lede, children }) {
263
271
  * Improve it, and Change opens the choice (AGL-4152); the wave's button posts
264
272
  * it. Each wave that has started says how it was built, which never changes.
265
273
  */ export function AiSiteImportJob({ job, orgId, orgSlug, host, siteName, user, busy, notice, onResume, onStartAll, onJob }) {
266
- var _job_siteImport, _ref, _ref1, _ref2, _job_error;
274
+ var _job_siteImport, _ref, _ref1, _ref2, _ref3, _job_error;
267
275
  const phase = aiSiteImportPhaseOf(job);
268
276
  // An app build for store review leaves out every way to buy more.
269
277
  const buyingHidden = useBuyingHidden();
@@ -298,6 +306,11 @@ function Frame({ siteName, heading, lede, children }) {
298
306
  orgSlug,
299
307
  host
300
308
  }) : null;
309
+ // Where the redirects plugin says its rules are listed (AGL-4245); no link where it is not loaded.
310
+ const redirectsHref = host && orgSlug ? pluginRecordListHref(AI_SITE_IMPORT_REDIRECT_RECORD, {
311
+ orgSlug,
312
+ host
313
+ }) : null;
301
314
  const [claim, setClaim] = useState(null);
302
315
  const [claimNotice, setClaimNotice] = useState(null);
303
316
  const verifyAgain = useCallback(async ()=>{
@@ -315,6 +328,22 @@ function Frame({ siteName, heading, lede, children }) {
315
328
  state,
316
329
  user
317
330
  ]);
331
+ const [addingRedirects, setAddingRedirects] = useState(false);
332
+ const [redirectsNotice, setRedirectsNotice] = useState(null);
333
+ const addRedirects = useCallback(async ()=>{
334
+ if (!orgId) return;
335
+ setAddingRedirects(true);
336
+ setRedirectsNotice(null);
337
+ const answer = await addAiSiteImportRedirectsRequest(user, orgId, job);
338
+ setAddingRedirects(false);
339
+ if (answer.job) onJob(answer.job);
340
+ if (answer.error) setRedirectsNotice(answer.error);
341
+ }, [
342
+ orgId,
343
+ user,
344
+ job,
345
+ onJob
346
+ ]);
318
347
  const cancel = /*#__PURE__*/ _jsx(Box, {
319
348
  children: /*#__PURE__*/ _jsx(AiJobCancelButton, {
320
349
  job: job,
@@ -521,6 +550,106 @@ function Frame({ siteName, heading, lede, children }) {
521
550
  })
522
551
  ]
523
552
  }) : null;
553
+ // The redirects from the old addresses (AGL-4245): what was added, and the
554
+ // other addresses of a page, which have no row of their own.
555
+ const redirectsSummary = aiSiteImportRedirectsSummary(state);
556
+ // Pages published since a wave, or room or redirects since: the same pass again, on the person's say-so.
557
+ const redirectsRetry = Boolean(orgId) && aiSiteImportRedirectsRetryable(state) && job.status !== 'running' && job.status !== 'queued';
558
+ const otherAddresses = ((_ref3 = state == null ? void 0 : state.redirects) != null ? _ref3 : []).filter((entry)=>!entry.slot && entry.outcome !== 'same');
559
+ const redirectsCard = redirectsSummary ? /*#__PURE__*/ _jsxs(Accordion, {
560
+ variant: "outlined",
561
+ disableGutters: true,
562
+ slotProps: {
563
+ heading: {
564
+ component: 'h2'
565
+ }
566
+ },
567
+ sx: {
568
+ borderRadius: 2,
569
+ '&::before': {
570
+ display: 'none'
571
+ }
572
+ },
573
+ children: [
574
+ /*#__PURE__*/ _jsx(AccordionSummary, {
575
+ expandIcon: /*#__PURE__*/ _jsx(MdiIcon, {
576
+ path: mdiChevronDown.path
577
+ }),
578
+ children: /*#__PURE__*/ _jsx(Typography, {
579
+ variant: "subtitle1",
580
+ component: "span",
581
+ children: 'Redirects from your old addresses'
582
+ })
583
+ }),
584
+ /*#__PURE__*/ _jsx(AccordionDetails, {
585
+ children: /*#__PURE__*/ _jsxs(Stack, {
586
+ spacing: 1.5,
587
+ children: [
588
+ /*#__PURE__*/ _jsx(Typography, {
589
+ variant: "body2",
590
+ children: redirectsSummary
591
+ }),
592
+ /*#__PURE__*/ _jsx(Typography, {
593
+ variant: "body2",
594
+ color: "text.secondary",
595
+ children: AI_SITE_IMPORT_REDIRECTS_WHEN
596
+ }),
597
+ otherAddresses.length ? /*#__PURE__*/ _jsx(Stack, {
598
+ component: "ul",
599
+ spacing: 0.5,
600
+ "aria-label": "Other old addresses",
601
+ sx: {
602
+ m: 0,
603
+ pl: 2.5
604
+ },
605
+ children: otherAddresses.map((entry, index)=>{
606
+ var _aiSiteImportRedirectText;
607
+ return /*#__PURE__*/ _jsx(Typography, {
608
+ component: "li",
609
+ variant: "body2",
610
+ sx: {
611
+ overflowWrap: 'anywhere'
612
+ },
613
+ children: `${entry.from} · ${(_aiSiteImportRedirectText = aiSiteImportRedirectText(entry)) != null ? _aiSiteImportRedirectText : ''}`
614
+ }, `${entry.from}-${index}`);
615
+ })
616
+ }) : null,
617
+ redirectsRetry ? /*#__PURE__*/ _jsxs(Stack, {
618
+ spacing: 0.5,
619
+ children: [
620
+ /*#__PURE__*/ _jsx(Typography, {
621
+ variant: "body2",
622
+ color: "text.secondary",
623
+ children: AI_SITE_IMPORT_REDIRECTS_RETRY_COPY.help
624
+ }),
625
+ /*#__PURE__*/ _jsx(Box, {
626
+ children: /*#__PURE__*/ _jsx(Button, {
627
+ variant: "outlined",
628
+ size: "small",
629
+ disabled: addingRedirects,
630
+ onClick: ()=>void addRedirects(),
631
+ children: addingRedirects ? AI_SITE_IMPORT_REDIRECTS_RETRY_COPY.busy : AI_SITE_IMPORT_REDIRECTS_RETRY_COPY.action
632
+ })
633
+ })
634
+ ]
635
+ }) : null,
636
+ redirectsNotice ? /*#__PURE__*/ _jsx(Alert, {
637
+ severity: "warning",
638
+ children: redirectsNotice
639
+ }) : null,
640
+ redirectsHref ? /*#__PURE__*/ _jsx(Box, {
641
+ children: /*#__PURE__*/ _jsx(Button, {
642
+ size: "small",
643
+ component: AppLink,
644
+ href: redirectsHref,
645
+ children: 'Open Redirects'
646
+ })
647
+ }) : null
648
+ ]
649
+ })
650
+ })
651
+ ]
652
+ }) : null;
524
653
  if (phase === 'reading') {
525
654
  return /*#__PURE__*/ _jsxs(Frame, {
526
655
  siteName: siteName,
@@ -555,12 +684,12 @@ function Frame({ siteName, heading, lede, children }) {
555
684
  }
556
685
  // A plan is in, and nothing of the site is built until its owner says so (AGL-4152).
557
686
  if (phase === 'ready' && state && planWaits) {
558
- var _ref3;
687
+ var _ref4;
559
688
  var _job_review;
560
689
  return /*#__PURE__*/ _jsxs(Frame, {
561
690
  siteName: siteName,
562
691
  heading: "Your new site is planned",
563
- lede: (_ref3 = (_job_review = job.review) == null ? void 0 : _job_review.message) != null ? _ref3 : undefined,
692
+ lede: (_ref4 = (_job_review = job.review) == null ? void 0 : _job_review.message) != null ? _ref4 : undefined,
564
693
  children: [
565
694
  notice && /*#__PURE__*/ _jsx(Alert, {
566
695
  severity: "warning",
@@ -606,12 +735,12 @@ function Frame({ siteName, heading, lede, children }) {
606
735
  });
607
736
  }
608
737
  if (phase === 'ready' && state) {
609
- var _ref4;
738
+ var _ref5;
610
739
  var _job_review1;
611
740
  return /*#__PURE__*/ _jsxs(Frame, {
612
741
  siteName: siteName,
613
742
  heading: aiSiteImportStoppedCopy(job) ? 'Your import is waiting for you' : 'Your site is read',
614
- lede: (_ref4 = (_job_review1 = job.review) == null ? void 0 : _job_review1.message) != null ? _ref4 : undefined,
743
+ lede: (_ref5 = (_job_review1 = job.review) == null ? void 0 : _job_review1.message) != null ? _ref5 : undefined,
615
744
  children: [
616
745
  notice && /*#__PURE__*/ _jsx(Alert, {
617
746
  severity: "warning",
@@ -671,8 +800,8 @@ function Frame({ siteName, heading, lede, children }) {
671
800
  });
672
801
  }
673
802
  if ((phase === 'running' || phase === 'starting') && state) {
674
- var _ref5, _aiSiteImportRunningWave;
675
- const wave = (_ref5 = (_aiSiteImportRunningWave = aiSiteImportRunningWave(state)) != null ? _aiSiteImportRunningWave : start == null ? void 0 : start.wave) != null ? _ref5 : null;
803
+ var _ref6, _aiSiteImportRunningWave;
804
+ const wave = (_ref6 = (_aiSiteImportRunningWave = aiSiteImportRunningWave(state)) != null ? _aiSiteImportRunningWave : start == null ? void 0 : start.wave) != null ? _ref6 : null;
676
805
  const rows = wave ? aiSiteImportWaveRows(job, wave) : [];
677
806
  const done = rows.filter((row)=>row.state !== 'waiting' && row.state !== 'active').length;
678
807
  return /*#__PURE__*/ _jsxs(Frame, {
@@ -713,12 +842,12 @@ function Frame({ siteName, heading, lede, children }) {
713
842
  });
714
843
  }
715
844
  if (phase === 'review' && state) {
716
- var _ref6;
845
+ var _ref7;
717
846
  var _job_sitePublish;
718
847
  const wave = aiSiteImportReviewWave(state);
719
848
  const spent = aiSiteImportWaveSpent(job, wave);
720
849
  // A site in preview has the wave's pages live for its team (AGL-4084); any other has them as drafts.
721
- const live = new Set(((_ref6 = (_job_sitePublish = job.sitePublish) == null ? void 0 : _job_sitePublish.published) != null ? _ref6 : []).map((page)=>page.id));
850
+ const live = new Set(((_ref7 = (_job_sitePublish = job.sitePublish) == null ? void 0 : _job_sitePublish.published) != null ? _ref7 : []).map((page)=>page.id));
722
851
  const inPreview = wave.slots.some((slot)=>{
723
852
  var _ref;
724
853
  var _state_pages_find;
@@ -816,6 +945,7 @@ function Frame({ siteName, heading, lede, children }) {
816
945
  }) : null,
817
946
  startButton,
818
947
  waves,
948
+ redirectsCard,
819
949
  leftOutCard,
820
950
  cancel
821
951
  ]
@@ -860,7 +990,7 @@ function Frame({ siteName, heading, lede, children }) {
860
990
  });
861
991
  }
862
992
  if (phase === 'held' || phase === 'paused') {
863
- var _ref7, _ref8;
993
+ var _ref8, _ref9;
864
994
  var _job_review2, _job_review3;
865
995
  const ownership = ((_job_review2 = job.review) == null ? void 0 : _job_review2.reason) === 'ownership';
866
996
  return /*#__PURE__*/ _jsxs(Frame, {
@@ -873,7 +1003,7 @@ function Frame({ siteName, heading, lede, children }) {
873
1003
  }),
874
1004
  /*#__PURE__*/ _jsx(Alert, {
875
1005
  severity: "info",
876
- children: (_ref7 = (_ref8 = (_job_review3 = job.review) == null ? void 0 : _job_review3.message) != null ? _ref8 : job.error) != null ? _ref7 : 'It stopped for your decision.'
1006
+ children: (_ref8 = (_ref9 = (_job_review3 = job.review) == null ? void 0 : _job_review3.message) != null ? _ref9 : job.error) != null ? _ref8 : 'It stopped for your decision.'
877
1007
  }),
878
1008
  ownership && orgId ? claim ? /*#__PURE__*/ _jsx(AiSiteOwnershipProof, {
879
1009
  orgId: orgId,
@@ -981,6 +1111,7 @@ function Frame({ siteName, heading, lede, children }) {
981
1111
  })
982
1112
  ]
983
1113
  }, wave.index)),
1114
+ redirectsCard,
984
1115
  leftOutCard
985
1116
  ]
986
1117
  });
@@ -1001,7 +1132,8 @@ function Frame({ siteName, heading, lede, children }) {
1001
1132
  children: 'Open your draft pages'
1002
1133
  })
1003
1134
  }) : null,
1004
- waves
1135
+ waves,
1136
+ redirectsCard
1005
1137
  ]
1006
1138
  });
1007
1139
  }