@egdesk/next-api-plugin 1.5.2 → 1.5.4
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/generate-helpers.js +220 -2
- package/dist/generate-proxy.js +34 -2
- package/package.json +1 -1
- package/src/generate-helpers.ts +220 -2
- package/src/generate-proxy.ts +34 -2
package/dist/generate-helpers.js
CHANGED
|
@@ -51,7 +51,7 @@ function generateHelpers(projectPath) {
|
|
|
51
51
|
* EGDesk Helper Functions for Next.js
|
|
52
52
|
*
|
|
53
53
|
* Type-safe helpers for EGDesk user data, FinanceHub (banks, cards, Hometax, promissory notes),
|
|
54
|
-
* internal knowledge / business identity / company research (MCP), and browser recorder replay.
|
|
54
|
+
* internal knowledge / business identity / company research (MCP), Korean law (MCP), and browser recorder replay.
|
|
55
55
|
* Works in both client and server components.
|
|
56
56
|
*
|
|
57
57
|
* Generated by @egdesk/next-api-plugin
|
|
@@ -606,6 +606,50 @@ export async function upsertFinanceHubBankProductRows(options: {
|
|
|
606
606
|
return callFinanceHubTool('financehub_upsert_bank_product_rows', options);
|
|
607
607
|
}
|
|
608
608
|
|
|
609
|
+
/**
|
|
610
|
+
* Delete an account and all its transactions/sync rows (not credentials).
|
|
611
|
+
*/
|
|
612
|
+
export async function deleteFinanceHubAccount(bankId: string, accountNumber: string) {
|
|
613
|
+
return callFinanceHubTool('financehub_delete_account', { bankId, accountNumber });
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Delete all imported data for a bankId (accounts, transactions, sync ops).
|
|
618
|
+
*/
|
|
619
|
+
export async function deleteFinanceHubImportedDataForBank(bankId: string) {
|
|
620
|
+
return callFinanceHubTool('financehub_delete_imported_data_for_bank', { bankId });
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Delete transactions by account scope, date range, and/or ids (max 500 ids).
|
|
625
|
+
*/
|
|
626
|
+
export async function deleteFinanceHubTransactions(options: {
|
|
627
|
+
accountId?: string;
|
|
628
|
+
bankId?: string;
|
|
629
|
+
accountNumber?: string;
|
|
630
|
+
startDate?: string;
|
|
631
|
+
endDate?: string;
|
|
632
|
+
transactionIds?: string[];
|
|
633
|
+
isCard?: boolean;
|
|
634
|
+
}) {
|
|
635
|
+
return callFinanceHubTool('financehub_delete_transactions', options);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Delete bank-product table rows by ids and/or filters (max 1000 rows).
|
|
640
|
+
*/
|
|
641
|
+
export async function deleteFinanceHubBankProductRows(options: {
|
|
642
|
+
tableSlug: string;
|
|
643
|
+
ids?: string[];
|
|
644
|
+
filters?: Array<{
|
|
645
|
+
column: string;
|
|
646
|
+
op: '=' | '!=' | '>' | '<' | '>=' | '<=' | 'like' | 'in';
|
|
647
|
+
value: string | number | Array<string | number>;
|
|
648
|
+
}>;
|
|
649
|
+
}) {
|
|
650
|
+
return callFinanceHubTool('financehub_delete_bank_product_rows', options);
|
|
651
|
+
}
|
|
652
|
+
|
|
609
653
|
// ==========================================
|
|
610
654
|
// INTERNAL KNOWLEDGE / BUSINESS IDENTITY / COMPANY RESEARCH (MCP)
|
|
611
655
|
// ==========================================
|
|
@@ -824,6 +868,9 @@ export async function getBrowserRecordingReplayOptions(testFile: string) {
|
|
|
824
868
|
}
|
|
825
869
|
|
|
826
870
|
export type BrowserRecordingRunOptions = {
|
|
871
|
+
headless?: boolean;
|
|
872
|
+
/** Save headless preference for scheduled runs */
|
|
873
|
+
persistHeadless?: boolean;
|
|
827
874
|
startDate?: string;
|
|
828
875
|
endDate?: string;
|
|
829
876
|
datePickersByIndex?: string[];
|
|
@@ -831,7 +878,18 @@ export type BrowserRecordingRunOptions = {
|
|
|
831
878
|
labeledFieldFills?: (string | undefined)[][];
|
|
832
879
|
};
|
|
833
880
|
|
|
834
|
-
|
|
881
|
+
export type BrowserRecordingScheduleOptions = {
|
|
882
|
+
testName?: string;
|
|
883
|
+
scheduledTime?: string;
|
|
884
|
+
frequencyType?: 'daily' | 'weekly' | 'monthly' | 'custom';
|
|
885
|
+
dayOfWeek?: number;
|
|
886
|
+
dayOfMonth?: number;
|
|
887
|
+
customIntervalDays?: number;
|
|
888
|
+
enabled?: boolean;
|
|
889
|
+
headless?: boolean;
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
/** Replay a saved recording in Chrome (optional headless, dates + labeledFieldFills) */
|
|
835
893
|
export async function runBrowserRecording(
|
|
836
894
|
testFile: string,
|
|
837
895
|
options: BrowserRecordingRunOptions = {}
|
|
@@ -842,6 +900,93 @@ export async function runBrowserRecording(
|
|
|
842
900
|
});
|
|
843
901
|
}
|
|
844
902
|
|
|
903
|
+
/** List Playwright scheduler entries for browser recorder tests */
|
|
904
|
+
export async function listBrowserRecordingSchedules() {
|
|
905
|
+
return callBrowserRecordingTool('browser_recording_list_schedules', {});
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
/** Get schedule for a test file, or null */
|
|
909
|
+
export async function getBrowserRecordingSchedule(testFile: string) {
|
|
910
|
+
return callBrowserRecordingTool('browser_recording_get_schedule', { testFile });
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/** Create or update a recurring schedule for a saved test */
|
|
914
|
+
export async function setBrowserRecordingSchedule(
|
|
915
|
+
testFile: string,
|
|
916
|
+
options: BrowserRecordingScheduleOptions = {}
|
|
917
|
+
) {
|
|
918
|
+
return callBrowserRecordingTool('browser_recording_set_schedule', {
|
|
919
|
+
testFile,
|
|
920
|
+
...options
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
/** Remove scheduler entry for a test file */
|
|
925
|
+
export async function removeBrowserRecordingSchedule(testFile: string) {
|
|
926
|
+
return callBrowserRecordingTool('browser_recording_remove_schedule', { testFile });
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
/** Pause a recurring schedule without deleting it */
|
|
930
|
+
export async function pauseBrowserRecordingSchedule(testFile: string) {
|
|
931
|
+
return callBrowserRecordingTool('browser_recording_pause_schedule', { testFile });
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/** Resume a paused recurring schedule */
|
|
935
|
+
export async function resumeBrowserRecordingSchedule(testFile: string) {
|
|
936
|
+
return callBrowserRecordingTool('browser_recording_resume_schedule', { testFile });
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
export type BrowserRecordingSyncConfigOptions = {
|
|
940
|
+
testFile?: string;
|
|
941
|
+
scriptFolderPath?: string;
|
|
942
|
+
scriptName?: string;
|
|
943
|
+
targetTableId?: string;
|
|
944
|
+
columnMappings?: Record<string, string>;
|
|
945
|
+
headerRow?: number;
|
|
946
|
+
skipBottomRows?: number;
|
|
947
|
+
sheetIndex?: number;
|
|
948
|
+
appliedSplits?: Array<{ originalColumn: string; dateColumn: string; numberColumn: string }>;
|
|
949
|
+
uniqueKeyColumns?: string[];
|
|
950
|
+
duplicateAction?: 'skip' | 'update' | 'allow' | 'replace-date-range' | 'replace-all';
|
|
951
|
+
fileAction?: 'keep' | 'archive' | 'delete';
|
|
952
|
+
enabled?: boolean;
|
|
953
|
+
autoSyncEnabled?: boolean;
|
|
954
|
+
};
|
|
955
|
+
|
|
956
|
+
/** List EGDesk-Browser download folders with Excel/CSV files */
|
|
957
|
+
export async function listBrowserRecordingDownloadFolders() {
|
|
958
|
+
return callBrowserRecordingTool('browser_recording_list_download_folders', {});
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/** List sync-to-SQL configs for browser downloads */
|
|
962
|
+
export async function listBrowserRecordingSyncConfigs() {
|
|
963
|
+
return callBrowserRecordingTool('browser_recording_list_sync_configs', {});
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
/** Get sync config by testFile or scriptFolderPath */
|
|
967
|
+
export async function getBrowserRecordingSyncConfig(opts: {
|
|
968
|
+
testFile?: string;
|
|
969
|
+
scriptFolderPath?: string;
|
|
970
|
+
}) {
|
|
971
|
+
return callBrowserRecordingTool('browser_recording_get_sync_config', opts);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
/** Create or update sync-to-DB for a browser download folder */
|
|
975
|
+
export async function setBrowserRecordingSyncConfig(
|
|
976
|
+
opts: BrowserRecordingSyncConfigOptions
|
|
977
|
+
) {
|
|
978
|
+
return callBrowserRecordingTool('browser_recording_set_sync_config', opts);
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
/** Remove sync config by configId, testFile, or scriptFolderPath */
|
|
982
|
+
export async function removeBrowserRecordingSyncConfig(opts: {
|
|
983
|
+
configId?: string;
|
|
984
|
+
testFile?: string;
|
|
985
|
+
scriptFolderPath?: string;
|
|
986
|
+
}) {
|
|
987
|
+
return callBrowserRecordingTool('browser_recording_remove_sync_config', opts);
|
|
988
|
+
}
|
|
989
|
+
|
|
845
990
|
// ==========================================
|
|
846
991
|
// AI CENTER (workflows, entities, relations, tags)
|
|
847
992
|
// ==========================================
|
|
@@ -1126,6 +1271,79 @@ export async function getCalendarEventsFromAICenter() {
|
|
|
1126
1271
|
export async function completeTask(taskId: string, status: 'completed' | 'approved' | 'rejected') {
|
|
1127
1272
|
return callAICenterTool('ai_center_complete_task', { taskId, status });
|
|
1128
1273
|
}
|
|
1274
|
+
|
|
1275
|
+
// ==========================================
|
|
1276
|
+
// KOREAN LAW / LAWYER (MCP)
|
|
1277
|
+
// ==========================================
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* Call EGDesk Korean Law MCP tool (법제처 API — laws, precedents, admin rules, municipal ordinances).
|
|
1281
|
+
*
|
|
1282
|
+
* - Server: \`POST {apiUrl}/korean-law/tools/call\`
|
|
1283
|
+
* - Client: \`POST /__korean_law_proxy\` (see proxy.ts / middleware)
|
|
1284
|
+
*/
|
|
1285
|
+
export async function callKoreanLawTool(
|
|
1286
|
+
toolName: string,
|
|
1287
|
+
args: Record<string, any> = {}
|
|
1288
|
+
): Promise<any> {
|
|
1289
|
+
const body = JSON.stringify({ tool: toolName, arguments: args });
|
|
1290
|
+
const headers: Record<string, string> = {
|
|
1291
|
+
'Content-Type': 'application/json'
|
|
1292
|
+
};
|
|
1293
|
+
|
|
1294
|
+
const isServer = typeof window === 'undefined';
|
|
1295
|
+
|
|
1296
|
+
let response: Response;
|
|
1297
|
+
if (isServer) {
|
|
1298
|
+
const apiUrl =
|
|
1299
|
+
(typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
|
|
1300
|
+
EGDESK_CONFIG.apiUrl;
|
|
1301
|
+
const apiKey =
|
|
1302
|
+
(typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_KEY) ||
|
|
1303
|
+
EGDESK_CONFIG.apiKey;
|
|
1304
|
+
if (apiKey) {
|
|
1305
|
+
headers['X-Api-Key'] = apiKey;
|
|
1306
|
+
}
|
|
1307
|
+
response = await fetch(\`\${apiUrl}/korean-law/tools/call\`, {
|
|
1308
|
+
method: 'POST',
|
|
1309
|
+
headers,
|
|
1310
|
+
body
|
|
1311
|
+
});
|
|
1312
|
+
} else {
|
|
1313
|
+
response = await fetch('/__korean_law_proxy', {
|
|
1314
|
+
method: 'POST',
|
|
1315
|
+
headers,
|
|
1316
|
+
body
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
return parseEgdeskMcpToolResponse(response);
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
/** Search laws, precedents, administrative rules, or municipal ordinances */
|
|
1324
|
+
export async function searchKoreanLaw(
|
|
1325
|
+
query: string,
|
|
1326
|
+
options: {
|
|
1327
|
+
target?: 'law' | 'prec' | 'admrul' | 'ordin';
|
|
1328
|
+
display?: number;
|
|
1329
|
+
page?: number;
|
|
1330
|
+
} = {}
|
|
1331
|
+
) {
|
|
1332
|
+
return callKoreanLawTool('korean_law_search', { query, ...options });
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
/** Get full text of a law, administrative rule, or municipal ordinance */
|
|
1336
|
+
export async function getKoreanLawText(
|
|
1337
|
+
id: string,
|
|
1338
|
+
target: 'law' | 'admrul' | 'ordin' = 'law'
|
|
1339
|
+
) {
|
|
1340
|
+
return callKoreanLawTool('korean_law_get_text', { id, target });
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
/** Get full text of a court precedent (판례) */
|
|
1344
|
+
export async function getKoreanLawDecision(id: string) {
|
|
1345
|
+
return callKoreanLawTool('korean_law_get_decision', { id });
|
|
1346
|
+
}
|
|
1129
1347
|
`;
|
|
1130
1348
|
fs.writeFileSync(helperPath, helperContent.replace(/\r?\n/g, os.EOL), 'utf-8');
|
|
1131
1349
|
console.log(`✅ Generated ${helperPath}`);
|
package/dist/generate-proxy.js
CHANGED
|
@@ -75,7 +75,7 @@ import type { NextRequest } from 'next/server';
|
|
|
75
75
|
/**
|
|
76
76
|
* EGDesk Database Proxy (Next.js 16+)
|
|
77
77
|
*
|
|
78
|
-
* Intercepts __user_data_proxy, __browser_recording_proxy, __internal_knowledge_proxy, and
|
|
78
|
+
* Intercepts __user_data_proxy, __browser_recording_proxy, __internal_knowledge_proxy, __ai_center_proxy, and __korean_law_proxy requests
|
|
79
79
|
* and forwards them to the EGDesk MCP HTTP server. This avoids CORS in local and tunneled environments.
|
|
80
80
|
*
|
|
81
81
|
* Generated by @egdesk/next-api-plugin
|
|
@@ -214,6 +214,38 @@ export async function proxy(request: NextRequest) {
|
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
+
if (pathname.includes('__korean_law_proxy')) {
|
|
218
|
+
try {
|
|
219
|
+
const body = await request.text();
|
|
220
|
+
|
|
221
|
+
const apiKey = process.env.NEXT_PUBLIC_EGDESK_API_KEY;
|
|
222
|
+
const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
|
|
223
|
+
|
|
224
|
+
const headers: HeadersInit = {
|
|
225
|
+
'Content-Type': 'application/json',
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
if (apiKey) {
|
|
229
|
+
headers['X-Api-Key'] = apiKey;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const response = await fetch(\`\${apiUrl}/korean-law/tools/call\`, {
|
|
233
|
+
method: 'POST',
|
|
234
|
+
headers,
|
|
235
|
+
body,
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
const result = await response.json();
|
|
239
|
+
|
|
240
|
+
return NextResponse.json(result, { status: response.status });
|
|
241
|
+
} catch (error: any) {
|
|
242
|
+
return NextResponse.json(
|
|
243
|
+
{ error: 'Proxy error', message: error.message },
|
|
244
|
+
{ status: 500 }
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
217
249
|
// Continue to next proxy or route
|
|
218
250
|
return NextResponse.next();
|
|
219
251
|
}
|
|
@@ -222,7 +254,7 @@ export const config = {
|
|
|
222
254
|
matcher: [
|
|
223
255
|
/*
|
|
224
256
|
* Match all paths except static assets
|
|
225
|
-
* The proxy function filters for __user_data_proxy / __browser_recording_proxy / __internal_knowledge_proxy
|
|
257
|
+
* The proxy function filters for __user_data_proxy / __browser_recording_proxy / __internal_knowledge_proxy / __ai_center_proxy / __korean_law_proxy
|
|
226
258
|
*/
|
|
227
259
|
'/:path*',
|
|
228
260
|
],
|
package/package.json
CHANGED
package/src/generate-helpers.ts
CHANGED
|
@@ -18,7 +18,7 @@ export function generateHelpers(projectPath: string): void {
|
|
|
18
18
|
* EGDesk Helper Functions for Next.js
|
|
19
19
|
*
|
|
20
20
|
* Type-safe helpers for EGDesk user data, FinanceHub (banks, cards, Hometax, promissory notes),
|
|
21
|
-
* internal knowledge / business identity / company research (MCP), and browser recorder replay.
|
|
21
|
+
* internal knowledge / business identity / company research (MCP), Korean law (MCP), and browser recorder replay.
|
|
22
22
|
* Works in both client and server components.
|
|
23
23
|
*
|
|
24
24
|
* Generated by @egdesk/next-api-plugin
|
|
@@ -573,6 +573,50 @@ export async function upsertFinanceHubBankProductRows(options: {
|
|
|
573
573
|
return callFinanceHubTool('financehub_upsert_bank_product_rows', options);
|
|
574
574
|
}
|
|
575
575
|
|
|
576
|
+
/**
|
|
577
|
+
* Delete an account and all its transactions/sync rows (not credentials).
|
|
578
|
+
*/
|
|
579
|
+
export async function deleteFinanceHubAccount(bankId: string, accountNumber: string) {
|
|
580
|
+
return callFinanceHubTool('financehub_delete_account', { bankId, accountNumber });
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Delete all imported data for a bankId (accounts, transactions, sync ops).
|
|
585
|
+
*/
|
|
586
|
+
export async function deleteFinanceHubImportedDataForBank(bankId: string) {
|
|
587
|
+
return callFinanceHubTool('financehub_delete_imported_data_for_bank', { bankId });
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Delete transactions by account scope, date range, and/or ids (max 500 ids).
|
|
592
|
+
*/
|
|
593
|
+
export async function deleteFinanceHubTransactions(options: {
|
|
594
|
+
accountId?: string;
|
|
595
|
+
bankId?: string;
|
|
596
|
+
accountNumber?: string;
|
|
597
|
+
startDate?: string;
|
|
598
|
+
endDate?: string;
|
|
599
|
+
transactionIds?: string[];
|
|
600
|
+
isCard?: boolean;
|
|
601
|
+
}) {
|
|
602
|
+
return callFinanceHubTool('financehub_delete_transactions', options);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Delete bank-product table rows by ids and/or filters (max 1000 rows).
|
|
607
|
+
*/
|
|
608
|
+
export async function deleteFinanceHubBankProductRows(options: {
|
|
609
|
+
tableSlug: string;
|
|
610
|
+
ids?: string[];
|
|
611
|
+
filters?: Array<{
|
|
612
|
+
column: string;
|
|
613
|
+
op: '=' | '!=' | '>' | '<' | '>=' | '<=' | 'like' | 'in';
|
|
614
|
+
value: string | number | Array<string | number>;
|
|
615
|
+
}>;
|
|
616
|
+
}) {
|
|
617
|
+
return callFinanceHubTool('financehub_delete_bank_product_rows', options);
|
|
618
|
+
}
|
|
619
|
+
|
|
576
620
|
// ==========================================
|
|
577
621
|
// INTERNAL KNOWLEDGE / BUSINESS IDENTITY / COMPANY RESEARCH (MCP)
|
|
578
622
|
// ==========================================
|
|
@@ -791,6 +835,9 @@ export async function getBrowserRecordingReplayOptions(testFile: string) {
|
|
|
791
835
|
}
|
|
792
836
|
|
|
793
837
|
export type BrowserRecordingRunOptions = {
|
|
838
|
+
headless?: boolean;
|
|
839
|
+
/** Save headless preference for scheduled runs */
|
|
840
|
+
persistHeadless?: boolean;
|
|
794
841
|
startDate?: string;
|
|
795
842
|
endDate?: string;
|
|
796
843
|
datePickersByIndex?: string[];
|
|
@@ -798,7 +845,18 @@ export type BrowserRecordingRunOptions = {
|
|
|
798
845
|
labeledFieldFills?: (string | undefined)[][];
|
|
799
846
|
};
|
|
800
847
|
|
|
801
|
-
|
|
848
|
+
export type BrowserRecordingScheduleOptions = {
|
|
849
|
+
testName?: string;
|
|
850
|
+
scheduledTime?: string;
|
|
851
|
+
frequencyType?: 'daily' | 'weekly' | 'monthly' | 'custom';
|
|
852
|
+
dayOfWeek?: number;
|
|
853
|
+
dayOfMonth?: number;
|
|
854
|
+
customIntervalDays?: number;
|
|
855
|
+
enabled?: boolean;
|
|
856
|
+
headless?: boolean;
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
/** Replay a saved recording in Chrome (optional headless, dates + labeledFieldFills) */
|
|
802
860
|
export async function runBrowserRecording(
|
|
803
861
|
testFile: string,
|
|
804
862
|
options: BrowserRecordingRunOptions = {}
|
|
@@ -809,6 +867,93 @@ export async function runBrowserRecording(
|
|
|
809
867
|
});
|
|
810
868
|
}
|
|
811
869
|
|
|
870
|
+
/** List Playwright scheduler entries for browser recorder tests */
|
|
871
|
+
export async function listBrowserRecordingSchedules() {
|
|
872
|
+
return callBrowserRecordingTool('browser_recording_list_schedules', {});
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/** Get schedule for a test file, or null */
|
|
876
|
+
export async function getBrowserRecordingSchedule(testFile: string) {
|
|
877
|
+
return callBrowserRecordingTool('browser_recording_get_schedule', { testFile });
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/** Create or update a recurring schedule for a saved test */
|
|
881
|
+
export async function setBrowserRecordingSchedule(
|
|
882
|
+
testFile: string,
|
|
883
|
+
options: BrowserRecordingScheduleOptions = {}
|
|
884
|
+
) {
|
|
885
|
+
return callBrowserRecordingTool('browser_recording_set_schedule', {
|
|
886
|
+
testFile,
|
|
887
|
+
...options
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
/** Remove scheduler entry for a test file */
|
|
892
|
+
export async function removeBrowserRecordingSchedule(testFile: string) {
|
|
893
|
+
return callBrowserRecordingTool('browser_recording_remove_schedule', { testFile });
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/** Pause a recurring schedule without deleting it */
|
|
897
|
+
export async function pauseBrowserRecordingSchedule(testFile: string) {
|
|
898
|
+
return callBrowserRecordingTool('browser_recording_pause_schedule', { testFile });
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/** Resume a paused recurring schedule */
|
|
902
|
+
export async function resumeBrowserRecordingSchedule(testFile: string) {
|
|
903
|
+
return callBrowserRecordingTool('browser_recording_resume_schedule', { testFile });
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
export type BrowserRecordingSyncConfigOptions = {
|
|
907
|
+
testFile?: string;
|
|
908
|
+
scriptFolderPath?: string;
|
|
909
|
+
scriptName?: string;
|
|
910
|
+
targetTableId?: string;
|
|
911
|
+
columnMappings?: Record<string, string>;
|
|
912
|
+
headerRow?: number;
|
|
913
|
+
skipBottomRows?: number;
|
|
914
|
+
sheetIndex?: number;
|
|
915
|
+
appliedSplits?: Array<{ originalColumn: string; dateColumn: string; numberColumn: string }>;
|
|
916
|
+
uniqueKeyColumns?: string[];
|
|
917
|
+
duplicateAction?: 'skip' | 'update' | 'allow' | 'replace-date-range' | 'replace-all';
|
|
918
|
+
fileAction?: 'keep' | 'archive' | 'delete';
|
|
919
|
+
enabled?: boolean;
|
|
920
|
+
autoSyncEnabled?: boolean;
|
|
921
|
+
};
|
|
922
|
+
|
|
923
|
+
/** List EGDesk-Browser download folders with Excel/CSV files */
|
|
924
|
+
export async function listBrowserRecordingDownloadFolders() {
|
|
925
|
+
return callBrowserRecordingTool('browser_recording_list_download_folders', {});
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
/** List sync-to-SQL configs for browser downloads */
|
|
929
|
+
export async function listBrowserRecordingSyncConfigs() {
|
|
930
|
+
return callBrowserRecordingTool('browser_recording_list_sync_configs', {});
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
/** Get sync config by testFile or scriptFolderPath */
|
|
934
|
+
export async function getBrowserRecordingSyncConfig(opts: {
|
|
935
|
+
testFile?: string;
|
|
936
|
+
scriptFolderPath?: string;
|
|
937
|
+
}) {
|
|
938
|
+
return callBrowserRecordingTool('browser_recording_get_sync_config', opts);
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
/** Create or update sync-to-DB for a browser download folder */
|
|
942
|
+
export async function setBrowserRecordingSyncConfig(
|
|
943
|
+
opts: BrowserRecordingSyncConfigOptions
|
|
944
|
+
) {
|
|
945
|
+
return callBrowserRecordingTool('browser_recording_set_sync_config', opts);
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/** Remove sync config by configId, testFile, or scriptFolderPath */
|
|
949
|
+
export async function removeBrowserRecordingSyncConfig(opts: {
|
|
950
|
+
configId?: string;
|
|
951
|
+
testFile?: string;
|
|
952
|
+
scriptFolderPath?: string;
|
|
953
|
+
}) {
|
|
954
|
+
return callBrowserRecordingTool('browser_recording_remove_sync_config', opts);
|
|
955
|
+
}
|
|
956
|
+
|
|
812
957
|
// ==========================================
|
|
813
958
|
// AI CENTER (workflows, entities, relations, tags)
|
|
814
959
|
// ==========================================
|
|
@@ -1093,6 +1238,79 @@ export async function getCalendarEventsFromAICenter() {
|
|
|
1093
1238
|
export async function completeTask(taskId: string, status: 'completed' | 'approved' | 'rejected') {
|
|
1094
1239
|
return callAICenterTool('ai_center_complete_task', { taskId, status });
|
|
1095
1240
|
}
|
|
1241
|
+
|
|
1242
|
+
// ==========================================
|
|
1243
|
+
// KOREAN LAW / LAWYER (MCP)
|
|
1244
|
+
// ==========================================
|
|
1245
|
+
|
|
1246
|
+
/**
|
|
1247
|
+
* Call EGDesk Korean Law MCP tool (법제처 API — laws, precedents, admin rules, municipal ordinances).
|
|
1248
|
+
*
|
|
1249
|
+
* - Server: \`POST {apiUrl}/korean-law/tools/call\`
|
|
1250
|
+
* - Client: \`POST /__korean_law_proxy\` (see proxy.ts / middleware)
|
|
1251
|
+
*/
|
|
1252
|
+
export async function callKoreanLawTool(
|
|
1253
|
+
toolName: string,
|
|
1254
|
+
args: Record<string, any> = {}
|
|
1255
|
+
): Promise<any> {
|
|
1256
|
+
const body = JSON.stringify({ tool: toolName, arguments: args });
|
|
1257
|
+
const headers: Record<string, string> = {
|
|
1258
|
+
'Content-Type': 'application/json'
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1261
|
+
const isServer = typeof window === 'undefined';
|
|
1262
|
+
|
|
1263
|
+
let response: Response;
|
|
1264
|
+
if (isServer) {
|
|
1265
|
+
const apiUrl =
|
|
1266
|
+
(typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
|
|
1267
|
+
EGDESK_CONFIG.apiUrl;
|
|
1268
|
+
const apiKey =
|
|
1269
|
+
(typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_KEY) ||
|
|
1270
|
+
EGDESK_CONFIG.apiKey;
|
|
1271
|
+
if (apiKey) {
|
|
1272
|
+
headers['X-Api-Key'] = apiKey;
|
|
1273
|
+
}
|
|
1274
|
+
response = await fetch(\`\${apiUrl}/korean-law/tools/call\`, {
|
|
1275
|
+
method: 'POST',
|
|
1276
|
+
headers,
|
|
1277
|
+
body
|
|
1278
|
+
});
|
|
1279
|
+
} else {
|
|
1280
|
+
response = await fetch('/__korean_law_proxy', {
|
|
1281
|
+
method: 'POST',
|
|
1282
|
+
headers,
|
|
1283
|
+
body
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
return parseEgdeskMcpToolResponse(response);
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
/** Search laws, precedents, administrative rules, or municipal ordinances */
|
|
1291
|
+
export async function searchKoreanLaw(
|
|
1292
|
+
query: string,
|
|
1293
|
+
options: {
|
|
1294
|
+
target?: 'law' | 'prec' | 'admrul' | 'ordin';
|
|
1295
|
+
display?: number;
|
|
1296
|
+
page?: number;
|
|
1297
|
+
} = {}
|
|
1298
|
+
) {
|
|
1299
|
+
return callKoreanLawTool('korean_law_search', { query, ...options });
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
/** Get full text of a law, administrative rule, or municipal ordinance */
|
|
1303
|
+
export async function getKoreanLawText(
|
|
1304
|
+
id: string,
|
|
1305
|
+
target: 'law' | 'admrul' | 'ordin' = 'law'
|
|
1306
|
+
) {
|
|
1307
|
+
return callKoreanLawTool('korean_law_get_text', { id, target });
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
/** Get full text of a court precedent (판례) */
|
|
1311
|
+
export async function getKoreanLawDecision(id: string) {
|
|
1312
|
+
return callKoreanLawTool('korean_law_get_decision', { id });
|
|
1313
|
+
}
|
|
1096
1314
|
`;
|
|
1097
1315
|
|
|
1098
1316
|
fs.writeFileSync(helperPath, helperContent.replace(/\r?\n/g, os.EOL), 'utf-8');
|
package/src/generate-proxy.ts
CHANGED
|
@@ -45,7 +45,7 @@ import type { NextRequest } from 'next/server';
|
|
|
45
45
|
/**
|
|
46
46
|
* EGDesk Database Proxy (Next.js 16+)
|
|
47
47
|
*
|
|
48
|
-
* Intercepts __user_data_proxy, __browser_recording_proxy, __internal_knowledge_proxy, and
|
|
48
|
+
* Intercepts __user_data_proxy, __browser_recording_proxy, __internal_knowledge_proxy, __ai_center_proxy, and __korean_law_proxy requests
|
|
49
49
|
* and forwards them to the EGDesk MCP HTTP server. This avoids CORS in local and tunneled environments.
|
|
50
50
|
*
|
|
51
51
|
* Generated by @egdesk/next-api-plugin
|
|
@@ -184,6 +184,38 @@ export async function proxy(request: NextRequest) {
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
if (pathname.includes('__korean_law_proxy')) {
|
|
188
|
+
try {
|
|
189
|
+
const body = await request.text();
|
|
190
|
+
|
|
191
|
+
const apiKey = process.env.NEXT_PUBLIC_EGDESK_API_KEY;
|
|
192
|
+
const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
|
|
193
|
+
|
|
194
|
+
const headers: HeadersInit = {
|
|
195
|
+
'Content-Type': 'application/json',
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
if (apiKey) {
|
|
199
|
+
headers['X-Api-Key'] = apiKey;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const response = await fetch(\`\${apiUrl}/korean-law/tools/call\`, {
|
|
203
|
+
method: 'POST',
|
|
204
|
+
headers,
|
|
205
|
+
body,
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
const result = await response.json();
|
|
209
|
+
|
|
210
|
+
return NextResponse.json(result, { status: response.status });
|
|
211
|
+
} catch (error: any) {
|
|
212
|
+
return NextResponse.json(
|
|
213
|
+
{ error: 'Proxy error', message: error.message },
|
|
214
|
+
{ status: 500 }
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
187
219
|
// Continue to next proxy or route
|
|
188
220
|
return NextResponse.next();
|
|
189
221
|
}
|
|
@@ -192,7 +224,7 @@ export const config = {
|
|
|
192
224
|
matcher: [
|
|
193
225
|
/*
|
|
194
226
|
* Match all paths except static assets
|
|
195
|
-
* The proxy function filters for __user_data_proxy / __browser_recording_proxy / __internal_knowledge_proxy
|
|
227
|
+
* The proxy function filters for __user_data_proxy / __browser_recording_proxy / __internal_knowledge_proxy / __ai_center_proxy / __korean_law_proxy
|
|
196
228
|
*/
|
|
197
229
|
'/:path*',
|
|
198
230
|
],
|