@dremio/js-sdk 0.41.0 → 0.43.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 (115) hide show
  1. package/README.md +282 -2
  2. package/dist/cloud/ai/AIResource.d.ts +716 -17
  3. package/dist/cloud/ai/AIResource.js +40 -18
  4. package/dist/cloud/ai/AIResource.js.map +1 -1
  5. package/dist/cloud/ai/DremioModelProvider.d.ts +1 -1
  6. package/dist/cloud/ai/DremioModelProvider.js +6 -13
  7. package/dist/cloud/ai/DremioModelProvider.js.map +1 -1
  8. package/dist/cloud/ai/modelProviderCodec.d.ts +12 -0
  9. package/dist/cloud/replaceOriginResource.js +4 -0
  10. package/dist/cloud/replaceOriginResource.js.map +1 -1
  11. package/dist/common/ConflictResolver.d.ts +9 -1
  12. package/dist/common/ConflictResolver.js +10 -1
  13. package/dist/common/ConflictResolver.js.map +1 -1
  14. package/dist/common/refineRfc9557Schema.d.ts +1 -0
  15. package/dist/common/refineRfc9557Schema.js +26 -0
  16. package/dist/common/refineRfc9557Schema.js.map +1 -0
  17. package/dist/common/sharedExports.d.ts +1 -0
  18. package/dist/common/sharedExports.js +1 -0
  19. package/dist/common/sharedExports.js.map +1 -1
  20. package/dist/enterprise/Dremio.d.ts +1 -1
  21. package/dist/enterprise/Dremio.js +3 -2
  22. package/dist/enterprise/Dremio.js.map +1 -1
  23. package/dist/enterprise/ai/AIResource.d.ts +699 -18
  24. package/dist/enterprise/ai/AIResource.js +41 -19
  25. package/dist/enterprise/ai/AIResource.js.map +1 -1
  26. package/dist/enterprise/ai/chat/ChatSession.d.ts +4 -25
  27. package/dist/enterprise/ai/chat/ChatSession.js +6 -55
  28. package/dist/enterprise/ai/chat/ChatSession.js.map +1 -1
  29. package/dist/enterprise/ai/chat/UserChatMessage.d.ts +38 -22
  30. package/dist/enterprise/ai/chat/UserChatMessage.js +33 -41
  31. package/dist/enterprise/ai/chat/UserChatMessage.js.map +1 -1
  32. package/dist/enterprise/ai/chat/chatEventSchema.d.ts +169 -11
  33. package/dist/enterprise/ai/chat/chatEventSchema.js +183 -35
  34. package/dist/enterprise/ai/chat/chatEventSchema.js.map +1 -1
  35. package/dist/enterprise/ai/chat/eventWrappers/AgentChatPartialResponse.d.ts +0 -6
  36. package/dist/enterprise/ai/chat/eventWrappers/AgentChatResponse.d.ts +6 -6
  37. package/dist/enterprise/ai/chat/eventWrappers/AgentChatResponse.js +2 -2
  38. package/dist/enterprise/ai/chat/eventWrappers/AgentChatResponse.js.map +1 -1
  39. package/dist/enterprise/ai/chat/index.d.ts +0 -3
  40. package/dist/enterprise/ai/chat/index.js +0 -1
  41. package/dist/enterprise/ai/chat/index.js.map +1 -1
  42. package/dist/enterprise/ai/chat/methods/sendChatMessage.js +4 -1
  43. package/dist/enterprise/ai/chat/methods/sendChatMessage.js.map +1 -1
  44. package/dist/enterprise/ai/chat/responseContent/AgentModelResponseContent.d.ts +1 -2
  45. package/dist/enterprise/ai/chat/responseContent/AgentModelResponseContent.js.map +1 -1
  46. package/dist/enterprise/ai/chat/responseContent/AgentToolRequestResponseContent.d.ts +1 -2
  47. package/dist/enterprise/ai/chat/responseContent/AgentToolRequestResponseContent.js +0 -1
  48. package/dist/enterprise/ai/chat/responseContent/AgentToolRequestResponseContent.js.map +1 -1
  49. package/dist/enterprise/ai/chat/responseContent/AgentToolResultResponseContent.d.ts +1 -2
  50. package/dist/enterprise/ai/chat/responseContent/AgentToolResultResponseContent.js +0 -1
  51. package/dist/enterprise/ai/chat/responseContent/AgentToolResultResponseContent.js.map +1 -1
  52. package/dist/enterprise/ai/conversations/AgentConversation.d.ts +215 -0
  53. package/dist/enterprise/ai/conversations/AgentConversation.js +180 -0
  54. package/dist/enterprise/ai/conversations/AgentConversation.js.map +1 -0
  55. package/dist/enterprise/ai/conversations/conversationPropertiesCodec.d.ts +22 -0
  56. package/dist/enterprise/ai/conversations/conversationPropertiesCodec.js +62 -0
  57. package/dist/enterprise/ai/conversations/conversationPropertiesCodec.js.map +1 -0
  58. package/dist/enterprise/ai/conversations/createConversationMachine.d.ts +682 -0
  59. package/dist/enterprise/ai/conversations/createConversationMachine.js +354 -0
  60. package/dist/enterprise/ai/conversations/createConversationMachine.js.map +1 -0
  61. package/dist/enterprise/ai/conversations/methods/createConversation.d.ts +28 -0
  62. package/dist/enterprise/ai/conversations/methods/createConversation.js +68 -0
  63. package/dist/enterprise/ai/conversations/methods/createConversation.js.map +1 -0
  64. package/dist/enterprise/ai/conversations/methods/createExchangeRun.d.ts +16 -0
  65. package/dist/enterprise/ai/conversations/methods/createExchangeRun.js +36 -0
  66. package/dist/enterprise/ai/conversations/methods/createExchangeRun.js.map +1 -0
  67. package/dist/enterprise/ai/conversations/methods/deleteConversation.d.ts +2 -0
  68. package/dist/enterprise/ai/conversations/methods/deleteConversation.js +24 -0
  69. package/dist/enterprise/ai/conversations/methods/deleteConversation.js.map +1 -0
  70. package/dist/enterprise/ai/conversations/methods/listConversations.d.ts +8 -0
  71. package/dist/enterprise/ai/conversations/methods/listConversations.js +30 -0
  72. package/dist/enterprise/ai/conversations/methods/listConversations.js.map +1 -0
  73. package/dist/enterprise/ai/conversations/methods/retrieveConversation.d.ts +12 -0
  74. package/dist/enterprise/ai/conversations/methods/retrieveConversation.js +29 -0
  75. package/dist/enterprise/ai/conversations/methods/retrieveConversation.js.map +1 -0
  76. package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.d.ts +86 -0
  77. package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.js +32 -0
  78. package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.js.map +1 -0
  79. package/dist/enterprise/ai/conversations/methods/stopExchangeRun.d.ts +2 -0
  80. package/dist/enterprise/ai/conversations/methods/stopExchangeRun.js +24 -0
  81. package/dist/enterprise/ai/conversations/methods/stopExchangeRun.js.map +1 -0
  82. package/dist/enterprise/ai/conversations/methods/streamRunEvents.d.ts +6 -0
  83. package/dist/enterprise/ai/conversations/methods/streamRunEvents.js +33 -0
  84. package/dist/enterprise/ai/conversations/methods/streamRunEvents.js.map +1 -0
  85. package/dist/enterprise/ai/conversations/methods/updateConversation.d.ts +15 -0
  86. package/dist/enterprise/ai/conversations/methods/updateConversation.js +35 -0
  87. package/dist/enterprise/ai/conversations/methods/updateConversation.js.map +1 -0
  88. package/dist/enterprise/ai/conversations/reduceChatEvents.d.ts +17 -0
  89. package/dist/enterprise/ai/conversations/reduceChatEvents.js +74 -0
  90. package/dist/enterprise/ai/conversations/reduceChatEvents.js.map +1 -0
  91. package/dist/enterprise/ai/index.d.ts +5 -1
  92. package/dist/enterprise/ai/index.js +4 -1
  93. package/dist/enterprise/ai/index.js.map +1 -1
  94. package/dist/enterprise/ai/modelProvider/ModelProvider.d.ts +15 -1
  95. package/dist/enterprise/ai/modelProvider/ModelProvider.js +12 -1
  96. package/dist/enterprise/ai/modelProvider/ModelProvider.js.map +1 -1
  97. package/dist/enterprise/ai/modelProvider/modelProviderCodec.d.ts +40 -0
  98. package/dist/enterprise/ai/modelProvider/modelProviderCodec.js +10 -1
  99. package/dist/enterprise/ai/modelProvider/modelProviderCodec.js.map +1 -1
  100. package/dist/enterprise/ai/modelProvider/modelProviderConfigSchemas.d.ts +21 -0
  101. package/dist/enterprise/ai/modelProvider/modelProviderConfigSchemas.js +17 -0
  102. package/dist/enterprise/ai/modelProvider/modelProviderConfigSchemas.js.map +1 -1
  103. package/dist/oss/catalog/CatalogReferences/DatasetCatalogReference.d.ts +1 -0
  104. package/dist/oss/catalog/CatalogReferences/DatasetCatalogReference.js +1 -0
  105. package/dist/oss/catalog/CatalogReferences/DatasetCatalogReference.js.map +1 -1
  106. package/dist-iife/cloud.js +21630 -6206
  107. package/dist-iife/community.js +25 -5
  108. package/dist-iife/enterprise.js +19414 -4042
  109. package/package.json +5 -2
  110. package/dist/enterprise/ai/chat/ChatSessionClient.d.ts +0 -18
  111. package/dist/enterprise/ai/chat/ChatSessionClient.js +0 -55
  112. package/dist/enterprise/ai/chat/ChatSessionClient.js.map +0 -1
  113. package/dist/enterprise/ai/chat/UserChatMessageContent.d.ts +0 -19
  114. package/dist/enterprise/ai/chat/UserChatMessageContent.js +0 -44
  115. package/dist/enterprise/ai/chat/UserChatMessageContent.js.map +0 -1
package/README.md CHANGED
@@ -42,6 +42,17 @@ bun install @dremio/js-sdk
42
42
  </script>
43
43
  ```
44
44
 
45
+ ### Deno
46
+
47
+ ```typescript
48
+ import { Dremio, fromPat } from "npm:@dremio/js-sdk@latest/cloud";
49
+
50
+ const dremio = new Dremio({
51
+ origin: "https://api.dremio.cloud",
52
+ credentials: fromPat("PERSONAL_ACCESS_TOKEN"),
53
+ });
54
+ ```
55
+
45
56
  ## Quick Start
46
57
 
47
58
  ```typescript
@@ -119,7 +130,9 @@ API responses are automatically converted to native JavaScript/TypeScript types:
119
130
 
120
131
  ## Table of Contents
121
132
 
133
+ - [Configuration](#configuration)
122
134
  - [Authentication](#authentication)
135
+ - [AI Agent](#ai-agent)
123
136
  - [Catalog](#catalog)
124
137
  - [Engine Rules](#engine-rules)
125
138
  - [Engines](#engines)
@@ -131,6 +144,65 @@ API responses are automatically converted to native JavaScript/TypeScript types:
131
144
  - [Scripts](#scripts)
132
145
  - [Users](#users)
133
146
 
147
+ ## Configuration
148
+
149
+ The `Dremio` class accepts a configuration object with the following properties:
150
+
151
+ ```typescript
152
+ interface DremioConfig {
153
+ origin: string;
154
+ credentials: CredentialProvider;
155
+ logger?: Logger;
156
+ fetch?: typeof fetch;
157
+ }
158
+ ```
159
+
160
+ ### `origin`
161
+
162
+ The base API URL of your Dremio instance:
163
+
164
+ **Dremio Cloud:**
165
+
166
+ - `"https://api.dremio.cloud"` - US region
167
+ - `"https://api.eu.dremio.cloud"` - EU region
168
+
169
+ **Dremio Self-Hosted:**
170
+
171
+ - Your self-hosted Dremio URL (e.g., `"https://dremio.example.com"`)
172
+
173
+ ### `credentials`
174
+
175
+ A credential provider function that returns authentication headers. See the [Authentication](#authentication) section for available options:
176
+
177
+ - `fromAccessToken()` - OAuth access token
178
+ - `fromRefreshToken()` - OAuth refresh token (auto-refreshes)
179
+ - `fromPat()` - Personal access token
180
+
181
+ ### `logger` (optional)
182
+
183
+ A custom logger implementation. Must implement:
184
+
185
+ ```typescript
186
+ interface Logger {
187
+ debug(message: string, ...args: any[]): void;
188
+ info(message: string, ...args: any[]): void;
189
+ warn(message: string, ...args: any[]): void;
190
+ error(message: string, ...args: any[]): void;
191
+ }
192
+ ```
193
+
194
+ See [Custom Logger](#custom-logger) for examples.
195
+
196
+ ### `fetch` (optional)
197
+
198
+ A custom fetch implementation. Useful for:
199
+
200
+ - Adding custom middleware
201
+ - Using a specific fetch polyfill
202
+ - Intercepting requests for testing
203
+
204
+ Defaults to the global `fetch` function.
205
+
134
206
  ## Authentication
135
207
 
136
208
  ### Access Token
@@ -171,6 +243,214 @@ const dremio = new Dremio({
171
243
  });
172
244
  ```
173
245
 
246
+ ## AI Agent
247
+
248
+ ### `AgentConversation`
249
+
250
+ Represents a conversation with the Dremio AI Agent.
251
+
252
+ #### Properties
253
+
254
+ - `id: string` - Unique identifier for the conversation
255
+ - `title: string` - The conversation title
256
+ - `createdAt: Temporal.Instant` - When the conversation was created
257
+ - `modifiedAt: Temporal.Instant` - When the conversation was last modified
258
+ - `modelName: string | null` - The AI model name last used for this conversation
259
+ - `modelProviderId: string | null` - The AI model provider ID last used for this conversation
260
+
261
+ #### `AgentConversation` implements the [`Observable` contract](https://github.com/WICG/observable) using `Symbol.observable`:
262
+
263
+ ```typescript
264
+ import { from } from "rxjs";
265
+
266
+ from(conversation).subscribe((chatEvent) => {
267
+ console.log(chatEvent);
268
+ });
269
+ ```
270
+
271
+ #### Create an `AgentConversation`
272
+
273
+ ```typescript
274
+ const conversation = await dremio.ai("PROJECT_ID").createConversation({
275
+ message: new UserChatMessage(
276
+ new UserChatMessageStringContent(
277
+ "Can you help me visualize the data in the Citibike sample dataset?",
278
+ ),
279
+ ),
280
+ });
281
+ ```
282
+
283
+ #### Retrieve `AgentConversation` by ID
284
+
285
+ ```typescript
286
+ const conversation = await dremio
287
+ .ai("PROJECT_ID")
288
+ .retrieveConversation("CONVERSATION_ID");
289
+ ```
290
+
291
+ #### Update `AgentConversation`
292
+
293
+ ```typescript
294
+ const result = await conversation.update({ title: "New title" });
295
+ ```
296
+
297
+ #### Delete `AgentConversation`
298
+
299
+ ```typescript
300
+ await conversation.delete();
301
+ ```
302
+
303
+ #### List all `AgentConversation`s
304
+
305
+ ```typescript
306
+ for await (const conversation of dremio
307
+ .ai("PROJECT_ID")
308
+ .listConversations()
309
+ .data()) {
310
+ console.log(conversation);
311
+ }
312
+ ```
313
+
314
+ #### Send message to `AgentConversation`
315
+
316
+ To send a message to the Agent, use the `startRun()` method:
317
+
318
+ ```typescript
319
+ await conversation.startRun({
320
+ message: new UserChatMessage(
321
+ new UserChatMessageStringContent(
322
+ "Please adjust the x-axis range to show only 2025-2026",
323
+ ),
324
+ ),
325
+ });
326
+ ```
327
+
328
+ ### `AgentConversationSnapshotBuilder`
329
+
330
+ Compiles a sequence of `ChatEvent`s into a structured view of the current conversation state.
331
+
332
+ #### Building a Snapshot
333
+
334
+ Create a snapshot from existing conversation history:
335
+
336
+ ```typescript
337
+ const conversation = (
338
+ await dremio.ai("PROJECT_ID").retrieveConversation("CONVERSATION_ID")
339
+ ).unwrap();
340
+
341
+ const conversationSnapshot = AgentConversationSnapshotBuilder.fromChatEvents(
342
+ conversation.id,
343
+ (await conversation.history()).unwrap(),
344
+ );
345
+ ```
346
+
347
+ #### Adding Events in Real-Time
348
+
349
+ Monitor chat events as they stream in and add them to the snapshot:
350
+
351
+ ```typescript
352
+ const runId = await conversation
353
+ .startRun({
354
+ message: new UserChatMessage(
355
+ new UserChatMessageStringContent(
356
+ "What data is available to me in Dremio?",
357
+ ),
358
+ ),
359
+ })
360
+ .then((res) => res.unwrap());
361
+
362
+ conversation.runEvents$(runId).subscribe((chatEvent) => {
363
+ conversationSnapshot.addChatEvent(chatEvent);
364
+ console.log(conversationSnapshot.get(runId)!.toJSON());
365
+ });
366
+ ```
367
+
368
+ #### Accessing Snapshot Data
369
+
370
+ The snapshot is iterable and provides access to exchanges:
371
+
372
+ ```typescript
373
+ // Iterate through all exchanges
374
+ for (const exchange of conversationSnapshot) {
375
+ console.log("Exchange ID:", exchange.id);
376
+ for (const message of exchange.messages) {
377
+ console.log("Message:", message);
378
+ }
379
+ for (const toolCall of exchange.toolCalls) {
380
+ console.log("Tool Call:", toolCall.id, toolCall.state);
381
+ }
382
+ }
383
+
384
+ // Get a specific exchange
385
+ const exchange = conversationSnapshot.get(runId);
386
+ ```
387
+
388
+ #### Snapshot Methods
389
+
390
+ - `length: number` - Get the number of exchanges in the snapshot
391
+ - `clone(): AgentConversationSnapshotBuilder` - Create a deep clone of the builder
392
+ - `slice(startExchangeId, endExchangeId?)` - Get a shallow clone containing exchanges in a range
393
+ - `toJSON()` - Serialize the snapshot to JSON
394
+
395
+ #### Snapshot Output Example
396
+
397
+ The `toJSON()` method returns an array of exchanges with their messages and tool calls:
398
+
399
+ ```json
400
+ [
401
+ {
402
+ "id": "run-id-1",
403
+ "messages": [
404
+ {
405
+ "id": "msg-1",
406
+ "runId": "run-id-1",
407
+ "conversationId": "conv-id",
408
+ "role": "user",
409
+ "content": {
410
+ "chunkType": "userMessage",
411
+ "text": "What data is available?"
412
+ }
413
+ },
414
+ {
415
+ "id": "msg-2",
416
+ "runId": "run-id-1",
417
+ "conversationId": "conv-id",
418
+ "role": "agent",
419
+ "content": {
420
+ "chunkType": "model",
421
+ "name": "modelGeneric",
422
+ "result": {
423
+ "text": "Here are the available datasets..."
424
+ }
425
+ }
426
+ }
427
+ ],
428
+ "toolCalls": [
429
+ {
430
+ "id": "tool-call-1",
431
+ "state": "success",
432
+ "request": {
433
+ "content": {
434
+ "chunkType": "toolRequest",
435
+ "name": "queryTool",
436
+ "arguments": { "query": "SELECT * FROM schemas" }
437
+ }
438
+ },
439
+ "result": {
440
+ "content": {
441
+ "chunkType": "toolResponse",
442
+ "name": "queryTool",
443
+ "result": {
444
+ "rows": [{ "schema_name": "public" }]
445
+ }
446
+ }
447
+ }
448
+ }
449
+ ]
450
+ }
451
+ ]
452
+ ```
453
+
174
454
  ## Catalog
175
455
 
176
456
  ### `CatalogReference` Interface
@@ -883,10 +1163,10 @@ import { Result } from "ts-results-es";
883
1163
  const result = await dremio.projects.retrieve("PROJECT_ID");
884
1164
 
885
1165
  if (result.isOk()) {
886
- const project = result.unwrap();
1166
+ const project = result.value;
887
1167
  console.log(project.name);
888
1168
  } else {
889
- const error = result.unwrapErr();
1169
+ const error = result.error;
890
1170
  console.error("Error:", error);
891
1171
  }
892
1172