@prisme.ai/sdk 1.0.2 → 2.0.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.
Files changed (66) hide show
  1. package/README.md +250 -0
  2. package/dist/index.d.mts +1129 -0
  3. package/dist/index.d.ts +1129 -7
  4. package/dist/index.js +1326 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +1287 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +50 -12
  9. package/Readme.md +0 -28
  10. package/dist/_virtual/_tslib.js +0 -116
  11. package/dist/lib/ApiError.d.ts +0 -8
  12. package/dist/lib/ApiError.test.d.ts +0 -1
  13. package/dist/lib/HTTPError.d.ts +0 -6
  14. package/dist/lib/HTTPError.test.d.ts +0 -1
  15. package/dist/lib/ImportProcessing.d.ts +0 -19
  16. package/dist/lib/WorkspacesEndpoint.d.ts +0 -10
  17. package/dist/lib/api.d.ts +0 -155
  18. package/dist/lib/api.test.d.ts +0 -1
  19. package/dist/lib/endpoints/users.d.ts +0 -13
  20. package/dist/lib/endpoints/workspaces.d.ts +0 -25
  21. package/dist/lib/endpoints/workspacesVersions.d.ts +0 -10
  22. package/dist/lib/events.d.ts +0 -40
  23. package/dist/lib/events.test.d.ts +0 -1
  24. package/dist/lib/fetch.d.ts +0 -2
  25. package/dist/lib/fetcher.d.ts +0 -24
  26. package/dist/lib/fetcher.test.d.ts +0 -1
  27. package/dist/lib/interpolate.d.ts +0 -2
  28. package/dist/lib/interpolate.test.d.ts +0 -1
  29. package/dist/lib/interpolateVars.d.ts +0 -2
  30. package/dist/lib/types.d.ts +0 -17
  31. package/dist/lib/utils.d.ts +0 -4
  32. package/dist/lib/utils.test.d.ts +0 -1
  33. package/dist/sdk/index.js +0 -19
  34. package/dist/sdk/lib/ApiError.js +0 -24
  35. package/dist/sdk/lib/HTTPError.js +0 -21
  36. package/dist/sdk/lib/ImportProcessing.js +0 -17
  37. package/dist/sdk/lib/WorkspacesEndpoint.js +0 -19
  38. package/dist/sdk/lib/api.js +0 -1018
  39. package/dist/sdk/lib/endpoints/users.js +0 -94
  40. package/dist/sdk/lib/endpoints/workspaces.js +0 -144
  41. package/dist/sdk/lib/endpoints/workspacesVersions.js +0 -40
  42. package/dist/sdk/lib/events.js +0 -169
  43. package/dist/sdk/lib/fetch.js +0 -12
  44. package/dist/sdk/lib/fetcher.js +0 -213
  45. package/dist/sdk/lib/interpolate.js +0 -26
  46. package/dist/sdk/lib/interpolateVars.js +0 -26
  47. package/dist/sdk/lib/utils.js +0 -65
  48. package/index.ts +0 -7
  49. package/lib/ApiError.test.ts +0 -13
  50. package/lib/ApiError.ts +0 -21
  51. package/lib/HTTPError.test.ts +0 -8
  52. package/lib/HTTPError.ts +0 -13
  53. package/lib/ImportProcessing.ts +0 -22
  54. package/lib/api.test.ts +0 -787
  55. package/lib/api.ts +0 -949
  56. package/lib/endpoints/users.ts +0 -58
  57. package/lib/endpoints/workspaces.ts +0 -121
  58. package/lib/endpoints/workspacesVersions.ts +0 -38
  59. package/lib/events.test.ts +0 -89
  60. package/lib/events.ts +0 -222
  61. package/lib/fetcher.test.ts +0 -246
  62. package/lib/fetcher.ts +0 -198
  63. package/lib/types.ts +0 -21
  64. package/lib/utils.test.ts +0 -38
  65. package/lib/utils.ts +0 -51
  66. package/tsconfig.json +0 -21
package/README.md ADDED
@@ -0,0 +1,250 @@
1
+ # @prismeai/sdk
2
+
3
+ Official Node.js SDK for the [Prisme.ai](https://prisme.ai) Agent Factory and Storage APIs.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @prismeai/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { PrismeAI } from '@prismeai/sdk';
15
+
16
+ const client = new PrismeAI({
17
+ apiKey: process.env.PRISMEAI_API_KEY,
18
+ environment: 'production', // or 'sandbox'
19
+ agentFactoryWorkspaceId: 'your-workspace-id',
20
+ storageWorkspaceId: 'your-storage-workspace-id', // optional
21
+ });
22
+ ```
23
+
24
+ ## Authentication
25
+
26
+ The SDK supports two authentication methods:
27
+
28
+ ```typescript
29
+ // API Key (recommended for server-side)
30
+ const client = new PrismeAI({
31
+ apiKey: 'sk-...',
32
+ agentFactoryWorkspaceId: 'ws-id',
33
+ });
34
+
35
+ // Bearer Token (for user-scoped access)
36
+ const client = new PrismeAI({
37
+ bearerToken: 'eyJ...',
38
+ agentFactoryWorkspaceId: 'ws-id',
39
+ });
40
+ ```
41
+
42
+ Environment variables `PRISMEAI_API_KEY` and `PRISMEAI_BEARER_TOKEN` are also supported.
43
+
44
+ ## Usage Examples
45
+
46
+ ### Agents
47
+
48
+ ```typescript
49
+ // List agents
50
+ const agents = client.agents.list();
51
+ for await (const agent of agents) {
52
+ console.log(agent.name);
53
+ }
54
+
55
+ // Create an agent
56
+ const agent = await client.agents.create({
57
+ name: 'My Agent',
58
+ description: 'A helpful assistant',
59
+ model: 'claude-sonnet-4-20250514',
60
+ instructions: 'You are a helpful assistant.',
61
+ });
62
+
63
+ // Get, update, delete
64
+ const fetched = await client.agents.get(agent.id);
65
+ const updated = await client.agents.update(agent.id, { name: 'Renamed Agent' });
66
+ await client.agents.delete(agent.id);
67
+
68
+ // Publish / discard draft
69
+ await client.agents.publish(agent.id);
70
+ await client.agents.discardDraft(agent.id);
71
+ ```
72
+
73
+ ### Messages
74
+
75
+ ```typescript
76
+ // Send a message (non-streaming)
77
+ const response = await client.agents.messages.send('agent-id', {
78
+ message: 'Hello, how are you?',
79
+ conversationId: 'conv-id', // optional
80
+ });
81
+ console.log(response);
82
+
83
+ // Stream a message (SSE)
84
+ const stream = await client.agents.messages.stream('agent-id', {
85
+ message: 'Tell me a story',
86
+ });
87
+ for await (const event of stream) {
88
+ if (event.type === 'delta') {
89
+ process.stdout.write(event.content ?? '');
90
+ }
91
+ }
92
+ ```
93
+
94
+ ### Conversations
95
+
96
+ ```typescript
97
+ // List conversations
98
+ for await (const conv of client.agents.conversations.list()) {
99
+ console.log(conv.id, conv.title);
100
+ }
101
+
102
+ // Create and manage
103
+ const conv = await client.agents.conversations.create({ agentId: 'agent-id' });
104
+ await client.agents.conversations.update(conv.id, { title: 'New Title' });
105
+
106
+ // Get messages in a conversation
107
+ for await (const msg of client.agents.conversations.messages(conv.id)) {
108
+ console.log(msg.role, msg.content);
109
+ }
110
+ ```
111
+
112
+ ### A2A (Agent-to-Agent)
113
+
114
+ ```typescript
115
+ // Send a message to another agent
116
+ const result = await client.agents.a2a.send('target-agent-id', {
117
+ message: 'Perform this task',
118
+ });
119
+
120
+ // Stream A2A response
121
+ const a2aStream = await client.agents.a2a.sendSubscribe('target-agent-id', {
122
+ message: 'Perform this task',
123
+ });
124
+ for await (const event of a2aStream) {
125
+ console.log(event);
126
+ }
127
+
128
+ // Get agent card
129
+ const card = await client.agents.a2a.getCard('agent-id');
130
+ ```
131
+
132
+ ### Files (Storage)
133
+
134
+ ```typescript
135
+ // Upload a file
136
+ const file = await client.storage.files.upload(
137
+ Buffer.from('Hello World'),
138
+ { filename: 'hello.txt' },
139
+ );
140
+
141
+ // List files
142
+ for await (const f of client.storage.files.list()) {
143
+ console.log(f.name, f.size);
144
+ }
145
+
146
+ // Download
147
+ const response = await client.storage.files.download(file.id);
148
+ ```
149
+
150
+ ### Vector Stores (Storage)
151
+
152
+ ```typescript
153
+ // Create a vector store
154
+ const vs = await client.storage.vectorStores.create({
155
+ name: 'My Knowledge Base',
156
+ });
157
+
158
+ // Search
159
+ const results = await client.storage.vectorStores.search(vs.id, {
160
+ query: 'How do I reset my password?',
161
+ limit: 5,
162
+ });
163
+
164
+ // Manage files in a vector store
165
+ await client.storage.vectorStores.files.add(vs.id, {
166
+ fileId: 'file-id',
167
+ });
168
+
169
+ for await (const file of client.storage.vectorStores.files.list(vs.id)) {
170
+ console.log(file.name, file.status);
171
+ }
172
+ ```
173
+
174
+ ### Tasks
175
+
176
+ ```typescript
177
+ for await (const task of client.tasks.list({ status: 'running' })) {
178
+ console.log(task.id, task.status);
179
+ }
180
+
181
+ const task = await client.tasks.get('task-id');
182
+ await client.tasks.cancel('task-id');
183
+ ```
184
+
185
+ ### Pagination
186
+
187
+ All list methods return async iterables that auto-paginate:
188
+
189
+ ```typescript
190
+ // Auto-pagination with for-await
191
+ for await (const agent of client.agents.list()) {
192
+ console.log(agent.name);
193
+ }
194
+
195
+ // Manual page control
196
+ const page = client.agents.list({ limit: 10 });
197
+ const firstPage = await page.getPage();
198
+ console.log(firstPage.data, firstPage.total);
199
+
200
+ // Collect all into array
201
+ const allAgents = await client.agents.list().toArray();
202
+ ```
203
+
204
+ ### Error Handling
205
+
206
+ ```typescript
207
+ import {
208
+ PrismeAIError,
209
+ AuthenticationError,
210
+ RateLimitError,
211
+ NotFoundError,
212
+ ValidationError,
213
+ } from '@prismeai/sdk';
214
+
215
+ try {
216
+ await client.agents.get('nonexistent');
217
+ } catch (error) {
218
+ if (error instanceof NotFoundError) {
219
+ console.log('Agent not found');
220
+ } else if (error instanceof RateLimitError) {
221
+ console.log(`Rate limited, retry after ${error.retryAfter}ms`);
222
+ } else if (error instanceof AuthenticationError) {
223
+ console.log('Invalid credentials');
224
+ } else if (error instanceof PrismeAIError) {
225
+ console.log(error.message, error.status);
226
+ }
227
+ }
228
+ ```
229
+
230
+ ## Configuration
231
+
232
+ | Option | Type | Default | Description |
233
+ |--------|------|---------|-------------|
234
+ | `apiKey` | `string` | `PRISMEAI_API_KEY` env | API key for authentication |
235
+ | `bearerToken` | `string` | `PRISMEAI_BEARER_TOKEN` env | Bearer token for auth |
236
+ | `environment` | `string` | `'production'` | `'sandbox'` or `'production'` |
237
+ | `baseURL` | `string` | — | Custom API base URL (overrides environment) |
238
+ | `agentFactoryWorkspaceId` | `string` | **required** | Workspace ID for Agent Factory |
239
+ | `storageWorkspaceId` | `string` | — | Workspace ID for Storage API |
240
+ | `timeout` | `number` | `60000` | Request timeout in ms |
241
+ | `maxRetries` | `number` | `2` | Max retries on 429/5xx |
242
+
243
+ ## Requirements
244
+
245
+ - Node.js 18+
246
+ - No runtime dependencies (uses native `fetch`)
247
+
248
+ ## License
249
+
250
+ MIT