@aglyn/plugins-ai 1.9.0 → 1.10.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 (82) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-job-requests.d.ts +5 -0
  3. package/src/lib/components/ai-job-requests.js +4 -0
  4. package/src/lib/components/ai-job-requests.js.map +1 -1
  5. package/src/lib/components/ai-site-build-page.component.js +10 -3
  6. package/src/lib/components/ai-site-build-page.component.js.map +1 -1
  7. package/src/lib/components/ai-site-import-finish.component.d.ts +40 -0
  8. package/src/lib/components/ai-site-import-finish.component.js +174 -0
  9. package/src/lib/components/ai-site-import-finish.component.js.map +1 -0
  10. package/src/lib/components/ai-site-import-job.component.d.ts +11 -3
  11. package/src/lib/components/ai-site-import-job.component.js +220 -135
  12. package/src/lib/components/ai-site-import-job.component.js.map +1 -1
  13. package/src/lib/components/ai-site-import-start.component.d.ts +11 -2
  14. package/src/lib/components/ai-site-import-start.component.js +27 -5
  15. package/src/lib/components/ai-site-import-start.component.js.map +1 -1
  16. package/src/lib/components/ai-site-start-card.component.js +1 -1
  17. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  18. package/src/lib/jobs/ai-build-capabilities.js +2 -2
  19. package/src/lib/jobs/ai-build-capabilities.js.map +1 -1
  20. package/src/lib/jobs/ai-job-import-step.d.ts +2 -0
  21. package/src/lib/jobs/ai-job-import-step.js +31 -8
  22. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  23. package/src/lib/jobs/ai-job-page-language.d.ts +40 -2
  24. package/src/lib/jobs/ai-job-page-language.js +188 -9
  25. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  26. package/src/lib/jobs/ai-job-page-step.js +2 -0
  27. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  28. package/src/lib/jobs/ai-job-privacy-step.d.ts +5 -0
  29. package/src/lib/jobs/ai-job-privacy-step.js +9 -4
  30. package/src/lib/jobs/ai-job-privacy-step.js.map +1 -1
  31. package/src/lib/jobs/ai-job-text-step.d.ts +7 -1
  32. package/src/lib/jobs/ai-job-text-step.js.map +1 -1
  33. package/src/lib/jobs/ai-site-import-compile.d.ts +13 -2
  34. package/src/lib/jobs/ai-site-import-compile.js +115 -21
  35. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  36. package/src/lib/jobs/ai-site-import-document.d.ts +5 -1
  37. package/src/lib/jobs/ai-site-import-document.js +5 -1
  38. package/src/lib/jobs/ai-site-import-document.js.map +1 -1
  39. package/src/lib/jobs/ai-site-import-look.d.ts +16 -4
  40. package/src/lib/jobs/ai-site-import-look.js +54 -13
  41. package/src/lib/jobs/ai-site-import-look.js.map +1 -1
  42. package/src/lib/jobs/ai-site-import-wording.d.ts +187 -0
  43. package/src/lib/jobs/ai-site-import-wording.js +747 -0
  44. package/src/lib/jobs/ai-site-import-wording.js.map +1 -0
  45. package/src/lib/layout-language/ai-layout-compiler.d.ts +12 -1
  46. package/src/lib/layout-language/ai-layout-compiler.js +29 -30
  47. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  48. package/src/lib/layout-language/ai-layout-language.d.ts +12 -0
  49. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  50. package/src/lib/model/ai-site-import-fidelity.d.ts +211 -2
  51. package/src/lib/model/ai-site-import-fidelity.js +1011 -14
  52. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  53. package/src/lib/model/ai-site-import-report.d.ts +52 -1
  54. package/src/lib/model/ai-site-import-report.js +102 -5
  55. package/src/lib/model/ai-site-import-report.js.map +1 -1
  56. package/src/lib/model/ai-site-import-view.d.ts +62 -2
  57. package/src/lib/model/ai-site-import-view.js +83 -4
  58. package/src/lib/model/ai-site-import-view.js.map +1 -1
  59. package/src/lib/model/ai-site-import.d.ts +122 -6
  60. package/src/lib/model/ai-site-import.js +202 -9
  61. package/src/lib/model/ai-site-import.js.map +1 -1
  62. package/src/lib/model/ai-site-look.d.ts +51 -0
  63. package/src/lib/model/ai-site-look.js +205 -29
  64. package/src/lib/model/ai-site-look.js.map +1 -1
  65. package/src/lib/runtime/ai-doctrine-validators.d.ts +19 -0
  66. package/src/lib/runtime/ai-doctrine-validators.js +25 -0
  67. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  68. package/src/lib/runtime/ai-doctrine.js +4 -1
  69. package/src/lib/runtime/ai-doctrine.js.map +1 -1
  70. package/src/lib/server/ai-allotments.js +4 -2
  71. package/src/lib/server/ai-allotments.js.map +1 -1
  72. package/src/lib/server/ai-jobs-resume.js +32 -5
  73. package/src/lib/server/ai-jobs-resume.js.map +1 -1
  74. package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +36 -10
  75. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +48 -4
  76. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
  77. package/src/lib/site-import/fixtures/site-look-slate.d.ts +27 -0
  78. package/src/lib/site-import/fixtures/site-look-slate.js +29 -0
  79. package/src/lib/site-import/fixtures/site-look-slate.js.map +1 -0
  80. package/src/lib/site-import/site-import-layout.d.ts +19 -5
  81. package/src/lib/site-import/site-import-layout.js +137 -16
  82. package/src/lib/site-import/site-import-layout.js.map +1 -1
@@ -28,6 +28,7 @@ import type { AiLoadEstimate } from '../runtime/ai-palette';
28
28
  import type { AiLayoutDesign } from '../layout-language/ai-layout-design';
29
29
  import type { AiSystemBlock } from '../runtime/ai-runtime';
30
30
  import { type AiSiteImportDocument } from './ai-site-import-document';
31
+ import { type AiSiteImportWords } from '../model/ai-site-import';
31
32
  /**
32
33
  * A page built in the compact layout language (AGL-3660): the page step's
33
34
  * pass for a site's page units — a guided start's and a build's — in place of
@@ -266,6 +267,12 @@ export interface AiLayoutPageBuilt {
266
267
  dropped: string[];
267
268
  /** How many repeated items each plan section shows, as built (AGL-3660). */
268
269
  items: number[];
270
+ /**
271
+ * How the words of a page brought in under Also improve my wording came
272
+ * out (AGL-4152): `improved` where a rewrite of its lines was kept, `kept`
273
+ * where none was. Absent on every other page.
274
+ */
275
+ words?: AiSiteImportWords;
269
276
  }
270
277
  export interface AiLayoutPageCheckInput {
271
278
  screen: AiBuildPlanScreen;
@@ -384,11 +391,17 @@ export declare function aiRunLayoutPage(input: AiLayoutPageRunInput): Promise<Ai
384
391
  export declare const AI_LAYOUT_DESIGN_TEXT: string;
385
392
  /** The design answer's cached instructions, and the rule that fenced text is data. */
386
393
  export declare const AI_JOB_PAGE_DESIGN_INSTRUCTIONS: readonly AiSystemBlock[];
394
+ /**
395
+ * The line a design answer is told when the owner asked the site improved
396
+ * (AGL-4152), in its user turn alone: the cached instructions and the tool are
397
+ * the same either way, and a page kept as it is is asked exactly as before.
398
+ */
399
+ export declare const AI_LAYOUT_DESIGN_IMPROVE_LINE = "The owner asked for a better design: choose the hero, bands, alignment and styles that read best for this kind of site; the source's own are not required.";
387
400
  /** A design answer's user turn: the page, the kind of site it is, and its structure, the sections' names fenced. */
388
401
  export declare function aiLayoutDesignPrompt(input: {
389
402
  job: Pick<AiJob, 'inputs' | '$id'>;
390
403
  screen: Pick<AiBuildPlanScreen, 'title' | 'slug' | 'sections'>;
391
- doc: Pick<AiSiteImportDocument, 'blocks' | 'title' | 'url' | 'layout'>;
404
+ doc: Pick<AiSiteImportDocument, 'blocks' | 'title' | 'url' | 'layout' | 'finish'>;
392
405
  }): string;
393
406
  /**
394
407
  * The check a page brought in is held to (AGL-4084, AGL-4107): its layout
@@ -396,11 +409,16 @@ export declare function aiLayoutDesignPrompt(input: {
396
409
  * answer where one is given — stored, and checked whole as a page of its
397
410
  * owner's own words. An answer whose design cannot be drawn is set aside and
398
411
  * the page is drawn as its source lays it out, so no answer is asked again
399
- * for what code decides. Nothing in an answer can change a word.
412
+ * for what code decides. Nothing in a design answer can change a word.
413
+ *
414
+ * `rewritten` names the lines a wording answer reworded (AGL-4152), whose
415
+ * words the document already carries: rule 14's copy checks judge them as
416
+ * the copy a generator wrote that they are.
400
417
  */
401
418
  export declare function aiImportedPageCheck(input: Pick<AiLayoutPageCheckInput, 'screen' | 'sectionIds' | 'targets' | 'context' | 'motion' | 'design'> & {
402
419
  doc: AiSiteImportDocument;
403
420
  language?: string;
421
+ rewritten?: readonly string[];
404
422
  }): (answer: Record<string, unknown> | null) => {
405
423
  value: AiLayoutPageBuilt | null;
406
424
  violations: AiDoctrineViolation[];
@@ -412,3 +430,23 @@ export declare const AI_LAYOUT_DESIGN_KIND = "layout-page";
412
430
  * group, with room to think, inside a page's ceiling on the balanced tier.
413
431
  */
414
432
  export declare const AI_LAYOUT_DESIGN_MAX_TOKENS = 3000;
433
+ /**
434
+ * The most a wording answer asks for (AGL-4152), whatever the page and the
435
+ * model: the rewrite of a long page's every line, with its thinking.
436
+ */
437
+ export declare const AI_SITE_IMPORT_WORDING_MOST_TOKENS = 8000;
438
+ /** The least a wording answer asks for: a short page's rewrites, and room to think before them. */
439
+ export declare const AI_SITE_IMPORT_WORDING_LEAST_TOKENS = 1500;
440
+ /**
441
+ * The ceiling a page's wording answer is asked at on this model (AGL-4152):
442
+ * what the time the page step registers leaves once its design answer's
443
+ * worst case is spent, so both answers and their re-asks fit one pass. The
444
+ * wording answer is offered no lookup of the site.
445
+ */
446
+ export declare function aiSiteImportWordingMaxTokens(model: string): number;
447
+ /**
448
+ * Whether a page brought in is asked to improve its wording (AGL-4152, G1):
449
+ * a main page Aglyn AI arranges, its wave under Improve it with Also improve
450
+ * my wording on, and never a policy page, by its address or its title.
451
+ */
452
+ export declare function aiImportedPageRewords(doc: Pick<AiSiteImportDocument, 'build' | 'finish' | 'wording' | 'title' | 'url'>, screen: Pick<AiBuildPlanScreen, 'slug' | 'title'>): boolean;
@@ -39,7 +39,10 @@ import { aiLayoutIsHomeSlug, aiLayoutSiteAliases, aiLayoutSitePages } from "./ai
39
39
  import { aiLayoutInventedContactViolations } from "./ai-layout-site-facts.js";
40
40
  import { aiSiteContactOf } from "../model/ai-site-details.js";
41
41
  import { aiSiteImportDocumentOf } from "./ai-site-import-document.js";
42
- import { AI_SITE_IMPORT_DESIGN_MAX_CHARS, aiCompileImportedPage, aiSiteImportDesignText, aiSiteImportSectionNames } from "./ai-site-import-compile.js";
42
+ import { AI_SITE_IMPORT_DESIGN_MAX_CHARS, aiCompileImportedPage, aiSiteImportDesignText, aiSiteImportFinishOf, aiSiteImportSectionNames } from "./ai-site-import-compile.js";
43
+ import { aiSiteImportPageIsLegal } from "../model/ai-site-import.js";
44
+ import { aiGenerationMaxTokensWithin, aiGenerationWorstCaseMs } from "./ai-job-budget.js";
45
+ import { AI_SITE_IMPORT_WORDING_INSTRUCTIONS, AI_SITE_IMPORT_WORDING_KIND, AI_SITE_IMPORT_WORDING_TOOL, aiSiteImportWordingCheck, aiSiteImportWordingPage, aiSiteImportWordingPrompt, aiSiteImportWordingTokens } from "./ai-site-import-wording.js";
43
46
  /**
44
47
  * A page built in the compact layout language (AGL-3660): the page step's
45
48
  * pass for a site's page units — a guided start's and a build's — in place of
@@ -888,11 +891,19 @@ export const AI_JOB_PAGE_LANGUAGE_BUDGET = aiJobStepBudget({
888
891
  text: UNTRUSTED_TEXT_RULE
889
892
  }
890
893
  ];
894
+ /**
895
+ * The line a design answer is told when the owner asked the site improved
896
+ * (AGL-4152), in its user turn alone: the cached instructions and the tool are
897
+ * the same either way, and a page kept as it is is asked exactly as before.
898
+ */ export const AI_LAYOUT_DESIGN_IMPROVE_LINE = "The owner asked for a better design: choose the hero, bands, alignment and styles that read best for this kind of site; the source's own are not required.";
891
899
  /** A design answer's user turn: the page, the kind of site it is, and its structure, the sections' names fenced. */ export function aiLayoutDesignPrompt(input) {
892
900
  const count = aiSiteImportSectionNames(input.doc).length;
893
901
  return [
894
902
  `Page: "${input.screen.title}" at ${input.screen.slug}`,
895
903
  ...aiSiteKindDesignLines(input.job.inputs),
904
+ ...aiSiteImportFinishOf(input.doc) === 'improve' ? [
905
+ AI_LAYOUT_DESIGN_IMPROVE_LINE
906
+ ] : [],
896
907
  `Its ${count === 1 ? 'one section' : `${count} sections`}, each with what it shows:`,
897
908
  fenceUntrustedText(`The structure of the owner's page ${input.doc.url}`, aiSiteImportDesignText(input.doc), {
898
909
  maxChars: AI_SITE_IMPORT_DESIGN_MAX_CHARS
@@ -913,11 +924,18 @@ export const AI_JOB_PAGE_LANGUAGE_BUDGET = aiJobStepBudget({
913
924
  * answer where one is given — stored, and checked whole as a page of its
914
925
  * owner's own words. An answer whose design cannot be drawn is set aside and
915
926
  * the page is drawn as its source lays it out, so no answer is asked again
916
- * for what code decides. Nothing in an answer can change a word.
927
+ * for what code decides. Nothing in a design answer can change a word.
928
+ *
929
+ * `rewritten` names the lines a wording answer reworded (AGL-4152), whose
930
+ * words the document already carries: rule 14's copy checks judge them as
931
+ * the copy a generator wrote that they are.
917
932
  */ export function aiImportedPageCheck(input) {
933
+ var _input_rewritten;
918
934
  const context = _extends({}, aiLayoutListingContext(input.context, input.targets), {
919
935
  ownWords: true
920
- });
936
+ }, ((_input_rewritten = input.rewritten) == null ? void 0 : _input_rewritten.length) ? {
937
+ rewritten: input.rewritten
938
+ } : {});
921
939
  const plan = {
922
940
  title: input.screen.title,
923
941
  sections: input.screen.sections.map((section)=>({
@@ -934,7 +952,9 @@ export const AI_JOB_PAGE_LANGUAGE_BUDGET = aiJobStepBudget({
934
952
  plan,
935
953
  targets: input.targets,
936
954
  design: importedDesign(input.design, input.screen),
937
- answer: design
955
+ answer: design,
956
+ // Kept as it is or improved, as the page's wave was asked (AGL-4152).
957
+ finish: aiSiteImportFinishOf(input.doc)
938
958
  }, input.language ? {
939
959
  language: input.language
940
960
  } : {}));
@@ -1020,15 +1040,60 @@ const NO_USAGE = {
1020
1040
  cacheReadTokens: 0,
1021
1041
  cacheWriteTokens: 0
1022
1042
  };
1043
+ /**
1044
+ * The most a wording answer asks for (AGL-4152), whatever the page and the
1045
+ * model: the rewrite of a long page's every line, with its thinking.
1046
+ */ export const AI_SITE_IMPORT_WORDING_MOST_TOKENS = 8000;
1047
+ /** The least a wording answer asks for: a short page's rewrites, and room to think before them. */ export const AI_SITE_IMPORT_WORDING_LEAST_TOKENS = 1500;
1048
+ /**
1049
+ * The ceiling a page's wording answer is asked at on this model (AGL-4152):
1050
+ * what the time the page step registers leaves once its design answer's
1051
+ * worst case is spent, so both answers and their re-asks fit one pass. The
1052
+ * wording answer is offered no lookup of the site.
1053
+ */ export function aiSiteImportWordingMaxTokens(model) {
1054
+ const design = aiGenerationWorstCaseMs({
1055
+ model,
1056
+ maxTokens: Math.min(AI_LAYOUT_DESIGN_MAX_TOKENS, AI_JOB_PAGE_LANGUAGE_BUDGET.maxTokens(model))
1057
+ });
1058
+ return aiGenerationMaxTokensWithin({
1059
+ model,
1060
+ budgetMs: AI_JOB_PAGE_LANGUAGE_BUDGET.minimumMs - design,
1061
+ cap: AI_SITE_IMPORT_WORDING_MOST_TOKENS,
1062
+ lookups: 0
1063
+ });
1064
+ }
1065
+ /**
1066
+ * Whether a page brought in is asked to improve its wording (AGL-4152, G1):
1067
+ * a main page Aglyn AI arranges, its wave under Improve it with Also improve
1068
+ * my wording on, and never a policy page, by its address or its title.
1069
+ */ export function aiImportedPageRewords(doc, screen) {
1070
+ if (doc.build !== 'arranged' || aiSiteImportFinishOf(doc) !== 'improve' || doc.wording !== 'improved') return false;
1071
+ let path = '';
1072
+ try {
1073
+ path = new URL(doc.url).pathname;
1074
+ } catch (unused) {
1075
+ // No address: its slug and title say whether it is a policy.
1076
+ }
1077
+ return !aiSiteImportPageIsLegal({
1078
+ slug: screen.slug,
1079
+ title: [
1080
+ screen.title,
1081
+ doc.title
1082
+ ].join(' '),
1083
+ path
1084
+ });
1085
+ }
1023
1086
  /**
1024
1087
  * A page brought in (AGL-4084, AGL-4107). Its layout is compiled first with
1025
1088
  * no model: a page of a collection is that page, nothing spent; a page that
1026
1089
  * cannot be built so is reviewed before anything is spent on it. A main page
1027
1090
  * then asks one design answer on the page step's balanced tier and is drawn
1028
- * with it, every word still the source's.
1091
+ * with it, every word still the source's. Under Also improve my wording
1092
+ * (AGL-4152) a main page then asks its wording too, drawn in the design its
1093
+ * first answer chose (`aiRunImportedPageWording`).
1029
1094
  */ async function aiRunImportedPage(input, doc) {
1030
1095
  var _input_observe;
1031
- const check = aiImportedPageCheck(_extends({
1096
+ const checkInput = _extends({
1032
1097
  screen: input.screen,
1033
1098
  sectionIds: input.sectionIds,
1034
1099
  targets: input.targets,
@@ -1037,7 +1102,8 @@ const NO_USAGE = {
1037
1102
  motion: aiLayoutMotionSiteOf(input.job, input.screen.slug)
1038
1103
  }, input.plan.language ? {
1039
1104
  language: input.plan.language
1040
- } : {}, {
1105
+ } : {});
1106
+ const check = aiImportedPageCheck(_extends({}, checkInput, {
1041
1107
  doc
1042
1108
  }));
1043
1109
  const spend = {
@@ -1062,7 +1128,11 @@ const NO_USAGE = {
1062
1128
  value: plain.value
1063
1129
  });
1064
1130
  const observe = (_input_observe = input.observe) != null ? _input_observe : (inner)=>inner;
1065
- return runValidatedGeneration(AI_LAYOUT_DESIGN_KIND, _extends({
1131
+ // The design answer the page was drawn with, which its reworded page is drawn with too.
1132
+ const drawn = {
1133
+ answer: null
1134
+ };
1135
+ const designed = await runValidatedGeneration(AI_LAYOUT_DESIGN_KIND, _extends({
1066
1136
  step: 'job.page',
1067
1137
  model: input.model,
1068
1138
  instructions: AI_JOB_PAGE_DESIGN_INSTRUCTIONS,
@@ -1085,10 +1155,119 @@ const NO_USAGE = {
1085
1155
  smaller: 'Answer with the choices alone.'
1086
1156
  }
1087
1157
  }, AI_LAYOUT_LANGUAGE_THINKING, {
1088
- check: observe((answer)=>check(answer))
1158
+ check: observe((answer)=>{
1159
+ const result = check(answer);
1160
+ if (result.value) drawn.answer = answer;
1161
+ return result;
1162
+ })
1163
+ }, input.signal ? {
1164
+ signal: input.signal
1165
+ } : {}));
1166
+ if (designed.status !== 'ok' || !aiImportedPageRewords(doc, input.screen)) return designed;
1167
+ return aiRunImportedPageWording({
1168
+ input,
1169
+ doc,
1170
+ designed,
1171
+ build: (reworded, rewritten)=>aiImportedPageCheck(_extends({}, checkInput, {
1172
+ doc: reworded,
1173
+ rewritten
1174
+ }))(drawn.answer)
1175
+ });
1176
+ }
1177
+ /**
1178
+ * A page's wording improved (AGL-4152, G1–G3): one `submit_wording` answer
1179
+ * on the page step's own tier, after its design, over the page's lines. Each
1180
+ * rewrite is held to its line's facts (`aiSiteImportWordingHolds`); a line
1181
+ * refused is asked again once, and refused again keeps its words, noted on
1182
+ * the page. The page is built whole in its rewrites and checked as any page
1183
+ * brought in, rule 14's copy checks on for the reworded lines. A rewrite
1184
+ * that fails as a whole, or an answer refused or cut off, leaves the page as
1185
+ * its design drew it, every word the source's, and it reads as kept.
1186
+ *
1187
+ * It spends inside the page's second pass of `AI_SITE_IMPORT_PAGE_CEILING_CREDITS`,
1188
+ * and is priced as an AI page (`AI_MEASURED_IMPORT_CREDITS.page`).
1189
+ */ async function aiRunImportedPageWording(scope) {
1190
+ var _input_context_framing;
1191
+ var _input_job_inputs;
1192
+ const { input, doc, designed } = scope;
1193
+ const kept = _extends({}, designed, {
1194
+ value: _extends({}, designed.value, {
1195
+ words: 'kept'
1196
+ })
1197
+ });
1198
+ const ceiling = aiSiteImportWordingMaxTokens(input.model);
1199
+ const page = aiSiteImportWordingPage(doc, {
1200
+ maxTokens: ceiling
1201
+ });
1202
+ if (!page.lines.length) return kept;
1203
+ const named = (_input_job_inputs = input.job.inputs) == null ? void 0 : _input_job_inputs['businessName'];
1204
+ const siteName = typeof named === 'string' ? named : null;
1205
+ const worded = await runValidatedGeneration(AI_SITE_IMPORT_WORDING_KIND, _extends({
1206
+ step: 'job.page',
1207
+ model: input.model,
1208
+ instructions: AI_SITE_IMPORT_WORDING_INSTRUCTIONS,
1209
+ messages: [
1210
+ {
1211
+ role: 'user',
1212
+ content: aiSiteImportWordingPrompt({
1213
+ screen: input.screen,
1214
+ doc,
1215
+ page,
1216
+ siteName
1217
+ })
1218
+ }
1219
+ ],
1220
+ tool: AI_SITE_IMPORT_WORDING_TOOL,
1221
+ maxTokens: Math.min(ceiling, Math.max(AI_SITE_IMPORT_WORDING_LEAST_TOKENS, aiSiteImportWordingTokens(page))),
1222
+ cutOff: {
1223
+ noun: 'wording',
1224
+ smaller: 'Reword fewer lines, and leave out every line that already reads well.'
1225
+ }
1226
+ }, AI_LAYOUT_LANGUAGE_THINKING, {
1227
+ check: aiSiteImportWordingCheck({
1228
+ doc,
1229
+ page,
1230
+ siteName,
1231
+ framing: (_input_context_framing = input.context.framing) != null ? _input_context_framing : null,
1232
+ build: scope.build
1233
+ })
1089
1234
  }, input.signal ? {
1090
1235
  signal: input.signal
1091
1236
  } : {}));
1237
+ const spent = spentTogether(designed, worded);
1238
+ if (worded.status !== 'ok') {
1239
+ // Logged by its codes alone: the rewrite's words are the site's content.
1240
+ console.info('ai imported page: its wording kept as written', {
1241
+ status: worded.status,
1242
+ codes: worded.status === 'needs_input' ? [
1243
+ ...new Set(worded.violations.map((violation)=>violation.code))
1244
+ ] : []
1245
+ });
1246
+ return _extends({}, kept, spent);
1247
+ }
1248
+ const { built, rewrites, kept: refused } = worded.value;
1249
+ const notes = refused.map((refusal)=>({
1250
+ at: `line ${refusal.line}`,
1251
+ what: `kept as written, refused twice: ${refusal.code}`
1252
+ }));
1253
+ if (!rewrites.size) return _extends({}, kept, spent, {
1254
+ value: _extends({}, kept.value, {
1255
+ settled: [
1256
+ ...kept.value.settled,
1257
+ ...notes
1258
+ ]
1259
+ })
1260
+ });
1261
+ return _extends({}, spent, {
1262
+ status: 'ok',
1263
+ value: _extends({}, built, {
1264
+ settled: [
1265
+ ...built.settled,
1266
+ ...notes
1267
+ ],
1268
+ words: 'improved'
1269
+ })
1270
+ });
1092
1271
  }
1093
1272
 
1094
1273
  //# sourceMappingURL=ai-job-page-language.js.map