oblien 1.2.0 → 1.2.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/index.d.ts +9 -1
- package/package.json +1 -1
- package/src/chat/index.js +4 -2
package/index.d.ts
CHANGED
|
@@ -60,6 +60,14 @@ export class RedisStorage implements StorageAdapter {
|
|
|
60
60
|
|
|
61
61
|
// ============ Guest Manager ============
|
|
62
62
|
|
|
63
|
+
export interface GuestOptions {
|
|
64
|
+
ip?: string;
|
|
65
|
+
fingerprint?: string;
|
|
66
|
+
namespace?: string;
|
|
67
|
+
agentId?: string;
|
|
68
|
+
sessionId?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
63
71
|
export interface GuestManagerOptions {
|
|
64
72
|
storage?: StorageAdapter;
|
|
65
73
|
ttl?: number;
|
|
@@ -95,7 +103,7 @@ export class GuestManager {
|
|
|
95
103
|
|
|
96
104
|
generateGuestId(ip: string): string;
|
|
97
105
|
getOrCreateGuest(ip: string, metadata?: Record<string, any>): Promise<Guest>;
|
|
98
|
-
getGuest(guestId: string): Promise<Guest | null>;
|
|
106
|
+
getGuest(guestId: string | GuestOptions): Promise<Guest | null>;
|
|
99
107
|
updateGuest(guestId: string, updates: Partial<Guest>): Promise<Guest>;
|
|
100
108
|
addSession(guestId: string, sessionId: string): Promise<Guest>;
|
|
101
109
|
deleteGuest(guestId: string): Promise<boolean>;
|
package/package.json
CHANGED
package/src/chat/index.js
CHANGED
|
@@ -131,7 +131,7 @@ export class OblienChat {
|
|
|
131
131
|
userAgent: metadata.userAgent,
|
|
132
132
|
guestNamespace: guest.namespace,
|
|
133
133
|
fingerprint: fingerprint,
|
|
134
|
-
endUserId: endUserId, // Optional: Your end user identifier
|
|
134
|
+
endUserId: endUserId || guest.id, // Optional: Your end user identifier
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
// Link session to guest
|
|
@@ -176,6 +176,8 @@ export class OblienChat {
|
|
|
176
176
|
const agentId = options.agentId || options.agent_id;
|
|
177
177
|
const sessionId = options.sessionId || options.session_id;
|
|
178
178
|
const guestId = options.guestId || options.namespace;
|
|
179
|
+
const ip = options.ip;
|
|
180
|
+
const fingerprint = options.fingerprint;
|
|
179
181
|
|
|
180
182
|
if (!agentId && !sessionId && !guestId) {
|
|
181
183
|
throw new Error('Either agentId, sessionId, or guestId is required');
|
|
@@ -185,7 +187,7 @@ export class OblienChat {
|
|
|
185
187
|
const response = await this.client.post(`ai/guest/info`, {
|
|
186
188
|
ip,
|
|
187
189
|
fingerprint,
|
|
188
|
-
namespace:
|
|
190
|
+
namespace: guestId,
|
|
189
191
|
agent_id: agentId,
|
|
190
192
|
session_id: sessionId,
|
|
191
193
|
});
|