@aglyn/plugins-ai 1.2.0 → 1.3.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/components/ai-site-import-job.component.js +2 -2
- package/src/lib/components/ai-site-import-job.component.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +35 -2
- package/src/lib/jobs/ai-job-import-step.js +124 -12
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-jobs.d.ts +6 -0
- package/src/lib/jobs/ai-jobs.js +43 -6
- package/src/lib/jobs/ai-jobs.js.map +1 -1
- package/src/lib/jobs/ai-layout-stock-photos.d.ts +13 -6
- package/src/lib/jobs/ai-layout-stock-photos.js +104 -32
- package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.js +110 -23
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-document.d.ts +5 -0
- package/src/lib/jobs/ai-site-import-document.js.map +1 -1
- package/src/lib/jobs/ai-site-import-forms.d.ts +83 -0
- package/src/lib/jobs/ai-site-import-forms.js +376 -0
- package/src/lib/jobs/ai-site-import-forms.js.map +1 -0
- package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.d.ts +21 -0
- package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.js +77 -0
- package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.js.map +1 -0
- package/src/lib/layout-language/ai-layout-compiler.d.ts +2 -0
- package/src/lib/layout-language/ai-layout-compiler.js +215 -30
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +12 -0
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/model/ai-credit-estimate.d.ts +25 -22
- package/src/lib/model/ai-credit-estimate.js +24 -22
- 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 +41 -5
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-report.d.ts +60 -0
- package/src/lib/model/ai-site-import-report.js +116 -0
- package/src/lib/model/ai-site-import-report.js.map +1 -0
- package/src/lib/model/ai-site-import-view.d.ts +7 -1
- package/src/lib/model/ai-site-import-view.js +14 -2
- package/src/lib/model/ai-site-import-view.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +49 -2
- package/src/lib/model/ai-site-import.js +81 -23
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +4 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js +9 -4
- package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
- package/src/lib/site-import/site-import-css.d.ts +10 -1
- package/src/lib/site-import/site-import-css.js +19 -12
- package/src/lib/site-import/site-import-css.js.map +1 -1
- package/src/lib/site-import/site-import-html.d.ts +17 -4
- package/src/lib/site-import/site-import-html.js +146 -17
- package/src/lib/site-import/site-import-html.js.map +1 -1
- package/src/lib/site-import/site-import-layout.js +194 -32
- package/src/lib/site-import/site-import-layout.js.map +1 -1
package/src/lib/jobs/ai-jobs.js
CHANGED
|
@@ -217,6 +217,18 @@ export function aiJobStepRunnerFor(kind) {
|
|
|
217
217
|
*/ export function registerAiJobStepPasses(kind, maxPasses) {
|
|
218
218
|
stepPassCaps.set(kind, Math.max(1, Math.floor(maxPasses)));
|
|
219
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* What a kind's build waits on when it stops with work left (AGL-4083), where
|
|
222
|
+
* ending would leave that work out for good: an import asked to bring in
|
|
223
|
+
* every wave, whose run takes hours, never reports `done` with pages missing.
|
|
224
|
+
* `null` from it settles the build as any other.
|
|
225
|
+
*/ const stopReviews = new Map();
|
|
226
|
+
/** Registers what a kind's stopped build waits on (AGL-4083). */ export function registerAiJobStopReview(kind, review) {
|
|
227
|
+
stopReviews.set(kind, review);
|
|
228
|
+
}
|
|
229
|
+
/** What a kind's stopped build waits on; `undefined` for a kind that ends. */ export function aiJobStopReviewFor(kind) {
|
|
230
|
+
return stopReviews.get(kind);
|
|
231
|
+
}
|
|
220
232
|
/** The passes a kind's step may take; the default where it registered none. */ export function aiJobStepMaxPasses(kind) {
|
|
221
233
|
var _stepPassCaps_get;
|
|
222
234
|
return (_stepPassCaps_get = stepPassCaps.get(kind)) != null ? _stepPassCaps_get : AI_JOB_STEP_MAX_PASSES;
|
|
@@ -1252,15 +1264,40 @@ async function transition(firestore, orgId, jobId, apply) {
|
|
|
1252
1264
|
* the items it never reached `skipped`. Then: anything delivered, and its
|
|
1253
1265
|
* planning is charged and the job is `done`, failed items and all; nothing
|
|
1254
1266
|
* delivered, and its planning is given back too and the job is `failed`.
|
|
1267
|
+
* A kind that registered a stop review (`registerAiJobStopReview`) waits on
|
|
1268
|
+
* it instead, with what it never reached still to do.
|
|
1255
1269
|
*/ export async function settleAiBuildJob(firestore, orgId, jobId, input) {
|
|
1256
|
-
var _job_items, _job_items1, _job_items2,
|
|
1257
|
-
var _job_orchestration;
|
|
1270
|
+
var _ref, _job_items, _job_items1, _job_items2, _ref1, _ref2, _job_items3;
|
|
1271
|
+
var _stopReviews_get, _job_orchestration;
|
|
1258
1272
|
const { now } = input;
|
|
1259
1273
|
let job = await getAiJob(firestore, orgId, jobId);
|
|
1260
1274
|
if (!job || isAiJobTerminal(job.status)) return job;
|
|
1261
1275
|
// A cancel asked before the build settled is how it ends (AGL-3616).
|
|
1262
1276
|
if (aiJobCancelPending(job)) return completeAiJob(firestore, orgId, jobId, now);
|
|
1263
1277
|
const stopped = input.stopped;
|
|
1278
|
+
// What was left stays to do, the row it stopped on with the rest, and the
|
|
1279
|
+
// person starts it (AGL-4083): the step is handed back with its attempts and
|
|
1280
|
+
// passes counted afresh, as a run the person started.
|
|
1281
|
+
const stopReview = stopped ? (_ref = (_stopReviews_get = stopReviews.get(job.kind)) == null ? void 0 : _stopReviews_get(job)) != null ? _ref : null : null;
|
|
1282
|
+
if (stopReview) {
|
|
1283
|
+
const { job: parked, changed } = await transition(firestore, orgId, jobId, (current)=>isAiJobTerminal(current.status) ? null : {
|
|
1284
|
+
status: 'needs_review',
|
|
1285
|
+
review: stopReview,
|
|
1286
|
+
steps: current.steps.map((step)=>step.name === AI_JOB_PLAN_STEP ? step : _extends({}, step, {
|
|
1287
|
+
status: 'pending',
|
|
1288
|
+
attempts: 0,
|
|
1289
|
+
passes: 0,
|
|
1290
|
+
endedAt: null,
|
|
1291
|
+
error: null
|
|
1292
|
+
})),
|
|
1293
|
+
error: null,
|
|
1294
|
+
lease: null,
|
|
1295
|
+
creditsReserved: 0,
|
|
1296
|
+
updatedAt: now
|
|
1297
|
+
});
|
|
1298
|
+
if (changed) await announceAiJobTransition(parked, 'needs-review');
|
|
1299
|
+
return parked;
|
|
1300
|
+
}
|
|
1264
1301
|
if (stopped && ((_job_items = job.items) != null ? _job_items : []).some((row)=>row.status === 'pending' || row.status === 'running')) {
|
|
1265
1302
|
var _job_items4;
|
|
1266
1303
|
const refunds = new Map();
|
|
@@ -1332,14 +1369,14 @@ async function transition(firestore, orgId, jobId, apply) {
|
|
|
1332
1369
|
if (job.kind === 'site') {
|
|
1333
1370
|
var _job_items5;
|
|
1334
1371
|
for (const row of (_job_items5 = job.items) != null ? _job_items5 : []){
|
|
1335
|
-
var _row_creditsSpent, _row_creditsRefunded,
|
|
1372
|
+
var _row_creditsSpent, _row_creditsRefunded, _ref3;
|
|
1336
1373
|
const owed = Math.max(0, ((_row_creditsSpent = row.creditsSpent) != null ? _row_creditsSpent : 0) - ((_row_creditsRefunded = row.creditsRefunded) != null ? _row_creditsRefunded : 0));
|
|
1337
1374
|
if (owed <= 0 || row.status === 'failed') continue;
|
|
1338
1375
|
const given = await refundBuildCredits(firestore, orgId, job, {
|
|
1339
1376
|
slot: row.slot,
|
|
1340
1377
|
attempt: row.attempt,
|
|
1341
1378
|
credits: owed,
|
|
1342
|
-
reason: (
|
|
1379
|
+
reason: (_ref3 = stopped == null ? void 0 : stopped.reason) != null ? _ref3 : 'step-failure',
|
|
1343
1380
|
free: input.free,
|
|
1344
1381
|
now
|
|
1345
1382
|
});
|
|
@@ -1350,7 +1387,7 @@ async function transition(firestore, orgId, jobId, apply) {
|
|
|
1350
1387
|
slot: 'plan',
|
|
1351
1388
|
attempt: 1,
|
|
1352
1389
|
credits: planCredits,
|
|
1353
|
-
reason: (
|
|
1390
|
+
reason: (_ref1 = stopped == null ? void 0 : stopped.reason) != null ? _ref1 : 'step-failure',
|
|
1354
1391
|
free: input.free,
|
|
1355
1392
|
now
|
|
1356
1393
|
});
|
|
@@ -1381,7 +1418,7 @@ async function transition(firestore, orgId, jobId, apply) {
|
|
|
1381
1418
|
});
|
|
1382
1419
|
});
|
|
1383
1420
|
const nothing = job.kind === 'site' ? AI_SITE_GUIDED_BUILD_FAILED_COPY : job.kind === 'import' ? AI_SITE_IMPORT_NOTHING_BUILT_COPY : AI_BUILD_NOTHING_BUILT_COPY;
|
|
1384
|
-
return failAiJob(firestore, orgId, jobId, (
|
|
1421
|
+
return failAiJob(firestore, orgId, jobId, (_ref2 = stopped == null ? void 0 : stopped.message) != null ? _ref2 : nothing, {
|
|
1385
1422
|
error: 'build delivered nothing',
|
|
1386
1423
|
// Ours unless every item that failed was the model declining (AGL-3616).
|
|
1387
1424
|
ours: Boolean(stopped) || ((_job_items3 = job.items) != null ? _job_items3 : []).some((row)=>{
|