connectbase-client 0.10.6 → 0.10.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 +22 -9
- 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
|
`);
|
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;
|