@dremio/js-sdk 0.43.1 → 0.45.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.
@@ -24945,6 +24945,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
24945
24945
  summary: optional(string2()),
24946
24946
  title: optional(string2())
24947
24947
  });
24948
+ var endOfStreamChunkSchema = object({
24949
+ chunkType: literal("endOfStream")
24950
+ });
24948
24951
  var modelChunkSchema = object({
24949
24952
  chunkType: literal("model"),
24950
24953
  name: string2().check(_trim(), _minLength(1)),
@@ -24983,6 +24986,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
24983
24986
  ]);
24984
24987
  var chatEventInputSchema = discriminatedUnion("chunkType", [
24985
24988
  errorChunkSchema,
24989
+ extend2(endOfStreamChunkSchema, chatEventSharedSchema),
24986
24990
  extend2(conversationUpdateChunkSchema, chatEventSharedSchema),
24987
24991
  extend2(modelChunkSchema, chatEventSharedSchema),
24988
24992
  extend2(toolRequestChunkSchema, chatEventSharedSchema),
@@ -24999,6 +25003,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
24999
25003
  role: literal("agent")
25000
25004
  }),
25001
25005
  extend2(chatEventOutputSharedSchema, { content: errorChunkSchema, role: literal("agent") }),
25006
+ extend2(chatEventOutputSharedSchema, {
25007
+ content: endOfStreamChunkSchema,
25008
+ role: literal("agent")
25009
+ }),
25002
25010
  extend2(chatEventOutputSharedSchema, { content: modelChunkSchema, role: literal("agent") }),
25003
25011
  extend2(chatEventOutputSharedSchema, {
25004
25012
  content: toolRequestChunkSchema,
@@ -25049,6 +25057,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
25049
25057
  },
25050
25058
  role: "agent"
25051
25059
  };
25060
+ case "endOfStream":
25061
+ return {
25062
+ ...sharedProperties,
25063
+ content: {
25064
+ chunkType: "endOfStream"
25065
+ },
25066
+ role: "agent"
25067
+ };
25052
25068
  case "model":
25053
25069
  return {
25054
25070
  ...sharedProperties,
@@ -26748,6 +26764,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
26748
26764
  }
26749
26765
  function applyChatEventToConversationExchange(conversationExchange, chatEvent) {
26750
26766
  switch (chatEvent.content.chunkType) {
26767
+ case "endOfStream": {
26768
+ for (const [, toolCall] of conversationExchange.toolCalls) {
26769
+ if (!toolCall.result) {
26770
+ toolCall.state = "canceled";
26771
+ }
26772
+ }
26773
+ break;
26774
+ }
26751
26775
  case "error":
26752
26776
  case "model":
26753
26777
  case "userMessage": {
@@ -31656,6 +31680,7 @@ ${err.message}`);
31656
31680
  },
31657
31681
  types: {
31658
31682
  context: {},
31683
+ emitted: {},
31659
31684
  events: {},
31660
31685
  input: {}
31661
31686
  }
@@ -31677,21 +31702,27 @@ ${err.message}`);
31677
31702
  }),
31678
31703
  onDone: [
31679
31704
  {
31680
- actions: assign({
31681
- conversationId: ({ event }) => event.output.id,
31682
- // Add the message attempt into the snapshot manually
31683
- conversationSnapshot: ({ context: context2, event }) => [
31684
- ...context2.conversationSnapshot ?? [],
31685
- {
31686
- id: event.output.currentRunId,
31687
- messages: /* @__PURE__ */ new Map(),
31688
- submittedUserMessage: context2.messageAttempt,
31689
- toolCalls: /* @__PURE__ */ new Map()
31690
- }
31691
- ],
31692
- currentRunId: ({ event }) => event.output.currentRunId,
31693
- messageAttempt: void 0
31694
- }),
31705
+ actions: [
31706
+ assign({
31707
+ conversationId: ({ event }) => event.output.id,
31708
+ // Add the message attempt into the snapshot manually
31709
+ conversationSnapshot: ({ context: context2, event }) => [
31710
+ ...context2.conversationSnapshot ?? [],
31711
+ {
31712
+ id: event.output.currentRunId,
31713
+ messages: /* @__PURE__ */ new Map(),
31714
+ submittedUserMessage: context2.messageAttempt,
31715
+ toolCalls: /* @__PURE__ */ new Map()
31716
+ }
31717
+ ],
31718
+ currentRunId: ({ event }) => event.output.currentRunId,
31719
+ messageAttempt: void 0
31720
+ }),
31721
+ emit(({ event }) => ({
31722
+ id: event.output.id,
31723
+ type: "conversationCreated"
31724
+ }))
31725
+ ],
31695
31726
  // Don't transition to streaming in a situation where we didn't receive a currentRunId
31696
31727
  guard: ({ event }) => !!event.output.currentRunId,
31697
31728
  target: "streaming"
@@ -31709,6 +31740,10 @@ ${err.message}`);
31709
31740
  }
31710
31741
  ],
31711
31742
  onError: {
31743
+ actions: emit(({ event }) => ({
31744
+ error: event.error,
31745
+ type: "apiError"
31746
+ })),
31712
31747
  target: "uninitialized"
31713
31748
  },
31714
31749
  src: "createConversation"
@@ -31766,9 +31801,15 @@ ${err.message}`);
31766
31801
  target: "uninitialized"
31767
31802
  },
31768
31803
  {
31769
- actions: assign({
31770
- lastError: ({ event }) => event.error
31771
- }),
31804
+ actions: [
31805
+ assign({
31806
+ lastError: ({ event }) => event.error
31807
+ }),
31808
+ emit(({ event }) => ({
31809
+ error: event.error,
31810
+ type: "apiError"
31811
+ }))
31812
+ ],
31772
31813
  target: "retrieve_history_failed"
31773
31814
  }
31774
31815
  ],
@@ -31797,16 +31838,19 @@ ${err.message}`);
31797
31838
  target: "idle"
31798
31839
  },
31799
31840
  onSnapshot: {
31800
- actions: assign({
31801
- conversationSnapshot: ({ context: context2, event }) => {
31802
- const chatEvent = event.snapshot.context;
31803
- if (!chatEvent) {
31804
- return context2.conversationSnapshot;
31805
- }
31806
- return AgentConversation.reduceChatEvents(context2.conversationSnapshot, [
31807
- chatEvent
31808
- ]);
31841
+ actions: enqueueActions(({ context: context2, enqueue, event }) => {
31842
+ const chatEvent = event.snapshot.context;
31843
+ if (!chatEvent) {
31844
+ return;
31809
31845
  }
31846
+ const nextSnapshot = AgentConversation.reduceChatEvents(context2.conversationSnapshot, [chatEvent]);
31847
+ enqueue.assign({
31848
+ conversationSnapshot: nextSnapshot
31849
+ });
31850
+ enqueue.emit({
31851
+ chatEvent,
31852
+ type: "chatEventReceived"
31853
+ });
31810
31854
  })
31811
31855
  },
31812
31856
  src: "streamRun"
@@ -31878,10 +31922,16 @@ ${err.message}`);
31878
31922
  target: "streaming"
31879
31923
  },
31880
31924
  onError: {
31881
- actions: assign({
31882
- currentRunId: () => null,
31883
- lastError: ({ event }) => event.error
31884
- }),
31925
+ actions: [
31926
+ assign({
31927
+ currentRunId: () => null,
31928
+ lastError: ({ event }) => event.error
31929
+ }),
31930
+ emit(({ event }) => ({
31931
+ error: event.error,
31932
+ type: "apiError"
31933
+ }))
31934
+ ],
31885
31935
  target: "submitting_message_failed"
31886
31936
  },
31887
31937
  src: "startRun"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dremio/js-sdk",
3
- "version": "0.43.1",
3
+ "version": "0.45.0",
4
4
  "description": "JavaScript library for the Dremio API",
5
5
  "keywords": [
6
6
  "dremio",