@aglyn/plugins-ai 1.22.0 → 1.22.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 +17 -17
- package/src/lib/components/ai-job-requests.d.ts +5 -1
- package/src/lib/components/ai-job-requests.js +9 -0
- package/src/lib/components/ai-job-requests.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +8 -0
- package/src/lib/jobs/ai-job-import-step.js +19 -2
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-page-language.d.ts +8 -0
- package/src/lib/jobs/ai-job-page-language.js +22 -1
- package/src/lib/jobs/ai-job-page-language.js.map +1 -1
- package/src/lib/jobs/ai-job-page-step.d.ts +10 -0
- package/src/lib/jobs/ai-job-page-step.js +23 -1
- package/src/lib/jobs/ai-job-page-step.js.map +1 -1
- package/src/lib/jobs/ai-site-import-actions.d.ts +12 -3
- package/src/lib/jobs/ai-site-import-actions.js +43 -18
- package/src/lib/jobs/ai-site-import-actions.js.map +1 -1
- package/src/lib/jobs/ai-site-import-improve.d.ts +44 -0
- package/src/lib/jobs/ai-site-import-improve.js +308 -21
- package/src/lib/jobs/ai-site-import-improve.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.d.ts +6 -0
- package/src/lib/layout-language/ai-layout-compiler.js +10 -4
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame.js +11 -2
- package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
- package/src/lib/layout-language/ai-layout-gaps.d.ts +27 -0
- package/src/lib/layout-language/ai-layout-gaps.js +124 -0
- package/src/lib/layout-language/ai-layout-gaps.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +5 -0
- package/src/lib/layout-language/ai-layout-language.js +46 -1
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +9 -8
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
- package/src/lib/site-import/site-import-page.d.ts +2 -2
- package/src/lib/site-import/site-import-page.js +42 -2
- package/src/lib/site-import/site-import-page.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-ai",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.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.22.
|
|
29
|
-
"@aglyn/shared-data-enums": "1.22.
|
|
30
|
-
"@aglyn/shared-data-mdi": "1.22.
|
|
31
|
-
"@aglyn/shared-data-types": "1.22.
|
|
32
|
-
"@aglyn/shared-ui-email-campaigns": "1.22.
|
|
33
|
-
"@aglyn/shared-ui-jsx": "1.22.
|
|
34
|
-
"@aglyn/shared-ui-snackstack": "1.22.
|
|
35
|
-
"@aglyn/shared-ui-theme": "1.22.
|
|
36
|
-
"@aglyn/shared-util-email": "1.22.
|
|
37
|
-
"@aglyn/shared-util-errors": "1.22.
|
|
38
|
-
"@aglyn/shared-util-http": "1.22.
|
|
39
|
-
"@aglyn/shared-util-timestamp": "1.22.
|
|
40
|
-
"@aglyn/shared-util-tools": "1.22.
|
|
41
|
-
"@aglyn/tenant-data-admin": "1.22.
|
|
42
|
-
"@aglyn/tenant-feature-instance": "1.22.
|
|
43
|
-
"@aglyn/tenant-runtime": "1.22.
|
|
28
|
+
"@aglyn/aglyn": "1.22.2",
|
|
29
|
+
"@aglyn/shared-data-enums": "1.22.2",
|
|
30
|
+
"@aglyn/shared-data-mdi": "1.22.2",
|
|
31
|
+
"@aglyn/shared-data-types": "1.22.2",
|
|
32
|
+
"@aglyn/shared-ui-email-campaigns": "1.22.2",
|
|
33
|
+
"@aglyn/shared-ui-jsx": "1.22.2",
|
|
34
|
+
"@aglyn/shared-ui-snackstack": "1.22.2",
|
|
35
|
+
"@aglyn/shared-ui-theme": "1.22.2",
|
|
36
|
+
"@aglyn/shared-util-email": "1.22.2",
|
|
37
|
+
"@aglyn/shared-util-errors": "1.22.2",
|
|
38
|
+
"@aglyn/shared-util-http": "1.22.2",
|
|
39
|
+
"@aglyn/shared-util-timestamp": "1.22.2",
|
|
40
|
+
"@aglyn/shared-util-tools": "1.22.2",
|
|
41
|
+
"@aglyn/tenant-data-admin": "1.22.2",
|
|
42
|
+
"@aglyn/tenant-feature-instance": "1.22.2",
|
|
43
|
+
"@aglyn/tenant-runtime": "1.22.2",
|
|
44
44
|
"@swc/helpers": "0.5.24"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type MaybeTokenSource } from '@aglyn/shared-util-http/authorized-token';
|
|
2
2
|
import { type AiCreditsPrompt } from '../model/ai-credit-estimate';
|
|
3
3
|
import type { AiJobSummary } from '../model/ai-jobs.types';
|
|
4
|
-
import type { AiSiteImportFinish } from '../model/ai-site-import';
|
|
4
|
+
import type { AiSiteImportFinish, AiSiteImportPlanChoice } from '../model/ai-site-import';
|
|
5
5
|
import { type AssistBuildProposal } from '../model/assist-build';
|
|
6
6
|
import { type AssistPageChangeProposal } from '../model/assist-page-change';
|
|
7
7
|
/**
|
|
@@ -50,7 +50,11 @@ export interface AiJobResumeOptions {
|
|
|
50
50
|
finish?: AiSiteImportFinish;
|
|
51
51
|
/** Under Improve it, whether its main pages' wording is improved too (AGL-4152). */
|
|
52
52
|
wording?: boolean;
|
|
53
|
+
/** The owner's answer to a generative plan (AGL-4152): whether its proposed page and generated pictures are in. */
|
|
54
|
+
plan?: AiSiteImportPlanChoice;
|
|
53
55
|
}
|
|
56
|
+
/** The plan answer the resume door reads (AGL-4152): only the switches the owner set. */
|
|
57
|
+
export declare function aiJobResumePlan(plan: AiSiteImportPlanChoice): AiSiteImportPlanChoice;
|
|
54
58
|
/**
|
|
55
59
|
* Confirms a plan, or tries again a step whose answer broke a building rule
|
|
56
60
|
* (AGL-2935). The door runs the next step inline and answers with the job.
|
|
@@ -20,6 +20,13 @@ import { AI_CREDITS_CONFIRM_CODE } from "../model/ai-credit-estimate.js";
|
|
|
20
20
|
import { assistBuildJobRequest } from "../model/assist-build.js";
|
|
21
21
|
import { assistPageChangeJobRequest } from "../model/assist-page-change.js";
|
|
22
22
|
import { publishAiJob } from "./ai-jobs-store.js";
|
|
23
|
+
/** The plan answer the resume door reads (AGL-4152): only the switches the owner set. */ export function aiJobResumePlan(plan) {
|
|
24
|
+
return _extends({}, typeof plan.addPage === 'boolean' ? {
|
|
25
|
+
addPage: plan.addPage
|
|
26
|
+
} : {}, typeof plan.pictures === 'boolean' ? {
|
|
27
|
+
pictures: plan.pictures
|
|
28
|
+
} : {});
|
|
29
|
+
}
|
|
23
30
|
/**
|
|
24
31
|
* Confirms a plan, or tries again a step whose answer broke a building rule
|
|
25
32
|
* (AGL-2935). The door runs the next step inline and answers with the job.
|
|
@@ -50,6 +57,8 @@ import { publishAiJob } from "./ai-jobs-store.js";
|
|
|
50
57
|
finish: options.finish
|
|
51
58
|
} : {}, typeof options.wording === 'boolean' ? {
|
|
52
59
|
wording: options.wording
|
|
60
|
+
} : {}, options.plan ? {
|
|
61
|
+
plan: aiJobResumePlan(options.plan)
|
|
53
62
|
} : {}))
|
|
54
63
|
});
|
|
55
64
|
const payload = await response.json().catch(()=>null);
|
|
@@ -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 } 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}\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 }),\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","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;AAoD9C;;;CAGC,GACD,OAAO,eAAeC,mBACpBC,IAAsB,EACtBC,KAAa,EACbC,GAAwC,EACxCC,UAA8B,CAAC,CAAC;IAEhC,IAAI;;QACF,MAAMC,WAAW,MAAMV,gBACrBM,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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b,CAAAA,2BAAAA,QAASc,KAAK,IAAG;YAAEA,OAAOd,QAAQc,KAAK;QAAC,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,MAAMV,gBACrBM,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;QAC3DJ,aAAa0B;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"],"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,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AAM0B,OAAO;QAA6C;IAC1E;AACF"}
|
|
@@ -226,6 +226,14 @@ export declare function aiSiteImportTileRoles(tile: NonNullable<SiteImportNavEnt
|
|
|
226
226
|
* color. Never the value itself.
|
|
227
227
|
*/
|
|
228
228
|
export declare function aiSiteImportFrameColorRole(hex: string | null, kind: 'fill' | 'ink', look: Pick<SiteImportLookFacts, 'buttonFill'> | null | undefined): AiLayoutFrameSourceRole;
|
|
229
|
+
/**
|
|
230
|
+
* The lines a frame's contact details are held to (AGL-4152): the source's
|
|
231
|
+
* header and footer words, and where a site's plan draws its footer, the
|
|
232
|
+
* address, phone and email it shows, each one the site states
|
|
233
|
+
* (`aiSiteImportPlannedFrame`), so a number only the home page's "Call now"
|
|
234
|
+
* gives is not refused as invented.
|
|
235
|
+
*/
|
|
236
|
+
export declare function aiSiteImportFrameFactLines(lines: readonly string[], source: AiLayoutFrameSource | null): string[];
|
|
229
237
|
/** The header and footer's job: a layout of the site's brand, linking the wave's pages, in the layout language. */
|
|
230
238
|
export declare function aiSiteImportFrameJob(job: AiJob, state: AiSiteImportState, wave: AiSiteImportWave, items: readonly AiJobItemLedger[]): AiJob;
|
|
231
239
|
/** What the site says of itself (AGL-4152): the home page's description and facts and the pages it brings in, the same bytes on every page. */
|
|
@@ -647,6 +647,23 @@ const delivered = (items, slot)=>items.some((row)=>row.slot === slot && (row.sta
|
|
|
647
647
|
const brand = (look == null ? void 0 : look.buttonFill) && /^#[0-9a-f]{6}$/i.test(look.buttonFill) ? aiHexOklch(look.buttonFill) : null;
|
|
648
648
|
return !brand || hueApart(own.h, brand.h) <= 40 ? 'primary.main' : 'secondary.main';
|
|
649
649
|
}
|
|
650
|
+
/**
|
|
651
|
+
* The lines a frame's contact details are held to (AGL-4152): the source's
|
|
652
|
+
* header and footer words, and where a site's plan draws its footer, the
|
|
653
|
+
* address, phone and email it shows, each one the site states
|
|
654
|
+
* (`aiSiteImportPlannedFrame`), so a number only the home page's "Call now"
|
|
655
|
+
* gives is not refused as invented.
|
|
656
|
+
*/ export function aiSiteImportFrameFactLines(lines, source) {
|
|
657
|
+
const reach = (source == null ? void 0 : source.planned) && source.footer ? [
|
|
658
|
+
source.footer.address,
|
|
659
|
+
source.footer.phone,
|
|
660
|
+
source.footer.email
|
|
661
|
+
] : [];
|
|
662
|
+
return [
|
|
663
|
+
...lines,
|
|
664
|
+
...reach.filter((line)=>!!(line == null ? void 0 : line.trim()) && !lines.some((entry)=>entry.includes(line)))
|
|
665
|
+
];
|
|
666
|
+
}
|
|
650
667
|
/** The header and footer's job: a layout of the site's brand, linking the wave's pages, in the layout language. */ export function aiSiteImportFrameJob(job, state, wave, items) {
|
|
651
668
|
var _ref, _state_home, _ref1, _ref2;
|
|
652
669
|
var _state_frame, _state_look, _home_brand_logo, _home_footer;
|
|
@@ -686,7 +703,7 @@ const delivered = (items, slot)=>items.some((row)=>row.slot === slot && (row.sta
|
|
|
686
703
|
alt
|
|
687
704
|
} : {}, aspect ? {
|
|
688
705
|
aspect
|
|
689
|
-
} : {}) : {}, withLogo && ((_home_footer = home.footer) == null ? void 0 : _home_footer.logo) === true ? {
|
|
706
|
+
} : {}) : {}, withLogo && (((_home_footer = home.footer) == null ? void 0 : _home_footer.logo) === true || redrawn) ? {
|
|
690
707
|
footer: true
|
|
691
708
|
} : {}, redrawn ? {
|
|
692
709
|
height: aiSiteImportLogoHeight(aspect)
|
|
@@ -720,7 +737,7 @@ const delivered = (items, slot)=>items.some((row)=>row.slot === slot && (row.sta
|
|
|
720
737
|
[AI_LAYOUT_SITE_FACTS_INPUT]: {
|
|
721
738
|
url: home.url,
|
|
722
739
|
description: home.description,
|
|
723
|
-
lines: home.facts.lines
|
|
740
|
+
lines: aiSiteImportFrameFactLines(home.facts.lines, source)
|
|
724
741
|
}
|
|
725
742
|
} : {}),
|
|
726
743
|
// Never words a footer could print as the site's own (AGL-4084): the prompt shows the source's.
|