@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/dist/index.d.ts CHANGED
@@ -1,7 +1,1129 @@
1
- export * from './lib/api';
2
- export * from './lib/ApiError';
3
- export * from './lib/events';
4
- export * from './lib/fetcher';
5
- export * from './lib/HTTPError';
6
- export * from './lib/types';
7
- export { default } from './lib/api';
1
+ interface HttpClientOptions {
2
+ baseURL: string;
3
+ headers: Record<string, string>;
4
+ timeout?: number;
5
+ maxRetries?: number;
6
+ }
7
+ interface RequestOptions {
8
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
9
+ path: string;
10
+ query?: Record<string, unknown>;
11
+ body?: unknown;
12
+ headers?: Record<string, string>;
13
+ timeout?: number;
14
+ signal?: AbortSignal;
15
+ raw?: boolean;
16
+ }
17
+ declare class HttpClient {
18
+ readonly baseURL: string;
19
+ private readonly defaultHeaders;
20
+ private readonly timeout;
21
+ private readonly maxRetries;
22
+ constructor(options: HttpClientOptions);
23
+ request<T>(options: RequestOptions): Promise<T>;
24
+ requestRaw(options: RequestOptions): Promise<Response>;
25
+ get<T>(path: string, query?: Record<string, unknown>, options?: Partial<RequestOptions>): Promise<T>;
26
+ post<T>(path: string, body?: unknown, options?: Partial<RequestOptions>): Promise<T>;
27
+ put<T>(path: string, body?: unknown, options?: Partial<RequestOptions>): Promise<T>;
28
+ patch<T>(path: string, body?: unknown, options?: Partial<RequestOptions>): Promise<T>;
29
+ delete<T>(path: string, query?: Record<string, unknown>, options?: Partial<RequestOptions>): Promise<T>;
30
+ private buildURL;
31
+ private getRetryDelay;
32
+ private safeParseBody;
33
+ }
34
+
35
+ interface PageResponse<T> {
36
+ data: T[];
37
+ total?: number;
38
+ page?: number;
39
+ limit?: number;
40
+ hasMore?: boolean;
41
+ }
42
+ interface PaginationParams {
43
+ page?: number;
44
+ limit?: number;
45
+ }
46
+ /**
47
+ * Async-iterable page iterator.
48
+ * Supports: for await...of (item-by-item), .getPage(), .toArray()
49
+ */
50
+ declare class PageIterator<T> implements AsyncIterable<T> {
51
+ private httpClient;
52
+ private options;
53
+ private pageSize;
54
+ private currentPage;
55
+ private extractData;
56
+ constructor(httpClient: HttpClient, options: RequestOptions, extractData: (body: unknown) => PageResponse<T>, pageSize?: number, startPage?: number);
57
+ /**
58
+ * Fetch a specific page.
59
+ */
60
+ getPage(page?: number): Promise<PageResponse<T>>;
61
+ /**
62
+ * Collect all items across all pages into a single array.
63
+ */
64
+ toArray(): Promise<T[]>;
65
+ [Symbol.asyncIterator](): AsyncIterator<T>;
66
+ }
67
+
68
+ type QueryParams = Record<string, any>;
69
+ /**
70
+ * Abstract base class for all API resource classes.
71
+ * Provides common HTTP methods and pagination helpers.
72
+ */
73
+ declare abstract class BaseResource {
74
+ protected readonly httpClient: HttpClient;
75
+ constructor(httpClient: HttpClient);
76
+ protected _get<T>(path: string, query?: QueryParams): Promise<T>;
77
+ protected _post<T>(path: string, body?: unknown, options?: Partial<RequestOptions>): Promise<T>;
78
+ protected _put<T>(path: string, body?: unknown): Promise<T>;
79
+ protected _patch<T>(path: string, body?: unknown): Promise<T>;
80
+ protected _del<T>(path: string, query?: QueryParams): Promise<T>;
81
+ protected _paginate<T>(path: string, query?: QueryParams, pagination?: PaginationParams, extractor?: (body: unknown) => PageResponse<T>): PageIterator<T>;
82
+ /**
83
+ * Build a path with workspace ID prefix.
84
+ */
85
+ protected buildPath(workspaceId: string, ...segments: string[]): string;
86
+ }
87
+
88
+ /** ISO 8601 timestamp string */
89
+ type Timestamp = string;
90
+ /** Localized text — either a plain string or { en: "...", fr: "...", ... } */
91
+ type LocalizedText = string | Record<string, string>;
92
+
93
+ interface Agent {
94
+ id: string;
95
+ slug: string;
96
+ name: LocalizedText;
97
+ description?: LocalizedText;
98
+ photo?: string;
99
+ status?: 'draft' | 'published';
100
+ labels?: string[];
101
+ model?: string;
102
+ systemPrompt?: string;
103
+ temperature?: number;
104
+ maxTokens?: number;
105
+ subAgents?: SubAgentConfig[];
106
+ guardrails?: GuardrailConfig[];
107
+ toolPermissions?: ToolPermissions;
108
+ tools?: AgentTool[];
109
+ discovery?: AgentDiscovery;
110
+ createdAt?: Timestamp;
111
+ updatedAt?: Timestamp;
112
+ createdBy?: string;
113
+ updatedBy?: string;
114
+ [key: string]: unknown;
115
+ }
116
+ interface AgentCreateParams {
117
+ name: LocalizedText;
118
+ description?: LocalizedText;
119
+ photo?: string;
120
+ labels?: string[];
121
+ model?: string;
122
+ systemPrompt?: string;
123
+ temperature?: number;
124
+ maxTokens?: number;
125
+ subAgents?: SubAgentConfig[];
126
+ guardrails?: GuardrailConfig[];
127
+ toolPermissions?: ToolPermissions;
128
+ tools?: AgentTool[];
129
+ discovery?: AgentDiscovery;
130
+ [key: string]: unknown;
131
+ }
132
+ interface AgentUpdateParams {
133
+ name?: LocalizedText;
134
+ description?: LocalizedText;
135
+ photo?: string;
136
+ labels?: string[];
137
+ model?: string;
138
+ systemPrompt?: string;
139
+ temperature?: number;
140
+ maxTokens?: number;
141
+ subAgents?: SubAgentConfig[];
142
+ guardrails?: GuardrailConfig[];
143
+ toolPermissions?: ToolPermissions;
144
+ tools?: AgentTool[];
145
+ discovery?: AgentDiscovery;
146
+ [key: string]: unknown;
147
+ }
148
+ interface AgentListParams {
149
+ page?: number;
150
+ limit?: number;
151
+ labels?: string;
152
+ search?: string;
153
+ }
154
+ interface SubAgentConfig {
155
+ agentId: string;
156
+ name?: string;
157
+ description?: string;
158
+ }
159
+ type GuardrailType = 'injection-detect' | 'toxicity-check' | 'pii-detect' | 'hallucination-check' | 'topic-guard' | 'action-approval';
160
+ interface GuardrailConfig {
161
+ id: string;
162
+ type: 'input' | 'output' | 'action';
163
+ guardrailType: GuardrailType;
164
+ config?: Record<string, unknown>;
165
+ enabled?: boolean;
166
+ }
167
+ type ToolPolicy = 'auto' | 'always_ask' | 'ask_external' | 'ask_first' | 'deny';
168
+ interface ToolPermissions {
169
+ default: ToolPolicy;
170
+ tools?: ToolRule[];
171
+ }
172
+ interface ToolRule {
173
+ tool: string;
174
+ policy: ToolPolicy;
175
+ conditions?: Record<string, unknown>;
176
+ approvers?: Approver[];
177
+ }
178
+ interface Approver {
179
+ type: 'user' | 'group' | 'owner';
180
+ id?: string;
181
+ }
182
+ interface AgentTool {
183
+ id?: string;
184
+ name: string;
185
+ description?: string;
186
+ type?: string;
187
+ config?: Record<string, unknown>;
188
+ }
189
+ interface AgentDiscovery {
190
+ enabled?: boolean;
191
+ categories?: string[];
192
+ featured?: boolean;
193
+ }
194
+
195
+ /**
196
+ * SSE (Server-Sent Events) stream parser.
197
+ * Implements AsyncIterable<T> for `for await...of` usage.
198
+ */
199
+ declare class SSEStream<T> implements AsyncIterable<T> {
200
+ private response;
201
+ private controller;
202
+ private _done;
203
+ constructor(response: Response, controller: AbortController);
204
+ get done(): boolean;
205
+ abort(): void;
206
+ [Symbol.asyncIterator](): AsyncIterator<T>;
207
+ }
208
+
209
+ interface MessageSendParams {
210
+ text?: string;
211
+ parts?: MessagePart[];
212
+ conversationId?: string;
213
+ context?: Record<string, unknown>;
214
+ [key: string]: unknown;
215
+ }
216
+ interface MessagePart {
217
+ type: 'text' | 'image' | 'file' | 'audio';
218
+ text?: string;
219
+ url?: string;
220
+ mimeType?: string;
221
+ data?: string;
222
+ }
223
+ interface MessageResponse {
224
+ output?: string;
225
+ conversationId?: string;
226
+ taskId?: string;
227
+ [key: string]: unknown;
228
+ }
229
+ /**
230
+ * SSE stream event types emitted during message streaming.
231
+ */
232
+ type StreamEvent = StreamEventDelta | StreamEventTaskStatus | StreamEventTaskCompleted | StreamEventToolCall | StreamEventToolResult | StreamEventError;
233
+ interface StreamEventDelta {
234
+ type: 'delta';
235
+ text?: string;
236
+ [key: string]: unknown;
237
+ }
238
+ interface StreamEventTaskStatus {
239
+ type: 'task.status';
240
+ taskId: string;
241
+ status: string;
242
+ [key: string]: unknown;
243
+ }
244
+ interface StreamEventTaskCompleted {
245
+ type: 'task.completed';
246
+ taskId: string;
247
+ output?: string;
248
+ conversationId?: string;
249
+ [key: string]: unknown;
250
+ }
251
+ interface StreamEventToolCall {
252
+ type: 'tool.call';
253
+ toolName: string;
254
+ toolId?: string;
255
+ arguments?: Record<string, unknown>;
256
+ [key: string]: unknown;
257
+ }
258
+ interface StreamEventToolResult {
259
+ type: 'tool.result';
260
+ toolId?: string;
261
+ result?: unknown;
262
+ [key: string]: unknown;
263
+ }
264
+ interface StreamEventError {
265
+ type: 'error';
266
+ error: string;
267
+ code?: string;
268
+ [key: string]: unknown;
269
+ }
270
+
271
+ declare class Messages extends BaseResource {
272
+ private readonly workspaceId;
273
+ constructor(httpClient: HttpClient, workspaceId: string);
274
+ private path;
275
+ /** Send a message to an agent and get a complete response. */
276
+ send(agentId: string, params: MessageSendParams): Promise<MessageResponse>;
277
+ /** Send a message and receive the response as an SSE stream. */
278
+ stream(agentId: string, params: MessageSendParams): Promise<SSEStream<StreamEvent>>;
279
+ }
280
+
281
+ interface Conversation {
282
+ id: string;
283
+ agentId?: string;
284
+ name?: string;
285
+ userId?: string;
286
+ metadata?: Record<string, unknown>;
287
+ createdAt?: Timestamp;
288
+ updatedAt?: Timestamp;
289
+ [key: string]: unknown;
290
+ }
291
+ interface ConversationCreateParams {
292
+ agentId?: string;
293
+ name?: string;
294
+ metadata?: Record<string, unknown>;
295
+ }
296
+ interface ConversationUpdateParams {
297
+ name?: string;
298
+ metadata?: Record<string, unknown>;
299
+ }
300
+ interface ConversationListParams {
301
+ page?: number;
302
+ limit?: number;
303
+ agentId?: string;
304
+ }
305
+ interface ConversationMessage {
306
+ id: string;
307
+ role: 'user' | 'assistant' | 'system';
308
+ content: string;
309
+ parts?: Array<{
310
+ type: string;
311
+ text?: string;
312
+ url?: string;
313
+ }>;
314
+ createdAt?: Timestamp;
315
+ [key: string]: unknown;
316
+ }
317
+ interface ConversationShareParams {
318
+ public?: boolean;
319
+ users?: string[];
320
+ groups?: string[];
321
+ }
322
+
323
+ declare class Conversations extends BaseResource {
324
+ private readonly workspaceId;
325
+ constructor(httpClient: HttpClient, workspaceId: string);
326
+ private path;
327
+ /** List conversations. */
328
+ list(params?: ConversationListParams): PageIterator<Conversation>;
329
+ /** Create a new conversation. */
330
+ create(params?: ConversationCreateParams): Promise<Conversation>;
331
+ /** Get a conversation by ID. */
332
+ get(conversationId: string): Promise<Conversation>;
333
+ /** Update a conversation. */
334
+ update(conversationId: string, params: ConversationUpdateParams): Promise<Conversation>;
335
+ /** Delete a conversation. */
336
+ delete(conversationId: string): Promise<void>;
337
+ /** List messages in a conversation. */
338
+ messages(conversationId: string, params?: {
339
+ page?: number;
340
+ limit?: number;
341
+ }): PageIterator<ConversationMessage>;
342
+ /** Share a conversation. */
343
+ share(conversationId: string, params: ConversationShareParams): Promise<void>;
344
+ }
345
+
346
+ interface Tool {
347
+ id?: string;
348
+ name: string;
349
+ description?: string;
350
+ type?: string;
351
+ schema?: Record<string, unknown>;
352
+ config?: Record<string, unknown>;
353
+ [key: string]: unknown;
354
+ }
355
+ interface ToolCreateParams {
356
+ name: string;
357
+ description?: string;
358
+ type?: string;
359
+ schema?: Record<string, unknown>;
360
+ config?: Record<string, unknown>;
361
+ }
362
+ interface ToolListParams {
363
+ page?: number;
364
+ limit?: number;
365
+ }
366
+
367
+ declare class Tools extends BaseResource {
368
+ private readonly workspaceId;
369
+ constructor(httpClient: HttpClient, workspaceId: string);
370
+ private path;
371
+ /** List tools available for agents. */
372
+ list(params?: ToolListParams): PageIterator<Tool>;
373
+ /** Create a new tool. */
374
+ create(params: ToolCreateParams): Promise<Tool>;
375
+ /** Get a tool by ID. */
376
+ get(toolId: string): Promise<Tool>;
377
+ }
378
+
379
+ interface AccessEntry {
380
+ id: string;
381
+ userId?: string;
382
+ email?: string;
383
+ role: string;
384
+ grantedAt?: Timestamp;
385
+ grantedBy?: string;
386
+ [key: string]: unknown;
387
+ }
388
+ interface AccessGrantParams {
389
+ email?: string;
390
+ userId?: string;
391
+ role: string;
392
+ }
393
+ interface AccessRequest {
394
+ id: string;
395
+ userId: string;
396
+ email?: string;
397
+ status: 'pending' | 'approved' | 'rejected';
398
+ createdAt?: Timestamp;
399
+ [key: string]: unknown;
400
+ }
401
+ interface AccessRequestHandleParams {
402
+ action: 'approve' | 'reject';
403
+ }
404
+ interface AccessListParams {
405
+ page?: number;
406
+ limit?: number;
407
+ }
408
+
409
+ declare class Access extends BaseResource {
410
+ private readonly workspaceId;
411
+ constructor(httpClient: HttpClient, workspaceId: string);
412
+ private path;
413
+ /** List access entries for an agent. */
414
+ list(agentId: string, params?: AccessListParams): PageIterator<AccessEntry>;
415
+ /** Grant access to an agent. */
416
+ grant(agentId: string, params: AccessGrantParams): Promise<AccessEntry>;
417
+ /** Revoke access to an agent. */
418
+ revoke(agentId: string, accessId: string): Promise<void>;
419
+ /** Request access to an agent. */
420
+ requestAccess(agentId: string): Promise<AccessRequest>;
421
+ /** List access requests for an agent. */
422
+ listRequests(agentId: string, params?: AccessListParams): PageIterator<AccessRequest>;
423
+ /** Handle an access request (approve/reject). */
424
+ handleRequest(agentId: string, requestId: string, params: AccessRequestHandleParams): Promise<AccessRequest>;
425
+ }
426
+
427
+ interface AnalyticsParams {
428
+ period?: 'day' | 'week' | 'month' | 'year';
429
+ granularity?: 'hour' | 'day' | 'week' | 'month';
430
+ startDate?: string;
431
+ endDate?: string;
432
+ }
433
+ interface AnalyticsResponse {
434
+ conversations?: number;
435
+ messages?: number;
436
+ uniqueUsers?: number;
437
+ avgResponseTime?: number;
438
+ timeSeries?: AnalyticsDataPoint[];
439
+ [key: string]: unknown;
440
+ }
441
+ interface AnalyticsDataPoint {
442
+ timestamp: string;
443
+ conversations?: number;
444
+ messages?: number;
445
+ uniqueUsers?: number;
446
+ [key: string]: unknown;
447
+ }
448
+
449
+ declare class Analytics extends BaseResource {
450
+ private readonly workspaceId;
451
+ constructor(httpClient: HttpClient, workspaceId: string);
452
+ private path;
453
+ /** Get analytics for an agent. */
454
+ get(agentId: string, params?: AnalyticsParams): Promise<AnalyticsResponse>;
455
+ }
456
+
457
+ interface Evaluation {
458
+ id: string;
459
+ agentId: string;
460
+ name?: string;
461
+ status?: string;
462
+ results?: Record<string, unknown>;
463
+ createdAt?: Timestamp;
464
+ [key: string]: unknown;
465
+ }
466
+ interface EvaluationCreateParams {
467
+ name?: string;
468
+ dataset?: Array<{
469
+ input: string;
470
+ expectedOutput?: string;
471
+ }>;
472
+ config?: Record<string, unknown>;
473
+ }
474
+ interface EvaluationListParams {
475
+ page?: number;
476
+ limit?: number;
477
+ }
478
+ declare class Evaluations extends BaseResource {
479
+ private readonly workspaceId;
480
+ constructor(httpClient: HttpClient, workspaceId: string);
481
+ private path;
482
+ /** List evaluations for an agent. */
483
+ list(agentId: string, params?: EvaluationListParams): PageIterator<Evaluation>;
484
+ /** Create a new evaluation. */
485
+ create(agentId: string, params: EvaluationCreateParams): Promise<Evaluation>;
486
+ }
487
+
488
+ interface A2ASendParams {
489
+ message: string;
490
+ taskId?: string;
491
+ context?: Record<string, unknown>;
492
+ [key: string]: unknown;
493
+ }
494
+ interface A2AResponse {
495
+ taskId: string;
496
+ output?: string;
497
+ status?: string;
498
+ [key: string]: unknown;
499
+ }
500
+ interface A2ACard {
501
+ name: string;
502
+ description?: string;
503
+ url?: string;
504
+ capabilities?: string[];
505
+ [key: string]: unknown;
506
+ }
507
+ interface A2AExtendedCard extends A2ACard {
508
+ tools?: Array<{
509
+ name: string;
510
+ description?: string;
511
+ }>;
512
+ subAgents?: Array<{
513
+ name: string;
514
+ agentId: string;
515
+ }>;
516
+ [key: string]: unknown;
517
+ }
518
+ type A2AStreamEvent = {
519
+ type: string;
520
+ [key: string]: unknown;
521
+ };
522
+
523
+ declare class A2A extends BaseResource {
524
+ private readonly workspaceId;
525
+ constructor(httpClient: HttpClient, workspaceId: string);
526
+ private path;
527
+ /** Send a message via A2A protocol. */
528
+ send(agentId: string, params: A2ASendParams): Promise<A2AResponse>;
529
+ /** Send a message and subscribe to SSE events (A2A protocol). */
530
+ sendSubscribe(agentId: string, params: A2ASendParams): Promise<SSEStream<A2AStreamEvent>>;
531
+ /** Get the A2A agent card. */
532
+ getCard(agentId: string): Promise<A2ACard>;
533
+ /** Get the extended A2A agent card with tools and sub-agents. */
534
+ getExtendedCard(agentId: string): Promise<A2AExtendedCard>;
535
+ }
536
+
537
+ declare class Agents extends BaseResource {
538
+ readonly messages: Messages;
539
+ readonly conversations: Conversations;
540
+ readonly tools: Tools;
541
+ readonly access: Access;
542
+ readonly analytics: Analytics;
543
+ readonly evaluations: Evaluations;
544
+ readonly a2a: A2A;
545
+ private readonly workspaceId;
546
+ constructor(httpClient: HttpClient, workspaceId: string);
547
+ private path;
548
+ /** List all agents. */
549
+ list(params?: AgentListParams): PageIterator<Agent>;
550
+ /** Create a new agent. */
551
+ create(params: AgentCreateParams): Promise<Agent>;
552
+ /** Get an agent by ID. */
553
+ get(agentId: string): Promise<Agent>;
554
+ /** Update an agent. */
555
+ update(agentId: string, params: AgentUpdateParams): Promise<Agent>;
556
+ /** Delete an agent. */
557
+ delete(agentId: string): Promise<void>;
558
+ /** Publish an agent (promote draft to published). */
559
+ publish(agentId: string): Promise<Agent>;
560
+ /** Discard the current draft. */
561
+ discardDraft(agentId: string): Promise<Agent>;
562
+ /** Update agent discovery settings. */
563
+ discovery(agentId: string, params: {
564
+ enabled?: boolean;
565
+ categories?: string[];
566
+ featured?: boolean;
567
+ }): Promise<Agent>;
568
+ /** Export an agent configuration. */
569
+ export(agentId: string): Promise<Record<string, unknown>>;
570
+ /** Import an agent configuration. */
571
+ import(config: Record<string, unknown>): Promise<Agent>;
572
+ }
573
+
574
+ interface Task {
575
+ id: string;
576
+ agentId?: string;
577
+ conversationId?: string;
578
+ status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
579
+ output?: string;
580
+ error?: string;
581
+ createdAt?: Timestamp;
582
+ updatedAt?: Timestamp;
583
+ [key: string]: unknown;
584
+ }
585
+ interface TaskListParams {
586
+ page?: number;
587
+ limit?: number;
588
+ agentId?: string;
589
+ status?: string;
590
+ }
591
+
592
+ declare class Tasks extends BaseResource {
593
+ private readonly workspaceId;
594
+ constructor(httpClient: HttpClient, workspaceId: string);
595
+ private path;
596
+ /** List tasks. */
597
+ list(params?: TaskListParams): PageIterator<Task>;
598
+ /** Get a task by ID. */
599
+ get(taskId: string): Promise<Task>;
600
+ /** Cancel a running task. */
601
+ cancel(taskId: string): Promise<Task>;
602
+ }
603
+
604
+ interface Artifact {
605
+ id: string;
606
+ name?: string;
607
+ type?: string;
608
+ content?: unknown;
609
+ conversationId?: string;
610
+ taskId?: string;
611
+ createdAt?: Timestamp;
612
+ updatedAt?: Timestamp;
613
+ [key: string]: unknown;
614
+ }
615
+ interface ArtifactUpdateParams {
616
+ name?: string;
617
+ content?: unknown;
618
+ [key: string]: unknown;
619
+ }
620
+ interface ArtifactListParams {
621
+ page?: number;
622
+ limit?: number;
623
+ conversationId?: string;
624
+ }
625
+ interface ArtifactShareParams {
626
+ public?: boolean;
627
+ users?: string[];
628
+ }
629
+
630
+ declare class Artifacts extends BaseResource {
631
+ private readonly workspaceId;
632
+ constructor(httpClient: HttpClient, workspaceId: string);
633
+ private path;
634
+ list(params?: ArtifactListParams): PageIterator<Artifact>;
635
+ get(artifactId: string): Promise<Artifact>;
636
+ update(artifactId: string, params: ArtifactUpdateParams): Promise<Artifact>;
637
+ delete(artifactId: string): Promise<void>;
638
+ share(artifactId: string, params: ArtifactShareParams): Promise<void>;
639
+ }
640
+
641
+ interface Share {
642
+ id: string;
643
+ type?: string;
644
+ resourceId?: string;
645
+ userId?: string;
646
+ public?: boolean;
647
+ createdAt?: Timestamp;
648
+ [key: string]: unknown;
649
+ }
650
+ interface ShareListParams {
651
+ page?: number;
652
+ limit?: number;
653
+ type?: string;
654
+ }
655
+
656
+ declare class Shares extends BaseResource {
657
+ private readonly workspaceId;
658
+ constructor(httpClient: HttpClient, workspaceId: string);
659
+ private path;
660
+ list(params?: ShareListParams): PageIterator<Share>;
661
+ get(shareId: string): Promise<Share>;
662
+ }
663
+
664
+ interface RatingCreateParams {
665
+ agentId: string;
666
+ conversationId?: string;
667
+ messageId?: string;
668
+ rating: number;
669
+ feedback?: string;
670
+ }
671
+ interface Rating {
672
+ id: string;
673
+ rating: number;
674
+ feedback?: string;
675
+ [key: string]: unknown;
676
+ }
677
+ declare class Ratings extends BaseResource {
678
+ private readonly workspaceId;
679
+ constructor(httpClient: HttpClient, workspaceId: string);
680
+ private path;
681
+ /** Submit a rating for an agent response. */
682
+ create(params: RatingCreateParams): Promise<Rating>;
683
+ }
684
+
685
+ interface ActivityEntry {
686
+ id: string;
687
+ type: string;
688
+ agentId?: string;
689
+ userId?: string;
690
+ description?: string;
691
+ createdAt?: Timestamp;
692
+ [key: string]: unknown;
693
+ }
694
+ interface ActivityListParams {
695
+ page?: number;
696
+ limit?: number;
697
+ agentId?: string;
698
+ type?: string;
699
+ }
700
+ declare class Activity extends BaseResource {
701
+ private readonly workspaceId;
702
+ constructor(httpClient: HttpClient, workspaceId: string);
703
+ private path;
704
+ /** List recent activity. */
705
+ list(params?: ActivityListParams): PageIterator<ActivityEntry>;
706
+ }
707
+
708
+ interface Profile {
709
+ id: string;
710
+ name?: string;
711
+ email?: string;
712
+ photo?: string;
713
+ [key: string]: unknown;
714
+ }
715
+ interface ProfileListParams {
716
+ page?: number;
717
+ limit?: number;
718
+ search?: string;
719
+ }
720
+ declare class Profiles extends BaseResource {
721
+ private readonly workspaceId;
722
+ constructor(httpClient: HttpClient, workspaceId: string);
723
+ private path;
724
+ /** List user profiles. */
725
+ list(params?: ProfileListParams): PageIterator<Profile>;
726
+ }
727
+
728
+ interface OrgAgentListParams {
729
+ page?: number;
730
+ limit?: number;
731
+ search?: string;
732
+ }
733
+ declare class Orgs extends BaseResource {
734
+ private readonly workspaceId;
735
+ constructor(httpClient: HttpClient, workspaceId: string);
736
+ private path;
737
+ /** List agents available in the organization. */
738
+ listAgents(params?: OrgAgentListParams): PageIterator<Agent>;
739
+ }
740
+
741
+ /**
742
+ * Supported input types for file uploads.
743
+ */
744
+ type FileInput = Buffer | ArrayBuffer | Uint8Array | ReadableStream | Blob | string;
745
+ interface FileUploadOptions {
746
+ filename?: string;
747
+ contentType?: string;
748
+ }
749
+
750
+ interface FileObject {
751
+ id: string;
752
+ name: string;
753
+ url?: string;
754
+ mimeType?: string;
755
+ size?: number;
756
+ metadata?: Record<string, unknown>;
757
+ createdAt?: Timestamp;
758
+ updatedAt?: Timestamp;
759
+ [key: string]: unknown;
760
+ }
761
+ interface FileUploadParams {
762
+ name?: string;
763
+ metadata?: Record<string, unknown>;
764
+ }
765
+ interface FileListParams {
766
+ page?: number;
767
+ limit?: number;
768
+ search?: string;
769
+ }
770
+
771
+ declare class Files extends BaseResource {
772
+ private readonly workspaceId;
773
+ constructor(httpClient: HttpClient, workspaceId: string);
774
+ private path;
775
+ /** List files. */
776
+ list(params?: FileListParams): PageIterator<FileObject>;
777
+ /** Upload a file. */
778
+ upload(file: FileInput, params?: FileUploadParams & FileUploadOptions): Promise<FileObject>;
779
+ /** Get file metadata. */
780
+ get(fileId: string): Promise<FileObject>;
781
+ /** Delete a file. */
782
+ delete(fileId: string): Promise<void>;
783
+ /** Download a file. Returns the raw Response for streaming. */
784
+ download(fileId: string): Promise<Response>;
785
+ }
786
+
787
+ interface VectorStore {
788
+ id: string;
789
+ name: string;
790
+ description?: string;
791
+ status?: string;
792
+ documentCount?: number;
793
+ config?: VectorStoreConfig;
794
+ createdAt?: Timestamp;
795
+ updatedAt?: Timestamp;
796
+ [key: string]: unknown;
797
+ }
798
+ interface VectorStoreConfig {
799
+ embeddingModel?: string;
800
+ chunkSize?: number;
801
+ chunkOverlap?: number;
802
+ [key: string]: unknown;
803
+ }
804
+ interface VectorStoreCreateParams {
805
+ name: string;
806
+ description?: string;
807
+ config?: VectorStoreConfig;
808
+ }
809
+ interface VectorStoreUpdateParams {
810
+ name?: string;
811
+ description?: string;
812
+ config?: VectorStoreConfig;
813
+ }
814
+ interface VectorStoreListParams {
815
+ page?: number;
816
+ limit?: number;
817
+ }
818
+ interface VectorStoreSearchParams {
819
+ query: string;
820
+ limit?: number;
821
+ filters?: Record<string, unknown>;
822
+ scoreThreshold?: number;
823
+ }
824
+ interface VectorStoreSearchResult {
825
+ id: string;
826
+ content: string;
827
+ score: number;
828
+ metadata?: Record<string, unknown>;
829
+ [key: string]: unknown;
830
+ }
831
+ interface VSFile {
832
+ id: string;
833
+ name: string;
834
+ vectorStoreId: string;
835
+ status?: 'pending' | 'processing' | 'completed' | 'failed';
836
+ chunkCount?: number;
837
+ createdAt?: Timestamp;
838
+ [key: string]: unknown;
839
+ }
840
+ interface VSFileAddParams {
841
+ fileId?: string;
842
+ url?: string;
843
+ content?: string;
844
+ name?: string;
845
+ metadata?: Record<string, unknown>;
846
+ }
847
+ interface VSFileListParams {
848
+ page?: number;
849
+ limit?: number;
850
+ }
851
+ interface VSFileChunk {
852
+ id: string;
853
+ content: string;
854
+ metadata?: Record<string, unknown>;
855
+ [key: string]: unknown;
856
+ }
857
+ interface VSAccessEntry {
858
+ id: string;
859
+ userId?: string;
860
+ email?: string;
861
+ role: string;
862
+ [key: string]: unknown;
863
+ }
864
+ interface VSAccessGrantParams {
865
+ email?: string;
866
+ userId?: string;
867
+ role: string;
868
+ }
869
+ interface VSAccessUpdateParams {
870
+ role: string;
871
+ }
872
+
873
+ declare class VSFiles extends BaseResource {
874
+ private readonly workspaceId;
875
+ constructor(httpClient: HttpClient, workspaceId: string);
876
+ private path;
877
+ /** List files in a vector store. */
878
+ list(vectorStoreId: string, params?: VSFileListParams): PageIterator<VSFile>;
879
+ /** Add a file to a vector store. */
880
+ add(vectorStoreId: string, params: VSFileAddParams): Promise<VSFile>;
881
+ /** Update a file in a vector store. */
882
+ update(vectorStoreId: string, fileId: string, params: Partial<VSFileAddParams>): Promise<VSFile>;
883
+ /** Remove a file from a vector store. */
884
+ delete(vectorStoreId: string, fileId: string): Promise<void>;
885
+ /** Get chunks for a file in a vector store. */
886
+ chunks(vectorStoreId: string, fileId: string): Promise<VSFileChunk[]>;
887
+ /** Reindex a specific file in a vector store. */
888
+ reindex(vectorStoreId: string, fileId: string): Promise<void>;
889
+ }
890
+
891
+ declare class VSAccess extends BaseResource {
892
+ private readonly workspaceId;
893
+ constructor(httpClient: HttpClient, workspaceId: string);
894
+ private path;
895
+ /** List access entries for a vector store. */
896
+ list(vectorStoreId: string): PageIterator<VSAccessEntry>;
897
+ /** Grant access to a vector store. */
898
+ grant(vectorStoreId: string, params: VSAccessGrantParams): Promise<VSAccessEntry>;
899
+ /** Update access for a vector store. */
900
+ update(vectorStoreId: string, accessId: string, params: VSAccessUpdateParams): Promise<VSAccessEntry>;
901
+ /** Revoke access to a vector store. */
902
+ revoke(vectorStoreId: string, accessId: string): Promise<void>;
903
+ }
904
+
905
+ declare class VectorStores extends BaseResource {
906
+ readonly files: VSFiles;
907
+ readonly access: VSAccess;
908
+ private readonly workspaceId;
909
+ constructor(httpClient: HttpClient, workspaceId: string);
910
+ private path;
911
+ /** List vector stores. */
912
+ list(params?: VectorStoreListParams): PageIterator<VectorStore>;
913
+ /** Create a new vector store. */
914
+ create(params: VectorStoreCreateParams): Promise<VectorStore>;
915
+ /** Get a vector store by ID. */
916
+ get(vectorStoreId: string): Promise<VectorStore>;
917
+ /** Update a vector store. */
918
+ update(vectorStoreId: string, params: VectorStoreUpdateParams): Promise<VectorStore>;
919
+ /** Delete a vector store. */
920
+ delete(vectorStoreId: string): Promise<void>;
921
+ /** Search a vector store. */
922
+ search(vectorStoreId: string, params: VectorStoreSearchParams): Promise<VectorStoreSearchResult[]>;
923
+ /** Reindex a vector store. */
924
+ reindex(vectorStoreId: string): Promise<void>;
925
+ /** Get crawl status for a vector store. */
926
+ crawlStatus(vectorStoreId: string): Promise<Record<string, unknown>>;
927
+ /** Trigger a recrawl for a vector store. */
928
+ recrawl(vectorStoreId: string): Promise<void>;
929
+ }
930
+
931
+ interface Skill {
932
+ id: string;
933
+ name: string;
934
+ description?: string;
935
+ type?: string;
936
+ config?: Record<string, unknown>;
937
+ schema?: Record<string, unknown>;
938
+ createdAt?: Timestamp;
939
+ updatedAt?: Timestamp;
940
+ [key: string]: unknown;
941
+ }
942
+ interface SkillCreateParams {
943
+ name: string;
944
+ description?: string;
945
+ type?: string;
946
+ config?: Record<string, unknown>;
947
+ schema?: Record<string, unknown>;
948
+ }
949
+ interface SkillUpdateParams {
950
+ name?: string;
951
+ description?: string;
952
+ config?: Record<string, unknown>;
953
+ schema?: Record<string, unknown>;
954
+ }
955
+ interface SkillListParams {
956
+ page?: number;
957
+ limit?: number;
958
+ }
959
+
960
+ declare class Skills extends BaseResource {
961
+ private readonly workspaceId;
962
+ constructor(httpClient: HttpClient, workspaceId: string);
963
+ private path;
964
+ list(params?: SkillListParams): PageIterator<Skill>;
965
+ create(params: SkillCreateParams): Promise<Skill>;
966
+ get(skillId: string): Promise<Skill>;
967
+ update(skillId: string, params: SkillUpdateParams): Promise<Skill>;
968
+ delete(skillId: string): Promise<void>;
969
+ }
970
+
971
+ interface StorageStats {
972
+ totalFiles?: number;
973
+ totalSize?: number;
974
+ vectorStores?: number;
975
+ totalDocuments?: number;
976
+ [key: string]: unknown;
977
+ }
978
+ interface StatsParams {
979
+ period?: string;
980
+ }
981
+
982
+ declare class Stats extends BaseResource {
983
+ private readonly workspaceId;
984
+ constructor(httpClient: HttpClient, workspaceId: string);
985
+ private path;
986
+ /** Get storage statistics. */
987
+ get(params?: StatsParams): Promise<StorageStats>;
988
+ }
989
+
990
+ /**
991
+ * Storage namespace — groups all storage-related resources.
992
+ */
993
+ declare class Storage {
994
+ readonly files: Files;
995
+ readonly vectorStores: VectorStores;
996
+ readonly skills: Skills;
997
+ readonly stats: Stats;
998
+ constructor(httpClient: HttpClient, workspaceId: string);
999
+ }
1000
+
1001
+ interface PrismeAIOptions {
1002
+ /** API key for authentication. Uses x-prismeai-api-key header. */
1003
+ apiKey?: string;
1004
+ /** Bearer token for authentication. Uses Authorization header. */
1005
+ bearerToken?: string;
1006
+ /** Environment name ('sandbox', 'production') or custom base URL. */
1007
+ environment?: string;
1008
+ /** Custom base URL. Overrides environment. */
1009
+ baseURL?: string;
1010
+ /** Agent Factory workspace ID. */
1011
+ agentFactoryWorkspaceId: string;
1012
+ /** Storage workspace ID. */
1013
+ storageWorkspaceId?: string;
1014
+ /** Request timeout in milliseconds. Default: 60000. */
1015
+ timeout?: number;
1016
+ /** Max retry attempts for failed requests. Default: 2. */
1017
+ maxRetries?: number;
1018
+ }
1019
+ /**
1020
+ * Main Prisme.ai SDK client.
1021
+ *
1022
+ * @example
1023
+ * ```typescript
1024
+ * const client = new PrismeAI({
1025
+ * apiKey: 'sk-...',
1026
+ * environment: 'sandbox',
1027
+ * agentFactoryWorkspaceId: '6t5T1iC',
1028
+ * storageWorkspaceId: 'hl2Xm8u',
1029
+ * });
1030
+ *
1031
+ * // List agents
1032
+ * for await (const agent of client.agents.list()) {
1033
+ * console.log(agent.name);
1034
+ * }
1035
+ *
1036
+ * // Stream a message
1037
+ * const stream = await client.agents.messages.stream('agent-id', {
1038
+ * text: 'Hello!',
1039
+ * });
1040
+ * for await (const event of stream) {
1041
+ * if (event.type === 'delta') console.log(event.text);
1042
+ * }
1043
+ * ```
1044
+ */
1045
+ declare class PrismeAI {
1046
+ /** Agent Factory resources. */
1047
+ readonly agents: Agents;
1048
+ readonly tasks: Tasks;
1049
+ readonly artifacts: Artifacts;
1050
+ readonly shares: Shares;
1051
+ readonly ratings: Ratings;
1052
+ readonly activity: Activity;
1053
+ readonly profiles: Profiles;
1054
+ readonly orgs: Orgs;
1055
+ /** Storage resources (files, vector stores, skills, stats). */
1056
+ readonly storage: Storage;
1057
+ private readonly agentFactoryClient;
1058
+ private readonly storageClient;
1059
+ constructor(options: PrismeAIOptions);
1060
+ }
1061
+
1062
+ declare class PrismeAIError extends Error {
1063
+ readonly status: number | undefined;
1064
+ readonly headers: Headers | undefined;
1065
+ readonly body: unknown;
1066
+ constructor(message: string, { status, headers, body }?: {
1067
+ status?: number;
1068
+ headers?: Headers;
1069
+ body?: unknown;
1070
+ });
1071
+ }
1072
+ declare class AuthenticationError extends PrismeAIError {
1073
+ readonly status = 401;
1074
+ constructor(message: string, opts?: {
1075
+ headers?: Headers;
1076
+ body?: unknown;
1077
+ });
1078
+ }
1079
+ declare class PermissionDeniedError extends PrismeAIError {
1080
+ readonly status = 403;
1081
+ constructor(message: string, opts?: {
1082
+ headers?: Headers;
1083
+ body?: unknown;
1084
+ });
1085
+ }
1086
+ declare class NotFoundError extends PrismeAIError {
1087
+ readonly status = 404;
1088
+ constructor(message: string, opts?: {
1089
+ headers?: Headers;
1090
+ body?: unknown;
1091
+ });
1092
+ }
1093
+ declare class ConflictError extends PrismeAIError {
1094
+ readonly status = 409;
1095
+ constructor(message: string, opts?: {
1096
+ headers?: Headers;
1097
+ body?: unknown;
1098
+ });
1099
+ }
1100
+ declare class ValidationError extends PrismeAIError {
1101
+ readonly status = 422;
1102
+ constructor(message: string, opts?: {
1103
+ headers?: Headers;
1104
+ body?: unknown;
1105
+ });
1106
+ }
1107
+ declare class RateLimitError extends PrismeAIError {
1108
+ readonly status = 429;
1109
+ readonly retryAfter: number | undefined;
1110
+ constructor(message: string, opts?: {
1111
+ headers?: Headers;
1112
+ body?: unknown;
1113
+ });
1114
+ }
1115
+ declare class InternalServerError extends PrismeAIError {
1116
+ readonly status = 500;
1117
+ constructor(message: string, opts?: {
1118
+ headers?: Headers;
1119
+ body?: unknown;
1120
+ });
1121
+ }
1122
+ declare class ConnectionError extends PrismeAIError {
1123
+ constructor(message: string);
1124
+ }
1125
+ declare class TimeoutError extends PrismeAIError {
1126
+ constructor(message: string);
1127
+ }
1128
+
1129
+ export { type A2ACard, type A2AExtendedCard, type A2AResponse, type A2ASendParams, type A2AStreamEvent, type AccessEntry, type AccessGrantParams, type AccessListParams, type AccessRequest, type AccessRequestHandleParams, type Agent, type AgentCreateParams, type AgentDiscovery, type AgentListParams, type AgentTool, type AgentUpdateParams, type AnalyticsDataPoint, type AnalyticsParams, type AnalyticsResponse, type Approver, type Artifact, type ArtifactListParams, type ArtifactShareParams, type ArtifactUpdateParams, AuthenticationError, ConflictError, ConnectionError, type Conversation, type ConversationCreateParams, type ConversationListParams, type ConversationMessage, type ConversationShareParams, type ConversationUpdateParams, type FileInput, type FileListParams, type FileObject, type FileUploadOptions, type FileUploadParams, type GuardrailConfig, type GuardrailType, InternalServerError, type LocalizedText, type MessagePart, type MessageResponse, type MessageSendParams, NotFoundError, PageIterator, type PageResponse, type PaginationParams, PermissionDeniedError, PrismeAI, PrismeAIError, type PrismeAIOptions, RateLimitError, SSEStream, type Share, type ShareListParams, type Skill, type SkillCreateParams, type SkillListParams, type SkillUpdateParams, type StatsParams, type StorageStats, type StreamEvent, type StreamEventDelta, type StreamEventError, type StreamEventTaskCompleted, type StreamEventTaskStatus, type StreamEventToolCall, type StreamEventToolResult, type SubAgentConfig, type Task, type TaskListParams, TimeoutError, type Timestamp, type Tool, type ToolCreateParams, type ToolListParams, type ToolPermissions, type ToolPolicy, type ToolRule, type VSAccessEntry, type VSAccessGrantParams, type VSAccessUpdateParams, type VSFile, type VSFileAddParams, type VSFileChunk, type VSFileListParams, ValidationError, type VectorStore, type VectorStoreConfig, type VectorStoreCreateParams, type VectorStoreListParams, type VectorStoreSearchParams, type VectorStoreSearchResult, type VectorStoreUpdateParams };