@egdesk/next-api-plugin 1.5.33 → 1.5.38

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/README.md CHANGED
@@ -6,7 +6,7 @@ Next.js plugin for EGDesk database proxy integration. Provides middleware-based
6
6
 
7
7
  - 🔒 CORS-free database access via Next.js middleware (or `proxy.ts` on Next.js 16+)
8
8
  - 🌐 Works in both local and tunneled environments
9
- - 📝 Type-safe table definitions and helper functions (user data, FinanceHub, internal knowledge / business identity / company research, browser recording)
9
+ - 📝 Type-safe table definitions and helper functions (user data, FinanceHub, internal knowledge / business identity / company research, browser recording replay + live browse)
10
10
  - 🚀 Auto-discovery of database tables
11
11
  - 🔧 Zero configuration after setup
12
12
 
@@ -137,9 +137,9 @@ function generateHelpers(projectPath, options = {}) {
137
137
  const helperContent = `/**
138
138
  * EGDesk Helper Functions for Next.js
139
139
  *
140
- * Type-safe helpers for EGDesk user data, Google Workspace (Sheets / Drive MCP + sync, Gmail, Apps Script),
140
+ * Type-safe helpers for EGDesk user data, Google Workspace (Sheets / Drive / Docs / Slides MCP + sync, Gmail, Apps Script),
141
141
  * FinanceHub (banks, cards, Hometax, promissory notes),
142
- * internal knowledge / business identity / company research (MCP), Korean law (MCP), and browser recorder replay.
142
+ * internal knowledge / business identity / company research (MCP), Korean law (MCP), and browser recorder replay / live browse.
143
143
  * Works in both client and server components.
144
144
  *
145
145
  * Generated by @egdesk/next-api-plugin — do not edit by hand.
@@ -154,6 +154,7 @@ function generateHelpers(projectPath, options = {}) {
154
154
  * - Check that EGDesk is running and MCP tools are actually available before relying on them.
155
155
  * - For app code in this repo, keep using these helpers (queryTable, etc.) — MCP is optional for agents.
156
156
  * - If MCP tools are missing/empty, fall back to helpers + EGDESK-README.md; ask the user to install MCP from EGDesk.
157
+ * - Tunnel: getEgdeskTunnel() (live prod/dev URLs + X-Api-Key). Embed into Apps Script with setupAppsScriptEgdeskTunnel().
157
158
  */
158
159
 
159
160
  import { EGDESK_CONFIG } from './egdesk.config';
@@ -1654,7 +1655,7 @@ export async function searchCompanyResearch(searchText: string) {
1654
1655
  // ==========================================
1655
1656
 
1656
1657
  /**
1657
- * Call EGDesk Browser Recording MCP tool (saved recorder tests, replay with optional dates).
1658
+ * Call EGDesk Browser Recording MCP tool (saved tests, replay, and live site+login sessions).
1658
1659
  *
1659
1660
  * - Server: \`POST {apiUrl}/browser-recording/tools/call\`
1660
1661
  * - Client: \`POST /__browser_recording_proxy\` (see proxy.ts / middleware)
@@ -1818,6 +1819,94 @@ export async function removeBrowserRecordingSyncConfig(opts: {
1818
1819
  return callBrowserRecordingTool('browser_recording_remove_sync_config', opts);
1819
1820
  }
1820
1821
 
1822
+ /** Recorded sites → logins → scripts (passwords never included) */
1823
+ export async function listBrowserRecordingSites(site?: string) {
1824
+ return callBrowserRecordingTool('browser_recording_list_sites', site ? { site } : {});
1825
+ }
1826
+
1827
+ /** One recorded login: identity + login vs post-login actions (no passwords) */
1828
+ export async function getBrowserRecordingAccount(siteKey: string, accountKey: string) {
1829
+ return callBrowserRecordingTool('browser_recording_get_account', { siteKey, accountKey });
1830
+ }
1831
+
1832
+ /**
1833
+ * Open Chrome after the recorded login only. Leaves the session open.
1834
+ * Use inspect / search / click next — do not close after login.
1835
+ */
1836
+ export async function openBrowserRecordingAccount(
1837
+ siteKey: string,
1838
+ accountKey: string,
1839
+ scriptPath?: string
1840
+ ) {
1841
+ return callBrowserRecordingTool('browser_recording_open_account', {
1842
+ siteKey,
1843
+ accountKey,
1844
+ ...(scriptPath ? { scriptPath } : {})
1845
+ });
1846
+ }
1847
+
1848
+ /** Numbered live-page elements, including left-nav / header menus */
1849
+ export async function inspectBrowserRecordingPage(sessionId: string) {
1850
+ return callBrowserRecordingTool('browser_recording_inspect_page', { sessionId });
1851
+ }
1852
+
1853
+ /** Search live-page labels (exact/substring first). Returns indexes for click. */
1854
+ export async function searchBrowserRecordingElements(sessionId: string, query: string) {
1855
+ return callBrowserRecordingTool('browser_recording_search_elements', { sessionId, query });
1856
+ }
1857
+
1858
+ /** Visible form fields; password values redacted */
1859
+ export async function getBrowserRecordingForms(
1860
+ sessionId: string,
1861
+ scroll?: 'none' | 'up' | 'down'
1862
+ ) {
1863
+ return callBrowserRecordingTool('browser_recording_get_forms', {
1864
+ sessionId,
1865
+ ...(scroll && scroll !== 'none' ? { scroll } : {})
1866
+ });
1867
+ }
1868
+
1869
+ /** Click by last-inspect index (prefers the real link over a wrapping table cell) */
1870
+ export async function clickBrowserRecordingElement(sessionId: string, elementIndex: number) {
1871
+ return callBrowserRecordingTool('browser_recording_click_element', { sessionId, elementIndex });
1872
+ }
1873
+
1874
+ /** Fill by field_id from getBrowserRecordingForms. Password fields are rejected. */
1875
+ export async function fillBrowserRecordingForm(
1876
+ sessionId: string,
1877
+ fields: Array<{ field_id: string; value: string }>
1878
+ ) {
1879
+ return callBrowserRecordingTool('browser_recording_fill_form', { sessionId, fields });
1880
+ }
1881
+
1882
+ /** Press Enter / Escape / arrows in the open live session (e.g. after 메뉴검색) */
1883
+ export async function pressBrowserRecordingKey(
1884
+ sessionId: string,
1885
+ key: 'Enter' | 'Escape' | 'Tab' | 'ArrowDown' | 'ArrowUp' | 'ArrowLeft' | 'ArrowRight' | 'Backspace'
1886
+ ) {
1887
+ return callBrowserRecordingTool('browser_recording_press_key', { sessionId, key });
1888
+ }
1889
+
1890
+ /** Open live browse sessions (site, login, url, sessionId) */
1891
+ export async function listBrowserRecordingSessions() {
1892
+ return callBrowserRecordingTool('browser_recording_list_sessions', {});
1893
+ }
1894
+
1895
+ /** Close a live session only when fully done — not after login */
1896
+ export async function closeBrowserRecordingSession(sessionId: string) {
1897
+ return callBrowserRecordingTool('browser_recording_close_session', { sessionId });
1898
+ }
1899
+
1900
+ /** Workflow clicks/fills/keys logged in an open live session (no passwords) */
1901
+ export async function listBrowserRecordingSessionActions(sessionId: string) {
1902
+ return callBrowserRecordingTool('browser_recording_list_session_actions', { sessionId });
1903
+ }
1904
+
1905
+ /** Save the live session as a new *.spec.js (login prefix + logged workflow). Does not close Chrome. */
1906
+ export async function saveBrowserRecordingSession(sessionId: string, name: string) {
1907
+ return callBrowserRecordingTool('browser_recording_save_session', { sessionId, name });
1908
+ }
1909
+
1821
1910
  // ==========================================
1822
1911
  // AI CENTER (workflows, entities, relations, tags)
1823
1912
  // ==========================================
@@ -2945,6 +3034,7 @@ export async function syncDrive(options: {
2945
3034
  /**
2946
3035
  * Call EGDesk Sheets MCP tool.
2947
3036
  *
3037
+ * Auth: personal OAuth, service account, or domain-wide delegation (call getSheetsAuthStatus() first).
2948
3038
  * - Server: \`POST {apiUrl}/sheets/tools/call\`
2949
3039
  * - Client: \`POST /__sheets_proxy\`
2950
3040
  */
@@ -2977,6 +3067,11 @@ export async function callSheetsTool(
2977
3067
  return parseEgdeskMcpToolResponse(response);
2978
3068
  }
2979
3069
 
3070
+ /** Who Sheets/Docs/Slides/Drive calls act as: personal_oauth, service_account, or domain_wide_delegation */
3071
+ export async function getSheetsAuthStatus() {
3072
+ return callSheetsTool('sheets_auth_status', {});
3073
+ }
3074
+
2980
3075
  /** Spreadsheet metadata (tabs, dimensions) */
2981
3076
  export async function getSpreadsheet(spreadsheetId: string) {
2982
3077
  return callSheetsTool('sheets_get_spreadsheet', { spreadsheetId });
@@ -3046,6 +3141,139 @@ export async function tintSheetDataTab(spreadsheetId: string, sheetName: string)
3046
3141
  return callSheetsTool('sheets_tint_data_tab', { spreadsheetId, sheetName });
3047
3142
  }
3048
3143
 
3144
+ // ==========================================
3145
+ // Google Docs (MCP)
3146
+ // ==========================================
3147
+
3148
+ export async function callDocsTool(
3149
+ toolName: string,
3150
+ args: Record<string, any> = {}
3151
+ ): Promise<any> {
3152
+ const body = JSON.stringify({ tool: toolName, arguments: args });
3153
+ const isServer = typeof window === 'undefined';
3154
+ let response: Response;
3155
+ if (isServer) {
3156
+ const apiUrl =
3157
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
3158
+ EGDESK_CONFIG.apiUrl;
3159
+ response = await fetch(\`\${apiUrl}/docs/tools/call\`, {
3160
+ method: 'POST',
3161
+ headers: buildServerEgdeskHeaders(),
3162
+ body
3163
+ });
3164
+ } else {
3165
+ response = await apiFetch('/__docs_proxy', {
3166
+ method: 'POST',
3167
+ headers: { 'Content-Type': 'application/json' },
3168
+ body
3169
+ });
3170
+ }
3171
+ return parseEgdeskMcpToolResponse(response);
3172
+ }
3173
+
3174
+ export async function getGoogleDocsAuthStatus() {
3175
+ return callDocsTool('docs_auth_status', {});
3176
+ }
3177
+
3178
+ export async function createGoogleDoc(title: string) {
3179
+ return callDocsTool('docs_create', { title });
3180
+ }
3181
+
3182
+ export async function getGoogleDoc(documentId: string) {
3183
+ return callDocsTool('docs_get', { documentId });
3184
+ }
3185
+
3186
+ export async function getGoogleDocText(documentId: string) {
3187
+ return callDocsTool('docs_get_text', { documentId });
3188
+ }
3189
+
3190
+ export async function insertGoogleDocText(documentId: string, text: string, index?: number) {
3191
+ return callDocsTool('docs_insert_text', { documentId, text, index });
3192
+ }
3193
+
3194
+ export async function replaceGoogleDocText(
3195
+ documentId: string,
3196
+ findText: string,
3197
+ replaceText: string,
3198
+ matchCase?: boolean,
3199
+ ) {
3200
+ return callDocsTool('docs_replace_text', { documentId, findText, replaceText, matchCase });
3201
+ }
3202
+
3203
+ // ==========================================
3204
+ // Google Slides (MCP)
3205
+ // ==========================================
3206
+
3207
+ export async function callSlidesTool(
3208
+ toolName: string,
3209
+ args: Record<string, any> = {}
3210
+ ): Promise<any> {
3211
+ const body = JSON.stringify({ tool: toolName, arguments: args });
3212
+ const isServer = typeof window === 'undefined';
3213
+ let response: Response;
3214
+ if (isServer) {
3215
+ const apiUrl =
3216
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
3217
+ EGDESK_CONFIG.apiUrl;
3218
+ response = await fetch(\`\${apiUrl}/slides/tools/call\`, {
3219
+ method: 'POST',
3220
+ headers: buildServerEgdeskHeaders(),
3221
+ body
3222
+ });
3223
+ } else {
3224
+ response = await apiFetch('/__slides_proxy', {
3225
+ method: 'POST',
3226
+ headers: { 'Content-Type': 'application/json' },
3227
+ body
3228
+ });
3229
+ }
3230
+ return parseEgdeskMcpToolResponse(response);
3231
+ }
3232
+
3233
+ export async function getGoogleSlidesAuthStatus() {
3234
+ return callSlidesTool('slides_auth_status', {});
3235
+ }
3236
+
3237
+ export async function createGoogleSlides(title: string) {
3238
+ return callSlidesTool('slides_create', { title });
3239
+ }
3240
+
3241
+ export async function getGoogleSlides(presentationId: string) {
3242
+ return callSlidesTool('slides_get', { presentationId });
3243
+ }
3244
+
3245
+ export async function getGoogleSlidesText(presentationId: string) {
3246
+ return callSlidesTool('slides_get_text', { presentationId });
3247
+ }
3248
+
3249
+ export async function addGoogleSlide(
3250
+ presentationId: string,
3251
+ options: { text?: string; insertionIndex?: number } = {},
3252
+ ) {
3253
+ return callSlidesTool('slides_add_slide', { presentationId, ...options });
3254
+ }
3255
+
3256
+ export async function replaceGoogleSlidesText(
3257
+ presentationId: string,
3258
+ findText: string,
3259
+ replaceText: string,
3260
+ matchCase?: boolean,
3261
+ ) {
3262
+ return callSlidesTool('slides_replace_text', { presentationId, findText, replaceText, matchCase });
3263
+ }
3264
+
3265
+ export async function insertGoogleSlidesImage(
3266
+ presentationId: string,
3267
+ options: {
3268
+ filePath?: string;
3269
+ imageUrl?: string;
3270
+ slideIndex?: number;
3271
+ slideObjectId?: string;
3272
+ },
3273
+ ) {
3274
+ return callSlidesTool('slides_insert_image', { presentationId, ...options });
3275
+ }
3276
+
3049
3277
  // ==========================================
3050
3278
  // Google Sheets HTTP sync — My DB ↔ Workspace
3051
3279
  // ==========================================
@@ -3121,6 +3349,11 @@ export async function callGmailTool(
3121
3349
  return parseEgdeskMcpToolResponse(response);
3122
3350
  }
3123
3351
 
3352
+ /** Who Gmail calls act as: personal_oauth, service_account, or domain_wide_delegation */
3353
+ export async function getGmailAuthStatus() {
3354
+ return callGmailTool('gmail_auth_status', {});
3355
+ }
3356
+
3124
3357
  /** Workspace → local: list domain users */
3125
3358
  export async function listGmailUsers() {
3126
3359
  return callGmailTool('gmail_list_users', {});
@@ -3142,7 +3375,7 @@ export async function searchGmailMessages(
3142
3375
  return callGmailTool('gmail_search_messages', { query, ...options });
3143
3376
  }
3144
3377
 
3145
- /** Local → Workspace: send from the signed-in Google account */
3378
+ /** Local → Workspace: send via personal OAuth or service account (see getGmailAuthStatus()) */
3146
3379
  export async function sendGmailMessage(options: {
3147
3380
  to: string;
3148
3381
  subject: string;
@@ -3188,6 +3421,11 @@ export async function callAppsScriptTool(
3188
3421
  return parseEgdeskMcpToolResponse(response);
3189
3422
  }
3190
3423
 
3424
+ /** Apps Script auth mode and identity (OAuth or service account / DWD — call before create/push/run) */
3425
+ export async function getAppsScriptAuthStatus() {
3426
+ return callAppsScriptTool('apps_script_auth_status', {});
3427
+ }
3428
+
3191
3429
  /** Local → Workspace */
3192
3430
  export async function pushAppsScriptToGoogle(
3193
3431
  projectId: string,
@@ -3201,6 +3439,49 @@ export async function pullAppsScriptFromGoogle(projectId: string) {
3201
3439
  return callAppsScriptTool('apps_script_pull_from_google', { projectId });
3202
3440
  }
3203
3441
 
3442
+ /** Create a container-bound Apps Script on a Sheet, Doc, Slide, or Form and register it */
3443
+ export async function createAppsScriptBound(options: {
3444
+ fileId: string;
3445
+ title?: string;
3446
+ scriptCode?: string;
3447
+ force?: boolean;
3448
+ }) {
3449
+ return callAppsScriptTool('apps_script_create_bound', options);
3450
+ }
3451
+
3452
+ /** Alias of createAppsScriptBound */
3453
+ export async function createAppsScriptForSpreadsheet(options: {
3454
+ spreadsheetId?: string;
3455
+ fileId?: string;
3456
+ title?: string;
3457
+ scriptCode?: string;
3458
+ force?: boolean;
3459
+ }) {
3460
+ return callAppsScriptTool('apps_script_create_bound', {
3461
+ fileId: options.fileId || options.spreadsheetId,
3462
+ title: options.title,
3463
+ scriptCode: options.scriptCode,
3464
+ force: options.force,
3465
+ });
3466
+ }
3467
+
3468
+ /**
3469
+ * Embed this EGDesk machine's tunnel URL + X-Api-Key into an Apps Script project
3470
+ * (EgdeskConfig.gs / EgdeskClient.gs) and push to Google.
3471
+ * Pass projectId to update an existing project, or fileId to create a bound script.
3472
+ */
3473
+ export async function setupAppsScriptEgdeskTunnel(options: {
3474
+ projectId?: string;
3475
+ fileId?: string;
3476
+ spreadsheetId?: string;
3477
+ title?: string;
3478
+ role?: 'prod' | 'dev';
3479
+ push?: boolean;
3480
+ force?: boolean;
3481
+ } = {}) {
3482
+ return callAppsScriptTool('apps_script_setup_egdesk_tunnel', options);
3483
+ }
3484
+
3204
3485
  /**
3205
3486
  * Apps Script HTTP sync (POST /apps-script/sync).
3206
3487
  * direction toWorkspace = push; toLocal = pull. Does not accept \`both\`.
@@ -3416,6 +3697,37 @@ export async function listGeminiApiKeys() {
3416
3697
  return listApiKeys({ provider: 'google' });
3417
3698
  }
3418
3699
 
3700
+ /** Tunnel URL + API key from env / egdesk.config (no live health check). */
3701
+ export function getEgdeskTunnelFromEnv(): {
3702
+ publicUrl: string;
3703
+ apiKey: string | undefined;
3704
+ userDataToolsCallUrl: string;
3705
+ } {
3706
+ const publicUrl = (
3707
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_TUNNEL_URL) ||
3708
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
3709
+ (EGDESK_CONFIG as { tunnelUrl?: string }).tunnelUrl ||
3710
+ EGDESK_CONFIG.apiUrl ||
3711
+ ''
3712
+ ).replace(/\\/$/, '');
3713
+ const apiKey =
3714
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_KEY) ||
3715
+ EGDESK_CONFIG.apiKey;
3716
+ return {
3717
+ publicUrl,
3718
+ apiKey,
3719
+ userDataToolsCallUrl: publicUrl ? \`\${publicUrl}/user-data/tools/call\` : '',
3720
+ };
3721
+ }
3722
+
3723
+ /**
3724
+ * Live prod/dev tunnel addresses and shared X-Api-Key from EGDesk
3725
+ * (\`egdesk_get_tunnel\`). Use setupAppsScriptEgdeskTunnel() to embed them in Apps Script.
3726
+ */
3727
+ export async function getEgdeskTunnel(role?: 'prod' | 'dev') {
3728
+ return callEgdeskConfigTool('egdesk_get_tunnel', role ? { role } : {});
3729
+ }
3730
+
3419
3731
  // ==========================================
3420
3732
  // Phone / Google Messages (MCP)
3421
3733
  // ==========================================
@@ -73,7 +73,7 @@ import type { NextRequest } from 'next/server';
73
73
  /**
74
74
  * EGDesk Database Proxy Middleware
75
75
  *
76
- * Intercepts __user_data_proxy, __browser_recording_proxy, __internal_knowledge_proxy, __company_research_proxy, __kakao_proxy, __drive_proxy, __sheets_proxy, __egdesk_http_proxy, __gmail_proxy, __apps_script_proxy, __visitor_auth_proxy, and __visitor_google_proxy requests
76
+ * Intercepts __user_data_proxy, __browser_recording_proxy, __internal_knowledge_proxy, __company_research_proxy, __kakao_proxy, __drive_proxy, __sheets_proxy, __docs_proxy, __slides_proxy, __egdesk_http_proxy, __gmail_proxy, __apps_script_proxy, __visitor_auth_proxy, and __visitor_google_proxy requests
77
77
  * and forwards them to the EGDesk MCP HTTP server.
78
78
  * This allows CORS-free database access in both local and tunneled environments.
79
79
  *
@@ -282,6 +282,52 @@ export async function middleware(request: NextRequest) {
282
282
  }
283
283
  }
284
284
 
285
+ if (pathname.includes('__docs_proxy')) {
286
+ try {
287
+ const body = await request.text();
288
+ const apiKey = process.env.NEXT_PUBLIC_EGDESK_API_KEY;
289
+ const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
290
+ const headers: HeadersInit = { 'Content-Type': 'application/json' };
291
+ if (apiKey) headers['X-Api-Key'] = apiKey;
292
+
293
+ const response = await fetch(\`\${apiUrl}/docs/tools/call\`, {
294
+ method: 'POST',
295
+ headers,
296
+ body,
297
+ });
298
+ const result = await response.json();
299
+ return NextResponse.json(result, { status: response.status });
300
+ } catch (error: any) {
301
+ return NextResponse.json(
302
+ { error: 'Proxy error', message: error.message },
303
+ { status: 500 }
304
+ );
305
+ }
306
+ }
307
+
308
+ if (pathname.includes('__slides_proxy')) {
309
+ try {
310
+ const body = await request.text();
311
+ const apiKey = process.env.NEXT_PUBLIC_EGDESK_API_KEY;
312
+ const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
313
+ const headers: HeadersInit = { 'Content-Type': 'application/json' };
314
+ if (apiKey) headers['X-Api-Key'] = apiKey;
315
+
316
+ const response = await fetch(\`\${apiUrl}/slides/tools/call\`, {
317
+ method: 'POST',
318
+ headers,
319
+ body,
320
+ });
321
+ const result = await response.json();
322
+ return NextResponse.json(result, { status: response.status });
323
+ } catch (error: any) {
324
+ return NextResponse.json(
325
+ { error: 'Proxy error', message: error.message },
326
+ { status: 500 }
327
+ );
328
+ }
329
+ }
330
+
285
331
  if (pathname.includes('__sheets_proxy')) {
286
332
  try {
287
333
  const body = await request.text();
@@ -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, __company_research_proxy, __ai_center_proxy, __korean_law_proxy, __seo_proxy, __ssl_proxy, __local_agent_proxy, __pageindex_proxy, __drive_proxy, __sheets_proxy, __egdesk_http_proxy, __gmail_proxy, __apps_script_proxy, __knowledge_wiki_proxy, __egdesk_config_proxy, __ai_caller_proxy, __kakao_proxy, __phone_proxy, __instagram_proxy, __financehub_proxy, __blog_proxy, __youtube_proxy, __visitor_auth_proxy, and __visitor_google_proxy requests
78
+ * Intercepts __user_data_proxy, __browser_recording_proxy, __internal_knowledge_proxy, __company_research_proxy, __ai_center_proxy, __korean_law_proxy, __seo_proxy, __ssl_proxy, __local_agent_proxy, __pageindex_proxy, __drive_proxy, __sheets_proxy, __docs_proxy, __slides_proxy, __egdesk_http_proxy, __gmail_proxy, __apps_script_proxy, __knowledge_wiki_proxy, __egdesk_config_proxy, __ai_caller_proxy, __kakao_proxy, __phone_proxy, __instagram_proxy, __financehub_proxy, __blog_proxy, __youtube_proxy, __visitor_auth_proxy, and __visitor_google_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
@@ -349,6 +349,50 @@ export async function proxy(request: NextRequest) {
349
349
  }
350
350
  }
351
351
 
352
+ if (pathname.includes('__docs_proxy')) {
353
+ try {
354
+ const body = await request.text();
355
+ const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
356
+
357
+ const response = await fetch(\`\${apiUrl}/docs/tools/call\`, {
358
+ method: 'POST',
359
+ headers: buildEgdeskHeaders(),
360
+ body,
361
+ });
362
+
363
+ const result = await response.json();
364
+
365
+ return NextResponse.json(result, { status: response.status });
366
+ } catch (error: any) {
367
+ return NextResponse.json(
368
+ { error: 'Proxy error', message: error.message },
369
+ { status: 500 }
370
+ );
371
+ }
372
+ }
373
+
374
+ if (pathname.includes('__slides_proxy')) {
375
+ try {
376
+ const body = await request.text();
377
+ const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
378
+
379
+ const response = await fetch(\`\${apiUrl}/slides/tools/call\`, {
380
+ method: 'POST',
381
+ headers: buildEgdeskHeaders(),
382
+ body,
383
+ });
384
+
385
+ const result = await response.json();
386
+
387
+ return NextResponse.json(result, { status: response.status });
388
+ } catch (error: any) {
389
+ return NextResponse.json(
390
+ { error: 'Proxy error', message: error.message },
391
+ { status: 500 }
392
+ );
393
+ }
394
+ }
395
+
352
396
  if (pathname.includes('__sheets_proxy')) {
353
397
  try {
354
398
  const body = await request.text();
@@ -693,7 +737,7 @@ export const config = {
693
737
  matcher: [
694
738
  /*
695
739
  * Match all paths except static assets
696
- * The proxy function filters for __user_data_proxy / __browser_recording_proxy / __internal_knowledge_proxy / __company_research_proxy / __ai_center_proxy / __korean_law_proxy / __seo_proxy / __ssl_proxy / __local_agent_proxy / __pageindex_proxy / __drive_proxy / __sheets_proxy / __egdesk_http_proxy / __gmail_proxy / __apps_script_proxy / __knowledge_wiki_proxy / __egdesk_config_proxy / __ai_caller_proxy / __kakao_proxy / __phone_proxy / __instagram_proxy / __financehub_proxy / __blog_proxy / __youtube_proxy / __visitor_auth_proxy / __visitor_google_proxy
740
+ * The proxy function filters for __user_data_proxy / __browser_recording_proxy / __internal_knowledge_proxy / __company_research_proxy / __ai_center_proxy / __korean_law_proxy / __seo_proxy / __ssl_proxy / __local_agent_proxy / __pageindex_proxy / __drive_proxy / __sheets_proxy / __docs_proxy / __slides_proxy / __egdesk_http_proxy / __gmail_proxy / __apps_script_proxy / __knowledge_wiki_proxy / __egdesk_config_proxy / __ai_caller_proxy / __kakao_proxy / __phone_proxy / __instagram_proxy / __financehub_proxy / __blog_proxy / __youtube_proxy / __visitor_auth_proxy / __visitor_google_proxy
697
741
  */
698
742
  '/:path*',
699
743
  ],
@@ -148,6 +148,8 @@ export const VISITOR_GOOGLE_OAUTH_SCOPES = [
148
148
  'https://www.googleapis.com/auth/userinfo.profile',
149
149
  'https://www.googleapis.com/auth/drive.file',
150
150
  'https://www.googleapis.com/auth/spreadsheets',
151
+ 'https://www.googleapis.com/auth/documents',
152
+ 'https://www.googleapis.com/auth/presentations',
151
153
  'openid',
152
154
  ] as const;
153
155
 
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  * The minimum EGDesk app version this plugin version is compatible with.
9
9
  * The app checks this at setup time and warns on mismatch.
10
10
  */
11
- export declare const COMPATIBLE_APP_VERSION = "1.4.46";
11
+ export declare const COMPATIBLE_APP_VERSION = "1.4.48";
12
12
  export interface SetupOptions {
13
13
  egdeskUrl?: string;
14
14
  /** Production EGDesk server URL — written to .env.production.local. Falls back to egdeskUrl. */
package/dist/index.js CHANGED
@@ -46,7 +46,7 @@ exports.setupNextApiPlugin = setupNextApiPlugin;
46
46
  * The minimum EGDesk app version this plugin version is compatible with.
47
47
  * The app checks this at setup time and warns on mismatch.
48
48
  */
49
- exports.COMPATIBLE_APP_VERSION = '1.4.46';
49
+ exports.COMPATIBLE_APP_VERSION = '1.4.48';
50
50
  const fs = __importStar(require("fs"));
51
51
  const path = __importStar(require("path"));
52
52
  const setup_userdata_1 = require("./setup-userdata");
@@ -215,6 +215,7 @@ prodTables) {
215
215
  // EGDesk-managed keys — always overwritten with fresh values
216
216
  const egdeskKeys = new Set([
217
217
  'NEXT_PUBLIC_EGDESK_API_URL',
218
+ 'NEXT_PUBLIC_EGDESK_TUNNEL_URL',
218
219
  'NEXT_PUBLIC_EGDESK_API_KEY',
219
220
  'NEXT_PUBLIC_EGDESK_PROJECT_ID',
220
221
  'NEXT_PUBLIC_EGDESK_ENV',
@@ -249,6 +250,7 @@ prodTables) {
249
250
  `# Generated at: ${config.generatedAt}`,
250
251
  '',
251
252
  `NEXT_PUBLIC_EGDESK_API_URL=${apiUrl}`,
253
+ `NEXT_PUBLIC_EGDESK_TUNNEL_URL=${apiUrl}`,
252
254
  ...(config.egdeskProjectId ? [`NEXT_PUBLIC_EGDESK_PROJECT_ID=${config.egdeskProjectId}`] : []),
253
255
  `NEXT_PUBLIC_EGDESK_ENV=${egdeskEnv}`,
254
256
  ...(config.apiKey ? [`NEXT_PUBLIC_EGDESK_API_KEY=${config.apiKey}`] : []),
@@ -351,6 +353,7 @@ function generateConfigFile(projectPath, config) {
351
353
 
352
354
  export const EGDESK_CONFIG = {
353
355
  apiUrl: '${config.baseUrl}',
356
+ tunnelUrl: '${config.prodBaseUrl ?? config.baseUrl}',
354
357
  apiKey: ${config.apiKey ? `'${config.apiKey}'` : 'undefined'},
355
358
  } as const;
356
359
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egdesk/next-api-plugin",
3
- "version": "1.5.33",
3
+ "version": "1.5.38",
4
4
  "description": "Next.js plugin for EGDesk database proxy integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",