@declarion/react 0.177.0 → 0.182.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.
@@ -1993,6 +1993,11 @@ type AgentRole = "user" | "assistant" | "tool" | "system";
1993
1993
  type AgentContentBlock = {
1994
1994
  type: "text";
1995
1995
  text: string;
1996
+ callback_data?: string;
1997
+ heard?: boolean;
1998
+ } | {
1999
+ type: "reaction";
2000
+ emoji?: string;
1996
2001
  } | {
1997
2002
  type: "tool_use";
1998
2003
  id: string;
@@ -2054,7 +2059,17 @@ interface AgentMessage {
2054
2059
  turn_id?: string | null;
2055
2060
  created_at: string;
2056
2061
  streaming?: boolean;
2057
- }
2062
+ bot_id?: string | null;
2063
+ chat_id?: string | null;
2064
+ topic_id?: string | null;
2065
+ sender_external_id?: string | null;
2066
+ sender_user_id?: string | null;
2067
+ delivery_key?: string | null;
2068
+ delivery_status?: AgentDeliveryStatus | null;
2069
+ bot?: string;
2070
+ sender_user?: string;
2071
+ }
2072
+ type AgentDeliveryStatus = "pending" | "sent" | "failed" | "unknown";
2058
2073
  type AgentTurnStatus = "queued" | "running" | "waiting" | "completed" | "failed" | "canceled";
2059
2074
  interface AgentTurn {
2060
2075
  id: string;
@@ -2111,6 +2126,9 @@ interface AgentConversation {
2111
2126
  created_by?: string;
2112
2127
  agent_id?: string;
2113
2128
  agent?: string;
2129
+ chat_id?: string | null;
2130
+ topic_id?: string | null;
2131
+ updated_at?: string;
2114
2132
  title?: string;
2115
2133
  model?: string;
2116
2134
  status: AgentConversationStatus;
@@ -1,95 +1,104 @@
1
- import { getMe as e, listTenants as t, logout as n, probeSession as r } from "../api/auth.js";
2
- import { startOrderNow as i } from "../api/access-expiry.js";
3
- import { cancelProactiveRefresh as a, endSessionInPage as o, ensureRefresh as s, isSignedOutInPage as c, scheduleProactiveRefresh as l, setLanguageReader as u } from "../api/client.js";
4
- import { sessionCaller as d } from "../api/audience.js";
5
- import { isEmbedTokenMode as f } from "../embed/token.js";
6
- import { warmRoutePages as p } from "../lib/capabilityPrefetch.js";
7
- import { usePreferencesStore as m } from "./preferences.js";
8
- import { create as h } from "zustand";
1
+ import { clearSignOut as e, startOrderNow as t } from "../api/access-expiry.js";
2
+ import { getMe as n, listTenants as r, logout as i, probeSession as a } from "../api/auth.js";
3
+ import { cancelProactiveRefresh as o, endSessionInPage as s, ensureRefresh as c, isSignedOutInPage as l, scheduleProactiveRefresh as u, setLanguageReader as d } from "../api/client.js";
4
+ import { sessionCaller as f } from "../api/audience.js";
5
+ import { isEmbedTokenMode as p } from "../embed/token.js";
6
+ import { warmRoutePages as m } from "../lib/capabilityPrefetch.js";
7
+ import { usePreferencesStore as h } from "./preferences.js";
8
+ import { create as g } from "zustand";
9
9
  // src/stores/auth.ts
10
- async function g(e, t, n) {
11
- let r = () => e({
10
+ async function _(t, n, r) {
11
+ let i = () => t({
12
12
  user: null,
13
13
  isAuthenticated: !1,
14
14
  isLoading: !1,
15
15
  sessionPresumed: !1,
16
16
  identitySince: performance.now()
17
17
  });
18
- if (c()) r();
19
- else try {
20
- let i = await n();
21
- if (c()) {
22
- r();
18
+ if (l()) {
19
+ i();
20
+ return;
21
+ }
22
+ let a = performance.now();
23
+ try {
24
+ let o = await r();
25
+ if (n().identitySince > a) return;
26
+ if (l()) {
27
+ i();
23
28
  return;
24
29
  }
25
- l(i.access_expires_at), e({
26
- user: i,
30
+ e(), u(o.access_expires_at), t({
31
+ user: o,
27
32
  isAuthenticated: !0,
28
33
  isLoading: !1,
29
- activeTenant: i.tenant ?? null,
34
+ activeTenant: o.tenant ?? null,
30
35
  identitySince: performance.now()
31
- }), t().loadTenants();
36
+ }), n().loadTenants();
32
37
  } catch {
33
- r();
38
+ n().identitySince <= a && i();
34
39
  }
35
40
  }
36
- var _ = h((a, l) => ({
41
+ var v = g((e, o) => ({
37
42
  user: null,
38
43
  isAuthenticated: !1,
39
44
  isLoading: !0,
40
45
  activeTenant: null,
41
46
  tenants: [],
42
47
  sessionPresumed: !1,
48
+ signedOutPresumed: !1,
43
49
  identitySince: 0,
44
50
  initialize: async () => {
45
- let e = i();
46
- e === "refresh-first" && (e = await s().then(() => "first-wave", () => "probe-first")), a({ sessionPresumed: e === "first-wave" }), e === "first-wave" && p(), await g(a, l, r), e === "probe-first" && l().isAuthenticated && p();
51
+ let n = t();
52
+ n === "refresh-first" && (n = await c().then(() => "first-wave", () => "probe-first")), e({
53
+ sessionPresumed: n === "first-wave",
54
+ signedOutPresumed: n === "probe-first" && window.location.pathname === "/login"
55
+ }), n === "first-wave" && m(), await _(e, o, a), n === "probe-first" && o().isAuthenticated && m();
47
56
  },
48
- reloadSession: () => g(a, l, e),
49
- recheckSession: () => g(a, l, r),
57
+ reloadSession: () => _(e, o, n),
58
+ recheckSession: () => _(e, o, a),
50
59
  refreshMe: async () => {
51
60
  try {
52
- let t = await e();
53
- if (c()) return;
54
- let n = l(), r = n.user?.id !== t.id || n.activeTenant?.id !== t.tenant?.id;
55
- a({
61
+ let t = await n();
62
+ if (l()) return;
63
+ let r = o(), i = r.user?.id !== t.id || r.activeTenant?.id !== t.tenant?.id;
64
+ e({
56
65
  user: t,
57
66
  activeTenant: t.tenant ?? null,
58
- ...r ? { identitySince: performance.now() } : {}
67
+ ...i ? { identitySince: performance.now() } : {}
59
68
  });
60
69
  } catch {}
61
70
  },
62
- setUser: (e, t) => {
63
- p(), a({
64
- user: e,
71
+ setUser: (t, n) => {
72
+ m(), e({
73
+ user: t,
65
74
  isAuthenticated: !0,
66
75
  isLoading: !1,
67
- activeTenant: t ?? null,
76
+ activeTenant: n ?? null,
68
77
  identitySince: performance.now()
69
78
  });
70
79
  },
71
80
  loadTenants: () => {
72
- t().then((e) => {
73
- c() || a({ tenants: e });
81
+ r().then((t) => {
82
+ l() || e({ tenants: t });
74
83
  }, () => void 0);
75
84
  },
76
- setActiveTenant: (e) => {
77
- a({ activeTenant: e });
85
+ setActiveTenant: (t) => {
86
+ e({ activeTenant: t });
78
87
  },
79
88
  logout: async () => {
80
- o(), a({
89
+ s(), e({
81
90
  user: null,
82
91
  isAuthenticated: !1,
83
92
  activeTenant: null,
84
93
  tenants: [],
85
94
  sessionPresumed: !1,
86
95
  identitySince: performance.now()
87
- }), await n(), y?.postMessage(v);
96
+ }), await i(), b?.postMessage(y);
88
97
  }
89
- })), v = "signed-out", y = typeof BroadcastChannel == "function" ? new BroadcastChannel("declarion.auth") : null;
90
- y?.addEventListener("message", (e) => {
91
- e.data === v && !f() && _.getState().isAuthenticated && (a(), window.location.assign("/login"));
92
- }), _.subscribe((e, t) => {
93
- u(d(e)), e.user?.id !== t.user?.id && m.getState().startIdentity();
98
+ })), y = "signed-out", b = typeof BroadcastChannel == "function" ? new BroadcastChannel("declarion.auth") : null;
99
+ b?.addEventListener("message", (e) => {
100
+ e.data === y && !p() && v.getState().isAuthenticated && (o(), window.location.assign("/login"));
101
+ }), v.subscribe((e, t) => {
102
+ d(f(e)), e.user?.id !== t.user?.id && h.getState().startIdentity();
94
103
  });
95
- export { _ as useAuthStore };
104
+ export { v as useAuthStore };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@declarion/react",
3
- "version": "0.177.0",
3
+ "version": "0.182.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "React SDK for Declarion, the schema-driven business apps platform.",