connectbase-client 0.10.6 → 0.10.8
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 +98 -65
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -30,7 +30,7 @@ var crypto = __toESM(require("crypto"));
|
|
|
30
30
|
var https = __toESM(require("https"));
|
|
31
31
|
var http = __toESM(require("http"));
|
|
32
32
|
var readline = __toESM(require("readline"));
|
|
33
|
-
var VERSION = "0.6
|
|
33
|
+
var VERSION = "0.10.6";
|
|
34
34
|
var DEFAULT_BASE_URL = "https://api.connectbase.world";
|
|
35
35
|
var colors = {
|
|
36
36
|
reset: "\x1B[0m",
|
|
@@ -182,7 +182,6 @@ async function makeRequest(url, method, headers, body) {
|
|
|
182
182
|
headers: {
|
|
183
183
|
...headers,
|
|
184
184
|
"Content-Type": "application/json",
|
|
185
|
-
Origin: `${parsedUrl.protocol}//${parsedUrl.host}`,
|
|
186
185
|
...bodyBuffer ? { "Content-Length": bodyBuffer.length } : {}
|
|
187
186
|
}
|
|
188
187
|
};
|
|
@@ -374,7 +373,9 @@ async function browserAuthFlow() {
|
|
|
374
373
|
{}
|
|
375
374
|
);
|
|
376
375
|
if (startRes.status !== 200) {
|
|
377
|
-
|
|
376
|
+
const errData = startRes.data;
|
|
377
|
+
const detail = errData?.error || errData?.message || `HTTP ${startRes.status}`;
|
|
378
|
+
error(`\uC778\uC99D \uC138\uC158 \uC2DC\uC791\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4: ${detail}`);
|
|
378
379
|
process.exit(1);
|
|
379
380
|
}
|
|
380
381
|
const { session_id } = startRes.data;
|
|
@@ -384,9 +385,11 @@ ${colors.cyan}\uBE0C\uB77C\uC6B0\uC800\uC5D0\uC11C \uB85C\uADF8\uC778\uD558\uC13
|
|
|
384
385
|
log(`${colors.dim}${authUrl}${colors.reset}
|
|
385
386
|
`);
|
|
386
387
|
openBrowser(authUrl);
|
|
387
|
-
const pollInterval =
|
|
388
|
-
const maxAttempts =
|
|
388
|
+
const pollInterval = 3e3;
|
|
389
|
+
const maxAttempts = 100;
|
|
389
390
|
let attempts = 0;
|
|
391
|
+
let consecutive404 = 0;
|
|
392
|
+
const max404Retries = 5;
|
|
390
393
|
const spinnerFrames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
391
394
|
while (attempts < maxAttempts) {
|
|
392
395
|
const frame = spinnerFrames[attempts % spinnerFrames.length];
|
|
@@ -399,6 +402,7 @@ ${colors.cyan}\uBE0C\uB77C\uC6B0\uC800\uC5D0\uC11C \uB85C\uADF8\uC778\uD558\uC13
|
|
|
399
402
|
{}
|
|
400
403
|
);
|
|
401
404
|
if (pollRes.status === 200) {
|
|
405
|
+
consecutive404 = 0;
|
|
402
406
|
const data = pollRes.data;
|
|
403
407
|
if (data.status === "approved" && data.secret_key) {
|
|
404
408
|
process.stdout.write("\r \r");
|
|
@@ -417,9 +421,12 @@ ${colors.cyan}\uBE0C\uB77C\uC6B0\uC800\uC5D0\uC11C \uB85C\uADF8\uC778\uD558\uC13
|
|
|
417
421
|
}
|
|
418
422
|
}
|
|
419
423
|
if (pollRes.status === 404) {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
424
|
+
consecutive404++;
|
|
425
|
+
if (consecutive404 >= max404Retries) {
|
|
426
|
+
process.stdout.write("\r \r");
|
|
427
|
+
error("\uC778\uC99D \uC138\uC158\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. \uB2E4\uC2DC \uC2DC\uB3C4\uD574\uC8FC\uC138\uC694.");
|
|
428
|
+
process.exit(1);
|
|
429
|
+
}
|
|
423
430
|
}
|
|
424
431
|
} catch {
|
|
425
432
|
}
|
|
@@ -456,7 +463,13 @@ ${colors.dim}\uC778\uC99D \uBC29\uC2DD\uC744 \uC120\uD0DD\uD558\uC138\uC694:${co
|
|
|
456
463
|
const authChoice = await prompt(`${colors.blue}?${colors.reset} \uC120\uD0DD (1/2): `);
|
|
457
464
|
let secretKey = "";
|
|
458
465
|
if (authChoice === "2") {
|
|
459
|
-
|
|
466
|
+
try {
|
|
467
|
+
secretKey = await browserAuthFlow();
|
|
468
|
+
} catch (err) {
|
|
469
|
+
error(`\uB124\uD2B8\uC6CC\uD06C \uC624\uB958: ${err instanceof Error ? err.message : err}`);
|
|
470
|
+
info("\uC778\uD130\uB137 \uC5F0\uACB0\uC744 \uD655\uC778\uD558\uAC70\uB098, Secret Key \uC9C1\uC811 \uC785\uB825(\uC635\uC158 1)\uC744 \uC2DC\uB3C4\uD558\uC138\uC694");
|
|
471
|
+
process.exit(1);
|
|
472
|
+
}
|
|
460
473
|
} else {
|
|
461
474
|
log(`${colors.dim}Secret Key (cb_sk_): \uCF58\uC194 > \uD504\uB85C\uD544 > \uC2DC\uD06C\uB9BF \uD0A4 \uD0ED\uC5D0\uC11C \uBC1C\uAE09${colors.reset}
|
|
462
475
|
`);
|
|
@@ -561,80 +574,100 @@ ${colors.blue}?${colors.reset} \uC120\uD0DD (\uBC88\uD638): `);
|
|
|
561
574
|
}
|
|
562
575
|
}
|
|
563
576
|
const apiKeyForSdk = publicKey || secretKey;
|
|
577
|
+
log(`
|
|
578
|
+
${colors.dim}\uC6A9\uB3C4\uB97C \uC120\uD0DD\uD558\uC138\uC694:${colors.reset}`);
|
|
579
|
+
log(` ${colors.cyan}1${colors.reset}) \uC6F9 \uBC30\uD3EC (\uC2A4\uD1A0\uB9AC\uC9C0 + \uBC30\uD3EC \uC124\uC815)`);
|
|
580
|
+
log(` ${colors.cyan}2${colors.reset}) \uD130\uB110 \uC804\uC6A9 (\uB85C\uCEEC \uC11C\uBE44\uC2A4 \uB178\uCD9C)`);
|
|
581
|
+
log(` ${colors.cyan}3${colors.reset}) SDK \uC5F0\uB3D9 (API Key\uB9CC)
|
|
582
|
+
`);
|
|
583
|
+
const useCase = await prompt(`${colors.blue}?${colors.reset} \uC120\uD0DD (1/2/3): `) || "1";
|
|
564
584
|
let storageId = "";
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
585
|
+
let deployDir = "";
|
|
586
|
+
if (useCase === "1") {
|
|
587
|
+
try {
|
|
588
|
+
info("\uC6F9 \uC2A4\uD1A0\uB9AC\uC9C0 \uC870\uD68C \uC911...");
|
|
589
|
+
const listRes = await makeRequest(
|
|
590
|
+
`${DEFAULT_BASE_URL}/v1/public/storages/webs`,
|
|
591
|
+
"GET",
|
|
592
|
+
{ "X-API-Key": apiKeyForSdk }
|
|
593
|
+
);
|
|
594
|
+
if (listRes.status === 200) {
|
|
595
|
+
const listData = listRes.data;
|
|
596
|
+
const storages = listData.storages || [];
|
|
597
|
+
if (storages.length > 0) {
|
|
598
|
+
log(`
|
|
577
599
|
${colors.dim}\uAE30\uC874 \uC6F9 \uC2A4\uD1A0\uB9AC\uC9C0:${colors.reset}`);
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
600
|
+
storages.forEach((s, i) => {
|
|
601
|
+
log(` ${colors.cyan}${i + 1}${colors.reset}) ${s.name} (${colors.dim}${s.id}${colors.reset})`);
|
|
602
|
+
});
|
|
603
|
+
log(` ${colors.cyan}0${colors.reset}) \uC0C8\uB85C \uC0DD\uC131`);
|
|
604
|
+
const choice = await prompt(`
|
|
583
605
|
${colors.blue}?${colors.reset} \uC120\uD0DD (\uBC88\uD638): `);
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
606
|
+
const num = parseInt(choice, 10);
|
|
607
|
+
if (num > 0 && num <= storages.length) {
|
|
608
|
+
storageId = storages[num - 1].id;
|
|
609
|
+
success(`\uC120\uD0DD\uB428: ${storages[num - 1].name}`);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
if (!storageId) {
|
|
613
|
+
const projectName = path.basename(cwd);
|
|
614
|
+
const name = await prompt(`${colors.blue}?${colors.reset} \uC2A4\uD1A0\uB9AC\uC9C0 \uC774\uB984 (${projectName}): `) || projectName;
|
|
615
|
+
info("\uC6F9 \uC2A4\uD1A0\uB9AC\uC9C0 \uC0DD\uC131 \uC911...");
|
|
616
|
+
const createRes = await makeRequest(
|
|
617
|
+
`${DEFAULT_BASE_URL}/v1/public/storages/webs`,
|
|
618
|
+
"POST",
|
|
619
|
+
{ "X-API-Key": apiKeyForSdk },
|
|
620
|
+
JSON.stringify({ name })
|
|
621
|
+
);
|
|
622
|
+
if (createRes.status !== 200) {
|
|
623
|
+
const data = createRes.data;
|
|
624
|
+
error(`\uC0DD\uC131 \uC2E4\uD328: ${data?.error || data?.message || `HTTP ${createRes.status}`}`);
|
|
625
|
+
process.exit(1);
|
|
626
|
+
}
|
|
627
|
+
const createData = createRes.data;
|
|
628
|
+
storageId = createData.storage_web_id;
|
|
629
|
+
success(`\uC6F9 \uC2A4\uD1A0\uB9AC\uC9C0 \uC0DD\uC131 \uC644\uB8CC: ${createData.name}`);
|
|
588
630
|
}
|
|
631
|
+
} else {
|
|
632
|
+
throw new Error(`HTTP ${listRes.status}`);
|
|
589
633
|
}
|
|
634
|
+
} catch (err) {
|
|
635
|
+
error(`\uB124\uD2B8\uC6CC\uD06C \uC624\uB958: ${err instanceof Error ? err.message : err}`);
|
|
636
|
+
log(`${colors.dim}\uC218\uB3D9\uC73C\uB85C Storage ID\uB97C \uC785\uB825\uD558\uC138\uC694${colors.reset}`);
|
|
637
|
+
storageId = await prompt(`${colors.blue}?${colors.reset} Storage ID: `);
|
|
590
638
|
if (!storageId) {
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
info("\uC6F9 \uC2A4\uD1A0\uB9AC\uC9C0 \uC0DD\uC131 \uC911...");
|
|
594
|
-
const createRes = await makeRequest(
|
|
595
|
-
`${DEFAULT_BASE_URL}/v1/public/storages/webs`,
|
|
596
|
-
"POST",
|
|
597
|
-
{ "X-API-Key": apiKeyForSdk },
|
|
598
|
-
JSON.stringify({ name })
|
|
599
|
-
);
|
|
600
|
-
if (createRes.status !== 200) {
|
|
601
|
-
const data = createRes.data;
|
|
602
|
-
error(`\uC0DD\uC131 \uC2E4\uD328: ${data?.error || data?.message || `HTTP ${createRes.status}`}`);
|
|
603
|
-
process.exit(1);
|
|
604
|
-
}
|
|
605
|
-
const createData = createRes.data;
|
|
606
|
-
storageId = createData.storage_web_id;
|
|
607
|
-
success(`\uC6F9 \uC2A4\uD1A0\uB9AC\uC9C0 \uC0DD\uC131 \uC644\uB8CC: ${createData.name}`);
|
|
639
|
+
error("Storage ID\uB294 \uD544\uC218\uC785\uB2C8\uB2E4");
|
|
640
|
+
process.exit(1);
|
|
608
641
|
}
|
|
609
|
-
} else {
|
|
610
|
-
throw new Error(`HTTP ${listRes.status}`);
|
|
611
|
-
}
|
|
612
|
-
} catch (err) {
|
|
613
|
-
error(`\uB124\uD2B8\uC6CC\uD06C \uC624\uB958: ${err instanceof Error ? err.message : err}`);
|
|
614
|
-
log(`${colors.dim}\uC218\uB3D9\uC73C\uB85C Storage ID\uB97C \uC785\uB825\uD558\uC138\uC694${colors.reset}`);
|
|
615
|
-
storageId = await prompt(`${colors.blue}?${colors.reset} Storage ID: `);
|
|
616
|
-
if (!storageId) {
|
|
617
|
-
error("Storage ID\uB294 \uD544\uC218\uC785\uB2C8\uB2E4");
|
|
618
|
-
process.exit(1);
|
|
619
642
|
}
|
|
643
|
+
const defaultDir = detectBuildDir();
|
|
644
|
+
deployDir = await prompt(`${colors.blue}?${colors.reset} \uBC30\uD3EC \uB514\uB809\uD1A0\uB9AC (${defaultDir}): `) || defaultDir;
|
|
620
645
|
}
|
|
621
|
-
const defaultDir = detectBuildDir();
|
|
622
|
-
const deployDir = await prompt(`${colors.blue}?${colors.reset} \uBC30\uD3EC \uB514\uB809\uD1A0\uB9AC (${defaultDir}): `) || defaultDir;
|
|
623
646
|
const config = {
|
|
624
|
-
apiKey: publicKey || ""
|
|
625
|
-
storageId,
|
|
626
|
-
deployDir
|
|
647
|
+
apiKey: useCase === "2" ? secretKey : publicKey || ""
|
|
627
648
|
};
|
|
649
|
+
if (storageId) config.storageId = storageId;
|
|
650
|
+
if (deployDir) config.deployDir = deployDir;
|
|
628
651
|
fs.writeFileSync(rcPath, JSON.stringify(config, null, 2) + "\n");
|
|
629
652
|
success(".connectbaserc \uC0DD\uC131 \uC644\uB8CC");
|
|
630
653
|
addToGitignore(".connectbaserc");
|
|
631
|
-
|
|
654
|
+
if (useCase === "1" && deployDir) {
|
|
655
|
+
addDeployScript(deployDir);
|
|
656
|
+
}
|
|
632
657
|
await setupClaudeCode(apiKeyForSdk, secretKey, projectRoot);
|
|
633
658
|
log(`
|
|
634
659
|
${colors.green}\uCD08\uAE30\uD654 \uC644\uB8CC!${colors.reset}
|
|
635
660
|
`);
|
|
636
|
-
|
|
637
|
-
|
|
661
|
+
if (useCase === "1") {
|
|
662
|
+
log(`${colors.dim}\uBC30\uD3EC\uD558\uB824\uBA74:${colors.reset}`);
|
|
663
|
+
log(` ${colors.cyan}npm run deploy${colors.reset}`);
|
|
664
|
+
} else if (useCase === "2") {
|
|
665
|
+
log(`${colors.dim}\uD130\uB110 \uC2DC\uC791\uD558\uB824\uBA74:${colors.reset}`);
|
|
666
|
+
log(` ${colors.cyan}npx connectbase tunnel <\uD3EC\uD2B8>${colors.reset}`);
|
|
667
|
+
} else {
|
|
668
|
+
log(`${colors.dim}SDK \uC0AC\uC6A9\uBC95:${colors.reset}`);
|
|
669
|
+
log(` ${colors.cyan}import ConnectBase from 'connectbase-client'${colors.reset}`);
|
|
670
|
+
}
|
|
638
671
|
log(`
|
|
639
672
|
${colors.dim}Claude Code\uC5D0\uC11C MCP\uAC00 \uC790\uB3D9 \uC5F0\uACB0\uB429\uB2C8\uB2E4${colors.reset}
|
|
640
673
|
`);
|
package/dist/index.d.mts
CHANGED
|
@@ -5441,6 +5441,7 @@ interface ListDocumentsResponse {
|
|
|
5441
5441
|
interface KnowledgeSearchRequest {
|
|
5442
5442
|
query: string;
|
|
5443
5443
|
top_k?: number;
|
|
5444
|
+
agentic?: boolean;
|
|
5444
5445
|
}
|
|
5445
5446
|
interface KnowledgeSearchResult {
|
|
5446
5447
|
chunk_id: string;
|
|
@@ -5591,6 +5592,7 @@ interface AIChatRequest {
|
|
|
5591
5592
|
appId?: string;
|
|
5592
5593
|
knowledgeBaseId?: string;
|
|
5593
5594
|
topK?: number;
|
|
5595
|
+
agentic?: boolean;
|
|
5594
5596
|
}
|
|
5595
5597
|
interface AISource {
|
|
5596
5598
|
chunkId: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -5441,6 +5441,7 @@ interface ListDocumentsResponse {
|
|
|
5441
5441
|
interface KnowledgeSearchRequest {
|
|
5442
5442
|
query: string;
|
|
5443
5443
|
top_k?: number;
|
|
5444
|
+
agentic?: boolean;
|
|
5444
5445
|
}
|
|
5445
5446
|
interface KnowledgeSearchResult {
|
|
5446
5447
|
chunk_id: string;
|
|
@@ -5591,6 +5592,7 @@ interface AIChatRequest {
|
|
|
5591
5592
|
appId?: string;
|
|
5592
5593
|
knowledgeBaseId?: string;
|
|
5593
5594
|
topK?: number;
|
|
5595
|
+
agentic?: boolean;
|
|
5594
5596
|
}
|
|
5595
5597
|
interface AISource {
|
|
5596
5598
|
chunkId: string;
|