@torqon/mcp 0.1.5 → 0.1.7
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/cli.js +7 -6
- package/package.json +2 -3
package/dist/cli.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
14
14
|
import { homedir } from 'os';
|
|
15
15
|
import { join } from 'path';
|
|
16
|
+
import { exec } from 'child_process';
|
|
16
17
|
// ── Config ────────────────────────────────────────────────────────────────────
|
|
17
18
|
const CONFIG_PATH = join(homedir(), '.torqon', 'config.json');
|
|
18
19
|
function loadConfig() {
|
|
@@ -85,7 +86,7 @@ function progressBar(value, max, width = 24, warn = false) {
|
|
|
85
86
|
}
|
|
86
87
|
// ── Commands ──────────────────────────────────────────────────────────────────
|
|
87
88
|
function printLogo() {
|
|
88
|
-
console.log(`\n ${P('t')}${B('orqon')} ${Gr('cli v0.1.
|
|
89
|
+
console.log(`\n ${P('t')}${B('orqon')} ${Gr('cli v0.1.6')}`);
|
|
89
90
|
console.log(` ${Gr('memory layer for LLMs')}\n`);
|
|
90
91
|
}
|
|
91
92
|
function printHelp() {
|
|
@@ -235,7 +236,6 @@ function cmdConfig() {
|
|
|
235
236
|
}
|
|
236
237
|
function openBrowser(url) {
|
|
237
238
|
const { platform } = process;
|
|
238
|
-
const { exec } = require('child_process');
|
|
239
239
|
if (platform === 'win32')
|
|
240
240
|
exec(`start "" "${url}"`);
|
|
241
241
|
else if (platform === 'darwin')
|
|
@@ -243,12 +243,12 @@ function openBrowser(url) {
|
|
|
243
243
|
else
|
|
244
244
|
exec(`xdg-open "${url}"`);
|
|
245
245
|
}
|
|
246
|
-
async function pollForToken(state, timeoutMs = 120_000) {
|
|
246
|
+
async function pollForToken(state, webUrl, timeoutMs = 120_000) {
|
|
247
247
|
const deadline = Date.now() + timeoutMs;
|
|
248
248
|
while (Date.now() < deadline) {
|
|
249
249
|
await new Promise(r => setTimeout(r, 2000));
|
|
250
250
|
try {
|
|
251
|
-
const res = await fetch(`${
|
|
251
|
+
const res = await fetch(`${webUrl}/api/auth/cli/token?state=${state}`);
|
|
252
252
|
if (res.ok) {
|
|
253
253
|
const data = await res.json();
|
|
254
254
|
if (data?.apiKey)
|
|
@@ -264,13 +264,14 @@ async function cmdLogin() {
|
|
|
264
264
|
printLogo();
|
|
265
265
|
// Generate a random one-time state token
|
|
266
266
|
const state = Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2);
|
|
267
|
-
const
|
|
267
|
+
const WEB_URL = API_URL.includes('localhost') ? 'http://localhost:3002' : 'https://torqon.vercel.app';
|
|
268
|
+
const loginUrl = `${WEB_URL}/auth/cli?state=${state}`;
|
|
268
269
|
console.log(` ${B('Opening browser to complete login...')}\n`);
|
|
269
270
|
console.log(` ${Gr('URL:')} ${Cy(loginUrl)}\n`);
|
|
270
271
|
console.log(` ${Gr("If the browser didn't open, copy the URL above and paste it manually.")}\n`);
|
|
271
272
|
openBrowser(loginUrl);
|
|
272
273
|
console.log(` ${Gr('Waiting for authentication')}`, '');
|
|
273
|
-
const apiKey = await pollForToken(state);
|
|
274
|
+
const apiKey = await pollForToken(state, WEB_URL);
|
|
274
275
|
if (!apiKey) {
|
|
275
276
|
console.log(`\n\n ${R('✗ Login timed out (2 minutes).')}`);
|
|
276
277
|
console.log(` ${Gr('Run')} ${P('torqon login')} ${Gr('to try again.\n')}`);
|