docs-combiner 0.4.0 → 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 (52) 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 +316 -1214
  28. package/dist/models.js +17 -0
  29. package/dist/offerSettings.js +19 -0
  30. package/dist/preload.js +9 -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.map +1 -1
  35. package/dist/server/app.js +378 -0
  36. package/dist/server/auth.js +74 -0
  37. package/dist/server/contentJobs.js +367 -0
  38. package/dist/server/driveCatalog.js +122 -0
  39. package/dist/server/driveProxy.js +220 -0
  40. package/dist/server/flexcardMeta.js +29 -0
  41. package/dist/server/googleAuth.js +84 -0
  42. package/dist/server/imageAssets.js +87 -0
  43. package/dist/server/imageJobs.js +776 -0
  44. package/dist/server/index.js +38 -0
  45. package/dist/server/jobEvents.js +116 -0
  46. package/dist/server/jobs.js +358 -0
  47. package/dist/server/openRouterMeta.js +58 -0
  48. package/dist/server/spec.js +544 -0
  49. package/dist/server/storage.js +133 -0
  50. package/dist/server/telegram.js +53 -0
  51. package/dist/server/workspaceSnapshot.js +273 -0
  52. package/package.json +15 -3
@@ -0,0 +1,440 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.registerAgentApiRoutes = registerAgentApiRoutes;
13
+ const httpHelpers_1 = require("./httpHelpers");
14
+ const spec_1 = require("./spec");
15
+ function replyRendererFailure(res, status, body) {
16
+ (0, httpHelpers_1.sendAgentJsonFailure)(res, status, body);
17
+ }
18
+ function replyRendererCall(res, response, onSuccess) {
19
+ var _a;
20
+ if (!response.ok) {
21
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
22
+ return;
23
+ }
24
+ if (((_a = response.result) === null || _a === void 0 ? void 0 : _a.ok) === false) {
25
+ replyRendererFailure(res, 400, response.result);
26
+ return;
27
+ }
28
+ onSuccess(response.result);
29
+ }
30
+ function requireSessionId(raw, res) {
31
+ const sessionId = String(raw !== null && raw !== void 0 ? raw : '').trim();
32
+ if (!sessionId) {
33
+ res.status(400).json({ ok: false, error: 'Session id is required.' });
34
+ return null;
35
+ }
36
+ return sessionId;
37
+ }
38
+ function registerAgentApiRoutes(api, ctx) {
39
+ api.get('/api/health', (_req, res) => __awaiter(this, void 0, void 0, function* () {
40
+ const sessions = ctx.getAgentWorkSessions();
41
+ const readyFlags = yield Promise.all(sessions.map(session => ctx.isAgentApiReadyInSession(session.id)));
42
+ res.json({
43
+ ok: true,
44
+ version: ctx.version,
45
+ host: ctx.host,
46
+ port: ctx.port,
47
+ sessions: sessions.length,
48
+ agentReadySessions: readyFlags.filter(Boolean).length,
49
+ agentControlledSessions: ctx.agentControlledSessionCount(),
50
+ });
51
+ }));
52
+ api.get('/api/windows', (_req, res) => __awaiter(this, void 0, void 0, function* () {
53
+ const sessions = ctx.getAgentWorkSessions();
54
+ const windowsWithReady = yield Promise.all(sessions.map((session) => __awaiter(this, void 0, void 0, function* () {
55
+ return (Object.assign(Object.assign({}, session), { agentApiReady: yield ctx.isAgentApiReadyInSession(session.id) }));
56
+ })));
57
+ res.json({ ok: true, windows: windowsWithReady });
58
+ }));
59
+ api.post('/api/windows', (req, res) => __awaiter(this, void 0, void 0, function* () {
60
+ var _a, _b, _c, _d;
61
+ const requestedId = String((_b = (_a = req.body) === null || _a === void 0 ? void 0 : _a.workspaceId) !== null && _b !== void 0 ? _b : '').trim();
62
+ const workspaceId = requestedId || ctx.createWorkspaceId();
63
+ const agentControlled = ((_c = req.body) === null || _c === void 0 ? void 0 : _c.agentControlled) !== false;
64
+ ctx.createWindow(workspaceId, { agentControlled });
65
+ ctx.broadcastWorkspaceWindowsUpdated();
66
+ const session = yield ctx.waitForAgentSessionReady(workspaceId);
67
+ const baseUrl = ctx.getAgentApiBaseUrl();
68
+ const sessionUrl = `${baseUrl}/api/windows/${encodeURIComponent(workspaceId)}`;
69
+ if (session) {
70
+ res.status(201).json({
71
+ ok: true,
72
+ ready: true,
73
+ session,
74
+ url: sessionUrl,
75
+ endpoints: (_d = ctx.getAgentWorkSessions().find(item => item.id === workspaceId)) === null || _d === void 0 ? void 0 : _d.endpoints,
76
+ });
77
+ return;
78
+ }
79
+ res.status(202).json({
80
+ ok: true,
81
+ ready: false,
82
+ session: { id: workspaceId, title: 'Новый оффер' },
83
+ url: sessionUrl,
84
+ message: 'Window opened, but renderer Agent API is not ready yet. Retry GET /api/windows/{sessionId}.',
85
+ });
86
+ }));
87
+ api.get('/api/catalog', (req, res) => __awaiter(this, void 0, void 0, function* () {
88
+ var _a;
89
+ const preferredSessionId = String((_a = req.query.sessionId) !== null && _a !== void 0 ? _a : '').trim();
90
+ const response = yield ctx.callFirstReadyAgentRendererApi('getDriveCatalog', null, preferredSessionId || undefined);
91
+ if (!response.ok) {
92
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
93
+ return;
94
+ }
95
+ res.json({ ok: true, catalog: response.result });
96
+ }));
97
+ api.get('/api/windows/:sessionId', (req, res) => __awaiter(this, void 0, void 0, function* () {
98
+ var _a;
99
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
100
+ if (!sessionId)
101
+ return;
102
+ const response = yield ctx.callAgentRendererApi(sessionId, 'getSessionInfo');
103
+ if (!response.ok) {
104
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
105
+ return;
106
+ }
107
+ res.json({ ok: true, session: response.result });
108
+ }));
109
+ api.delete('/api/windows/:sessionId', (req, res) => {
110
+ var _a;
111
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
112
+ if (!sessionId)
113
+ return;
114
+ const result = ctx.closeSession(sessionId);
115
+ if (!result.ok) {
116
+ replyRendererFailure(res, 404, result);
117
+ return;
118
+ }
119
+ ctx.broadcastWorkspaceWindowsUpdated();
120
+ res.json({ ok: true, closed: sessionId });
121
+ });
122
+ api.patch('/api/windows/:sessionId', (req, res) => __awaiter(this, void 0, void 0, function* () {
123
+ var _a, _b;
124
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
125
+ if (!sessionId)
126
+ return;
127
+ const response = yield ctx.callAgentRendererApi(sessionId, 'patchSessionInfo', req.body);
128
+ if (!response.ok) {
129
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
130
+ return;
131
+ }
132
+ if (((_b = response.result) === null || _b === void 0 ? void 0 : _b.ok) === false) {
133
+ replyRendererFailure(res, 400, response.result);
134
+ return;
135
+ }
136
+ res.json(response.result);
137
+ }));
138
+ api.post('/api/windows/:sessionId/setup-campaign', (req, res) => __awaiter(this, void 0, void 0, function* () {
139
+ var _a, _b;
140
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
141
+ if (!sessionId)
142
+ return;
143
+ const response = yield ctx.callAgentRendererApi(sessionId, 'setupCampaignWorkspace', req.body);
144
+ if (!response.ok) {
145
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
146
+ return;
147
+ }
148
+ if (((_b = response.result) === null || _b === void 0 ? void 0 : _b.ok) === false) {
149
+ replyRendererFailure(res, 400, response.result);
150
+ return;
151
+ }
152
+ res.json(response.result);
153
+ }));
154
+ api.post('/api/windows/:sessionId/catalog/groups', (req, res) => __awaiter(this, void 0, void 0, function* () {
155
+ var _a, _b;
156
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
157
+ if (!sessionId)
158
+ return;
159
+ const response = yield ctx.callAgentRendererApi(sessionId, 'createCampaignGroup', req.body);
160
+ if (!response.ok) {
161
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
162
+ return;
163
+ }
164
+ if (((_b = response.result) === null || _b === void 0 ? void 0 : _b.ok) === false) {
165
+ replyRendererFailure(res, 400, response.result);
166
+ return;
167
+ }
168
+ res.json(response.result);
169
+ }));
170
+ api.post('/api/windows/:sessionId/catalog/workspaces', (req, res) => __awaiter(this, void 0, void 0, function* () {
171
+ var _a, _b;
172
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
173
+ if (!sessionId)
174
+ return;
175
+ const response = yield ctx.callAgentRendererApi(sessionId, 'createWorkspaceFolder', req.body);
176
+ if (!response.ok) {
177
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
178
+ return;
179
+ }
180
+ if (((_b = response.result) === null || _b === void 0 ? void 0 : _b.ok) === false) {
181
+ replyRendererFailure(res, 400, response.result);
182
+ return;
183
+ }
184
+ res.json(response.result);
185
+ }));
186
+ api.post('/api/windows/:sessionId/generate', (req, res) => __awaiter(this, void 0, void 0, function* () {
187
+ var _a;
188
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
189
+ if (!sessionId)
190
+ return;
191
+ const body = req.body && typeof req.body === 'object' ? req.body : {};
192
+ (0, httpHelpers_1.sendAgentActionResponse)(res, yield ctx.callAgentRendererApi(sessionId, 'startGeneration', body));
193
+ }));
194
+ api.post('/api/windows/:sessionId/geo-block', (req, res) => __awaiter(this, void 0, void 0, function* () {
195
+ var _a, _b;
196
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
197
+ if (!sessionId)
198
+ return;
199
+ const response = yield ctx.callAgentRendererApi(sessionId, 'fillGeoBlock', req.body);
200
+ if (!response.ok) {
201
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
202
+ return;
203
+ }
204
+ if (((_b = response.result) === null || _b === void 0 ? void 0 : _b.ok) === false) {
205
+ replyRendererFailure(res, 400, response.result);
206
+ return;
207
+ }
208
+ res.json(response.result);
209
+ }));
210
+ api.get('/api/windows/:sessionId/creative-selections', (req, res) => __awaiter(this, void 0, void 0, function* () {
211
+ var _a;
212
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
213
+ if (!sessionId)
214
+ return;
215
+ const response = yield ctx.callAgentRendererApi(sessionId, 'getCreativeSelections');
216
+ if (!response.ok) {
217
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
218
+ return;
219
+ }
220
+ res.json({ ok: true, selections: response.result });
221
+ }));
222
+ api.post('/api/windows/:sessionId/creative-selections', (req, res) => __awaiter(this, void 0, void 0, function* () {
223
+ var _a, _b;
224
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
225
+ if (!sessionId)
226
+ return;
227
+ const response = yield ctx.callAgentRendererApi(sessionId, 'setCreativeSelections', req.body);
228
+ if (!response.ok) {
229
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
230
+ return;
231
+ }
232
+ if (((_b = response.result) === null || _b === void 0 ? void 0 : _b.ok) === false) {
233
+ replyRendererFailure(res, 400, response.result);
234
+ return;
235
+ }
236
+ res.json(response.result);
237
+ }));
238
+ api.get('/api/windows/:sessionId/capabilities', (req, res) => __awaiter(this, void 0, void 0, function* () {
239
+ var _a;
240
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
241
+ if (!sessionId)
242
+ return;
243
+ const response = yield ctx.callAgentRendererApi(sessionId, 'getCapabilities');
244
+ if (!response.ok) {
245
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
246
+ return;
247
+ }
248
+ res.json({ ok: true, capabilities: response.result });
249
+ }));
250
+ api.get('/api/windows/:sessionId/validation', (req, res) => __awaiter(this, void 0, void 0, function* () {
251
+ var _a;
252
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
253
+ if (!sessionId)
254
+ return;
255
+ const response = yield ctx.callAgentRendererApi(sessionId, 'getValidation');
256
+ if (!response.ok) {
257
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
258
+ return;
259
+ }
260
+ res.json({ ok: true, validation: response.result });
261
+ }));
262
+ api.get('/api/windows/:sessionId/jobs', (req, res) => __awaiter(this, void 0, void 0, function* () {
263
+ var _a;
264
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
265
+ if (!sessionId)
266
+ return;
267
+ const response = yield ctx.callAgentRendererApi(sessionId, 'getJobStatus', {});
268
+ if (!response.ok) {
269
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
270
+ return;
271
+ }
272
+ res.json(response.result);
273
+ }));
274
+ api.get('/api/windows/:sessionId/jobs/:jobId', (req, res) => __awaiter(this, void 0, void 0, function* () {
275
+ var _a, _b, _c;
276
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
277
+ if (!sessionId)
278
+ return;
279
+ const jobId = String((_b = req.params.jobId) !== null && _b !== void 0 ? _b : '').trim();
280
+ const wait = req.query.wait === '1' || req.query.wait === 'true';
281
+ const timeoutSec = Math.min(Math.max(Number(req.query.timeout) || 120, 1), 600);
282
+ const response = wait
283
+ ? yield (0, httpHelpers_1.waitForAgentJobStatus)(ctx.callAgentRendererApi, sessionId, jobId, timeoutSec * 1000)
284
+ : yield ctx.callAgentRendererApi(sessionId, 'getJobStatus', { jobId });
285
+ if (!response.ok) {
286
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
287
+ return;
288
+ }
289
+ if (((_c = response.result) === null || _c === void 0 ? void 0 : _c.ok) === false) {
290
+ replyRendererFailure(res, 404, response.result);
291
+ return;
292
+ }
293
+ res.json(response.result);
294
+ }));
295
+ api.get('/api/windows/:sessionId/approach-matrix', (req, res) => __awaiter(this, void 0, void 0, function* () {
296
+ var _a;
297
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
298
+ if (!sessionId)
299
+ return;
300
+ const response = yield ctx.callAgentRendererApi(sessionId, 'getApproachMatrix');
301
+ if (!response.ok) {
302
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
303
+ return;
304
+ }
305
+ res.json(response.result);
306
+ }));
307
+ api.post('/api/windows/:sessionId/approach-matrix', (req, res) => __awaiter(this, void 0, void 0, function* () {
308
+ var _a, _b;
309
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
310
+ if (!sessionId)
311
+ return;
312
+ const response = yield ctx.callAgentRendererApi(sessionId, 'setApproachMatrix', req.body);
313
+ if (!response.ok) {
314
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
315
+ return;
316
+ }
317
+ if (((_b = response.result) === null || _b === void 0 ? void 0 : _b.ok) === false) {
318
+ replyRendererFailure(res, 400, response.result);
319
+ return;
320
+ }
321
+ res.json(response.result);
322
+ }));
323
+ api.post('/api/windows/:sessionId/agent-control', (req, res) => __awaiter(this, void 0, void 0, function* () {
324
+ var _a, _b, _c;
325
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
326
+ if (!sessionId)
327
+ return;
328
+ const mode = String((_c = (_b = req.body) === null || _b === void 0 ? void 0 : _b.mode) !== null && _c !== void 0 ? _c : '').trim();
329
+ if (mode !== 'agent' && mode !== 'manual') {
330
+ res.status(400).json({ ok: false, error: 'mode must be "agent" or "manual".' });
331
+ return;
332
+ }
333
+ if (!ctx.getWindowByWorkspaceId(sessionId)) {
334
+ replyRendererFailure(res, 404, { ok: false, error: 'Session not found.' });
335
+ return;
336
+ }
337
+ ctx.setSessionAgentControlMode(sessionId, mode);
338
+ const response = yield ctx.callAgentRendererApi(sessionId, 'setAgentControlMode', { mode });
339
+ if (!response.ok) {
340
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
341
+ return;
342
+ }
343
+ res.json(Object.assign({ ok: true, mode }, (response.result || {})));
344
+ }));
345
+ api.get('/api/windows/:sessionId/agent-control', (req, res) => __awaiter(this, void 0, void 0, function* () {
346
+ var _a;
347
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
348
+ if (!sessionId)
349
+ return;
350
+ const response = yield ctx.callAgentRendererApi(sessionId, 'getAgentControlStatus');
351
+ if (!response.ok) {
352
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
353
+ return;
354
+ }
355
+ res.json(Object.assign({ ok: true }, (response.result || {})));
356
+ }));
357
+ api.post('/api/windows/:sessionId/actions/load-content', (req, res) => __awaiter(this, void 0, void 0, function* () {
358
+ var _a;
359
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
360
+ if (!sessionId)
361
+ return;
362
+ const body = req.body && typeof req.body === 'object' ? req.body : {};
363
+ (0, httpHelpers_1.sendAgentActionResponse)(res, yield ctx.callAgentRendererApi(sessionId, 'loadContent', body));
364
+ }));
365
+ api.post('/api/windows/:sessionId/actions/upload-images', (req, res) => __awaiter(this, void 0, void 0, function* () {
366
+ var _a;
367
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
368
+ if (!sessionId)
369
+ return;
370
+ const body = req.body && typeof req.body === 'object' ? req.body : {};
371
+ (0, httpHelpers_1.sendAgentActionResponse)(res, yield ctx.callAgentRendererApi(sessionId, 'uploadImages', body));
372
+ }));
373
+ api.post('/api/windows/:sessionId/actions/check-images', (req, res) => __awaiter(this, void 0, void 0, function* () {
374
+ var _a;
375
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
376
+ if (!sessionId)
377
+ return;
378
+ const body = req.body && typeof req.body === 'object' ? req.body : {};
379
+ (0, httpHelpers_1.sendAgentActionResponse)(res, yield ctx.callAgentRendererApi(sessionId, 'checkImages', body));
380
+ }));
381
+ api.post('/api/windows/:sessionId/actions/regenerate-pair', (req, res) => __awaiter(this, void 0, void 0, function* () {
382
+ var _a;
383
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
384
+ if (!sessionId)
385
+ return;
386
+ const body = req.body && typeof req.body === 'object' ? req.body : {};
387
+ (0, httpHelpers_1.sendAgentActionResponse)(res, yield ctx.callAgentRendererApi(sessionId, 'regeneratePair', body));
388
+ }));
389
+ api.post('/api/windows/:sessionId/actions/regenerate-images', (req, res) => __awaiter(this, void 0, void 0, function* () {
390
+ var _a;
391
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
392
+ if (!sessionId)
393
+ return;
394
+ const body = req.body && typeof req.body === 'object' ? req.body : {};
395
+ (0, httpHelpers_1.sendAgentActionResponse)(res, yield ctx.callAgentRendererApi(sessionId, 'regenerateImages', body));
396
+ }));
397
+ api.get('/api/windows/:sessionId/generated', (req, res) => __awaiter(this, void 0, void 0, function* () {
398
+ var _a;
399
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
400
+ if (!sessionId)
401
+ return;
402
+ const response = yield ctx.callAgentRendererApi(sessionId, 'getGenerated');
403
+ if (!response.ok) {
404
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
405
+ return;
406
+ }
407
+ res.json({ ok: true, generated: response.result });
408
+ }));
409
+ api.patch('/api/windows/:sessionId/generated', (req, res) => __awaiter(this, void 0, void 0, function* () {
410
+ var _a, _b;
411
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
412
+ if (!sessionId)
413
+ return;
414
+ const response = yield ctx.callAgentRendererApi(sessionId, 'patchGenerated', req.body);
415
+ if (!response.ok) {
416
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
417
+ return;
418
+ }
419
+ if (((_b = response.result) === null || _b === void 0 ? void 0 : _b.ok) === false) {
420
+ replyRendererFailure(res, 400, response.result);
421
+ return;
422
+ }
423
+ res.json(response.result);
424
+ }));
425
+ api.get('/api/windows/:sessionId/logs', (req, res) => __awaiter(this, void 0, void 0, function* () {
426
+ var _a;
427
+ const sessionId = requireSessionId(String((_a = req.params.sessionId) !== null && _a !== void 0 ? _a : ''), res);
428
+ if (!sessionId)
429
+ return;
430
+ const response = yield ctx.callAgentRendererApi(sessionId, 'getLogs');
431
+ if (!response.ok) {
432
+ replyRendererFailure(res, response.status, { ok: false, error: response.error });
433
+ return;
434
+ }
435
+ res.json({ ok: true, logs: response.result });
436
+ }));
437
+ api.get('/api/spec', (_req, res) => {
438
+ res.json((0, spec_1.getAgentApiSpec)(ctx.host, ctx.port, ctx.version));
439
+ });
440
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildAgentSessionInfo = buildAgentSessionInfo;
4
+ function buildAgentSessionInfo(input) {
5
+ var _a;
6
+ const updatedAt = (_a = input.updatedAt) !== null && _a !== void 0 ? _a : new Date().toISOString();
7
+ const snapshot = {
8
+ id: input.workspaceId,
9
+ updatedAt,
10
+ driveFolderUrl: input.drive.driveFolderUrl,
11
+ driveFolderName: input.drive.driveFolderName,
12
+ driveFolderDisplayPath: input.drive.driveFolderDisplayPath,
13
+ rootDriveFolderUrl: input.drive.offersRootUrl,
14
+ generateProduct: input.generation.product,
15
+ generateGeo: input.generation.firstGeo,
16
+ generateAdditionalInfo: input.generation.additionalInfo,
17
+ generatePriceWithCurrency: input.generation.firstPriceWithCurrency,
18
+ generationMarkets: input.generation.generationMarkets,
19
+ link: input.generation.firstLink,
20
+ selectedPairApproaches: input.creative.selectedPairApproaches,
21
+ imageApproachCounts: input.creative.imageApproachCounts,
22
+ approachMatrixEnabled: input.creative.approachMatrixEnabled,
23
+ approachMatrix: input.creative.approachMatrix,
24
+ catalogUrlIncludeTextApproach: input.catalogUrlSettings.includeTextApproach,
25
+ catalogUrlIncludeCreoApproach: input.catalogUrlSettings.includeCreoApproach,
26
+ catalogUrlIncludeImageAspect: input.catalogUrlSettings.includeImageAspect,
27
+ catalogUrlTextApproachParam: input.catalogUrlSettings.textApproachParam,
28
+ catalogUrlCreoApproachParam: input.catalogUrlSettings.creoApproachParam,
29
+ catalogUrlImageAspectParam: input.catalogUrlSettings.imageAspectParam,
30
+ catalogLinkExtraMacros: input.catalogUrlSettings.extraMacros,
31
+ };
32
+ return {
33
+ id: input.workspaceId,
34
+ title: input.drive.driveFolderDisplayPath ||
35
+ input.drive.driveFolderName ||
36
+ input.titleProductFallback ||
37
+ 'Новый оффер',
38
+ updatedAt,
39
+ drive: {
40
+ offersRootUrl: input.drive.offersRootUrl,
41
+ campaignsRootUrl: input.drive.campaignsRootUrl,
42
+ driveFolderUrl: input.drive.driveFolderUrl,
43
+ driveFolderName: input.drive.driveFolderName,
44
+ driveFolderDisplayPath: input.drive.driveFolderDisplayPath,
45
+ pickedCampaignGroup: input.drive.pickedCampaignGroup,
46
+ mappedOffer: input.drive.mappedOffer,
47
+ offerSettingsBaseline: input.drive.offerSettingsBaseline,
48
+ campaignDescriptionOverrides: input.drive.campaignDescriptionOverrides,
49
+ loadingCampaignTree: input.drive.loadingCampaignTree,
50
+ },
51
+ generation: {
52
+ product: input.generation.product,
53
+ additionalInfo: input.generation.additionalInfo,
54
+ geoBlock: input.generation.generationMarkets,
55
+ firstGeo: input.generation.firstGeo,
56
+ firstPriceWithCurrency: input.generation.firstPriceWithCurrency,
57
+ firstLink: input.generation.firstLink,
58
+ brand: input.brand,
59
+ },
60
+ catalogUrlSettings: {
61
+ includeTextApproach: input.catalogUrlSettings.includeTextApproach,
62
+ includeCreoApproach: input.catalogUrlSettings.includeCreoApproach,
63
+ includeImageAspect: input.catalogUrlSettings.includeImageAspect,
64
+ textApproachParam: input.catalogUrlSettings.textApproachParam,
65
+ creoApproachParam: input.catalogUrlSettings.creoApproachParam,
66
+ imageAspectParam: input.catalogUrlSettings.imageAspectParam,
67
+ extraMacros: input.catalogUrlSettings.extraMacros,
68
+ },
69
+ promptSettings: {
70
+ selectedPairApproaches: input.creative.selectedPairApproaches,
71
+ imageApproachCounts: input.creative.imageApproachCounts,
72
+ approachMatrixEnabled: input.creative.approachMatrixEnabled,
73
+ approachMatrix: input.creative.approachMatrix,
74
+ creativeSelections: input.creative.creativeSelections,
75
+ },
76
+ agentControl: {
77
+ mode: input.agentControlMode,
78
+ manualControlBlocked: input.agentControlMode === 'agent',
79
+ },
80
+ snapshot,
81
+ };
82
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });