@egdesk/next-api-plugin 1.5.35 → 1.5.40

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
@@ -99,6 +99,8 @@ The plugin generates `middleware.ts` or `proxy.ts` that intercepts special paths
99
99
  |------|-------------|
100
100
  | `__user_data_proxy` | `POST /user-data/tools/call` |
101
101
  | `__browser_recording_proxy` | `POST /browser-recording/tools/call` |
102
+
103
+ **Browser recording file upload:** `listBrowserRecordingSites` → `openBrowserRecordingAccount` (navigate-only sites use `accountKey: "__unknown_account__"`) → `inspectBrowserRecordingPage` → `uploadBrowserRecordingFile(sessionId, absPath, elementIndex?)`. Prefer the hidden `[file input]` index. `filePath` must exist on the EGDesk machine. Persist with `saveBrowserRecordingSession`. Replay override: `fileUploadsByIndex`.
102
104
  | `__internal_knowledge_proxy` | `POST /internal-knowledge/tools/call` (knowledge docs, business identity snapshots, company research) |
103
105
 
104
106
  **User-data request flow:**
@@ -137,7 +137,7 @@ 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
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.
@@ -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';
@@ -1658,6 +1659,10 @@ export async function searchCompanyResearch(searchText: string) {
1658
1659
  *
1659
1660
  * - Server: \`POST {apiUrl}/browser-recording/tools/call\`
1660
1661
  * - Client: \`POST /__browser_recording_proxy\` (see proxy.ts / middleware)
1662
+ *
1663
+ * File upload (standalone, not only download-chain):
1664
+ * list_sites → open_account → inspect_page → uploadBrowserRecordingFile(sessionId, absPath, elementIndex?)
1665
+ * See uploadBrowserRecordingFile() for the full caller recipe.
1661
1666
  */
1662
1667
  export async function callBrowserRecordingTool(
1663
1668
  toolName: string,
@@ -1707,6 +1712,8 @@ export type BrowserRecordingRunOptions = {
1707
1712
  datePickersByIndex?: string[];
1708
1713
  /** Per captureLabeledFields step, values in field order */
1709
1714
  labeledFieldFills?: (string | undefined)[][];
1715
+ /** Per fileUpload step — absolute path override (empty uses the recorded path) */
1716
+ fileUploadsByIndex?: (string | undefined)[];
1710
1717
  };
1711
1718
 
1712
1719
  export type BrowserRecordingScheduleOptions = {
@@ -1854,7 +1861,7 @@ export async function searchBrowserRecordingElements(sessionId: string, query: s
1854
1861
  return callBrowserRecordingTool('browser_recording_search_elements', { sessionId, query });
1855
1862
  }
1856
1863
 
1857
- /** Visible form fields; password values redacted */
1864
+ /** Visible form fields (dialog-scoped). lookup = type_into then double-click a row. */
1858
1865
  export async function getBrowserRecordingForms(
1859
1866
  sessionId: string,
1860
1867
  scroll?: 'none' | 'up' | 'down'
@@ -1865,12 +1872,20 @@ export async function getBrowserRecordingForms(
1865
1872
  });
1866
1873
  }
1867
1874
 
1868
- /** Click by last-inspect index (prefers the real link over a wrapping table cell) */
1869
- export async function clickBrowserRecordingElement(sessionId: string, elementIndex: number) {
1870
- return callBrowserRecordingTool('browser_recording_click_element', { sessionId, elementIndex });
1875
+ /** Click by last-inspect index. clickCount=2 double-clicks a lookup row. */
1876
+ export async function clickBrowserRecordingElement(
1877
+ sessionId: string,
1878
+ elementIndex: number,
1879
+ clickCount?: 1 | 2
1880
+ ) {
1881
+ return callBrowserRecordingTool('browser_recording_click_element', {
1882
+ sessionId,
1883
+ elementIndex,
1884
+ ...(clickCount === 2 ? { clickCount: 2 } : {}),
1885
+ });
1871
1886
  }
1872
1887
 
1873
- /** Fill by field_id from getBrowserRecordingForms. Password fields are rejected. */
1888
+ /** Fill free-text/select by field_id (locator + verify). Rejected: passwords, lookups, file inputs. */
1874
1889
  export async function fillBrowserRecordingForm(
1875
1890
  sessionId: string,
1876
1891
  fields: Array<{ field_id: string; value: string }>
@@ -1878,6 +1893,20 @@ export async function fillBrowserRecordingForm(
1878
1893
  return callBrowserRecordingTool('browser_recording_fill_form', { sessionId, fields });
1879
1894
  }
1880
1895
 
1896
+ /** Type into a lookup/search field (does not bind hidden id). Then inspect and double-click a row. */
1897
+ export async function typeIntoBrowserRecording(
1898
+ sessionId: string,
1899
+ opts: { field_id?: string; elementIndex?: number; text: string; submit?: boolean }
1900
+ ) {
1901
+ return callBrowserRecordingTool('browser_recording_type_into', {
1902
+ sessionId,
1903
+ text: opts.text,
1904
+ ...(opts.field_id ? { field_id: opts.field_id } : {}),
1905
+ ...(opts.elementIndex !== undefined ? { elementIndex: opts.elementIndex } : {}),
1906
+ ...(opts.submit ? { submit: true } : {}),
1907
+ });
1908
+ }
1909
+
1881
1910
  /** Press Enter / Escape / arrows in the open live session (e.g. after 메뉴검색) */
1882
1911
  export async function pressBrowserRecordingKey(
1883
1912
  sessionId: string,
@@ -1896,6 +1925,49 @@ export async function closeBrowserRecordingSession(sessionId: string) {
1896
1925
  return callBrowserRecordingTool('browser_recording_close_session', { sessionId });
1897
1926
  }
1898
1927
 
1928
+ /** Workflow clicks/fills/keys logged in an open live session (no passwords) */
1929
+ export async function listBrowserRecordingSessionActions(sessionId: string) {
1930
+ return callBrowserRecordingTool('browser_recording_list_session_actions', { sessionId });
1931
+ }
1932
+
1933
+ /**
1934
+ * Attach a local file in an open live session (standalone fileUpload).
1935
+ *
1936
+ * How to call this from an MCP / helper caller:
1937
+ * 1. Enable the browser-recording service and start the EGDesk HTTP server.
1938
+ * 2. listBrowserRecordingSites() — navigate-only recordings (no login) use
1939
+ * accountKey: "__unknown_account__".
1940
+ * 3. openBrowserRecordingAccount(siteKey, accountKey) — replays login if one
1941
+ * was recorded, otherwise just opens the first navigate URL. Keep Chrome open.
1942
+ * 4. inspectBrowserRecordingPage(sessionId) (or search). Pick the
1943
+ * input / "[file input]" index, not a heading. Styled "Select PDF files"
1944
+ * buttons often do not fire a file chooser; the hidden file input does.
1945
+ * 5. Call this helper with an absolute path on the EGDesk machine.
1946
+ * Omit elementIndex to use the first input[type=file].
1947
+ * 6. Re-inspect, then listBrowserRecordingSessionActions → saveBrowserRecordingSession
1948
+ * to persist the upload. Replay uses the recorded path; override with
1949
+ * fileUploadsByIndex on runBrowserRecording.
1950
+ *
1951
+ * HTTP equivalent: POST /browser-recording/tools/call
1952
+ * { tool: "browser_recording_upload_file", arguments: { sessionId, filePath, elementIndex? } }
1953
+ */
1954
+ export async function uploadBrowserRecordingFile(
1955
+ sessionId: string,
1956
+ filePath: string,
1957
+ elementIndex?: number
1958
+ ) {
1959
+ return callBrowserRecordingTool('browser_recording_upload_file', {
1960
+ sessionId,
1961
+ filePath,
1962
+ ...(elementIndex !== undefined ? { elementIndex } : {}),
1963
+ });
1964
+ }
1965
+
1966
+ /** Save the live session as a new *.spec.js (login prefix + logged workflow). Does not close Chrome. */
1967
+ export async function saveBrowserRecordingSession(sessionId: string, name: string) {
1968
+ return callBrowserRecordingTool('browser_recording_save_session', { sessionId, name });
1969
+ }
1970
+
1899
1971
  // ==========================================
1900
1972
  // AI CENTER (workflows, entities, relations, tags)
1901
1973
  // ==========================================
@@ -3023,6 +3095,7 @@ export async function syncDrive(options: {
3023
3095
  /**
3024
3096
  * Call EGDesk Sheets MCP tool.
3025
3097
  *
3098
+ * Auth: personal OAuth, service account, or domain-wide delegation (call getSheetsAuthStatus() first).
3026
3099
  * - Server: \`POST {apiUrl}/sheets/tools/call\`
3027
3100
  * - Client: \`POST /__sheets_proxy\`
3028
3101
  */
@@ -3055,6 +3128,11 @@ export async function callSheetsTool(
3055
3128
  return parseEgdeskMcpToolResponse(response);
3056
3129
  }
3057
3130
 
3131
+ /** Who Sheets/Docs/Slides/Drive calls act as: personal_oauth, service_account, or domain_wide_delegation */
3132
+ export async function getSheetsAuthStatus() {
3133
+ return callSheetsTool('sheets_auth_status', {});
3134
+ }
3135
+
3058
3136
  /** Spreadsheet metadata (tabs, dimensions) */
3059
3137
  export async function getSpreadsheet(spreadsheetId: string) {
3060
3138
  return callSheetsTool('sheets_get_spreadsheet', { spreadsheetId });
@@ -3124,6 +3202,139 @@ export async function tintSheetDataTab(spreadsheetId: string, sheetName: string)
3124
3202
  return callSheetsTool('sheets_tint_data_tab', { spreadsheetId, sheetName });
3125
3203
  }
3126
3204
 
3205
+ // ==========================================
3206
+ // Google Docs (MCP)
3207
+ // ==========================================
3208
+
3209
+ export async function callDocsTool(
3210
+ toolName: string,
3211
+ args: Record<string, any> = {}
3212
+ ): Promise<any> {
3213
+ const body = JSON.stringify({ tool: toolName, arguments: args });
3214
+ const isServer = typeof window === 'undefined';
3215
+ let response: Response;
3216
+ if (isServer) {
3217
+ const apiUrl =
3218
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
3219
+ EGDESK_CONFIG.apiUrl;
3220
+ response = await fetch(\`\${apiUrl}/docs/tools/call\`, {
3221
+ method: 'POST',
3222
+ headers: buildServerEgdeskHeaders(),
3223
+ body
3224
+ });
3225
+ } else {
3226
+ response = await apiFetch('/__docs_proxy', {
3227
+ method: 'POST',
3228
+ headers: { 'Content-Type': 'application/json' },
3229
+ body
3230
+ });
3231
+ }
3232
+ return parseEgdeskMcpToolResponse(response);
3233
+ }
3234
+
3235
+ export async function getGoogleDocsAuthStatus() {
3236
+ return callDocsTool('docs_auth_status', {});
3237
+ }
3238
+
3239
+ export async function createGoogleDoc(title: string) {
3240
+ return callDocsTool('docs_create', { title });
3241
+ }
3242
+
3243
+ export async function getGoogleDoc(documentId: string) {
3244
+ return callDocsTool('docs_get', { documentId });
3245
+ }
3246
+
3247
+ export async function getGoogleDocText(documentId: string) {
3248
+ return callDocsTool('docs_get_text', { documentId });
3249
+ }
3250
+
3251
+ export async function insertGoogleDocText(documentId: string, text: string, index?: number) {
3252
+ return callDocsTool('docs_insert_text', { documentId, text, index });
3253
+ }
3254
+
3255
+ export async function replaceGoogleDocText(
3256
+ documentId: string,
3257
+ findText: string,
3258
+ replaceText: string,
3259
+ matchCase?: boolean,
3260
+ ) {
3261
+ return callDocsTool('docs_replace_text', { documentId, findText, replaceText, matchCase });
3262
+ }
3263
+
3264
+ // ==========================================
3265
+ // Google Slides (MCP)
3266
+ // ==========================================
3267
+
3268
+ export async function callSlidesTool(
3269
+ toolName: string,
3270
+ args: Record<string, any> = {}
3271
+ ): Promise<any> {
3272
+ const body = JSON.stringify({ tool: toolName, arguments: args });
3273
+ const isServer = typeof window === 'undefined';
3274
+ let response: Response;
3275
+ if (isServer) {
3276
+ const apiUrl =
3277
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
3278
+ EGDESK_CONFIG.apiUrl;
3279
+ response = await fetch(\`\${apiUrl}/slides/tools/call\`, {
3280
+ method: 'POST',
3281
+ headers: buildServerEgdeskHeaders(),
3282
+ body
3283
+ });
3284
+ } else {
3285
+ response = await apiFetch('/__slides_proxy', {
3286
+ method: 'POST',
3287
+ headers: { 'Content-Type': 'application/json' },
3288
+ body
3289
+ });
3290
+ }
3291
+ return parseEgdeskMcpToolResponse(response);
3292
+ }
3293
+
3294
+ export async function getGoogleSlidesAuthStatus() {
3295
+ return callSlidesTool('slides_auth_status', {});
3296
+ }
3297
+
3298
+ export async function createGoogleSlides(title: string) {
3299
+ return callSlidesTool('slides_create', { title });
3300
+ }
3301
+
3302
+ export async function getGoogleSlides(presentationId: string) {
3303
+ return callSlidesTool('slides_get', { presentationId });
3304
+ }
3305
+
3306
+ export async function getGoogleSlidesText(presentationId: string) {
3307
+ return callSlidesTool('slides_get_text', { presentationId });
3308
+ }
3309
+
3310
+ export async function addGoogleSlide(
3311
+ presentationId: string,
3312
+ options: { text?: string; insertionIndex?: number } = {},
3313
+ ) {
3314
+ return callSlidesTool('slides_add_slide', { presentationId, ...options });
3315
+ }
3316
+
3317
+ export async function replaceGoogleSlidesText(
3318
+ presentationId: string,
3319
+ findText: string,
3320
+ replaceText: string,
3321
+ matchCase?: boolean,
3322
+ ) {
3323
+ return callSlidesTool('slides_replace_text', { presentationId, findText, replaceText, matchCase });
3324
+ }
3325
+
3326
+ export async function insertGoogleSlidesImage(
3327
+ presentationId: string,
3328
+ options: {
3329
+ filePath?: string;
3330
+ imageUrl?: string;
3331
+ slideIndex?: number;
3332
+ slideObjectId?: string;
3333
+ },
3334
+ ) {
3335
+ return callSlidesTool('slides_insert_image', { presentationId, ...options });
3336
+ }
3337
+
3127
3338
  // ==========================================
3128
3339
  // Google Sheets HTTP sync — My DB ↔ Workspace
3129
3340
  // ==========================================
@@ -3199,6 +3410,11 @@ export async function callGmailTool(
3199
3410
  return parseEgdeskMcpToolResponse(response);
3200
3411
  }
3201
3412
 
3413
+ /** Who Gmail calls act as: personal_oauth, service_account, or domain_wide_delegation */
3414
+ export async function getGmailAuthStatus() {
3415
+ return callGmailTool('gmail_auth_status', {});
3416
+ }
3417
+
3202
3418
  /** Workspace → local: list domain users */
3203
3419
  export async function listGmailUsers() {
3204
3420
  return callGmailTool('gmail_list_users', {});
@@ -3220,7 +3436,7 @@ export async function searchGmailMessages(
3220
3436
  return callGmailTool('gmail_search_messages', { query, ...options });
3221
3437
  }
3222
3438
 
3223
- /** Local → Workspace: send from the signed-in Google account */
3439
+ /** Local → Workspace: send via personal OAuth or service account (see getGmailAuthStatus()) */
3224
3440
  export async function sendGmailMessage(options: {
3225
3441
  to: string;
3226
3442
  subject: string;
@@ -3266,6 +3482,11 @@ export async function callAppsScriptTool(
3266
3482
  return parseEgdeskMcpToolResponse(response);
3267
3483
  }
3268
3484
 
3485
+ /** Apps Script auth mode and identity (OAuth or service account / DWD — call before create/push/run) */
3486
+ export async function getAppsScriptAuthStatus() {
3487
+ return callAppsScriptTool('apps_script_auth_status', {});
3488
+ }
3489
+
3269
3490
  /** Local → Workspace */
3270
3491
  export async function pushAppsScriptToGoogle(
3271
3492
  projectId: string,
@@ -3305,6 +3526,23 @@ export async function createAppsScriptForSpreadsheet(options: {
3305
3526
  });
3306
3527
  }
3307
3528
 
3529
+ /**
3530
+ * Embed this EGDesk machine's tunnel URL + X-Api-Key into an Apps Script project
3531
+ * (EgdeskConfig.gs / EgdeskClient.gs) and push to Google.
3532
+ * Pass projectId to update an existing project, or fileId to create a bound script.
3533
+ */
3534
+ export async function setupAppsScriptEgdeskTunnel(options: {
3535
+ projectId?: string;
3536
+ fileId?: string;
3537
+ spreadsheetId?: string;
3538
+ title?: string;
3539
+ role?: 'prod' | 'dev';
3540
+ push?: boolean;
3541
+ force?: boolean;
3542
+ } = {}) {
3543
+ return callAppsScriptTool('apps_script_setup_egdesk_tunnel', options);
3544
+ }
3545
+
3308
3546
  /**
3309
3547
  * Apps Script HTTP sync (POST /apps-script/sync).
3310
3548
  * direction toWorkspace = push; toLocal = pull. Does not accept \`both\`.
@@ -3520,6 +3758,37 @@ export async function listGeminiApiKeys() {
3520
3758
  return listApiKeys({ provider: 'google' });
3521
3759
  }
3522
3760
 
3761
+ /** Tunnel URL + API key from env / egdesk.config (no live health check). */
3762
+ export function getEgdeskTunnelFromEnv(): {
3763
+ publicUrl: string;
3764
+ apiKey: string | undefined;
3765
+ userDataToolsCallUrl: string;
3766
+ } {
3767
+ const publicUrl = (
3768
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_TUNNEL_URL) ||
3769
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
3770
+ (EGDESK_CONFIG as { tunnelUrl?: string }).tunnelUrl ||
3771
+ EGDESK_CONFIG.apiUrl ||
3772
+ ''
3773
+ ).replace(/\\/$/, '');
3774
+ const apiKey =
3775
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_KEY) ||
3776
+ EGDESK_CONFIG.apiKey;
3777
+ return {
3778
+ publicUrl,
3779
+ apiKey,
3780
+ userDataToolsCallUrl: publicUrl ? \`\${publicUrl}/user-data/tools/call\` : '',
3781
+ };
3782
+ }
3783
+
3784
+ /**
3785
+ * Live prod/dev tunnel addresses and shared X-Api-Key from EGDesk
3786
+ * (\`egdesk_get_tunnel\`). Use setupAppsScriptEgdeskTunnel() to embed them in Apps Script.
3787
+ */
3788
+ export async function getEgdeskTunnel(role?: 'prod' | 'dev') {
3789
+ return callEgdeskConfigTool('egdesk_get_tunnel', role ? { role } : {});
3790
+ }
3791
+
3523
3792
  // ==========================================
3524
3793
  // Phone / Google Messages (MCP)
3525
3794
  // ==========================================
@@ -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.47";
11
+ export declare const COMPATIBLE_APP_VERSION = "1.4.49";
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.47';
49
+ exports.COMPATIBLE_APP_VERSION = '1.4.49';
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.35",
3
+ "version": "1.5.40",
4
4
  "description": "Next.js plugin for EGDesk database proxy integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",