@aglyn/plugins-ai 1.0.0-beta.228 → 1.0.0-beta.230
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/README.md +3 -3
- package/package.json +17 -17
- package/src/lib/activity/ai-activity-actions.js +7 -1
- package/src/lib/activity/ai-activity-actions.js.map +1 -1
- package/src/lib/components/ai-automation-zones.d.ts +38 -0
- package/src/lib/components/ai-automation-zones.js +5 -1
- package/src/lib/components/ai-automation-zones.js.map +1 -1
- package/src/lib/components/ai-brief-dialog.component.d.ts +20 -2
- package/src/lib/components/ai-brief-dialog.component.js +87 -8
- package/src/lib/components/ai-brief-dialog.component.js.map +1 -1
- package/src/lib/components/ai-campaign-create.component.d.ts +54 -0
- package/src/lib/components/ai-campaign-create.component.js +270 -0
- package/src/lib/components/ai-campaign-create.component.js.map +1 -0
- package/src/lib/components/ai-describe-automation.component.d.ts +8 -3
- package/src/lib/components/ai-describe-automation.component.js +15 -6
- package/src/lib/components/ai-describe-automation.component.js.map +1 -1
- package/src/lib/components/ai-describe-button.component.d.ts +20 -8
- package/src/lib/components/ai-describe-button.component.js +19 -36
- package/src/lib/components/ai-describe-button.component.js.map +1 -1
- package/src/lib/components/ai-describe-email.component.d.ts +31 -0
- package/src/lib/components/ai-describe-email.component.js +22 -0
- package/src/lib/components/ai-describe-email.component.js.map +1 -0
- package/src/lib/components/ai-describe-org-automation.component.d.ts +36 -0
- package/src/lib/components/ai-describe-org-automation.component.js +238 -0
- package/src/lib/components/ai-describe-org-automation.component.js.map +1 -0
- package/src/lib/components/ai-experiment-cards.component.d.ts +9 -1
- package/src/lib/components/ai-experiment-cards.component.js +104 -18
- package/src/lib/components/ai-experiment-cards.component.js.map +1 -1
- package/src/lib/components/ai-explain-automation.component.js +1 -5
- package/src/lib/components/ai-explain-automation.component.js.map +1 -1
- package/src/lib/components/ai-funnel-zones.component.d.ts +61 -0
- package/src/lib/components/ai-funnel-zones.component.js +178 -0
- package/src/lib/components/ai-funnel-zones.component.js.map +1 -0
- package/src/lib/components/ai-insight-card.component.d.ts +42 -0
- package/src/lib/components/ai-insight-card.component.js +137 -0
- package/src/lib/components/ai-insight-card.component.js.map +1 -0
- package/src/lib/components/ai-insight-dialog.component.d.ts +6 -0
- package/src/lib/components/ai-insight-dialog.component.js +9 -3
- package/src/lib/components/ai-insight-dialog.component.js.map +1 -1
- package/src/lib/components/ai-job-plan.component.d.ts +7 -2
- package/src/lib/components/ai-job-plan.component.js +35 -5
- package/src/lib/components/ai-job-plan.component.js.map +1 -1
- package/src/lib/components/ai-job-requests.d.ts +17 -1
- package/src/lib/components/ai-job-requests.js +39 -3
- package/src/lib/components/ai-job-requests.js.map +1 -1
- package/src/lib/components/ai-jobs-list-page.component.js +12 -1
- package/src/lib/components/ai-jobs-list-page.component.js.map +1 -1
- package/src/lib/components/ai-logic-zones.d.ts +64 -0
- package/src/lib/components/ai-logic-zones.js +18 -0
- package/src/lib/components/ai-logic-zones.js.map +1 -0
- package/src/lib/components/ai-logic.component.d.ts +77 -0
- package/src/lib/components/ai-logic.component.js +553 -0
- package/src/lib/components/ai-logic.component.js.map +1 -0
- package/src/lib/components/ai-marketing-insight.component.d.ts +30 -0
- package/src/lib/components/ai-marketing-insight.component.js +80 -0
- package/src/lib/components/ai-marketing-insight.component.js.map +1 -0
- package/src/lib/components/ai-media-create.component.d.ts +55 -0
- package/src/lib/components/ai-media-create.component.js +433 -0
- package/src/lib/components/ai-media-create.component.js.map +1 -0
- package/src/lib/components/ai-overlay-cards.component.d.ts +83 -0
- package/src/lib/components/ai-overlay-cards.component.js +505 -0
- package/src/lib/components/ai-overlay-cards.component.js.map +1 -0
- package/src/lib/components/ai-product-zones.d.ts +5 -0
- package/src/lib/components/ai-product-zones.js +1 -1
- package/src/lib/components/ai-product-zones.js.map +1 -1
- package/src/lib/components/ai-products-create-button.component.d.ts +42 -0
- package/src/lib/components/ai-products-create-button.component.js +67 -0
- package/src/lib/components/ai-products-create-button.component.js.map +1 -0
- package/src/lib/components/ai-products-hub-card.component.js +100 -81
- package/src/lib/components/ai-products-hub-card.component.js.map +1 -1
- package/src/lib/components/ai-revise-automation.component.d.ts +16 -0
- package/src/lib/components/ai-revise-automation.component.js +207 -0
- package/src/lib/components/ai-revise-automation.component.js.map +1 -0
- package/src/lib/components/ai-site-build-page.component.d.ts +1 -1
- package/src/lib/components/ai-site-build-page.component.js +177 -20
- package/src/lib/components/ai-site-build-page.component.js.map +1 -1
- package/src/lib/components/ai-site-start-card.component.d.ts +10 -1
- package/src/lib/components/ai-site-start-card.component.js +7 -4
- package/src/lib/components/ai-site-start-card.component.js.map +1 -1
- package/src/lib/components/ai-upsell-dialog.component.d.ts +53 -0
- package/src/lib/components/ai-upsell-dialog.component.js +177 -0
- package/src/lib/components/ai-upsell-dialog.component.js.map +1 -0
- package/src/lib/components/assist-build-card.component.d.ts +42 -0
- package/src/lib/components/assist-build-card.component.js +183 -0
- package/src/lib/components/assist-build-card.component.js.map +1 -0
- package/src/lib/components/assist-edit-canvas.d.ts +2 -0
- package/src/lib/components/assist-edit-canvas.js +56 -1
- package/src/lib/components/assist-edit-canvas.js.map +1 -1
- package/src/lib/components/assist-jobs-drawer.component.d.ts +11 -0
- package/src/lib/components/assist-jobs-drawer.component.js +85 -4
- package/src/lib/components/assist-jobs-drawer.component.js.map +1 -1
- package/src/lib/components/assist-panel.component.js +51 -2
- package/src/lib/components/assist-panel.component.js.map +1 -1
- package/src/lib/components/use-ai-job-run.d.ts +3 -14
- package/src/lib/components/use-ai-job-run.js +0 -50
- package/src/lib/components/use-ai-job-run.js.map +1 -1
- package/src/lib/jobs/ai-build-capabilities.d.ts +58 -0
- package/src/lib/jobs/ai-build-capabilities.js +256 -0
- package/src/lib/jobs/ai-build-capabilities.js.map +1 -0
- package/src/lib/jobs/ai-build-unit-outcome.d.ts +52 -0
- package/src/lib/jobs/ai-build-unit-outcome.js +138 -0
- package/src/lib/jobs/ai-build-unit-outcome.js.map +1 -0
- package/src/lib/jobs/ai-job-build-step.d.ts +144 -0
- package/src/lib/jobs/ai-job-build-step.js +657 -0
- package/src/lib/jobs/ai-job-build-step.js.map +1 -0
- package/src/lib/jobs/ai-job-draft-ids.js +9 -1
- package/src/lib/jobs/ai-job-draft-ids.js.map +1 -1
- package/src/lib/jobs/ai-job-drafts.d.ts +14 -4
- package/src/lib/jobs/ai-job-drafts.js +25 -4
- package/src/lib/jobs/ai-job-drafts.js.map +1 -1
- package/src/lib/jobs/ai-job-layout-site-pages.d.ts +70 -0
- package/src/lib/jobs/ai-job-layout-site-pages.js +216 -0
- package/src/lib/jobs/ai-job-layout-site-pages.js.map +1 -0
- package/src/lib/jobs/ai-job-layout-step.d.ts +2 -2
- package/src/lib/jobs/ai-job-layout-step.js +19 -1
- package/src/lib/jobs/ai-job-layout-step.js.map +1 -1
- package/src/lib/jobs/ai-job-logic-step.d.ts +107 -0
- package/src/lib/jobs/ai-job-logic-step.js +395 -0
- package/src/lib/jobs/ai-job-logic-step.js.map +1 -0
- package/src/lib/jobs/ai-job-overlay-copy.d.ts +70 -0
- package/src/lib/jobs/ai-job-overlay-copy.js +178 -0
- package/src/lib/jobs/ai-job-overlay-copy.js.map +1 -0
- package/src/lib/jobs/ai-job-page-step.js +6 -6
- package/src/lib/jobs/ai-job-page-step.js.map +1 -1
- package/src/lib/jobs/ai-job-plan-step.d.ts +26 -1
- package/src/lib/jobs/ai-job-plan-step.js +79 -11
- package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
- package/src/lib/jobs/ai-job-site-step.d.ts +15 -1
- package/src/lib/jobs/ai-job-site-step.js +207 -58
- package/src/lib/jobs/ai-job-site-step.js.map +1 -1
- package/src/lib/jobs/ai-job-text-step.d.ts +22 -1
- package/src/lib/jobs/ai-job-text-step.js +12 -0
- package/src/lib/jobs/ai-job-text-step.js.map +1 -1
- package/src/lib/jobs/ai-job-workflow-step.d.ts +54 -4
- package/src/lib/jobs/ai-job-workflow-step.js +318 -13
- package/src/lib/jobs/ai-job-workflow-step.js.map +1 -1
- package/src/lib/jobs/ai-jobs.d.ts +90 -2
- package/src/lib/jobs/ai-jobs.js +495 -61
- package/src/lib/jobs/ai-jobs.js.map +1 -1
- package/src/lib/jobs/ai-logic-records.d.ts +40 -0
- package/src/lib/jobs/ai-logic-records.js +55 -0
- package/src/lib/jobs/ai-logic-records.js.map +1 -0
- package/src/lib/jobs/ai-site-publish.d.ts +7 -0
- package/src/lib/jobs/ai-site-publish.js +9 -0
- package/src/lib/jobs/ai-site-publish.js.map +1 -1
- package/src/lib/jobs/ai-workflow-records.d.ts +4 -0
- package/src/lib/jobs/ai-workflow-records.js +40 -1
- package/src/lib/jobs/ai-workflow-records.js.map +1 -1
- package/src/lib/model/ai-automation-draft.d.ts +18 -0
- package/src/lib/model/ai-automation-draft.js +86 -0
- package/src/lib/model/ai-automation-draft.js.map +1 -1
- package/src/lib/model/ai-build-job.d.ts +201 -0
- package/src/lib/model/ai-build-job.js +471 -0
- package/src/lib/model/ai-build-job.js.map +1 -0
- package/src/lib/model/ai-build-plan.d.ts +61 -0
- package/src/lib/model/ai-build-plan.js +154 -9
- package/src/lib/model/ai-build-plan.js.map +1 -1
- package/src/lib/model/ai-build-progress.d.ts +56 -0
- package/src/lib/model/ai-build-progress.js +128 -0
- package/src/lib/model/ai-build-progress.js.map +1 -0
- package/src/lib/model/ai-insight.d.ts +20 -10
- package/src/lib/model/ai-insight.js +72 -9
- package/src/lib/model/ai-insight.js.map +1 -1
- package/src/lib/model/ai-job-activity.js +3 -1
- package/src/lib/model/ai-job-activity.js.map +1 -1
- package/src/lib/model/ai-job-failure-copy.d.ts +20 -1
- package/src/lib/model/ai-job-failure-copy.js +28 -1
- package/src/lib/model/ai-job-failure-copy.js.map +1 -1
- package/src/lib/model/ai-job-notice.d.ts +3 -0
- package/src/lib/model/ai-job-notice.js +11 -2
- package/src/lib/model/ai-job-notice.js.map +1 -1
- package/src/lib/model/ai-jobs.types.d.ts +87 -2
- package/src/lib/model/ai-jobs.types.js +3 -1
- package/src/lib/model/ai-jobs.types.js.map +1 -1
- package/src/lib/model/ai-logic-job.d.ts +108 -0
- package/src/lib/model/ai-logic-job.js +327 -0
- package/src/lib/model/ai-logic-job.js.map +1 -0
- package/src/lib/model/ai-media-credits.d.ts +52 -0
- package/src/lib/model/ai-media-credits.js +61 -0
- package/src/lib/model/ai-media-credits.js.map +1 -0
- package/src/lib/model/ai-overlay-copy.d.ts +114 -0
- package/src/lib/model/ai-overlay-copy.js +175 -0
- package/src/lib/model/ai-overlay-copy.js.map +1 -0
- package/src/lib/model/ai-site-build-progress.d.ts +28 -3
- package/src/lib/model/ai-site-build-progress.js +231 -17
- package/src/lib/model/ai-site-build-progress.js.map +1 -1
- package/src/lib/model/ai-site-start-seo.d.ts +16 -0
- package/src/lib/model/ai-site-start-seo.js +54 -4
- package/src/lib/model/ai-site-start-seo.js.map +1 -1
- package/src/lib/model/ai-site-start.d.ts +14 -0
- package/src/lib/model/ai-site-start.js +43 -0
- package/src/lib/model/ai-site-start.js.map +1 -1
- package/src/lib/model/ai-svg.d.ts +69 -0
- package/src/lib/model/ai-svg.js +265 -0
- package/src/lib/model/ai-svg.js.map +1 -0
- package/src/lib/model/ai-usage-by-user.d.ts +3 -2
- package/src/lib/model/ai-usage-by-user.js.map +1 -1
- package/src/lib/model/ai-workflow-job.d.ts +92 -4
- package/src/lib/model/ai-workflow-job.js +124 -7
- package/src/lib/model/ai-workflow-job.js.map +1 -1
- package/src/lib/model/assist-build.d.ts +58 -0
- package/src/lib/model/assist-build.js +52 -0
- package/src/lib/model/assist-build.js.map +1 -0
- package/src/lib/model/assist-edit.d.ts +48 -3
- package/src/lib/model/assist-edit.js +48 -4
- package/src/lib/model/assist-edit.js.map +1 -1
- package/src/lib/plugin-config.js +2 -0
- package/src/lib/plugin-config.js.map +1 -1
- package/src/lib/plugin.js +240 -11
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/providers/catalog.d.ts +81 -4
- package/src/lib/providers/catalog.js +80 -9
- package/src/lib/providers/catalog.js.map +1 -1
- package/src/lib/providers/image-contract.d.ts +116 -0
- package/src/lib/providers/image-contract.js +74 -0
- package/src/lib/providers/image-contract.js.map +1 -0
- package/src/lib/providers/model-choice.js +11 -0
- package/src/lib/providers/model-choice.js.map +1 -1
- package/src/lib/providers/routing.js +18 -0
- package/src/lib/providers/routing.js.map +1 -1
- package/src/lib/providers/vertex-image.d.ts +121 -0
- package/src/lib/providers/vertex-image.js +312 -0
- package/src/lib/providers/vertex-image.js.map +1 -0
- package/src/lib/runtime/ai-doctrine-validators.d.ts +19 -0
- package/src/lib/runtime/ai-doctrine-validators.js +89 -0
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
- package/src/lib/runtime/ai-doctrine.d.ts +6 -0
- package/src/lib/runtime/ai-doctrine.js +16 -6
- package/src/lib/runtime/ai-doctrine.js.map +1 -1
- package/src/lib/runtime/ai-eval-live.js +4 -0
- package/src/lib/runtime/ai-eval-live.js.map +1 -1
- package/src/lib/runtime/ai-eval.d.ts +15 -1
- package/src/lib/runtime/ai-eval.js +52 -1
- package/src/lib/runtime/ai-eval.js.map +1 -1
- package/src/lib/runtime/experiment-variant-copy.d.ts +34 -0
- package/src/lib/runtime/experiment-variant-copy.js +102 -0
- package/src/lib/runtime/experiment-variant-copy.js.map +1 -0
- package/src/lib/server/ai-experiment-versions.d.ts +51 -0
- package/src/lib/server/ai-experiment-versions.js +270 -0
- package/src/lib/server/ai-experiment-versions.js.map +1 -0
- package/src/lib/server/ai-jobs-resume.js +74 -4
- package/src/lib/server/ai-jobs-resume.js.map +1 -1
- package/src/lib/server/ai-media-image.d.ts +66 -0
- package/src/lib/server/ai-media-image.js +521 -0
- package/src/lib/server/ai-media-image.js.map +1 -0
- package/src/lib/server/ai-media-svg.d.ts +91 -0
- package/src/lib/server/ai-media-svg.js +186 -0
- package/src/lib/server/ai-media-svg.js.map +1 -0
- package/src/lib/server/assist-build.d.ts +54 -0
- package/src/lib/server/assist-build.js +121 -0
- package/src/lib/server/assist-build.js.map +1 -0
- package/src/lib/server/assist-chat.js +108 -12
- package/src/lib/server/assist-chat.js.map +1 -1
- package/src/lib/server/assist-edit.js +213 -3
- package/src/lib/server/assist-edit.js.map +1 -1
- package/src/lib/server/assist-view-context.js +242 -4
- package/src/lib/server/assist-view-context.js.map +1 -1
- package/src/lib/server.js +26 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/tools/ai-logic-tool.d.ts +27 -0
- package/src/lib/tools/ai-logic-tool.js +207 -0
- package/src/lib/tools/ai-logic-tool.js.map +1 -0
- package/src/lib/tools/ai-overlay-tool.d.ts +35 -0
- package/src/lib/tools/ai-overlay-tool.js +107 -0
- package/src/lib/tools/ai-overlay-tool.js.map +1 -0
- package/src/lib/tools/ai-workflow-tool.d.ts +11 -0
- package/src/lib/tools/ai-workflow-tool.js +31 -0
- package/src/lib/tools/ai-workflow-tool.js.map +1 -1
- package/src/lib/usage/assist-job-refund.d.ts +31 -3
- package/src/lib/usage/assist-job-refund.js +46 -10
- package/src/lib/usage/assist-job-refund.js.map +1 -1
- package/src/lib/usage/assist-usage.d.ts +5 -0
- package/src/lib/usage/assist-usage.js +2 -0
- package/src/lib/usage/assist-usage.js.map +1 -1
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2026 Aglyn LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/ /**
|
|
18
|
+
* Overlay copy by AI (AGL-3603): what a `text` job asked for an announcement
|
|
19
|
+
* bar's or a popup's copy answers, in the shape the step writes and the
|
|
20
|
+
* console reads. Pure data, so the widgets and the step share one reading.
|
|
21
|
+
*
|
|
22
|
+
* The overlay is the marketing plugin's, and neither plugin imports the other:
|
|
23
|
+
* the limits and the trigger catalog are handed to the widget by the zone,
|
|
24
|
+
* and the widget passes them on as the job's inputs. The step then holds the
|
|
25
|
+
* answer to the TIGHTER of those and its own ceilings below, so a job started
|
|
26
|
+
* by anything else is still bounded, and drops a trigger the caller did not
|
|
27
|
+
* name rather than inventing one.
|
|
28
|
+
*/ /** The `text` job's `inputs.task` that asks for overlay copy. */ export const AI_OVERLAY_COPY_TASK = 'overlay';
|
|
29
|
+
/** The step's own ceilings: no zone may widen a field past these. */ export const AI_OVERLAY_COPY_CEILINGS = {
|
|
30
|
+
name: 80,
|
|
31
|
+
text: 200,
|
|
32
|
+
headline: 120,
|
|
33
|
+
body: 600,
|
|
34
|
+
ctaLabel: 60
|
|
35
|
+
};
|
|
36
|
+
/** The triggers a popup may be proposed to open on, as the site runtime names them. */ export const AI_OVERLAY_TRIGGERS = [
|
|
37
|
+
'delay',
|
|
38
|
+
'scroll',
|
|
39
|
+
'exit'
|
|
40
|
+
];
|
|
41
|
+
/** The longest description of the current copy a job sends. */ export const AI_OVERLAY_CURRENT_MAX_CHARS = 1200;
|
|
42
|
+
const str = (value)=>typeof value === 'string' ? value.trim() : '';
|
|
43
|
+
/** The kind a job's inputs name, or `null`. */ export function aiOverlayKind(inputs) {
|
|
44
|
+
const kind = inputs == null ? void 0 : inputs['overlayKind'];
|
|
45
|
+
return kind === 'bar' || kind === 'popup' ? kind : null;
|
|
46
|
+
}
|
|
47
|
+
/** Whether a `text` job's inputs ask for overlay copy. */ export function aiOverlayCopyRequested(inputs) {
|
|
48
|
+
return (inputs == null ? void 0 : inputs['task']) === AI_OVERLAY_COPY_TASK;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The limit each field is held to: the caller's, where it named one, never
|
|
52
|
+
* past the step's ceiling. Inputs carry them as `limit_<field>`.
|
|
53
|
+
*/ export function aiOverlayLimits(inputs) {
|
|
54
|
+
const limits = _extends({}, AI_OVERLAY_COPY_CEILINGS);
|
|
55
|
+
for (const field of Object.keys(limits)){
|
|
56
|
+
const asked = Number(inputs == null ? void 0 : inputs[`limit_${field}`]);
|
|
57
|
+
if (Number.isFinite(asked) && asked > 0) limits[field] = Math.min(limits[field], Math.floor(asked));
|
|
58
|
+
}
|
|
59
|
+
return limits;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The triggers the caller allows, with their ranges. Inputs carry them as
|
|
63
|
+
* `triggers` (`delay:0-120,scroll:1-100,exit`); an id the runtime does not
|
|
64
|
+
* know is dropped, and with no list a popup is proposed no trigger at all.
|
|
65
|
+
*/ export function aiOverlayTriggerRanges(inputs) {
|
|
66
|
+
const ranges = new Map();
|
|
67
|
+
for (const part of str(inputs == null ? void 0 : inputs['triggers']).split(',')){
|
|
68
|
+
const [id, range] = part.trim().split(':');
|
|
69
|
+
if (!AI_OVERLAY_TRIGGERS.includes(id)) continue;
|
|
70
|
+
const [min, max] = String(range != null ? range : '').split('-').map(Number);
|
|
71
|
+
ranges.set(id, Number.isFinite(min) && Number.isFinite(max) && max >= min ? {
|
|
72
|
+
min,
|
|
73
|
+
max
|
|
74
|
+
} : null);
|
|
75
|
+
}
|
|
76
|
+
return ranges;
|
|
77
|
+
}
|
|
78
|
+
/** The zone's trigger catalog as the job's `triggers` input. */ export function aiOverlayTriggersInput(rules) {
|
|
79
|
+
return rules.filter((rule)=>AI_OVERLAY_TRIGGERS.includes(rule.id)).map((rule)=>rule.unit ? `${rule.id}:${rule.min}-${rule.max}` : rule.id).join(',');
|
|
80
|
+
}
|
|
81
|
+
/** The zone's limits as the job's `limit_<field>` inputs. */ export function aiOverlayLimitInputs(limits) {
|
|
82
|
+
const inputs = {};
|
|
83
|
+
for (const field of Object.keys(AI_OVERLAY_COPY_CEILINGS)){
|
|
84
|
+
const limit = limits[field];
|
|
85
|
+
if (typeof limit === 'number' && limit > 0) inputs[`limit_${field}`] = limit;
|
|
86
|
+
}
|
|
87
|
+
return inputs;
|
|
88
|
+
}
|
|
89
|
+
/** One field on one line, or a body with its paragraphs, cut to its limit. */ function fit(value, limit, multiline = false) {
|
|
90
|
+
const folded = multiline ? value.replace(/\r\n?/g, '\n').replace(/[^\S\n]+/g, ' ').replace(/\n{3,}/g, '\n\n') : value.replace(/\s+/g, ' ');
|
|
91
|
+
return folded.trim().slice(0, limit).trim();
|
|
92
|
+
}
|
|
93
|
+
/** Markup, a fence or a link: things a bar or a popup shows as typed. */ const MARKUP = /<\/?[a-z][^>]*>|```|\[[^\]]*\]\([^)]*\)|https?:\/\//i;
|
|
94
|
+
/**
|
|
95
|
+
* An answer held to the overlay's rules, or `null` when nothing usable is
|
|
96
|
+
* left: a bar with no text, a popup with no body, or copy carrying markup or
|
|
97
|
+
* a link. A field over its limit is cut rather than refused, and a trigger
|
|
98
|
+
* outside the caller's catalog is dropped, with each recorded as a finding.
|
|
99
|
+
*/ export function checkAiOverlayCopy(answer, kind, limits, triggers) {
|
|
100
|
+
if (!answer) return null;
|
|
101
|
+
const findings = [];
|
|
102
|
+
const field = (name, multiline = false)=>{
|
|
103
|
+
const raw = answer[name];
|
|
104
|
+
const value = fit(raw, limits[name], multiline);
|
|
105
|
+
if (fit(raw, Number.MAX_SAFE_INTEGER, multiline).length > limits[name]) {
|
|
106
|
+
findings.push(`${name} cut to ${limits[name]} characters`);
|
|
107
|
+
}
|
|
108
|
+
return value;
|
|
109
|
+
};
|
|
110
|
+
const proposal = {
|
|
111
|
+
kind,
|
|
112
|
+
name: field('name'),
|
|
113
|
+
text: kind === 'bar' ? field('text') : '',
|
|
114
|
+
headline: kind === 'popup' ? field('headline') : '',
|
|
115
|
+
body: kind === 'popup' ? field('body', true) : '',
|
|
116
|
+
ctaLabel: kind === 'popup' ? field('ctaLabel') : '',
|
|
117
|
+
trigger: null,
|
|
118
|
+
triggerValue: null,
|
|
119
|
+
rationale: fit(answer.rationale, 200)
|
|
120
|
+
};
|
|
121
|
+
if ([
|
|
122
|
+
proposal.text,
|
|
123
|
+
proposal.headline,
|
|
124
|
+
proposal.body,
|
|
125
|
+
proposal.ctaLabel
|
|
126
|
+
].some((value)=>MARKUP.test(value))) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
if (kind === 'bar' ? !proposal.text : !proposal.body) return null;
|
|
130
|
+
if (kind === 'popup' && answer.trigger) {
|
|
131
|
+
const trigger = answer.trigger;
|
|
132
|
+
if (triggers.has(trigger)) {
|
|
133
|
+
var _triggers_get;
|
|
134
|
+
proposal.trigger = trigger;
|
|
135
|
+
const range = (_triggers_get = triggers.get(trigger)) != null ? _triggers_get : null;
|
|
136
|
+
if (range && answer.triggerValue !== null && Number.isFinite(answer.triggerValue)) {
|
|
137
|
+
proposal.triggerValue = Math.min(range.max, Math.max(range.min, Math.round(answer.triggerValue)));
|
|
138
|
+
}
|
|
139
|
+
} else if (answer.trigger !== 'none') {
|
|
140
|
+
findings.push(`trigger "${answer.trigger}" is not one the site offers`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
proposal,
|
|
145
|
+
findings
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/** The proposal a finished overlay job's output carries, or `null` for anything else. */ export function readAiOverlayCopy(proposal) {
|
|
149
|
+
if (!proposal || proposal['task'] !== AI_OVERLAY_COPY_TASK) return null;
|
|
150
|
+
const kind = proposal['kind'];
|
|
151
|
+
if (kind !== 'bar' && kind !== 'popup') return null;
|
|
152
|
+
const trigger = proposal['trigger'];
|
|
153
|
+
const value = proposal['triggerValue'];
|
|
154
|
+
return {
|
|
155
|
+
kind,
|
|
156
|
+
name: str(proposal['name']),
|
|
157
|
+
text: str(proposal['text']),
|
|
158
|
+
headline: str(proposal['headline']),
|
|
159
|
+
body: str(proposal['body']),
|
|
160
|
+
ctaLabel: str(proposal['ctaLabel']),
|
|
161
|
+
trigger: AI_OVERLAY_TRIGGERS.includes(trigger) ? trigger : null,
|
|
162
|
+
triggerValue: typeof value === 'number' && Number.isFinite(value) ? value : null,
|
|
163
|
+
rationale: str(proposal['rationale'])
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/** A proposal as the plain text a `text` output shows on the AI jobs page. */ export function aiOverlayCopyText(proposal) {
|
|
167
|
+
if (proposal.kind === 'bar') return proposal.text;
|
|
168
|
+
return [
|
|
169
|
+
proposal.headline,
|
|
170
|
+
proposal.body,
|
|
171
|
+
proposal.ctaLabel ? `Button: ${proposal.ctaLabel}` : ''
|
|
172
|
+
].filter(Boolean).join('\n\n');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
//# sourceMappingURL=ai-overlay-copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-overlay-copy.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Overlay copy by AI (AGL-3603): what a `text` job asked for an announcement\n * bar's or a popup's copy answers, in the shape the step writes and the\n * console reads. Pure data, so the widgets and the step share one reading.\n *\n * The overlay is the marketing plugin's, and neither plugin imports the other:\n * the limits and the trigger catalog are handed to the widget by the zone,\n * and the widget passes them on as the job's inputs. The step then holds the\n * answer to the TIGHTER of those and its own ceilings below, so a job started\n * by anything else is still bounded, and drops a trigger the caller did not\n * name rather than inventing one.\n */\n\n/** The `text` job's `inputs.task` that asks for overlay copy. */\nexport const AI_OVERLAY_COPY_TASK = 'overlay'\n\n/** What the copy is for. */\nexport type AiOverlayKind = 'bar' | 'popup'\n\n/** The fields an answer fills. */\nexport type AiOverlayCopyField = 'name' | 'text' | 'headline' | 'body' | 'ctaLabel'\n\n/** The step's own ceilings: no zone may widen a field past these. */\nexport const AI_OVERLAY_COPY_CEILINGS: Readonly<Record<AiOverlayCopyField, number>> = {\n name: 80,\n text: 200,\n headline: 120,\n body: 600,\n ctaLabel: 60,\n}\n\n/** The triggers a popup may be proposed to open on, as the site runtime names them. */\nexport const AI_OVERLAY_TRIGGERS = ['delay', 'scroll', 'exit'] as const\nexport type AiOverlayTrigger = (typeof AI_OVERLAY_TRIGGERS)[number]\n\n/** One trigger as the zone hands it over: its id and the range of its value. */\nexport interface AiOverlayTriggerRule {\n id: string\n label: string\n unit: 'seconds' | 'percent' | null\n min: number\n max: number\n}\n\n/** The longest description of the current copy a job sends. */\nexport const AI_OVERLAY_CURRENT_MAX_CHARS = 1_200\n\n/** What a checked answer proposes. Absent fields propose nothing. */\nexport interface AiOverlayCopyProposal {\n kind: AiOverlayKind\n name: string\n text: string\n headline: string\n body: string\n ctaLabel: string\n trigger: AiOverlayTrigger | null\n triggerValue: number | null\n /** One sentence on what the copy leans on; shown, never written. */\n rationale: string\n}\n\n/** What the model answered, before the check. */\nexport interface AiOverlayCopyAnswer {\n name: string\n text: string\n headline: string\n body: string\n ctaLabel: string\n trigger: string\n triggerValue: number | null\n rationale: string\n}\n\nconst str = (value: unknown): string => (typeof value === 'string' ? value.trim() : '')\n\n/** The kind a job's inputs name, or `null`. */\nexport function aiOverlayKind(inputs: Readonly<Record<string, unknown>> | null | undefined): AiOverlayKind | null {\n const kind = inputs?.['overlayKind']\n return kind === 'bar' || kind === 'popup' ? kind : null\n}\n\n/** Whether a `text` job's inputs ask for overlay copy. */\nexport function aiOverlayCopyRequested(inputs: Readonly<Record<string, unknown>> | null | undefined): boolean {\n return inputs?.['task'] === AI_OVERLAY_COPY_TASK\n}\n\n/**\n * The limit each field is held to: the caller's, where it named one, never\n * past the step's ceiling. Inputs carry them as `limit_<field>`.\n */\nexport function aiOverlayLimits(\n inputs: Readonly<Record<string, unknown>> | null | undefined,\n): Record<AiOverlayCopyField, number> {\n const limits = { ...AI_OVERLAY_COPY_CEILINGS }\n for (const field of Object.keys(limits) as AiOverlayCopyField[]) {\n const asked = Number(inputs?.[`limit_${field}`])\n if (Number.isFinite(asked) && asked > 0) limits[field] = Math.min(limits[field], Math.floor(asked))\n }\n return limits\n}\n\n/**\n * The triggers the caller allows, with their ranges. Inputs carry them as\n * `triggers` (`delay:0-120,scroll:1-100,exit`); an id the runtime does not\n * know is dropped, and with no list a popup is proposed no trigger at all.\n */\nexport function aiOverlayTriggerRanges(\n inputs: Readonly<Record<string, unknown>> | null | undefined,\n): Map<AiOverlayTrigger, { min: number; max: number } | null> {\n const ranges = new Map<AiOverlayTrigger, { min: number; max: number } | null>()\n for (const part of str(inputs?.['triggers']).split(',')) {\n const [id, range] = part.trim().split(':')\n if (!(AI_OVERLAY_TRIGGERS as readonly string[]).includes(id)) continue\n const [min, max] = String(range ?? '').split('-').map(Number)\n ranges.set(\n id as AiOverlayTrigger,\n Number.isFinite(min) && Number.isFinite(max) && max >= min ? { min, max } : null,\n )\n }\n return ranges\n}\n\n/** The zone's trigger catalog as the job's `triggers` input. */\nexport function aiOverlayTriggersInput(rules: readonly AiOverlayTriggerRule[]): string {\n return rules\n .filter((rule) => (AI_OVERLAY_TRIGGERS as readonly string[]).includes(rule.id))\n .map((rule) => (rule.unit ? `${rule.id}:${rule.min}-${rule.max}` : rule.id))\n .join(',')\n}\n\n/** The zone's limits as the job's `limit_<field>` inputs. */\nexport function aiOverlayLimitInputs(\n limits: Readonly<Partial<Record<AiOverlayCopyField, number>>>,\n): Record<string, number> {\n const inputs: Record<string, number> = {}\n for (const field of Object.keys(AI_OVERLAY_COPY_CEILINGS) as AiOverlayCopyField[]) {\n const limit = limits[field]\n if (typeof limit === 'number' && limit > 0) inputs[`limit_${field}`] = limit\n }\n return inputs\n}\n\n/** One field on one line, or a body with its paragraphs, cut to its limit. */\nfunction fit(value: string, limit: number, multiline = false): string {\n const folded = multiline\n ? value.replace(/\\r\\n?/g, '\\n').replace(/[^\\S\\n]+/g, ' ').replace(/\\n{3,}/g, '\\n\\n')\n : value.replace(/\\s+/g, ' ')\n return folded.trim().slice(0, limit).trim()\n}\n\n/** Markup, a fence or a link: things a bar or a popup shows as typed. */\nconst MARKUP = /<\\/?[a-z][^>]*>|```|\\[[^\\]]*\\]\\([^)]*\\)|https?:\\/\\//i\n\nexport interface AiOverlayCopyCheck {\n proposal: AiOverlayCopyProposal\n /** What was cut or dropped, for the log. */\n findings: string[]\n}\n\n/**\n * An answer held to the overlay's rules, or `null` when nothing usable is\n * left: a bar with no text, a popup with no body, or copy carrying markup or\n * a link. A field over its limit is cut rather than refused, and a trigger\n * outside the caller's catalog is dropped, with each recorded as a finding.\n */\nexport function checkAiOverlayCopy(\n answer: AiOverlayCopyAnswer | null,\n kind: AiOverlayKind,\n limits: Readonly<Record<AiOverlayCopyField, number>>,\n triggers: ReadonlyMap<AiOverlayTrigger, { min: number; max: number } | null>,\n): AiOverlayCopyCheck | null {\n if (!answer) return null\n const findings: string[] = []\n const field = (name: AiOverlayCopyField, multiline = false): string => {\n const raw = answer[name]\n const value = fit(raw, limits[name], multiline)\n if (fit(raw, Number.MAX_SAFE_INTEGER, multiline).length > limits[name]) {\n findings.push(`${name} cut to ${limits[name]} characters`)\n }\n return value\n }\n const proposal: AiOverlayCopyProposal = {\n kind,\n name: field('name'),\n text: kind === 'bar' ? field('text') : '',\n headline: kind === 'popup' ? field('headline') : '',\n body: kind === 'popup' ? field('body', true) : '',\n ctaLabel: kind === 'popup' ? field('ctaLabel') : '',\n trigger: null,\n triggerValue: null,\n rationale: fit(answer.rationale, 200),\n }\n if ([proposal.text, proposal.headline, proposal.body, proposal.ctaLabel].some((value) => MARKUP.test(value))) {\n return null\n }\n if (kind === 'bar' ? !proposal.text : !proposal.body) return null\n if (kind === 'popup' && answer.trigger) {\n const trigger = answer.trigger as AiOverlayTrigger\n if (triggers.has(trigger)) {\n proposal.trigger = trigger\n const range = triggers.get(trigger) ?? null\n if (range && answer.triggerValue !== null && Number.isFinite(answer.triggerValue)) {\n proposal.triggerValue = Math.min(range.max, Math.max(range.min, Math.round(answer.triggerValue)))\n }\n } else if (answer.trigger !== 'none') {\n findings.push(`trigger \"${answer.trigger}\" is not one the site offers`)\n }\n }\n return { proposal, findings }\n}\n\n/** The proposal a finished overlay job's output carries, or `null` for anything else. */\nexport function readAiOverlayCopy(proposal: Record<string, unknown> | null | undefined): AiOverlayCopyProposal | null {\n if (!proposal || proposal['task'] !== AI_OVERLAY_COPY_TASK) return null\n const kind = proposal['kind']\n if (kind !== 'bar' && kind !== 'popup') return null\n const trigger = proposal['trigger']\n const value = proposal['triggerValue']\n return {\n kind,\n name: str(proposal['name']),\n text: str(proposal['text']),\n headline: str(proposal['headline']),\n body: str(proposal['body']),\n ctaLabel: str(proposal['ctaLabel']),\n trigger: (AI_OVERLAY_TRIGGERS as readonly unknown[]).includes(trigger) ? (trigger as AiOverlayTrigger) : null,\n triggerValue: typeof value === 'number' && Number.isFinite(value) ? value : null,\n rationale: str(proposal['rationale']),\n }\n}\n\n/** A proposal as the plain text a `text` output shows on the AI jobs page. */\nexport function aiOverlayCopyText(proposal: AiOverlayCopyProposal): string {\n if (proposal.kind === 'bar') return proposal.text\n return [\n proposal.headline,\n proposal.body,\n proposal.ctaLabel ? `Button: ${proposal.ctaLabel}` : '',\n ]\n .filter(Boolean)\n .join('\\n\\n')\n}\n"],"names":["AI_OVERLAY_COPY_TASK","AI_OVERLAY_COPY_CEILINGS","name","text","headline","body","ctaLabel","AI_OVERLAY_TRIGGERS","AI_OVERLAY_CURRENT_MAX_CHARS","str","value","trim","aiOverlayKind","inputs","kind","aiOverlayCopyRequested","aiOverlayLimits","limits","field","Object","keys","asked","Number","isFinite","Math","min","floor","aiOverlayTriggerRanges","ranges","Map","part","split","id","range","includes","max","String","map","set","aiOverlayTriggersInput","rules","filter","rule","unit","join","aiOverlayLimitInputs","limit","fit","multiline","folded","replace","slice","MARKUP","checkAiOverlayCopy","answer","triggers","findings","raw","MAX_SAFE_INTEGER","length","push","proposal","trigger","triggerValue","rationale","some","test","has","get","round","readAiOverlayCopy","aiOverlayCopyText","Boolean"],"mappings":"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"}
|
|
@@ -27,16 +27,41 @@ import type { AiJobSummary } from './ai-jobs.types';
|
|
|
27
27
|
*
|
|
28
28
|
* Pure: no React, no request. The page and its spec read the same rows.
|
|
29
29
|
*/
|
|
30
|
-
export type AiSiteBuildRowState = 'done' | 'active' | 'waiting' | 'failed';
|
|
30
|
+
export type AiSiteBuildRowState = 'done' | 'active' | 'waiting' | 'failed' | 'skipped';
|
|
31
31
|
export interface AiSiteBuildRow {
|
|
32
32
|
id: string;
|
|
33
33
|
label: string;
|
|
34
34
|
state: AiSiteBuildRowState;
|
|
35
|
+
/** What the person should know about this row (AGL-3616): a build item's failure, note or refund. */
|
|
36
|
+
detail?: string | null;
|
|
37
|
+
/** What the row is doing while it is the active one, in a sentence. */
|
|
38
|
+
hint?: string | null;
|
|
39
|
+
/** A page's planned sections, in order, so the person sees what is being written. */
|
|
40
|
+
sections?: string[];
|
|
41
|
+
/** The credits this row's work used, once it has finished; absent while it runs. */
|
|
42
|
+
credits?: number;
|
|
43
|
+
/** When this row's work started, for the elapsed time beside the active row. */
|
|
44
|
+
startedAt?: string | null;
|
|
35
45
|
}
|
|
36
46
|
/** Where the whole job stands, as the page's header and actions read it. */
|
|
37
47
|
export type AiSiteBuildPhase = 'working' | 'done' | 'stopped' | 'failed' | 'canceled';
|
|
38
48
|
export declare function aiSiteBuildPhase(job: Pick<AiJobSummary, 'status'>): AiSiteBuildPhase;
|
|
39
|
-
|
|
49
|
+
/**
|
|
50
|
+
* One row a stage: planning, then each creation the plan builds before its
|
|
51
|
+
* pages — the colors, the layout, the form — then each page (AGL-3596). A
|
|
52
|
+
* scaffold builds them in that order and reports each as an output when it
|
|
53
|
+
* is written, so the first row without its output is where the build is, and
|
|
54
|
+
* where a failure stopped it: a layout that broke is the layout's row, never
|
|
55
|
+
* the first page's.
|
|
56
|
+
*/
|
|
57
|
+
export declare function aiSiteBuildRows(job: Pick<AiJobSummary, 'status' | 'steps' | 'plan' | 'outputs' | 'review'> & Partial<Pick<AiJobSummary, 'items' | 'kind' | 'siteInputs' | 'sitePublish'>>): AiSiteBuildRow[];
|
|
58
|
+
/** What the planning row says while it runs. */
|
|
59
|
+
export declare const AI_SITE_PLAN_HINT = "Reading your answers and choosing your pages, what each one says, and the forms and layout they need. This usually takes under a minute.";
|
|
60
|
+
/**
|
|
61
|
+
* How far the job is, from 0 to 1, by its rows: a finished row counts whole
|
|
62
|
+
* and the active one half. `null` before there is more than one row to count.
|
|
63
|
+
*/
|
|
64
|
+
export declare function aiSiteBuildFraction(rows: readonly AiSiteBuildRow[]): number | null;
|
|
40
65
|
/**
|
|
41
66
|
* The job's one price (AGL-3594), never a plan's on its own: what it has used
|
|
42
67
|
* so far while it works, what it used once done, and, on a failure we gave
|
|
@@ -58,4 +83,4 @@ export interface AiJobPageCopy {
|
|
|
58
83
|
* done site job without that record — an older job, or one that was not a
|
|
59
84
|
* guided start — built drafts, and says that instead.
|
|
60
85
|
*/
|
|
61
|
-
export declare function aiJobPageCopy(job: Pick<AiJobSummary, 'kind' | 'status' | 'review' | 'error'> & Partial<Pick<AiJobSummary, 'sitePublish'>>, brand: string): AiJobPageCopy;
|
|
86
|
+
export declare function aiJobPageCopy(job: Pick<AiJobSummary, 'kind' | 'status' | 'review' | 'error'> & Partial<Pick<AiJobSummary, 'sitePublish' | 'items'>>, brand: string): AiJobPageCopy;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
1
2
|
/**
|
|
2
3
|
* @license
|
|
3
4
|
* Copyright 2026 Aglyn LLC
|
|
@@ -14,6 +15,8 @@
|
|
|
14
15
|
* See the License for the specific language governing permissions and
|
|
15
16
|
* limitations under the License.
|
|
16
17
|
*/ import { aiJobKindNoun } from "./ai-job-activity.js";
|
|
18
|
+
import { aiJobRefundCopy } from "./ai-job-failure-copy.js";
|
|
19
|
+
import { aiBuildItemRows, aiBuildOutcomeLine, aiSitePartialCopy } from "./ai-build-progress.js";
|
|
17
20
|
export function aiSiteBuildPhase(job) {
|
|
18
21
|
switch(job.status){
|
|
19
22
|
case 'done':
|
|
@@ -29,34 +32,181 @@ export function aiSiteBuildPhase(job) {
|
|
|
29
32
|
return 'working';
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
/** The creations a scaffold builds before its pages, in its build order, and what each row says. */ const CREATION_ROWS = [
|
|
36
|
+
{
|
|
37
|
+
kind: 'theme-change',
|
|
38
|
+
resource: 'theme',
|
|
39
|
+
label: ()=>'Choosing your colors'
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
kind: 'layout',
|
|
43
|
+
resource: 'layout',
|
|
44
|
+
label: (name)=>`Building the header and footer: ${name}`
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
kind: 'form',
|
|
48
|
+
resource: 'form',
|
|
49
|
+
label: (name)=>`Building the form: ${name}`
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
/**
|
|
53
|
+
* One row a stage: planning, then each creation the plan builds before its
|
|
54
|
+
* pages — the colors, the layout, the form — then each page (AGL-3596). A
|
|
55
|
+
* scaffold builds them in that order and reports each as an output when it
|
|
56
|
+
* is written, so the first row without its output is where the build is, and
|
|
57
|
+
* where a failure stopped it: a layout that broke is the layout's row, never
|
|
58
|
+
* the first page's.
|
|
59
|
+
*/ export function aiSiteBuildRows(job) {
|
|
60
|
+
var _ref, _planStep_creditsSpent, _built_get, _ref1;
|
|
61
|
+
var _job_items, _job_plan;
|
|
35
62
|
const phase = aiSiteBuildPhase(job);
|
|
63
|
+
// A build is read off its item ledger (AGL-3616): one row an item, each with
|
|
64
|
+
// its own state and what became of its credits.
|
|
65
|
+
if ((_job_items = job.items) == null ? void 0 : _job_items.length) {
|
|
66
|
+
var _job_items1;
|
|
67
|
+
const site = job.kind !== 'build';
|
|
68
|
+
const pages = ((_job_items1 = job.items) != null ? _job_items1 : []).filter((row)=>row.op === 'page');
|
|
69
|
+
return [
|
|
70
|
+
{
|
|
71
|
+
id: 'plan',
|
|
72
|
+
label: site ? 'Planning your pages' : 'Planning what to build',
|
|
73
|
+
state: 'done'
|
|
74
|
+
},
|
|
75
|
+
...aiBuildItemRows(job).map((row, index)=>{
|
|
76
|
+
var _job_items, _ledger_creditsSpent, _ledger_creditsRefunded;
|
|
77
|
+
const ledger = ((_job_items = job.items) != null ? _job_items : [])[index];
|
|
78
|
+
// A site keeps the scaffold's own words for each stage (AGL-3596).
|
|
79
|
+
const label = !site || !ledger ? row.label : ledger.op === 'theme' ? 'Choosing your colors' : ledger.op === 'layout' ? `Building the header and footer: ${ledger.label}` : ledger.op === 'form' ? `Building the form: ${ledger.label}` : ledger.op === 'page' ? `Writing page ${pages.indexOf(ledger) + 1} of ${pages.length}: ${ledger.label}` : ledger.op === 'email' ? 'Writing your welcome email' : row.label;
|
|
80
|
+
const screen = (ledger == null ? void 0 : ledger.op) === 'page' ? aiPlanScreenFor(job.plan, ledger.label, pages.indexOf(ledger)) : null;
|
|
81
|
+
const finished = row.state === 'done' || row.state === 'failed';
|
|
82
|
+
const net = ledger ? Math.max(0, Math.floor(((_ledger_creditsSpent = ledger.creditsSpent) != null ? _ledger_creditsSpent : 0) - ((_ledger_creditsRefunded = ledger.creditsRefunded) != null ? _ledger_creditsRefunded : 0))) : 0;
|
|
83
|
+
return _extends({
|
|
84
|
+
id: row.slot,
|
|
85
|
+
label,
|
|
86
|
+
state: row.state,
|
|
87
|
+
detail: row.detail
|
|
88
|
+
}, (screen == null ? void 0 : screen.sections.length) ? {
|
|
89
|
+
sections: screen.sections.map((section)=>section.name)
|
|
90
|
+
} : {}, finished && ledger ? {
|
|
91
|
+
credits: net
|
|
92
|
+
} : {});
|
|
93
|
+
}),
|
|
94
|
+
...aiSitePublishRow(job, phase)
|
|
95
|
+
];
|
|
96
|
+
}
|
|
36
97
|
const planStep = job.steps.find((step)=>step.name === 'plan');
|
|
37
98
|
const planDone = (planStep == null ? void 0 : planStep.status) === 'done' || Boolean(job.plan);
|
|
38
|
-
const
|
|
39
|
-
const
|
|
99
|
+
const stopped = phase === 'failed' || phase === 'stopped';
|
|
100
|
+
const planState = planDone ? 'done' : stopped ? 'failed' : phase === 'working' ? 'active' : 'waiting';
|
|
40
101
|
const rows = [
|
|
41
|
-
{
|
|
102
|
+
_extends({
|
|
42
103
|
id: 'plan',
|
|
43
104
|
label: 'Planning your pages',
|
|
44
|
-
state:
|
|
45
|
-
|
|
105
|
+
state: planState,
|
|
106
|
+
startedAt: (_ref = planStep == null ? void 0 : planStep.startedAt) != null ? _ref : null,
|
|
107
|
+
hint: planState === 'active' ? AI_SITE_PLAN_HINT : null
|
|
108
|
+
}, planDone && planStep ? {
|
|
109
|
+
credits: Math.max(0, Math.floor((_planStep_creditsSpent = planStep.creditsSpent) != null ? _planStep_creditsSpent : 0))
|
|
110
|
+
} : {})
|
|
46
111
|
];
|
|
47
|
-
|
|
48
|
-
|
|
112
|
+
// Before there is a plan, the stages a guided start always goes through
|
|
113
|
+
// are named from its answers, so the page shows the whole way from the
|
|
114
|
+
// start rather than one row.
|
|
115
|
+
if (!job.plan && job.kind !== 'build') {
|
|
116
|
+
var _job_siteInputs;
|
|
117
|
+
const pagesAsked = typeof ((_job_siteInputs = job.siteInputs) == null ? void 0 : _job_siteInputs['pages']) === 'number' ? Math.round(job.siteInputs['pages']) : 0;
|
|
118
|
+
if (job.siteInputs) {
|
|
119
|
+
rows.push({
|
|
120
|
+
id: 'layout',
|
|
121
|
+
label: 'Building the header and footer',
|
|
122
|
+
state: 'waiting'
|
|
123
|
+
});
|
|
124
|
+
rows.push({
|
|
125
|
+
id: 'pages',
|
|
126
|
+
label: pagesAsked > 1 ? `Writing your ${pagesAsked} pages` : 'Writing your pages',
|
|
127
|
+
state: 'waiting'
|
|
128
|
+
});
|
|
129
|
+
rows.push(...aiSitePublishRow(job, phase));
|
|
130
|
+
}
|
|
131
|
+
return rows;
|
|
132
|
+
}
|
|
133
|
+
const built = new Map();
|
|
134
|
+
for (const output of job.outputs)built.set(output.resource, ((_built_get = built.get(output.resource)) != null ? _built_get : 0) + 1);
|
|
135
|
+
const take = (resource)=>{
|
|
136
|
+
var _built_get;
|
|
137
|
+
const left = (_built_get = built.get(resource)) != null ? _built_get : 0;
|
|
138
|
+
if (left <= 0) return false;
|
|
139
|
+
built.set(resource, left - 1);
|
|
140
|
+
return true;
|
|
141
|
+
};
|
|
142
|
+
const stages = [];
|
|
143
|
+
for (const row of CREATION_ROWS){
|
|
144
|
+
var _job_plan1;
|
|
145
|
+
const creation = (_job_plan1 = job.plan) == null ? void 0 : _job_plan1.create.find((entry)=>entry.kind === row.kind);
|
|
146
|
+
if (creation) stages.push({
|
|
147
|
+
id: row.resource,
|
|
148
|
+
label: row.label(creation.name),
|
|
149
|
+
resource: row.resource
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
const pages = (_ref1 = (_job_plan = job.plan) == null ? void 0 : _job_plan.screens) != null ? _ref1 : [];
|
|
49
153
|
pages.forEach((page, index)=>{
|
|
50
|
-
|
|
51
|
-
const current = !done && index === written && planDone;
|
|
52
|
-
rows.push({
|
|
154
|
+
stages.push({
|
|
53
155
|
id: `page-${index}`,
|
|
54
156
|
label: `Writing page ${index + 1} of ${pages.length}: ${page.title}`,
|
|
55
|
-
|
|
157
|
+
resource: 'screen',
|
|
158
|
+
sections: page.sections.map((section)=>section.name)
|
|
56
159
|
});
|
|
57
160
|
});
|
|
161
|
+
let reached = false;
|
|
162
|
+
for (const stage of stages){
|
|
163
|
+
var _stage_sections;
|
|
164
|
+
const done = phase === 'done' || take(stage.resource);
|
|
165
|
+
const current = !done && !reached && planDone;
|
|
166
|
+
if (current) reached = true;
|
|
167
|
+
rows.push(_extends({
|
|
168
|
+
id: stage.id,
|
|
169
|
+
label: stage.label,
|
|
170
|
+
state: done ? 'done' : current && stopped ? 'failed' : current && phase === 'working' ? 'active' : 'waiting'
|
|
171
|
+
}, ((_stage_sections = stage.sections) == null ? void 0 : _stage_sections.length) ? {
|
|
172
|
+
sections: stage.sections
|
|
173
|
+
} : {}));
|
|
174
|
+
}
|
|
175
|
+
rows.push(...aiSitePublishRow(job, phase));
|
|
58
176
|
return rows;
|
|
59
177
|
}
|
|
178
|
+
/** What the planning row says while it runs. */ export const AI_SITE_PLAN_HINT = 'Reading your answers and choosing your pages, what each one says, and the forms and layout they need. This usually takes under a minute.';
|
|
179
|
+
/** The plan's page an item builds: by its title, else by its place among the pages. */ function aiPlanScreenFor(plan, title, index) {
|
|
180
|
+
var _ref, _screens_find, _screens_index;
|
|
181
|
+
const screens = (_ref = plan == null ? void 0 : plan.screens) != null ? _ref : [];
|
|
182
|
+
return (_screens_find = screens.find((screen)=>screen.title === title)) != null ? _screens_find : index >= 0 ? (_screens_index = screens[index]) != null ? _screens_index : null : null;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* A guided start ends by putting its pages live (AGL-3596): the last row, so
|
|
186
|
+
* the person sees that step coming and when it is done. Only a site job
|
|
187
|
+
* publishes on its own; a build publishes when asked, and says so in its plan.
|
|
188
|
+
*/ function aiSitePublishRow(job, phase) {
|
|
189
|
+
var _ref;
|
|
190
|
+
var _job_sitePublish;
|
|
191
|
+
if (job.kind !== 'site') return [];
|
|
192
|
+
const published = ((_ref = (_job_sitePublish = job.sitePublish) == null ? void 0 : _job_sitePublish.published.length) != null ? _ref : 0) > 0;
|
|
193
|
+
return [
|
|
194
|
+
{
|
|
195
|
+
id: 'publish',
|
|
196
|
+
label: 'Publishing your site',
|
|
197
|
+
// A job that stopped or failed publishes nothing, so the row is passed over.
|
|
198
|
+
state: phase === 'done' ? published ? 'done' : 'skipped' : phase === 'working' ? 'waiting' : 'skipped'
|
|
199
|
+
}
|
|
200
|
+
];
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* How far the job is, from 0 to 1, by its rows: a finished row counts whole
|
|
204
|
+
* and the active one half. `null` before there is more than one row to count.
|
|
205
|
+
*/ export function aiSiteBuildFraction(rows) {
|
|
206
|
+
if (rows.length < 2) return null;
|
|
207
|
+
const counted = rows.reduce((sum, row)=>sum + (row.state === 'active' ? 0.5 : row.state === 'waiting' ? 0 : 1), 0);
|
|
208
|
+
return Math.min(1, counted / rows.length);
|
|
209
|
+
}
|
|
60
210
|
/**
|
|
61
211
|
* The job's one price (AGL-3594), never a plan's on its own: what it has used
|
|
62
212
|
* so far while it works, what it used once done, and, on a failure we gave
|
|
@@ -69,10 +219,13 @@ export function aiSiteBuildRows(job) {
|
|
|
69
219
|
const phase = aiSiteBuildPhase(job);
|
|
70
220
|
// What the job made, by its kind; a job that names none is a site's.
|
|
71
221
|
const subject = !job.kind || job.kind === 'site' ? 'This site' : aiJobKindNoun(job.kind) === 'AI job' ? 'This AI job' : `This ${aiJobKindNoun(job.kind)}`;
|
|
72
|
-
|
|
222
|
+
// A failure on our side says so in the words every surface uses (AGL-3596),
|
|
223
|
+
// from the job's recorded give-back.
|
|
224
|
+
const refund = phase === 'working' || phase === 'done' ? null : aiJobRefundCopy(job);
|
|
225
|
+
if (refund && refunded > 0) return refund;
|
|
73
226
|
if (phase === 'done') return `${subject} used ${net} credits.`;
|
|
74
227
|
if (phase === 'working') return `Credits used so far: ${net}`;
|
|
75
|
-
if (
|
|
228
|
+
if (refund) return `${subject} used ${net} credits. ${refund}`;
|
|
76
229
|
return net > 0 ? `${subject} used ${net} credits.` : null;
|
|
77
230
|
}
|
|
78
231
|
/**
|
|
@@ -88,6 +241,8 @@ export function aiSiteBuildRows(job) {
|
|
|
88
241
|
var _ref, _ref1;
|
|
89
242
|
var _job_review;
|
|
90
243
|
const phase = aiSiteBuildPhase(job);
|
|
244
|
+
// A build is what the person asked for, item by item (AGL-3616).
|
|
245
|
+
if (job.kind === 'build') return aiBuildPageCopy(job, brand);
|
|
91
246
|
const noun = job.kind === 'site' ? 'site' : aiJobKindNoun(job.kind);
|
|
92
247
|
const generic = noun === 'AI job';
|
|
93
248
|
// `products` is the one plural noun.
|
|
@@ -103,13 +258,25 @@ export function aiSiteBuildRows(job) {
|
|
|
103
258
|
var _ref2;
|
|
104
259
|
var _job_sitePublish;
|
|
105
260
|
const published = (_ref2 = (_job_sitePublish = job.sitePublish) == null ? void 0 : _job_sitePublish.published.length) != null ? _ref2 : 0;
|
|
261
|
+
// Part of the site was built (AGL-3616): what was, what was not, and its credits.
|
|
262
|
+
const partial = job.kind === 'site' ? aiSitePartialCopy({
|
|
263
|
+
items: job.items,
|
|
264
|
+
status: job.status
|
|
265
|
+
}) : null;
|
|
106
266
|
if (job.kind === 'site' && published > 0) {
|
|
107
267
|
var _job_sitePublish1;
|
|
108
268
|
return {
|
|
109
269
|
heading: 'Your site is live',
|
|
110
|
-
lede:
|
|
270
|
+
lede: [
|
|
271
|
+
partial,
|
|
272
|
+
((_job_sitePublish1 = job.sitePublish) == null ? void 0 : _job_sitePublish1.drafts.length) ? 'Your pages are published, except the ones listed below, which stayed drafts.' : 'Your pages are published, and anyone can visit your site now.'
|
|
273
|
+
].filter(Boolean).join(' ')
|
|
111
274
|
};
|
|
112
275
|
}
|
|
276
|
+
if (partial) return {
|
|
277
|
+
heading: 'Your site is ready',
|
|
278
|
+
lede: `${partial} Your new pages are drafts. Publish them when you’re happy.`
|
|
279
|
+
};
|
|
113
280
|
if (job.kind === 'site' && job.sitePublish) {
|
|
114
281
|
return {
|
|
115
282
|
heading: 'Your site is ready',
|
|
@@ -132,5 +299,52 @@ export function aiSiteBuildRows(job) {
|
|
|
132
299
|
lede: why != null ? why : generic ? 'Something went wrong running this job.' : `Something went wrong building your ${noun}.`
|
|
133
300
|
};
|
|
134
301
|
}
|
|
302
|
+
/** A build's page heading and sentence (AGL-3616). */ function aiBuildPageCopy(job, brand) {
|
|
303
|
+
var _job_items, _job_error;
|
|
304
|
+
const phase = aiSiteBuildPhase(job);
|
|
305
|
+
const outcome = aiBuildOutcomeLine({
|
|
306
|
+
items: (_job_items = job.items) != null ? _job_items : [],
|
|
307
|
+
status: job.status
|
|
308
|
+
});
|
|
309
|
+
if (phase === 'working') {
|
|
310
|
+
return {
|
|
311
|
+
heading: 'Building what you asked for',
|
|
312
|
+
lede: `${brand} AI is building each part in turn. You can leave this page; it keeps going.`
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
if (phase === 'stopped') {
|
|
316
|
+
var _ref, _ref1;
|
|
317
|
+
var _job_review, _job_review1;
|
|
318
|
+
return {
|
|
319
|
+
heading: ((_job_review = job.review) == null ? void 0 : _job_review.reason) === 'plan' ? 'Your plan is ready' : 'Your build needs you',
|
|
320
|
+
lede: (_ref = (_ref1 = (_job_review1 = job.review) == null ? void 0 : _job_review1.message) != null ? _ref1 : job.error) != null ? _ref : 'It waits for your decision.'
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
if (phase === 'done') {
|
|
324
|
+
var _job_items1, _ref2;
|
|
325
|
+
var _job_sitePublish;
|
|
326
|
+
const failed = ((_job_items1 = job.items) != null ? _job_items1 : []).some((row)=>row.status === 'failed' || row.status === 'skipped');
|
|
327
|
+
const live = (_ref2 = (_job_sitePublish = job.sitePublish) == null ? void 0 : _job_sitePublish.published.length) != null ? _ref2 : 0;
|
|
328
|
+
return {
|
|
329
|
+
heading: failed ? 'Most of it is ready' : 'Everything you asked for is ready',
|
|
330
|
+
lede: [
|
|
331
|
+
outcome,
|
|
332
|
+
live ? 'Your new pages are published.' : 'Everything it built is an unpublished draft until you publish it.',
|
|
333
|
+
failed ? 'Try again builds only what failed.' : ''
|
|
334
|
+
].filter(Boolean).join(' ')
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
if (phase === 'canceled') return {
|
|
338
|
+
heading: 'Your build was canceled',
|
|
339
|
+
lede: 'The job was canceled.'
|
|
340
|
+
};
|
|
341
|
+
return {
|
|
342
|
+
heading: 'Nothing could be built',
|
|
343
|
+
lede: [
|
|
344
|
+
(_job_error = job.error) != null ? _job_error : 'Something went wrong building what you asked for.',
|
|
345
|
+
outcome
|
|
346
|
+
].filter(Boolean).join(' ')
|
|
347
|
+
};
|
|
348
|
+
}
|
|
135
349
|
|
|
136
350
|
//# sourceMappingURL=ai-site-build-progress.js.map
|