openliate 0.0.1 → 0.1.6

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.
Files changed (73) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +73 -241
  3. package/README.npm.md +128 -0
  4. package/dist/bin.js +24644 -42273
  5. package/dist/liate.js +39479 -0
  6. package/dist/runtime/hono.js +28072 -0
  7. package/dist/runtime/index.js +28072 -0
  8. package/hub/agents/docgyan-agent/agent.json +27 -0
  9. package/hub/agents/docgyan-agent/agent.ts +39 -0
  10. package/hub/agents/gnani-agent/agent.json +17 -0
  11. package/hub/agents/neon-agent/agent.json +18 -0
  12. package/hub/agents/prism-agent/agent.json +17 -0
  13. package/hub/agents/sarvam-agent/agent.json +9 -6
  14. package/package.json +33 -21
  15. package/src/cli/index.ts +346 -0
  16. package/src/cli/resolver.ts +153 -0
  17. package/src/core/aum.ts +87 -28
  18. package/src/core/om.ts +159 -0
  19. package/src/core/spec.ts +112 -0
  20. package/src/core/uuid.ts +5 -16
  21. package/src/core/version.ts +2 -0
  22. package/src/layers/agent/harness.ts +118 -0
  23. package/src/{agent → layers/agent}/loop.ts +44 -24
  24. package/src/layers/agent/skills.ts +302 -0
  25. package/src/{agent → layers/agent}/types.ts +14 -1
  26. package/src/{environment/environment.ts → layers/environment/sandbox.ts} +24 -5
  27. package/src/{environment → layers/environment}/types.ts +8 -0
  28. package/src/layers/integration/knowledge.ts +187 -0
  29. package/src/layers/integration/lib.ts +167 -0
  30. package/src/{integration → layers/integration}/memory.ts +49 -67
  31. package/src/layers/integration/repo.ts +273 -0
  32. package/src/{integration → layers/integration}/types.ts +60 -31
  33. package/src/layers/llm/model.ts +928 -0
  34. package/src/layers/llm/types.ts +64 -0
  35. package/src/{tools → layers/tools}/mcp.ts +24 -10
  36. package/src/layers/tools/registry.ts +307 -0
  37. package/src/{tools → layers/tools}/server.ts +12 -13
  38. package/src/{tools → layers/tools}/types.ts +3 -2
  39. package/src/liate.ts +64 -24
  40. package/src/routes/skills.ts +73 -0
  41. package/src/runtime/hono.ts +346 -0
  42. package/src/runtime/wasm.ts +23 -0
  43. package/src/scaffold/project.ts +188 -0
  44. package/dist/engine/engine.zip +0 -0
  45. package/dist/engine/index.js +0 -36790
  46. package/hub/agents/email-agent/agent.json +0 -19
  47. package/hub/agents/general-agent/agent.json +0 -18
  48. package/hub/agents/identity-agent/agent.json +0 -19
  49. package/hub/agents/research-agent/agent.json +0 -18
  50. package/hub/llm/sarvam.json +0 -27
  51. package/hub/mcp/agentmail.json +0 -10
  52. package/hub/mcp/fetch.json +0 -9
  53. package/hub/mcp/neon.json +0 -12
  54. package/hub/mcp/sarvam.json +0 -12
  55. package/hub/mcp/supabase.json +0 -12
  56. package/hub/mcp/vercel.json +0 -12
  57. package/src/agent/agent.ts +0 -165
  58. package/src/cli.ts +0 -272
  59. package/src/engine/types.ts +0 -104
  60. package/src/integration/integration.ts +0 -37
  61. package/src/link/index.ts +0 -317
  62. package/src/link/neon.ts +0 -646
  63. package/src/link/supabase.ts +0 -567
  64. package/src/link/vercel.ts +0 -633
  65. package/src/llm/config.ts +0 -46
  66. package/src/llm/hub.ts +0 -59
  67. package/src/llm/llm.ts +0 -60
  68. package/src/llm/sarvam.ts +0 -136
  69. package/src/server/engine.ts +0 -277
  70. package/src/server/index.ts +0 -32
  71. package/src/tools/builtin/fetch.ts +0 -66
  72. package/src/tools/builtin/identity.ts +0 -131
  73. package/src/tools/registry.ts +0 -218
@@ -1,567 +0,0 @@
1
- import { createHash, randomBytes } from "crypto";
2
- import http from "http";
3
- import fs from "fs";
4
- import path from "path";
5
- import os from "os";
6
- import { generateUUIDv7 } from "../core/uuid";
7
-
8
- export const SUPABASE_MCP_ENDPOINT = "https://mcp.supabase.com/mcp";
9
- export const SUPABASE_REGISTER_ENDPOINT = "https://api.supabase.com/platform/oauth/apps/register";
10
- export const SUPABASE_AUTH_ENDPOINT = "https://api.supabase.com/v1/oauth/authorize";
11
- export const SUPABASE_TOKEN_ENDPOINT = "https://api.supabase.com/v1/oauth/token";
12
- export const SUPABASE_API_ENDPOINT = "https://api.supabase.com/v1";
13
- export const DEFAULT_SUPABASE_CALLBACK_PORT = 54323;
14
- export const DEFAULT_SUPABASE_CALLBACK_URL = `http://localhost:${DEFAULT_SUPABASE_CALLBACK_PORT}/callback`;
15
-
16
- export function base64url(buffer: Buffer): string {
17
- return buffer
18
- .toString("base64")
19
- .replace(/\+/g, "-")
20
- .replace(/\//g, "_")
21
- .replace(/=+$/, "");
22
- }
23
-
24
- export function generatePKCE() {
25
- const codeVerifier = base64url(randomBytes(32));
26
- const codeChallenge = base64url(createHash("sha256").update(codeVerifier).digest());
27
- return { codeVerifier, codeChallenge };
28
- }
29
-
30
- export interface SupabaseTokenData {
31
- access_token: string;
32
- refresh_token?: string;
33
- project_ref?: string;
34
- organization?: string;
35
- mcp_url?: string;
36
- saved_at: string;
37
- }
38
-
39
- export interface ClientRegistration {
40
- client_id: string;
41
- client_secret?: string;
42
- }
43
-
44
- export class SupabaseMcpOAuth {
45
- public static getTokenPath(): string {
46
- if (process.env.LIATE_CONFIG_DIR) {
47
- if (!fs.existsSync(process.env.LIATE_CONFIG_DIR)) {
48
- fs.mkdirSync(process.env.LIATE_CONFIG_DIR, { recursive: true });
49
- }
50
- return path.join(process.env.LIATE_CONFIG_DIR, "supabase_token.json");
51
- }
52
-
53
- try {
54
- const homeDir = path.join(os.homedir(), ".liate");
55
- if (!fs.existsSync(homeDir)) {
56
- fs.mkdirSync(homeDir, { recursive: true });
57
- }
58
- return path.join(homeDir, "supabase_token.json");
59
- } catch {
60
- return path.resolve(process.cwd(), ".liate", "supabase_token.json");
61
- }
62
- }
63
-
64
- public static loadToken(): SupabaseTokenData | null {
65
- const candidatePaths = [
66
- process.env.LIATE_CONFIG_DIR ? path.join(process.env.LIATE_CONFIG_DIR, "supabase_token.json") : "",
67
- path.resolve(process.cwd(), ".liate", "supabase_token.json"),
68
- path.resolve(process.cwd(), "..", ".liate", "supabase_token.json"),
69
- path.resolve(__dirname, "..", "..", ".liate", "supabase_token.json"),
70
- path.resolve(os.homedir(), ".liate", "supabase_token.json")
71
- ].filter(Boolean);
72
-
73
- for (const p of candidatePaths) {
74
- try {
75
- if (fs.existsSync(p)) {
76
- const raw = fs.readFileSync(p, "utf-8");
77
- const parsed = JSON.parse(raw);
78
- if (parsed && parsed.access_token) {
79
- return parsed;
80
- }
81
- }
82
- } catch {}
83
- }
84
-
85
- const envToken = process.env.SUPABASE_MCP_TOKEN || process.env.SUPABASE_ACCESS_TOKEN;
86
- if (envToken) {
87
- return {
88
- access_token: envToken,
89
- saved_at: new Date().toISOString()
90
- };
91
- }
92
-
93
- return null;
94
- }
95
-
96
- public static saveToken(data: SupabaseTokenData): void {
97
- const tokenPath = SupabaseMcpOAuth.getTokenPath();
98
- const dir = path.dirname(tokenPath);
99
- if (!fs.existsSync(dir)) {
100
- fs.mkdirSync(dir, { recursive: true });
101
- }
102
- fs.writeFileSync(tokenPath, JSON.stringify(data, null, 2), "utf-8");
103
-
104
- try {
105
- const mirrorPath = path.resolve(process.cwd(), ".liate", "supabase_token.json");
106
- const mirrorDir = path.dirname(mirrorPath);
107
- if (!fs.existsSync(mirrorDir)) {
108
- fs.mkdirSync(mirrorDir, { recursive: true });
109
- }
110
- fs.writeFileSync(mirrorPath, JSON.stringify(data, null, 2), "utf-8");
111
- } catch {}
112
-
113
- try {
114
- const envPath = path.join(process.cwd(), ".env.local");
115
- let content = fs.existsSync(envPath) ? fs.readFileSync(envPath, "utf-8") : "";
116
- if (content.includes("SUPABASE_MCP_TOKEN=")) {
117
- content = content.replace(/SUPABASE_MCP_TOKEN=.*(\r?\n|$)/, `SUPABASE_MCP_TOKEN="${data.access_token}"\n`);
118
- } else {
119
- content += `\n# OpenLiate Supabase MCP Access Token\nSUPABASE_MCP_TOKEN="${data.access_token}"\n`;
120
- }
121
- if (data.project_ref) {
122
- if (content.includes("SUPABASE_PROJECT_REF=")) {
123
- content = content.replace(/SUPABASE_PROJECT_REF=.*(\r?\n|$)/, `SUPABASE_PROJECT_REF="${data.project_ref}"\n`);
124
- } else {
125
- content += `SUPABASE_PROJECT_REF="${data.project_ref}"\n`;
126
- }
127
- }
128
- fs.writeFileSync(envPath, content, "utf-8");
129
- } catch {}
130
- }
131
-
132
- public static clearToken(): void {
133
- const candidatePaths = [
134
- process.env.LIATE_CONFIG_DIR ? path.join(process.env.LIATE_CONFIG_DIR, "supabase_token.json") : "",
135
- SupabaseMcpOAuth.getTokenPath(),
136
- path.resolve(process.cwd(), ".liate", "supabase_token.json"),
137
- path.resolve(process.cwd(), "..", ".liate", "supabase_token.json"),
138
- path.resolve(__dirname, "..", "..", ".liate", "supabase_token.json"),
139
- path.resolve(os.homedir(), ".liate", "supabase_token.json")
140
- ].filter(Boolean);
141
-
142
- for (const p of candidatePaths) {
143
- try {
144
- if (fs.existsSync(p)) {
145
- fs.unlinkSync(p);
146
- }
147
- } catch {}
148
- }
149
-
150
- try {
151
- const envPath = path.join(process.cwd(), ".env.local");
152
- if (fs.existsSync(envPath)) {
153
- let content = fs.readFileSync(envPath, "utf-8");
154
- content = content.replace(/SUPABASE_MCP_TOKEN=.*(\r?\n|$)/g, "");
155
- content = content.replace(/SUPABASE_PROJECT_REF=.*(\r?\n|$)/g, "");
156
- fs.writeFileSync(envPath, content.trim() + "\n", "utf-8");
157
- }
158
- } catch {}
159
-
160
- delete process.env.SUPABASE_MCP_TOKEN;
161
- delete process.env.SUPABASE_ACCESS_TOKEN;
162
- delete process.env.SUPABASE_PROJECT_REF;
163
- }
164
-
165
- public static async registerClient(callbackUrl: string): Promise<ClientRegistration> {
166
- try {
167
- const res = await fetch(SUPABASE_REGISTER_ENDPOINT, {
168
- method: "POST",
169
- headers: { "Content-Type": "application/json" },
170
- body: JSON.stringify({
171
- client_name: "OpenLiate CLI",
172
- client_uri: "https://openliate.tech",
173
- redirect_uris: [callbackUrl],
174
- grant_types: ["authorization_code", "refresh_token"],
175
- response_types: ["code"],
176
- token_endpoint_auth_method: "client_secret_post"
177
- })
178
- });
179
-
180
- if (res.ok) {
181
- const body = (await res.json()) as any;
182
- if (body.client_id) {
183
- return {
184
- client_id: body.client_id,
185
- client_secret: body.client_secret
186
- };
187
- }
188
- }
189
- } catch {}
190
-
191
- return {
192
- client_id: process.env.SUPABASE_MCP_CLIENT_ID || "ca05de37-96dd-400c-b0a6-fe081604eb4f",
193
- client_secret: process.env.SUPABASE_MCP_CLIENT_SECRET || "sba_604a6f033ea7f9c904f52f3b78140b5fae6992b5"
194
- };
195
- }
196
-
197
- public static buildAuthUrl(
198
- clientId: string,
199
- redirectUri: string,
200
- codeChallenge: string,
201
- state: string
202
- ): string {
203
- const url = new URL(SUPABASE_AUTH_ENDPOINT);
204
- url.searchParams.set("client_id", clientId);
205
- url.searchParams.set("response_type", "code");
206
- url.searchParams.set("redirect_uri", redirectUri);
207
- url.searchParams.set("code_challenge", codeChallenge);
208
- url.searchParams.set("code_challenge_method", "S256");
209
- url.searchParams.set("state", state);
210
- return url.toString();
211
- }
212
-
213
- public static async exchangeCodeForToken(
214
- clientId: string,
215
- clientSecret: string | undefined,
216
- code: string,
217
- codeVerifier: string,
218
- redirectUri: string
219
- ): Promise<SupabaseTokenData> {
220
- const params = new URLSearchParams({
221
- grant_type: "authorization_code",
222
- code: code,
223
- redirect_uri: redirectUri,
224
- client_id: clientId,
225
- code_verifier: codeVerifier
226
- });
227
-
228
- const headers: Record<string, string> = {
229
- "Content-Type": "application/x-www-form-urlencoded"
230
- };
231
-
232
- if (clientSecret) {
233
- headers["Authorization"] = `Basic ${Buffer.from(`${clientId}:${clientSecret}`).toString("base64")}`;
234
- }
235
-
236
- const res = await fetch(SUPABASE_TOKEN_ENDPOINT, {
237
- method: "POST",
238
- headers,
239
- body: params
240
- });
241
-
242
- if (!res.ok) {
243
- const errText = await res.text();
244
- throw new Error(`Supabase MCP token exchange failed (${res.status}): ${errText}`);
245
- }
246
-
247
- const data = (await res.json()) as any;
248
- if (!data.access_token) {
249
- throw new Error("No access_token returned by Supabase token endpoint");
250
- }
251
-
252
- let projectRef: string | undefined;
253
- let organization: string | undefined;
254
-
255
- // Dynamically query user organizations and projects
256
- try {
257
- const [orgRes, projRes] = await Promise.all([
258
- fetch(`${SUPABASE_API_ENDPOINT}/organizations`, {
259
- headers: { Authorization: `Bearer ${data.access_token}` }
260
- }),
261
- fetch(`${SUPABASE_API_ENDPOINT}/projects`, {
262
- headers: { Authorization: `Bearer ${data.access_token}` }
263
- })
264
- ]);
265
-
266
- if (orgRes.ok) {
267
- const orgs = (await orgRes.json()) as any[];
268
- if (Array.isArray(orgs) && orgs.length > 0) {
269
- organization = orgs[0].name || orgs[0].id;
270
- }
271
- }
272
-
273
- if (projRes.ok) {
274
- const projs = (await projRes.json()) as any[];
275
- if (Array.isArray(projs) && projs.length > 0) {
276
- projectRef = projs[0].id || projs[0].ref;
277
- }
278
- }
279
- } catch {}
280
-
281
- return {
282
- access_token: data.access_token,
283
- refresh_token: data.refresh_token,
284
- project_ref: projectRef,
285
- organization: organization,
286
- mcp_url: SUPABASE_MCP_ENDPOINT,
287
- saved_at: new Date().toISOString()
288
- };
289
- }
290
- }
291
-
292
- export class SupabaseMcpClient {
293
- private token: string;
294
-
295
- constructor(token: string) {
296
- this.token = token;
297
- }
298
-
299
- public async callMcp(method: string, params: Record<string, any> = {}): Promise<any> {
300
- const rpcPayload = {
301
- jsonrpc: "2.0",
302
- id: Date.now(),
303
- method: method,
304
- params: params
305
- };
306
-
307
- const res = await fetch(SUPABASE_MCP_ENDPOINT, {
308
- method: "POST",
309
- headers: {
310
- "Content-Type": "application/json",
311
- Authorization: `Bearer ${this.token}`,
312
- Accept: "application/json, text/event-stream"
313
- },
314
- body: JSON.stringify(rpcPayload)
315
- });
316
-
317
- const text = await res.text();
318
- const match = text.match(/data: ({.*})/);
319
- if (match) {
320
- return JSON.parse(match[1]);
321
- }
322
- try {
323
- return JSON.parse(text);
324
- } catch {
325
- return { raw: text };
326
- }
327
- }
328
-
329
- public async listProjects(): Promise<any[]> {
330
- const res = await fetch(`${SUPABASE_API_ENDPOINT}/projects`, {
331
- headers: {
332
- Authorization: `Bearer ${this.token}`,
333
- Accept: "application/json"
334
- }
335
- });
336
- if (!res.ok) {
337
- throw new Error(`Failed to list Supabase projects: ${res.statusText}`);
338
- }
339
- return (await res.json()) as any[];
340
- }
341
-
342
- public async deployEngine(options: {
343
- slug?: string;
344
- projectRef?: string;
345
- body?: string;
346
- } = {}): Promise<{
347
- slug: string;
348
- name: string;
349
- projectRef: string;
350
- functionUrl: string;
351
- engineUrl: string;
352
- mcpUrl: string;
353
- }> {
354
- const uuid7 = generateUUIDv7();
355
- const fnSlug = options.slug || "openliate";
356
-
357
- let projectRef = options.projectRef || process.env.SUPABASE_PROJECT_REF;
358
- if (!projectRef) {
359
- const saved = SupabaseMcpOAuth.loadToken();
360
- projectRef = saved?.project_ref;
361
- }
362
-
363
- if (!projectRef) {
364
- const projects = await this.listProjects();
365
- if (projects.length === 0) {
366
- throw new Error("No active Supabase projects found in account. Please create a project at https://supabase.com/dashboard first.");
367
- }
368
- projectRef = projects[0].id || projects[0].ref;
369
- }
370
-
371
- let bundleCode = options.body || "";
372
- if (!bundleCode) {
373
- const candidatePaths = [
374
- path.resolve(process.cwd(), "dist", "engine", "index.js"),
375
- path.resolve(process.cwd(), "liate", "dist", "engine", "index.js"),
376
- path.resolve(__dirname, "..", "..", "dist", "engine", "index.js")
377
- ];
378
- for (const p of candidatePaths) {
379
- if (fs.existsSync(p)) {
380
- bundleCode = fs.readFileSync(p, "utf-8");
381
- break;
382
- }
383
- }
384
- }
385
-
386
- if (!bundleCode) {
387
- throw new Error("Could not locate dist/engine/index.js. Please run 'bun run build:engine' first.");
388
- }
389
-
390
- // Ensure Node builtins use node: prefix for Deno runtime compatibility in Supabase Edge Functions
391
- bundleCode = bundleCode
392
- .replace(/from\s+["'](os|fs|path|http|https|crypto|stream|events|util|buffer|url|net|tls|zlib)["']/g, 'from "node:$1"')
393
- .replace(/import\s+["'](os|fs|path|http|https|crypto|stream|events|util|buffer|url|net|tls|zlib)["']/g, 'import "node:$1"')
394
- .replace(/require\(["'](os|fs|path|http|https|crypto|stream|events|util|buffer|url|net|tls|zlib)["']\)/g, 'require("node:$1")');
395
-
396
- const deployRes = await fetch(`${SUPABASE_API_ENDPOINT}/projects/${projectRef}/functions`, {
397
- method: "POST",
398
- headers: {
399
- Authorization: `Bearer ${this.token}`,
400
- "Content-Type": "application/json"
401
- },
402
- body: JSON.stringify({
403
- slug: fnSlug,
404
- name: fnSlug,
405
- body: bundleCode,
406
- verify_jwt: false
407
- })
408
- });
409
-
410
- const deployData = (await deployRes.json()) as any;
411
- if (!deployRes.ok || !deployData?.id) {
412
- // If function already exists, try update (PATCH)
413
- if (deployRes.status === 409 || deployData?.message?.includes("already exists")) {
414
- const patchRes = await fetch(`${SUPABASE_API_ENDPOINT}/projects/${projectRef}/functions/${fnSlug}`, {
415
- method: "PATCH",
416
- headers: {
417
- Authorization: `Bearer ${this.token}`,
418
- "Content-Type": "application/json"
419
- },
420
- body: JSON.stringify({
421
- body: bundleCode,
422
- verify_jwt: false
423
- })
424
- });
425
- if (!patchRes.ok) {
426
- throw new Error(`Supabase function update failed (${patchRes.status}): ${await patchRes.text()}`);
427
- }
428
- } else {
429
- throw new Error(`Supabase function deploy failed (${deployRes.status}): ${deployData?.message || JSON.stringify(deployData)}`);
430
- }
431
- }
432
-
433
- const functionUrl = `https://${projectRef}.supabase.co/functions/v1/${fnSlug}`;
434
- const engineUrl = `${functionUrl}/run`;
435
-
436
- try {
437
- const deployPath = path.resolve(process.cwd(), ".liate", "supabase_deployment.json");
438
- const deployDir = path.dirname(deployPath);
439
- if (!fs.existsSync(deployDir)) {
440
- fs.mkdirSync(deployDir, { recursive: true });
441
- }
442
- fs.writeFileSync(
443
- deployPath,
444
- JSON.stringify(
445
- {
446
- slug: fnSlug,
447
- projectRef,
448
- functionUrl,
449
- engineUrl,
450
- uuid7,
451
- deployedAt: new Date().toISOString()
452
- },
453
- null,
454
- 2
455
- ),
456
- "utf-8"
457
- );
458
- } catch {}
459
-
460
- return {
461
- slug: fnSlug,
462
- name: fnSlug,
463
- projectRef,
464
- functionUrl,
465
- engineUrl,
466
- mcpUrl: SUPABASE_MCP_ENDPOINT
467
- };
468
- }
469
- }
470
-
471
- export async function runSupabaseLinkFlow(options: {
472
- port?: number;
473
- openBrowser?: boolean;
474
- } = {}): Promise<SupabaseTokenData> {
475
- const port = options.port || DEFAULT_SUPABASE_CALLBACK_PORT;
476
- const redirectUri = `http://localhost:${port}/callback`;
477
-
478
- console.log(`\n⚡ [OpenLiate] Registering Dynamic Client with Supabase MCP...`);
479
- const reg = await SupabaseMcpOAuth.registerClient(redirectUri);
480
-
481
- const { codeVerifier, codeChallenge } = generatePKCE();
482
- const state = randomBytes(16).toString("hex");
483
-
484
- const authUrl = SupabaseMcpOAuth.buildAuthUrl(
485
- reg.client_id,
486
- redirectUri,
487
- codeChallenge,
488
- state
489
- );
490
-
491
- return new Promise<SupabaseTokenData>((resolve, reject) => {
492
- const server = http.createServer(async (req, res) => {
493
- try {
494
- const reqUrl = new URL(req.url || "/", `http://localhost:${port}`);
495
- if (reqUrl.pathname === "/callback") {
496
- const code = reqUrl.searchParams.get("code");
497
- const retState = reqUrl.searchParams.get("state");
498
- const error = reqUrl.searchParams.get("error");
499
-
500
- if (error) {
501
- res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
502
- res.end(`<h3>Supabase MCP Link Failed</h3><p>${error}</p>`);
503
- server.close();
504
- return reject(new Error(`Supabase OAuth Error: ${error}`));
505
- }
506
-
507
- if (!code || retState !== state) {
508
- res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
509
- res.end(`<h3>Invalid State or Missing Code</h3>`);
510
- server.close();
511
- return reject(new Error("State mismatch or missing authorization code"));
512
- }
513
-
514
- res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
515
- res.end(`<!DOCTYPE html>
516
- <html>
517
- <head>
518
- <meta charset="utf-8">
519
- <title>Liate — Supabase Linked</title>
520
- </head>
521
- <body style="font-family: -apple-system, system-ui, sans-serif; padding: 40px; text-align: center; color: #111;">
522
- <h2>Authentication successful</h2>
523
- <p>Supabase is linked to Liate. You can close this window and return to your terminal.</p>
524
- <script>try { window.close(); } catch(e) {}</script>
525
- </body>
526
- </html>`);
527
- server.close();
528
-
529
- console.log(`⚡ [OpenLiate] Exchanging Authorization Code with Supabase...`);
530
- const tokenData = await SupabaseMcpOAuth.exchangeCodeForToken(
531
- reg.client_id,
532
- reg.client_secret,
533
- code,
534
- codeVerifier,
535
- redirectUri
536
- );
537
-
538
- SupabaseMcpOAuth.saveToken(tokenData);
539
- console.log(`⚡ [OpenLiate] Supabase MCP Access Token saved successfully!`);
540
- resolve(tokenData);
541
- }
542
- } catch (err) {
543
- server.close();
544
- reject(err);
545
- }
546
- });
547
-
548
- server.listen(port, () => {
549
- console.log(`\n⚡ [OpenLiate] Complete Supabase authorization in your browser:\n`);
550
- console.log(` ${authUrl}\n`);
551
-
552
- if (options.openBrowser !== false) {
553
- try {
554
- const { exec } = require("child_process");
555
- const startCmd =
556
- process.platform === "win32"
557
- ? `start "" "${authUrl}"`
558
- : process.platform === "darwin"
559
- ? `open "${authUrl}"`
560
- : `xdg-open "${authUrl}"`;
561
- exec(startCmd);
562
- } catch {}
563
- }
564
- });
565
- });
566
- }
567
-