oblien 1.1.1 → 1.1.2
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/README.md +8 -9
- package/index.d.ts +12 -3
- package/package.json +1 -1
- package/src/chat/index.js +9 -1
- package/src/chat/session.js +3 -0
- package/src/client.js +8 -10
package/README.md
CHANGED
|
@@ -25,9 +25,8 @@ import { OblienCredits } from 'oblien/credits';
|
|
|
25
25
|
|
|
26
26
|
// Initialize client
|
|
27
27
|
const client = new OblienClient({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
baseURL: 'https://api.oblien.com' // Optional
|
|
28
|
+
clientId: 'your-client-id',
|
|
29
|
+
clientSecret: 'your-client-secret'
|
|
31
30
|
});
|
|
32
31
|
|
|
33
32
|
// Use modules
|
|
@@ -284,8 +283,8 @@ import { OblienSandboxes } from 'oblien/sandbox';
|
|
|
284
283
|
|
|
285
284
|
// Initialize
|
|
286
285
|
const client = new OblienClient({
|
|
287
|
-
|
|
288
|
-
|
|
286
|
+
clientId: 'your-client-id',
|
|
287
|
+
clientSecret: 'your-client-secret'
|
|
289
288
|
});
|
|
290
289
|
|
|
291
290
|
const agents = new OblienAgents(client);
|
|
@@ -384,8 +383,8 @@ All modules use client credentials authentication:
|
|
|
384
383
|
|
|
385
384
|
```javascript
|
|
386
385
|
const client = new OblienClient({
|
|
387
|
-
|
|
388
|
-
|
|
386
|
+
clientId: 'your-client-id', // X-Client-ID header
|
|
387
|
+
clientSecret: 'your-client-secret' // X-Client-Secret header
|
|
389
388
|
});
|
|
390
389
|
```
|
|
391
390
|
|
|
@@ -409,8 +408,8 @@ import {
|
|
|
409
408
|
} from 'oblien';
|
|
410
409
|
|
|
411
410
|
const client: OblienClient = new OblienClient({
|
|
412
|
-
|
|
413
|
-
|
|
411
|
+
clientId: string,
|
|
412
|
+
clientSecret: string
|
|
414
413
|
});
|
|
415
414
|
```
|
|
416
415
|
|
package/index.d.ts
CHANGED
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
// ============ Client Types ============
|
|
6
6
|
|
|
7
7
|
export interface OblienConfig {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
clientId: string;
|
|
9
|
+
clientSecret: string;
|
|
10
10
|
baseURL?: string;
|
|
11
|
-
version?: string;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export class OblienClient {
|
|
@@ -101,6 +100,10 @@ export interface SessionOptions {
|
|
|
101
100
|
isGuest?: boolean;
|
|
102
101
|
namespace?: string;
|
|
103
102
|
workspace?: Record<string, any>;
|
|
103
|
+
ipAddress?: string;
|
|
104
|
+
userAgent?: string;
|
|
105
|
+
fingerprint?: string;
|
|
106
|
+
endUserId?: string;
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
export interface SessionData {
|
|
@@ -136,6 +139,11 @@ export interface CreateSessionOptions {
|
|
|
136
139
|
workflowId?: string;
|
|
137
140
|
namespace?: string; // For authenticated users, typically user_id
|
|
138
141
|
workspace?: Record<string, any>;
|
|
142
|
+
endUserId?: string;
|
|
143
|
+
isGuest?: boolean;
|
|
144
|
+
ipAddress?: string;
|
|
145
|
+
userAgent?: string;
|
|
146
|
+
fingerprint?: string;
|
|
139
147
|
}
|
|
140
148
|
|
|
141
149
|
export interface CreateGuestSessionOptions {
|
|
@@ -145,6 +153,7 @@ export interface CreateGuestSessionOptions {
|
|
|
145
153
|
workflowId?: string;
|
|
146
154
|
metadata?: Record<string, any>;
|
|
147
155
|
workspace?: Record<string, any>;
|
|
156
|
+
endUserId?: string;
|
|
148
157
|
}
|
|
149
158
|
|
|
150
159
|
export interface GuestSessionData extends SessionData {
|
package/package.json
CHANGED
package/src/chat/index.js
CHANGED
|
@@ -34,6 +34,12 @@ export class OblienChat {
|
|
|
34
34
|
* @param {string} options.agentId - Agent ID to chat with
|
|
35
35
|
* @param {string} [options.workflowId] - Workflow ID (if using workflow)
|
|
36
36
|
* @param {Object} [options.workspace] - Workspace configuration
|
|
37
|
+
* @param {string} [options.endUserId] - End user ID (for client's end users)
|
|
38
|
+
* @param {string} [options.namespace] - Guest namespace for rate limiting
|
|
39
|
+
* @param {boolean} [options.isGuest] - Is this a guest session
|
|
40
|
+
* @param {string} [options.ipAddress] - IP address of the user
|
|
41
|
+
* @param {string} [options.userAgent] - User agent of the user
|
|
42
|
+
* @param {string} [options.fingerprint] - Fingerprint of the user
|
|
37
43
|
* @returns {Promise<Object>} Session data with token
|
|
38
44
|
*/
|
|
39
45
|
async createSession(options) {
|
|
@@ -54,10 +60,11 @@ export class OblienChat {
|
|
|
54
60
|
* @param {string} [options.workflowId] - Workflow ID
|
|
55
61
|
* @param {Object} [options.metadata] - Additional guest metadata
|
|
56
62
|
* @param {Object} [options.workspace] - Workspace configuration
|
|
63
|
+
* @param {string} [options.endUserId] - End user ID (for client's end users)
|
|
57
64
|
* @returns {Promise<Object>} Session data with token and guest info
|
|
58
65
|
*/
|
|
59
66
|
async createGuestSession(options) {
|
|
60
|
-
const { ip, fingerprint, agentId, workflowId, metadata = {}, workspace } = options;
|
|
67
|
+
const { ip, fingerprint, agentId, workflowId, metadata = {}, workspace, endUserId } = options;
|
|
61
68
|
|
|
62
69
|
if (!ip) {
|
|
63
70
|
throw new Error('IP address is required for guest sessions');
|
|
@@ -81,6 +88,7 @@ export class OblienChat {
|
|
|
81
88
|
ipAddress: ip,
|
|
82
89
|
userAgent: metadata.userAgent,
|
|
83
90
|
fingerprint: fingerprint,
|
|
91
|
+
endUserId: endUserId,
|
|
84
92
|
});
|
|
85
93
|
|
|
86
94
|
const sessionData = await session.create();
|
package/src/chat/session.js
CHANGED
|
@@ -16,6 +16,7 @@ export class ChatSession {
|
|
|
16
16
|
* @param {string} [options.ipAddress] - IP address of the user
|
|
17
17
|
* @param {string} [options.userAgent] - User agent of the user
|
|
18
18
|
* @param {string} [options.fingerprint] - Fingerprint of the user
|
|
19
|
+
* @param {string} [options.endUserId] - End user ID (for client's end users)
|
|
19
20
|
*/
|
|
20
21
|
constructor(options) {
|
|
21
22
|
if (!options.client) {
|
|
@@ -38,6 +39,7 @@ export class ChatSession {
|
|
|
38
39
|
this.ipAddress = options.ipAddress || null;
|
|
39
40
|
this.userAgent = options.userAgent || null;
|
|
40
41
|
this.fingerprint = options.fingerprint || null;
|
|
42
|
+
this.endUserId = options.endUserId || null;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
/**
|
|
@@ -54,6 +56,7 @@ export class ChatSession {
|
|
|
54
56
|
ip_address: this.ipAddress,
|
|
55
57
|
user_agent: this.userAgent,
|
|
56
58
|
fingerprint: this.fingerprint,
|
|
59
|
+
end_user_id: this.endUserId,
|
|
57
60
|
};
|
|
58
61
|
|
|
59
62
|
this.data = await this.client.post('ai/session/create', payload);
|
package/src/client.js
CHANGED
|
@@ -6,21 +6,19 @@
|
|
|
6
6
|
export class OblienClient {
|
|
7
7
|
/**
|
|
8
8
|
* @param {Object} config - Configuration options
|
|
9
|
-
* @param {string} config.
|
|
10
|
-
* @param {string} config.
|
|
11
|
-
* @param {string} [config.baseURL] - Base URL for API (default: https://api.oblien.com)
|
|
12
|
-
* @param {string} [config.version] - API version (default: v1)
|
|
9
|
+
* @param {string} config.clientId - Your Oblien Client ID (x-client-id)
|
|
10
|
+
* @param {string} config.clientSecret - Your Oblien Client Secret (x-client-secret)
|
|
13
11
|
*/
|
|
14
12
|
constructor(config) {
|
|
15
|
-
if (!config || !config.
|
|
16
|
-
throw new Error('Oblien
|
|
13
|
+
if (!config || !config.clientId) {
|
|
14
|
+
throw new Error('Oblien client ID is required');
|
|
17
15
|
}
|
|
18
|
-
if (!config.
|
|
19
|
-
throw new Error('Oblien
|
|
16
|
+
if (!config.clientSecret) {
|
|
17
|
+
throw new Error('Oblien client secret is required');
|
|
20
18
|
}
|
|
21
19
|
|
|
22
|
-
this.clientId = config.
|
|
23
|
-
this.clientSecret = config.
|
|
20
|
+
this.clientId = config.clientId;
|
|
21
|
+
this.clientSecret = config.clientSecret;
|
|
24
22
|
this.baseURL = config.baseURL || 'https://api.oblien.com';
|
|
25
23
|
}
|
|
26
24
|
|