@dbx-tools/ui-mastra 0.3.21 → 0.3.22

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.
@@ -1,4 +1,4 @@
1
- import { usePluginClientConfig } from "@dbx-tools/ui-appkit/react";
1
+ import { error as errorUtil } from "@dbx-tools/shared-core";
2
2
  import {
3
3
  feedback,
4
4
  override,
@@ -17,8 +17,8 @@ import {
17
17
  type MastraUpdateThreadResponse,
18
18
  type StatementData,
19
19
  } from "@dbx-tools/shared-mastra";
20
- import { error as errorUtil } from "@dbx-tools/shared-core";
21
20
  import type { ServingEndpointSummary } from "@dbx-tools/shared-model";
21
+ import { usePluginClientConfig } from "@dbx-tools/ui-appkit/react";
22
22
  import { MastraClient } from "@mastra/client-js";
23
23
  import { useCallback, useEffect, useMemo, useState } from "react";
24
24
  import { asMastraStreamResponse, type MastraStreamResponse } from "./mastra-stream";
@@ -59,8 +59,7 @@ export class MastraPluginClient extends MastraClient {
59
59
 
60
60
  constructor(config: MastraClientConfig) {
61
61
  super({
62
- baseUrl:
63
- typeof window !== "undefined" ? window.location.origin : "http://localhost",
62
+ baseUrl: typeof window !== "undefined" ? window.location.origin : "http://localhost",
64
63
  apiPrefix: config.basePath,
65
64
  credentials: "include",
66
65
  headers: {},
@@ -261,9 +260,7 @@ export class MastraPluginClient extends MastraClient {
261
260
  "DELETE",
262
261
  wire.MastraClearHistoryResponseSchema,
263
262
  {
264
- ...(options.threadId
265
- ? { headers: { [thread.THREAD_ID_HEADER]: options.threadId } }
266
- : {}),
263
+ ...(options.threadId ? { headers: { [thread.THREAD_ID_HEADER]: options.threadId } } : {}),
267
264
  ...(options.signal ? { signal: options.signal } : {}),
268
265
  },
269
266
  );
@@ -551,8 +548,7 @@ export const useMastraModels = (
551
548
  // lists a vectoriser. If the server didn't tag tasks at all,
552
549
  // pass everything through so we don't show an empty list.
553
550
  const llms = endpoints.filter(
554
- (e) =>
555
- e.task !== "llm/v1/embeddings" && (!e.task || e.task.startsWith("llm/v1/")),
551
+ (e) => e.task !== "llm/v1/embeddings" && (!e.task || e.task.startsWith("llm/v1/")),
556
552
  );
557
553
  setModels(llms.length > 0 ? llms : endpoints);
558
554
  })
@@ -709,8 +705,7 @@ export const useMastraThreads = (
709
705
  setError(null);
710
706
  })
711
707
  .catch((e: unknown) => {
712
- if (controller.signal.aborted || (e as { name?: string }).name === "AbortError")
713
- return;
708
+ if (controller.signal.aborted || (e as { name?: string }).name === "AbortError") return;
714
709
  setError(errorUtil.toError(e));
715
710
  setThreads([]);
716
711
  })
@@ -766,8 +761,7 @@ export interface ByIdFetchState<T> {
766
761
  * everything. Keyed by `<type>:<id>` (e.g. `chart:abc123`).
767
762
  */
768
763
  type FetchCacheEntry<T> =
769
- | { kind: "pending"; promise: Promise<T | undefined> }
770
- | { kind: "ready"; data: T | undefined };
764
+ { kind: "pending"; promise: Promise<T | undefined> } | { kind: "ready"; data: T | undefined };
771
765
 
772
766
  const fetchCache = new Map<string, FetchCacheEntry<unknown>>();
773
767
 
@@ -902,8 +896,7 @@ function useByIdFetch<T>(
902
896
  * stays stable - inlining a fresh closure would refire the
903
897
  * effect on every render.
904
898
  */
905
- const chartIsTerminal = (c: Chart): boolean =>
906
- c.result !== undefined || c.error !== undefined;
899
+ const chartIsTerminal = (c: Chart): boolean => c.result !== undefined || c.error !== undefined;
907
900
 
908
901
  /**
909
902
  * `isTerminal` for {@link useStatementFetch}. A statement
@@ -955,9 +948,6 @@ export const useStatementFetch = (
955
948
  ): ByIdFetchState<StatementData> => {
956
949
  const client = useMastraClient();
957
950
  const key = statementId ? `data:${statementId}` : undefined;
958
- const fetcher = useCallback(
959
- () => client.statement(statementId as string),
960
- [client, statementId],
961
- );
951
+ const fetcher = useCallback(() => client.statement(statementId as string), [client, statementId]);
962
952
  return useByIdFetch<StatementData>(key, fetcher, statementIsTerminal);
963
953
  };
@@ -57,10 +57,7 @@ export function isSessionRunning(session: ThreadSession): boolean {
57
57
  }
58
58
 
59
59
  /** Append a steer to the queue (oldest first). Returns a new array. */
60
- export function enqueueSteer(
61
- queue: QueuedSteer[],
62
- steer: QueuedSteer,
63
- ): QueuedSteer[] {
60
+ export function enqueueSteer(queue: QueuedSteer[], steer: QueuedSteer): QueuedSteer[] {
64
61
  return [...queue, steer];
65
62
  }
66
63