@appaflytech/zeyrek-ai-mcp 0.0.64 → 0.0.66
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/access.md +4 -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
package/dist/tools/case.js
CHANGED
|
@@ -7,9 +7,8 @@ import { withNormalization } from '../knowledge/normalize.js';
|
|
|
7
7
|
import { PlatformApiError } from '../platform/errors.js';
|
|
8
8
|
import { caseFindings } from '../knowledge/case.js';
|
|
9
9
|
import { handle } from '../platform/responses.js';
|
|
10
|
-
import { readFile } from 'node:fs/promises';
|
|
11
10
|
import fastJsonPatch from 'fast-json-patch';
|
|
12
|
-
import {
|
|
11
|
+
import { readLocalFile, resolveLocalOutput } from '../platform/localFiles.js';
|
|
13
12
|
import { z } from 'zod';
|
|
14
13
|
const maxInlineXmlBytes = 256_000;
|
|
15
14
|
const maxCmmnBytes = 5_000_000;
|
|
@@ -127,10 +126,12 @@ export function registerCaseTools(server, platform) {
|
|
|
127
126
|
project: projectParam,
|
|
128
127
|
environment: environmentParam,
|
|
129
128
|
id: guid,
|
|
130
|
-
outPath: z.string().min(1).optional().describe(
|
|
129
|
+
outPath: z.string().min(1).optional().describe("verilirse XML bu yerel yola yazılır ve yanıt yalnız özet döner; gateway'in çalışma dizininin ya da .env MCP_INPUT_DIR'in altında (göreli yol MCP_INPUT_DIR'e göre çözülür)")
|
|
131
130
|
},
|
|
132
131
|
annotations: readOnly
|
|
133
132
|
}, handle(config, async ({ project, environment, id, outPath }) => {
|
|
133
|
+
// g-12 (DD-23): outPath izinli kökte mi, istekten ÖNCE denetlenir (localFiles).
|
|
134
|
+
const target = outPath === undefined ? undefined : await resolveLocalOutput('case_cmmn_get', 'outPath', outPath, config);
|
|
134
135
|
const response = await platform.tenantWithHeaders('GET', project, `/bpm/cases/${id}/cmmn`, { environment, expectBinary: true });
|
|
135
136
|
const payload = response.body;
|
|
136
137
|
const xml = payload.bytes.toString('utf8').replace(/^/, '');
|
|
@@ -140,8 +141,8 @@ export function registerCaseTools(server, platform) {
|
|
|
140
141
|
state: response.headers['x-case-version-state'] ?? null,
|
|
141
142
|
sizeBytes: payload.bytes.byteLength
|
|
142
143
|
};
|
|
143
|
-
if (
|
|
144
|
-
return { ...summary, path: await writeLocalFile('case_cmmn_get',
|
|
144
|
+
if (target)
|
|
145
|
+
return { ...summary, path: await writeLocalFile('case_cmmn_get', target, xml) };
|
|
145
146
|
const inline = { ...summary, xml };
|
|
146
147
|
assertInline('case_cmmn_get', config, inline);
|
|
147
148
|
return inline;
|
|
@@ -154,7 +155,7 @@ export function registerCaseTools(server, platform) {
|
|
|
154
155
|
environment: environmentParam,
|
|
155
156
|
applicationId: guid.optional(),
|
|
156
157
|
xml: z.string().min(1).max(maxInlineXmlBytes).optional(),
|
|
157
|
-
filePath: z.string().min(1).optional().describe(
|
|
158
|
+
filePath: z.string().min(1).optional().describe("yerel .cmmn dosyası; gateway'in çalışma dizininin ya da .env MCP_INPUT_DIR'in altında (göreli yol MCP_INPUT_DIR'e göre çözülür)")
|
|
158
159
|
},
|
|
159
160
|
annotations: updates
|
|
160
161
|
}, handle(config, async ({ project, environment, applicationId, xml, filePath }) => {
|
|
@@ -162,14 +163,9 @@ export function registerCaseTools(server, platform) {
|
|
|
162
163
|
if (Boolean(xml) === Boolean(filePath))
|
|
163
164
|
throw new PlatformApiError("case_cmmn_update: 'xml' ya da 'filePath' — yalnız biri (istek gönderilmedi).", 400);
|
|
164
165
|
let content = xml ?? '';
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
catch (error) {
|
|
170
|
-
throw new PlatformApiError(`case_cmmn_update: dosya okunamadı — ${resolve(filePath)} (${error instanceof Error ? error.message : String(error)}). Yol gateway sürecinin çalıştığı makineye göre çözülür (istek gönderilmedi).`, 400);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
166
|
+
// g-12 (DD-23): izinli köklerden okunur (localFiles); sınır aşan dosya okunurken durur.
|
|
167
|
+
if (filePath)
|
|
168
|
+
content = (await readLocalFile('case_cmmn_update', filePath, { label: 'dosya', maxBytes: maxCmmnBytes, tooLarge: () => `XML en çok ${maxCmmnBytes} B.` }, config)).buffer.toString('utf8');
|
|
173
169
|
content = content.replace(/^/, '');
|
|
174
170
|
if (Buffer.byteLength(content, 'utf8') > maxCmmnBytes)
|
|
175
171
|
throw new PlatformApiError(`case_cmmn_update: XML en çok ${maxCmmnBytes} B (istek gönderilmedi).`, 413);
|
package/dist/tools/common.js
CHANGED
|
@@ -56,7 +56,7 @@ export function microOps(tool, ops, operations) {
|
|
|
56
56
|
}
|
|
57
57
|
export const pagingParams = {
|
|
58
58
|
pageIndex: z.number().int().min(0).optional().describe('0 tabanlı sayfa numarası'),
|
|
59
|
-
pageLength: z.number().int().min(1).max(200).optional().describe('Sayfa boyu; platform varsayılanı 10'),
|
|
59
|
+
pageLength: z.number().int().min(1).max(200).optional().describe('Sayfa boyu, en çok 200 (gateway sınırı); platform varsayılanı 10. Devamı pageIndex ile'),
|
|
60
60
|
order: z.string().optional().describe('Sıralanacak alan adı'),
|
|
61
61
|
isDescending: z.boolean().optional()
|
|
62
62
|
};
|
package/dist/tools/decisions.js
CHANGED
|
@@ -8,9 +8,8 @@ import { decisionFindings } from '../knowledge/decision.js';
|
|
|
8
8
|
import { withNormalization } from '../knowledge/normalize.js';
|
|
9
9
|
import { PlatformApiError } from '../platform/errors.js';
|
|
10
10
|
import { handle } from '../platform/responses.js';
|
|
11
|
-
import { readFile } from 'node:fs/promises';
|
|
12
11
|
import fastJsonPatch from 'fast-json-patch';
|
|
13
|
-
import {
|
|
12
|
+
import { readLocalFile, resolveLocalOutput } from '../platform/localFiles.js';
|
|
14
13
|
import { z } from 'zod';
|
|
15
14
|
const maxInlineXmlBytes = 256_000;
|
|
16
15
|
const maxDmnBytes = 5_000_000;
|
|
@@ -155,10 +154,12 @@ export function registerDecisionTools(server, platform) {
|
|
|
155
154
|
environment: environmentParam,
|
|
156
155
|
id: guid,
|
|
157
156
|
version: z.number().int().min(1).optional(),
|
|
158
|
-
outPath: z.string().min(1).optional().describe(
|
|
157
|
+
outPath: z.string().min(1).optional().describe("verilirse XML bu yerel yola yazılır ve yanıt yalnız özet döner; gateway'in çalışma dizininin ya da .env MCP_INPUT_DIR'in altında (göreli yol MCP_INPUT_DIR'e göre çözülür)")
|
|
159
158
|
},
|
|
160
159
|
annotations: readOnly
|
|
161
160
|
}, handle(config, async ({ project, environment, id, version, outPath }) => {
|
|
161
|
+
// g-12 (DD-23): outPath izinli kökte mi, istekten ÖNCE denetlenir (localFiles).
|
|
162
|
+
const target = outPath === undefined ? undefined : await resolveLocalOutput('decision_dmn_get', 'outPath', outPath, config);
|
|
162
163
|
const response = await platform.tenantWithHeaders('GET', project, `/bpm/decisions/${id}/dmn`, { environment, query: { version }, expectBinary: true });
|
|
163
164
|
const payload = response.body;
|
|
164
165
|
const xml = payload.bytes.toString('utf8').replace(/^\uFEFF/, '');
|
|
@@ -168,8 +169,8 @@ export function registerDecisionTools(server, platform) {
|
|
|
168
169
|
state: response.headers['x-decision-version-state'] ?? null,
|
|
169
170
|
sizeBytes: payload.bytes.byteLength
|
|
170
171
|
};
|
|
171
|
-
if (
|
|
172
|
-
return { ...summary, path: await writeLocalFile('decision_dmn_get',
|
|
172
|
+
if (target)
|
|
173
|
+
return { ...summary, path: await writeLocalFile('decision_dmn_get', target, xml) };
|
|
173
174
|
const inline = { ...summary, xml };
|
|
174
175
|
assertInline('decision_dmn_get', config, inline);
|
|
175
176
|
return inline;
|
|
@@ -182,7 +183,7 @@ export function registerDecisionTools(server, platform) {
|
|
|
182
183
|
environment: environmentParam,
|
|
183
184
|
applicationId: guid.optional(),
|
|
184
185
|
xml: z.string().min(1).max(maxInlineXmlBytes).optional(),
|
|
185
|
-
filePath: z.string().min(1).optional().describe(
|
|
186
|
+
filePath: z.string().min(1).optional().describe("yerel .dmn dosyası; gateway'in çalışma dizininin ya da .env MCP_INPUT_DIR'in altında (göreli yol MCP_INPUT_DIR'e göre çözülür)")
|
|
186
187
|
},
|
|
187
188
|
annotations: updates
|
|
188
189
|
}, handle(config, async ({ project, environment, applicationId, xml, filePath }) => {
|
|
@@ -190,14 +191,9 @@ export function registerDecisionTools(server, platform) {
|
|
|
190
191
|
if (Boolean(xml) === Boolean(filePath))
|
|
191
192
|
throw new PlatformApiError("decision_dmn_update: 'xml' ya da 'filePath' — yalnız biri (istek gönderilmedi).", 400);
|
|
192
193
|
let content = xml ?? '';
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
catch (error) {
|
|
198
|
-
throw new PlatformApiError(`decision_dmn_update: dosya okunamadı — ${resolve(filePath)} (${error instanceof Error ? error.message : String(error)}). Yol gateway sürecinin çalıştığı makineye göre çözülür (istek gönderilmedi).`, 400);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
194
|
+
// g-12 (DD-23): izinli köklerden okunur (localFiles); sınır aşan dosya okunurken durur.
|
|
195
|
+
if (filePath)
|
|
196
|
+
content = (await readLocalFile('decision_dmn_update', filePath, { label: 'dosya', maxBytes: maxDmnBytes, tooLarge: () => `XML en çok ${maxDmnBytes} B.` }, config)).buffer.toString('utf8');
|
|
201
197
|
content = content.replace(/^/, '');
|
|
202
198
|
if (Buffer.byteLength(content, 'utf8') > maxDmnBytes)
|
|
203
199
|
throw new PlatformApiError(`decision_dmn_update: XML en çok ${maxDmnBytes} B (istek gönderilmedi).`, 413);
|
|
@@ -1,14 +1,121 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { guid, readOnly, writes } from './common.js';
|
|
3
3
|
import { handle } from '../platform/responses.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { listAll } from '../platform/ifExists.js';
|
|
5
|
+
const finishedDeploymentTypes = new Set(['completed', 'completed-with-mismatch']);
|
|
6
|
+
/**
|
|
7
|
+
* Studio'nun `isDeploymentFinished` kümesi (`apps/studio/src/features/deployment/deployment.functions.ts`); eşlik testi
|
|
8
|
+
* `test/deployments.test.ts`. `error` da bitiştir: aktarım atomiktir, hedef değişmemiştir.
|
|
9
|
+
*/
|
|
10
|
+
export const DEPLOYMENT_TERMINAL_TYPES = ['completed', 'completed-with-mismatch', 'error'];
|
|
11
|
+
// g-11 (derdini-dok DD-24): bitiş olaysızdı (backend SignalR yayınlıyor, gateway dinlemiyor), ajan elle yokluyordu.
|
|
12
|
+
// 2 sn Studio'nun yoklama aralığıyla aynı mertebede. İnceleme 2026-11-05: tavan 55 → 45 sn — süre dolarken uçuştaki son
|
|
13
|
+
// okuma istemcilerin 60 sn araç zaman aşımına 15 sn pay bırakır; bitişten sonraki kayıt taşıması okuması (DEP-010) aynı
|
|
14
|
+
// bütçenin içindedir (kalan süreyle yarışır, yetişmezse alan düşer).
|
|
15
|
+
const deploymentWaitIntervalMs = 2000;
|
|
16
|
+
const deploymentWaitMaxSeconds = 45;
|
|
17
|
+
// DD-1 ipucu yalnız yeni biten dağıtımda: DTO'da bitiş zamanı yok (DeploymentDto.cs StartAt), başlangıç vekildir.
|
|
18
|
+
const recentDeploymentMs = 15 * 60_000;
|
|
19
|
+
function deploymentRecord(payload) {
|
|
20
|
+
const data = payload && typeof payload === 'object' ? payload.data : undefined;
|
|
21
|
+
return data && typeof data === 'object' && !Array.isArray(data)
|
|
22
|
+
? { id: data.id, type: String(data.type ?? ''), startAt: data.startAt }
|
|
23
|
+
: { type: '' };
|
|
24
|
+
}
|
|
25
|
+
async function waitForDeployment(read, waitSeconds, signal) {
|
|
26
|
+
const startedAt = Date.now();
|
|
27
|
+
const deadline = startedAt + waitSeconds * 1000;
|
|
28
|
+
const first = await read();
|
|
29
|
+
let payload = first;
|
|
30
|
+
// Kayıt yoksa (`data: null`) ya da tipsizse beklenecek bir süreç yoktur: hiç deployment yapılmamış projede süre boşa gitmez.
|
|
31
|
+
// Son bekleme süreyi aşmaz: kalan süre aralıktan kısaysa o kadar beklenir ve bitişte bir kez daha okunur. İstek iptal
|
|
32
|
+
// edilince (extra.signal) bekleme hemen biter ve yeniden okunmaz — iptal edilmiş çağrı 45 sn arka planda yoklamaz.
|
|
33
|
+
while (deploymentRecord(payload).type !== '' && !DEPLOYMENT_TERMINAL_TYPES.includes(deploymentRecord(payload).type) && Date.now() < deadline && !signal?.aborted) {
|
|
34
|
+
await new Promise(resolve => {
|
|
35
|
+
const done = () => {
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
signal?.removeEventListener('abort', done);
|
|
38
|
+
resolve();
|
|
39
|
+
};
|
|
40
|
+
const timer = setTimeout(done, Math.min(deploymentWaitIntervalMs, deadline - Date.now()));
|
|
41
|
+
signal?.addEventListener('abort', done, { once: true });
|
|
42
|
+
});
|
|
43
|
+
if (signal?.aborted)
|
|
44
|
+
break;
|
|
45
|
+
payload = await read();
|
|
46
|
+
}
|
|
47
|
+
const settled = DEPLOYMENT_TERMINAL_TYPES.includes(deploymentRecord(payload).type);
|
|
48
|
+
return { payload, settled, waitedMs: Date.now() - startedAt, observedFinish: settled && !DEPLOYMENT_TERMINAL_TYPES.includes(deploymentRecord(first).type), deadline };
|
|
49
|
+
}
|
|
50
|
+
function waitFields(waited) {
|
|
51
|
+
return {
|
|
52
|
+
settled: waited.settled,
|
|
53
|
+
waitedMs: waited.waitedMs,
|
|
54
|
+
...(deploymentRecord(waited.payload).type === 'completed' ? { statusNote: "completed: ardından koşan özet (parite) denetimi durumu completed-with-mismatch'e çevirebilir — production'ı environment_diff ile doğrulayın ya da bir süre sonra yeniden okuyun." } : {})
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// İnceleme 2026-11-05: eşleşme yalnız waitSeconds verilince denetleniyordu; tek okumada deploymentId sessizce yok sayılıyordu.
|
|
58
|
+
function deploymentIdFields(payload, deploymentId) {
|
|
59
|
+
const record = deploymentRecord(payload);
|
|
60
|
+
return deploymentId !== undefined && record.id !== undefined && String(record.id) !== deploymentId
|
|
61
|
+
? { deploymentIdWarning: `deploymentId '${deploymentId}' son süreçle eşleşmiyor: son kayıt '${String(record.id)}'. Durum o sürecindir; sizinki daha önce bitmiş ya da başka bir dağıtım sonradan başlamış olabilir.` }
|
|
62
|
+
: {};
|
|
63
|
+
}
|
|
64
|
+
// Proje slug'ı ve kaynak environment adı tek okumayla: taslak ve kayıt taşıması listeleri aynı kaynaktan okunur.
|
|
65
|
+
async function projectSource(platform, projectId, match) {
|
|
7
66
|
const project = await platform.org('GET', `/projects/${projectId}`);
|
|
8
67
|
const slug = project?.data?.slug;
|
|
9
|
-
const environment = project?.data?.environments?.find(
|
|
10
|
-
|
|
11
|
-
|
|
68
|
+
const environment = project?.data?.environments?.find(match)?.name;
|
|
69
|
+
return slug && environment ? { slug, environment } : undefined;
|
|
70
|
+
}
|
|
71
|
+
// DD-1 · K1 (derdini-dok, 2026-11-05): `recordTransferMode` + `transferRowIds` entity tanımında KALICIDIR ve promote her
|
|
72
|
+
// seferinde okur (SystemRecordDataCollector.cs:55, EntityRecordTransferPlanner.cs:237-243); temizleyen kod yok. Tek
|
|
73
|
+
// seferlik veri sonraki her dağıtımda yeniden gider. Yalnız OKUR: datasource listesi + datasource başına entity listesi
|
|
74
|
+
// (EntityDto bu üç alanı taşır; entity başına GET yok). Okunamazsa deployment yine başlar, liste düşer.
|
|
75
|
+
async function readRecordTransfers(platform, source) {
|
|
76
|
+
const transfers = [];
|
|
77
|
+
for (const datasource of await listAll(platform, source.slug, source.environment, '/datasources')) {
|
|
78
|
+
for (const entity of await listAll(platform, source.slug, source.environment, `/entities/${String(datasource.id)}`)) {
|
|
79
|
+
const mode = entity.recordTransferMode;
|
|
80
|
+
if (typeof mode !== 'string' || mode === '')
|
|
81
|
+
continue;
|
|
82
|
+
transfers.push({
|
|
83
|
+
entity: String(entity.slug ?? entity.name ?? entity.id),
|
|
84
|
+
mode,
|
|
85
|
+
...(mode === 'specific' ? { rows: Array.isArray(entity.transferRowIds) ? entity.transferRowIds.length : 0 } : {}),
|
|
86
|
+
skipExisting: entity.recordTransferSkipExisting === true
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return transfers;
|
|
91
|
+
}
|
|
92
|
+
function specificTables(transfers) {
|
|
93
|
+
return transfers
|
|
94
|
+
.filter(transfer => transfer.mode === 'specific')
|
|
95
|
+
.map(transfer => `'${transfer.entity}' (${transfer.rows ?? 0} satır, skipExisting ${transfer.skipExisting ? 'açık' : 'kapalı'})`)
|
|
96
|
+
.join(', ');
|
|
97
|
+
}
|
|
98
|
+
function recordTransferNote(transfers) {
|
|
99
|
+
const specific = specificTables(transfers);
|
|
100
|
+
const mirrored = transfers.filter(transfer => transfer.mode === 'all').map(transfer => `'${transfer.entity}'`).join(', ');
|
|
101
|
+
return [
|
|
102
|
+
specific === '' ? '' : `Seçili satır taşıması açık tablolar: ${specific}. 'specific' + transferRowIds tanımda KALICIDIR: bu satırlar sonraki her dağıtımda yeniden gönderilir. Tek seferlikse dağıtım bitince development'ta işareti kaldırın (deployment_status bitişte cleanupHint verir). skipExisting açıkken production'da var olan satır güncellenmez — metin düzeltmesi hiç uygulanmaz; kapalıyken sonraki her dağıtım production'daki düzeltmeyi development değeriyle ezer.`,
|
|
103
|
+
mirrored === '' ? '' : `'all' tablolar (${mirrored}) her dağıtımda gider; skipExisting kapalıysa production o tabloda development'ın aynasıdır, kaynakta olmayan satır silinir (DEP-005).`,
|
|
104
|
+
"Tek seferlik veri tarifi: ayarı aç → bir dağıtım → development'ta kapat; metin düzeltmesinde skipExisting o dağıtım için kapalı olmalı. platform_guide('deployment') §Tek seferlik veri."
|
|
105
|
+
].filter(part => part !== '').join(' ');
|
|
106
|
+
}
|
|
107
|
+
// İnceleme 2026-11-05: liste development'ın ŞİMDİKİ tanımından okunur; dağıtımın gerçekte ne taşıdığını söylemez (dağıtımdan
|
|
108
|
+
// sonra işaret değişmiş olabilir). Metin bu yüzden "şu an açık" der.
|
|
109
|
+
function cleanupHint(transfers) {
|
|
110
|
+
const specific = specificTables(transfers);
|
|
111
|
+
return specific === ''
|
|
112
|
+
? "Dağıtım bitti; development'ta şu an kayıt taşıması açık tablolar yalnız 'all' kipinde — kalıcı ayarsa dokunmayın, tek seferlikse development'ta entity_patch ile /recordTransferMode → null."
|
|
113
|
+
: `Dağıtım bitti; development'ta şu an seçili satır taşıması açık tablolar: ${specific}. Tek seferlik veriyse işareti kaldırın: entity_patch ile [{ op: 'replace', path: '/recordTransferMode', value: null }, { op: 'replace', path: '/transferRowIds', value: [] }]. Açık kalırsa sonraki her dağıtım aynı satırları yeniden gönderir. Production'a doğrudan yazılmaz — platform_guide('deployment') §Tek seferlik veri.`;
|
|
114
|
+
}
|
|
115
|
+
// Koşu 42 S-21: promote yayınlanmamış taslağı taşımaz (sözleşme) ve saga bunu hiçbir yerde söylemez.
|
|
116
|
+
// Liste kaynak environment'ın şemasından okunur; okunamazsa deployment yine başlar, uyarı düşer.
|
|
117
|
+
async function readUnpublishedDrafts(platform, source) {
|
|
118
|
+
const { slug, environment } = source;
|
|
12
119
|
const drafts = [];
|
|
13
120
|
for (let pageIndex = 0; pageIndex < 50; pageIndex++) {
|
|
14
121
|
const page = await platform.tenant('GET', slug, '/bpm/definitions', { environment, query: { pageIndex, pageLength: 200 } });
|
|
@@ -27,7 +134,7 @@ export function registerDeploymentTools(server, platform) {
|
|
|
27
134
|
const config = platform.config;
|
|
28
135
|
server.registerTool('deployment_start', {
|
|
29
136
|
title: 'Deployment başlat',
|
|
30
|
-
description: 'Projeyi kaynak environment\'tan hedef environment\'a deploy eder. Asenkron bir saga\'dır: sonuç bu yanıtta bitmez, deployment_status ile izleyin. Environment id\'lerini project_get çıktısından alın. BPM: süreç tanımları ve iş takvimleri taşınır — hedefte farklı aktif model yeni sürüm olarak yayınlanır (production\'da gelişte aktif), hedefin uyarlaması korunur; uyarlama, örnek, görev ve defter taşınmaz; kaynakta olmayan tanım silinir, açık örneği varsa emekliye ayrılır. KAYNAK YALNIZ DEVELOPMENT\'TIR: dal ya da production kaynak verilirse 400 (CantDeployFromBranchException) — dalı önce development\'a merge edin. ÖN DENETİM: deploy başlamadan production verisi denetlenir; veriyi bozacak ya da silecek her değişiklik 400 (DeploymentDataRiskException) ile listelenir ve deploy BAŞLAMAZ — biçim \'tablo.alan: tür (satır)\', türler not-null | unique | field-removed | table-removed | localization-move. YALNIZ TANIM TAŞINIR: tablo satırları ancak tabloda recordTransferMode (\'all\' | \'specific\' + transferRowIds) açıksa gider, çeviri ve junction satırları ana tabloyla birlikte. Kayıt taşıması \'all\' olan tabloda production development\'ın AYNASIDIR (kaynakta olmayan satır ve çevirisi silinir) — tabloda recordTransferSkipExisting açıksa ayna yoktur, production\'da var olan satır güncellenmez, yalnız eksik satır eklenir. DOSYA yalnız id referansıyla gider (file tipli prop { type:\'file\', ref:<fileId> } ya da taşınan satırın dosya sütunu); sayfaya düz yazılan /d/ serve URL\'si /p/\'ye çevrilir ama dosya kopyalanmaz, production\'da 404 döner — platform_guide(\'deployment\'). Microfunction\'ın yalnız YAYINLANMIŞ kodu taşınır ve hedefte yayınlanır; hiç yayınlanmamış olan hedefte taslak kalır. Zamanlanmış işin duraklatma durumu taşınır. YAYINLANMAMIŞ TASLAK TAŞINMAZ: kaynakta taslağı olan süreçler yanıtta unpublishedDrafts ({ slug, name, draftVersionNumber, activeVersionNumber }) ve note ile listelenir; hedefte aktif sürüm kalır. Taşımak için taslağı kaynakta yayınlayın (requireGreenScenarios açıksa önce senaryoları taslak üzerinde koşun), sonra yeniden deploy edin. DELTA (varsayılan): yalnız içerik özeti production\'dakinden farklı tanımlar taşınır, kaynakta olmayan tanım silinir; entity, rol, erişim politikası, bileşen, dosya, süreç tanımı, organizasyon yapısı ve tablo satırları her deploy\'da tam taşınır; klasör silme taşınmaz. Kaynağın ya da production\'ın özeti güvenilir değilse (son tamamlanmış özet denetimi güncel biçimde bir fill ya da farksız bir check değilse) deploy kendiliğinden tam koşar; fullMode:true her tanımı taşır. Hangi kipte koştuğu ve modül başına sayılar deployment_status yanıtında (mode, counters).',
|
|
137
|
+
description: 'Projeyi kaynak environment\'tan hedef environment\'a deploy eder. Asenkron bir saga\'dır: sonuç bu yanıtta bitmez, deployment_status ile izleyin. Environment id\'lerini project_get çıktısından alın. BPM: süreç tanımları ve iş takvimleri taşınır — hedefte farklı aktif model yeni sürüm olarak yayınlanır (production\'da gelişte aktif), hedefin uyarlaması korunur; uyarlama, örnek, görev ve defter taşınmaz; kaynakta olmayan tanım silinir, açık örneği varsa emekliye ayrılır. KAYNAK YALNIZ DEVELOPMENT\'TIR: dal ya da production kaynak verilirse 400 (CantDeployFromBranchException) — dalı önce development\'a merge edin. ÖN DENETİM: deploy başlamadan production verisi denetlenir; veriyi bozacak ya da silecek her değişiklik 400 (DeploymentDataRiskException) ile listelenir ve deploy BAŞLAMAZ — biçim \'tablo.alan: tür (satır)\', türler not-null | unique | field-removed | table-removed | localization-move. YALNIZ TANIM TAŞINIR: tablo satırları ancak tabloda recordTransferMode (\'all\' | \'specific\' + transferRowIds) açıksa gider, çeviri ve junction satırları ana tabloyla birlikte. Yanıt, kaynakta kayıt taşıması açık tabloları recordTransfer ({ entity, mode, rows, skipExisting }) ve recordTransferNote ile listeler (DEP-010): \'specific\' + transferRowIds tanımda KALICIDIR, sonraki her dağıtımda yeniden gider — tek seferlik veri tarifi: ayarı aç → bir dağıtım → development\'ta kapat; metin düzeltmesinde recordTransferSkipExisting o dağıtım için kapalı olmalı (platform_guide(\'deployment\') §Tek seferlik veri). Kayıt taşıması \'all\' olan tabloda production development\'ın AYNASIDIR (kaynakta olmayan satır ve çevirisi silinir) — tabloda recordTransferSkipExisting açıksa ayna yoktur, production\'da var olan satır güncellenmez, yalnız eksik satır eklenir. DOSYA yalnız id referansıyla gider (file tipli prop { type:\'file\', ref:<fileId> } ya da taşınan satırın dosya sütunu); sayfaya düz yazılan /d/ serve URL\'si /p/\'ye çevrilir ama dosya kopyalanmaz, production\'da 404 döner — platform_guide(\'deployment\'). Microfunction\'ın yalnız YAYINLANMIŞ kodu taşınır ve hedefte yayınlanır; hiç yayınlanmamış olan hedefte taslak kalır. Zamanlanmış işin duraklatma durumu taşınır. YAYINLANMAMIŞ TASLAK TAŞINMAZ: kaynakta taslağı olan süreçler yanıtta unpublishedDrafts ({ slug, name, draftVersionNumber, activeVersionNumber }) ve note ile listelenir; hedefte aktif sürüm kalır. Taşımak için taslağı kaynakta yayınlayın (requireGreenScenarios açıksa önce senaryoları taslak üzerinde koşun), sonra yeniden deploy edin. DELTA (varsayılan): yalnız içerik özeti production\'dakinden farklı tanımlar taşınır, kaynakta olmayan tanım silinir; entity, rol, erişim politikası, bileşen, dosya, süreç tanımı, organizasyon yapısı ve tablo satırları her deploy\'da tam taşınır; klasör silme taşınmaz. Kaynağın ya da production\'ın özeti güvenilir değilse (son tamamlanmış özet denetimi güncel biçimde bir fill ya da farksız bir check değilse) deploy kendiliğinden tam koşar; fullMode:true her tanımı taşır. Hangi kipte koştuğu ve modül başına sayılar deployment_status yanıtında (mode, counters).',
|
|
31
138
|
inputSchema: {
|
|
32
139
|
projectId: guid,
|
|
33
140
|
sourceEnvironmentId: guid,
|
|
@@ -36,26 +143,38 @@ export function registerDeploymentTools(server, platform) {
|
|
|
36
143
|
},
|
|
37
144
|
annotations: writes
|
|
38
145
|
}, handle(config, async ({ projectId, ...body }) => {
|
|
39
|
-
const
|
|
146
|
+
const source = await projectSource(platform, projectId, entry => entry.id === body.sourceEnvironmentId).catch(() => undefined);
|
|
147
|
+
const unpublishedDrafts = source === undefined ? undefined : await readUnpublishedDrafts(platform, source).catch(() => undefined);
|
|
148
|
+
const recordTransfer = source === undefined ? undefined : await readRecordTransfers(platform, source).catch(() => undefined);
|
|
40
149
|
const payload = await platform.org('POST', `/deployments/${projectId}/deploy`, { body });
|
|
41
|
-
if (!
|
|
150
|
+
if (!payload || typeof payload !== 'object')
|
|
42
151
|
return payload;
|
|
43
|
-
const listed = unpublishedDrafts
|
|
152
|
+
const listed = (unpublishedDrafts ?? [])
|
|
44
153
|
.map(draft => `${String(draft.slug)} (taslak v${String(draft.draftVersionNumber)}, aktif ${draft.activeVersionNumber === null ? 'yok' : `v${String(draft.activeVersionNumber)}`})`)
|
|
45
154
|
.join(', ');
|
|
46
155
|
return {
|
|
47
156
|
...payload,
|
|
48
|
-
unpublishedDrafts
|
|
49
|
-
|
|
157
|
+
...(unpublishedDrafts?.length ? {
|
|
158
|
+
unpublishedDrafts,
|
|
159
|
+
note: `Kaynakta yayınlanmamış taslağı olan ${unpublishedDrafts.length} süreç var; promote taslak taşımaz, hedefte aktif sürüm kalır: ${listed}. Taşımak için taslağı kaynakta yayınlayın (requireGreenScenarios açıksa önce senaryoları taslak üzerinde koşun), sonra yeniden deploy edin.`
|
|
160
|
+
} : {}),
|
|
161
|
+
...(recordTransfer?.length ? { recordTransfer, recordTransferNote: recordTransferNote(recordTransfer) } : {})
|
|
50
162
|
};
|
|
51
163
|
}));
|
|
52
164
|
server.registerTool('deployment_status', {
|
|
53
165
|
title: 'Deployment durumu',
|
|
54
|
-
description: "Projenin son deployment durumunu döner. Bittikten sonra iki ortamın tanım farkını environment_diff verir (özetten; tablo satırları hariç). 'projectId' ZORUNLUDUR (project_list/project_get'ten alın) — verilmezse çağrı MCP şema katmanında reddedilir, platforma hiç gitmez. Hiç deployment yapılmamış projede yanıt BOŞ gelir; o durumda tool 'hiç deployment kaydı yok' bilgisini açıkça döner, yani boş yanıtı 'tool çalışmadı' diye okumayın. Durum satırı modül başına ayrılmaz: süreç tanımları ve iş takvimleri sayfa ve workflow'lardan sonra aynı saga adımında aktarılır; hedefte çalışamayan (eksik workflow/entity/rol) tanım aktarımı DefinitionInvalid ile düşürür. type 'error' ise 'error' alanı düşüş nedenini taşır (DefinitionInvalid'de bulgular 'yol: mesaj | …' olarak eklenir); aktarım atomiktir, hedef değişmemiştir. type 'completed-with-mismatch': deploy tamamlandı, kayıtlar production'a yazıldı, ama ardından koşan özet denetimi production'da fark buldu; sonraki deploy otomatik tam (full) koşar. Yanıt mode (full | delta: deploy'un gerçekte koştuğu kip) ve counters (delta'da modül başına added/updated/deleted) taşır.",
|
|
55
|
-
inputSchema: {
|
|
166
|
+
description: "Projenin son deployment durumunu döner. Yoklamayın: waitSeconds (en çok 45) verilirse araç 2 sn aralıkla kendisi yoklar ve bitişte (completed | completed-with-mismatch | error) ya da süre dolunca döner (istek iptal edilince yoklama durur); yanıt settled ve waitedMs taşır. deploymentId verildiyse (waitSeconds olsun olmasın) son süreçle eşleşmezse deploymentIdWarning. completed'ten sonra özet denetimi durumu completed-with-mismatch'e çevirebilir (statusNote). Bittikten sonra iki ortamın tanım farkını environment_diff verir (özetten; tablo satırları hariç). 'projectId' ZORUNLUDUR (project_list/project_get'ten alın) — verilmezse çağrı MCP şema katmanında reddedilir, platforma hiç gitmez. Hiç deployment yapılmamış projede yanıt BOŞ gelir; o durumda tool 'hiç deployment kaydı yok' bilgisini açıkça döner, yani boş yanıtı 'tool çalışmadı' diye okumayın. Durum satırı modül başına ayrılmaz: süreç tanımları ve iş takvimleri sayfa ve workflow'lardan sonra aynı saga adımında aktarılır; hedefte çalışamayan (eksik workflow/entity/rol) tanım aktarımı DefinitionInvalid ile düşürür. type 'error' ise 'error' alanı düşüş nedenini taşır (DefinitionInvalid'de bulgular 'yol: mesaj | …' olarak eklenir); aktarım atomiktir, hedef değişmemiştir. type 'completed-with-mismatch': deploy tamamlandı, kayıtlar production'a yazıldı, ama ardından koşan özet denetimi production'da fark buldu; sonraki deploy otomatik tam (full) koşar. Yanıt mode (full | delta: deploy'un gerçekte koştuğu kip) ve counters (delta'da modül başına added/updated/deleted) taşır. Dağıtım YENİ bittiyse (bu çağrının beklemesi bitişi gördü ya da startAt son 15 dk içinde) development'ta ŞU AN kayıt taşıması açık tablolar recordTransfer ve cleanupHint ile söylenir (DEP-010): tek seferlik veride işareti kaldırma tarifi oradadır; eski dağıtımın durum okumasında liste okunmaz.",
|
|
167
|
+
inputSchema: {
|
|
168
|
+
projectId: guid,
|
|
169
|
+
waitSeconds: z.number().int().min(1).max(deploymentWaitMaxSeconds).optional()
|
|
170
|
+
.describe('Bitişi en çok bu kadar saniye bekler (2 sn aralıkla yoklar); verilmezse tek okuma'),
|
|
171
|
+
deploymentId: z.string().min(1).optional().describe("deployment_start yanıtındaki id; son süreç başkaysa deploymentIdWarning döner")
|
|
172
|
+
},
|
|
56
173
|
annotations: readOnly
|
|
57
|
-
}, handle(config, async ({ projectId }) => {
|
|
58
|
-
const
|
|
174
|
+
}, handle(config, async ({ projectId, waitSeconds, deploymentId }, extra) => {
|
|
175
|
+
const waited = waitSeconds === undefined ? undefined : await waitForDeployment(() => platform.org('GET', `/deployments/${projectId}`), waitSeconds, extra?.signal);
|
|
176
|
+
const payload = waited === undefined ? await platform.org('GET', `/deployments/${projectId}`) : waited.payload;
|
|
177
|
+
const fields = { ...(waited === undefined ? {} : waitFields(waited)), ...deploymentIdFields(payload, deploymentId) };
|
|
59
178
|
const record = payload && typeof payload === 'object' ? payload : undefined;
|
|
60
179
|
const data = record?.data;
|
|
61
180
|
// Platform hiç kayıt yokken `{"data":null,"message":null}` döner. Eski kural yalnız `data`
|
|
@@ -66,8 +185,31 @@ export function registerDeploymentTools(server, platform) {
|
|
|
66
185
|
? Object.values(record ?? {}).every(value => value === null || value === undefined)
|
|
67
186
|
: Array.isArray(data) ? data.length === 0 : Object.keys(data).length === 0;
|
|
68
187
|
// "Tool çalışmadı" ile "kayıt yok" boş `{}` yanıtında ayırt edilemiyordu (09-05 S-10).
|
|
69
|
-
if (!isEmpty)
|
|
70
|
-
|
|
188
|
+
if (!isEmpty) {
|
|
189
|
+
const type = data && typeof data === 'object' && !Array.isArray(data) ? String(data.type ?? '') : '';
|
|
190
|
+
const decorated = Object.keys(fields).length > 0;
|
|
191
|
+
// DD-1: bitişte satır taşıyan tablolar yeniden söylenir; sürerken okunmaz (yoklama her turda okuma yapmasın).
|
|
192
|
+
if (!finishedDeploymentTypes.has(type))
|
|
193
|
+
return decorated ? { ...record, ...fields } : payload;
|
|
194
|
+
// İnceleme 2026-11-05: her durum çağrısı 2+N okuma yapıyordu. Liste yalnız yeni biten dağıtımda okunur: bu çağrının
|
|
195
|
+
// beklemesi bitişi gözlediyse ya da kaydın startAt'i son 15 dk içindeyse. startAt yoksa/okunamıyorsa okunmaz.
|
|
196
|
+
const startAt = Date.parse(String(deploymentRecord(payload).startAt ?? ''));
|
|
197
|
+
const recent = waited?.observedFinish === true || (Number.isFinite(startAt) && Date.now() - startAt <= recentDeploymentMs);
|
|
198
|
+
const remaining = waited === undefined ? undefined : waited.deadline - Date.now();
|
|
199
|
+
let recordTransfer;
|
|
200
|
+
if (recent && (remaining === undefined || remaining > 0)) {
|
|
201
|
+
const reading = projectSource(platform, projectId, entry => entry.name === 'development')
|
|
202
|
+
.then(source => source === undefined ? undefined : readRecordTransfers(platform, source))
|
|
203
|
+
.catch(() => undefined);
|
|
204
|
+
let timer;
|
|
205
|
+
recordTransfer = remaining === undefined
|
|
206
|
+
? await reading
|
|
207
|
+
: await Promise.race([reading, new Promise(resolve => { timer = setTimeout(() => resolve(undefined), remaining); })]).finally(() => clearTimeout(timer));
|
|
208
|
+
}
|
|
209
|
+
return recordTransfer?.length || decorated
|
|
210
|
+
? { ...record, ...fields, ...(recordTransfer?.length ? { recordTransfer, cleanupHint: cleanupHint(recordTransfer) } : {}) }
|
|
211
|
+
: payload;
|
|
212
|
+
}
|
|
71
213
|
// Environment listesi BİR EK istek: 2026-09-06 koşusu deployment_start'ı atlayabilmek için
|
|
72
214
|
// tam olarak bu bilgiyi ayrı bir project_get turuyla aldı, yani ek istek bir tur EKLEMİYOR,
|
|
73
215
|
// bir turu buraya taşıyor. Okunamazsa boş sonuç sözleşmesi yine döner.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { guid, projectParam, environmentParam, readOnly, writes, updates, destructive } from './common.js';
|
|
2
|
-
import { mkdir
|
|
2
|
+
import { mkdir } from 'node:fs/promises';
|
|
3
|
+
import { readLocalFile, resolveLocalOutput, writeLocalOutput } from '../platform/localFiles.js';
|
|
3
4
|
import { PlatformApiError } from '../platform/errors.js';
|
|
4
5
|
import { handle } from '../platform/responses.js';
|
|
5
|
-
import { basename, join
|
|
6
|
+
import { basename, join } from 'node:path';
|
|
6
7
|
import { z } from 'zod';
|
|
7
8
|
import { evaluatePolicy, enforcePolicy } from '../knowledge/policy.js';
|
|
8
9
|
import { policyRules } from '../knowledge/rules.js';
|
|
@@ -28,6 +29,8 @@ async function assertExternalComponentsAllowed(platform, applicationId, tool) {
|
|
|
28
29
|
const PROTOCOL_VERSION = EXTERNAL_COMPONENT_PROTOCOL_VERSION;
|
|
29
30
|
/** Backend `ExternalComponentRules.MaxBundleSizeBytes` ile aynı sınır */
|
|
30
31
|
const maxBundleBytes = 2 * 1024 * 1024;
|
|
32
|
+
/** g-12: manifest okuma kapısının sınırı (yalnız JSON tanım; paketin sınırıyla aynı tutuldu) */
|
|
33
|
+
const maxManifestBytes = maxBundleBytes;
|
|
31
34
|
const slugPattern = /^x-[a-z][a-z0-9-]*$/;
|
|
32
35
|
const slugParam = z.string().regex(slugPattern)
|
|
33
36
|
.describe("Harici komponent slug'ı; 'x-' ile başlamak zorunda (örn. 'x-rating-stars') — bu önek platform slug'larıyla çakışmayı imkânsız kılar");
|
|
@@ -174,7 +177,7 @@ export function registerExternalComponentTools(server, platform) {
|
|
|
174
177
|
title: 'Harici komponent iskeleti üret',
|
|
175
178
|
description: "Yerel bir dizine çalışan bir harici komponent iskeleti yazar: element.mjs (köprü protokolünü karşılayan sınıf), manifest.json (prop/event/boyut tanımı) ve README. Mevcut katalog ihtiyacınızı karşılamıyorsa buradan başlayın; ürettiği dosyaları düzenleyip external_component_publish ile yayınlarsınız. Dosyalar gateway sürecinin çalıştığı makineye yazılır, içerikleri model bağlamına girmez.",
|
|
176
179
|
inputSchema: {
|
|
177
|
-
directory: z.string().min(1).describe(
|
|
180
|
+
directory: z.string().min(1).describe("İskeletin yazılacağı yerel dizin; yoksa oluşturulur. Gateway'in çalışma dizininin ya da .env MCP_INPUT_DIR'in altında olmalı (göreli yol MCP_INPUT_DIR'e göre çözülür)"),
|
|
178
181
|
slug: slugParam,
|
|
179
182
|
name: z.string().min(1).describe("Studio toolbox'ta görünecek ad"),
|
|
180
183
|
props: z.array(z.string().min(1)).optional().describe("Komponentin alacağı prop adları; verilmezse ['value'] varsayılır. id/class/style/name gibi DOM adları kullanılamaz")
|
|
@@ -186,15 +189,17 @@ export function registerExternalComponentTools(server, platform) {
|
|
|
186
189
|
if (reserved.length) {
|
|
187
190
|
throw new PlatformApiError(`external_component_scaffold: şu prop adları platform tarafından rezerve edilmiş ve yayınlama sırasında reddedilir: ${reserved.join(', ')}.`);
|
|
188
191
|
}
|
|
189
|
-
|
|
192
|
+
// g-12 (DD-23): dizin ve içine yazılan her dosya yazma kapısından geçer (localFiles) — dizin izinli kökte olsa
|
|
193
|
+
// da içinde dışarıyı gösteren bir `element.mjs` bağı varsa yazma bağı izleyip kök dışına düşerdi.
|
|
194
|
+
const target = await resolveLocalOutput('external_component_scaffold', 'directory', directory, config);
|
|
195
|
+
const files = await Promise.all([
|
|
196
|
+
{ name: 'element.mjs', content: elementTemplate(slug, propNames) },
|
|
197
|
+
{ name: 'manifest.json', content: manifestTemplate(slug, name, propNames) },
|
|
198
|
+
{ name: 'README.md', content: readmeTemplate(slug) }
|
|
199
|
+
].map(async (file) => ({ path: await resolveLocalOutput('external_component_scaffold', 'directory', join(target, file.name), config), content: file.content })));
|
|
190
200
|
await mkdir(target, { recursive: true });
|
|
191
|
-
const files = [
|
|
192
|
-
{ path: join(target, 'element.mjs'), content: elementTemplate(slug, propNames) },
|
|
193
|
-
{ path: join(target, 'manifest.json'), content: manifestTemplate(slug, name, propNames) },
|
|
194
|
-
{ path: join(target, 'README.md'), content: readmeTemplate(slug) }
|
|
195
|
-
];
|
|
196
201
|
for (const file of files) {
|
|
197
|
-
await
|
|
202
|
+
await writeLocalOutput(file.path, file.content);
|
|
198
203
|
}
|
|
199
204
|
return {
|
|
200
205
|
directory: target,
|
|
@@ -210,36 +215,32 @@ export function registerExternalComponentTools(server, platform) {
|
|
|
210
215
|
project: projectParam,
|
|
211
216
|
environment: environmentParam,
|
|
212
217
|
applicationId: guid,
|
|
213
|
-
bundlePath: z.string().min(1).describe(
|
|
214
|
-
manifestPath: z.string().min(1).describe('manifest.json yerel yolu; slug, name, definition ve protocolVersion buradan okunur'),
|
|
218
|
+
bundlePath: z.string().min(1).describe("Tek dosyalık ES module paketinin yerel yolu (.mjs); gateway'in çalışma dizininin ya da .env MCP_INPUT_DIR'in altında (göreli yol MCP_INPUT_DIR'e göre çözülür)"),
|
|
219
|
+
manifestPath: z.string().min(1).describe('manifest.json yerel yolu (aynı izinli kökler); slug, name, definition ve protocolVersion buradan okunur'),
|
|
215
220
|
version: versionParam
|
|
216
221
|
},
|
|
217
222
|
annotations: writes
|
|
218
223
|
}, handle(config, async ({ project, environment, applicationId, bundlePath, manifestPath, version }) => {
|
|
219
224
|
await assertExternalComponentsAllowed(platform, applicationId, 'external_component_publish');
|
|
220
|
-
|
|
221
|
-
const
|
|
225
|
+
// g-12 (DD-23): manifest ve paket izinli köklerden okunur (localFiles).
|
|
226
|
+
const manifestFile = await readLocalFile('external_component_publish', manifestPath, { label: 'manifestPath', maxBytes: maxManifestBytes }, config);
|
|
227
|
+
const bundleFile = await readLocalFile('external_component_publish', bundlePath, {
|
|
228
|
+
label: 'bundlePath',
|
|
229
|
+
maxBytes: maxBundleBytes,
|
|
230
|
+
tooLarge: (real, size) => `${maxBundleBytes} bayt sınırını aşıyor (${size} B) — ${real}.`
|
|
231
|
+
}, config);
|
|
222
232
|
let manifest;
|
|
223
233
|
try {
|
|
224
|
-
manifest = JSON.parse(
|
|
234
|
+
manifest = JSON.parse(manifestFile.buffer.toString('utf8'));
|
|
225
235
|
}
|
|
226
236
|
catch (error) {
|
|
227
|
-
throw new PlatformApiError(`external_component_publish: manifest
|
|
237
|
+
throw new PlatformApiError(`external_component_publish: manifest geçerli JSON değil — ${manifestFile.real} (${error instanceof Error ? error.message : String(error)}).`);
|
|
228
238
|
}
|
|
229
239
|
const slug = typeof manifest.slug === 'string' ? manifest.slug : undefined;
|
|
230
240
|
if (!slug || !slugPattern.test(slug)) {
|
|
231
241
|
throw new PlatformApiError(`external_component_publish: manifest'teki slug 'x-' ile başlamalı ve küçük harf/rakam/tire içermeli — okunan: ${String(manifest.slug)}.`);
|
|
232
242
|
}
|
|
233
|
-
|
|
234
|
-
try {
|
|
235
|
-
bytes = await readFile(bundleFile);
|
|
236
|
-
}
|
|
237
|
-
catch (error) {
|
|
238
|
-
throw new PlatformApiError(`external_component_publish: paket okunamadı — ${bundleFile} (${error instanceof Error ? error.message : String(error)}). Yol gateway sürecinin çalıştığı makineye göre çözülür.`);
|
|
239
|
-
}
|
|
240
|
-
if (bytes.byteLength > maxBundleBytes) {
|
|
241
|
-
throw new PlatformApiError(`external_component_publish: paket ${maxBundleBytes} bayt sınırını aşıyor (${bytes.byteLength} B).`);
|
|
242
|
-
}
|
|
243
|
+
const bytes = bundleFile.buffer;
|
|
243
244
|
// EXT-001: protocolVersion, definition.blocks, ayrılmış prop adları ve prop tipleri — kayıt
|
|
244
245
|
// ucu 422 dönmeden manifest'te yakalanır; paket yükleme ikinci istek olduğu için yarım kayıt kalmaz.
|
|
245
246
|
enforcePolicy(evaluatePolicy(config, policyRules, 'externalComponent', { ...manifest, slug }, { operation: 'create' }), false);
|
|
@@ -259,7 +260,7 @@ export function registerExternalComponentTools(server, platform) {
|
|
|
259
260
|
environment,
|
|
260
261
|
multipart: [
|
|
261
262
|
{ name: 'Version', value: version },
|
|
262
|
-
{ name: 'Bundle', filename: basename(
|
|
263
|
+
{ name: 'Bundle', filename: basename(bundlePath), contentType: 'text/javascript', content: bytes }
|
|
263
264
|
]
|
|
264
265
|
});
|
|
265
266
|
return {
|
package/dist/tools/files.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { guid, projectParam, environmentParam, pagingParams, readOnly, updates, destructive, writes } from './common.js';
|
|
2
2
|
import { PlatformApiError } from '../platform/errors.js';
|
|
3
3
|
import { handle } from '../platform/responses.js';
|
|
4
|
-
import {
|
|
5
|
-
import { basename, extname
|
|
4
|
+
import { readLocalFile, resolveLocalOutput, writeLocalOutput } from '../platform/localFiles.js';
|
|
5
|
+
import { basename, extname } from 'node:path';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import { FORBIDDEN_NAME_CHARACTERS } from '../knowledge/backendConstraints.js';
|
|
8
8
|
const maxInlineBytes = 8 * 1024 * 1024;
|
|
@@ -46,14 +46,14 @@ export async function uploadFile(platform, { project, environment, path, content
|
|
|
46
46
|
let bytes;
|
|
47
47
|
let name;
|
|
48
48
|
if (path) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
name = filename ?? basename(
|
|
49
|
+
// g-12 (DD-23): yol izinli köklerden okunur (localFiles); `import_analyze` `path` de buradan geçer.
|
|
50
|
+
const read = await readLocalFile('file_upload', path, {
|
|
51
|
+
label: 'path',
|
|
52
|
+
maxBytes: maxUploadBytes,
|
|
53
|
+
tooLarge: (real, size) => `${maxUploadBytes} bayt platform sınırını aşıyor (${size} B) — ${real}.`
|
|
54
|
+
}, platform.config);
|
|
55
|
+
bytes = read.buffer;
|
|
56
|
+
name = filename ?? basename(path);
|
|
57
57
|
}
|
|
58
58
|
else if (text !== undefined) {
|
|
59
59
|
if (!filename)
|
|
@@ -108,7 +108,7 @@ export function registerFileTools(server, platform) {
|
|
|
108
108
|
inputSchema: {
|
|
109
109
|
project: projectParam,
|
|
110
110
|
environment: environmentParam,
|
|
111
|
-
path: z.string().min(1).optional().describe("
|
|
111
|
+
path: z.string().min(1).optional().describe("Yerel dosya yolu; gateway'in çalışma dizininin ya da .env MCP_INPUT_DIR'in altında (göreli yol MCP_INPUT_DIR'e göre çözülür). `content` ile birlikte verilmez"),
|
|
112
112
|
content: z.string().min(1).optional().describe('Base64 kodlanmış dosya içeriği; `filename` ile birlikte zorunludur'),
|
|
113
113
|
text: z.string().min(1).optional().describe("Düz metin içerik (UTF-8): SVG, CSV, Markdown, JSON, düz metin. `filename` ile birlikte zorunludur ve base64'e çevirmeye gerek yoktur — yalnız MCP araçlarıyla çalışan bir ajanın elinde base64 kodlayıcı yok, bu alan o boşluğu kapatır (G-26). İkili dosyalar için `path` ya da `content` kullanın."),
|
|
114
114
|
filename: z.string().min(1).optional().describe("`content` ile zorunlu; `path` verildiğinde dosya adını ezer"),
|
|
@@ -124,14 +124,15 @@ export function registerFileTools(server, platform) {
|
|
|
124
124
|
project: projectParam,
|
|
125
125
|
environment: environmentParam,
|
|
126
126
|
id: guid,
|
|
127
|
-
outPath: z.string().min(1).describe(
|
|
127
|
+
outPath: z.string().min(1).describe("İçeriğin yazılacağı yerel dosya yolu; gateway'in çalışma dizininin ya da .env MCP_INPUT_DIR'in altında (göreli yol MCP_INPUT_DIR'e göre çözülür)")
|
|
128
128
|
},
|
|
129
129
|
annotations: writes
|
|
130
130
|
}, handle(config, async ({ project, environment, id, outPath }) => {
|
|
131
|
+
// g-12 (DD-23): hedef izinli kökte mi, indirmeden ÖNCE denetlenir (localFiles).
|
|
132
|
+
const absolute = await resolveLocalOutput('file_download', 'outPath', outPath, config);
|
|
131
133
|
const payload = await platform.tenant('GET', project, `/files/${id}/download`, { environment, expectBinary: true });
|
|
132
|
-
const absolute = resolve(outPath);
|
|
133
134
|
try {
|
|
134
|
-
await
|
|
135
|
+
await writeLocalOutput(absolute, payload.bytes);
|
|
135
136
|
}
|
|
136
137
|
catch (error) {
|
|
137
138
|
throw new PlatformApiError(`file_download: dosya yazılamadı — ${absolute} (${error instanceof Error ? error.message : String(error)}).`);
|