oblien 1.0.7 → 1.1.1

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/agents.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Agents Module Entry Point
3
+ * Import this for AI agents management only
4
+ */
5
+
6
+ export { OblienAgents, Agent, AgentSettings, Tools } from './src/agents/index.js';
7
+
8
+ export default {
9
+ OblienAgents,
10
+ Agent,
11
+ AgentSettings,
12
+ Tools
13
+ };
14
+
package/credits.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Credits Module Entry Point
3
+ * Import this for credits management only
4
+ */
5
+
6
+ export { OblienCredits } from './src/credits/index.js';
7
+
8
+ export default {
9
+ OblienCredits
10
+ };
11
+
package/icons.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Icons Module Entry Point
3
+ * Import this for icons functionality only
4
+ */
5
+
6
+ export { OblienIcons } from './src/icons/index.js';
7
+
8
+ export default {
9
+ OblienIcons
10
+ };
11
+
package/index.d.ts CHANGED
@@ -19,6 +19,7 @@ export class OblienClient {
19
19
  get(path: string, params?: Record<string, any>): Promise<any>;
20
20
  post(path: string, body?: Record<string, any>): Promise<any>;
21
21
  put(path: string, body?: Record<string, any>): Promise<any>;
22
+ patch(path: string, body?: Record<string, any>): Promise<any>;
22
23
  delete(path: string): Promise<any>;
23
24
  }
24
25
 
@@ -167,12 +168,272 @@ export class OblienChat {
167
168
  cleanupGuests(): Promise<number>;
168
169
  }
169
170
 
171
+ // ============ Namespaces ============
172
+
173
+ export interface NamespaceData {
174
+ id: string;
175
+ client_id: string;
176
+ name: string;
177
+ slug: string;
178
+ description?: string;
179
+ end_user_id?: string;
180
+ fingerprint?: string;
181
+ ip_address?: string;
182
+ user_agent?: string;
183
+ country?: string;
184
+ status: 'active' | 'inactive' | 'suspended' | 'archived';
185
+ type: string;
186
+ is_default: boolean;
187
+ metadata?: Record<string, any>;
188
+ tags?: string[];
189
+ created_at: string;
190
+ updated_at: string;
191
+ last_active_at?: string;
192
+ archived_at?: string;
193
+ }
194
+
195
+ export interface CreateNamespaceOptions {
196
+ name: string;
197
+ slug?: string;
198
+ description?: string;
199
+ type?: 'default' | 'production' | 'testing' | 'development';
200
+ isDefault?: boolean;
201
+ metadata?: Record<string, any>;
202
+ tags?: string[];
203
+ endUserId?: string;
204
+ }
205
+
206
+ export interface UpdateNamespaceOptions {
207
+ name?: string;
208
+ description?: string;
209
+ status?: 'active' | 'inactive' | 'suspended' | 'archived';
210
+ type?: string;
211
+ metadata?: Record<string, any>;
212
+ tags?: string[];
213
+ }
214
+
215
+ export interface ListNamespacesOptions {
216
+ limit?: number;
217
+ offset?: number;
218
+ status?: 'active' | 'inactive' | 'suspended' | 'archived';
219
+ type?: string;
220
+ search?: string;
221
+ sortBy?: 'name' | 'created_at' | 'updated_at' | 'last_active_at';
222
+ sortOrder?: 'ASC' | 'DESC';
223
+ }
224
+
225
+ export interface ServiceConfig {
226
+ id: number;
227
+ namespace_id: string;
228
+ service: string;
229
+ enabled: boolean;
230
+ config?: Record<string, any>;
231
+ rate_limit_requests?: number;
232
+ rate_limit_period?: string;
233
+ features?: string[];
234
+ created_at: string;
235
+ updated_at: string;
236
+ }
237
+
238
+ export interface ConfigureServiceOptions {
239
+ service: string;
240
+ enabled?: boolean;
241
+ config?: Record<string, any>;
242
+ rateLimitRequests?: number;
243
+ rateLimitPeriod?: 'minute' | 'hour' | 'day';
244
+ features?: string[];
245
+ }
246
+
247
+ export interface NamespaceUsage {
248
+ usage: Array<{
249
+ service: string;
250
+ date: string;
251
+ requests: number;
252
+ credits: number;
253
+ deductions: number;
254
+ }>;
255
+ summary: Array<{
256
+ service: string;
257
+ total_requests: number;
258
+ total_credits: number;
259
+ first_used: string;
260
+ last_used: string;
261
+ }>;
262
+ quotas: Array<any>;
263
+ active_sessions: number;
264
+ }
265
+
266
+ export class Namespace {
267
+ constructor(options: { client: OblienClient; namespaceId?: string; data?: NamespaceData });
268
+
269
+ namespaceId: string | null;
270
+ data: NamespaceData | null;
271
+
272
+ create(options: CreateNamespaceOptions): Promise<NamespaceData>;
273
+ get(identifier?: string): Promise<NamespaceData>;
274
+ update(updates: UpdateNamespaceOptions, namespaceId?: string): Promise<NamespaceData>;
275
+ delete(namespaceId?: string): Promise<any>;
276
+ getActivity(options?: { limit?: number; offset?: number }, namespaceId?: string): Promise<any[]>;
277
+ getUsage(options?: { service?: string; days?: number }, namespaceId?: string): Promise<NamespaceUsage>;
278
+ configureService(options: ConfigureServiceOptions, namespaceId?: string): Promise<ServiceConfig>;
279
+ listServices(namespaceId?: string): Promise<ServiceConfig[]>;
280
+ getServiceConfig(service: string, namespaceId?: string): Promise<ServiceConfig>;
281
+ toggleService(service: string, enabled: boolean, namespaceId?: string): Promise<ServiceConfig>;
282
+ deleteService(service: string, namespaceId?: string): Promise<any>;
283
+ bulkConfigureServices(services: ConfigureServiceOptions[], namespaceId?: string): Promise<ServiceConfig[]>;
284
+ }
285
+
286
+ export class OblienNamespaces {
287
+ constructor(client: OblienClient);
288
+
289
+ create(options: CreateNamespaceOptions): Promise<NamespaceData>;
290
+ get(identifier: string): Promise<NamespaceData>;
291
+ list(options?: ListNamespacesOptions): Promise<{ success: boolean; data: NamespaceData[]; pagination: any }>;
292
+ update(namespaceId: string, updates: UpdateNamespaceOptions): Promise<NamespaceData>;
293
+ delete(namespaceId: string): Promise<any>;
294
+ getActivity(namespaceId: string, options?: { limit?: number; offset?: number }): Promise<any[]>;
295
+ getUsage(namespaceId: string, options?: { service?: string; days?: number }): Promise<NamespaceUsage>;
296
+ getAvailableServices(): Promise<any[]>;
297
+ configureService(namespaceId: string, options: ConfigureServiceOptions): Promise<ServiceConfig>;
298
+ listServices(namespaceId: string): Promise<ServiceConfig[]>;
299
+ getServiceConfig(namespaceId: string, service: string): Promise<ServiceConfig>;
300
+ toggleService(namespaceId: string, service: string, enabled: boolean): Promise<ServiceConfig>;
301
+ enableService(namespaceId: string, service: string): Promise<ServiceConfig>;
302
+ disableService(namespaceId: string, service: string): Promise<ServiceConfig>;
303
+ deleteService(namespaceId: string, service: string): Promise<any>;
304
+ bulkConfigureServices(namespaceId: string, services: ConfigureServiceOptions[]): Promise<ServiceConfig[]>;
305
+ namespace(namespaceId?: string): Namespace;
306
+ }
307
+
308
+ // ============ Credits ============
309
+
310
+ export interface QuotaData {
311
+ id: number;
312
+ client_id: string;
313
+ namespace: string;
314
+ service: string;
315
+ quota_limit: number | null;
316
+ quota_used: number;
317
+ period: string;
318
+ period_start?: string;
319
+ period_end?: string;
320
+ enabled: boolean;
321
+ created_at: string;
322
+ updated_at: string;
323
+ }
324
+
325
+ export interface CreditTransaction {
326
+ id: number;
327
+ client_id: string;
328
+ namespace: string;
329
+ end_user_id?: string;
330
+ amount: number;
331
+ client_balance_after: number;
332
+ namespace_quota_used?: number;
333
+ type: 'deduction' | 'addition' | 'refund' | 'adjustment';
334
+ service?: string;
335
+ description?: string;
336
+ metadata?: Record<string, any>;
337
+ created_at: string;
338
+ }
339
+
340
+ export interface SetQuotaOptions {
341
+ namespace: string;
342
+ service: string;
343
+ quotaLimit: number;
344
+ period?: 'daily' | 'monthly' | 'unlimited';
345
+ }
346
+
347
+ export interface HistoryOptions {
348
+ namespace?: string;
349
+ endUserId?: string;
350
+ service?: string;
351
+ type?: 'deduction' | 'addition' | 'refund' | 'adjustment';
352
+ startDate?: string;
353
+ endDate?: string;
354
+ limit?: number;
355
+ offset?: number;
356
+ after?: string;
357
+ afterId?: number;
358
+ }
359
+
360
+ export interface SummaryOptions {
361
+ namespace?: string;
362
+ days?: number;
363
+ limit?: number;
364
+ offset?: number;
365
+ after?: number;
366
+ }
367
+
368
+ export interface CreditPackage {
369
+ id: string;
370
+ name: string;
371
+ credits: number;
372
+ price: number;
373
+ currency: string;
374
+ active: boolean;
375
+ }
376
+
377
+ export interface CalculateCostOptions {
378
+ packageId?: string;
379
+ amount?: number;
380
+ credits?: number;
381
+ }
382
+
383
+ export interface PurchaseOptions {
384
+ packageId?: string;
385
+ amount?: number;
386
+ metadata?: Record<string, any>;
387
+ }
388
+
389
+ export interface PurchaseHistoryOptions {
390
+ limit?: number;
391
+ offset?: number;
392
+ light?: boolean;
393
+ }
394
+
395
+ export class OblienCredits {
396
+ constructor(client: OblienClient);
397
+
398
+ // Balance Management
399
+ getBalance(): Promise<number>;
400
+ addCredits(amount: number, reason?: string, metadata?: Record<string, any>): Promise<any>;
401
+
402
+ // Quota Management
403
+ getNamespaceQuotas(options?: { limit?: number; offset?: number; after?: string; search?: string; status?: string }): Promise<any>;
404
+ getNamespaceDetails(namespace: string, options?: { days?: number }): Promise<any>;
405
+ setQuota(options: SetQuotaOptions): Promise<QuotaData>;
406
+ resetQuota(namespace: string, service: string): Promise<any>;
407
+
408
+ // Usage History & Transactions
409
+ getHistory(options?: HistoryOptions): Promise<{ success: boolean; data: CreditTransaction[]; pagination: any }>;
410
+ getHistoryFilters(): Promise<{ namespaces: string[]; services: string[] }>;
411
+ getSummary(options?: SummaryOptions): Promise<any>;
412
+ getUsageStats(options?: { days?: number }): Promise<any>;
413
+
414
+ // Pricing & Packages
415
+ getPackages(): Promise<CreditPackage[]>;
416
+ getPricingInfo(): Promise<any>;
417
+ calculateCost(options: CalculateCostOptions): Promise<any>;
418
+ calculateCredits(amount: number): Promise<any>;
419
+
420
+ // Purchase Management
421
+ createCheckout(options: PurchaseOptions): Promise<any>;
422
+ getPurchaseHistory(options?: PurchaseHistoryOptions): Promise<any>;
423
+ getPurchaseDetails(purchaseId: string): Promise<any>;
424
+ getPurchaseSession(purchaseId: string): Promise<any>;
425
+ cancelPurchase(purchaseId: string): Promise<any>;
426
+ }
427
+
170
428
  // ============ Exports ============
171
429
 
172
430
  declare const _default: {
173
431
  OblienClient: typeof OblienClient;
174
432
  OblienChat: typeof OblienChat;
175
433
  ChatSession: typeof ChatSession;
434
+ OblienNamespaces: typeof OblienNamespaces;
435
+ Namespace: typeof Namespace;
436
+ OblienCredits: typeof OblienCredits;
176
437
  GuestManager: typeof GuestManager;
177
438
  NodeCacheStorage: typeof NodeCacheStorage;
178
439
  InMemoryStorage: typeof InMemoryStorage;
package/index.js CHANGED
@@ -5,6 +5,12 @@
5
5
 
6
6
  import { OblienClient } from './src/client.js';
7
7
  import { OblienChat, ChatSession } from './src/chat/index.js';
8
+ import { OblienAgents, Agent, Tools, AgentSettings } from './src/agents/index.js';
9
+ import { OblienSandboxes, Sandbox } from './src/sandbox/index.js';
10
+ import { OblienSearch } from './src/search/index.js';
11
+ import { OblienIcons } from './src/icons/index.js';
12
+ import { OblienNamespaces, Namespace } from './src/namespaces/index.js';
13
+ import { OblienCredits } from './src/credits/index.js';
8
14
  import {
9
15
  GuestManager,
10
16
  NodeCacheStorage,
@@ -15,6 +21,12 @@ import {
15
21
  // Re-export as named exports
16
22
  export { OblienClient };
17
23
  export { OblienChat, ChatSession };
24
+ export { OblienAgents, Agent, Tools, AgentSettings };
25
+ export { OblienSandboxes, Sandbox };
26
+ export { OblienSearch };
27
+ export { OblienIcons };
28
+ export { OblienNamespaces, Namespace };
29
+ export { OblienCredits };
18
30
  export {
19
31
  GuestManager,
20
32
  NodeCacheStorage,
@@ -27,6 +39,17 @@ export default {
27
39
  OblienClient,
28
40
  OblienChat,
29
41
  ChatSession,
42
+ OblienAgents,
43
+ Agent,
44
+ Tools,
45
+ AgentSettings,
46
+ OblienSandboxes,
47
+ Sandbox,
48
+ OblienSearch,
49
+ OblienIcons,
50
+ OblienNamespaces,
51
+ Namespace,
52
+ OblienCredits,
30
53
  GuestManager,
31
54
  NodeCacheStorage,
32
55
  InMemoryStorage,
package/namespaces.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Namespaces Module Entry Point
3
+ * Import this for namespace management only
4
+ */
5
+
6
+ export { OblienNamespaces, Namespace } from './src/namespaces/index.js';
7
+
8
+ export default {
9
+ OblienNamespaces,
10
+ Namespace
11
+ };
12
+
package/package.json CHANGED
@@ -1,13 +1,19 @@
1
1
  {
2
2
  "name": "oblien",
3
- "version": "1.0.7",
3
+ "version": "1.1.1",
4
4
  "description": "Server-side SDK for Oblien AI Platform - Build AI-powered applications with chat, agents, and workflows",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "types": "index.d.ts",
8
8
  "exports": {
9
9
  ".": "./index.js",
10
- "./chat": "./chat.js"
10
+ "./chat": "./chat.js",
11
+ "./namespaces": "./namespaces.js",
12
+ "./credits": "./credits.js",
13
+ "./agents": "./agents.js",
14
+ "./sandbox": "./sandbox.js",
15
+ "./search": "./search.js",
16
+ "./icons": "./icons.js"
11
17
  },
12
18
  "scripts": {
13
19
  "test": "node --test tests/**/*.test.js"
@@ -56,7 +62,12 @@
56
62
  "index.js",
57
63
  "index.d.ts",
58
64
  "chat.js",
65
+ "namespaces.js",
66
+ "credits.js",
59
67
  "agents.js",
68
+ "sandbox.js",
69
+ "search.js",
70
+ "icons.js",
60
71
  "workflows.js",
61
72
  "README.md",
62
73
  "LICENSE"
package/sandbox.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Sandbox Module Entry Point
3
+ * Import this for sandbox management only
4
+ */
5
+
6
+ export { OblienSandboxes, Sandbox } from './src/sandbox/index.js';
7
+
8
+ export default {
9
+ OblienSandboxes,
10
+ Sandbox
11
+ };
12
+
package/search.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Search Module Entry Point
3
+ * Import this for search functionality only
4
+ */
5
+
6
+ export { OblienSearch } from './src/search/index.js';
7
+
8
+ export default {
9
+ OblienSearch
10
+ };
11
+
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Agent Class
3
+ * Represents a single agent with methods for operations
4
+ */
5
+
6
+ import { AgentSettings } from './settings.js';
7
+
8
+ export class Agent {
9
+ /**
10
+ * @param {Object} options
11
+ * @param {import('../client.js').OblienClient} options.client - Oblien client instance
12
+ * @param {string} [options.agentId] - Agent ID
13
+ */
14
+ constructor({ client, agentId = null }) {
15
+ if (!client) {
16
+ throw new Error('Oblien client is required');
17
+ }
18
+
19
+ this.client = client;
20
+ this.agentId = agentId;
21
+ this._settings = null;
22
+ }
23
+
24
+ /**
25
+ * Get settings manager for this agent
26
+ * @returns {AgentSettings} Settings manager instance
27
+ */
28
+ get settings() {
29
+ if (!this.agentId) {
30
+ throw new Error('Agent ID is required for settings operations');
31
+ }
32
+
33
+ if (!this._settings) {
34
+ this._settings = new AgentSettings({
35
+ client: this.client,
36
+ agentId: this.agentId
37
+ });
38
+ }
39
+
40
+ return this._settings;
41
+ }
42
+
43
+ /**
44
+ * Create a new agent
45
+ * @param {Object} options - Agent options
46
+ * @param {string} options.name - Agent name (required)
47
+ * @param {Object} options.prompts - Agent prompts/configuration (required)
48
+ * @param {string} [options.description] - Agent description
49
+ * @param {string} [options.namespace] - Namespace for organization
50
+ * @param {Array<string>} [options.collectionIds] - Collection IDs
51
+ * @param {Object} [options.settings] - Agent settings
52
+ * @returns {Promise<Object>} Created agent data
53
+ */
54
+ async create(options) {
55
+ const { name, prompts, description, namespace, collectionIds, settings } = options;
56
+
57
+ if (!name) {
58
+ throw new Error('Agent name is required');
59
+ }
60
+ if (!prompts) {
61
+ throw new Error('Agent prompts are required');
62
+ }
63
+
64
+ const response = await this.client.post('ai/agents/create', {
65
+ name,
66
+ prompts,
67
+ description,
68
+ namespace,
69
+ collectionIds,
70
+ settings
71
+ });
72
+
73
+ if (response.agentId || response.id) {
74
+ this.agentId = response.agentId || response.id;
75
+ }
76
+
77
+ return response;
78
+ }
79
+
80
+ /**
81
+ * Get agent details
82
+ * @param {string} [section] - Optional section to retrieve
83
+ * @returns {Promise<Object>} Agent data
84
+ */
85
+ async get(section = null) {
86
+ if (!this.agentId) {
87
+ throw new Error('Agent ID is required');
88
+ }
89
+
90
+ const path = section
91
+ ? `ai/agents/${this.agentId}/${section}`
92
+ : `ai/agents/${this.agentId}`;
93
+
94
+ return await this.client.get(path);
95
+ }
96
+
97
+ /**
98
+ * Update agent
99
+ * @param {Object} updates - Fields to update
100
+ * @param {string} [updates.name] - Agent name
101
+ * @param {string} [updates.description] - Description
102
+ * @param {Object} [updates.prompts] - Prompts
103
+ * @param {Object} [updates.settings] - Settings
104
+ * @param {string} [updates.namespace] - Namespace (for validation)
105
+ * @returns {Promise<Object>} Update result
106
+ */
107
+ async update(updates) {
108
+ if (!this.agentId) {
109
+ throw new Error('Agent ID is required');
110
+ }
111
+
112
+ return await this.client.put(`ai/agents/${this.agentId}`, updates);
113
+ }
114
+
115
+ /**
116
+ * Delete agent
117
+ * @param {Object} [options] - Delete options
118
+ * @param {string} [options.namespace] - Namespace for validation
119
+ * @returns {Promise<Object>} Delete result
120
+ */
121
+ async delete(options = {}) {
122
+ if (!this.agentId) {
123
+ throw new Error('Agent ID is required');
124
+ }
125
+
126
+ // Use POST with body for DELETE with namespace validation
127
+ const response = await fetch(this.client._buildURL(`ai/agents/${this.agentId}`), {
128
+ method: 'DELETE',
129
+ headers: this.client.getAuthHeaders(),
130
+ body: JSON.stringify(options)
131
+ });
132
+
133
+ return this.client._handleResponse(response);
134
+ }
135
+
136
+ /**
137
+ * Get agent overview/analytics
138
+ * @param {Object} [options] - Query options
139
+ * @param {number} [options.days=7] - Number of days for activity data
140
+ * @returns {Promise<Object>} Analytics data
141
+ */
142
+ async getOverview(options = {}) {
143
+ if (!this.agentId) {
144
+ throw new Error('Agent ID is required');
145
+ }
146
+
147
+ return await this.client.get(`ai/agents/${this.agentId}/overview`, options);
148
+ }
149
+
150
+ /**
151
+ * Get agent sessions
152
+ * @param {Object} [options] - Query options
153
+ * @param {number} [options.limit] - Max results
154
+ * @param {number} [options.offset] - Offset for pagination
155
+ * @param {string} [options.search] - Search term
156
+ * @param {string} [options.sortBy] - Sort by field
157
+ * @param {string} [options.sortOrder] - Sort order (asc/desc)
158
+ * @returns {Promise<Object>} Sessions data
159
+ */
160
+ async getSessions(options = {}) {
161
+ if (!this.agentId) {
162
+ throw new Error('Agent ID is required');
163
+ }
164
+
165
+ return await this.client.get(`ai/agents/${this.agentId}/sessions`, options);
166
+ }
167
+
168
+ /**
169
+ * Get agent bans
170
+ * @param {Object} [options] - Query options
171
+ * @returns {Promise<Array>} Bans data
172
+ */
173
+ async getBans(options = {}) {
174
+ if (!this.agentId) {
175
+ throw new Error('Agent ID is required');
176
+ }
177
+
178
+ return await this.client.get(`ai/agents/${this.agentId}/bans`, options);
179
+ }
180
+
181
+
182
+ /**
183
+ * Get agent users
184
+ * @param {Object} [options] - Query options
185
+ * @returns {Promise<Array>} Agent users data
186
+ */
187
+ async getUsers(options = {}) {
188
+ if (!this.agentId) {
189
+ throw new Error('Agent ID is required');
190
+ }
191
+
192
+ return await this.client.get(`ai/agents/${this.agentId}/users`, options);
193
+ }
194
+
195
+ /**
196
+ * Get specific agent user
197
+ * @param {string} userId - User ID
198
+ * @returns {Promise<Object>} User data
199
+ */
200
+ async getUser(userId) {
201
+ if (!this.agentId) {
202
+ throw new Error('Agent ID is required');
203
+ }
204
+ if (!userId) {
205
+ throw new Error('User ID is required');
206
+ }
207
+
208
+ return await this.client.get(`ai/agents/${this.agentId}/users/${userId}`);
209
+ }
210
+
211
+ /**
212
+ * Reset user limits
213
+ * @param {string} userId - User ID
214
+ * @returns {Promise<Object>} Reset result
215
+ */
216
+ async resetUserLimits(userId) {
217
+ if (!this.agentId) {
218
+ throw new Error('Agent ID is required');
219
+ }
220
+ if (!userId) {
221
+ throw new Error('User ID is required');
222
+ }
223
+
224
+ return await this.client.post(`ai/agents/${this.agentId}/users/${userId}/reset-limits`);
225
+ }
226
+ }
227
+
228
+ export default Agent;
229
+