@aglyn/plugins-ai 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-site-start-card.component.d.ts +1 -1
  3. package/src/lib/components/ai-site-start-card.component.js +40 -13
  4. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  5. package/src/lib/components/ai-site-start-steps.component.d.ts +17 -1
  6. package/src/lib/components/ai-site-start-steps.component.js +30 -7
  7. package/src/lib/components/ai-site-start-steps.component.js.map +1 -1
  8. package/src/lib/components/assist-panel.component.js +8 -12
  9. package/src/lib/components/assist-panel.component.js.map +1 -1
  10. package/src/lib/jobs/ai-job-drafts.d.ts +3 -0
  11. package/src/lib/jobs/ai-job-drafts.js +5 -0
  12. package/src/lib/jobs/ai-job-drafts.js.map +1 -1
  13. package/src/lib/jobs/ai-job-layout-language.d.ts +10 -0
  14. package/src/lib/jobs/ai-job-layout-language.js +38 -2
  15. package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
  16. package/src/lib/jobs/ai-job-layout-step.js +3 -3
  17. package/src/lib/jobs/ai-job-layout-step.js.map +1 -1
  18. package/src/lib/jobs/ai-site-import-compile.js +15 -7
  19. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  20. package/src/lib/layout-language/ai-layout-compiler.js +39 -1
  21. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  22. package/src/lib/layout-language/ai-layout-frame.d.ts +6 -0
  23. package/src/lib/layout-language/ai-layout-frame.js +85 -30
  24. package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
  25. package/src/lib/layout-language/ai-layout-language.d.ts +5 -0
  26. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  27. package/src/lib/model/ai-site-import-fidelity.d.ts +175 -0
  28. package/src/lib/model/ai-site-import-fidelity.js +941 -0
  29. package/src/lib/model/ai-site-import-fidelity.js.map +1 -0
  30. package/src/lib/model/ai-site-start.d.ts +27 -0
  31. package/src/lib/model/ai-site-start.js +41 -0
  32. package/src/lib/model/ai-site-start.js.map +1 -1
  33. package/src/lib/model/assist-page-change.d.ts +26 -6
  34. package/src/lib/model/assist-page-change.js +32 -10
  35. package/src/lib/model/assist-page-change.js.map +1 -1
  36. package/src/lib/runtime/ai-node-tree.js +18 -2
  37. package/src/lib/runtime/ai-node-tree.js.map +1 -1
  38. package/src/lib/server/assist-chat.d.ts +5 -0
  39. package/src/lib/server/assist-chat.js +11 -2
  40. package/src/lib/server/assist-chat.js.map +1 -1
  41. package/src/lib/server/assist-page-change.d.ts +12 -0
  42. package/src/lib/server/assist-page-change.js +23 -1
  43. package/src/lib/server/assist-page-change.js.map +1 -1
  44. package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +62 -0
  45. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +374 -0
  46. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/plugins-ai",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -25,22 +25,22 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@aglyn/aglyn": "1.0.0",
29
- "@aglyn/shared-data-enums": "1.0.0",
30
- "@aglyn/shared-data-mdi": "1.0.0",
31
- "@aglyn/shared-data-types": "1.0.0",
32
- "@aglyn/shared-ui-email-campaigns": "1.0.0",
33
- "@aglyn/shared-ui-jsx": "1.0.0",
34
- "@aglyn/shared-ui-snackstack": "1.0.0",
35
- "@aglyn/shared-ui-theme": "1.0.0",
36
- "@aglyn/shared-util-email": "1.0.0",
37
- "@aglyn/shared-util-errors": "1.0.0",
38
- "@aglyn/shared-util-http": "1.0.0",
39
- "@aglyn/shared-util-timestamp": "1.0.0",
40
- "@aglyn/shared-util-tools": "1.0.0",
41
- "@aglyn/tenant-data-admin": "1.0.0",
42
- "@aglyn/tenant-feature-instance": "1.0.0",
43
- "@aglyn/tenant-runtime": "1.0.0",
28
+ "@aglyn/aglyn": "1.1.0",
29
+ "@aglyn/shared-data-enums": "1.1.0",
30
+ "@aglyn/shared-data-mdi": "1.1.0",
31
+ "@aglyn/shared-data-types": "1.1.0",
32
+ "@aglyn/shared-ui-email-campaigns": "1.1.0",
33
+ "@aglyn/shared-ui-jsx": "1.1.0",
34
+ "@aglyn/shared-ui-snackstack": "1.1.0",
35
+ "@aglyn/shared-ui-theme": "1.1.0",
36
+ "@aglyn/shared-util-email": "1.1.0",
37
+ "@aglyn/shared-util-errors": "1.1.0",
38
+ "@aglyn/shared-util-http": "1.1.0",
39
+ "@aglyn/shared-util-timestamp": "1.1.0",
40
+ "@aglyn/shared-util-tools": "1.1.0",
41
+ "@aglyn/tenant-data-admin": "1.1.0",
42
+ "@aglyn/tenant-feature-instance": "1.1.0",
43
+ "@aglyn/tenant-runtime": "1.1.0",
44
44
  "@swc/helpers": "0.5.23"
45
45
  },
46
46
  "peerDependencies": {
@@ -44,5 +44,5 @@ export type AiSiteStartCardProps = ConsoleHostFirstRunZoneProps & {
44
44
  * `aiSiteStartBrief` and `aiSiteStartInputs`. Each step is reported as a
45
45
  * funnel, with where people struggle (`ai-site-start-tracking.ts`).
46
46
  */
47
- export declare function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leave, pendingSite, chooseStarter: chooseStarterInShell, clientBuild, initialAnswers, }: AiSiteStartCardProps): import("react").JSX.Element;
47
+ export declare function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leave, pendingSite, chooseStarter: chooseStarterInShell, starter, clientBuild, initialAnswers, }: AiSiteStartCardProps): import("react").JSX.Element;
48
48
  export default AiSiteStartCard;
@@ -35,7 +35,7 @@ import { AI_JOB_AUTO_CONFIRM_INPUT, AI_SITE_FREE_PAGES, aiFreeCreditsNoneLeftTex
35
35
  import { FREE_AI_TASTE_CREDITS_PER_MONTH } from "../plan-entitlements.js";
36
36
  import { AI_CREDITS_CONFIRM_CODE, aiCreditRangeText } from "../model/ai-credit-estimate.js";
37
37
  import { AiCreditsPromptNotice } from "./ai-credits-prompt.component.js";
38
- import { AI_SITE_START_ANSWERS, AI_SITE_START_STYLE_REQUIRED, aiSiteStartAnswersFromClientBuild, aiSiteStartBrief, aiSiteStartClientBrief, aiSiteStartClientInputs, aiSiteStartClientNote, aiSiteStartExtrasGiven, aiSiteStartInputs, aiSiteStartKind, aiSiteStartRefusal } from "../model/ai-site-start.js";
38
+ import { AI_SITE_START_ANSWERS, AI_SITE_START_STYLE_REQUIRED, aiSiteStartAnswersFromClientBuild, aiSiteStartAnswersFromStarter, aiSiteStartBrief, aiSiteStartClientBrief, aiSiteStartClientInputs, aiSiteStartClientNote, aiSiteStartExtrasGiven, aiSiteStartInputs, aiSiteStartKind, aiSiteStartRefusal } from "../model/ai-site-start.js";
39
39
  import { aiSiteInspirationLimit } from "../model/ai-site-inspiration.js";
40
40
  import { aiSiteStartFieldErrors, aiSiteStartFirstInvalidStep, aiSiteStartNextStep, aiSiteStartPreviousStep, aiSiteStartStepErrors, aiSiteStartStepIndex, AI_SITE_START_STEPS, AI_SITE_START_STEP_FIELDS } from "../model/ai-site-start-steps.js";
41
41
  import { aiSiteKindOfInputs } from "../model/ai-site-kinds.js";
@@ -203,8 +203,8 @@ function SectionLabel({ children, help }) {
203
203
  * held, and only the review turns them into the job, through the same
204
204
  * `aiSiteStartBrief` and `aiSiteStartInputs`. Each step is reported as a
205
205
  * funnel, with where people struggle (`ai-site-start-tracking.ts`).
206
- */ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leave, pendingSite, chooseStarter: chooseStarterInShell, clientBuild, initialAnswers = null }) {
207
- var _ref, _ref1, _ref2, _ref3, _aiFreeSitePrompt, _aiSiteStartRefusal;
206
+ */ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leave, pendingSite, chooseStarter: chooseStarterInShell, starter, clientBuild, initialAnswers = null }) {
207
+ var _ref, _ref1, _ref2, _ref3, _ref4, _aiFreeSitePrompt, _aiSiteStartRefusal;
208
208
  var _aiSiteKindOfInputs, _modelChoice_options_options_find, _modelChoice_options, _pendingSite_previewControl;
209
209
  const { data: user } = useUser();
210
210
  const router = useRouter();
@@ -218,7 +218,12 @@ function SectionLabel({ children, help }) {
218
218
  // Create site with that start's answers: read once, and only here, where
219
219
  // the site does not exist yet. It opens on the first question, where the
220
220
  // site's name and address are asked, with every answer after it filled in.
221
- const [handedOff] = useState(()=>pendingSite && !initialAnswers ? readAiSiteStartAnswers() : null);
221
+ const [handedOff] = useState(()=>pendingSite && !initialAnswers && !starter ? readAiSiteStartAnswers() : null);
222
+ // An AI starter picked in "Choose your starter" (AGL-4049): its answers
223
+ // fill the questions, read once, and the start opens on the first one.
224
+ // The style it names arrives chosen — the person chose it by picking the
225
+ // starter — and every answer is theirs to change.
226
+ const [starterAnswers] = useState(()=>starter && !initialAnswers && !clientBuild ? aiSiteStartAnswersFromStarter(starter.answers) : null);
222
227
  // A site staff are building for a client (AGL-3958): the intake answered
223
228
  // the questions already, so the start opens on the review with them, and
224
229
  // stays on this screen once it has started. Read once, like a reopened start.
@@ -230,10 +235,18 @@ function SectionLabel({ children, help }) {
230
235
  const clientBuildRef = useRef(clientBuild);
231
236
  clientBuildRef.current = clientBuild;
232
237
  // Read once: a start reopened on its answers stays one while it is open.
233
- const reopened = useRef(initialAnswers !== null || handedOff !== null || clientAnswers !== null);
234
- // A start reopened on its answers opens on the review, every answer there to change.
235
- const [step, setStep] = useState(initialAnswers || clientAnswers ? 'review' : 'choose');
236
- const [answers, setAnswers] = useState((_ref1 = (_ref2 = initialAnswers != null ? initialAnswers : clientAnswers) != null ? _ref2 : handedOff) != null ? _ref1 : AI_SITE_START_ANSWERS);
238
+ const reopened = useRef(initialAnswers !== null || handedOff !== null || clientAnswers !== null || starterAnswers !== null);
239
+ // A start reopened on its answers opens on the review, every answer there
240
+ // to change; one filled in from a starter, on the first question.
241
+ const [step, setStep] = useState(initialAnswers || clientAnswers ? 'review' : starterAnswers ? 'kind' : 'choose');
242
+ const [answers, setAnswers] = useState((_ref1 = (_ref2 = (_ref3 = initialAnswers != null ? initialAnswers : clientAnswers) != null ? _ref3 : starterAnswers) != null ? _ref2 : handedOff) != null ? _ref1 : AI_SITE_START_ANSWERS);
243
+ // The starter the answers came from, for the site to record (AGL-4049),
244
+ // and the style card that says so.
245
+ const starterChoice = starterAnswers && starter ? starter.choice : null;
246
+ const pickedStarterStyle = (starterAnswers == null ? void 0 : starterAnswers.kind) && starter ? {
247
+ id: starterAnswers.kind,
248
+ name: starter.displayName
249
+ } : null;
237
250
  // The steps whose reasons not to go forward are shown: the ones Next was refused on.
238
251
  const [checked, setChecked] = useState(()=>new Set());
239
252
  // A step opened from the review's Edit goes back to the review on Next.
@@ -340,7 +353,7 @@ function SectionLabel({ children, help }) {
340
353
  answers.pages
341
354
  ]);
342
355
  // A store's first products and a blog's first posts are part of the start (AGL-3676, AGL-3798).
343
- const siteKind = (_ref3 = (_aiSiteKindOfInputs = aiSiteKindOfInputs(aiSiteStartInputs(answers))) == null ? void 0 : _aiSiteKindOfInputs.id) != null ? _ref3 : null;
356
+ const siteKind = (_ref4 = (_aiSiteKindOfInputs = aiSiteKindOfInputs(aiSiteStartInputs(answers))) == null ? void 0 : _aiSiteKindOfInputs.id) != null ? _ref4 : null;
344
357
  const prompt = freeTaste ? (_aiFreeSitePrompt = aiFreeSitePrompt(freeCredits, answers.pages, {
345
358
  siteKind
346
359
  })) != null ? _aiFreeSitePrompt : serverPrompt : null;
@@ -448,10 +461,13 @@ function SectionLabel({ children, help }) {
448
461
  };
449
462
  if (!hostId && pendingSite) {
450
463
  if (!pendingSite.created && !await refused(await requestJob(null, true))) return;
451
- // The style the questions took (AGL-4049), recorded on the site.
452
- const made = await pendingSite.create(asked.style ? {
464
+ // The style the questions took (AGL-4049), recorded on the site, and
465
+ // the AI starter they were filled in from, when they were.
466
+ const made = await pendingSite.create(asked.style || starterChoice ? _extends({}, asked.style ? {
453
467
  style: asked.style
454
- } : undefined);
468
+ } : {}, starterChoice ? {
469
+ starter: starterChoice
470
+ } : {}) : undefined);
455
471
  if ('error' in made) {
456
472
  setNotice(made.error);
457
473
  if (made.address) setStep('choose');
@@ -529,7 +545,8 @@ function SectionLabel({ children, help }) {
529
545
  siteKind,
530
546
  tracker,
531
547
  clientIntake,
532
- siteInspiration
548
+ siteInspiration,
549
+ starterChoice
533
550
  ]);
534
551
  // The zone's `startBlank`, with the style chosen for the starter (AGL-4049).
535
552
  // Before the site exists it creates it with the starter, and answers
@@ -1093,9 +1110,19 @@ function SectionLabel({ children, help }) {
1093
1110
  }) : /*#__PURE__*/ _jsxs(Box, {
1094
1111
  component: "section",
1095
1112
  children: [
1113
+ step === 'kind' && starter && starterAnswers ? /*#__PURE__*/ _jsx(Alert, {
1114
+ severity: "info",
1115
+ variant: "outlined",
1116
+ "data-start-area": "starter-note",
1117
+ sx: {
1118
+ mb: 3
1119
+ },
1120
+ children: `Filled in from ${starter.displayName}. Change any answer you like.`
1121
+ }) : null,
1096
1122
  step === 'kind' && /*#__PURE__*/ _jsx(KindStep, _extends({}, stepProps)),
1097
1123
  step === 'audience' && /*#__PURE__*/ _jsx(AudienceStep, _extends({}, stepProps)),
1098
1124
  step === 'style' && /*#__PURE__*/ _jsx(StyleStep, _extends({}, stepProps, {
1125
+ starterStyle: pickedStarterStyle,
1099
1126
  inspiration: siteInspiration ? {
1100
1127
  limit: aiSiteInspirationLimit(freeTaste),
1101
1128
  upgradeHref: orgSlug ? aiCreditsBillingHref(orgSlug) : null