@dremio/js-sdk 0.42.0 → 0.43.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +274 -0
- package/dist/cloud/ai/AIResource.d.ts +716 -17
- package/dist/cloud/ai/AIResource.js +40 -18
- package/dist/cloud/ai/AIResource.js.map +1 -1
- package/dist/cloud/ai/DremioModelProvider.d.ts +1 -1
- package/dist/cloud/ai/DremioModelProvider.js +6 -13
- package/dist/cloud/ai/DremioModelProvider.js.map +1 -1
- package/dist/cloud/ai/modelProviderCodec.d.ts +12 -0
- package/dist/cloud/replaceOriginResource.js +4 -0
- package/dist/cloud/replaceOriginResource.js.map +1 -1
- package/dist/common/ConflictResolver.d.ts +9 -1
- package/dist/common/ConflictResolver.js +10 -1
- package/dist/common/ConflictResolver.js.map +1 -1
- package/dist/common/refineRfc9557Schema.d.ts +1 -0
- package/dist/common/refineRfc9557Schema.js +26 -0
- package/dist/common/refineRfc9557Schema.js.map +1 -0
- package/dist/common/sharedExports.d.ts +1 -0
- package/dist/common/sharedExports.js +1 -0
- package/dist/common/sharedExports.js.map +1 -1
- package/dist/enterprise/Dremio.d.ts +1 -1
- package/dist/enterprise/Dremio.js +3 -2
- package/dist/enterprise/Dremio.js.map +1 -1
- package/dist/enterprise/ai/AIResource.d.ts +699 -18
- package/dist/enterprise/ai/AIResource.js +41 -19
- package/dist/enterprise/ai/AIResource.js.map +1 -1
- package/dist/enterprise/ai/chat/ChatSession.d.ts +4 -25
- package/dist/enterprise/ai/chat/ChatSession.js +6 -55
- package/dist/enterprise/ai/chat/ChatSession.js.map +1 -1
- package/dist/enterprise/ai/chat/UserChatMessage.d.ts +38 -22
- package/dist/enterprise/ai/chat/UserChatMessage.js +33 -41
- package/dist/enterprise/ai/chat/UserChatMessage.js.map +1 -1
- package/dist/enterprise/ai/chat/chatEventSchema.d.ts +169 -11
- package/dist/enterprise/ai/chat/chatEventSchema.js +183 -35
- package/dist/enterprise/ai/chat/chatEventSchema.js.map +1 -1
- package/dist/enterprise/ai/chat/eventWrappers/AgentChatPartialResponse.d.ts +0 -6
- package/dist/enterprise/ai/chat/eventWrappers/AgentChatResponse.d.ts +6 -6
- package/dist/enterprise/ai/chat/eventWrappers/AgentChatResponse.js +2 -2
- package/dist/enterprise/ai/chat/eventWrappers/AgentChatResponse.js.map +1 -1
- package/dist/enterprise/ai/chat/index.d.ts +0 -3
- package/dist/enterprise/ai/chat/index.js +0 -1
- package/dist/enterprise/ai/chat/index.js.map +1 -1
- package/dist/enterprise/ai/chat/methods/sendChatMessage.js +4 -1
- package/dist/enterprise/ai/chat/methods/sendChatMessage.js.map +1 -1
- package/dist/enterprise/ai/chat/responseContent/AgentModelResponseContent.d.ts +1 -2
- package/dist/enterprise/ai/chat/responseContent/AgentModelResponseContent.js.map +1 -1
- package/dist/enterprise/ai/chat/responseContent/AgentToolRequestResponseContent.d.ts +1 -2
- package/dist/enterprise/ai/chat/responseContent/AgentToolRequestResponseContent.js +0 -1
- package/dist/enterprise/ai/chat/responseContent/AgentToolRequestResponseContent.js.map +1 -1
- package/dist/enterprise/ai/chat/responseContent/AgentToolResultResponseContent.d.ts +1 -2
- package/dist/enterprise/ai/chat/responseContent/AgentToolResultResponseContent.js +0 -1
- package/dist/enterprise/ai/chat/responseContent/AgentToolResultResponseContent.js.map +1 -1
- package/dist/enterprise/ai/conversations/AgentConversation.d.ts +215 -0
- package/dist/enterprise/ai/conversations/AgentConversation.js +180 -0
- package/dist/enterprise/ai/conversations/AgentConversation.js.map +1 -0
- package/dist/enterprise/ai/conversations/conversationPropertiesCodec.d.ts +22 -0
- package/dist/enterprise/ai/conversations/conversationPropertiesCodec.js +62 -0
- package/dist/enterprise/ai/conversations/conversationPropertiesCodec.js.map +1 -0
- package/dist/enterprise/ai/conversations/createConversationMachine.d.ts +682 -0
- package/dist/enterprise/ai/conversations/createConversationMachine.js +354 -0
- package/dist/enterprise/ai/conversations/createConversationMachine.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/createConversation.d.ts +28 -0
- package/dist/enterprise/ai/conversations/methods/createConversation.js +68 -0
- package/dist/enterprise/ai/conversations/methods/createConversation.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/createExchangeRun.d.ts +16 -0
- package/dist/enterprise/ai/conversations/methods/createExchangeRun.js +36 -0
- package/dist/enterprise/ai/conversations/methods/createExchangeRun.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/deleteConversation.d.ts +2 -0
- package/dist/enterprise/ai/conversations/methods/deleteConversation.js +24 -0
- package/dist/enterprise/ai/conversations/methods/deleteConversation.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/listConversations.d.ts +8 -0
- package/dist/enterprise/ai/conversations/methods/listConversations.js +30 -0
- package/dist/enterprise/ai/conversations/methods/listConversations.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversation.d.ts +12 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversation.js +29 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversation.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.d.ts +86 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.js +32 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/stopExchangeRun.d.ts +2 -0
- package/dist/enterprise/ai/conversations/methods/stopExchangeRun.js +24 -0
- package/dist/enterprise/ai/conversations/methods/stopExchangeRun.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/streamRunEvents.d.ts +6 -0
- package/dist/enterprise/ai/conversations/methods/streamRunEvents.js +33 -0
- package/dist/enterprise/ai/conversations/methods/streamRunEvents.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/updateConversation.d.ts +15 -0
- package/dist/enterprise/ai/conversations/methods/updateConversation.js +35 -0
- package/dist/enterprise/ai/conversations/methods/updateConversation.js.map +1 -0
- package/dist/enterprise/ai/conversations/reduceChatEvents.d.ts +17 -0
- package/dist/enterprise/ai/conversations/reduceChatEvents.js +74 -0
- package/dist/enterprise/ai/conversations/reduceChatEvents.js.map +1 -0
- package/dist/enterprise/ai/index.d.ts +5 -1
- package/dist/enterprise/ai/index.js +4 -1
- package/dist/enterprise/ai/index.js.map +1 -1
- package/dist/enterprise/ai/modelProvider/ModelProvider.d.ts +15 -1
- package/dist/enterprise/ai/modelProvider/ModelProvider.js +12 -1
- package/dist/enterprise/ai/modelProvider/ModelProvider.js.map +1 -1
- package/dist/enterprise/ai/modelProvider/modelProviderCodec.d.ts +40 -0
- package/dist/enterprise/ai/modelProvider/modelProviderCodec.js +10 -1
- package/dist/enterprise/ai/modelProvider/modelProviderCodec.js.map +1 -1
- package/dist/enterprise/ai/modelProvider/modelProviderConfigSchemas.d.ts +21 -0
- package/dist/enterprise/ai/modelProvider/modelProviderConfigSchemas.js +17 -0
- package/dist/enterprise/ai/modelProvider/modelProviderConfigSchemas.js.map +1 -1
- package/dist/oss/catalog/CatalogReferences/DatasetCatalogReference.d.ts +1 -0
- package/dist/oss/catalog/CatalogReferences/DatasetCatalogReference.js +1 -0
- package/dist/oss/catalog/CatalogReferences/DatasetCatalogReference.js.map +1 -1
- package/dist-iife/cloud.js +21620 -6202
- package/dist-iife/community.js +14 -0
- package/dist-iife/enterprise.js +19404 -4038
- package/package.json +5 -2
- package/dist/enterprise/ai/chat/ChatSessionClient.d.ts +0 -18
- package/dist/enterprise/ai/chat/ChatSessionClient.js +0 -55
- package/dist/enterprise/ai/chat/ChatSessionClient.js.map +0 -1
- package/dist/enterprise/ai/chat/UserChatMessageContent.d.ts +0 -19
- package/dist/enterprise/ai/chat/UserChatMessageContent.js +0 -44
- package/dist/enterprise/ai/chat/UserChatMessageContent.js.map +0 -1
package/README.md
CHANGED
|
@@ -132,6 +132,7 @@ API responses are automatically converted to native JavaScript/TypeScript types:
|
|
|
132
132
|
|
|
133
133
|
- [Configuration](#configuration)
|
|
134
134
|
- [Authentication](#authentication)
|
|
135
|
+
- [AI Agent](#ai-agent)
|
|
135
136
|
- [Catalog](#catalog)
|
|
136
137
|
- [Engine Rules](#engine-rules)
|
|
137
138
|
- [Engines](#engines)
|
|
@@ -242,6 +243,279 @@ const dremio = new Dremio({
|
|
|
242
243
|
});
|
|
243
244
|
```
|
|
244
245
|
|
|
246
|
+
## AI Agent
|
|
247
|
+
|
|
248
|
+
### `AgentConversation`
|
|
249
|
+
|
|
250
|
+
Represents a conversation with the Dremio AI Agent.
|
|
251
|
+
|
|
252
|
+
#### Properties
|
|
253
|
+
|
|
254
|
+
- `createdAt: Temporal.Instant` - When the conversation was created
|
|
255
|
+
- `currentRunId: string | null` - The ID of the currently active run, if any
|
|
256
|
+
- `id: string` - Unique identifier for the conversation
|
|
257
|
+
- `modelName: string | null` - The AI model name last used for this conversation
|
|
258
|
+
- `modelProviderId: string | null` - The AI model provider ID last used for this conversation
|
|
259
|
+
- `modifiedAt: Temporal.Instant` - When the conversation was last modified
|
|
260
|
+
- `tag: string` - Version tag for optimistic concurrency control
|
|
261
|
+
- `title: string` - The conversation title
|
|
262
|
+
|
|
263
|
+
#### Create an `AgentConversation`
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
import { UserChatMessage } from "@dremio/js-sdk/enterprise/ai";
|
|
267
|
+
|
|
268
|
+
const conversation = await dremio.ai("PROJECT_ID").createConversation({
|
|
269
|
+
message: UserChatMessage.new(
|
|
270
|
+
"Can you help me visualize the data in the Citibike sample dataset?",
|
|
271
|
+
),
|
|
272
|
+
});
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
#### Retrieve `AgentConversation` by ID
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
const conversation = await dremio
|
|
279
|
+
.ai("PROJECT_ID")
|
|
280
|
+
.retrieveConversation("CONVERSATION_ID");
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
#### Update `AgentConversation`
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
await conversation.update({ title: "New title" });
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
The `update()` method supports optimistic concurrency control with conflict resolution:
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
await conversation.update(
|
|
293
|
+
{ title: "New title" },
|
|
294
|
+
{
|
|
295
|
+
onConflict: async (local, remote, changes) => {
|
|
296
|
+
// Overwrite with local title
|
|
297
|
+
return { title: local.title };
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
);
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
#### Delete `AgentConversation`
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
await conversation.delete();
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
#### List all `AgentConversation`s
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
for await (const conversation of dremio
|
|
313
|
+
.ai("PROJECT_ID")
|
|
314
|
+
.listConversations()
|
|
315
|
+
.data()) {
|
|
316
|
+
console.log(conversation);
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
#### Send message to `AgentConversation`
|
|
321
|
+
|
|
322
|
+
To send a message to the Agent, use the `startRun()` method:
|
|
323
|
+
|
|
324
|
+
```typescript
|
|
325
|
+
import { UserChatMessage } from "@dremio/js-sdk/enterprise/ai";
|
|
326
|
+
|
|
327
|
+
const runId = await conversation.startRun({
|
|
328
|
+
message: UserChatMessage.new(
|
|
329
|
+
"Please adjust the x-axis range to show only 2025-2026",
|
|
330
|
+
),
|
|
331
|
+
});
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
#### Stream Run Events
|
|
335
|
+
|
|
336
|
+
Monitor chat events as they stream in from a run:
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
import { UserChatMessage } from "@dremio/js-sdk/enterprise/ai";
|
|
340
|
+
|
|
341
|
+
const runId = await conversation.startRun({
|
|
342
|
+
message: UserChatMessage.new("What data is available to me in Dremio?"),
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
conversation.runEvents$(runId).subscribe((chatEvent) => {
|
|
346
|
+
console.log("Event:", chatEvent.content.chunkType);
|
|
347
|
+
if (chatEvent.content.chunkType === "model") {
|
|
348
|
+
console.log("Model response:", chatEvent.content.result);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
#### Retrieve Conversation History
|
|
354
|
+
|
|
355
|
+
Get the full history of chat events for a conversation:
|
|
356
|
+
|
|
357
|
+
```typescript
|
|
358
|
+
const history = await conversation.history();
|
|
359
|
+
|
|
360
|
+
console.log(`Conversation has ${history.length} events`);
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### Working with Chat Events
|
|
364
|
+
|
|
365
|
+
The state of a conversation is represented as a stream of `ChatEvent` objects. These events include user messages, tool call requests and results, and Agent replies. While the event stream enables incremental UI updates, it contains implicit relationships that need to be made explicit for easier consumption.
|
|
366
|
+
|
|
367
|
+
#### Chat Event Types
|
|
368
|
+
|
|
369
|
+
- `userMessage` - A message from the user
|
|
370
|
+
- `model` - A response from the AI model
|
|
371
|
+
- `toolRequest` - A request to execute a tool (tool calls can run in parallel)
|
|
372
|
+
- `toolResponse` - The result of a tool execution
|
|
373
|
+
- `error` - An error message
|
|
374
|
+
|
|
375
|
+
#### Building a Conversation Snapshot
|
|
376
|
+
|
|
377
|
+
The `AgentConversation.reduceChatEvents()` method transforms a stream of chat events into a structured snapshot that makes implicit relationships explicit:
|
|
378
|
+
|
|
379
|
+
- **Groups events by exchange** - Each user-agent interaction (identified by `runId`) becomes a separate exchange
|
|
380
|
+
- **Pairs tool calls** - Tool requests and responses are matched by `callId` and combined into a single object
|
|
381
|
+
- **Derives tool state** - Automatically determines if a tool call is `pending`, `success`, or `error`
|
|
382
|
+
- **Handles duplicates** - Efficiently filters duplicate events when merging history and live streams
|
|
383
|
+
- **Preserves order** - Maintains insertion order for messages and tool calls
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
import { AgentConversation } from "@dremio/js-sdk/enterprise/ai";
|
|
387
|
+
|
|
388
|
+
const conversation = await dremio
|
|
389
|
+
.ai("PROJECT_ID")
|
|
390
|
+
.retrieveConversation("CONVERSATION_ID");
|
|
391
|
+
|
|
392
|
+
const history = await conversation.history();
|
|
393
|
+
|
|
394
|
+
const snapshot = AgentConversation.reduceChatEvents([], history);
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
Each exchange in the snapshot represents a single user-agent interaction:
|
|
398
|
+
|
|
399
|
+
```typescript
|
|
400
|
+
type ConversationExchange = {
|
|
401
|
+
id: string; // The run ID
|
|
402
|
+
messages: Map<string, ConversationExchangeMessage>;
|
|
403
|
+
toolCalls: Map<string, AgentToolCall>;
|
|
404
|
+
submittedUserMessage?: UserChatMessage;
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
type AgentToolCall = {
|
|
408
|
+
id: string;
|
|
409
|
+
state: "error" | "pending" | "success";
|
|
410
|
+
request: ChatEventWithChunkType<"toolRequest"> | undefined;
|
|
411
|
+
result: ChatEventWithChunkType<"toolResponse"> | undefined;
|
|
412
|
+
};
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
#### Incremental Updates
|
|
416
|
+
|
|
417
|
+
The reducer is a pure function with signature `(snapshot, events) => newSnapshot`. You can incrementally update a snapshot as new events arrive:
|
|
418
|
+
|
|
419
|
+
```typescript
|
|
420
|
+
import {
|
|
421
|
+
AgentConversation,
|
|
422
|
+
UserChatMessage,
|
|
423
|
+
} from "@dremio/js-sdk/enterprise/ai";
|
|
424
|
+
|
|
425
|
+
let snapshot = AgentConversation.reduceChatEvents([], historyEvents);
|
|
426
|
+
|
|
427
|
+
const runId = await conversation.startRun({
|
|
428
|
+
message: UserChatMessage.new("What tables exist?"),
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
conversation.runEvents$(runId).subscribe((chatEvent) => {
|
|
432
|
+
snapshot = AgentConversation.reduceChatEvents(snapshot, [chatEvent]);
|
|
433
|
+
|
|
434
|
+
const currentExchange = snapshot[snapshot.length - 1];
|
|
435
|
+
console.log("Current exchange:", currentExchange);
|
|
436
|
+
});
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### `UserChatMessage`
|
|
440
|
+
|
|
441
|
+
Create user messages to send to the AI Agent.
|
|
442
|
+
|
|
443
|
+
#### Create a Simple Message
|
|
444
|
+
|
|
445
|
+
```typescript
|
|
446
|
+
import { UserChatMessage } from "@dremio/js-sdk/enterprise/ai";
|
|
447
|
+
|
|
448
|
+
const message = UserChatMessage.new("What tables are available?");
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
#### Create a Message with Context
|
|
452
|
+
|
|
453
|
+
```typescript
|
|
454
|
+
import { UserChatMessage } from "@dremio/js-sdk/enterprise/ai";
|
|
455
|
+
|
|
456
|
+
const message = UserChatMessage.new("Analyze this data", {
|
|
457
|
+
context: "Additional context about the request",
|
|
458
|
+
skillIds: ["skill-id-1", "skill-id-2"],
|
|
459
|
+
});
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
#### Message Properties
|
|
463
|
+
|
|
464
|
+
- `id: string` - Unique identifier for the message
|
|
465
|
+
- `createdAt: Temporal.ZonedDateTime` - When the message was created
|
|
466
|
+
- `content: string` - The message text
|
|
467
|
+
- `prompt?: object` - Optional prompt configuration including context, skillIds, and approvals
|
|
468
|
+
|
|
469
|
+
### `AgentConversationMachine`
|
|
470
|
+
|
|
471
|
+
An XState state machine for managing conversation lifecycle with built-in state management.
|
|
472
|
+
|
|
473
|
+
#### Create and Use the Machine
|
|
474
|
+
|
|
475
|
+
```typescript
|
|
476
|
+
import { createActor } from "xstate";
|
|
477
|
+
import { UserChatMessage } from "@dremio/js-sdk/enterprise/ai";
|
|
478
|
+
|
|
479
|
+
const conversationMachine = dremio.ai("PROJECT_ID").conversationMachine;
|
|
480
|
+
|
|
481
|
+
// Create a new conversation
|
|
482
|
+
const actor = createActor(conversationMachine, {
|
|
483
|
+
input: {
|
|
484
|
+
conversationId: null,
|
|
485
|
+
initialMessage: UserChatMessage.new("Hello, can you help me?"),
|
|
486
|
+
},
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
actor.subscribe((snapshot) => {
|
|
490
|
+
console.log("State:", snapshot.value);
|
|
491
|
+
console.log("Exchanges:", snapshot.context.conversationSnapshot);
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
actor.start();
|
|
495
|
+
|
|
496
|
+
// Send additional messages
|
|
497
|
+
actor.send({
|
|
498
|
+
type: "SUBMIT_USER_MESSAGE",
|
|
499
|
+
message: UserChatMessage.new("What data sources are available?"),
|
|
500
|
+
});
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
#### Machine States
|
|
504
|
+
|
|
505
|
+
- `uninitialized` - Initial state before conversation is created
|
|
506
|
+
- `creating_conversation` - Creating a new conversation
|
|
507
|
+
- `retrieving_history` - Fetching conversation history
|
|
508
|
+
- `idle` - Ready to accept new messages
|
|
509
|
+
- `submitting_message` - Sending a user message
|
|
510
|
+
- `streaming` - Receiving agent responses
|
|
511
|
+
- `retrieve_history_failed` - Error state when history retrieval fails
|
|
512
|
+
|
|
513
|
+
#### Machine Events
|
|
514
|
+
|
|
515
|
+
- `SUBMIT_USER_MESSAGE` - Send a new message
|
|
516
|
+
- `REFRESH_HISTORY` - Reload conversation history
|
|
517
|
+
- `CANCEL_RUN` - Cancel the current run
|
|
518
|
+
|
|
245
519
|
## Catalog
|
|
246
520
|
|
|
247
521
|
### `CatalogReference` Interface
|