oblien 1.2.7 → 2.0.0

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.
Files changed (171) hide show
  1. package/dist/client.d.ts +31 -0
  2. package/dist/client.d.ts.map +1 -0
  3. package/dist/client.js +33 -0
  4. package/dist/client.js.map +1 -0
  5. package/dist/error.d.ts +29 -0
  6. package/dist/error.d.ts.map +1 -0
  7. package/dist/error.js +52 -0
  8. package/dist/error.js.map +1 -0
  9. package/dist/http.d.ts +20 -0
  10. package/dist/http.d.ts.map +1 -0
  11. package/dist/http.js +108 -0
  12. package/dist/http.js.map +1 -0
  13. package/dist/index.d.ts +8 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +10 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/resources/api-access.d.ts +21 -0
  18. package/dist/resources/api-access.d.ts.map +1 -0
  19. package/dist/resources/api-access.js +32 -0
  20. package/dist/resources/api-access.js.map +1 -0
  21. package/dist/resources/base.d.ts +17 -0
  22. package/dist/resources/base.d.ts.map +1 -0
  23. package/dist/resources/base.js +21 -0
  24. package/dist/resources/base.js.map +1 -0
  25. package/dist/resources/images.d.ts +11 -0
  26. package/dist/resources/images.d.ts.map +1 -0
  27. package/dist/resources/images.js +16 -0
  28. package/dist/resources/images.js.map +1 -0
  29. package/dist/resources/lifecycle.d.ts +23 -0
  30. package/dist/resources/lifecycle.d.ts.map +1 -0
  31. package/dist/resources/lifecycle.js +32 -0
  32. package/dist/resources/lifecycle.js.map +1 -0
  33. package/dist/resources/logs.d.ts +25 -0
  34. package/dist/resources/logs.d.ts.map +1 -0
  35. package/dist/resources/logs.js +51 -0
  36. package/dist/resources/logs.js.map +1 -0
  37. package/dist/resources/metadata.d.ts +15 -0
  38. package/dist/resources/metadata.d.ts.map +1 -0
  39. package/dist/resources/metadata.js +20 -0
  40. package/dist/resources/metadata.js.map +1 -0
  41. package/dist/resources/metrics.d.ts +17 -0
  42. package/dist/resources/metrics.d.ts.map +1 -0
  43. package/dist/resources/metrics.js +27 -0
  44. package/dist/resources/metrics.js.map +1 -0
  45. package/dist/resources/network.d.ts +17 -0
  46. package/dist/resources/network.d.ts.map +1 -0
  47. package/dist/resources/network.js +20 -0
  48. package/dist/resources/network.js.map +1 -0
  49. package/dist/resources/public-access.d.ts +15 -0
  50. package/dist/resources/public-access.d.ts.map +1 -0
  51. package/dist/resources/public-access.js +21 -0
  52. package/dist/resources/public-access.js.map +1 -0
  53. package/dist/resources/resources.d.ts +15 -0
  54. package/dist/resources/resources.d.ts.map +1 -0
  55. package/dist/resources/resources.js +20 -0
  56. package/dist/resources/resources.js.map +1 -0
  57. package/dist/resources/snapshots.d.ts +27 -0
  58. package/dist/resources/snapshots.d.ts.map +1 -0
  59. package/dist/resources/snapshots.js +45 -0
  60. package/dist/resources/snapshots.js.map +1 -0
  61. package/dist/resources/ssh.d.ts +19 -0
  62. package/dist/resources/ssh.d.ts.map +1 -0
  63. package/dist/resources/ssh.js +28 -0
  64. package/dist/resources/ssh.js.map +1 -0
  65. package/dist/resources/usage.d.ts +25 -0
  66. package/dist/resources/usage.d.ts.map +1 -0
  67. package/dist/resources/usage.js +44 -0
  68. package/dist/resources/usage.js.map +1 -0
  69. package/dist/resources/workloads.d.ts +39 -0
  70. package/dist/resources/workloads.d.ts.map +1 -0
  71. package/dist/resources/workloads.js +83 -0
  72. package/dist/resources/workloads.js.map +1 -0
  73. package/dist/runtime/exec.d.ts +71 -0
  74. package/dist/runtime/exec.d.ts.map +1 -0
  75. package/dist/runtime/exec.js +163 -0
  76. package/dist/runtime/exec.js.map +1 -0
  77. package/dist/runtime/files.d.ts +39 -0
  78. package/dist/runtime/files.d.ts.map +1 -0
  79. package/dist/runtime/files.js +143 -0
  80. package/dist/runtime/files.js.map +1 -0
  81. package/dist/runtime/search.d.ts +23 -0
  82. package/dist/runtime/search.d.ts.map +1 -0
  83. package/dist/runtime/search.js +65 -0
  84. package/dist/runtime/search.js.map +1 -0
  85. package/dist/runtime/terminal.d.ts +29 -0
  86. package/dist/runtime/terminal.d.ts.map +1 -0
  87. package/dist/runtime/terminal.js +58 -0
  88. package/dist/runtime/terminal.js.map +1 -0
  89. package/dist/runtime/watcher.d.ts +27 -0
  90. package/dist/runtime/watcher.d.ts.map +1 -0
  91. package/dist/runtime/watcher.js +53 -0
  92. package/dist/runtime/watcher.js.map +1 -0
  93. package/dist/runtime/ws.d.ts +92 -0
  94. package/dist/runtime/ws.d.ts.map +1 -0
  95. package/dist/runtime/ws.js +228 -0
  96. package/dist/runtime/ws.js.map +1 -0
  97. package/dist/runtime-http.d.ts +35 -0
  98. package/dist/runtime-http.d.ts.map +1 -0
  99. package/dist/runtime-http.js +99 -0
  100. package/dist/runtime-http.js.map +1 -0
  101. package/dist/runtime.d.ts +77 -0
  102. package/dist/runtime.d.ts.map +1 -0
  103. package/dist/runtime.js +97 -0
  104. package/dist/runtime.js.map +1 -0
  105. package/dist/types/client.d.ts +7 -0
  106. package/dist/types/client.d.ts.map +1 -0
  107. package/dist/types/client.js +3 -0
  108. package/dist/types/client.js.map +1 -0
  109. package/dist/types/common.d.ts +13 -0
  110. package/dist/types/common.d.ts.map +1 -0
  111. package/dist/types/common.js +3 -0
  112. package/dist/types/common.js.map +1 -0
  113. package/dist/types/index.d.ts +8 -0
  114. package/dist/types/index.d.ts.map +1 -0
  115. package/dist/types/index.js +2 -0
  116. package/dist/types/index.js.map +1 -0
  117. package/dist/types/network.d.ts +15 -0
  118. package/dist/types/network.d.ts.map +1 -0
  119. package/dist/types/network.js +3 -0
  120. package/dist/types/network.js.map +1 -0
  121. package/dist/types/resources.d.ts +10 -0
  122. package/dist/types/resources.d.ts.map +1 -0
  123. package/dist/types/resources.js +3 -0
  124. package/dist/types/resources.js.map +1 -0
  125. package/dist/types/runtime.d.ts +302 -0
  126. package/dist/types/runtime.d.ts.map +1 -0
  127. package/dist/types/runtime.js +3 -0
  128. package/dist/types/runtime.js.map +1 -0
  129. package/dist/types/workspace-resources.d.ts +186 -0
  130. package/dist/types/workspace-resources.d.ts.map +1 -0
  131. package/dist/types/workspace-resources.js +3 -0
  132. package/dist/types/workspace-resources.js.map +1 -0
  133. package/dist/types/workspace.d.ts +41 -0
  134. package/dist/types/workspace.d.ts.map +1 -0
  135. package/dist/types/workspace.js +3 -0
  136. package/dist/types/workspace.js.map +1 -0
  137. package/dist/workspace.d.ts +135 -0
  138. package/dist/workspace.d.ts.map +1 -0
  139. package/dist/workspace.js +194 -0
  140. package/dist/workspace.js.map +1 -0
  141. package/package.json +31 -70
  142. package/LICENSE +0 -21
  143. package/README.md +0 -574
  144. package/agents.js +0 -14
  145. package/browser.js +0 -6
  146. package/cdn.js +0 -6
  147. package/chat.js +0 -21
  148. package/credits.js +0 -11
  149. package/icons.js +0 -11
  150. package/index.d.ts +0 -967
  151. package/index.js +0 -63
  152. package/namespaces.js +0 -12
  153. package/sandbox.js +0 -12
  154. package/search.js +0 -11
  155. package/src/agents/agent.js +0 -229
  156. package/src/agents/index.js +0 -212
  157. package/src/agents/settings.js +0 -100
  158. package/src/agents/tools.js +0 -155
  159. package/src/browser/index.js +0 -449
  160. package/src/cdn/index.js +0 -744
  161. package/src/chat/index.js +0 -704
  162. package/src/chat/session.js +0 -93
  163. package/src/client.js +0 -175
  164. package/src/credits/index.js +0 -480
  165. package/src/icons/index.js +0 -185
  166. package/src/namespaces/index.js +0 -225
  167. package/src/namespaces/namespace.js +0 -274
  168. package/src/sandbox/index.js +0 -185
  169. package/src/sandbox/sandbox.js +0 -124
  170. package/src/search/index.js +0 -191
  171. package/src/utils/guest-manager.js +0 -454
package/package.json CHANGED
@@ -1,85 +1,46 @@
1
1
  {
2
2
  "name": "oblien",
3
- "version": "1.2.7",
4
- "description": "Server-side SDK for Oblien AI Platform - Build AI-powered applications with chat, agents, and workflows",
5
- "main": "index.js",
3
+ "version": "2.0.0",
4
+ "description": "Official TypeScript SDK for the Oblien Workspace API",
6
5
  "type": "module",
7
- "types": "index.d.ts",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
8
  "exports": {
9
- ".": "./index.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",
17
- "./cdn": "./cdn.js",
18
- "./browser": "./browser.js"
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./workspace": {
14
+ "import": "./dist/workspace.js",
15
+ "types": "./dist/workspace.d.ts"
16
+ },
17
+ "./runtime": {
18
+ "import": "./dist/runtime.js",
19
+ "types": "./dist/runtime.d.ts"
20
+ }
19
21
  },
22
+ "files": [
23
+ "dist"
24
+ ],
20
25
  "scripts": {
21
- "test": "node --test tests/**/*.test.js"
26
+ "build": "tsc",
27
+ "dev": "tsc --watch",
28
+ "clean": "rm -rf dist",
29
+ "prepublishOnly": "npm run clean && npm run build"
30
+ },
31
+ "devDependencies": {
32
+ "typescript": "^5.4.0"
22
33
  },
23
- "keywords": [
24
- "oblien",
25
- "ai",
26
- "chat",
27
- "agents",
28
- "workflows",
29
- "sdk",
30
- "api",
31
- "server-side",
32
- "llm",
33
- "assistant",
34
- "cdn",
35
- "file-upload",
36
- "image-processing",
37
- "browser-automation",
38
- "puppeteer",
39
- "scraping"
40
- ],
41
- "author": "Oblien",
42
- "license": "MIT",
43
34
  "repository": {
44
35
  "type": "git",
45
- "url": "git@github.com:oblien/core.git"
36
+ "url": "git@github.com:oblien/sdk.git"
46
37
  },
47
- "homepage": "https://oblien.com/docs/core",
38
+ "homepage": "https://oblien.com/docs/sdk",
48
39
  "bugs": {
49
- "url": "https://github.com/oblien/core/issues"
50
- },
51
- "dependencies": {
52
- "node-cache": "^5.1.2"
53
- },
54
- "peerDependencies": {
55
- "redis": "^4.0.0"
56
- },
57
- "peerDependenciesMeta": {
58
- "redis": {
59
- "optional": true
60
- }
61
- },
62
- "devDependencies": {
63
- "@types/node": "^20.0.0"
40
+ "url": "https://github.com/oblien/sdk/issues"
64
41
  },
65
42
  "engines": {
66
43
  "node": ">=18.0.0"
67
44
  },
68
- "files": [
69
- "src/",
70
- "index.js",
71
- "index.d.ts",
72
- "chat.js",
73
- "namespaces.js",
74
- "credits.js",
75
- "agents.js",
76
- "sandbox.js",
77
- "search.js",
78
- "icons.js",
79
- "cdn.js",
80
- "browser.js",
81
- "workflows.js",
82
- "README.md",
83
- "LICENSE"
84
- ]
85
- }
45
+ "license": "MIT"
46
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Oblien
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/README.md DELETED
@@ -1,574 +0,0 @@
1
- # Oblien Core SDK
2
-
3
- Complete Node.js SDK for the Oblien AI Platform. Manage agents, chat sessions, sandboxes, namespaces, and more.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install oblien
9
- ```
10
-
11
- ## Quick Start
12
-
13
- ```javascript
14
- // Import client
15
- import { OblienClient } from 'oblien';
16
-
17
- // Import modules (tree-shakeable)
18
- import { OblienAgents } from 'oblien/agents'; // agent creation
19
- import { OblienChat } from 'oblien/chat'; // agent chat managment
20
- import { OblienSandboxes } from 'oblien/sandbox'; // sandbox for agent code execution
21
- import { OblienEmbeddings } from 'oblien/embeddings'; // embeddings store for semantic search
22
- import { OblienSearch } from 'oblien/search'; // search gateway for your agent
23
- import { OblienIcons } from 'oblien/icons'; // sematic based icons fetch
24
- import { OblienNamespaces } from 'oblien/namespaces'; // user and guest management
25
- import { OblienCredits } from 'oblien/credits'; // credits managemnt for your user
26
- import { OblienCDN } from 'oblien/cdn'; // cdn upload for your app
27
- import { OblienBrowser } from 'oblien/browser'; // browser api for scrap or any task
28
- import { OblienDeployments } from 'oblien/deployments'; // deployments gateway
29
-
30
- // Initialize client
31
- const client = new OblienClient({
32
- clientId: 'your-client-id',
33
- clientSecret: 'your-client-secret'
34
- });
35
-
36
- // Use modules
37
- const agents = new OblienAgents(client);
38
- const chat = new OblienChat(client);
39
- const sandboxes = new OblienSandboxes(client);
40
- const search = new OblienSearch(client);
41
- const icons = new OblienIcons(client);
42
- ```
43
-
44
- ---
45
-
46
- ## Modules Overview
47
-
48
- ### 🤖 Agents Module
49
-
50
- Manage AI agents with settings, tools, and analytics.
51
-
52
- ```javascript
53
- import { OblienAgents } from 'oblien/agents';
54
-
55
- const agents = new OblienAgents(client);
56
-
57
- // Create agent
58
- const agent = await agents.create({
59
- name: 'Support Agent',
60
- namespace: 'production',
61
- prompts: {
62
- identity: 'You are a helpful assistant.'
63
- }
64
- });
65
-
66
- // Configure settings
67
- const agentInstance = agents.agent(agent.agentId);
68
- await agentInstance.settings.updateModelConfig({
69
- model: 'oblien-master',
70
- temperature: 0.8
71
- });
72
-
73
- // Assign tools
74
- await agentInstance.settings.updateTools(['web-search', 'calculator']);
75
-
76
- // Get analytics
77
- const overview = await agentInstance.getOverview({ days: 7 });
78
- ```
79
-
80
- **Features:**
81
- - ✅ CRUD operations (create, read, update, delete)
82
- - ✅ Settings management (5 sections: switches, model, tools, guest limits, context)
83
- - ✅ Tools management (list, search, create, validate)
84
- - ✅ Analytics & monitoring
85
- - ✅ Namespace support
86
- - ✅ User management
87
-
88
- 📖 [Full Documentation](./docs/AGENTS_COMPLETE.md) | 💡 [Examples](./examples/agents-complete-example.js)
89
-
90
- ---
91
-
92
- ### 💬 Chat Module
93
-
94
- Create sessions, send messages, and manage guests with streaming support.
95
-
96
- ```javascript
97
- import { OblienChat } from 'oblien/chat';
98
-
99
- const chat = new OblienChat(client);
100
-
101
- // Create session
102
- const session = await chat.createSession({
103
- agentId: 'agent-id',
104
- namespace: 'production'
105
- });
106
-
107
- // Send message with streaming
108
- await chat.send({
109
- token: session.token,
110
- message: 'Tell me about AI',
111
- stream: true,
112
- onChunk: (data) => console.log(data)
113
- });
114
-
115
- // Upload files
116
- const uploadResult = await chat.upload({
117
- token: session.token,
118
- files: fileArray
119
- });
120
-
121
- // Send message with uploaded files
122
- await chat.send({
123
- token: session.token,
124
- message: 'Analyze these files',
125
- uploadId: uploadResult.uploadId
126
- });
127
-
128
- // Create guest session
129
- const guestSession = await chat.createGuestSession({
130
- ip: '192.168.1.1',
131
- fingerprint: 'abc123',
132
- agentId: 'agent-id'
133
- });
134
-
135
- // Get guest usage
136
- const usage = await chat.getGuestUsage(guestSession.token);
137
- ```
138
-
139
- **Features:**
140
- - ✅ Session management (create, list, delete)
141
- - ✅ Message sending with streaming support
142
- - ✅ File uploads for agent analysis
143
- - ✅ Guest sessions with IP + fingerprint tracking
144
- - ✅ Guest usage monitoring and rate limiting
145
- - ✅ Hybrid mode (works with token or client credentials)
146
- - ✅ Cache statistics for monitoring
147
-
148
- 📖 [Full Documentation](./docs/CHAT.md) | 💡 [Examples](./examples/chat-example.js)
149
-
150
- ---
151
-
152
- ### 📦 Sandboxes Module
153
-
154
- Manage cloud sandboxes (containerized environments).
155
-
156
- ```javascript
157
- import { OblienSandboxes } from 'oblien/sandbox';
158
-
159
- const sandboxes = new OblienSandboxes(client);
160
-
161
- // Create sandbox
162
- const sandbox = await sandboxes.create({
163
- name: 'my-dev-env',
164
- region: 'us-east-1',
165
- template: 'node-20',
166
- autoStart: true
167
- });
168
-
169
- // Use sandbox
170
- const { url, token } = sandbox.sandbox;
171
- const response = await fetch(`${url}/files/list`, {
172
- headers: { 'Authorization': `Bearer ${token}` }
173
- });
174
-
175
- // Control lifecycle
176
- await sandboxes.stop(sandboxId);
177
- await sandboxes.start(sandboxId);
178
- await sandboxes.restart(sandboxId);
179
-
180
- // Regenerate token (1h expiry)
181
- const newToken = await sandboxes.regenerateToken(sandboxId);
182
-
183
- // Get metrics
184
- const metrics = await sandboxes.getMetrics(sandboxId);
185
- ```
186
-
187
- **Features:**
188
- - ✅ Create, start, stop, restart, delete sandboxes
189
- - ✅ Auto-start option
190
- - ✅ Token management (1h JWT)
191
- - ✅ Resource metrics
192
- - ✅ Multiple templates & regions
193
- - ✅ Platform statistics
194
-
195
- 📖 [Full Documentation](./docs/SANDBOXES.md) | 💡 [Examples](./examples/sandbox-example.js)
196
-
197
- ---
198
-
199
- ### 🗂️ Namespaces Module
200
-
201
- Manage namespaces and service configurations.
202
-
203
- ```javascript
204
- import { OblienNamespaces } from 'oblien/namespaces';
205
-
206
- const namespaces = new OblienNamespaces(client);
207
-
208
- // Create namespace
209
- const namespace = await namespaces.create({
210
- name: 'production',
211
- slug: 'prod',
212
- type: 'production'
213
- });
214
-
215
- // Configure services
216
- await namespaces.configureService(namespaceId, {
217
- service: 'ai',
218
- enabled: true,
219
- config: { /* ... */ }
220
- });
221
-
222
- // Get usage stats
223
- const usage = await namespaces.getUsage(namespaceId);
224
- ```
225
-
226
- **Features:**
227
- - ✅ Namespace CRUD
228
- - ✅ Service configuration
229
- - ✅ Usage tracking
230
- - ✅ Activity logs
231
-
232
- 📖 [Documentation](./docs/NAMESPACES.md)
233
-
234
- ---
235
-
236
- ### 🎨 Icons Module
237
-
238
- Search and fetch icons, images, and videos using AI-powered semantic search.
239
-
240
- ```javascript
241
- import { OblienIcons } from 'oblien/icons';
242
-
243
- const icons = new OblienIcons(client);
244
-
245
- // Search for icons
246
- const results = await icons.search('home', { limit: 20 });
247
-
248
- // Fetch specific icons
249
- const icon = await icons.fetchIcon('settings gear');
250
-
251
- // Fetch multiple icons at once
252
- const iconSet = await icons.fetchIcons([
253
- 'home',
254
- 'user profile',
255
- 'settings',
256
- 'notification bell'
257
- ]);
258
-
259
- // Fetch mixed media (icons, images, videos)
260
- const media = await icons.fetch([
261
- { type: 'icon', description: 'user avatar' },
262
- { type: 'image', description: 'mountain landscape' },
263
- { type: 'video', description: 'product demo' }
264
- ]);
265
- ```
266
-
267
- **Features:**
268
- - ✅ Semantic icon search with AI embeddings
269
- - ✅ Fetch icons, images, and videos
270
- - ✅ Relevance scoring
271
- - ✅ Multiple icon styles (Outline, Filled, etc.)
272
- - ✅ Batch fetching
273
- - ✅ Pagination support
274
- - ✅ CDN-hosted assets
275
-
276
- 📖 [Full Documentation](./docs/ICONS.md) | 💡 [Examples](./examples/icons-example.js)
277
-
278
- ---
279
-
280
- ### 💳 Credits Module
281
-
282
- Manage billing and credits.
283
-
284
- ```javascript
285
- import { OblienCredits } from 'oblien/credits';
286
-
287
- const credits = new OblienCredits(client);
288
-
289
- // Get balance
290
- const balance = await credits.getBalance();
291
-
292
- // Get usage
293
- const usage = await credits.getUsage({ period: 'monthly' });
294
- ```
295
-
296
- **Features:**
297
- - ✅ Balance checking
298
- - ✅ Usage tracking
299
- - ✅ Transaction history
300
-
301
- ---
302
-
303
- ## Complete Example
304
-
305
- ```javascript
306
- // Import client and modules
307
- import { OblienClient } from 'oblien';
308
- import { OblienAgents } from 'oblien/agents';
309
- import { OblienChat } from 'oblien/chat';
310
- import { OblienSandboxes } from 'oblien/sandbox';
311
-
312
- // Initialize
313
- const client = new OblienClient({
314
- clientId: 'your-client-id',
315
- clientSecret: 'your-client-secret'
316
- });
317
-
318
- const agents = new OblienAgents(client);
319
- const chat = new OblienChat(client);
320
- const sandboxes = new OblienSandboxes(client);
321
-
322
- async function main() {
323
- // 1. Create agent with tools
324
- const agent = await agents.create({
325
- name: 'Code Assistant',
326
- namespace: 'production',
327
- prompts: {
328
- identity: 'You are a coding assistant.'
329
- }
330
- });
331
-
332
- // Configure agent
333
- const agentInstance = agents.agent(agent.agentId);
334
- await agentInstance.settings.updateTools(['web-search', 'calculator']);
335
- await agentInstance.settings.updateModelConfig({
336
- temperature: 0.7,
337
- max_tokens: 3000
338
- });
339
-
340
- // 2. Create sandbox for code execution
341
- const sandbox = await sandboxes.create({
342
- name: 'code-env',
343
- template: 'node-20',
344
- autoStart: true
345
- });
346
-
347
- // 3. Create chat session
348
- const session = await chat.createSession({
349
- agentId: agent.agentId,
350
- namespace: 'production'
351
- });
352
-
353
- console.log('Setup complete!');
354
- console.log('- Agent ID:', agent.agentId);
355
- console.log('- Sandbox URL:', sandbox.sandbox.url);
356
- console.log('- Session ID:', session.sessionId);
357
- }
358
-
359
- main();
360
- ```
361
-
362
- ---
363
-
364
- ## Module Structure
365
-
366
- ```
367
- oblien/
368
- ├── src/
369
- │ ├── agents/ # Agents management
370
- │ │ ├── index.js # OblienAgents class
371
- │ │ ├── agent.js # Agent instance
372
- │ │ ├── settings.js # AgentSettings class
373
- │ │ └── tools.js # Tools class
374
- │ ├── chat/ # Chat sessions
375
- │ │ ├── index.js # OblienChat class
376
- │ │ └── session.js # ChatSession class
377
- │ ├── sandbox/ # Sandboxes management
378
- │ │ ├── index.js # OblienSandboxes class
379
- │ │ └── sandbox.js # Sandbox instance
380
- │ ├── namespaces/ # Namespaces management
381
- │ ├── credits/ # Credits & billing
382
- │ └── client.js # OblienClient (base)
383
- ├── docs/ # Documentation
384
- │ ├── AGENTS_COMPLETE.md
385
- │ ├── SANDBOXES.md
386
- │ ├── CHAT.md
387
- │ └── NAMESPACES.md
388
- └── examples/ # Usage examples
389
- ├── agents-complete-example.js
390
- ├── sandbox-example.js
391
- └── chat-example.js
392
- ```
393
-
394
- ---
395
-
396
- ## API Endpoints
397
-
398
- | Module | Base Path | Operations |
399
- |--------|-----------|------------|
400
- | **Agents** | `/ai/agents` | CRUD, settings, tools, analytics |
401
- | **Chat** | `/ai/session` | Create, list, history |
402
- | **Sandboxes** | `/sandbox` | CRUD, start/stop/restart, metrics |
403
- | **Tools** | `/ai/tools` | List, search, create |
404
- | **Namespaces** | `/namespaces` | CRUD, services, usage |
405
-
406
- ---
407
-
408
- ## Authentication
409
-
410
- All modules use client credentials authentication:
411
-
412
- ```javascript
413
- const client = new OblienClient({
414
- clientId: 'your-client-id', // X-Client-ID header
415
- clientSecret: 'your-client-secret' // X-Client-Secret header
416
- });
417
- ```
418
-
419
- Get your credentials from the [Oblien Dashboard](https://dashboard.oblien.com).
420
-
421
- ---
422
-
423
- ## TypeScript Support
424
-
425
- The SDK includes TypeScript definitions:
426
-
427
- ```typescript
428
- import {
429
- OblienClient,
430
- OblienAgents,
431
- Agent,
432
- AgentSettings,
433
- Tools,
434
- OblienSandboxes,
435
- Sandbox
436
- } from 'oblien';
437
-
438
- const client: OblienClient = new OblienClient({
439
- clientId: string,
440
- clientSecret: string
441
- });
442
- ```
443
-
444
- ---
445
-
446
- ## Error Handling
447
-
448
- ```javascript
449
- try {
450
- const agent = await agents.create({ /* ... */ });
451
- } catch (error) {
452
- console.error('Error:', error.message);
453
-
454
- if (error.message.includes('401')) {
455
- // Authentication failed
456
- } else if (error.message.includes('404')) {
457
- // Resource not found
458
- } else if (error.message.includes('429')) {
459
- // Rate limit exceeded
460
- }
461
- }
462
- ```
463
-
464
- ---
465
-
466
- ## Best Practices
467
-
468
- 1. **Reuse Client**: Create one client instance and share across modules
469
- 2. **Error Handling**: Always wrap API calls in try-catch
470
- 3. **Token Management**: For sandboxes, refresh tokens before 1h expiry
471
- 4. **Resource Cleanup**: Stop/delete unused sandboxes and sessions
472
- 5. **Namespace Organization**: Use namespaces to separate environments
473
- 6. **Tool Validation**: Validate tools before assigning to agents
474
-
475
- ---
476
-
477
- ## Examples
478
-
479
- ### Multi-Agent System
480
-
481
- ```javascript
482
- // Create specialized agents
483
- const coder = await agents.create({
484
- name: 'Coder',
485
- prompts: { identity: 'Expert coder' }
486
- });
487
-
488
- const reviewer = await agents.create({
489
- name: 'Reviewer',
490
- prompts: { identity: 'Code reviewer' }
491
- });
492
-
493
- // Configure each with specific tools
494
- await agents.agent(coder.agentId).settings.updateTools([
495
- 'web-search', 'code-interpreter'
496
- ]);
497
-
498
- await agents.agent(reviewer.agentId).settings.updateTools([
499
- 'code-analyzer', 'security-scanner'
500
- ]);
501
- ```
502
-
503
- ### Guest Chat System
504
-
505
- ```javascript
506
- // Create agent for customer support
507
- const supportAgent = await agents.create({
508
- name: 'Support Bot',
509
- namespace: 'production'
510
- });
511
-
512
- // Set guest limits
513
- await agents.agent(supportAgent.agentId).settings.updateGuestLimits({
514
- enabled: true,
515
- max_messages_per_day: 100,
516
- max_total_tokens_per_day: 50000
517
- });
518
-
519
- // Create guest session
520
- const session = await chat.createGuestSession({
521
- ip: req.ip,
522
- fingerprint: req.headers['x-fingerprint'],
523
- agentId: supportAgent.agentId
524
- });
525
- ```
526
-
527
- ---
528
-
529
- ## Links
530
-
531
- - **Website**: https://oblien.com
532
- - **Documentation**: https://docs.oblien.com
533
- - **Dashboard**: https://dashboard.oblien.com
534
- - **API Reference**: https://api.oblien.com/docs
535
- - **Support**: support@oblien.com
536
- - **GitHub**: https://github.com/oblien/oblien
537
-
538
- ---
539
-
540
- ## License
541
-
542
- MIT License - see LICENSE file for details
543
-
544
- ---
545
-
546
- ## Changelog
547
-
548
- ### v1.3.0 (Latest)
549
- - ✅ Added `send()` method to Chat module with streaming support
550
- - ✅ Added `upload()` method for file attachments
551
- - ✅ Added guest usage monitoring (`getGuestUsage()`)
552
- - ✅ Added cache statistics (`getCacheStatistics()`)
553
- - ✅ Hybrid mode support (token or client credentials)
554
- - ✅ Complete Chat documentation with examples
555
-
556
- ### v1.2.0
557
- - ✅ Added Sandboxes module
558
- - ✅ Enhanced Agents module with proper settings sections
559
- - ✅ Added Tools management
560
- - ✅ Improved documentation
561
-
562
- ### v1.1.0
563
- - ✅ Added Agents module
564
- - ✅ Added Namespaces module
565
- - ✅ Guest session support
566
-
567
- ### v1.0.0
568
- - ✅ Initial release
569
- - ✅ Chat module
570
- - ✅ Credits module
571
-
572
- ---
573
-
574
- Made with ❤️ by the Oblien Team