@egdesk/next-api-plugin 1.5.163 → 1.5.200
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.d.ts +1 -1
- package/dist/generate-helpers.js +154 -7
- package/dist/generate-helpers.test.js +17 -3
- package/dist/generate-proxy.js +24 -2
- package/dist/generate-visitor-auth.js +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -33,5 +33,5 @@ export interface GenerateHelpersOptions {
|
|
|
33
33
|
apiKeyNames?: string[];
|
|
34
34
|
}
|
|
35
35
|
/** Bump when generated helper/middleware behavior changes; EGDesk regenerates stale projects. */
|
|
36
|
-
export declare const EGDESK_HELPERS_GENERATION_VERSION = "
|
|
36
|
+
export declare const EGDESK_HELPERS_GENERATION_VERSION = "7";
|
|
37
37
|
export declare function generateHelpers(projectPath: string, options?: GenerateHelpersOptions): void;
|
package/dist/generate-helpers.js
CHANGED
|
@@ -134,7 +134,7 @@ function ensureSchemaFile(projectPath, tables) {
|
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
136
|
/** Bump when generated helper/middleware behavior changes; EGDesk regenerates stale projects. */
|
|
137
|
-
exports.EGDESK_HELPERS_GENERATION_VERSION = '
|
|
137
|
+
exports.EGDESK_HELPERS_GENERATION_VERSION = '7';
|
|
138
138
|
function generateHelpers(projectPath, options = {}) {
|
|
139
139
|
const helperPath = path.join(projectPath, 'egdesk-helpers.ts');
|
|
140
140
|
const helperContent = `/**
|
|
@@ -144,7 +144,7 @@ function generateHelpers(projectPath, options = {}) {
|
|
|
144
144
|
*
|
|
145
145
|
* Type-safe helpers for EGDesk user data, Google Workspace (Sheets / Drive / Docs / Slides MCP + sync, Gmail, Apps Script),
|
|
146
146
|
* FinanceHub (banks, cards, Hometax, promissory notes),
|
|
147
|
-
* internal knowledge / business identity / company research (MCP), company research docs (cited tool-result blocks), Korean law (MCP), Bizinfo grants (MCP), NPS workplace headcount (MCP), and browser recorder replay / live browse.
|
|
147
|
+
* internal knowledge / business identity / company research (MCP), company research docs (cited tool-result blocks), Relate graph memory (MCP), Korean law (MCP), Bizinfo grants (MCP), NPS workplace headcount (MCP), and browser recorder replay / live browse.
|
|
148
148
|
* Works in both client and server components.
|
|
149
149
|
*
|
|
150
150
|
* Generated by @egdesk/next-api-plugin — do not edit by hand.
|
|
@@ -154,11 +154,13 @@ function generateHelpers(projectPath, options = {}) {
|
|
|
154
154
|
* - egdesk.config.ts — auto-generated runtime snapshot (gitignored; do not edit)
|
|
155
155
|
*
|
|
156
156
|
* AI / external agents:
|
|
157
|
-
* -
|
|
158
|
-
*
|
|
159
|
-
* -
|
|
160
|
-
* -
|
|
161
|
-
* - If
|
|
157
|
+
* - Install MCP from EGDesk (MCP Server → Claude Desktop / Antigravity / Cursor). One server key \`egdesk\`
|
|
158
|
+
* runs \`mcp-stdio-proxy.js combined\` against \`http://localhost:8080\` (full tool catalog when services are enabled).
|
|
159
|
+
* - Do not rely on \`egdesk-recorder\` alone (Recorder on :8081) for My DB — that catalog is Playwright / phone / scheduler only.
|
|
160
|
+
* - Prefer MCP tools when present: user_data_list_projects → user_data_select_project → user_data_list_tables / query.
|
|
161
|
+
* - If tools are only browser_recording_* / phone_* / scheduler_*, fix MCP config (main \`egdesk\` on :8080, EGDesk running), then restart the agent.
|
|
162
|
+
* - For app code in this repo, keep using these helpers — MCP is optional for external agents.
|
|
163
|
+
* - If MCP tools are missing/empty, fall back to helpers + EGDESK-README.md and ask the user to reinstall MCP from EGDesk.
|
|
162
164
|
* - Tunnel: getEgdeskTunnel() (live prod/dev URLs + X-Api-Key). Embed into Apps Script with setupAppsScriptEgdeskTunnel().
|
|
163
165
|
*/
|
|
164
166
|
|
|
@@ -4968,6 +4970,151 @@ export async function syncAppsScript(options: {
|
|
|
4968
4970
|
});
|
|
4969
4971
|
}
|
|
4970
4972
|
|
|
4973
|
+
// ==========================================
|
|
4974
|
+
// Relate (MCP) — graph memory / episodes / facts
|
|
4975
|
+
// ==========================================
|
|
4976
|
+
|
|
4977
|
+
/**
|
|
4978
|
+
* Call EGDesk Relate MCP tool (per-project graph: search, read-only Cypher, episode ingest).
|
|
4979
|
+
*
|
|
4980
|
+
* - Server: \`POST {apiUrl}/relate/tools/call\`
|
|
4981
|
+
* - Client: \`POST /__relate_proxy\` (see proxy.ts / middleware)
|
|
4982
|
+
* - Tools: \`relate_graph\`, \`relate_query\`, \`relate_ingest\` (enable Relate in EGDesk MCP settings)
|
|
4983
|
+
*/
|
|
4984
|
+
export async function callRelateTool(
|
|
4985
|
+
toolName: 'relate_graph' | 'relate_query' | 'relate_ingest',
|
|
4986
|
+
args: Record<string, any> = {}
|
|
4987
|
+
): Promise<any> {
|
|
4988
|
+
const body = JSON.stringify({ tool: toolName, arguments: args });
|
|
4989
|
+
|
|
4990
|
+
const isServer = typeof window === 'undefined';
|
|
4991
|
+
|
|
4992
|
+
let response: Response;
|
|
4993
|
+
if (isServer) {
|
|
4994
|
+
const apiUrl = resolveServerEgdeskApiUrl();
|
|
4995
|
+
response = await fetch(\`\${apiUrl}/relate/tools/call\`, {
|
|
4996
|
+
method: 'POST',
|
|
4997
|
+
headers: buildServerEgdeskHeaders(),
|
|
4998
|
+
body,
|
|
4999
|
+
});
|
|
5000
|
+
} else {
|
|
5001
|
+
response = await apiFetch('/__relate_proxy', {
|
|
5002
|
+
method: 'POST',
|
|
5003
|
+
headers: { 'Content-Type': 'application/json' },
|
|
5004
|
+
body,
|
|
5005
|
+
});
|
|
5006
|
+
}
|
|
5007
|
+
|
|
5008
|
+
return parseEgdeskMcpToolResponse(response);
|
|
5009
|
+
}
|
|
5010
|
+
|
|
5011
|
+
/** Relate graph project status (enabled, queue, counts). */
|
|
5012
|
+
export async function getRelateStatus(projectId?: string) {
|
|
5013
|
+
return callRelateTool('relate_graph', {
|
|
5014
|
+
action: 'status',
|
|
5015
|
+
...(projectId ? { project_id: projectId } : {}),
|
|
5016
|
+
});
|
|
5017
|
+
}
|
|
5018
|
+
|
|
5019
|
+
/** Hybrid / lexical / vector search over entities, facts, and episodes. */
|
|
5020
|
+
export async function searchRelateGraph(
|
|
5021
|
+
query: string,
|
|
5022
|
+
options: {
|
|
5023
|
+
projectId?: string;
|
|
5024
|
+
limit?: number;
|
|
5025
|
+
mode?: 'hybrid' | 'lexical' | 'vector';
|
|
5026
|
+
} = {}
|
|
5027
|
+
) {
|
|
5028
|
+
return callRelateTool('relate_graph', {
|
|
5029
|
+
action: 'search',
|
|
5030
|
+
query,
|
|
5031
|
+
...(options.projectId ? { project_id: options.projectId } : {}),
|
|
5032
|
+
...(options.limit !== undefined ? { limit: options.limit } : {}),
|
|
5033
|
+
...(options.mode ? { mode: options.mode } : {}),
|
|
5034
|
+
});
|
|
5035
|
+
}
|
|
5036
|
+
|
|
5037
|
+
export async function getRelateCurrentFacts(entityId: string, projectId?: string) {
|
|
5038
|
+
return callRelateTool('relate_graph', {
|
|
5039
|
+
action: 'current_facts',
|
|
5040
|
+
entity_id: entityId,
|
|
5041
|
+
...(projectId ? { project_id: projectId } : {}),
|
|
5042
|
+
});
|
|
5043
|
+
}
|
|
5044
|
+
|
|
5045
|
+
export async function getRelateFactHistory(
|
|
5046
|
+
entityId: string,
|
|
5047
|
+
factKey: string,
|
|
5048
|
+
projectId?: string
|
|
5049
|
+
) {
|
|
5050
|
+
return callRelateTool('relate_graph', {
|
|
5051
|
+
action: 'fact_history',
|
|
5052
|
+
entity_id: entityId,
|
|
5053
|
+
fact_key: factKey,
|
|
5054
|
+
...(projectId ? { project_id: projectId } : {}),
|
|
5055
|
+
});
|
|
5056
|
+
}
|
|
5057
|
+
|
|
5058
|
+
export async function getRelateEpisode(episodeId: string, projectId?: string) {
|
|
5059
|
+
return callRelateTool('relate_graph', {
|
|
5060
|
+
action: 'episode',
|
|
5061
|
+
episode_id: episodeId,
|
|
5062
|
+
...(projectId ? { project_id: projectId } : {}),
|
|
5063
|
+
});
|
|
5064
|
+
}
|
|
5065
|
+
|
|
5066
|
+
/** Read-only Cypher against the project graph (row cap enforced server-side). */
|
|
5067
|
+
export async function queryRelateGraph(
|
|
5068
|
+
cypher: string,
|
|
5069
|
+
options: { params?: Record<string, any>; projectId?: string } = {}
|
|
5070
|
+
) {
|
|
5071
|
+
return callRelateTool('relate_query', {
|
|
5072
|
+
cypher,
|
|
5073
|
+
...(options.params ? { params: options.params } : {}),
|
|
5074
|
+
...(options.projectId ? { project_id: options.projectId } : {}),
|
|
5075
|
+
});
|
|
5076
|
+
}
|
|
5077
|
+
|
|
5078
|
+
export async function addRelateEpisode(options: {
|
|
5079
|
+
text: string;
|
|
5080
|
+
kind?: 'call' | 'chat' | 'meeting' | 'note';
|
|
5081
|
+
sourceRef?: string;
|
|
5082
|
+
occurredAt?: string;
|
|
5083
|
+
participants?: string[];
|
|
5084
|
+
projectId?: string;
|
|
5085
|
+
confirmed?: boolean;
|
|
5086
|
+
}) {
|
|
5087
|
+
return callRelateTool('relate_ingest', {
|
|
5088
|
+
action: 'add_episode',
|
|
5089
|
+
text: options.text,
|
|
5090
|
+
...(options.kind ? { kind: options.kind } : {}),
|
|
5091
|
+
...(options.sourceRef ? { source_ref: options.sourceRef } : {}),
|
|
5092
|
+
...(options.occurredAt ? { occurred_at: options.occurredAt } : {}),
|
|
5093
|
+
...(options.participants ? { participants: options.participants } : {}),
|
|
5094
|
+
...(options.projectId ? { project_id: options.projectId } : {}),
|
|
5095
|
+
...(options.confirmed ? { confirmed: true } : {}),
|
|
5096
|
+
});
|
|
5097
|
+
}
|
|
5098
|
+
|
|
5099
|
+
export async function reextractRelateEpisode(
|
|
5100
|
+
episodeId: string,
|
|
5101
|
+
options: { projectId?: string; confirmed?: boolean } = {}
|
|
5102
|
+
) {
|
|
5103
|
+
return callRelateTool('relate_ingest', {
|
|
5104
|
+
action: 'reextract',
|
|
5105
|
+
episode_id: episodeId,
|
|
5106
|
+
...(options.projectId ? { project_id: options.projectId } : {}),
|
|
5107
|
+
...(options.confirmed ? { confirmed: true } : {}),
|
|
5108
|
+
});
|
|
5109
|
+
}
|
|
5110
|
+
|
|
5111
|
+
export async function getRelateIngestStatus(projectId?: string) {
|
|
5112
|
+
return callRelateTool('relate_ingest', {
|
|
5113
|
+
action: 'status',
|
|
5114
|
+
...(projectId ? { project_id: projectId } : {}),
|
|
5115
|
+
});
|
|
5116
|
+
}
|
|
5117
|
+
|
|
4971
5118
|
// ==========================================
|
|
4972
5119
|
// Knowledge Wiki (MCP) — Obsidian + wikiHow
|
|
4973
5120
|
// ==========================================
|
|
@@ -72,10 +72,24 @@ function loadGeneratedHelpersModule() {
|
|
|
72
72
|
node_fs_1.default.rmSync(tmpDir, { recursive: true, force: true });
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
(0, node_test_1.default)('EGDESK_HELPERS_GENERATION_VERSION is
|
|
75
|
+
(0, node_test_1.default)('EGDESK_HELPERS_GENERATION_VERSION is 7', () => {
|
|
76
76
|
const { helpers } = loadGeneratedHelpersModule();
|
|
77
|
-
strict_1.default.equal(generate_helpers_1.EGDESK_HELPERS_GENERATION_VERSION, '
|
|
78
|
-
strict_1.default.equal(helpers.EGDESK_HELPERS_GENERATION_VERSION, '
|
|
77
|
+
strict_1.default.equal(generate_helpers_1.EGDESK_HELPERS_GENERATION_VERSION, '7');
|
|
78
|
+
strict_1.default.equal(helpers.EGDESK_HELPERS_GENERATION_VERSION, '7');
|
|
79
|
+
});
|
|
80
|
+
(0, node_test_1.default)('searchRelateGraph calls relate MCP with search action', async () => {
|
|
81
|
+
const { helpers, calls } = loadGeneratedHelpersModule();
|
|
82
|
+
await helpers.searchRelateGraph('acme contract', { mode: 'hybrid', limit: 5 });
|
|
83
|
+
strict_1.default.equal(calls.length, 1);
|
|
84
|
+
strict_1.default.equal(calls[0].url, 'http://localhost:8080/relate/tools/call');
|
|
85
|
+
const body = JSON.parse(String(calls[0].options.body));
|
|
86
|
+
strict_1.default.equal(body.tool, 'relate_graph');
|
|
87
|
+
strict_1.default.deepEqual(body.arguments, {
|
|
88
|
+
action: 'search',
|
|
89
|
+
query: 'acme contract',
|
|
90
|
+
limit: 5,
|
|
91
|
+
mode: 'hybrid',
|
|
92
|
+
});
|
|
79
93
|
});
|
|
80
94
|
(0, node_test_1.default)('queryTable normalizes where fallback and coerces primitive values to strings', async () => {
|
|
81
95
|
const { helpers, calls } = loadGeneratedHelpersModule();
|
package/dist/generate-proxy.js
CHANGED
|
@@ -76,7 +76,7 @@ import type { NextRequest } from 'next/server';
|
|
|
76
76
|
/**
|
|
77
77
|
* EGDesk Database Proxy (Next.js 16+)
|
|
78
78
|
*
|
|
79
|
-
* Intercepts __user_data_proxy, __browser_recording_proxy, __business_identity_proxy, __company_research_proxy, __ai_center_proxy, __korean_law_proxy, __bizinfo_proxy, __nps_proxy, __seo_proxy, __hosting_coding_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
|
+
* Intercepts __user_data_proxy, __browser_recording_proxy, __business_identity_proxy, __company_research_proxy, __ai_center_proxy, __korean_law_proxy, __bizinfo_proxy, __nps_proxy, __seo_proxy, __hosting_coding_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, __relate_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
|
|
80
80
|
*
|
|
81
81
|
* POLICY (workspace-oauth-byo-multi-HANDOFF-README.md §6.9): Never codegen app/api/workspace-oauth/*
|
|
82
82
|
* or browser proxies to POST /workspace-oauth/tools/call — operator BYO config is not a visitor API.
|
|
@@ -678,6 +678,28 @@ export async function proxy(request: NextRequest) {
|
|
|
678
678
|
}
|
|
679
679
|
}
|
|
680
680
|
|
|
681
|
+
if (pathname.includes('__relate_proxy')) {
|
|
682
|
+
try {
|
|
683
|
+
const body = await request.text();
|
|
684
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
685
|
+
|
|
686
|
+
const response = await fetch(\`\${apiUrl}/relate/tools/call\`, {
|
|
687
|
+
method: 'POST',
|
|
688
|
+
headers: buildEgdeskHeaders(),
|
|
689
|
+
body,
|
|
690
|
+
});
|
|
691
|
+
|
|
692
|
+
const result = await response.json();
|
|
693
|
+
|
|
694
|
+
return NextResponse.json(result, { status: response.status });
|
|
695
|
+
} catch (error: any) {
|
|
696
|
+
return NextResponse.json(
|
|
697
|
+
{ error: 'Proxy error', message: error.message },
|
|
698
|
+
{ status: 500 }
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
|
|
681
703
|
if (pathname.includes('__kakao_proxy')) {
|
|
682
704
|
try {
|
|
683
705
|
const body = await request.text();
|
|
@@ -912,7 +934,7 @@ export const config = {
|
|
|
912
934
|
matcher: [
|
|
913
935
|
/*
|
|
914
936
|
* Match all paths except static assets
|
|
915
|
-
* The proxy function filters for __user_data_proxy / __browser_recording_proxy / __business_identity_proxy / __company_research_proxy / __ai_center_proxy / __korean_law_proxy / __bizinfo_proxy / __nps_proxy / __seo_proxy / __hosting_coding_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
|
|
937
|
+
* The proxy function filters for __user_data_proxy / __browser_recording_proxy / __business_identity_proxy / __company_research_proxy / __ai_center_proxy / __korean_law_proxy / __bizinfo_proxy / __nps_proxy / __seo_proxy / __hosting_coding_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 / __relate_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
|
|
916
938
|
*/
|
|
917
939
|
'/:path*',
|
|
918
940
|
],
|
|
@@ -779,6 +779,10 @@ export function VisitorGcpByoPanel() {
|
|
|
779
779
|
<p style={{ fontSize: '0.9rem', color: '#444' }}>
|
|
780
780
|
Upload a Web application OAuth client JSON. Secrets stay on the operator's EGDesk PC, not this site's server.
|
|
781
781
|
</p>
|
|
782
|
+
<p style={{ fontSize: '0.85rem', color: '#555', marginTop: 8 }}>
|
|
783
|
+
In Google Cloud Console → APIs & Services → Library, enable: Google Drive API, Google Sheets API,
|
|
784
|
+
Google Apps Script API, and Maps JavaScript API on the same project as your OAuth client.
|
|
785
|
+
</p>
|
|
782
786
|
<label style={{ display: 'block', marginBottom: 8 }}>
|
|
783
787
|
Handle (optional)
|
|
784
788
|
<input
|
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.
|
|
11
|
+
export declare const COMPATIBLE_APP_VERSION = "1.4.221";
|
|
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.
|
|
49
|
+
exports.COMPATIBLE_APP_VERSION = '1.4.221';
|
|
50
50
|
const fs = __importStar(require("fs"));
|
|
51
51
|
const path = __importStar(require("path"));
|
|
52
52
|
const setup_userdata_1 = require("./setup-userdata");
|