@aglyn/plugins-ai 1.15.0 → 1.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/src/lib/components/ai-site-import-start.component.js +3 -1
- package/src/lib/components/ai-site-import-start.component.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +18 -2
- package/src/lib/jobs/ai-job-import-step.js +24 -8
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-page-language.d.ts +2 -0
- package/src/lib/jobs/ai-job-page-language.js +72 -37
- package/src/lib/jobs/ai-job-page-language.js.map +1 -1
- package/src/lib/jobs/ai-job-page-step.js +5 -3
- package/src/lib/jobs/ai-job-page-step.js.map +1 -1
- package/src/lib/jobs/ai-job-text-step.d.ts +1 -0
- package/src/lib/jobs/ai-job-text-step.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.js +26 -1
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-improve.d.ts +59 -6
- package/src/lib/jobs/ai-site-import-improve.js +149 -19
- package/src/lib/jobs/ai-site-import-improve.js.map +1 -1
- package/src/lib/jobs/ai-site-import-plan.js +1 -1
- package/src/lib/jobs/ai-site-import-plan.js.map +1 -1
- package/src/lib/model/ai-credit-estimate.d.ts +16 -0
- package/src/lib/model/ai-credit-estimate.js +14 -0
- package/src/lib/model/ai-credit-estimate.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +2 -0
- package/src/lib/model/ai-site-import-fidelity.js +7 -1
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-view.d.ts +3 -1
- package/src/lib/model/ai-site-import-view.js +8 -3
- package/src/lib/model/ai-site-import-view.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +27 -2
- package/src/lib/model/ai-site-import.js +63 -14
- package/src/lib/model/ai-site-import.js.map +1 -1
|
@@ -284,6 +284,8 @@ export interface AiLayoutPageBuilt {
|
|
|
284
284
|
added: AiSiteImportAddedSection[];
|
|
285
285
|
pictures: AiSiteImportPagePictures | null;
|
|
286
286
|
names?: string[];
|
|
287
|
+
/** Why its layout was kept, or the design lines a redesign was taken missing, by internal code (AGL-4152): the row keeps them, the owner never reads them. */
|
|
288
|
+
missed?: string[];
|
|
287
289
|
};
|
|
288
290
|
}
|
|
289
291
|
export interface AiLayoutPageCheckInput {
|
|
@@ -45,7 +45,7 @@ import { AI_SITE_IMPORT_DESIGN_MAX_CHARS, aiCompileImportedPage, aiSiteImportDes
|
|
|
45
45
|
import { aiSiteImportPageIsLegal, AI_SITE_IMPORT_LAYOUT_KEPT, AI_SITE_IMPORT_PROPOSED_NOT_WRITTEN } from "../model/ai-site-import.js";
|
|
46
46
|
import { siteImportFidelity } from "../model/ai-site-import-fidelity.js";
|
|
47
47
|
import { aiGenerationMaxTokensWithin, aiGenerationWorstCaseMs } from "./ai-job-budget.js";
|
|
48
|
-
import { AI_SITE_IMPORT_IMPROVE_KIND, AI_SITE_IMPORT_IMPROVE_MOST_TOKENS, AI_SITE_IMPORT_IMPROVE_TOOL, aiSiteImportImproveCheck, aiSiteImportImproveDestinations, aiSiteImportImproveDigest, aiSiteImportImproveInstructions, aiSiteImportImproveLedger, aiSiteImportImprovePrompt, aiSiteImportImproveScope, aiSiteImportImprovedMisses, aiSiteImportImproveInputUsage, aiSiteImportImproveReaskTokens, aiSiteImportImproveRoleLines, aiSiteImportImproveTokensWithin, aiSiteImportNewSectionsWanted, aiSiteImportPageRoleOf } from "./ai-site-import-improve.js";
|
|
48
|
+
import { AI_SITE_IMPORT_IMPROVE_KIND, AI_SITE_IMPORT_IMPROVE_MOST_TOKENS, AI_SITE_IMPORT_IMPROVE_TOOL, aiSiteImportImproveCheck, aiSiteImportImproveDestinations, aiSiteImportImproveDigest, aiSiteImportImproveInstructions, aiSiteImportImproveLedger, aiSiteImportImprovePrompt, aiSiteImportImproveScope, aiSiteImportImprovedMisses, aiSiteImportImproveInputUsage, aiSiteImportImproveReaskTokens, aiSiteImportImproveRoleLines, aiSiteImportImproveTokensWithin, aiSiteImportImproveOnlySoft, aiSiteImportNewSectionsWanted, aiSiteImportPageRoleOf } from "./ai-site-import-improve.js";
|
|
49
49
|
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";
|
|
50
50
|
/**
|
|
51
51
|
* A page built in the compact layout language (AGL-3660): the page step's
|
|
@@ -1308,8 +1308,8 @@ const NO_USAGE = {
|
|
|
1308
1308
|
* cut off leaves the page as today's compile draws it, every word the source's,
|
|
1309
1309
|
* and its row says the layout was kept.
|
|
1310
1310
|
*/ async function aiRunImprovedPage(scope) {
|
|
1311
|
-
var _doc_theme, _input_observe, _doc_siteLines, _doc_plan, _ref
|
|
1312
|
-
var _input_job_inputs,
|
|
1311
|
+
var _doc_theme, _input_observe, _doc_siteLines, _doc_plan, _ref;
|
|
1312
|
+
var _input_job_inputs, _doc_plan1;
|
|
1313
1313
|
const { input, doc, checkInput, plain, spend } = scope;
|
|
1314
1314
|
const ledger = aiSiteImportImproveLedger(doc);
|
|
1315
1315
|
const named = (_input_job_inputs = input.job.inputs) == null ? void 0 : _input_job_inputs['businessName'];
|
|
@@ -1344,7 +1344,7 @@ const NO_USAGE = {
|
|
|
1344
1344
|
seed: input.job.$id.slice(-6),
|
|
1345
1345
|
roleLines: aiSiteImportImproveRoleLines(_extends({}, needs, {
|
|
1346
1346
|
folded: ledger.folded,
|
|
1347
|
-
kind: (_ref = (
|
|
1347
|
+
kind: (_ref = (_doc_plan1 = doc.plan) == null ? void 0 : _doc_plan1.site.kind) != null ? _ref : null,
|
|
1348
1348
|
seed: aiSiteSeed(input.job.$id)
|
|
1349
1349
|
}))
|
|
1350
1350
|
});
|
|
@@ -1359,40 +1359,22 @@ const NO_USAGE = {
|
|
|
1359
1359
|
}),
|
|
1360
1360
|
most
|
|
1361
1361
|
});
|
|
1362
|
-
const
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
messages: [
|
|
1367
|
-
{
|
|
1368
|
-
role: 'user',
|
|
1369
|
-
content: prompt
|
|
1370
|
-
}
|
|
1371
|
-
],
|
|
1372
|
-
tool: AI_SITE_IMPORT_IMPROVE_TOOL,
|
|
1373
|
-
maxTokens: Math.max(1, first),
|
|
1374
|
-
// Nothing is spent before it: a page brought in is compiled with no model first.
|
|
1375
|
-
reaskTokens: (spent, last)=>aiSiteImportImproveReaskTokens({
|
|
1376
|
-
model: input.model,
|
|
1377
|
-
spent,
|
|
1378
|
-
lastOutput: last.outputTokens,
|
|
1379
|
-
most
|
|
1380
|
-
}),
|
|
1381
|
-
cutOff: {
|
|
1382
|
-
noun: 'page',
|
|
1383
|
-
smaller: 'Write shorter copy, and fewer sections.'
|
|
1384
|
-
}
|
|
1385
|
-
}, AI_LAYOUT_LANGUAGE_THINKING, {
|
|
1386
|
-
check: observe(aiSiteImportImproveCheck({
|
|
1362
|
+
const checkOf = (lenient)=>{
|
|
1363
|
+
var _ref, _input_context_framing, _doc_plan;
|
|
1364
|
+
var _input_targets_forms_;
|
|
1365
|
+
return aiSiteImportImproveCheck(_extends({
|
|
1387
1366
|
doc,
|
|
1388
1367
|
ledger,
|
|
1389
1368
|
design,
|
|
1390
1369
|
scope: facts,
|
|
1391
|
-
formId: input.targets.forms.length === 1 ? (
|
|
1370
|
+
formId: input.targets.forms.length === 1 ? (_ref = (_input_targets_forms_ = input.targets.forms[0]) == null ? void 0 : _input_targets_forms_.id) != null ? _ref : null : null,
|
|
1392
1371
|
framing: (_input_context_framing = input.context.framing) != null ? _input_context_framing : null,
|
|
1393
|
-
plan: (
|
|
1372
|
+
plan: (_doc_plan = doc.plan) != null ? _doc_plan : null,
|
|
1394
1373
|
theme,
|
|
1395
|
-
needs
|
|
1374
|
+
needs
|
|
1375
|
+
}, lenient ? {
|
|
1376
|
+
lenient: true
|
|
1377
|
+
} : {}, {
|
|
1396
1378
|
build: (page)=>aiImportedPageCheck(_extends({}, checkInput, {
|
|
1397
1379
|
doc,
|
|
1398
1380
|
given: page.given,
|
|
@@ -1428,18 +1410,69 @@ const NO_USAGE = {
|
|
|
1428
1410
|
});
|
|
1429
1411
|
return aiSiteImportImprovedMisses(report);
|
|
1430
1412
|
}
|
|
1431
|
-
}))
|
|
1413
|
+
}));
|
|
1414
|
+
};
|
|
1415
|
+
const answered = await runValidatedGeneration(AI_SITE_IMPORT_IMPROVE_KIND, _extends({
|
|
1416
|
+
step: 'job.page',
|
|
1417
|
+
model: input.model,
|
|
1418
|
+
instructions,
|
|
1419
|
+
messages: [
|
|
1420
|
+
{
|
|
1421
|
+
role: 'user',
|
|
1422
|
+
content: prompt
|
|
1423
|
+
}
|
|
1424
|
+
],
|
|
1425
|
+
tool: AI_SITE_IMPORT_IMPROVE_TOOL,
|
|
1426
|
+
maxTokens: Math.max(1, first),
|
|
1427
|
+
// Nothing is spent before it: a page brought in is compiled with no model first.
|
|
1428
|
+
reaskTokens: (spent, last)=>aiSiteImportImproveReaskTokens({
|
|
1429
|
+
model: input.model,
|
|
1430
|
+
spent,
|
|
1431
|
+
lastOutput: last.outputTokens,
|
|
1432
|
+
most
|
|
1433
|
+
}),
|
|
1434
|
+
cutOff: {
|
|
1435
|
+
noun: 'page',
|
|
1436
|
+
smaller: 'Write shorter copy, and fewer sections.'
|
|
1437
|
+
}
|
|
1438
|
+
}, AI_LAYOUT_LANGUAGE_THINKING, {
|
|
1439
|
+
check: observe(checkOf(false))
|
|
1432
1440
|
}, input.signal ? {
|
|
1433
1441
|
signal: input.signal
|
|
1434
1442
|
} : {}));
|
|
1435
1443
|
const spent = spentTogether(spend, answered);
|
|
1444
|
+
// Its last answer, where no re-ask was left and it missed only how it is planned or drawn: taken, its misses on its row (AGL-4152).
|
|
1445
|
+
const taken = answered.status === 'needs_input' && answered.answer && aiSiteImportImproveOnlySoft(answered.violations) ? checkOf(true)(answered.answer) : null;
|
|
1446
|
+
if (taken == null ? void 0 : taken.value) {
|
|
1447
|
+
const { built, page, missed } = taken.value;
|
|
1448
|
+
console.info('ai imported page: its redesign taken with design lines missed', {
|
|
1449
|
+
codes: missed != null ? missed : []
|
|
1450
|
+
});
|
|
1451
|
+
return _extends({}, spent, {
|
|
1452
|
+
status: 'ok',
|
|
1453
|
+
value: _extends({}, built, {
|
|
1454
|
+
words: 'improved',
|
|
1455
|
+
redesign: _extends({
|
|
1456
|
+
status: 'redesigned',
|
|
1457
|
+
added: page.added,
|
|
1458
|
+
pictures: page.pictures,
|
|
1459
|
+
names: page.names
|
|
1460
|
+
}, (missed == null ? void 0 : missed.length) ? {
|
|
1461
|
+
missed
|
|
1462
|
+
} : {})
|
|
1463
|
+
})
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1436
1466
|
if (answered.status !== 'ok') {
|
|
1467
|
+
const codes = answered.status === 'needs_input' ? [
|
|
1468
|
+
...new Set(answered.violations.map((violation)=>violation.code))
|
|
1469
|
+
] : [
|
|
1470
|
+
answered.status
|
|
1471
|
+
];
|
|
1437
1472
|
// Logged by its codes alone: an answer's words are the site's content.
|
|
1438
1473
|
console.info('ai imported page: its redesign did not pass, its layout kept', {
|
|
1439
1474
|
status: answered.status,
|
|
1440
|
-
codes
|
|
1441
|
-
...new Set(answered.violations.map((violation)=>violation.code))
|
|
1442
|
-
] : []
|
|
1475
|
+
codes
|
|
1443
1476
|
});
|
|
1444
1477
|
// A new page has no words of its own to fall back on: it is left out, and its row says why.
|
|
1445
1478
|
if (doc.proposed) return _extends({}, spent, {
|
|
@@ -1459,10 +1492,12 @@ const NO_USAGE = {
|
|
|
1459
1492
|
}
|
|
1460
1493
|
],
|
|
1461
1494
|
words: 'kept',
|
|
1495
|
+
// Why, by internal code, for the job's row and the report (AGL-4152): never shown to the owner as it is.
|
|
1462
1496
|
redesign: {
|
|
1463
1497
|
status: 'layout-kept',
|
|
1464
1498
|
added: [],
|
|
1465
|
-
pictures: null
|
|
1499
|
+
pictures: null,
|
|
1500
|
+
missed: codes
|
|
1466
1501
|
}
|
|
1467
1502
|
})
|
|
1468
1503
|
});
|