@gram-ai/elements 1.33.1 → 1.34.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 (48) hide show
  1. package/dist/components/ui/time-range-picker.d.ts +17 -1
  2. package/dist/components/ui/time-range-picker.test.d.ts +1 -0
  3. package/dist/elements.cjs +1 -1
  4. package/dist/elements.js +19 -16
  5. package/dist/hooks/useGramThreadListAdapter.d.ts +13 -0
  6. package/dist/{index-CGoLfO5p.js → index-B5lZrrO2.js} +52 -37
  7. package/dist/index-B5lZrrO2.js.map +1 -0
  8. package/dist/{index-Dn0_JCoN.js → index-BFU6NvbL.js} +6867 -6816
  9. package/dist/index-BFU6NvbL.js.map +1 -0
  10. package/dist/{index-DAWGW1Nj.cjs → index-C08dvTEo.cjs} +43 -43
  11. package/dist/index-C08dvTEo.cjs.map +1 -0
  12. package/dist/index-DzZ1-jQY.cjs +194 -0
  13. package/dist/index-DzZ1-jQY.cjs.map +1 -0
  14. package/dist/index.d.ts +4 -1
  15. package/dist/lib/messageConverter.d.ts +58 -8
  16. package/dist/lib/models.d.ts +1 -1
  17. package/dist/lib/utils.d.ts +2 -0
  18. package/dist/plugins.cjs +1 -1
  19. package/dist/plugins.js +1 -1
  20. package/dist/{profiler-Ce0O8-iW.cjs → profiler-BRnyr1GA.cjs} +2 -2
  21. package/dist/{profiler-Ce0O8-iW.cjs.map → profiler-BRnyr1GA.cjs.map} +1 -1
  22. package/dist/{profiler-DtaHTumy.js → profiler-KLSTpp6I.js} +2 -2
  23. package/dist/{profiler-DtaHTumy.js.map → profiler-KLSTpp6I.js.map} +1 -1
  24. package/dist/{startRecording-DjP64hyw.js → startRecording-BfxB1xxR.js} +2 -2
  25. package/dist/{startRecording-DjP64hyw.js.map → startRecording-BfxB1xxR.js.map} +1 -1
  26. package/dist/{startRecording-Cpeh1_CL.cjs → startRecording-CKx-YWbq.cjs} +2 -2
  27. package/dist/{startRecording-Cpeh1_CL.cjs.map → startRecording-CKx-YWbq.cjs.map} +1 -1
  28. package/dist/types/index.d.ts +64 -1
  29. package/package.json +4 -2
  30. package/src/components/assistant-ui/thread.tsx +7 -3
  31. package/src/components/ui/time-range-picker.test.ts +57 -0
  32. package/src/components/ui/time-range-picker.tsx +29 -4
  33. package/src/contexts/ElementsProvider.tsx +57 -8
  34. package/src/hooks/useAuth.ts +13 -1
  35. package/src/hooks/useGramThreadListAdapter.tsx +68 -6
  36. package/src/index.ts +16 -0
  37. package/src/lib/cassette.ts +1 -19
  38. package/src/lib/contextCompaction.test.ts +2 -2
  39. package/src/lib/contextCompaction.ts +20 -8
  40. package/src/lib/messageConverter.ts +94 -56
  41. package/src/lib/models.ts +19 -7
  42. package/src/lib/utils.ts +20 -0
  43. package/src/types/index.ts +73 -1
  44. package/dist/index-BqBo07H_.cjs +0 -194
  45. package/dist/index-BqBo07H_.cjs.map +0 -1
  46. package/dist/index-CGoLfO5p.js.map +0 -1
  47. package/dist/index-DAWGW1Nj.cjs.map +0 -1
  48. package/dist/index-Dn0_JCoN.js.map +0 -1
@@ -11,6 +11,15 @@ export interface TimeRangePreset {
11
11
  }
12
12
  export declare const PRESETS: TimeRangePreset[];
13
13
  export declare function getPresetRange(preset: DateRangePreset): TimeRange;
14
+ type ParseResult = {
15
+ type: "preset";
16
+ preset: DateRangePreset;
17
+ } | {
18
+ type: "custom";
19
+ range: TimeRange;
20
+ label?: string;
21
+ } | null;
22
+ export declare function parseWithAI(input: string, apiUrl: string, projectSlug?: string, authHeaders?: Record<string, string>): Promise<ParseResult>;
14
23
  export interface TimeRangePickerProps {
15
24
  /** Current preset value */
16
25
  preset?: DateRangePreset | null;
@@ -40,10 +49,17 @@ export interface TimeRangePickerProps {
40
49
  apiUrl?: string;
41
50
  /** Project slug for API authentication */
42
51
  projectSlug?: string;
52
+ /**
53
+ * Auth headers to send with the AI parsing request to /chat/completions
54
+ * (e.g. `{ "Gram-Session": token }`). The `/chat/completions` proxy
55
+ * authenticates from request headers, not cookies, so without these the
56
+ * request is rejected with 401 and natural-language parsing silently fails.
57
+ */
58
+ authHeaders?: Record<string, string>;
43
59
  /** Additional class name for the trigger */
44
60
  className?: string;
45
61
  }
46
- declare function TimeRangePicker({ preset, customRange, onPresetChange, onCustomRangeChange, onClearCustomRange, customRangeLabel: initialCustomLabel, showLive, isLive, onLiveChange, availablePresets, disabled, timezone, apiUrl, projectSlug, className, }: TimeRangePickerProps): import("react/jsx-runtime").JSX.Element;
62
+ declare function TimeRangePicker({ preset, customRange, onPresetChange, onCustomRangeChange, onClearCustomRange, customRangeLabel: initialCustomLabel, showLive, isLive, onLiveChange, availablePresets, disabled, timezone, apiUrl, projectSlug, authHeaders, className, }: TimeRangePickerProps): import("react/jsx-runtime").JSX.Element;
47
63
  declare namespace TimeRangePicker {
48
64
  var displayName: string;
49
65
  }
@@ -0,0 +1 @@
1
+ export {};
package/dist/elements.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BqBo07H_.cjs"),r=require("./index-DAWGW1Nj.cjs");exports.CREDITS_EXHAUSTED_MESSAGE=e.CREDITS_EXHAUSTED_MESSAGE;exports.Calendar=e.Calendar;exports.Chat=e.Chat;exports.ChatHistory=e.ChatHistory;exports.ElementsProvider=e.ElementsProvider;exports.GramElementsProvider=e.ElementsProvider;exports.MODELS=e.MODELS;exports.MessageContent=e.MessageContent;exports.PRESETS=e.PRESETS;exports.Replay=e.Replay;exports.ShareButton=e.ShareButton;exports.TimeRangePicker=e.TimeRangePicker;exports.ToolFallback=e.ToolFallback;exports.defineFrontendTool=e.defineFrontendTool;exports.describeStreamError=e.describeStreamError;exports.getPresetRange=e.getPresetRange;exports.trackError=e.trackError;exports.useRecordCassette=e.useRecordCassette;exports.useThreadId=e.useThreadId;exports.useChatId=r.useChatId;exports.useElements=r.useElements;exports.useGramElements=r.useElements;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DzZ1-jQY.cjs"),r=require("./index-C08dvTEo.cjs");exports.CREDITS_EXHAUSTED_MESSAGE=e.CREDITS_EXHAUSTED_MESSAGE;exports.Calendar=e.Calendar;exports.Chat=e.Chat;exports.ChatHistory=e.ChatHistory;exports.ElementsProvider=e.ElementsProvider;exports.GramElementsProvider=e.ElementsProvider;exports.MODELS=e.MODELS;exports.MessageContent=e.MessageContent;exports.PRESETS=e.PRESETS;exports.Replay=e.Replay;exports.ShareButton=e.ShareButton;exports.TimeRangePicker=e.TimeRangePicker;exports.ToolFallback=e.ToolFallback;exports.convertGramMessagesToExported=e.convertGramMessagesToExported;exports.convertGramMessagesToUIMessages=e.convertGramMessagesToUIMessages;exports.defineFrontendTool=e.defineFrontendTool;exports.describeStreamError=e.describeStreamError;exports.getPresetRange=e.getPresetRange;exports.trackError=e.trackError;exports.useRecordCassette=e.useRecordCassette;exports.useThreadId=e.useThreadId;exports.sleep=r.sleep;exports.useChatId=r.useChatId;exports.useElements=r.useElements;exports.useGramElements=r.useElements;
2
2
  //# sourceMappingURL=elements.cjs.map
package/dist/elements.js CHANGED
@@ -1,5 +1,5 @@
1
- import { aj as s, ap as r, aa as t, ab as o, a8 as n, a8 as E, al as d, ae as l, ao as m, af as S, ac as i, am as C, ad as T, ah as c, ak as h, an as u, ai as R, ag as g, a9 as P } from "./index-Dn0_JCoN.js";
2
- import { V as k, H as p, H } from "./index-CGoLfO5p.js";
1
+ import { aj as s, ar as r, aa as t, ab as o, a8 as n, a8 as E, al as m, ae as d, aq as l, af as S, ac as T, ao as c, ad as g, an as i, am as C, ah as h, ak as p, ap as u, ai as I, ag as M, a9 as R } from "./index-BFU6NvbL.js";
2
+ import { s as P, W as f, I as k, I as v } from "./index-B5lZrrO2.js";
3
3
  export {
4
4
  s as CREDITS_EXHAUSTED_MESSAGE,
5
5
  r as Calendar,
@@ -7,21 +7,24 @@ export {
7
7
  o as ChatHistory,
8
8
  n as ElementsProvider,
9
9
  E as GramElementsProvider,
10
- d as MODELS,
11
- l as MessageContent,
12
- m as PRESETS,
10
+ m as MODELS,
11
+ d as MessageContent,
12
+ l as PRESETS,
13
13
  S as Replay,
14
- i as ShareButton,
15
- C as TimeRangePicker,
16
- T as ToolFallback,
17
- c as defineFrontendTool,
18
- h as describeStreamError,
14
+ T as ShareButton,
15
+ c as TimeRangePicker,
16
+ g as ToolFallback,
17
+ i as convertGramMessagesToExported,
18
+ C as convertGramMessagesToUIMessages,
19
+ h as defineFrontendTool,
20
+ p as describeStreamError,
19
21
  u as getPresetRange,
20
- R as trackError,
21
- k as useChatId,
22
- p as useElements,
23
- H as useGramElements,
24
- g as useRecordCassette,
25
- P as useThreadId
22
+ P as sleep,
23
+ I as trackError,
24
+ f as useChatId,
25
+ k as useElements,
26
+ v as useGramElements,
27
+ M as useRecordCassette,
28
+ R as useThreadId
26
29
  };
27
30
  //# sourceMappingURL=elements.js.map
@@ -9,6 +9,19 @@ export interface ThreadListAdapterOptions {
9
9
  headers: Record<string, string>;
10
10
  /** Map to translate local thread IDs to UUIDs (shared with transport) */
11
11
  localIdToUuidMap?: Map<string, string>;
12
+ /**
13
+ * Extra query parameters forwarded to `chat.list` to filter which threads are
14
+ * listed. Opaque to the adapter — the consumer chooses the keys.
15
+ */
16
+ threadListFilters?: Record<string, string>;
17
+ /**
18
+ * Don't client-mint a chat id for a brand-new thread. When true, `initialize`
19
+ * waits for the transport to assign the id (via the shared `localIdToUuidMap`,
20
+ * e.g. a server-minted id reported through the transport context's
21
+ * `adoptChatId` bind closure) instead of generating one with
22
+ * `crypto.randomUUID()`. Use this when the backend owns chat-id creation.
23
+ */
24
+ deferThreadIdMinting?: boolean;
12
25
  }
13
26
  /**
14
27
  * Hook that creates a RemoteThreadListAdapter for the Gram API.
@@ -2945,14 +2945,28 @@ function tX(e, t) {
2945
2945
  if (!e)
2946
2946
  throw new Error(t);
2947
2947
  }
2948
- const yI = Pt(null), rX = () => {
2948
+ function rX(e, t) {
2949
+ return new Promise((r, n) => {
2950
+ if (t?.aborted) {
2951
+ n(new DOMException("Aborted", "AbortError"));
2952
+ return;
2953
+ }
2954
+ const i = () => {
2955
+ clearTimeout(a), t?.removeEventListener("abort", i), n(new DOMException("Aborted", "AbortError"));
2956
+ }, a = setTimeout(() => {
2957
+ t?.removeEventListener("abort", i), r();
2958
+ }, e);
2959
+ t?.addEventListener("abort", i, { once: !0 });
2960
+ });
2961
+ }
2962
+ const yI = Pt(null), nX = () => {
2949
2963
  const e = mt(yI);
2950
2964
  if (!e)
2951
2965
  throw new Error("useChatId must be used within ElementsProvider");
2952
2966
  return e.chatId;
2953
2967
  }, gI = Pt(
2954
2968
  void 0
2955
- ), nX = Pt(null), mA = () => {
2969
+ ), iX = Pt(null), mA = () => {
2956
2970
  const e = mt(gI);
2957
2971
  if (!e)
2958
2972
  throw new Error("useElements must be used within a ElementsProvider");
@@ -24828,7 +24842,7 @@ function WK(e) {
24828
24842
  }
24829
24843
  var sE = Symbol("radix.slottable");
24830
24844
  // @__NO_SIDE_EFFECTS__
24831
- function iX(e) {
24845
+ function aX(e) {
24832
24846
  const t = ({ children: r }) => /* @__PURE__ */ _(Nr, { children: r });
24833
24847
  return t.displayName = `${e}.Slottable`, t.__radixId = sE, t;
24834
24848
  }
@@ -24901,8 +24915,8 @@ var cE = Object.freeze({
24901
24915
  )
24902
24916
  );
24903
24917
  uE.displayName = YK;
24904
- var aX = uE;
24905
- function oX(e, t) {
24918
+ var oX = uE;
24919
+ function sX(e, t) {
24906
24920
  const r = P.createContext(t), n = (a) => {
24907
24921
  const { children: o, ...s } = a, c = P.useMemo(() => s, Object.values(s));
24908
24922
  return /* @__PURE__ */ _(r.Provider, { value: c, children: o });
@@ -29734,7 +29748,7 @@ function V4(e) {
29734
29748
  const t = ({ children: r }) => /* @__PURE__ */ _(Nr, { children: r });
29735
29749
  return t.displayName = `${e}.Slottable`, t.__radixId = wC, t;
29736
29750
  }
29737
- var sX = /* @__PURE__ */ V4("Slottable");
29751
+ var cX = /* @__PURE__ */ V4("Slottable");
29738
29752
  function K4(e) {
29739
29753
  return P.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === wC;
29740
29754
  }
@@ -30193,7 +30207,7 @@ function bY({
30193
30207
  const OC = Pt(
30194
30208
  null
30195
30209
  );
30196
- function cX({
30210
+ function uX({
30197
30211
  children: e,
30198
30212
  tools: t
30199
30213
  }) {
@@ -30729,7 +30743,7 @@ function XY(e) {
30729
30743
  return t.filter((i) => !n.has(i.id ?? i.language));
30730
30744
  }, t;
30731
30745
  }
30732
- const uX = XY([zK, YY]);
30746
+ const lX = XY([zK, YY]);
30733
30747
  export {
30734
30748
  l6 as A,
30735
30749
  Z4 as B,
@@ -30737,25 +30751,26 @@ export {
30737
30751
  EE as D,
30738
30752
  gI as E,
30739
30753
  CE as F,
30740
- MG as G,
30741
- mA as H,
30742
- RI as I,
30743
- yA as J,
30744
- xA as K,
30745
- c5 as L,
30746
- pE as M,
30747
- hE as N,
30748
- bv as O,
30754
+ Be as G,
30755
+ MG as H,
30756
+ mA as I,
30757
+ RI as J,
30758
+ yA as K,
30759
+ xA as L,
30760
+ c5 as M,
30761
+ pE as N,
30762
+ hE as O,
30749
30763
  pe as P,
30750
- CI as Q,
30764
+ bv as Q,
30751
30765
  BE as R,
30752
- sX as S,
30753
- nX as T,
30754
- fo as U,
30755
- rX as V,
30756
- eX as W,
30757
- YY as X,
30758
- zK as Y,
30766
+ cX as S,
30767
+ iX as T,
30768
+ CI as U,
30769
+ fo as V,
30770
+ nX as W,
30771
+ eX as X,
30772
+ YY as Y,
30773
+ zK as Z,
30759
30774
  tX as a,
30760
30775
  er as b,
30761
30776
  fc as c,
@@ -30767,20 +30782,20 @@ export {
30767
30782
  TG as i,
30768
30783
  Ya as j,
30769
30784
  z5 as k,
30770
- oX as l,
30785
+ sX as l,
30771
30786
  mT as m,
30772
30787
  u6 as n,
30773
30788
  d6 as o,
30774
- iX as p,
30775
- aX as q,
30776
- uX as r,
30777
- yI as s,
30778
- cX as t,
30789
+ aX as p,
30790
+ oX as q,
30791
+ lX as r,
30792
+ rX as s,
30793
+ yI as t,
30779
30794
  Br as u,
30780
- ae as v,
30781
- wA as w,
30782
- W4 as x,
30783
- yr as y,
30784
- Be as z
30795
+ uX as v,
30796
+ ae as w,
30797
+ wA as x,
30798
+ W4 as y,
30799
+ yr as z
30785
30800
  };
30786
- //# sourceMappingURL=index-CGoLfO5p.js.map
30801
+ //# sourceMappingURL=index-B5lZrrO2.js.map