@appaflytech/zeyrek-ai-mcp 0.0.64 → 0.0.65
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/dist/knowledge/access.js +29 -0
- package/dist/knowledge/componentEvents.js +5 -2
- package/dist/knowledge/previewLimits.js +72 -0
- package/dist/knowledge/rules.js +256 -4
- package/dist/knowledge/storeImport.js +22 -0
- package/dist/platform/bodyFile.js +22 -87
- package/dist/platform/capture/actions.js +43 -1
- package/dist/platform/capture/capture.js +84 -13
- package/dist/platform/localFiles.js +197 -0
- package/dist/platform/responses.js +2 -2
- package/dist/platform/storeArt/deck.js +22 -15
- package/dist/platform/storeArt/gallery.js +11 -4
- package/dist/resources/examples/workflow-push-own-profile.json +100 -0
- package/dist/resources/guides/deployment.md +32 -0
- package/dist/resources/guides/entity.md +2 -0
- package/dist/resources/guides/expressions.md +4 -2
- package/dist/resources/guides/microservice.md +7 -3
- package/dist/resources/guides/mobile-publish.md +25 -5
- package/dist/resources/guides/mobile-steps.md +19 -1
- package/dist/resources/guides/mobile.md +6 -6
- package/dist/resources/guides/workflow.md +23 -5
- package/dist/resources/schema-fingerprint.json +3 -3
- package/dist/tools/bpmGovernance.js +22 -19
- package/dist/tools/bpmReporting.js +6 -3
- package/dist/tools/case.js +10 -14
- package/dist/tools/common.js +1 -1
- package/dist/tools/decisions.js +10 -14
- package/dist/tools/deployments.js +160 -18
- package/dist/tools/externalComponents.js +28 -27
- package/dist/tools/files.js +15 -14
- package/dist/tools/mobileStore.js +22 -13
- package/dist/tools/mobileStoreImport.js +22 -12
- package/dist/tools/pages.js +32 -11
- package/dist/tools/queries.js +15 -2
- package/dist/tools/rows.js +70 -33
- package/dist/tools/translations.js +16 -18
- package/dist/tools/workflows.js +13 -6
- package/package.json +1 -1
|
@@ -13,6 +13,8 @@ export const SWIPE_INTERVAL_MS = 16;
|
|
|
13
13
|
* taşıma bir satır eksik inerdi (inceleme bulgusu 2, oyun alanında `row-0 → row-2` → `reorder 0→1`).
|
|
14
14
|
*/
|
|
15
15
|
export const SWIPE_EDGE_INSET = 2;
|
|
16
|
+
/** g-05 (DD-10): `click`'in değer izi aldığı bileşen tipleri (`data-component-type`); öteki tıklamalar değişmez. */
|
|
17
|
+
const TOGGLE_COMPONENT_TYPES = ['checkbox', 'switch', 'radio'];
|
|
16
18
|
/**
|
|
17
19
|
* g-15 (K8) — `click`'in ikinci yarısı. Sayfa içi betik hedefi seçer ve basılacak noktayı (`press`) döndürür; basış
|
|
18
20
|
* gateway'den gerçek fare olayıyla yapılır, çünkü yalnız gerçek olay o noktada en üstteki öğeye iner ve telefondaki
|
|
@@ -68,6 +70,7 @@ export function actionScript(action, captureTarget = studioWebTarget) {
|
|
|
68
70
|
// çipin "kaldır" düğmesidir — eskiden ona basılıp seçim siliniyordu (37 S-18). Tek basışlı
|
|
69
71
|
// denetimin yüzeyi <id>__press'tir (ui-native press-role-guard), anahtarınki role="switch".
|
|
70
72
|
var press = document.querySelector(${JSON.stringify(`[data-element-id="${String(action.target ?? '')}${INTERNAL_ROLE_SEPARATOR}press"]`)});
|
|
73
|
+
var toggleRoot = document.querySelector(${JSON.stringify(`[data-element-id="${rootElementId(String(action.target ?? ''))}"]`)});
|
|
71
74
|
// g-11 incelemesi: önizleme penceresi (onay/uyarı/biyometri) açıkken altında kalan sayfa öğesine gerçek kullanıcı
|
|
72
75
|
// basamaz; DOM tıklaması basardı ve sayfa eylemi pencere yanıtlanmadan koşardı.
|
|
73
76
|
var shield = document.querySelector('${AWAITING_WINDOW_SELECTOR}');
|
|
@@ -116,7 +119,17 @@ export function actionScript(action, captureTarget = studioWebTarget) {
|
|
|
116
119
|
area.scrollIntoView({ block: 'center', inline: 'center' });
|
|
117
120
|
found = probe();
|
|
118
121
|
}
|
|
119
|
-
if (found.at)
|
|
122
|
+
if (found.at) {
|
|
123
|
+
var pressed = { found: true, applied: false, requests: count, press: { x: found.at.x, y: found.at.y, id: target.getAttribute('data-element-id') } };
|
|
124
|
+
// g-05 (DD-10): onay kutusu / anahtar / radyoda basış değerin değiştiğini kanıtlamaz — etiketin işleyicisiz
|
|
125
|
+
// Pressable'ı basışı yutuyordu ve adım "uygulandı" diyordu. Kökün prop izi basıştan önce alınır (toggle).
|
|
126
|
+
var kind = toggleRoot ? toggleRoot.getAttribute('data-component-type') : null;
|
|
127
|
+
if (${JSON.stringify(TOGGLE_COMPONENT_TYPES)}.indexOf(String(kind)) >= 0) {
|
|
128
|
+
pressed.toggle = true;
|
|
129
|
+
pressed.propsBefore = ${runtimePropsScript(rootElementId(String(action.target ?? '')))};
|
|
130
|
+
}
|
|
131
|
+
return pressed;
|
|
132
|
+
}
|
|
120
133
|
if (found.hidden || found.outside) {
|
|
121
134
|
return { found: true, applied: false, requests: count, note: "hedef görünmüyor (kutusu boş ya da kaydırınca da ekran dışında): gerçek kullanıcı ona basamaz, eylem uygulanmadı — görünürlüğü summaryText'ten okuyun" };
|
|
122
135
|
}
|
|
@@ -508,6 +521,35 @@ export function actionScript(action, captureTarget = studioWebTarget) {
|
|
|
508
521
|
}
|
|
509
522
|
|
|
510
523
|
var field = node.matches('input, select, textarea') ? node : node.querySelector('input, select, textarea');
|
|
524
|
+
// g-05 (DD-11): mobil onay kutusu ve anahtar native alan değil, role="checkbox"/"switch" div'idir (@rn-primitives,
|
|
525
|
+
// react-native-web). Durum aria-checked ya da data-state'ten okunur; istenenle aynıysa basılmaz, değilse kutunun
|
|
526
|
+
// kendisinin ortası döner, gateway gerçek fare olayıyla basar (pressPoint) ve prop izini karşılaştırır.
|
|
527
|
+
var toggle = field ? null : node.matches('[role="checkbox"], [role="switch"]') ? node : node.querySelector('[role="checkbox"], [role="switch"]');
|
|
528
|
+
if (toggle) {
|
|
529
|
+
var role = toggle.getAttribute('role');
|
|
530
|
+
var aria = toggle.getAttribute('aria-checked');
|
|
531
|
+
var dataState = toggle.getAttribute('data-state');
|
|
532
|
+
var state = aria === 'true' || aria === 'false' || aria === 'mixed' ? aria
|
|
533
|
+
: dataState === 'checked' ? 'true' : dataState === 'unchecked' ? 'false' : dataState === 'indeterminate' ? 'mixed' : null;
|
|
534
|
+
var wantedOn = wanted === 'true' || wanted === '1' || wanted === 'on';
|
|
535
|
+
if (state === null) return finish({ found: true, applied: false, requests: count, note: "role=" + role + " öğesi durumunu söylemiyor (aria-checked / data-state yok): değer okunamadı, eylem uygulanmadı — click ile basın" });
|
|
536
|
+
if (state === String(wantedOn)) return { found: true, applied: true, requests: count, note: "zaten " + (wantedOn ? 'işaretli' : 'işaretsiz') + ": basılmadı" };
|
|
537
|
+
if (state === 'mixed' && !wantedOn) return finish({ found: true, applied: false, requests: count, note: "kutu belirsiz (mixed): bir basış onu işaretli yapar, işaretsiz yapmaz — eylem uygulanmadı; önce set true, sonra set false" });
|
|
538
|
+
if (toggle.getAttribute('aria-disabled') === 'true' || toggle.disabled === true) return finish({ found: true, applied: false, requests: count, note: "role=" + role + " devre dışı (aria-disabled): basılmadı" });
|
|
539
|
+
var box = toggle.getBoundingClientRect();
|
|
540
|
+
if ((box.width <= 0 || box.height <= 0) || box.top < 0 || box.bottom > window.innerHeight) {
|
|
541
|
+
if (toggle.scrollIntoView) toggle.scrollIntoView({ block: 'center', inline: 'center' });
|
|
542
|
+
box = toggle.getBoundingClientRect();
|
|
543
|
+
}
|
|
544
|
+
if (box.width <= 0 || box.height <= 0) return finish({ found: true, applied: false, requests: count, note: "role=" + role + " görünmüyor (kutusu boş): gerçek kullanıcı ona basamaz, eylem uygulanmadı" });
|
|
545
|
+
var x = box.left + box.width / 2, y = box.top + box.height / 2;
|
|
546
|
+
var hit = document.elementFromPoint(x, y);
|
|
547
|
+
if (!hit || !toggle.contains(hit)) {
|
|
548
|
+
var cover = hit && hit.closest ? hit.closest('[data-element-id]') : null;
|
|
549
|
+
return finish({ found: true, applied: false, requests: count, coveredBy: cover ? String(cover.getAttribute('data-element-id')) : 'bilinmeyen öğe', note: "role=" + role + " öğesinin ortasında başka öğe var: basışı o alır, eylem uygulanmadı" });
|
|
550
|
+
}
|
|
551
|
+
return finish({ found: true, applied: false, requests: count, toggle: true, press: { x: x, y: y, id: toggle.getAttribute('data-element-id') } });
|
|
552
|
+
}
|
|
511
553
|
if (!field) return finish({ found: true, applied: false, note: 'düğümde input/select/textarea yok — bu komponent native alan kullanmıyor olabilir, click ile deneyin', requests: count });
|
|
512
554
|
var proto = field instanceof HTMLSelectElement ? HTMLSelectElement.prototype
|
|
513
555
|
: (field instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype);
|
|
@@ -9,19 +9,27 @@ import { createPageConsoleLog, describePageFailure, isExpressionEcho, parseRende
|
|
|
9
9
|
import { awaitingUserNote, decideReadiness, describeUnready, parseAwaitingWindow, parseReadiness, readinessScript, runtimePath } from './readiness.js';
|
|
10
10
|
/** Runtime'ın Connect Data bağlantısı için bastığı sözde akış kimliği: hata bir akış adımından değil bağlı prop'un okumasından gelir. */
|
|
11
11
|
const CONNECT_DATA_FLOW_ID = 'connect-data';
|
|
12
|
+
/** f-07 (derdini-dok DD-14): mobil runtime'ın önizlemede bıraktığı sınır kayıtları (ng-apps-ui-native `runtime-tasks.ts`). */
|
|
13
|
+
const PREVIEW_LIMIT_CODES = new Set(['share-unavailable', 'back-unavailable']);
|
|
12
14
|
/**
|
|
13
15
|
* `runtimeErrors` yanında dönen okuma notu. Bağlantı hatasının (`flowId: 'connect-data'`) açılacak akışı yoktur:
|
|
14
16
|
* not onu bağlantının araçlarına yönlendirir (39/M-18 — `flow_get` önerisi ajanı olmayan bir akışa götürüyordu).
|
|
15
17
|
*/
|
|
16
18
|
export function runtimeErrorsNote(errors) {
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
19
|
+
// g-08 (DD-14, K5): f-07'nin iki kaydı önizlemenin sınırıdır — paylaşım penceresi yok, yığın kökünde geri yok.
|
|
20
|
+
const limits = errors.filter(error => typeof error.code === 'string' && PREVIEW_LIMIT_CODES.has(error.code));
|
|
21
|
+
const real = errors.filter(error => !limits.includes(error));
|
|
22
|
+
const connections = real.filter(error => error.flowId === CONNECT_DATA_FLOW_ID);
|
|
23
|
+
const flows = real.length - connections.length;
|
|
24
|
+
const head = real.length > 0 ? `Sayfa ${real.length} yapısal hata bıraktı; kare 'çalışıyor' görünse bile bu adımlar işini YAPMADI. element/property alanı hangi komponentin hangi prop'unun yazılamadığını söyler — o komponent eski/boş değerindedir.` : '';
|
|
20
25
|
const flowHint = flows > 0 ? ` Akış hatasında (${flows}) adımı flow_get ile açıp ifadeyi düzeltin.` : '';
|
|
21
26
|
const connectionHint = connections.length > 0
|
|
22
27
|
? ` Bağlantı hatasında (flowId 'connect-data': ${connections.map(error => `${error.element}.${error.property}`).join(', ')}) akış yoktur: code alanı reddin nedenidir — connect_data_get ile tanımı, connect_data_execute { op: 'list', asUserId } ile aynı isteği görün (kompleks projede 403 çoğunlukla kaynağın grant'i ya da ACC-005).`
|
|
23
28
|
: '';
|
|
24
|
-
|
|
29
|
+
const limitHint = limits.length > 0
|
|
30
|
+
? ` ${[...new Set(limits.map(error => error.code))].join(' / ')} kayıtları (${limits.length}) önizleme sınırı, hata değil: önizlemede paylaşım penceresi ve yığın kökünde geri yoktur. Davranışı cihazda doğrulayın (previewLimits).`
|
|
31
|
+
: '';
|
|
32
|
+
return `${head}${flowHint}${connectionHint}${limitHint}`.trim();
|
|
25
33
|
}
|
|
26
34
|
/**
|
|
27
35
|
* Ziyaretçinin tema tercihinin yaşadığı localStorage anahtarı — `theme-toggle` bunu yazar,
|
|
@@ -162,6 +170,46 @@ const navigationAttempts = 2;
|
|
|
162
170
|
/** g-12 oturumları: depo durumu çerez (jeton dahil) taşıdığı için diske değil süreç belleğine yazılır. */
|
|
163
171
|
const sessionTtlMs = 30 * 60_000;
|
|
164
172
|
const maxSessions = 8;
|
|
173
|
+
/**
|
|
174
|
+
* g-07 (DD-12, derdini-dok 2026-11-05): önizleme `secure` state'i sessionStorage'a yazar (kök ADR 0004,
|
|
175
|
+
* `browser-state-stores.ts`); Playwright `storageState` onu taşımaz ve sekme kapanınca ölür. Oturum kaydedilirken
|
|
176
|
+
* açık sayfadan okunur.
|
|
177
|
+
*/
|
|
178
|
+
export const sessionStorageSnapshotScript = `(function () { /* sessionStorageSnapshot */
|
|
179
|
+
try {
|
|
180
|
+
var entries = [];
|
|
181
|
+
for (var index = 0; index < sessionStorage.length; index++) {
|
|
182
|
+
var key = sessionStorage.key(index);
|
|
183
|
+
if (key !== null) entries.push([key, sessionStorage.getItem(key)]);
|
|
184
|
+
}
|
|
185
|
+
return { origin: location.origin, entries: entries };
|
|
186
|
+
} catch (error) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
})()`;
|
|
190
|
+
export function parseSessionStorageSnapshot(value) {
|
|
191
|
+
if (!value || typeof value !== 'object')
|
|
192
|
+
return undefined;
|
|
193
|
+
const { origin, entries } = value;
|
|
194
|
+
if (typeof origin !== 'string' || !origin.startsWith('http') || !Array.isArray(entries))
|
|
195
|
+
return undefined;
|
|
196
|
+
const pairs = entries.filter((entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === 'string' && typeof entry[1] === 'string');
|
|
197
|
+
return { origin, entries: pairs };
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Geri yükleme sayfanın script'lerinden ÖNCE koşar (tema ekmenin kalıbı). Yalnız kaydedilen kökende ve sekmenin
|
|
201
|
+
* sessionStorage'ı BOŞKEN yazar: sayfa kendi içinde yeniden yüklenirse init script yeniden koşar ve çekim sırasında
|
|
202
|
+
* değişen değeri eski kayıtla ezmemelidir.
|
|
203
|
+
*/
|
|
204
|
+
export function sessionStorageRestoreScript(snapshot) {
|
|
205
|
+
return `(function () {
|
|
206
|
+
try {
|
|
207
|
+
if (location.origin !== ${JSON.stringify(snapshot.origin)} || sessionStorage.length > 0) return;
|
|
208
|
+
var entries = ${JSON.stringify(snapshot.entries)};
|
|
209
|
+
for (var index = 0; index < entries.length; index++) sessionStorage.setItem(entries[index][0], entries[index][1]);
|
|
210
|
+
} catch (error) { /* sessionStorage kapalıysa sayfa güvenli depoyu boş görür */ }
|
|
211
|
+
})()`;
|
|
212
|
+
}
|
|
165
213
|
/**
|
|
166
214
|
* Yalnız zaman aşımı yeniden denenir. `net::ERR_CONNECTION_REFUSED` / DNS gibi hızlı düşen
|
|
167
215
|
* hatalarda Studio ayakta değildir; tekrar yalnız bekleme süresini iki katına çıkarır ve
|
|
@@ -335,7 +383,8 @@ export class StudioScreenshotter {
|
|
|
335
383
|
return { found: true, applied: true, requests: typeof count === 'number' ? count : 0, ...(typeof online === 'boolean' ? { online } : {}) };
|
|
336
384
|
})()
|
|
337
385
|
: await page.evaluate(actionScript(action, request.target))
|
|
338
|
-
|
|
386
|
+
// g-05: `set` de onay kutusunun/anahtarın kendisine gerçek fare olayıyla basar (role=checkbox div'i native alan değil).
|
|
387
|
+
.then(result => action.action === 'click' || action.action === 'set' ? pressPoint(page, result) : result)
|
|
339
388
|
.catch(error => ({
|
|
340
389
|
found: false,
|
|
341
390
|
applied: false,
|
|
@@ -398,9 +447,11 @@ export class StudioScreenshotter {
|
|
|
398
447
|
const applied = before.applied === true && propWritten !== false;
|
|
399
448
|
// g-11: eylem bir önizleme penceresi açtıysa (onay, uyarı, biyometri) sıradaki eylemin neye basacağı burada söylenir.
|
|
400
449
|
const awaitingNote = readiness.state === 'awaiting-user' ? awaitingUserNote(readiness.snapshot?.awaitingWindow) : undefined;
|
|
401
|
-
const note = propWritten === false
|
|
402
|
-
? `değer
|
|
403
|
-
:
|
|
450
|
+
const note = propWritten === false && before.toggle === true
|
|
451
|
+
? `basıldı ama değer değişmedi (etiket ya da üst öğe basışı yuttu) — '${rootElementId(String(action.target ?? ''))}' düğümünün runtime prop'ları aynı kaldı (radyoda seçenek zaten seçiliyse beklenir). Onay kutusu/anahtarı { action: 'set', value: true|false } kutunun kendisine basarak işaretler; telefonda da aynı nokta yutuyor olabilir.`
|
|
452
|
+
: propWritten === false
|
|
453
|
+
? `değer DOM'a yazıldı ama '${rootElementId(String(action.target ?? ''))}' düğümünün runtime prop'ları DEĞİŞMEDİ — bileşen olayı kendi change yoluna çevirmedi ya da değer zaten aynıydı. Çok alanlı bileşende <elementId>__<rol> kutusunu hedefleyin (component_get → internalRoles).`
|
|
454
|
+
: [before.note, awaitingNote].filter((part) => part !== undefined && part !== '').join(' ') || undefined;
|
|
404
455
|
outcomes.push({
|
|
405
456
|
index,
|
|
406
457
|
action: String(action.action),
|
|
@@ -519,6 +570,7 @@ export class StudioScreenshotter {
|
|
|
519
570
|
// Oturum depoyu bir kez kaydeder: başarılı yolda yanıttan önce, hata yolunda `finally`'de. Yükleme yarıda kaldıysa
|
|
520
571
|
// (`setStorageState` önce siler, sonra yazar) yarı boş depo iyi kaydın üstüne yazılmaz (g-12 inceleme #6).
|
|
521
572
|
let sessionPending = request.session !== undefined;
|
|
573
|
+
let openPage;
|
|
522
574
|
// Okunamayan depo eski kaydı BIRAKMAZ: bırakılsaydı sonraki çekim aradaki yazmaları sessizce kaybeden eski depoyu
|
|
523
575
|
// `sessionRestored: true` ile yüklerdi (g-12 inceleme #5).
|
|
524
576
|
const saveSession = async () => {
|
|
@@ -529,7 +581,11 @@ export class StudioScreenshotter {
|
|
|
529
581
|
this.sessions.delete(request.session);
|
|
530
582
|
if (state === undefined)
|
|
531
583
|
return false;
|
|
532
|
-
|
|
584
|
+
// sessionStorage sekmeyle ölür: sayfa KAPANMADAN okunur. Okunamazsa oturum depo durumuyla sürer.
|
|
585
|
+
const snapshot = openPage === undefined
|
|
586
|
+
? undefined
|
|
587
|
+
: parseSessionStorageSnapshot(await openPage.evaluate(sessionStorageSnapshotScript).catch(() => undefined));
|
|
588
|
+
this.sessions.set(request.session, { state, ...(snapshot !== undefined && snapshot.entries.length > 0 ? { sessionStorage: snapshot } : {}), at: Date.now() });
|
|
533
589
|
for (const [key, entry] of this.sessions) {
|
|
534
590
|
if (Date.now() - entry.at > sessionTtlMs || this.sessions.size > maxSessions)
|
|
535
591
|
this.sessions.delete(key);
|
|
@@ -555,6 +611,14 @@ export class StudioScreenshotter {
|
|
|
555
611
|
sessionPending = false;
|
|
556
612
|
throw error;
|
|
557
613
|
}
|
|
614
|
+
const carried = sessionRestored ? saved?.sessionStorage : undefined;
|
|
615
|
+
if (carried !== undefined) {
|
|
616
|
+
if (!context.addInitScript) {
|
|
617
|
+
sessionPending = false;
|
|
618
|
+
throw new PlatformApiError(`session='${request.session.split('|')[0]}' güvenli depoyu (sessionStorage) geri yükleyemiyor: tarayıcı bağlamı addInitScript desteklemiyor. Kare güvenli deposu boş çekilirdi ve bu sessizce yanlış olurdu.`);
|
|
619
|
+
}
|
|
620
|
+
await context.addInitScript(sessionStorageRestoreScript(carried));
|
|
621
|
+
}
|
|
558
622
|
}
|
|
559
623
|
const cookies = new Map();
|
|
560
624
|
if (request.token)
|
|
@@ -583,6 +647,7 @@ export class StudioScreenshotter {
|
|
|
583
647
|
await context.addInitScript(`try { localStorage.setItem(${JSON.stringify(VIEWER_MODE_STORAGE_KEY)}, ${JSON.stringify(request.colorScheme)}) } catch (error) { /* localStorage kapalıysa proje varsayılanı çizilir */ }`);
|
|
584
648
|
}
|
|
585
649
|
const page = await context.newPage();
|
|
650
|
+
openPage = page;
|
|
586
651
|
// Konsol ve istisna dinleyicileri navigasyondan ÖNCE takılır: modül yüklenirken patlayan
|
|
587
652
|
// bileşenin hatası ilk karede düşer ve sonradan takılan dinleyici onu kaçırırdı (g-06).
|
|
588
653
|
const consoleLog = createPageConsoleLog();
|
|
@@ -592,9 +657,12 @@ export class StudioScreenshotter {
|
|
|
592
657
|
// bütçeyi de uzatır (09-02 E-2). Yanıt hazırlık döngüsünü BLOKLAMAZ: runtime dışına
|
|
593
658
|
// yönlendirilen sayfa bu isteği hiç atmaz ve eskiden 15 sn boşa bekleniyordu.
|
|
594
659
|
const readyBudgetMs = apiResponseTimeoutMs + request.delayMs;
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
.
|
|
660
|
+
let observedPagePackage = Promise.resolve(undefined);
|
|
661
|
+
const watchApiResponse = () => {
|
|
662
|
+
const observed = page.waitForResponse(response => response.url().includes(request.apiPathMarker), { timeout: readyBudgetMs });
|
|
663
|
+
observedPagePackage = observed.then(response => response.json?.(), () => undefined).catch(() => undefined);
|
|
664
|
+
return observed.then(response => response.status(), () => undefined);
|
|
665
|
+
};
|
|
598
666
|
// `delayMs` navigasyon bütçesini de uzatır. Eskiden sabit 20 sn'ydi ve soğuk Studio'da
|
|
599
667
|
// ajanın elinde tek çıkış çağrıyı tekrarlamaktı (09-08 S-8) — "sabrım bu kadar" demenin
|
|
600
668
|
// tek anlamı olsun diye iki bütçe de aynı düğmeye bağlı.
|
|
@@ -708,6 +776,8 @@ export class StudioScreenshotter {
|
|
|
708
776
|
logStep('akış hatası ✕', `${runtimeErrors.length} akış adımı hata bıraktı — sayfa yine 200 döndü`, runtimeErrors.map(error => `${error.step?.name ?? '?'}${error.element ? ` → ${error.element}.${error.property ?? '?'}` : ''}: ${error.message ?? ''}`));
|
|
709
777
|
}
|
|
710
778
|
const sessionSaved = await saveSession();
|
|
779
|
+
// İstek gözlendiyse gövde okunabilir durumdadır; gözlenmediyse bekleme vaadi hâlâ açık olabilir, beklenmez.
|
|
780
|
+
const pagePackage = apiStatus === undefined ? undefined : await observedPagePackage;
|
|
711
781
|
return {
|
|
712
782
|
...(png === undefined ? {} : { png, mimeType: format === 'jpeg' ? 'image/jpeg' : 'image/png' }),
|
|
713
783
|
...(png === undefined ? {} : (size => size === undefined ? {} : { imageSize: size })(imageSize(png))),
|
|
@@ -733,7 +803,8 @@ export class StudioScreenshotter {
|
|
|
733
803
|
...(flowsSettled === undefined ? {} : { flowsSettled }),
|
|
734
804
|
...(navigationRetried ? { navigationRetried: true } : {}),
|
|
735
805
|
...(sessionRestored === undefined ? {} : { sessionRestored }),
|
|
736
|
-
...(sessionSaved ? {} : { sessionSaved: false })
|
|
806
|
+
...(sessionSaved ? {} : { sessionSaved: false }),
|
|
807
|
+
...(pagePackage === undefined ? {} : { pagePackage })
|
|
737
808
|
};
|
|
738
809
|
}
|
|
739
810
|
finally {
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { lstat, open, realpath, stat } from 'node:fs/promises';
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
4
|
+
import { PlatformApiError } from './errors.js';
|
|
5
|
+
const readChunkBytes = 64 * 1024;
|
|
6
|
+
/** Göreli yolun çözüldüğü kök: MCP_INPUT_DIR, tanımsızsa çalışma dizini. */
|
|
7
|
+
export function localBase(config) {
|
|
8
|
+
return config.inputDirectory ? { source: 'MCP_INPUT_DIR', path: resolve(config.inputDirectory) } : { source: 'cwd', path: process.cwd() };
|
|
9
|
+
}
|
|
10
|
+
/** MCP_INPUT_DIR önce gelir: dosya iki kökün de altındaysa yanıt ajanın bildiği kökü söyler. Kökler gerçek yollarıdır. */
|
|
11
|
+
export async function allowedRoots(config) {
|
|
12
|
+
const candidates = [
|
|
13
|
+
...(config.inputDirectory ? [{ source: 'MCP_INPUT_DIR', path: config.inputDirectory }] : []),
|
|
14
|
+
{ source: 'cwd', path: process.cwd() }
|
|
15
|
+
];
|
|
16
|
+
const resolved = await Promise.all(candidates.map(async (root) => ({ source: root.source, path: await realpath(resolve(root.path)).catch(() => undefined) })));
|
|
17
|
+
return resolved.filter((root) => root.path !== undefined);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Yalnız-okuma kökü (inceleme 2026-11-05): gateway'in KENDİ çıktı klasörü (ör. `mobile_asset_preview` kartları,
|
|
21
|
+
* `storeArtRoot`) ajanın okuma köklerine eklenir ama yazma kapısına girmez. Klasör süreç sahibinindir ve grup/herkes
|
|
22
|
+
* yazamaz — başkasının açabildiği bir klasör (paylaşılan /tmp) okuma kökü olmaz; köke özgü uzantı sınırı orada başka
|
|
23
|
+
* dosyanın (deck.json, index.html) okunmasını önler. Koşul tutmuyorsa ya da klasör yoksa `undefined`.
|
|
24
|
+
*/
|
|
25
|
+
export async function privateReadRoot(source, path, extensions) {
|
|
26
|
+
const real = await realpath(resolve(path)).catch(() => undefined);
|
|
27
|
+
if (real === undefined)
|
|
28
|
+
return undefined;
|
|
29
|
+
const info = await stat(real).catch(() => undefined);
|
|
30
|
+
const owner = process.getuid?.();
|
|
31
|
+
if (!info?.isDirectory() || (owner !== undefined && info.uid !== owner) || (info.mode & 0o022) !== 0)
|
|
32
|
+
return undefined;
|
|
33
|
+
return { source, path: real, extensions };
|
|
34
|
+
}
|
|
35
|
+
function rootOf(real, roots) {
|
|
36
|
+
return roots.find(candidate => real === candidate.path || real.startsWith(`${candidate.path}${sep}`));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* İnceleme 2026-11-05 (g-12 sertleştirmesi): çalışma dizini repo köküdür; `.env*` gateway'in parolalarını ve uç
|
|
40
|
+
* adreslerini, `.mcp.json` ile `.claude/` ajanın kendi ayar ve izinlerini, `.git/` depo kancalarını taşır. Kök
|
|
41
|
+
* içinde olsalar da okunmaz ve yazılmaz — ajan kendi sırrını platforma yükleyemez, kendi iznini genişletemez.
|
|
42
|
+
*/
|
|
43
|
+
const protectedSegments = new Set(['.git', '.claude', '.mcp.json']);
|
|
44
|
+
function protectedPath(real, root) {
|
|
45
|
+
return relative(root.path, real).split(sep).some(segment => protectedSegments.has(segment) || segment.startsWith('.env'));
|
|
46
|
+
}
|
|
47
|
+
function protectedMessage(tool, label, verb, real) {
|
|
48
|
+
return `${tool}: ${label} korunan yol — ${real}. Gateway .env*, .git/, .claude/ ve .mcp.json altındaki dosyaları ${verb === 'okur' ? 'okumaz' : 'yazmaz'} (sır, depo kancası ve ajan ayarı taşırlar); dosyayı başka bir yere kopyalayıp o yolu verin. İstek gönderilmedi.`;
|
|
49
|
+
}
|
|
50
|
+
function outsideMessage(tool, label, verb, real, given, config, roots) {
|
|
51
|
+
// İnceleme 2026-11-05: tanımlı ama olmayan MCP_INPUT_DIR kök listesinden sessizce düşüyordu; mesaj "dışında" deyip
|
|
52
|
+
// klasörün yokluğunu saklıyordu.
|
|
53
|
+
const inputDirectory = config.inputDirectory === undefined
|
|
54
|
+
? "MCP_INPUT_DIR'in (tanımsız)"
|
|
55
|
+
: roots.some(root => root.source === 'MCP_INPUT_DIR')
|
|
56
|
+
? `MCP_INPUT_DIR'in (${config.inputDirectory})`
|
|
57
|
+
: `MCP_INPUT_DIR'in — DİKKAT: .env'deki MCP_INPUT_DIR klasörü yok (${resolve(config.inputDirectory)}), kök sayılmadı; klasörü açın ya da yolu düzeltin —`;
|
|
58
|
+
return `${tool}: ${label} izinli dizinlerin dışında — ${real}${real !== given ? ` (${given} bağının hedefi)` : ''}. Gateway yalnız çalışma dizininin (${process.cwd()}) ve .env'deki ${inputDirectory} altındaki dosyaları ${verb}; başka bir klasör gerekiyorsa insan .env'de MCP_INPUT_DIR'i ayarlar. İstek gönderilmedi.`;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Okuma kapısı: uzantı (yol ve bağın hedefi), izinli kök, düzenli dosya ve bayt sınırı. O_NONBLOCK FIFO'nun çağrıyı
|
|
62
|
+
* bekletmesini önler; boyut dosyanın büyüklüğüne değil okunan bayta bakar.
|
|
63
|
+
*
|
|
64
|
+
* `realpath` ile `open` atomik DEĞİLDİR: O_NOFOLLOW yalnız SON bileşenin sonradan bağa çevrilmesini önler, yolun
|
|
65
|
+
* ortasındaki bir klasör denetimden sonra dışarıyı gösteren bağa çevrilirse `open` dışarıdaki dosyayı açar (g-22
|
|
66
|
+
* incelemesi, `test/body-file-race.test.ts`). Açtıktan sonra tutamacın aygıt/düğümü yolun taze `stat`'ıyla
|
|
67
|
+
* karşılaştırılır ve `realpath` yeniden koşturulur: yol aynı yere çözülmüyor ya da izinli kökün dışına düşüyorsa okuma
|
|
68
|
+
* reddedilir. Bu pencereyi DARALTIR, kapatmaz — iki denetim arasında geri çevrilen bir bağ yine görülmez; tam çözüm
|
|
69
|
+
* (`openat2` RESOLVE_BENEATH) Node'da yoktur. Okunan bayt yine de açılan tutamaçtan gelir.
|
|
70
|
+
*/
|
|
71
|
+
export async function readLocalFile(tool, path, options, config, roots) {
|
|
72
|
+
const { label, extensions, maxBytes } = options;
|
|
73
|
+
const absolute = resolve(localBase(config).path, path);
|
|
74
|
+
const accepted = extensions?.join(', ');
|
|
75
|
+
if (extensions && !extensions.includes(extname(absolute).toLowerCase())) {
|
|
76
|
+
throw new PlatformApiError(`${tool}: ${label} yalnız ${accepted} okur — verilen: ${absolute}. İstek gönderilmedi.`, 400);
|
|
77
|
+
}
|
|
78
|
+
let real;
|
|
79
|
+
try {
|
|
80
|
+
real = await realpath(absolute);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
const missingInput = config.inputDirectory !== undefined && await realpath(resolve(config.inputDirectory)).then(() => false, () => true);
|
|
84
|
+
throw new PlatformApiError(`${tool}: ${label} okunamadı — ${absolute} (${error instanceof Error ? error.message : String(error)}). Yol gateway sürecinin çalıştığı makineye göre çözülür; göreli yol MCP_INPUT_DIR'e (tanımsızsa çalışma dizinine) göre.${missingInput ? ` .env'deki MCP_INPUT_DIR klasörü yok (${resolve(config.inputDirectory)}).` : ''} İstek gönderilmedi.`, 400);
|
|
85
|
+
}
|
|
86
|
+
if (extensions && !extensions.includes(extname(real).toLowerCase())) {
|
|
87
|
+
throw new PlatformApiError(`${tool}: ${label} hedefi ${accepted} değil — ${real} (${absolute} bağının hedefi). İstek gönderilmedi.`, 400);
|
|
88
|
+
}
|
|
89
|
+
const candidates = roots ?? await allowedRoots(config);
|
|
90
|
+
const root = rootOf(real, candidates);
|
|
91
|
+
if (!root)
|
|
92
|
+
throw new PlatformApiError(outsideMessage(tool, label, 'okur', real, absolute, config, candidates), 400);
|
|
93
|
+
if (protectedPath(real, root))
|
|
94
|
+
throw new PlatformApiError(protectedMessage(tool, label, 'okur', real), 400);
|
|
95
|
+
if (root.extensions && !root.extensions.includes(extname(real).toLowerCase())) {
|
|
96
|
+
throw new PlatformApiError(`${tool}: ${label} ${root.path} altında yalnız ${root.extensions.join(', ')} okunur — verilen: ${real}. Bu klasör gateway'in kendi çıktısıdır. İstek gönderilmedi.`, 400);
|
|
97
|
+
}
|
|
98
|
+
let handle;
|
|
99
|
+
try {
|
|
100
|
+
handle = await open(real, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
throw new PlatformApiError(`${tool}: ${label} açılamadı — ${real} (${error instanceof Error ? error.message : String(error)}). İstek gönderilmedi.`, 400);
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const info = await handle.stat();
|
|
107
|
+
if (!info.isFile()) {
|
|
108
|
+
throw new PlatformApiError(`${tool}: ${label} düzenli dosya değil — ${real}. İstek gönderilmedi.`, 400);
|
|
109
|
+
}
|
|
110
|
+
const fresh = await stat(real).catch(() => undefined);
|
|
111
|
+
const again = await realpath(absolute).catch(() => undefined);
|
|
112
|
+
const stillInside = again !== undefined && (again === root.path || again.startsWith(`${root.path}${sep}`));
|
|
113
|
+
if (!fresh || fresh.dev !== info.dev || fresh.ino !== info.ino || again !== real || !stillInside) {
|
|
114
|
+
throw new PlatformApiError(`${tool}: ${label} yolu denetimden sonra değişti — ${real} artık ${again ?? 'çözülemeyen bir yere'} gösteriyor (araya bir bağ girdi). Okunmadı. İstek gönderilmedi.`, 400);
|
|
115
|
+
}
|
|
116
|
+
// Tek `read` dosyanın tamamını döndürmek zorunda değildir; EOF'a ya da sınırın bir baytı ötesine kadar parça parça
|
|
117
|
+
// okunur. Sınır kadar tampon baştan ayrılmaz: 50 MB sınırlı satır dosyası küçük dosyada 50 MB ayırırdı.
|
|
118
|
+
const chunks = [];
|
|
119
|
+
let bytesRead = 0;
|
|
120
|
+
while (bytesRead <= maxBytes) {
|
|
121
|
+
const chunk = Buffer.alloc(Math.min(readChunkBytes, maxBytes + 1 - bytesRead));
|
|
122
|
+
const { bytesRead: count } = await handle.read(chunk, 0, chunk.length, bytesRead);
|
|
123
|
+
if (count === 0)
|
|
124
|
+
break;
|
|
125
|
+
chunks.push(chunk.subarray(0, count));
|
|
126
|
+
bytesRead += count;
|
|
127
|
+
}
|
|
128
|
+
if (bytesRead > maxBytes) {
|
|
129
|
+
const reason = options.tooLarge?.(real, info.size) ?? `${maxBytes} B sınırını aşıyor — ${real}.`;
|
|
130
|
+
throw new PlatformApiError(`${tool}: ${label} ${reason} İstek gönderilmedi.`, 400);
|
|
131
|
+
}
|
|
132
|
+
return { real, root, buffer: Buffer.concat(chunks, bytesRead) };
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
await handle.close();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Yazma kapısı: hedef yolun var olan en yakın atası (ve dosya varsa kendisi, bağ çözülerek) izinli kökün altında
|
|
140
|
+
* olmalıdır. Dönen yol çağıranın verdiği yolun mutlak hâlidir (yanıtta ajanın tanıdığı yol görünsün); son bileşen bir
|
|
141
|
+
* bağsa bağın kökteki gerçek hedefidir — yazıcı (`writeLocalOutput`) bağ izlemez. Klasörü açmak ve yazmak çağıranındır;
|
|
142
|
+
* yazma `writeLocalOutput` ile yapılır. Okuma kapısının yarış notu burada da geçerlidir: denetimle yazma arasında atası
|
|
143
|
+
* bağa çevrilen yol görülmez.
|
|
144
|
+
*
|
|
145
|
+
* İnceleme 2026-11-05: son bileşeni hedefi olmayan (sarkık) bir bağ olan yolun `realpath`'i ENOENT verir; eski kapı ata
|
|
146
|
+
* yürüyüşüne düşüp bağ adını kökte sayıyordu ve `writeFile` bağı izleyip kök dışında dosya açıyordu. Son bileşen
|
|
147
|
+
* `lstat` ile okunur: bağsa hedefi çözülmeli ve kökte olmalıdır.
|
|
148
|
+
*/
|
|
149
|
+
export async function resolveLocalOutput(tool, label, path, config) {
|
|
150
|
+
const absolute = resolve(localBase(config).path, path);
|
|
151
|
+
const roots = await allowedRoots(config);
|
|
152
|
+
const link = (await lstat(absolute).catch(() => undefined))?.isSymbolicLink() === true;
|
|
153
|
+
const existing = await realpath(absolute).catch(() => undefined);
|
|
154
|
+
if (link && existing === undefined) {
|
|
155
|
+
throw new PlatformApiError(`${tool}: ${label} hedefi olmayan bir bağ — ${absolute}. Gateway bağın gösterdiği yere yazmaz (bağ kök dışını gösterebilir); bağı kaldırın ya da başka bir yol verin. İstek gönderilmedi.`, 400);
|
|
156
|
+
}
|
|
157
|
+
if (existing !== undefined) {
|
|
158
|
+
const root = rootOf(existing, roots);
|
|
159
|
+
if (!root)
|
|
160
|
+
throw new PlatformApiError(outsideMessage(tool, label, 'yazar', existing, absolute, config, roots), 400);
|
|
161
|
+
if (protectedPath(existing, root))
|
|
162
|
+
throw new PlatformApiError(protectedMessage(tool, label, 'yazar', existing), 400);
|
|
163
|
+
return link ? existing : absolute;
|
|
164
|
+
}
|
|
165
|
+
const missing = [basename(absolute)];
|
|
166
|
+
let ancestor = dirname(absolute);
|
|
167
|
+
for (;;) {
|
|
168
|
+
const real = await realpath(ancestor).catch(() => undefined);
|
|
169
|
+
if (real !== undefined) {
|
|
170
|
+
const target = join(real, ...missing);
|
|
171
|
+
const root = rootOf(target, roots);
|
|
172
|
+
if (!root)
|
|
173
|
+
throw new PlatformApiError(outsideMessage(tool, label, 'yazar', target, absolute, config, roots), 400);
|
|
174
|
+
if (protectedPath(target, root))
|
|
175
|
+
throw new PlatformApiError(protectedMessage(tool, label, 'yazar', target), 400);
|
|
176
|
+
return absolute;
|
|
177
|
+
}
|
|
178
|
+
const parent = dirname(ancestor);
|
|
179
|
+
if (parent === ancestor || !isAbsolute(parent))
|
|
180
|
+
throw new PlatformApiError(`${tool}: ${label} çözülemedi — ${absolute}. İstek gönderilmedi.`, 400);
|
|
181
|
+
missing.unshift(basename(ancestor));
|
|
182
|
+
ancestor = parent;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* `resolveLocalOutput`'tan geçmiş yola yazar. O_NOFOLLOW: denetimden sonra son bileşen bağa çevrilmişse açılış ELOOP ile
|
|
187
|
+
* düşer, bağ izlenmez; O_NONBLOCK okuyucusuz FIFO'da bekletmez (ENXIO). Klasör açmak çağıranındır.
|
|
188
|
+
*/
|
|
189
|
+
export async function writeLocalOutput(absolute, data) {
|
|
190
|
+
const handle = await open(absolute, constants.O_WRONLY | constants.O_CREAT | constants.O_TRUNC | constants.O_NOFOLLOW | constants.O_NONBLOCK, 0o666);
|
|
191
|
+
try {
|
|
192
|
+
await handle.writeFile(data);
|
|
193
|
+
}
|
|
194
|
+
finally {
|
|
195
|
+
await handle.close();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -228,7 +228,7 @@ export function toolError(error, expectFailure) {
|
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
230
|
export function handle(config, run) {
|
|
231
|
-
return async (args) => {
|
|
231
|
+
return async (args, extra) => {
|
|
232
232
|
try {
|
|
233
233
|
// Tool'un kendi input şeması `expectFailure: z.boolean().optional()` taşıyorsa (ör.
|
|
234
234
|
// microservice_execute, automation_preview) burada otomatik okunur ve toolResult'a geçirilir
|
|
@@ -236,7 +236,7 @@ export function handle(config, run) {
|
|
|
236
236
|
// aracının plansız hata oranını şişirmez. Şemasında bu alan olmayan tool'larda args'ta
|
|
237
237
|
// anahtar hiç bulunmaz, davranış değişmez.
|
|
238
238
|
const expectFailure = args?.expectFailure === true;
|
|
239
|
-
return toolResult(await run(args), config, expectFailure);
|
|
239
|
+
return toolResult(await run(args, extra), config, expectFailure);
|
|
240
240
|
}
|
|
241
241
|
catch (error) {
|
|
242
242
|
return toolError(error, args?.expectFailure === true);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { COLOR_PATTERN, SCREENSHOT_CAPTURE_DEVICES } from '../../knowledge/mobileStore.js';
|
|
5
5
|
import { PlatformApiError } from '../errors.js';
|
|
6
|
+
import { readLocalFile } from '../localFiles.js';
|
|
6
7
|
import { imageSize } from '../capture/capture.js';
|
|
7
8
|
import { LAYOUT_IDS, STORE_ART_LAYOUTS } from './layouts.js';
|
|
8
9
|
import { STYLE_IDS } from './styles.js';
|
|
@@ -17,6 +18,11 @@ export const SUBTITLE_MAX = 140;
|
|
|
17
18
|
export const EYEBROW_MAX = 30;
|
|
18
19
|
export const MAX_STYLES = 4;
|
|
19
20
|
export const MAX_CARDS = 40;
|
|
21
|
+
/**
|
|
22
|
+
* g-12: ham kare okuma kapısının sınırı. Ham kare yüklenmez (yüklenen çizilen karttır, 10 MB), yalnız çizime girer;
|
|
23
|
+
* page_screenshot'ın en büyük cihaz karesi (ipad13 PNG) bunun çok altındadır.
|
|
24
|
+
*/
|
|
25
|
+
const RAW_FRAME_MAX_BYTES = 25 * 1024 * 1024;
|
|
20
26
|
const defaultStyles = ['clean'];
|
|
21
27
|
const aspectTolerance = 0.01;
|
|
22
28
|
const pad = (value) => String(value).padStart(2, '0');
|
|
@@ -49,26 +55,27 @@ export function parseCardSpec(deck, value) {
|
|
|
49
55
|
return { error: `layout: '${spec.layout}' ham kare ister — raw verin ya da 'text' seçin` };
|
|
50
56
|
return { spec };
|
|
51
57
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
/**
|
|
59
|
+
* g-12 (DD-23): ham kare izinli köklerden okunur (localFiles) — page_screenshot `outPath` aynı köklere yazar. Okunan
|
|
60
|
+
* bayt galeri dizinine yazılır; yol ikinci kez açılmaz (kapıdan sonra bağa çevrilen yol kopyalanamaz).
|
|
61
|
+
*/
|
|
62
|
+
async function readSlideSource(config, source, index) {
|
|
63
|
+
const { real, buffer: bytes } = await readLocalFile('mobile_asset_preview', source, {
|
|
64
|
+
label: `slides[${index}].path`,
|
|
65
|
+
maxBytes: RAW_FRAME_MAX_BYTES,
|
|
66
|
+
tooLarge: (file, size) => `${size} B, ham kare sınırı ${RAW_FRAME_MAX_BYTES} B — ${file}. Hiçbir kare çizilmedi.`
|
|
67
|
+
}, config);
|
|
61
68
|
const size = imageSize(bytes);
|
|
62
69
|
if (size === undefined) {
|
|
63
|
-
throw new PlatformApiError(`mobile_asset_preview: slides[${index}].path PNG ya da JPEG değil — ${
|
|
70
|
+
throw new PlatformApiError(`mobile_asset_preview: slides[${index}].path PNG ya da JPEG değil — ${real}. Ham kareyi page_screenshot { format: 'jpeg', outPath } ile üretin. Hiçbir kare çizilmedi.`, 400);
|
|
64
71
|
}
|
|
65
|
-
return {
|
|
72
|
+
return { real, bytes, size, png: bytes[0] === 0x89 };
|
|
66
73
|
}
|
|
67
74
|
/**
|
|
68
75
|
* Araç girdisinden desteyi kurar: ham kareleri doğrular ve galeri dizinine kopyalar, kartları kare sırasıyla
|
|
69
76
|
* (her karenin stilleri yan yana) dizer — deste sırası yükleme sırasıdır.
|
|
70
77
|
*/
|
|
71
|
-
export async function buildDeck(input, directory) {
|
|
78
|
+
export async function buildDeck(input, directory, config) {
|
|
72
79
|
const styles = input.styles ?? defaultStyles;
|
|
73
80
|
if (new Set(styles).size !== styles.length) {
|
|
74
81
|
throw new PlatformApiError(`mobile_asset_preview: styles tekrar ediyor (${styles.join(', ')}) — her stil bir kez verilir. Hiçbir kare çizilmedi.`, 400);
|
|
@@ -81,7 +88,7 @@ export async function buildDeck(input, directory) {
|
|
|
81
88
|
if (slide.path === undefined) {
|
|
82
89
|
throw new PlatformApiError(`mobile_asset_preview: slides[${index}].path gerekli — '${layout}' yerleşimi ham kareyi cihazda gösterir; yalnız 'text' yerleşimi kare istemez. Hiçbir kare çizilmedi.`, 400);
|
|
83
90
|
}
|
|
84
|
-
return readSlideSource(slide.path, index);
|
|
91
|
+
return readSlideSource(config, slide.path, index);
|
|
85
92
|
}));
|
|
86
93
|
// Oranı farklı kare ekrana `object-fit: cover` ile kırpılarak oturur; çizim durmaz ama ajan bilmeli.
|
|
87
94
|
const warnings = sources.flatMap((source, index) => source && Math.abs(source.size.height / source.size.width - capture.height / capture.width) > aspectTolerance
|
|
@@ -97,7 +104,7 @@ export async function buildDeck(input, directory) {
|
|
|
97
104
|
}
|
|
98
105
|
const name = `raw-${pad(index + 1)}.${source.png ? 'png' : 'jpg'}`;
|
|
99
106
|
const copy = path.join(directory, name);
|
|
100
|
-
await
|
|
107
|
+
await writeFile(copy, source.bytes);
|
|
101
108
|
raws.push({ name, path: copy, ...source.size });
|
|
102
109
|
rawOfSlide.push(raws.length - 1);
|
|
103
110
|
}
|
|
@@ -303,15 +303,22 @@ async function persist(gallery) {
|
|
|
303
303
|
await writeFile(path.join(gallery.directory, 'index.html'), staticGalleryHtml(gallery.deck, true));
|
|
304
304
|
}
|
|
305
305
|
export const sharedGalleryServer = new GalleryServer();
|
|
306
|
+
/**
|
|
307
|
+
* Kartların yazıldığı kök: `MCP_STATE_DIR` (yoksa işletim sisteminin geçici dizini) altındaki `store-art`. `sendFile`
|
|
308
|
+
* mutlak yol istediği için çözülür — kök `.env`'deki `MCP_STATE_DIR` göreli bir yoldur. `mobile_asset_create` aynı kökü
|
|
309
|
+
* yalnız-okuma kökü olarak kullanır (passthrough'ta yükleme `path: files[i].path` ile yapılır; GW-016).
|
|
310
|
+
*/
|
|
311
|
+
export function storeArtRoot(config) {
|
|
312
|
+
return path.resolve(config.stateDirectory ?? path.join(os.tmpdir(), 'zeyrek-mcp'), 'store-art');
|
|
313
|
+
}
|
|
306
314
|
/**
|
|
307
315
|
* Desteyi kurar, kartları çizer, `deck.json` ve salt görüntü `index.html`'i diske yazar ve (AUTH_MODE=local'da)
|
|
308
|
-
* editörü açar. Dizin `
|
|
309
|
-
* istediği için çözülür — kök `.env`'deki `MCP_STATE_DIR` göreli bir yoldur.
|
|
316
|
+
* editörü açar. Dizin `storeArtRoot` altındadır.
|
|
310
317
|
*/
|
|
311
318
|
export async function previewStoreArt(launch, config, gallery, input, upload) {
|
|
312
319
|
const key = randomBytes(16).toString('hex');
|
|
313
|
-
const directory = path.
|
|
314
|
-
const { deck, warnings } = await buildDeck(input, directory);
|
|
320
|
+
const directory = path.join(storeArtRoot(config), key);
|
|
321
|
+
const { deck, warnings } = await buildDeck(input, directory, config);
|
|
315
322
|
const renderDeck = (cards, fileName) => renderCards(launch, deck, directory, cards, fileName);
|
|
316
323
|
const files = await renderDeck(deck.cards);
|
|
317
324
|
// passthrough'ta platform kimliği MCP isteğinden gelir; tarayıcıdan gelen yükleme isteğinin kimliği yoktur.
|