@aglyn/plugins-ai 1.16.0 → 1.18.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.
- package/package.json +17 -17
- package/src/lib/jobs/ai-job-import-step.js +7 -4
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-page-step.js +7 -4
- package/src/lib/jobs/ai-job-page-step.js.map +1 -1
- package/src/lib/jobs/ai-layout-stock-photos.d.ts +9 -0
- package/src/lib/jobs/ai-layout-stock-photos.js +4 -0
- package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
- package/src/lib/jobs/ai-site-import-actions.d.ts +35 -0
- package/src/lib/jobs/ai-site-import-actions.js +215 -0
- package/src/lib/jobs/ai-site-import-actions.js.map +1 -0
- package/src/lib/jobs/ai-site-import-compile.d.ts +7 -0
- package/src/lib/jobs/ai-site-import-compile.js +34 -4
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-improve.d.ts +13 -1
- package/src/lib/jobs/ai-site-import-improve.js +153 -12
- package/src/lib/jobs/ai-site-import-improve.js.map +1 -1
- package/src/lib/jobs/ai-site-import-pictures.js +4 -2
- package/src/lib/jobs/ai-site-import-pictures.js.map +1 -1
- package/src/lib/jobs/ai-site-import-plan.d.ts +67 -1
- package/src/lib/jobs/ai-site-import-plan.js +173 -4
- package/src/lib/jobs/ai-site-import-plan.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.js +13 -15
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +6 -0
- package/src/lib/model/ai-site-import-fidelity.js +88 -10
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-ledger.js +10 -2
- package/src/lib/model/ai-site-import-ledger.js.map +1 -1
- package/src/lib/model/ai-site-import-marks.d.ts +37 -0
- package/src/lib/model/ai-site-import-marks.js +53 -0
- package/src/lib/model/ai-site-import-marks.js.map +1 -0
- package/src/lib/model/ai-site-import.d.ts +11 -1
- package/src/lib/model/ai-site-import.js +14 -2
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/runtime/ai-node-tree.js +8 -0
- package/src/lib/runtime/ai-node-tree.js.map +1 -1
- package/src/lib/site-import/site-import-images.js +9 -6
- package/src/lib/site-import/site-import-images.js.map +1 -1
|
@@ -205,8 +205,20 @@ export interface AiSiteImportImprovedPage {
|
|
|
205
205
|
added: AiSiteImportAddedSection[];
|
|
206
206
|
pictures: AiSiteImportPagePictures;
|
|
207
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* The opening of a redesign without a brand's mark for its photo (AGL-4152):
|
|
210
|
+
* a picture the source names a logo, a badge or an icon (`aiSiteImportIsBrandMark`)
|
|
211
|
+
* that the answer keeps in its first section takes the page's widest photo no
|
|
212
|
+
* section placed instead, or, where it has none, is left out, and a row it
|
|
213
|
+
* leaves a column empty in is drawn as one column. A client's logo the source
|
|
214
|
+
* showed beside its words read, as a cover, as the page's own work.
|
|
215
|
+
*/
|
|
216
|
+
export declare function aiSiteImportOpeningPhoto(answer: readonly AiSiteImportImprovedSection[], input: {
|
|
217
|
+
doc: Pick<AiSiteImportDocument, 'blocks' | 'photos'>;
|
|
218
|
+
ledger: Pick<SiteImportLedger, 'items'>;
|
|
219
|
+
}): AiSiteImportImprovedSection[];
|
|
208
220
|
/** The sections a redesign holds, in the compiler's language: every `keep` expanded to the source's own blocks, every link resolved. */
|
|
209
|
-
export declare function aiSiteImportImprovedPage(
|
|
221
|
+
export declare function aiSiteImportImprovedPage(given: readonly AiSiteImportImprovedSection[], input: AiSiteImportImproveCompileInput): AiSiteImportImprovedPage;
|
|
210
222
|
/** The most an answer may ask for, whatever the page and the model: a whole page's design and words, with its thinking. */
|
|
211
223
|
export declare const AI_SITE_IMPORT_IMPROVE_MOST_TOKENS = 8000;
|
|
212
224
|
/**
|
|
@@ -43,12 +43,14 @@ import { AI_LAYOUT_ALIGNS, AI_LAYOUT_BANDS, AI_LAYOUT_MAX_COLS, AI_LAYOUT_STYLES
|
|
|
43
43
|
import { AI_ICON_WORDS } from "../runtime/ai-icon-library.js";
|
|
44
44
|
import { aiSiteHomeArc } from "../model/ai-site-home-arcs.js";
|
|
45
45
|
import { SITE_IMPORT_IMPROVED_MEANING, SITE_IMPORT_MEANING_FLOOR, siteImportContentKept, siteImportContentWords } from "../model/ai-site-import-fidelity.js";
|
|
46
|
+
import { aiSiteImportIsBrandMark } from "../model/ai-site-import-marks.js";
|
|
46
47
|
import { siteImportLedger } from "../model/ai-site-import-ledger.js";
|
|
47
48
|
import { AI_SITE_IMPORT_PAGE_CEILING_CREDITS } from "../model/ai-site-import.js";
|
|
48
49
|
import { estimateAiBilledUsd } from "../providers/catalog.js";
|
|
49
50
|
import { assistCreditsFromUsd } from "../usage/assist-credits.js";
|
|
50
51
|
import { siteImportLabel } from "../site-import/site-import-page.js";
|
|
51
52
|
import { aiSiteImportHonesty, aiSiteImportImprovedPlaced } from "./ai-site-import-honesty.js";
|
|
53
|
+
import { aiSiteImportSectionActions } from "./ai-site-import-actions.js";
|
|
52
54
|
import { aiSiteImportLayoutOf, aiSiteImportLinkTo, aiSiteImportMapScope, aiSiteImportNodeBlocks, aiSiteImportTakePicture } from "./ai-site-import-compile.js";
|
|
53
55
|
import { aiSiteImportTextParts } from "./ai-site-import-document.js";
|
|
54
56
|
const clean = (text)=>typeof text === 'string' ? text.replace(/\s+/g, ' ').trim() : '';
|
|
@@ -731,6 +733,11 @@ const short = (text, most = 80)=>text.length > most ? `${text.slice(0, most - 1)
|
|
|
731
733
|
'column',
|
|
732
734
|
'editorial'
|
|
733
735
|
]);
|
|
736
|
+
/** The heroes that lay their photo edge to edge behind the words, which a square or a portrait cannot fill. */ const COVERING_HEROES = new Set([
|
|
737
|
+
'cover',
|
|
738
|
+
'poster',
|
|
739
|
+
'panel'
|
|
740
|
+
]);
|
|
734
741
|
/**
|
|
735
742
|
* The site's hero as a page brought in draws it: a collage or a portrait holds
|
|
736
743
|
* what a page brought in does not. A redesign whose opening holds the page's
|
|
@@ -740,7 +747,10 @@ const short = (text, most = 80)=>text.length > most ? `${text.slice(0, most - 1)
|
|
|
740
747
|
*/ export function aiSiteImportImproveHero(design, plan, opening) {
|
|
741
748
|
var _ref, _ref1;
|
|
742
749
|
const chosen = (_ref = plan == null ? void 0 : plan.design.hero) != null ? _ref : aiLayoutDesignChoices(design).hero;
|
|
743
|
-
|
|
750
|
+
const ratio = (_ref1 = opening == null ? void 0 : opening.ratio) != null ? _ref1 : 0;
|
|
751
|
+
if (BOXED_HEROES.has(chosen) && ratio >= AI_SITE_IMPORT_COVER_LEAST_RATIO) return 'cover';
|
|
752
|
+
// A square or a portrait is never stretched behind the words (AGL-4152): it sits beside them.
|
|
753
|
+
if (COVERING_HEROES.has(chosen) && ratio > 0 && ratio < AI_SITE_IMPORT_COVER_LEAST_RATIO) return 'split';
|
|
744
754
|
return chosen === 'collage' || chosen === 'portrait' ? 'split' : chosen;
|
|
745
755
|
}
|
|
746
756
|
/** How many of a group's items sit across: planned for how much each says. */ export function aiSiteImportImproveColumns(items) {
|
|
@@ -836,8 +846,88 @@ const WORD_KINDS = new Set([
|
|
|
836
846
|
return name;
|
|
837
847
|
});
|
|
838
848
|
}
|
|
839
|
-
/**
|
|
849
|
+
/**
|
|
850
|
+
* The opening of a redesign without a brand's mark for its photo (AGL-4152):
|
|
851
|
+
* a picture the source names a logo, a badge or an icon (`aiSiteImportIsBrandMark`)
|
|
852
|
+
* that the answer keeps in its first section takes the page's widest photo no
|
|
853
|
+
* section placed instead, or, where it has none, is left out, and a row it
|
|
854
|
+
* leaves a column empty in is drawn as one column. A client's logo the source
|
|
855
|
+
* showed beside its words read, as a cover, as the page's own work.
|
|
856
|
+
*/ export function aiSiteImportOpeningPhoto(answer, input) {
|
|
857
|
+
const [first, ...rest] = answer;
|
|
858
|
+
if (!first) return [
|
|
859
|
+
...answer
|
|
860
|
+
];
|
|
861
|
+
const { doc, ledger } = input;
|
|
862
|
+
const items = new Map(ledger.items.map((item)=>[
|
|
863
|
+
item.ref,
|
|
864
|
+
item
|
|
865
|
+
]));
|
|
866
|
+
const imageOf = (ref)=>{
|
|
867
|
+
const item = items.get(ref);
|
|
868
|
+
const block = (item == null ? void 0 : item.kind) === 'picture' ? doc.blocks[item.lines[0]] : undefined;
|
|
869
|
+
return (block == null ? void 0 : block.kind) === 'image' ? block : null;
|
|
870
|
+
};
|
|
871
|
+
const markAt = (ref)=>{
|
|
872
|
+
const image = imageOf(ref);
|
|
873
|
+
return !!image && aiSiteImportIsBrandMark({
|
|
874
|
+
url: image.url,
|
|
875
|
+
alt: image.alt
|
|
876
|
+
});
|
|
877
|
+
};
|
|
878
|
+
const marks = new Set(first.blocks.filter((block)=>block.kind === 'keep' && markAt(block.ref)));
|
|
879
|
+
if (!marks.size) return [
|
|
880
|
+
...answer
|
|
881
|
+
];
|
|
882
|
+
const placed = new Set(aiSiteImportImprovedPlaced(answer, ledger));
|
|
883
|
+
const ratioOf = (ref)=>{
|
|
884
|
+
var _imageOf;
|
|
885
|
+
const url = (_imageOf = imageOf(ref)) == null ? void 0 : _imageOf.url;
|
|
886
|
+
const photo = url ? doc.photos.find((entry)=>entry.from === url) : undefined;
|
|
887
|
+
return (photo == null ? void 0 : photo.width) && photo.height ? photo.width / photo.height : 0;
|
|
888
|
+
};
|
|
889
|
+
const spare = ledger.items.filter((item)=>item.kind === 'picture' && !placed.has(item.ref) && !markAt(item.ref)).sort((a, b)=>ratioOf(b.ref) - ratioOf(a.ref));
|
|
890
|
+
let next = 0;
|
|
891
|
+
const blocks = first.blocks.flatMap((block)=>{
|
|
892
|
+
if (!marks.has(block) || block.kind !== 'keep') return [
|
|
893
|
+
block
|
|
894
|
+
];
|
|
895
|
+
const instead = spare[next++];
|
|
896
|
+
return instead ? [
|
|
897
|
+
_extends({}, block, {
|
|
898
|
+
ref: instead.ref
|
|
899
|
+
})
|
|
900
|
+
] : [];
|
|
901
|
+
});
|
|
902
|
+
// A row with a column left empty is no row.
|
|
903
|
+
const cols = first.cols;
|
|
904
|
+
const emptied = !!cols && cols.some((_, col)=>!blocks.some((block)=>block.col === col));
|
|
905
|
+
const opening = emptied ? _extends({}, first.band ? {
|
|
906
|
+
band: first.band
|
|
907
|
+
} : {}, first.align ? {
|
|
908
|
+
align: first.align
|
|
909
|
+
} : {}, {
|
|
910
|
+
blocks: blocks.map((_0)=>{
|
|
911
|
+
let { col: _col } = _0, block = _object_without_properties_loose(_0, [
|
|
912
|
+
"col"
|
|
913
|
+
]);
|
|
914
|
+
return block;
|
|
915
|
+
})
|
|
916
|
+
}) : _extends({}, first, {
|
|
917
|
+
blocks
|
|
918
|
+
});
|
|
919
|
+
return [
|
|
920
|
+
opening,
|
|
921
|
+
...rest
|
|
922
|
+
];
|
|
923
|
+
}
|
|
924
|
+
/** The sections a redesign holds, in the compiler's language: every `keep` expanded to the source's own blocks, every link resolved. */ export function aiSiteImportImprovedPage(given, input) {
|
|
840
925
|
const { doc, ledger, design, destinations } = input;
|
|
926
|
+
// A brand's mark is never the opening's photo (AGL-4152).
|
|
927
|
+
const answer = aiSiteImportOpeningPhoto(given, {
|
|
928
|
+
doc,
|
|
929
|
+
ledger
|
|
930
|
+
});
|
|
841
931
|
const scope = aiSiteImportMapScope(doc, {
|
|
842
932
|
formId: input.formId,
|
|
843
933
|
finish: 'improve'
|
|
@@ -914,9 +1004,47 @@ const WORD_KINDS = new Set([
|
|
|
914
1004
|
};
|
|
915
1005
|
// The source's pictures a written set of cards stands for, where the answer gave them none (AGL-4152).
|
|
916
1006
|
const carded = aiSiteImportCardPictures(answer, ledger);
|
|
1007
|
+
// The page's own photo an opening that asks for a picture takes (AGL-4152), and which of its things it was.
|
|
1008
|
+
const asked = new Set([
|
|
1009
|
+
...aiSiteImportImprovedPlaced(answer, ledger),
|
|
1010
|
+
...[
|
|
1011
|
+
...carded.values()
|
|
1012
|
+
].flat()
|
|
1013
|
+
]);
|
|
1014
|
+
const ownOpening = {
|
|
1015
|
+
ref: null,
|
|
1016
|
+
taken: false
|
|
1017
|
+
};
|
|
1018
|
+
const openingPicture = ()=>{
|
|
1019
|
+
var _widest, _ref;
|
|
1020
|
+
if (ownOpening.taken) return null;
|
|
1021
|
+
const ratioOf = (line)=>{
|
|
1022
|
+
const image = line === undefined || scope.used.has(line) ? undefined : doc.blocks[line];
|
|
1023
|
+
if ((image == null ? void 0 : image.kind) !== 'image' || aiSiteImportIsBrandMark({
|
|
1024
|
+
url: image.url,
|
|
1025
|
+
alt: image.alt
|
|
1026
|
+
})) return 0;
|
|
1027
|
+
const photo = scope.photos.get(image.url);
|
|
1028
|
+
return (photo == null ? void 0 : photo.width) && photo.height ? photo.width / photo.height : 0;
|
|
1029
|
+
};
|
|
1030
|
+
const widest = (found)=>found.filter((entry)=>ratioOf(entry.line) > 0).sort((a, b)=>ratioOf(b.line) - ratioOf(a.line))[0];
|
|
1031
|
+
// Its photo no section places; else one of a gallery it keeps, which shows the rest.
|
|
1032
|
+
const pick = (_widest = widest(ledger.items.filter((item)=>item.kind === 'picture' && !asked.has(item.ref)).map((item)=>({
|
|
1033
|
+
ref: item.ref,
|
|
1034
|
+
line: item.lines[0]
|
|
1035
|
+
})))) != null ? _widest : widest(ledger.items.filter((item)=>item.kind === 'gallery' && asked.has(item.ref)).flatMap((item)=>item.lines.map((line)=>({
|
|
1036
|
+
ref: null,
|
|
1037
|
+
line
|
|
1038
|
+
}))));
|
|
1039
|
+
const picture = pick ? aiSiteImportTakePicture(scope, pick.line) : null;
|
|
1040
|
+
if (!picture) return null;
|
|
1041
|
+
ownOpening.taken = true;
|
|
1042
|
+
ownOpening.ref = (_ref = pick == null ? void 0 : pick.ref) != null ? _ref : null;
|
|
1043
|
+
return picture;
|
|
1044
|
+
};
|
|
917
1045
|
const sections = answer.map((section, index)=>{
|
|
918
1046
|
var _pictures__picture;
|
|
919
|
-
var _pictures_;
|
|
1047
|
+
var _input_plan_nav_primaryCta, _input_plan, _pictures_;
|
|
920
1048
|
scope.at = `sections[${index}]`;
|
|
921
1049
|
const words = section.blocks.flatMap((block)=>{
|
|
922
1050
|
var _block_text;
|
|
@@ -924,7 +1052,7 @@ const WORD_KINDS = new Set([
|
|
|
924
1052
|
(_block_text = block.text) != null ? _block_text : ''
|
|
925
1053
|
] : [];
|
|
926
1054
|
}).join(' ');
|
|
927
|
-
const
|
|
1055
|
+
const drawn = section.blocks.flatMap((raw)=>{
|
|
928
1056
|
var _block_items;
|
|
929
1057
|
if (raw.kind === 'keep') return keepOf(raw.ref, raw.col);
|
|
930
1058
|
const block = raw;
|
|
@@ -932,11 +1060,17 @@ const WORD_KINDS = new Set([
|
|
|
932
1060
|
col: block.col
|
|
933
1061
|
} : {};
|
|
934
1062
|
if (block.kind === 'image') {
|
|
1063
|
+
var _block_picture;
|
|
935
1064
|
const { col: _col } = block, rest = _object_without_properties_loose(block, [
|
|
936
1065
|
"col"
|
|
937
1066
|
]);
|
|
1067
|
+
// An opening that asks for a picture shows the page's own where it has one (AGL-4152): a slot the
|
|
1068
|
+
// library fills is searched by words alone, and put a stranger's desk on a builder's gallery.
|
|
1069
|
+
const own = index === 0 && !((_block_picture = block.picture) == null ? void 0 : _block_picture.src) ? openingPicture() : null;
|
|
938
1070
|
return [
|
|
939
|
-
_extends({}, rest,
|
|
1071
|
+
_extends({}, rest, own ? {
|
|
1072
|
+
picture: own
|
|
1073
|
+
} : {}, placed)
|
|
940
1074
|
];
|
|
941
1075
|
}
|
|
942
1076
|
if (block.kind === 'text' || block.kind === 'lede' || block.kind === 'note') {
|
|
@@ -1011,6 +1145,12 @@ const WORD_KINDS = new Set([
|
|
|
1011
1145
|
})
|
|
1012
1146
|
];
|
|
1013
1147
|
});
|
|
1148
|
+
// Each call to action once, in its place (AGL-4152).
|
|
1149
|
+
const tidy = aiSiteImportSectionActions({
|
|
1150
|
+
cols: section.cols,
|
|
1151
|
+
blocks: drawn
|
|
1152
|
+
}, (_input_plan = input.plan) == null ? void 0 : (_input_plan_nav_primaryCta = _input_plan.nav.primaryCta) == null ? void 0 : _input_plan_nav_primaryCta.label);
|
|
1153
|
+
const blocks = tidy.blocks;
|
|
1014
1154
|
const pictures = blocks.filter((block)=>block.kind === 'image' || block.kind === 'video');
|
|
1015
1155
|
const opens = index === 0 && pictures.length === 1 && blocks.every((block)=>block.kind === 'image' || block.kind === 'video' || WORD_KINDS.has(block.kind));
|
|
1016
1156
|
const opening = ((_pictures_ = pictures[0]) == null ? void 0 : _pictures_.kind) === 'image' ? (_pictures__picture = pictures[0].picture) != null ? _pictures__picture : null : null;
|
|
@@ -1020,8 +1160,8 @@ const WORD_KINDS = new Set([
|
|
|
1020
1160
|
band
|
|
1021
1161
|
} : {}, section.align ? {
|
|
1022
1162
|
align: section.align
|
|
1023
|
-
} : {},
|
|
1024
|
-
cols:
|
|
1163
|
+
} : {}, tidy.cols && !hero ? {
|
|
1164
|
+
cols: tidy.cols
|
|
1025
1165
|
} : {}, hero ? {
|
|
1026
1166
|
hero,
|
|
1027
1167
|
blocks: blocks.map((block)=>block.kind === 'image' && block.picture ? _extends({}, block, {
|
|
@@ -1047,10 +1187,10 @@ const WORD_KINDS = new Set([
|
|
|
1047
1187
|
} : {});
|
|
1048
1188
|
});
|
|
1049
1189
|
const placed = new Set([
|
|
1050
|
-
...
|
|
1051
|
-
...[
|
|
1052
|
-
|
|
1053
|
-
]
|
|
1190
|
+
...asked,
|
|
1191
|
+
...ownOpening.ref ? [
|
|
1192
|
+
ownOpening.ref
|
|
1193
|
+
] : []
|
|
1054
1194
|
]);
|
|
1055
1195
|
const allPictures = ledger.items.filter((item)=>item.kind === 'picture');
|
|
1056
1196
|
const unplaced = allPictures.filter((item)=>!placed.has(item.ref)).flatMap((item)=>{
|
|
@@ -1070,7 +1210,8 @@ const WORD_KINDS = new Set([
|
|
|
1070
1210
|
written,
|
|
1071
1211
|
added,
|
|
1072
1212
|
pictures: {
|
|
1073
|
-
|
|
1213
|
+
// A gallery's photo the opening shows is the source's too.
|
|
1214
|
+
source: allPictures.length - unplaced.length + (ownOpening.taken && !ownOpening.ref ? 1 : 0),
|
|
1074
1215
|
stock: 0,
|
|
1075
1216
|
generated: 0,
|
|
1076
1217
|
slots: sections.reduce((total, section)=>total + section.blocks.filter((block)=>block.kind === 'image' && !block.picture).length, 0),
|