docs-combiner 0.2.2 → 1.0.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 (53) hide show
  1. package/dist/agentApi/agentControlClaim.js +26 -0
  2. package/dist/agentApi/approachMatrixView.js +19 -0
  3. package/dist/agentApi/capabilitiesMeta.js +78 -0
  4. package/dist/agentApi/catalogUrlPresets.js +26 -0
  5. package/dist/agentApi/constants.js +11 -0
  6. package/dist/agentApi/creativeSelections.js +25 -0
  7. package/dist/agentApi/escalation.js +221 -0
  8. package/dist/agentApi/generatedPairsGuard.js +85 -0
  9. package/dist/agentApi/httpHelpers.js +77 -0
  10. package/dist/agentApi/imagesReadiness.js +60 -0
  11. package/dist/agentApi/jobStatus.js +113 -0
  12. package/dist/agentApi/productImageDrive.js +39 -0
  13. package/dist/agentApi/regenerateImages.js +125 -0
  14. package/dist/agentApi/rendererTypes.js +3 -0
  15. package/dist/agentApi/routes.js +440 -0
  16. package/dist/agentApi/sessionSnapshot.js +82 -0
  17. package/dist/agentApi/sessionTypes.js +2 -0
  18. package/dist/agentApi/spec.js +1045 -0
  19. package/dist/agentApi/types.js +2 -0
  20. package/dist/agentApi/validation.js +32 -0
  21. package/dist/campaignsCsv.js +420 -0
  22. package/dist/contentPairs.js +62 -0
  23. package/dist/flexcardBalance.js +88 -0
  24. package/dist/integrations/driveApi.js +420 -0
  25. package/dist/integrations/httpTimeout.js +116 -0
  26. package/dist/integrations/openrouter.js +532 -0
  27. package/dist/main.js +830 -165
  28. package/dist/models.js +17 -0
  29. package/dist/offerSettings.js +19 -0
  30. package/dist/preload.js +28 -0
  31. package/dist/promptOverrides.js +437 -0
  32. package/dist/prompts.js +1243 -0
  33. package/dist/renderer.js +19 -19
  34. package/dist/renderer.js.LICENSE.txt +4 -0
  35. package/dist/renderer.js.map +1 -1
  36. package/dist/server/app.js +378 -0
  37. package/dist/server/auth.js +74 -0
  38. package/dist/server/contentJobs.js +367 -0
  39. package/dist/server/driveCatalog.js +122 -0
  40. package/dist/server/driveProxy.js +220 -0
  41. package/dist/server/flexcardMeta.js +29 -0
  42. package/dist/server/googleAuth.js +84 -0
  43. package/dist/server/imageAssets.js +87 -0
  44. package/dist/server/imageJobs.js +776 -0
  45. package/dist/server/index.js +38 -0
  46. package/dist/server/jobEvents.js +116 -0
  47. package/dist/server/jobs.js +358 -0
  48. package/dist/server/openRouterMeta.js +58 -0
  49. package/dist/server/spec.js +544 -0
  50. package/dist/server/storage.js +133 -0
  51. package/dist/server/telegram.js +53 -0
  52. package/dist/server/workspaceSnapshot.js +273 -0
  53. package/package.json +18 -4
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildImagesJobProgress = buildImagesJobProgress;
4
+ exports.buildRegenerateImagesJobStatus = buildRegenerateImagesJobStatus;
5
+ exports.buildImagesJobStatus = buildImagesJobStatus;
6
+ exports.isTerminalAgentJobWait = isTerminalAgentJobWait;
7
+ const regenerateImages_1 = require("./regenerateImages");
8
+ const imagesReadiness_1 = require("./imagesReadiness");
9
+ function asAgentImageSlot(image) {
10
+ var _a;
11
+ return {
12
+ index: (_a = image.index) !== null && _a !== void 0 ? _a : 0,
13
+ imageUrl: image.imageUrl,
14
+ failed: image.failed,
15
+ uploaded: image.uploaded,
16
+ driveUploadedFileId: image.driveUploadedFileId,
17
+ generating: image.generating,
18
+ regenerating: image.regenerating,
19
+ uploading: image.uploading,
20
+ checking: image.checking,
21
+ checkStatus: image.checkStatus,
22
+ checkResult: image.checkResult,
23
+ checkFailed: image.checkFailed,
24
+ errorMessage: image.errorMessage,
25
+ };
26
+ }
27
+ function isImageSlotActive(image) {
28
+ var _a;
29
+ if (image.generating || image.regenerating || image.uploading || image.checking)
30
+ return true;
31
+ const lifecycleType = (_a = image.lifecycle) === null || _a === void 0 ? void 0 : _a.type;
32
+ return lifecycleType === 'generating' || lifecycleType === 'regenerating' || lifecycleType === 'checking';
33
+ }
34
+ function buildImagesJobProgress(images) {
35
+ return {
36
+ total: images.length,
37
+ generated: images.filter(image => (0, regenerateImages_1.isImageSlotGenerated)(asAgentImageSlot(image))).length,
38
+ failed: images.filter(image => (0, regenerateImages_1.isImageSlotFailed)(asAgentImageSlot(image))).length,
39
+ checking: images.filter(image => { var _a; return image.checking || image.checkStatus === 'checking' || ((_a = image.lifecycle) === null || _a === void 0 ? void 0 : _a.type) === 'checking'; }).length,
40
+ verified: images.filter(image => image.checkStatus === 'ok').length,
41
+ uploaded: images.filter(image => image.uploaded).length,
42
+ };
43
+ }
44
+ function buildRegenerateImagesJobStatus(input) {
45
+ const subsetActive = input.images
46
+ .filter(img => input.acceptedIndices.includes(img.index))
47
+ .some(isImageSlotActive);
48
+ const progress = (0, regenerateImages_1.buildRegenerateImagesJobProgress)(input.images, input.acceptedIndices);
49
+ let status = 'idle';
50
+ if (input.running || subsetActive) {
51
+ status = 'running';
52
+ }
53
+ else if (input.runId > 0 || input.acceptedIndices.length > 0) {
54
+ status = 'done';
55
+ }
56
+ return {
57
+ id: 'regenerateImages',
58
+ status,
59
+ startedAt: input.startedAt,
60
+ elapsedSeconds: input.elapsedSeconds,
61
+ logs: input.logs,
62
+ runId: input.runId,
63
+ progress,
64
+ };
65
+ }
66
+ function buildImagesJobStatus(input) {
67
+ const progress = buildImagesJobProgress(input.images);
68
+ const slotActive = input.images.some(isImageSlotActive);
69
+ const isRunning = input.generatingImages ||
70
+ slotActive ||
71
+ (input.checkingImages && input.images.some(image => image.checking || image.checkStatus === 'checking'));
72
+ const agentImages = input.images.map(asAgentImageSlot);
73
+ const readiness = (0, imagesReadiness_1.buildImagesReadiness)(agentImages, { busy: isRunning });
74
+ let status = 'idle';
75
+ if (isRunning) {
76
+ status = 'running';
77
+ }
78
+ else if (input.runId > 0) {
79
+ status = 'done';
80
+ }
81
+ else if (progress.total > 0) {
82
+ status = 'done';
83
+ }
84
+ return {
85
+ id: 'images',
86
+ status,
87
+ startedAt: input.startedAt,
88
+ elapsedSeconds: input.elapsedSeconds,
89
+ logs: input.logs,
90
+ runId: input.runId,
91
+ progress,
92
+ imagesReady: readiness.imagesReady,
93
+ blockingFailures: readiness.blockingFailures,
94
+ };
95
+ }
96
+ function isTerminalAgentJobWait(input) {
97
+ var _a;
98
+ if (input.status === 'running')
99
+ return false;
100
+ if (input.status === 'idle') {
101
+ if (input.jobId === 'images' || input.jobId === 'regenerateImages')
102
+ return input.sawRunning;
103
+ return true;
104
+ }
105
+ if (input.jobId !== 'images' && input.jobId !== 'regenerateImages')
106
+ return true;
107
+ const runId = typeof input.runId === 'number' ? input.runId : 0;
108
+ const initialRunId = (_a = input.initialRunId) !== null && _a !== void 0 ? _a : runId;
109
+ if (!input.sawRunning && input.status === 'done' && runId === initialRunId) {
110
+ return false;
111
+ }
112
+ return true;
113
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WORKSPACE_PRODUCT_FILENAMES = void 0;
4
+ exports.isWorkspaceProductFileName = isWorkspaceProductFileName;
5
+ exports.resolveOfferFolderProductFromImageFiles = resolveOfferFolderProductFromImageFiles;
6
+ exports.formatOfferFolderMultipleImagesError = formatOfferFolderMultipleImagesError;
7
+ exports.formatOfferFolderNoImageError = formatOfferFolderNoImageError;
8
+ exports.pickWorkspaceProductFile = pickWorkspaceProductFile;
9
+ exports.WORKSPACE_PRODUCT_FILENAMES = ['product.png', 'product.jpg', 'product.webp'];
10
+ function isWorkspaceProductFileName(name) {
11
+ const lower = String(name !== null && name !== void 0 ? name : '').trim().toLowerCase();
12
+ return exports.WORKSPACE_PRODUCT_FILENAMES.includes(lower);
13
+ }
14
+ /** В папке оффера допускается ровно одно изображение с любым именем. */
15
+ function resolveOfferFolderProductFromImageFiles(files) {
16
+ const images = files.filter(file => { var _a; return file.id && ((_a = file.name) === null || _a === void 0 ? void 0 : _a.trim()); });
17
+ if (images.length === 0) {
18
+ return { ok: false, code: 'none', files: [] };
19
+ }
20
+ if (images.length > 1) {
21
+ return { ok: false, code: 'multiple', files: images };
22
+ }
23
+ return { ok: true, file: images[0] };
24
+ }
25
+ function formatOfferFolderMultipleImagesError(offerName, fileNames) {
26
+ const list = fileNames.filter(Boolean).join(', ') || 'несколько файлов';
27
+ return `В папке оффера «${offerName}» найдено ${fileNames.length} изображений (${list}) — оставьте ровно один файл картинки продукта.`;
28
+ }
29
+ function formatOfferFolderNoImageError(offerName) {
30
+ return `В папке оффера «${offerName}» нет изображения продукта — добавьте один файл картинки (любое имя).`;
31
+ }
32
+ function pickWorkspaceProductFile(files) {
33
+ const named = files.filter(file => isWorkspaceProductFileName(file.name));
34
+ if (named.length === 0)
35
+ return null;
36
+ const pngFile = named.find(file => file.name.toLowerCase() === 'product.png');
37
+ const webpFile = named.find(file => file.name.toLowerCase() === 'product.webp');
38
+ return pngFile || webpFile || named[0] || null;
39
+ }
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isImageSlotBusy = isImageSlotBusy;
4
+ exports.isImageSlotUploadedOk = isImageSlotUploadedOk;
5
+ exports.isImageSlotFailed = isImageSlotFailed;
6
+ exports.isImageSlotGenerated = isImageSlotGenerated;
7
+ exports.isImageSlotCheckTransportFailure = isImageSlotCheckTransportFailure;
8
+ exports.resolveImageSlotFailureAction = resolveImageSlotFailureAction;
9
+ exports.isImageSlotProblem = isImageSlotProblem;
10
+ exports.isImageSlotPendingUpload = isImageSlotPendingUpload;
11
+ exports.isRegenerateImageEligible = isRegenerateImageEligible;
12
+ exports.resolveRegenerateImageIndices = resolveRegenerateImageIndices;
13
+ exports.buildImageSlotStatusSummary = buildImageSlotStatusSummary;
14
+ exports.buildAgentGeneratedImageView = buildAgentGeneratedImageView;
15
+ exports.buildRegenerateImagesJobProgress = buildRegenerateImagesJobProgress;
16
+ function isImageSlotBusy(img) {
17
+ return Boolean(img.generating || img.regenerating || img.uploading || img.checking);
18
+ }
19
+ /** Uploaded to Drive with validator OK — local preview URL may be cleared intentionally. */
20
+ function isImageSlotUploadedOk(img) {
21
+ var _a;
22
+ return Boolean(img.uploaded &&
23
+ ((_a = img.driveUploadedFileId) === null || _a === void 0 ? void 0 : _a.trim()) &&
24
+ img.checkStatus === 'ok');
25
+ }
26
+ function isImageSlotFailed(img) {
27
+ var _a;
28
+ if (isImageSlotUploadedOk(img))
29
+ return false;
30
+ if (isImageSlotBusy(img))
31
+ return false;
32
+ if (img.failed === true)
33
+ return true;
34
+ if (!((_a = img.imageUrl) === null || _a === void 0 ? void 0 : _a.trim())) {
35
+ return img.checkStatus !== 'pending';
36
+ }
37
+ return false;
38
+ }
39
+ function isImageSlotGenerated(img) {
40
+ var _a;
41
+ return isImageSlotUploadedOk(img) || Boolean((_a = img.imageUrl) === null || _a === void 0 ? void 0 : _a.trim());
42
+ }
43
+ /**
44
+ * Validator transport error (e.g. "Failed to fetch") rather than a real "needs_rebuild"
45
+ * verdict: the image itself is fine, the validator just couldn't reach/parse it.
46
+ * Such a slot only needs to be re-checked, not regenerated.
47
+ */
48
+ function isImageSlotCheckTransportFailure(img) {
49
+ var _a;
50
+ return Boolean(img.checkFailed && img.checkStatus === 'needs_rebuild' && ((_a = img.imageUrl) === null || _a === void 0 ? void 0 : _a.trim()) && !img.uploaded);
51
+ }
52
+ /**
53
+ * Recommended next step for a non-uploaded problem slot:
54
+ * - 'recheck' → validator transport error, the image is fine, just re-run the validator
55
+ * (POST .../actions/check-images with this index).
56
+ * - 'rebuild' → generation failed or the validator rejected the image
57
+ * (POST .../actions/regenerate-images with this index).
58
+ */
59
+ function resolveImageSlotFailureAction(img) {
60
+ return isImageSlotCheckTransportFailure(img) ? 'recheck' : 'rebuild';
61
+ }
62
+ /** Slot that is not OK-uploaded, not busy, and has a terminal problem (failed gen or needs_rebuild). */
63
+ function isImageSlotProblem(img) {
64
+ if (isImageSlotUploadedOk(img))
65
+ return false;
66
+ if (isImageSlotBusy(img))
67
+ return false;
68
+ return isImageSlotFailed(img) || img.checkStatus === 'needs_rebuild';
69
+ }
70
+ function isImageSlotPendingUpload(img) {
71
+ var _a;
72
+ return Boolean(((_a = img.imageUrl) === null || _a === void 0 ? void 0 : _a.trim()) &&
73
+ img.checkStatus === 'ok' &&
74
+ img.checkResult !== 'Проверка отключена' &&
75
+ !img.uploaded);
76
+ }
77
+ function isRegenerateImageEligible(img) {
78
+ var _a, _b;
79
+ if (isImageSlotBusy(img))
80
+ return false;
81
+ if (isImageSlotUploadedOk(img))
82
+ return false;
83
+ return Boolean(((_a = img.originalPrompt) === null || _a === void 0 ? void 0 : _a.trim()) && ((_b = img.productImageUrl) === null || _b === void 0 ? void 0 : _b.trim()));
84
+ }
85
+ function resolveRegenerateImageIndices(input) {
86
+ var _a;
87
+ const known = new Map(input.images.map(img => [img.index, img]));
88
+ const candidates = ((_a = input.indices) === null || _a === void 0 ? void 0 : _a.length)
89
+ ? [...new Set(input.indices.filter(index => known.has(index)))].sort((a, b) => a - b)
90
+ : [];
91
+ const acceptedIndices = [];
92
+ const skippedIndices = [];
93
+ for (const index of candidates) {
94
+ const img = known.get(index);
95
+ if (!img || isImageSlotBusy(img) || !isRegenerateImageEligible(img)) {
96
+ skippedIndices.push(index);
97
+ continue;
98
+ }
99
+ acceptedIndices.push(index);
100
+ }
101
+ return { acceptedIndices, skippedIndices };
102
+ }
103
+ function buildImageSlotStatusSummary(img) {
104
+ var _a;
105
+ return Object.assign({ index: img.index, failed: isImageSlotFailed(img), checkStatus: (_a = img.checkStatus) !== null && _a !== void 0 ? _a : 'pending', checkFailed: Boolean(img.checkFailed), uploaded: Boolean(img.uploaded), busy: isImageSlotBusy(img), regenerateEligible: isRegenerateImageEligible(img) && !isImageSlotBusy(img), errorMessage: img.errorMessage }, (isImageSlotProblem(img) ? { recommendedAction: resolveImageSlotFailureAction(img) } : {}));
106
+ }
107
+ function buildAgentGeneratedImageView(img, driveUrlFromId) {
108
+ var _a, _b, _c;
109
+ const driveUrl = img.driveUploadedFileId && driveUrlFromId ? driveUrlFromId(img.driveUploadedFileId) : undefined;
110
+ const imageUrl = ((_a = img.imageUrl) === null || _a === void 0 ? void 0 : _a.trim()) || driveUrl;
111
+ const failed = isImageSlotFailed(img);
112
+ return Object.assign(Object.assign({ index: img.index, failed, errorMessage: img.errorMessage, checkStatus: (_b = img.checkStatus) !== null && _b !== void 0 ? _b : 'pending', checkFailed: Boolean(img.checkFailed), uploaded: Boolean(img.uploaded), imageUrl,
113
+ driveUrl, regenerateEligible: isRegenerateImageEligible(img) && !isImageSlotBusy(img) }, (isImageSlotProblem(img) ? { recommendedAction: resolveImageSlotFailureAction(img) } : {})), (failed && ((_c = img.productImageUrl) === null || _c === void 0 ? void 0 : _c.trim()) ? { productImageUrl: img.productImageUrl } : {}));
114
+ }
115
+ function buildRegenerateImagesJobProgress(images, acceptedIndices) {
116
+ const subset = images.filter(img => acceptedIndices.includes(img.index));
117
+ return {
118
+ total: acceptedIndices.length,
119
+ generated: subset.filter(img => isImageSlotGenerated(img)).length,
120
+ failed: subset.filter(img => isImageSlotFailed(img)).length,
121
+ checking: subset.filter(img => img.checking || img.checkStatus === 'checking' || img.regenerating || img.generating).length,
122
+ verified: subset.filter(img => img.checkStatus === 'ok').length,
123
+ uploaded: subset.filter(img => img.uploaded).length,
124
+ };
125
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ /** Payload types for window.__docsCombinerAgentApi (renderer). */
3
+ Object.defineProperty(exports, "__esModule", { value: true });