@egdesk/next-api-plugin 1.3.2 → 1.4.1

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
@@ -4,9 +4,9 @@ Next.js plugin for EGDesk database proxy integration. Provides middleware-based
4
4
 
5
5
  ## Features
6
6
 
7
- - 🔒 CORS-free database access via Next.js middleware
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
9
+ - 📝 Type-safe table definitions and helper functions (user data, FinanceHub, internal knowledge / business identity / company research, browser recording)
10
10
  - 🚀 Auto-discovery of database tables
11
11
  - 🔧 Zero configuration after setup
12
12
 
@@ -81,14 +81,21 @@ await setupNextApiPlugin('/path/to/project', {
81
81
 
82
82
  ## How It Works
83
83
 
84
- The plugin creates a Next.js middleware that intercepts requests to `__user_data_proxy` and forwards them to your EGDesk MCP server. This allows your Next.js app to make database queries without CORS issues, even in tunneled environments.
84
+ The plugin generates `middleware.ts` or `proxy.ts` that intercepts special paths and forwards them to your EGDesk HTTP MCP server so the browser never talks to another origin directly.
85
85
 
86
- **Request Flow:**
87
- 1. Your component calls `queryTable()` or other helpers
88
- 2. Helper makes a fetch to `__user_data_proxy`
89
- 3. Next.js middleware intercepts the request
90
- 4. Middleware forwards to `localhost:8080/user-data/tools/call`
91
- 5. Response is returned to your component
86
+ **Proxied paths (examples):**
87
+
88
+ | Path | Forwards to |
89
+ |------|-------------|
90
+ | `__user_data_proxy` | `POST /user-data/tools/call` |
91
+ | `__browser_recording_proxy` | `POST /browser-recording/tools/call` |
92
+ | `__internal_knowledge_proxy` | `POST /internal-knowledge/tools/call` (knowledge docs, business identity snapshots, company research) |
93
+
94
+ **User-data request flow:**
95
+ 1. Your code calls `queryTable()` or another helper
96
+ 2. Helper fetches `__user_data_proxy`
97
+ 3. Middleware/proxy forwards to `http://<EGDESK>/user-data/tools/call`
98
+ 4. Parsed JSON is returned to your component
92
99
 
93
100
  ## API Reference
94
101
 
@@ -121,6 +128,21 @@ listTables()
121
128
 
122
129
  // Get table schema
123
130
  getTableSchema(tableName: string)
131
+
132
+ // Internal Knowledge / Business Identity / Company Research (MCP)
133
+ callInternalKnowledgeTool(toolName: string, args?: Record<string, any>)
134
+ listKnowledgeDocuments(snapshotId: string, category?: 'hierarchy' | 'process' | 'policy' | 'note')
135
+ getKnowledgeDocument(documentId: string)
136
+ searchKnowledgeContent(snapshotId: string, searchText: string, category?: ...)
137
+ getKnowledgeByCategory(snapshotId: string, category: ...)
138
+ listBusinessIdentitySnapshots(brandKey?: string)
139
+ getBusinessIdentitySnapshot(snapshotId: string)
140
+ getBusinessIdentityCompanyInfo(snapshotId: string)
141
+ getBusinessIdentityServicesProducts(snapshotId: string)
142
+ listCompanyResearch(status?: 'completed' | 'failed' | 'in_progress')
143
+ getCompanyResearchById(researchId: string)
144
+ getCompanyResearchByDomain(domain: string)
145
+ searchCompanyResearch(searchText: string)
124
146
  ```
125
147
 
126
148
  ### Configuration Types
@@ -50,7 +50,8 @@ function generateHelpers(projectPath) {
50
50
  const helperContent = `/**
51
51
  * EGDesk Helper Functions for Next.js
52
52
  *
53
- * Type-safe helpers for EGDesk user data, FinanceHub (banks, cards, Hometax), and browser recorder replay.
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
55
  * Works in both client and server components.
55
56
  *
56
57
  * Generated by @egdesk/next-api-plugin
@@ -497,6 +498,184 @@ export async function getHometaxSyncHistory(limit: number = 50) {
497
498
  return callFinanceHubTool('financehub_get_hometax_sync_history', { limit });
498
499
  }
499
500
 
501
+ /**
502
+ * Query promissory notes (promissory_notes: 어음, issued/received)
503
+ */
504
+ export async function queryPromissoryNotes(options: {
505
+ bankId?: string;
506
+ accountId?: string;
507
+ status?: string;
508
+ noteType?: 'issued' | 'received';
509
+ maturityStart?: string;
510
+ maturityEnd?: string;
511
+ issueStart?: string;
512
+ issueEnd?: string;
513
+ searchText?: string;
514
+ limit?: number;
515
+ offset?: number;
516
+ } = {}) {
517
+ return callFinanceHubTool('financehub_query_promissory_notes', options);
518
+ }
519
+
520
+ // ==========================================
521
+ // INTERNAL KNOWLEDGE / BUSINESS IDENTITY / COMPANY RESEARCH (MCP)
522
+ // ==========================================
523
+
524
+ /**
525
+ * Call EGDesk Internal Knowledge MCP tool (knowledge docs, business identity snapshots, company research).
526
+ *
527
+ * - Server: \`POST {apiUrl}/internal-knowledge/tools/call\`
528
+ * - Client: \`POST /__internal_knowledge_proxy\` (see proxy.ts / middleware)
529
+ */
530
+ export async function callInternalKnowledgeTool(
531
+ toolName: string,
532
+ args: Record<string, any> = {}
533
+ ): Promise<any> {
534
+ const body = JSON.stringify({ tool: toolName, arguments: args });
535
+ const headers: Record<string, string> = {
536
+ 'Content-Type': 'application/json'
537
+ };
538
+
539
+ const isServer = typeof window === 'undefined';
540
+
541
+ let response: Response;
542
+ if (isServer) {
543
+ const apiUrl =
544
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
545
+ EGDESK_CONFIG.apiUrl;
546
+ const apiKey =
547
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_KEY) ||
548
+ EGDESK_CONFIG.apiKey;
549
+ if (apiKey) {
550
+ headers['X-Api-Key'] = apiKey;
551
+ }
552
+ response = await fetch(\`\${apiUrl}/internal-knowledge/tools/call\`, {
553
+ method: 'POST',
554
+ headers,
555
+ body
556
+ });
557
+ } else {
558
+ response = await fetch('/__internal_knowledge_proxy', {
559
+ method: 'POST',
560
+ headers,
561
+ body
562
+ });
563
+ }
564
+
565
+ return parseEgdeskMcpToolResponse(response);
566
+ }
567
+
568
+ /** List internal knowledge documents for a business identity snapshot */
569
+ export async function listKnowledgeDocuments(
570
+ snapshotId: string,
571
+ category?: 'hierarchy' | 'process' | 'policy' | 'note'
572
+ ) {
573
+ return callInternalKnowledgeTool('knowledge_list_documents', {
574
+ snapshotId,
575
+ ...(category != null ? { category } : {})
576
+ });
577
+ }
578
+
579
+ /** Get one knowledge document by ID (full markdown content) */
580
+ export async function getKnowledgeDocument(documentId: string) {
581
+ return callInternalKnowledgeTool('knowledge_get_document', { documentId });
582
+ }
583
+
584
+ /** Search knowledge documents by text in title or content */
585
+ export async function searchKnowledgeContent(
586
+ snapshotId: string,
587
+ searchText: string,
588
+ category?: 'hierarchy' | 'process' | 'policy' | 'note'
589
+ ) {
590
+ return callInternalKnowledgeTool('knowledge_search_content', {
591
+ snapshotId,
592
+ searchText,
593
+ ...(category != null ? { category } : {})
594
+ });
595
+ }
596
+
597
+ /** Get all documents of a single category for a snapshot */
598
+ export async function getKnowledgeByCategory(
599
+ snapshotId: string,
600
+ category: 'hierarchy' | 'process' | 'policy' | 'note'
601
+ ) {
602
+ return callInternalKnowledgeTool('knowledge_get_by_category', { snapshotId, category });
603
+ }
604
+
605
+ /** Create a new knowledge document */
606
+ export async function createKnowledgeDocument(
607
+ snapshotId: string,
608
+ title: string,
609
+ category: 'hierarchy' | 'process' | 'policy' | 'note',
610
+ content?: string
611
+ ) {
612
+ return callInternalKnowledgeTool('knowledge_create_document', {
613
+ snapshotId,
614
+ title,
615
+ category,
616
+ ...(content != null ? { content } : {})
617
+ });
618
+ }
619
+
620
+ /** Update an existing knowledge document */
621
+ export async function updateKnowledgeDocument(
622
+ documentId: string,
623
+ updates: { title?: string; category?: 'hierarchy' | 'process' | 'policy' | 'note'; content?: string }
624
+ ) {
625
+ return callInternalKnowledgeTool('knowledge_update_document', { documentId, ...updates });
626
+ }
627
+
628
+ /** Delete a knowledge document */
629
+ export async function deleteKnowledgeDocument(documentId: string) {
630
+ return callInternalKnowledgeTool('knowledge_delete_document', { documentId });
631
+ }
632
+
633
+ /** List business identity snapshots (optional brand filter) */
634
+ export async function listBusinessIdentitySnapshots(brandKey?: string) {
635
+ return callInternalKnowledgeTool('businessidentity_list_snapshots', {
636
+ ...(brandKey != null ? { brandKey } : {})
637
+ });
638
+ }
639
+
640
+ /** Full snapshot by ID (identity JSON, SEO/SSL analysis, etc.) */
641
+ export async function getBusinessIdentitySnapshot(snapshotId: string) {
642
+ return callInternalKnowledgeTool('businessidentity_get_snapshot', { snapshotId });
643
+ }
644
+
645
+ /** Company info slice from a snapshot (contact, structure, partners, industries) */
646
+ export async function getBusinessIdentityCompanyInfo(snapshotId: string) {
647
+ return callInternalKnowledgeTool('businessidentity_get_company_info', { snapshotId });
648
+ }
649
+
650
+ /** Services and products from a snapshot */
651
+ export async function getBusinessIdentityServicesProducts(snapshotId: string) {
652
+ return callInternalKnowledgeTool('businessidentity_get_services_products', { snapshotId });
653
+ }
654
+
655
+ /** List company research records */
656
+ export async function listCompanyResearch(
657
+ status?: 'completed' | 'failed' | 'in_progress'
658
+ ) {
659
+ return callInternalKnowledgeTool('companyresearch_list_all', {
660
+ ...(status != null ? { status } : {})
661
+ });
662
+ }
663
+
664
+ /** One company research record by ID */
665
+ export async function getCompanyResearchById(researchId: string) {
666
+ return callInternalKnowledgeTool('companyresearch_get_by_id', { researchId });
667
+ }
668
+
669
+ /** Research records for a domain */
670
+ export async function getCompanyResearchByDomain(domain: string) {
671
+ return callInternalKnowledgeTool('companyresearch_get_by_domain', { domain });
672
+ }
673
+
674
+ /** Search company research by company name or domain */
675
+ export async function searchCompanyResearch(searchText: string) {
676
+ return callInternalKnowledgeTool('companyresearch_search', { searchText });
677
+ }
678
+
500
679
  // ==========================================
501
680
  // BROWSER RECORDING HELPERS
502
681
  // ==========================================
@@ -550,7 +729,7 @@ export async function listBrowserRecordingTests() {
550
729
  return callBrowserRecordingTool('browser_recording_list_saved_tests', {});
551
730
  }
552
731
 
553
- /** Inspect a spec for date-picker replay options */
732
+ /** Inspect a spec: date UI, defaultReplayDates, labeledFieldReplayBlocks, etc. */
554
733
  export async function getBrowserRecordingReplayOptions(testFile: string) {
555
734
  return callBrowserRecordingTool('browser_recording_get_replay_options', { testFile });
556
735
  }
@@ -559,9 +738,11 @@ export type BrowserRecordingRunOptions = {
559
738
  startDate?: string;
560
739
  endDate?: string;
561
740
  datePickersByIndex?: string[];
741
+ /** Per captureLabeledFields step, values in field order */
742
+ labeledFieldFills?: (string | undefined)[][];
562
743
  };
563
744
 
564
- /** Replay a saved recording in Chrome */
745
+ /** Replay a saved recording in Chrome (optional dates + labeledFieldFills) */
565
746
  export async function runBrowserRecording(
566
747
  testFile: string,
567
748
  options: BrowserRecordingRunOptions = {}
@@ -73,8 +73,8 @@ import type { NextRequest } from 'next/server';
73
73
  /**
74
74
  * EGDesk Database Proxy Middleware
75
75
  *
76
- * Intercepts __user_data_proxy and __browser_recording_proxy requests and forwards them
77
- * to the EGDesk MCP HTTP server.
76
+ * Intercepts __user_data_proxy, __browser_recording_proxy, and __internal_knowledge_proxy requests
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
  *
80
80
  * Generated by @egdesk/next-api-plugin
@@ -149,6 +149,38 @@ export async function middleware(request: NextRequest) {
149
149
  }
150
150
  }
151
151
 
152
+ if (pathname.includes('__internal_knowledge_proxy')) {
153
+ try {
154
+ const body = await request.text();
155
+
156
+ const apiKey = process.env.NEXT_PUBLIC_EGDESK_API_KEY;
157
+ const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
158
+
159
+ const headers: HeadersInit = {
160
+ 'Content-Type': 'application/json',
161
+ };
162
+
163
+ if (apiKey) {
164
+ headers['X-Api-Key'] = apiKey;
165
+ }
166
+
167
+ const response = await fetch(\`\${apiUrl}/internal-knowledge/tools/call\`, {
168
+ method: 'POST',
169
+ headers,
170
+ body,
171
+ });
172
+
173
+ const result = await response.json();
174
+
175
+ return NextResponse.json(result, { status: response.status });
176
+ } catch (error: any) {
177
+ return NextResponse.json(
178
+ { error: 'Proxy error', message: error.message },
179
+ { status: 500 }
180
+ );
181
+ }
182
+ }
183
+
152
184
  // Continue to next middleware or route
153
185
  return NextResponse.next();
154
186
  }
@@ -75,8 +75,8 @@ import type { NextRequest } from 'next/server';
75
75
  /**
76
76
  * EGDesk Database Proxy (Next.js 16+)
77
77
  *
78
- * Intercepts __user_data_proxy and __browser_recording_proxy requests and forwards them
79
- * to the EGDesk MCP HTTP server. This avoids CORS in local and tunneled environments.
78
+ * Intercepts __user_data_proxy, __browser_recording_proxy, and __internal_knowledge_proxy requests
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
82
82
  */
@@ -150,6 +150,38 @@ export async function proxy(request: NextRequest) {
150
150
  }
151
151
  }
152
152
 
153
+ if (pathname.includes('__internal_knowledge_proxy')) {
154
+ try {
155
+ const body = await request.text();
156
+
157
+ const apiKey = process.env.NEXT_PUBLIC_EGDESK_API_KEY;
158
+ const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
159
+
160
+ const headers: HeadersInit = {
161
+ 'Content-Type': 'application/json',
162
+ };
163
+
164
+ if (apiKey) {
165
+ headers['X-Api-Key'] = apiKey;
166
+ }
167
+
168
+ const response = await fetch(\`\${apiUrl}/internal-knowledge/tools/call\`, {
169
+ method: 'POST',
170
+ headers,
171
+ body,
172
+ });
173
+
174
+ const result = await response.json();
175
+
176
+ return NextResponse.json(result, { status: response.status });
177
+ } catch (error: any) {
178
+ return NextResponse.json(
179
+ { error: 'Proxy error', message: error.message },
180
+ { status: 500 }
181
+ );
182
+ }
183
+ }
184
+
153
185
  // Continue to next proxy or route
154
186
  return NextResponse.next();
155
187
  }
@@ -158,7 +190,7 @@ export const config = {
158
190
  matcher: [
159
191
  /*
160
192
  * Match all paths except static assets
161
- * The proxy function filters for __user_data_proxy / __browser_recording_proxy
193
+ * The proxy function filters for __user_data_proxy / __browser_recording_proxy / __internal_knowledge_proxy
162
194
  */
163
195
  '/:path*',
164
196
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egdesk/next-api-plugin",
3
- "version": "1.3.2",
3
+ "version": "1.4.1",
4
4
  "description": "Next.js plugin for EGDesk database proxy integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,7 +17,8 @@ export function generateHelpers(projectPath: string): void {
17
17
  const helperContent = `/**
18
18
  * EGDesk Helper Functions for Next.js
19
19
  *
20
- * Type-safe helpers for EGDesk user data, FinanceHub (banks, cards, Hometax), and browser recorder replay.
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
22
  * Works in both client and server components.
22
23
  *
23
24
  * Generated by @egdesk/next-api-plugin
@@ -464,6 +465,184 @@ export async function getHometaxSyncHistory(limit: number = 50) {
464
465
  return callFinanceHubTool('financehub_get_hometax_sync_history', { limit });
465
466
  }
466
467
 
468
+ /**
469
+ * Query promissory notes (promissory_notes: 어음, issued/received)
470
+ */
471
+ export async function queryPromissoryNotes(options: {
472
+ bankId?: string;
473
+ accountId?: string;
474
+ status?: string;
475
+ noteType?: 'issued' | 'received';
476
+ maturityStart?: string;
477
+ maturityEnd?: string;
478
+ issueStart?: string;
479
+ issueEnd?: string;
480
+ searchText?: string;
481
+ limit?: number;
482
+ offset?: number;
483
+ } = {}) {
484
+ return callFinanceHubTool('financehub_query_promissory_notes', options);
485
+ }
486
+
487
+ // ==========================================
488
+ // INTERNAL KNOWLEDGE / BUSINESS IDENTITY / COMPANY RESEARCH (MCP)
489
+ // ==========================================
490
+
491
+ /**
492
+ * Call EGDesk Internal Knowledge MCP tool (knowledge docs, business identity snapshots, company research).
493
+ *
494
+ * - Server: \`POST {apiUrl}/internal-knowledge/tools/call\`
495
+ * - Client: \`POST /__internal_knowledge_proxy\` (see proxy.ts / middleware)
496
+ */
497
+ export async function callInternalKnowledgeTool(
498
+ toolName: string,
499
+ args: Record<string, any> = {}
500
+ ): Promise<any> {
501
+ const body = JSON.stringify({ tool: toolName, arguments: args });
502
+ const headers: Record<string, string> = {
503
+ 'Content-Type': 'application/json'
504
+ };
505
+
506
+ const isServer = typeof window === 'undefined';
507
+
508
+ let response: Response;
509
+ if (isServer) {
510
+ const apiUrl =
511
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
512
+ EGDESK_CONFIG.apiUrl;
513
+ const apiKey =
514
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_KEY) ||
515
+ EGDESK_CONFIG.apiKey;
516
+ if (apiKey) {
517
+ headers['X-Api-Key'] = apiKey;
518
+ }
519
+ response = await fetch(\`\${apiUrl}/internal-knowledge/tools/call\`, {
520
+ method: 'POST',
521
+ headers,
522
+ body
523
+ });
524
+ } else {
525
+ response = await fetch('/__internal_knowledge_proxy', {
526
+ method: 'POST',
527
+ headers,
528
+ body
529
+ });
530
+ }
531
+
532
+ return parseEgdeskMcpToolResponse(response);
533
+ }
534
+
535
+ /** List internal knowledge documents for a business identity snapshot */
536
+ export async function listKnowledgeDocuments(
537
+ snapshotId: string,
538
+ category?: 'hierarchy' | 'process' | 'policy' | 'note'
539
+ ) {
540
+ return callInternalKnowledgeTool('knowledge_list_documents', {
541
+ snapshotId,
542
+ ...(category != null ? { category } : {})
543
+ });
544
+ }
545
+
546
+ /** Get one knowledge document by ID (full markdown content) */
547
+ export async function getKnowledgeDocument(documentId: string) {
548
+ return callInternalKnowledgeTool('knowledge_get_document', { documentId });
549
+ }
550
+
551
+ /** Search knowledge documents by text in title or content */
552
+ export async function searchKnowledgeContent(
553
+ snapshotId: string,
554
+ searchText: string,
555
+ category?: 'hierarchy' | 'process' | 'policy' | 'note'
556
+ ) {
557
+ return callInternalKnowledgeTool('knowledge_search_content', {
558
+ snapshotId,
559
+ searchText,
560
+ ...(category != null ? { category } : {})
561
+ });
562
+ }
563
+
564
+ /** Get all documents of a single category for a snapshot */
565
+ export async function getKnowledgeByCategory(
566
+ snapshotId: string,
567
+ category: 'hierarchy' | 'process' | 'policy' | 'note'
568
+ ) {
569
+ return callInternalKnowledgeTool('knowledge_get_by_category', { snapshotId, category });
570
+ }
571
+
572
+ /** Create a new knowledge document */
573
+ export async function createKnowledgeDocument(
574
+ snapshotId: string,
575
+ title: string,
576
+ category: 'hierarchy' | 'process' | 'policy' | 'note',
577
+ content?: string
578
+ ) {
579
+ return callInternalKnowledgeTool('knowledge_create_document', {
580
+ snapshotId,
581
+ title,
582
+ category,
583
+ ...(content != null ? { content } : {})
584
+ });
585
+ }
586
+
587
+ /** Update an existing knowledge document */
588
+ export async function updateKnowledgeDocument(
589
+ documentId: string,
590
+ updates: { title?: string; category?: 'hierarchy' | 'process' | 'policy' | 'note'; content?: string }
591
+ ) {
592
+ return callInternalKnowledgeTool('knowledge_update_document', { documentId, ...updates });
593
+ }
594
+
595
+ /** Delete a knowledge document */
596
+ export async function deleteKnowledgeDocument(documentId: string) {
597
+ return callInternalKnowledgeTool('knowledge_delete_document', { documentId });
598
+ }
599
+
600
+ /** List business identity snapshots (optional brand filter) */
601
+ export async function listBusinessIdentitySnapshots(brandKey?: string) {
602
+ return callInternalKnowledgeTool('businessidentity_list_snapshots', {
603
+ ...(brandKey != null ? { brandKey } : {})
604
+ });
605
+ }
606
+
607
+ /** Full snapshot by ID (identity JSON, SEO/SSL analysis, etc.) */
608
+ export async function getBusinessIdentitySnapshot(snapshotId: string) {
609
+ return callInternalKnowledgeTool('businessidentity_get_snapshot', { snapshotId });
610
+ }
611
+
612
+ /** Company info slice from a snapshot (contact, structure, partners, industries) */
613
+ export async function getBusinessIdentityCompanyInfo(snapshotId: string) {
614
+ return callInternalKnowledgeTool('businessidentity_get_company_info', { snapshotId });
615
+ }
616
+
617
+ /** Services and products from a snapshot */
618
+ export async function getBusinessIdentityServicesProducts(snapshotId: string) {
619
+ return callInternalKnowledgeTool('businessidentity_get_services_products', { snapshotId });
620
+ }
621
+
622
+ /** List company research records */
623
+ export async function listCompanyResearch(
624
+ status?: 'completed' | 'failed' | 'in_progress'
625
+ ) {
626
+ return callInternalKnowledgeTool('companyresearch_list_all', {
627
+ ...(status != null ? { status } : {})
628
+ });
629
+ }
630
+
631
+ /** One company research record by ID */
632
+ export async function getCompanyResearchById(researchId: string) {
633
+ return callInternalKnowledgeTool('companyresearch_get_by_id', { researchId });
634
+ }
635
+
636
+ /** Research records for a domain */
637
+ export async function getCompanyResearchByDomain(domain: string) {
638
+ return callInternalKnowledgeTool('companyresearch_get_by_domain', { domain });
639
+ }
640
+
641
+ /** Search company research by company name or domain */
642
+ export async function searchCompanyResearch(searchText: string) {
643
+ return callInternalKnowledgeTool('companyresearch_search', { searchText });
644
+ }
645
+
467
646
  // ==========================================
468
647
  // BROWSER RECORDING HELPERS
469
648
  // ==========================================
@@ -517,7 +696,7 @@ export async function listBrowserRecordingTests() {
517
696
  return callBrowserRecordingTool('browser_recording_list_saved_tests', {});
518
697
  }
519
698
 
520
- /** Inspect a spec for date-picker replay options */
699
+ /** Inspect a spec: date UI, defaultReplayDates, labeledFieldReplayBlocks, etc. */
521
700
  export async function getBrowserRecordingReplayOptions(testFile: string) {
522
701
  return callBrowserRecordingTool('browser_recording_get_replay_options', { testFile });
523
702
  }
@@ -526,9 +705,11 @@ export type BrowserRecordingRunOptions = {
526
705
  startDate?: string;
527
706
  endDate?: string;
528
707
  datePickersByIndex?: string[];
708
+ /** Per captureLabeledFields step, values in field order */
709
+ labeledFieldFills?: (string | undefined)[][];
529
710
  };
530
711
 
531
- /** Replay a saved recording in Chrome */
712
+ /** Replay a saved recording in Chrome (optional dates + labeledFieldFills) */
532
713
  export async function runBrowserRecording(
533
714
  testFile: string,
534
715
  options: BrowserRecordingRunOptions = {}
@@ -43,8 +43,8 @@ import type { NextRequest } from 'next/server';
43
43
  /**
44
44
  * EGDesk Database Proxy Middleware
45
45
  *
46
- * Intercepts __user_data_proxy and __browser_recording_proxy requests and forwards them
47
- * to the EGDesk MCP HTTP server.
46
+ * Intercepts __user_data_proxy, __browser_recording_proxy, and __internal_knowledge_proxy requests
47
+ * and forwards them to the EGDesk MCP HTTP server.
48
48
  * This allows CORS-free database access in both local and tunneled environments.
49
49
  *
50
50
  * Generated by @egdesk/next-api-plugin
@@ -119,6 +119,38 @@ export async function middleware(request: NextRequest) {
119
119
  }
120
120
  }
121
121
 
122
+ if (pathname.includes('__internal_knowledge_proxy')) {
123
+ try {
124
+ const body = await request.text();
125
+
126
+ const apiKey = process.env.NEXT_PUBLIC_EGDESK_API_KEY;
127
+ const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
128
+
129
+ const headers: HeadersInit = {
130
+ 'Content-Type': 'application/json',
131
+ };
132
+
133
+ if (apiKey) {
134
+ headers['X-Api-Key'] = apiKey;
135
+ }
136
+
137
+ const response = await fetch(\`\${apiUrl}/internal-knowledge/tools/call\`, {
138
+ method: 'POST',
139
+ headers,
140
+ body,
141
+ });
142
+
143
+ const result = await response.json();
144
+
145
+ return NextResponse.json(result, { status: response.status });
146
+ } catch (error: any) {
147
+ return NextResponse.json(
148
+ { error: 'Proxy error', message: error.message },
149
+ { status: 500 }
150
+ );
151
+ }
152
+ }
153
+
122
154
  // Continue to next middleware or route
123
155
  return NextResponse.next();
124
156
  }
@@ -45,8 +45,8 @@ import type { NextRequest } from 'next/server';
45
45
  /**
46
46
  * EGDesk Database Proxy (Next.js 16+)
47
47
  *
48
- * Intercepts __user_data_proxy and __browser_recording_proxy requests and forwards them
49
- * to the EGDesk MCP HTTP server. This avoids CORS in local and tunneled environments.
48
+ * Intercepts __user_data_proxy, __browser_recording_proxy, and __internal_knowledge_proxy requests
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
52
52
  */
@@ -120,6 +120,38 @@ export async function proxy(request: NextRequest) {
120
120
  }
121
121
  }
122
122
 
123
+ if (pathname.includes('__internal_knowledge_proxy')) {
124
+ try {
125
+ const body = await request.text();
126
+
127
+ const apiKey = process.env.NEXT_PUBLIC_EGDESK_API_KEY;
128
+ const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
129
+
130
+ const headers: HeadersInit = {
131
+ 'Content-Type': 'application/json',
132
+ };
133
+
134
+ if (apiKey) {
135
+ headers['X-Api-Key'] = apiKey;
136
+ }
137
+
138
+ const response = await fetch(\`\${apiUrl}/internal-knowledge/tools/call\`, {
139
+ method: 'POST',
140
+ headers,
141
+ body,
142
+ });
143
+
144
+ const result = await response.json();
145
+
146
+ return NextResponse.json(result, { status: response.status });
147
+ } catch (error: any) {
148
+ return NextResponse.json(
149
+ { error: 'Proxy error', message: error.message },
150
+ { status: 500 }
151
+ );
152
+ }
153
+ }
154
+
123
155
  // Continue to next proxy or route
124
156
  return NextResponse.next();
125
157
  }
@@ -128,7 +160,7 @@ export const config = {
128
160
  matcher: [
129
161
  /*
130
162
  * Match all paths except static assets
131
- * The proxy function filters for __user_data_proxy / __browser_recording_proxy
163
+ * The proxy function filters for __user_data_proxy / __browser_recording_proxy / __internal_knowledge_proxy
132
164
  */
133
165
  '/:path*',
134
166
  ],