@dotbots-boutique/auth-sdk 1.0.22 → 1.0.24
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/cjs/index.js +7 -45
- package/dist/esm/index.js +7 -45
- package/dist/types/DotBotsAuth.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +7 -45
- package/dist/types/types.d.ts +9 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -396,41 +396,9 @@ class DotBotsAuth {
|
|
|
396
396
|
}
|
|
397
397
|
async ai(feature, request, onDelta) {
|
|
398
398
|
this.assertInitialized();
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
return new Promise((resolve, reject) => {
|
|
402
|
-
this.aiStream(feature, request, onDelta, resolve).catch(reject);
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
const baseUrl = this.proxyConfigManager.getBaseUrl();
|
|
406
|
-
console.warn(`[DotBotsAuth] ai() — feature: ${feature}, messages: ${request.messages.length}`);
|
|
407
|
-
const response = await this.buildRequest(`${baseUrl}/ai/call`, {
|
|
408
|
-
method: 'POST',
|
|
409
|
-
headers: { 'Content-Type': 'application/json' },
|
|
410
|
-
body: JSON.stringify({
|
|
411
|
-
feature,
|
|
412
|
-
messages: request.messages,
|
|
413
|
-
tools: request.tools,
|
|
414
|
-
stream: false,
|
|
415
|
-
maxTokens: request.maxTokens,
|
|
416
|
-
}),
|
|
399
|
+
return new Promise((resolve, reject) => {
|
|
400
|
+
this.aiStream(feature, request, onDelta ?? (() => { }), resolve).catch(reject);
|
|
417
401
|
});
|
|
418
|
-
if (response.status === 402) {
|
|
419
|
-
console.error('[DotBotsAuth] ai() failed — 402: insufficient balance');
|
|
420
|
-
throw new DotBotsAuthError('AI_INSUFFICIENT_BALANCE', 'Insufficient balance for AI call');
|
|
421
|
-
}
|
|
422
|
-
if (response.status === 400) {
|
|
423
|
-
const body = await response.json();
|
|
424
|
-
console.error(`[DotBotsAuth] ai() failed — 400: ${body.error}`);
|
|
425
|
-
throw new DotBotsAuthError(body.error || 'AI_FEATURE_NOT_FOUND', body.message ?? 'AI request failed');
|
|
426
|
-
}
|
|
427
|
-
if (!response.ok) {
|
|
428
|
-
console.error(`[DotBotsAuth] ai() failed — HTTP ${response.status}`);
|
|
429
|
-
throw new DotBotsAuthError('AI_CALL_FAILED', `AI call failed: ${response.status}`);
|
|
430
|
-
}
|
|
431
|
-
const data = await response.json();
|
|
432
|
-
console.warn(`[DotBotsAuth] ai() success — model: ${data.model}, tokens: ${data.usage.totalTokens}, transactionId: ${data.transactionId}`);
|
|
433
|
-
return data;
|
|
434
402
|
}
|
|
435
403
|
async aiStream(feature, request, onDelta, onDone) {
|
|
436
404
|
this.assertInitialized();
|
|
@@ -474,17 +442,11 @@ class DotBotsAuth {
|
|
|
474
442
|
onDelta(data.delta);
|
|
475
443
|
}
|
|
476
444
|
else if (data.type === 'done') {
|
|
477
|
-
const finalResponse = {
|
|
478
|
-
content: '',
|
|
479
|
-
model: data.model,
|
|
480
|
-
provider: data.provider,
|
|
481
|
-
usage: data.usage,
|
|
482
|
-
cost: data.cost,
|
|
483
|
-
transactionId: data.transactionId,
|
|
484
|
-
toolCalls: data.toolCalls,
|
|
485
|
-
};
|
|
486
445
|
console.warn(`[DotBotsAuth] aiStream() done — model: ${data.model}, tokens: ${data.usage.totalTokens}, transactionId: ${data.transactionId}`);
|
|
487
|
-
onDone?.(
|
|
446
|
+
onDone?.(data);
|
|
447
|
+
}
|
|
448
|
+
else if (data.type === 'error') {
|
|
449
|
+
throw new DotBotsAuthError(data.error ?? 'AI_CALL_FAILED', data.message ?? 'AI call failed');
|
|
488
450
|
}
|
|
489
451
|
}
|
|
490
452
|
}
|
|
@@ -618,7 +580,7 @@ class DotBotsAuth {
|
|
|
618
580
|
}
|
|
619
581
|
}
|
|
620
582
|
}
|
|
621
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
583
|
+
DotBotsAuth.SDK_VERSION = '1.0.24';
|
|
622
584
|
|
|
623
585
|
exports.DotBotsAuth = DotBotsAuth;
|
|
624
586
|
exports.DotBotsAuthError = DotBotsAuthError;
|
package/dist/esm/index.js
CHANGED
|
@@ -394,41 +394,9 @@ class DotBotsAuth {
|
|
|
394
394
|
}
|
|
395
395
|
async ai(feature, request, onDelta) {
|
|
396
396
|
this.assertInitialized();
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
return new Promise((resolve, reject) => {
|
|
400
|
-
this.aiStream(feature, request, onDelta, resolve).catch(reject);
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
const baseUrl = this.proxyConfigManager.getBaseUrl();
|
|
404
|
-
console.warn(`[DotBotsAuth] ai() — feature: ${feature}, messages: ${request.messages.length}`);
|
|
405
|
-
const response = await this.buildRequest(`${baseUrl}/ai/call`, {
|
|
406
|
-
method: 'POST',
|
|
407
|
-
headers: { 'Content-Type': 'application/json' },
|
|
408
|
-
body: JSON.stringify({
|
|
409
|
-
feature,
|
|
410
|
-
messages: request.messages,
|
|
411
|
-
tools: request.tools,
|
|
412
|
-
stream: false,
|
|
413
|
-
maxTokens: request.maxTokens,
|
|
414
|
-
}),
|
|
397
|
+
return new Promise((resolve, reject) => {
|
|
398
|
+
this.aiStream(feature, request, onDelta ?? (() => { }), resolve).catch(reject);
|
|
415
399
|
});
|
|
416
|
-
if (response.status === 402) {
|
|
417
|
-
console.error('[DotBotsAuth] ai() failed — 402: insufficient balance');
|
|
418
|
-
throw new DotBotsAuthError('AI_INSUFFICIENT_BALANCE', 'Insufficient balance for AI call');
|
|
419
|
-
}
|
|
420
|
-
if (response.status === 400) {
|
|
421
|
-
const body = await response.json();
|
|
422
|
-
console.error(`[DotBotsAuth] ai() failed — 400: ${body.error}`);
|
|
423
|
-
throw new DotBotsAuthError(body.error || 'AI_FEATURE_NOT_FOUND', body.message ?? 'AI request failed');
|
|
424
|
-
}
|
|
425
|
-
if (!response.ok) {
|
|
426
|
-
console.error(`[DotBotsAuth] ai() failed — HTTP ${response.status}`);
|
|
427
|
-
throw new DotBotsAuthError('AI_CALL_FAILED', `AI call failed: ${response.status}`);
|
|
428
|
-
}
|
|
429
|
-
const data = await response.json();
|
|
430
|
-
console.warn(`[DotBotsAuth] ai() success — model: ${data.model}, tokens: ${data.usage.totalTokens}, transactionId: ${data.transactionId}`);
|
|
431
|
-
return data;
|
|
432
400
|
}
|
|
433
401
|
async aiStream(feature, request, onDelta, onDone) {
|
|
434
402
|
this.assertInitialized();
|
|
@@ -472,17 +440,11 @@ class DotBotsAuth {
|
|
|
472
440
|
onDelta(data.delta);
|
|
473
441
|
}
|
|
474
442
|
else if (data.type === 'done') {
|
|
475
|
-
const finalResponse = {
|
|
476
|
-
content: '',
|
|
477
|
-
model: data.model,
|
|
478
|
-
provider: data.provider,
|
|
479
|
-
usage: data.usage,
|
|
480
|
-
cost: data.cost,
|
|
481
|
-
transactionId: data.transactionId,
|
|
482
|
-
toolCalls: data.toolCalls,
|
|
483
|
-
};
|
|
484
443
|
console.warn(`[DotBotsAuth] aiStream() done — model: ${data.model}, tokens: ${data.usage.totalTokens}, transactionId: ${data.transactionId}`);
|
|
485
|
-
onDone?.(
|
|
444
|
+
onDone?.(data);
|
|
445
|
+
}
|
|
446
|
+
else if (data.type === 'error') {
|
|
447
|
+
throw new DotBotsAuthError(data.error ?? 'AI_CALL_FAILED', data.message ?? 'AI call failed');
|
|
486
448
|
}
|
|
487
449
|
}
|
|
488
450
|
}
|
|
@@ -616,6 +578,6 @@ class DotBotsAuth {
|
|
|
616
578
|
}
|
|
617
579
|
}
|
|
618
580
|
}
|
|
619
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
581
|
+
DotBotsAuth.SDK_VERSION = '1.0.24';
|
|
620
582
|
|
|
621
583
|
export { DotBotsAuth, DotBotsAuthError };
|
|
@@ -11,7 +11,7 @@ export declare class DotBotsAuth {
|
|
|
11
11
|
private initialized;
|
|
12
12
|
private initializePromise;
|
|
13
13
|
private readonly _console;
|
|
14
|
-
static readonly SDK_VERSION = "1.0.
|
|
14
|
+
static readonly SDK_VERSION = "1.0.24";
|
|
15
15
|
constructor(config: DotBotsConfig);
|
|
16
16
|
initialize(): Promise<void>;
|
|
17
17
|
private _doInitialize;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { DotBotsAuth } from './DotBotsAuth.js';
|
|
2
2
|
export { DotBotsAuthError } from './DotBotsAuthError.js';
|
|
3
|
-
export type { DotBotsConfig, DotBotsUser, DotBotsAuthEvent, DotBotsAuthErrorCode, DotBotsProxyConfig, ProxyFeature, DotBotsEnvironment, AiMessage, AiContentBlock, AiTool, AiRequest, AiResponse, AiToolCall, } from './types.js';
|
|
3
|
+
export type { DotBotsConfig, DotBotsUser, DotBotsAuthEvent, DotBotsAuthErrorCode, DotBotsProxyConfig, ProxyFeature, DotBotsEnvironment, AiMessage, AiContentBlock, AiTool, AiRequest, AiResponse, AiImage, AiToolCall, } from './types.js';
|
package/dist/types/index.js
CHANGED
|
@@ -394,41 +394,9 @@ class DotBotsAuth {
|
|
|
394
394
|
}
|
|
395
395
|
async ai(feature, request, onDelta) {
|
|
396
396
|
this.assertInitialized();
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
return new Promise((resolve, reject) => {
|
|
400
|
-
this.aiStream(feature, request, onDelta, resolve).catch(reject);
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
const baseUrl = this.proxyConfigManager.getBaseUrl();
|
|
404
|
-
console.warn(`[DotBotsAuth] ai() — feature: ${feature}, messages: ${request.messages.length}`);
|
|
405
|
-
const response = await this.buildRequest(`${baseUrl}/ai/call`, {
|
|
406
|
-
method: 'POST',
|
|
407
|
-
headers: { 'Content-Type': 'application/json' },
|
|
408
|
-
body: JSON.stringify({
|
|
409
|
-
feature,
|
|
410
|
-
messages: request.messages,
|
|
411
|
-
tools: request.tools,
|
|
412
|
-
stream: false,
|
|
413
|
-
maxTokens: request.maxTokens,
|
|
414
|
-
}),
|
|
397
|
+
return new Promise((resolve, reject) => {
|
|
398
|
+
this.aiStream(feature, request, onDelta ?? (() => { }), resolve).catch(reject);
|
|
415
399
|
});
|
|
416
|
-
if (response.status === 402) {
|
|
417
|
-
console.error('[DotBotsAuth] ai() failed — 402: insufficient balance');
|
|
418
|
-
throw new DotBotsAuthError('AI_INSUFFICIENT_BALANCE', 'Insufficient balance for AI call');
|
|
419
|
-
}
|
|
420
|
-
if (response.status === 400) {
|
|
421
|
-
const body = await response.json();
|
|
422
|
-
console.error(`[DotBotsAuth] ai() failed — 400: ${body.error}`);
|
|
423
|
-
throw new DotBotsAuthError(body.error || 'AI_FEATURE_NOT_FOUND', body.message ?? 'AI request failed');
|
|
424
|
-
}
|
|
425
|
-
if (!response.ok) {
|
|
426
|
-
console.error(`[DotBotsAuth] ai() failed — HTTP ${response.status}`);
|
|
427
|
-
throw new DotBotsAuthError('AI_CALL_FAILED', `AI call failed: ${response.status}`);
|
|
428
|
-
}
|
|
429
|
-
const data = await response.json();
|
|
430
|
-
console.warn(`[DotBotsAuth] ai() success — model: ${data.model}, tokens: ${data.usage.totalTokens}, transactionId: ${data.transactionId}`);
|
|
431
|
-
return data;
|
|
432
400
|
}
|
|
433
401
|
async aiStream(feature, request, onDelta, onDone) {
|
|
434
402
|
this.assertInitialized();
|
|
@@ -472,17 +440,11 @@ class DotBotsAuth {
|
|
|
472
440
|
onDelta(data.delta);
|
|
473
441
|
}
|
|
474
442
|
else if (data.type === 'done') {
|
|
475
|
-
const finalResponse = {
|
|
476
|
-
content: '',
|
|
477
|
-
model: data.model,
|
|
478
|
-
provider: data.provider,
|
|
479
|
-
usage: data.usage,
|
|
480
|
-
cost: data.cost,
|
|
481
|
-
transactionId: data.transactionId,
|
|
482
|
-
toolCalls: data.toolCalls,
|
|
483
|
-
};
|
|
484
443
|
console.warn(`[DotBotsAuth] aiStream() done — model: ${data.model}, tokens: ${data.usage.totalTokens}, transactionId: ${data.transactionId}`);
|
|
485
|
-
onDone?.(
|
|
444
|
+
onDone?.(data);
|
|
445
|
+
}
|
|
446
|
+
else if (data.type === 'error') {
|
|
447
|
+
throw new DotBotsAuthError(data.error ?? 'AI_CALL_FAILED', data.message ?? 'AI call failed');
|
|
486
448
|
}
|
|
487
449
|
}
|
|
488
450
|
}
|
|
@@ -616,6 +578,6 @@ class DotBotsAuth {
|
|
|
616
578
|
}
|
|
617
579
|
}
|
|
618
580
|
}
|
|
619
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
581
|
+
DotBotsAuth.SDK_VERSION = '1.0.24';
|
|
620
582
|
|
|
621
583
|
export { DotBotsAuth, DotBotsAuthError };
|
package/dist/types/types.d.ts
CHANGED
|
@@ -69,8 +69,17 @@ export interface AiRequest {
|
|
|
69
69
|
tools?: AiTool[];
|
|
70
70
|
maxTokens?: number;
|
|
71
71
|
}
|
|
72
|
+
export interface AiImage {
|
|
73
|
+
mimeType: string;
|
|
74
|
+
data: string;
|
|
75
|
+
url: string;
|
|
76
|
+
}
|
|
72
77
|
export interface AiResponse {
|
|
73
78
|
content: string;
|
|
79
|
+
images?: AiImage[];
|
|
80
|
+
imageUrl?: string;
|
|
81
|
+
image_url?: string;
|
|
82
|
+
image?: AiImage;
|
|
74
83
|
model: string;
|
|
75
84
|
provider: string;
|
|
76
85
|
usage: {
|