@8wave/ai-elements 0.101.0 → 0.102.0-beta.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/dist/_chunks/{Agent-DMCeO6o-.js → Agent-Cq-9OZHI.js} +77 -65
- package/dist/_chunks/Agent-Cq-9OZHI.js.map +1 -0
- package/dist/_chunks/{Document-C1Fp99qu.js → Document-s7Ct8xXa.js} +2 -2
- package/dist/_chunks/{Document-C1Fp99qu.js.map → Document-s7Ct8xXa.js.map} +1 -1
- package/dist/_chunks/{Media-c-RubI3_.js → Media-CMWDdtLL.js} +2 -2
- package/dist/_chunks/Media-CMWDdtLL.js.map +1 -0
- package/dist/_chunks/{PkToolRequestGeolocation-OZYwTIls.js → PkToolRequestGeolocation-hAaQJW-t.js} +2 -2
- package/dist/_chunks/{PkToolRequestGeolocation-OZYwTIls.js.map → PkToolRequestGeolocation-hAaQJW-t.js.map} +1 -1
- package/dist/_chunks/{PkToolRequestOAuthConnection-HmWtu2b3.js → PkToolRequestOAuthConnection-Bf_zoT2r.js} +2 -2
- package/dist/_chunks/{PkToolRequestOAuthConnection-HmWtu2b3.js.map → PkToolRequestOAuthConnection-Bf_zoT2r.js.map} +1 -1
- package/dist/_chunks/{PkToolShowForm-BzopoW7z.js → PkToolShowForm-CdUUAjPc.js} +2 -2
- package/dist/_chunks/{PkToolShowForm-BzopoW7z.js.map → PkToolShowForm-CdUUAjPc.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSources-Blw5XOA7.js → PkToolShowSources-U7etupUP.js} +2 -2
- package/dist/_chunks/{PkToolShowSources-Blw5XOA7.js.map → PkToolShowSources-U7etupUP.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSuggestedReply-nsXsvLUW.js → PkToolShowSuggestedReply-BvHgjMQ4.js} +2 -2
- package/dist/_chunks/{PkToolShowSuggestedReply-nsXsvLUW.js.map → PkToolShowSuggestedReply-BvHgjMQ4.js.map} +1 -1
- package/dist/ai-elements.es.js +6006 -5923
- package/dist/ai-elements.es.js.map +1 -1
- package/dist-vue/PkChatbot.js +1 -1
- package/dist-vue/PkChatbotMessages.js +1 -1
- package/dist-vue/PkChatbotViewChat.js +1 -1
- package/dist-vue/PkChatbotViewConversations.js +1 -1
- package/dist-vue/PkChatbotViewFiles.js +1 -1
- package/dist-vue/PkChatbotViewProfile.js +1 -1
- package/dist-vue/_chunks/{Agent-WEwgRwnY.js → Agent-Cy-XE9N1.js} +77 -66
- package/dist-vue/_chunks/Agent-Cy-XE9N1.js.map +1 -0
- package/dist-vue/_chunks/{Document-Vx3oKWp3.js → Document-B6xVkCfQ.js} +8 -8
- package/dist-vue/_chunks/{Document-Vx3oKWp3.js.map → Document-B6xVkCfQ.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbot-1Y7fGR-C.js → PkChatbot-CHe6t-LR.js} +6 -6
- package/dist-vue/_chunks/{PkChatbot-1Y7fGR-C.js.map → PkChatbot-CHe6t-LR.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotMessages-C6X92Igt.js → PkChatbotMessages-CWPSx2ce.js} +8 -8
- package/dist-vue/_chunks/{PkChatbotMessages-C6X92Igt.js.map → PkChatbotMessages-CWPSx2ce.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewChat-CBvcSg0J.js → PkChatbotViewChat-DeeGCFJf.js} +2674 -2651
- package/dist-vue/_chunks/PkChatbotViewChat-DeeGCFJf.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotViewConversations-BT5ojZEm.js → PkChatbotViewConversations-DXwqumyn.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewConversations-BT5ojZEm.js.map → PkChatbotViewConversations-DXwqumyn.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewFiles-DHzFAQZP.js → PkChatbotViewFiles-B4u87oH6.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotViewFiles-DHzFAQZP.js.map → PkChatbotViewFiles-B4u87oH6.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewProfile-DgN0Pydw.js → PkChatbotViewProfile-C_A0AP8x.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewProfile-DgN0Pydw.js.map → PkChatbotViewProfile-C_A0AP8x.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolRequestGeolocation-B1K2fN7U.js → PkToolRequestGeolocation-CaHo_418.js} +2 -2
- package/dist-vue/_chunks/{PkToolRequestGeolocation-B1K2fN7U.js.map → PkToolRequestGeolocation-CaHo_418.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolRequestOAuthConnection-D-qoxuPc.js → PkToolRequestOAuthConnection-URjYDFhm.js} +2 -2
- package/dist-vue/_chunks/{PkToolRequestOAuthConnection-D-qoxuPc.js.map → PkToolRequestOAuthConnection-URjYDFhm.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-BvOy4aeQ.js → PkToolShowDiagram-CuQyY0uv.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowDiagram-BvOy4aeQ.js.map → PkToolShowDiagram-CuQyY0uv.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowForm-BzzeoKss.js → PkToolShowForm-vXgu3bZO.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowForm-BzzeoKss.js.map → PkToolShowForm-vXgu3bZO.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSources-DdfHFaPA.js → PkToolShowSources-Die_j1bn.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowSources-DdfHFaPA.js.map → PkToolShowSources-Die_j1bn.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSuggestedReply-DSd1dnZM.js → PkToolShowSuggestedReply-CryAdy6t.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowSuggestedReply-DSd1dnZM.js.map → PkToolShowSuggestedReply-CryAdy6t.js.map} +1 -1
- package/dist-vue/_chunks/{createChatbotApiClient-xbpuy6e1.js → createChatbotApiClient-CoTSUkuj.js} +107 -99
- package/dist-vue/_chunks/createChatbotApiClient-CoTSUkuj.js.map +1 -0
- package/dist-vue/_chunks/{useChatbotStore-DWLLr7sg.js → useChatbotStore-BcLvyaIV.js} +1043 -1014
- package/dist-vue/_chunks/{useChatbotStore-DWLLr7sg.js.map → useChatbotStore-BcLvyaIV.js.map} +1 -1
- package/dist-vue/api.js +1 -1
- package/dist-vue/composables.js +2 -2
- package/dist-vue/index.js +63 -63
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/locales.js +2 -0
- package/dist-vue/packages/components/src/chat/PkAgentSettingsPanel.d.ts +2 -2
- package/dist-vue/packages/components/src/chat/PkReasoningSettings.d.ts +2 -2
- package/dist-vue/packages/components/src/chat/PkVoiceSession.d.ts +12 -0
- package/dist-vue/packages/components/src/chat/useVoiceSession.d.ts +7 -0
- package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +40 -10
- package/dist-vue/packages/models/src/schema/Agent.d.ts +39 -7
- package/dist-vue/packages/models/src/schema/AgentChatStatistics.d.ts +42 -0
- package/dist-vue/packages/models/src/schema/Chat.d.ts +46 -1
- package/dist-vue/packages/models/src/schema/ReasoningChat.d.ts +2 -2
- package/dist-vue/packages/models/src/schema/SubAgent.d.ts +2 -2
- package/dist-vue/packages/models/src/schema/constants.d.ts +7 -3
- package/package.json +1 -1
- package/dist/_chunks/Agent-DMCeO6o-.js.map +0 -1
- package/dist/_chunks/Media-c-RubI3_.js.map +0 -1
- package/dist-vue/_chunks/Agent-WEwgRwnY.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotViewChat-CBvcSg0J.js.map +0 -1
- package/dist-vue/_chunks/createChatbotApiClient-xbpuy6e1.js.map +0 -1
package/dist-vue/_chunks/{createChatbotApiClient-xbpuy6e1.js → createChatbotApiClient-CoTSUkuj.js}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { _ as e, a as t, b as n, f as r, g as i, h as a, l as o, n as s, o as c, v as l, x as ee } from "./schemas-COkEQ0wM.js";
|
|
2
|
-
import { i as u, t as
|
|
3
|
-
import {
|
|
2
|
+
import { i as u, t as te } from "./Media-yi949VrV.js";
|
|
3
|
+
import { F as d, a as f, b as p, c as m, f as h, k as ne, l as re, n as ie, s as ae, u as oe } from "./Agent-Cy-XE9N1.js";
|
|
4
4
|
import "./src-BbpxM17m.js";
|
|
5
|
-
import { r as
|
|
6
|
-
import { Ability as
|
|
5
|
+
import { r as g, t as se } from "./url-validation-uLMZ5-AU.js";
|
|
6
|
+
import { Ability as ce, buildMongoQueryMatcher as le, createAliasResolver as ue } from "@casl/ability";
|
|
7
7
|
import { createAccessControl as de } from "better-auth/plugins";
|
|
8
8
|
import { adminAc as fe, defaultStatements as pe, memberAc as _, ownerAc as me } from "better-auth/plugins/organization/access";
|
|
9
9
|
//#region ../../packages/models/src/schema/ConversationAnalysis.ts
|
|
@@ -46,7 +46,7 @@ var he = /* @__PURE__ */ function(e) {
|
|
|
46
46
|
text: l()
|
|
47
47
|
}), E = i({
|
|
48
48
|
type: r("file"),
|
|
49
|
-
mediaType: l().regex(
|
|
49
|
+
mediaType: l().regex(te),
|
|
50
50
|
url: ee(),
|
|
51
51
|
filename: l().optional(),
|
|
52
52
|
providerMetadata: e(l(), e(l(), n())).optional()
|
|
@@ -66,22 +66,30 @@ i({
|
|
|
66
66
|
maxOutputTokens: a().positive().optional(),
|
|
67
67
|
presencePenalty: a().min(-2).max(2).optional(),
|
|
68
68
|
frequencyPenalty: a().min(-2).max(2).optional(),
|
|
69
|
-
searchMode: s(
|
|
69
|
+
searchMode: s(re).optional(),
|
|
70
70
|
limit: a().optional(),
|
|
71
|
-
ranking:
|
|
72
|
-
reasoning:
|
|
73
|
-
webSearch:
|
|
71
|
+
ranking: ae.optional(),
|
|
72
|
+
reasoning: m,
|
|
73
|
+
webSearch: h.optional(),
|
|
74
74
|
maxStepCount: a().int().min(1).max(40).optional(),
|
|
75
|
-
disabledTools: t(s(
|
|
75
|
+
disabledTools: t(s(ie)).optional(),
|
|
76
76
|
fallbackModels: t(l()).optional(),
|
|
77
|
-
gatewayOptions:
|
|
78
|
-
deviceContext:
|
|
77
|
+
gatewayOptions: f.partial().optional(),
|
|
78
|
+
deviceContext: ne.optional(),
|
|
79
79
|
externalContext: e(l(), n()).optional(),
|
|
80
80
|
smoothStream: c().optional()
|
|
81
81
|
});
|
|
82
82
|
var O = /* @__PURE__ */ function(e) {
|
|
83
83
|
return e.SevereAbuse = "severe_abuse", e.HighRiskScore = "high_risk_score", e.RepeatedWarnings = "repeated_warnings", e;
|
|
84
|
-
}({})
|
|
84
|
+
}({});
|
|
85
|
+
s(/* @__PURE__ */ function(e) {
|
|
86
|
+
return e.Web = "web", e.WhatsApp = "whatsapp", e.Teams = "teams", e.Voice = "voice", e.Api = "api", e.Reasoning = "reasoning", e.Endpoint = "endpoint", e;
|
|
87
|
+
}({}));
|
|
88
|
+
var k = /* @__PURE__ */ new Set([
|
|
89
|
+
"output-available",
|
|
90
|
+
"output-error",
|
|
91
|
+
"output-denied"
|
|
92
|
+
]), A = i({
|
|
85
93
|
id: l(),
|
|
86
94
|
messages: t(n()),
|
|
87
95
|
title: l().nullable(),
|
|
@@ -107,20 +115,20 @@ var O = /* @__PURE__ */ function(e) {
|
|
|
107
115
|
lastMessageAt: u()
|
|
108
116
|
});
|
|
109
117
|
i({
|
|
110
|
-
...
|
|
111
|
-
...
|
|
118
|
+
...d.pagination(),
|
|
119
|
+
...d.sort([
|
|
112
120
|
"updatedAt",
|
|
113
121
|
"createdAt",
|
|
114
122
|
"lastMessageAt"
|
|
115
123
|
]),
|
|
116
|
-
...
|
|
117
|
-
...
|
|
118
|
-
...
|
|
119
|
-
...
|
|
124
|
+
...d.filters(["agentId", "userId"]),
|
|
125
|
+
...d.range("updatedAt"),
|
|
126
|
+
...d.range("lastMessageAt"),
|
|
127
|
+
...d.ids(),
|
|
120
128
|
startDate: l().optional(),
|
|
121
129
|
endDate: l().optional()
|
|
122
130
|
});
|
|
123
|
-
var
|
|
131
|
+
var j = i({
|
|
124
132
|
id: l(),
|
|
125
133
|
agentId: l().optional(),
|
|
126
134
|
organizationId: l(),
|
|
@@ -132,7 +140,7 @@ var A = i({
|
|
|
132
140
|
lastMessageAt: u(),
|
|
133
141
|
messages: t(n()),
|
|
134
142
|
blocked: c()
|
|
135
|
-
}),
|
|
143
|
+
}), M = class {
|
|
136
144
|
constructor(e, t) {
|
|
137
145
|
this.operator = e, this.value = t, Object.defineProperty(this, "_notes", { writable: !0 });
|
|
138
146
|
}
|
|
@@ -142,22 +150,22 @@ var A = i({
|
|
|
142
150
|
addNote(e) {
|
|
143
151
|
this._notes = this._notes || [], this._notes.push(e);
|
|
144
152
|
}
|
|
145
|
-
},
|
|
153
|
+
}, N = class extends M {}, P = class extends N {
|
|
146
154
|
constructor(e, t) {
|
|
147
155
|
if (!Array.isArray(t)) throw Error(`"${e}" operator expects to receive an array of conditions`);
|
|
148
156
|
super(e, t);
|
|
149
157
|
}
|
|
150
|
-
},
|
|
158
|
+
}, F = "__itself__", I = class extends M {
|
|
151
159
|
constructor(e, t, n) {
|
|
152
160
|
super(e, n), this.field = t;
|
|
153
161
|
}
|
|
154
|
-
},
|
|
162
|
+
}, L = new N("__null__", null);
|
|
155
163
|
Object.hasOwn;
|
|
156
|
-
function
|
|
164
|
+
function _e(e, t) {
|
|
157
165
|
let n;
|
|
158
166
|
for (let r = 0, i = t.length; r < i; r++) {
|
|
159
167
|
let i = t[r];
|
|
160
|
-
if (i instanceof
|
|
168
|
+
if (i instanceof P) {
|
|
161
169
|
if (i.operator !== e) {
|
|
162
170
|
n && n.push(i);
|
|
163
171
|
continue;
|
|
@@ -170,11 +178,11 @@ function L(e, t) {
|
|
|
170
178
|
}
|
|
171
179
|
return n || t;
|
|
172
180
|
}
|
|
173
|
-
function
|
|
181
|
+
function ve(e, t) {
|
|
174
182
|
if (t.length === 1) return t[0];
|
|
175
|
-
if (t.length === 0) return new
|
|
176
|
-
let n =
|
|
177
|
-
return n.length === 1 ? n[0] : (n.length, new
|
|
183
|
+
if (t.length === 0) return new P(e, t);
|
|
184
|
+
let n = _e(e, t);
|
|
185
|
+
return n.length === 1 ? n[0] : (n.length, new P(e, n));
|
|
178
186
|
}
|
|
179
187
|
Object.defineProperty(Object.create(null), "__@type@__", { value: "ignore value" });
|
|
180
188
|
//#endregion
|
|
@@ -188,108 +196,108 @@ var R = Object.defineProperty;
|
|
|
188
196
|
});
|
|
189
197
|
return t || R(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
190
198
|
})({
|
|
191
|
-
$all: () =>
|
|
199
|
+
$all: () => we,
|
|
192
200
|
$and: () => z,
|
|
193
|
-
$elemMatch: () =>
|
|
194
|
-
$eq: () =>
|
|
195
|
-
$exists: () =>
|
|
196
|
-
$gt: () =>
|
|
197
|
-
$gte: () =>
|
|
198
|
-
$in: () =>
|
|
199
|
-
$lt: () =>
|
|
200
|
-
$lte: () =>
|
|
201
|
-
$mod: () =>
|
|
202
|
-
$ne: () =>
|
|
203
|
-
$nin: () =>
|
|
204
|
-
$nor: () =>
|
|
205
|
-
$not: () =>
|
|
206
|
-
$options: () =>
|
|
201
|
+
$elemMatch: () => xe,
|
|
202
|
+
$eq: () => G,
|
|
203
|
+
$exists: () => Ee,
|
|
204
|
+
$gt: () => W,
|
|
205
|
+
$gte: () => U,
|
|
206
|
+
$in: () => H,
|
|
207
|
+
$lt: () => De,
|
|
208
|
+
$lte: () => Oe,
|
|
209
|
+
$mod: () => Te,
|
|
210
|
+
$ne: () => ke,
|
|
211
|
+
$nin: () => Ce,
|
|
212
|
+
$nor: () => ye,
|
|
213
|
+
$not: () => be,
|
|
214
|
+
$options: () => je,
|
|
207
215
|
$or: () => B,
|
|
208
|
-
$regex: () =>
|
|
209
|
-
$size: () =>
|
|
210
|
-
$where: () =>
|
|
216
|
+
$regex: () => Ae,
|
|
217
|
+
$size: () => Se,
|
|
218
|
+
$where: () => Me
|
|
211
219
|
});
|
|
212
220
|
var z = {
|
|
213
221
|
type: "compound",
|
|
214
|
-
validate:
|
|
222
|
+
validate: q,
|
|
215
223
|
parse(e, t, n) {
|
|
216
|
-
let r =
|
|
217
|
-
return
|
|
224
|
+
let r = V(e, t, n);
|
|
225
|
+
return ve(e.name, r);
|
|
218
226
|
}
|
|
219
|
-
}, B = z,
|
|
227
|
+
}, B = z, ye = {
|
|
220
228
|
type: "compound",
|
|
221
|
-
validate:
|
|
229
|
+
validate: q,
|
|
222
230
|
parse(e, t, n) {
|
|
223
|
-
let r =
|
|
224
|
-
return new
|
|
231
|
+
let r = V(e, t, n);
|
|
232
|
+
return new P(e.name, r);
|
|
225
233
|
}
|
|
226
234
|
};
|
|
227
|
-
function
|
|
235
|
+
function V(e, t, n) {
|
|
228
236
|
let r = Array(t.length);
|
|
229
237
|
for (let i = 0; i < t.length; i++) {
|
|
230
238
|
let a = t[i];
|
|
231
|
-
|
|
239
|
+
Ne(e, a, i), r[i] = n.parse(a);
|
|
232
240
|
}
|
|
233
241
|
return r;
|
|
234
242
|
}
|
|
235
|
-
var
|
|
243
|
+
var be = {
|
|
236
244
|
type: "field",
|
|
237
245
|
validate(e, t) {
|
|
238
246
|
if (!(t && (t instanceof RegExp || t.constructor === Object))) throw Error(`"${e.name}" expects to receive either regular expression or object of field operators`);
|
|
239
247
|
},
|
|
240
248
|
parse(e, t, n) {
|
|
241
|
-
let r = t instanceof RegExp ? new
|
|
242
|
-
return new
|
|
249
|
+
let r = t instanceof RegExp ? new I("regex", n.field, t) : n.parse(t, n);
|
|
250
|
+
return new P(e.name, [r]);
|
|
243
251
|
}
|
|
244
|
-
},
|
|
252
|
+
}, xe = {
|
|
245
253
|
type: "field",
|
|
246
254
|
validate(e, t) {
|
|
247
255
|
if (!t || t.constructor !== Object) throw Error(`"${e.name}" expects to receive an object with nested query or field level operators`);
|
|
248
256
|
},
|
|
249
257
|
parse(e, t, { parse: n, field: r, hasOperators: i }) {
|
|
250
|
-
let a = i(t) ? n(t, { field:
|
|
251
|
-
return new
|
|
258
|
+
let a = i(t) ? n(t, { field: F }) : n(t);
|
|
259
|
+
return new I(e.name, r, a);
|
|
252
260
|
}
|
|
253
|
-
},
|
|
261
|
+
}, Se = {
|
|
254
262
|
type: "field",
|
|
255
263
|
validate: Y("number")
|
|
256
|
-
},
|
|
264
|
+
}, H = {
|
|
257
265
|
type: "field",
|
|
258
|
-
validate:
|
|
259
|
-
},
|
|
266
|
+
validate: K
|
|
267
|
+
}, Ce = H, we = H, Te = {
|
|
260
268
|
type: "field",
|
|
261
269
|
validate(e, t) {
|
|
262
270
|
if (!Array.isArray(t) || t.length !== 2) throw Error(`"${e.name}" expects an array with 2 numeric elements`);
|
|
263
271
|
}
|
|
264
|
-
},
|
|
272
|
+
}, Ee = {
|
|
265
273
|
type: "field",
|
|
266
274
|
validate: Y("boolean")
|
|
267
|
-
},
|
|
275
|
+
}, U = {
|
|
268
276
|
type: "field",
|
|
269
|
-
validate:
|
|
270
|
-
},
|
|
277
|
+
validate: J
|
|
278
|
+
}, W = U, De = W, Oe = W, G = { type: "field" }, ke = G, Ae = {
|
|
271
279
|
type: "field",
|
|
272
280
|
validate(e, t) {
|
|
273
281
|
if (!(t instanceof RegExp) && typeof t != "string") throw Error(`"${e.name}" expects value to be a regular expression or a string that represents regular expression`);
|
|
274
282
|
},
|
|
275
283
|
parse(e, t, n) {
|
|
276
284
|
let r = typeof t == "string" ? new RegExp(t, n.query.$options || "") : t;
|
|
277
|
-
return new
|
|
285
|
+
return new I(e.name, n.field, r);
|
|
278
286
|
}
|
|
279
|
-
},
|
|
287
|
+
}, je = {
|
|
280
288
|
type: "field",
|
|
281
|
-
parse: () =>
|
|
282
|
-
},
|
|
289
|
+
parse: () => L
|
|
290
|
+
}, Me = {
|
|
283
291
|
type: "document",
|
|
284
292
|
validate: Y("function")
|
|
285
293
|
};
|
|
286
|
-
function
|
|
294
|
+
function K(e, t) {
|
|
287
295
|
if (!Array.isArray(t)) throw Error(`"${e.name}" expects value to be an array`);
|
|
288
296
|
}
|
|
289
|
-
function
|
|
290
|
-
if (
|
|
297
|
+
function q(e, t) {
|
|
298
|
+
if (K(e, t), !t.length) throw Error(`"${e.name}" expects to have at least one element in array`);
|
|
291
299
|
}
|
|
292
|
-
function
|
|
300
|
+
function J(e, t) {
|
|
293
301
|
if (!(typeof t == "string" || typeof t == "number" || t instanceof Date)) throw Error(`"${e.name}" expects value to be comparable (i.e., string, number or date)`);
|
|
294
302
|
}
|
|
295
303
|
function Y(e) {
|
|
@@ -297,7 +305,7 @@ function Y(e) {
|
|
|
297
305
|
if (typeof n !== e) throw Error(`"${t.name}" expects value to be a "${e}"`);
|
|
298
306
|
};
|
|
299
307
|
}
|
|
300
|
-
function
|
|
308
|
+
function Ne(e, t, n) {
|
|
301
309
|
let r = t;
|
|
302
310
|
if (!r || r.constructor !== Object) throw Error(`"${e.name}" expects item at index ${n} to be an object`);
|
|
303
311
|
}
|
|
@@ -307,7 +315,7 @@ var X = /* @__PURE__ */ function(e) {
|
|
|
307
315
|
return e.Backoffice = "backoffice", e.Frontoffice = "frontoffice", e.System = "system", e.Public = "public", e;
|
|
308
316
|
}({}), Z = /* @__PURE__ */ function(e) {
|
|
309
317
|
return e.All = "all", e.Todo = "todo", e.User = "user", e.Chat = "chat", e.Agent = "agent", e.SubAgent = "subAgent", e.Document = "document", e.AgentDocument = "agent_document", e.AgentAnalytic = "agent_analytic", e.McpServer = "mcp_server", e.Media = "media", e.RevisedAnswer = "revised_answer", e.Organization = "organization", e.Member = "member", e.Lead = "lead", e.MessageFeedback = "message_feedback", e.Backoffice = "backoffice", e.Frontoffice = "frontoffice", e.System = "system", e.Invitation = "invitation", e.Crawler = "crawler", e.ReasoningChat = "reasoning_chat", e.TimeTrackerChat = "time_tracker_chat", e.OrganizationExternalAuth = "organization_external_auth", e.AgentEndpoint = "agent_endpoint", e.AgentEndpointLog = "agent_endpoint_log", e.AgentApiTool = "agent_api_tool", e.DocumentFolder = "document_folder", e.Integration = "integration", e.Notification = "notification", e.PlatformConnection = "platform_connection", e;
|
|
310
|
-
}({}),
|
|
318
|
+
}({}), Pe = (e) => e ? [
|
|
311
319
|
{
|
|
312
320
|
subject: Z.Chat,
|
|
313
321
|
action: "create"
|
|
@@ -328,7 +336,7 @@ var X = /* @__PURE__ */ function(e) {
|
|
|
328
336
|
{
|
|
329
337
|
subject: Z.Agent,
|
|
330
338
|
action: "read",
|
|
331
|
-
condition: { status: { $eq:
|
|
339
|
+
condition: { status: { $eq: oe.Active } }
|
|
332
340
|
},
|
|
333
341
|
{
|
|
334
342
|
subject: Z.MessageFeedback,
|
|
@@ -339,23 +347,23 @@ var X = /* @__PURE__ */ function(e) {
|
|
|
339
347
|
action: "read",
|
|
340
348
|
condition: { createdBy: { $eq: e.user?.id } }
|
|
341
349
|
}
|
|
342
|
-
] : [],
|
|
350
|
+
] : [], Fe = ue({ modify: [
|
|
343
351
|
"read",
|
|
344
352
|
"update",
|
|
345
353
|
"delete"
|
|
346
|
-
] }),
|
|
347
|
-
new
|
|
348
|
-
conditionsMatcher:
|
|
349
|
-
resolveAction:
|
|
354
|
+
] }), Ie = le({ $or: B });
|
|
355
|
+
new ce(Pe(), {
|
|
356
|
+
conditionsMatcher: Ie,
|
|
357
|
+
resolveAction: Fe,
|
|
350
358
|
fieldMatcher: (e) => (t) => e.includes(t)
|
|
351
359
|
});
|
|
352
360
|
var Q = de(pe);
|
|
353
361
|
Q.newRole(fe.statements), Q.newRole(me.statements), Q.newRole(_.statements), Q.newRole(_.statements);
|
|
354
362
|
//#endregion
|
|
355
363
|
//#region ../../packages/composable/src/chatbot/api/resolveShortUrls.ts
|
|
356
|
-
async function
|
|
364
|
+
async function Le(e, t, n = {}) {
|
|
357
365
|
try {
|
|
358
|
-
let r =
|
|
366
|
+
let r = g(e), i = await fetch(`${r}/api/r/resolve`, {
|
|
359
367
|
method: "POST",
|
|
360
368
|
credentials: n.credentials ?? "include",
|
|
361
369
|
headers: {
|
|
@@ -371,12 +379,12 @@ async function Ie(e, t, n = {}) {
|
|
|
371
379
|
}
|
|
372
380
|
//#endregion
|
|
373
381
|
//#region ../../packages/composable/src/chatbot/api/createChatbotApiClient.ts
|
|
374
|
-
var
|
|
382
|
+
var Re = A.or(j);
|
|
375
383
|
function $(e) {
|
|
376
|
-
let t =
|
|
384
|
+
let t = Re.safeParse(e);
|
|
377
385
|
return t.success ? t.data : e;
|
|
378
386
|
}
|
|
379
|
-
async function
|
|
387
|
+
async function ze(e) {
|
|
380
388
|
let t = `${e.status} ${e.statusText}`.trim();
|
|
381
389
|
try {
|
|
382
390
|
let n = await e.json();
|
|
@@ -385,8 +393,8 @@ async function Re(e) {
|
|
|
385
393
|
return t;
|
|
386
394
|
}
|
|
387
395
|
}
|
|
388
|
-
function
|
|
389
|
-
let t = e.basePath ?
|
|
396
|
+
function Be(e) {
|
|
397
|
+
let t = e.basePath ? se(e.basePath) : `/api/v1/${X.Public}`, n = `${g(e.baseUrl)}${t}`, r = `${g(e.baseUrl)}${t.replace(/\/[^/]+$/, `/${X.Frontoffice}`)}`;
|
|
390
398
|
async function i(t, r, i = "json") {
|
|
391
399
|
let a = await fetch(`${n}${t}`, {
|
|
392
400
|
credentials: e.credentials ?? "include",
|
|
@@ -396,7 +404,7 @@ function ze(e) {
|
|
|
396
404
|
...r?.headers
|
|
397
405
|
}
|
|
398
406
|
});
|
|
399
|
-
if (!a.ok) throw Error(await
|
|
407
|
+
if (!a.ok) throw Error(await ze(a));
|
|
400
408
|
if (i !== "void" && a.status !== 204) return a.json();
|
|
401
409
|
}
|
|
402
410
|
return {
|
|
@@ -533,7 +541,7 @@ function ze(e) {
|
|
|
533
541
|
return i(`/agents/${encodeURIComponent(e)}/mcp-oauth/authorize?${n}`);
|
|
534
542
|
},
|
|
535
543
|
async createVoiceSession(e, t, n) {
|
|
536
|
-
return
|
|
544
|
+
return p.parse(await i(`/agents/${encodeURIComponent(e)}/voice/session`, {
|
|
537
545
|
method: "POST",
|
|
538
546
|
headers: { "Content-Type": "application/json" },
|
|
539
547
|
body: JSON.stringify({
|
|
@@ -550,7 +558,7 @@ function ze(e) {
|
|
|
550
558
|
}, "void");
|
|
551
559
|
},
|
|
552
560
|
resolveShortUrls(t) {
|
|
553
|
-
return
|
|
561
|
+
return Le(e.baseUrl, t, {
|
|
554
562
|
headers: e.headers?.(),
|
|
555
563
|
credentials: e.credentials
|
|
556
564
|
});
|
|
@@ -558,6 +566,6 @@ function ze(e) {
|
|
|
558
566
|
};
|
|
559
567
|
}
|
|
560
568
|
//#endregion
|
|
561
|
-
export { X as n,
|
|
569
|
+
export { X as n, k as r, Be as t };
|
|
562
570
|
|
|
563
|
-
//# sourceMappingURL=createChatbotApiClient-
|
|
571
|
+
//# sourceMappingURL=createChatbotApiClient-CoTSUkuj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createChatbotApiClient-CoTSUkuj.js","names":["c","l","d","f","s","n","e","t","i","r"],"sources":["../../../../packages/models/src/schema/ConversationAnalysis.ts","../../../../packages/models/src/schema/Chat.ts","../../../../node_modules/.pnpm/@ucast+core@2.0.0/node_modules/@ucast/core/dist/esm/index.mjs","../../../../node_modules/.pnpm/@ucast+mongo@3.0.0/node_modules/@ucast/mongo/dist/esm/index.mjs","../../../../packages/ability/src/types.ts","../../../../packages/ability/src/roles/User.ts","../../../../packages/ability/src/index.ts","../../../../packages/composable/src/chatbot/api/resolveShortUrls.ts","../../../../packages/composable/src/chatbot/api/createChatbotApiClient.ts"],"sourcesContent":["import * as z from 'zod'\n\nexport enum AbuseCategory {\n Harassment = 'harassment',\n HateSpeech = 'hate_speech',\n SexualContent = 'sexual_content',\n SelfHarm = 'self_harm',\n Violence = 'violence',\n PromptInjection = 'prompt_injection',\n DataExtraction = 'data_extraction',\n Spam = 'spam',\n OffTopicPersistent = 'off_topic_persistent',\n Impersonation = 'impersonation',\n}\n\nexport enum AbuseConfidence {\n Low = 'low',\n Medium = 'medium',\n High = 'high',\n}\n\nexport enum LlmIssueCategory {\n FalseSuccess = 'false_success',\n Hallucination = 'hallucination',\n OffBrand = 'off_brand',\n DataLeak = 'data_leak',\n InappropriateTone = 'inappropriate_tone',\n RefusalLoop = 'refusal_loop',\n Repetition = 'repetition',\n}\n\nexport enum ConversationAnalysisTrigger {\n SummaryCycle = 'summary_cycle',\n AgentRequest = 'agent_request',\n Manual = 'manual',\n}\n\nexport enum UserEngagement {\n High = 'high',\n Medium = 'medium',\n Low = 'low',\n Disengaged = 'disengaged',\n}\n\nexport enum UserTone {\n Polite = 'polite',\n Neutral = 'neutral',\n Impatient = 'impatient',\n Aggressive = 'aggressive',\n Abusive = 'abusive',\n}\n\nexport enum Sentiment {\n Positive = 'positive',\n Neutral = 'neutral',\n Negative = 'negative',\n Frustrated = 'frustrated',\n Excited = 'excited',\n}\n\nexport enum SentimentTrend {\n Improving = 'improving',\n Stable = 'stable',\n Degrading = 'degrading',\n}\n\nexport const ConversationAnalysisSchema = z.object({\n // --- Metadata (set programmatically, not by the LLM) ---\n analyzedAt: z.coerce.date().describe('When the analysis was generated.'),\n analysisTrigger: z\n .enum(ConversationAnalysisTrigger)\n .describe('What triggered this analysis run.'),\n\n // --- Sentiment & Tone ---\n sentiment: z\n .enum(Sentiment)\n .describe('Overall user sentiment in the conversation.'),\n sentimentTrend: z\n .enum(SentimentTrend)\n .describe('How the user sentiment evolved during the conversation.'),\n userTone: z\n .enum(UserTone)\n .describe('Predominant tone of the user messages.'),\n\n // --- Language ---\n language: z\n .string()\n .max(10)\n .describe(\n 'ISO 639-1 language code of the conversation (e.g. \"en\", \"it\").',\n ),\n\n // --- Topics ---\n topics: z\n .array(z.string().max(100))\n .max(10)\n .describe('Main topics discussed, as short lowercase labels.'),\n\n // --- User Abuse Detection ---\n userAbuseDetected: z\n .boolean()\n .describe(\n 'Whether user abuse was detected. If false, userAbuseCategories MUST be empty.',\n ),\n userAbuseCategories: z\n .array(z.enum(AbuseCategory))\n .default([])\n .describe(\n 'Abuse categories detected. Non-empty only if userAbuseDetected is true.',\n ),\n userAbuseConfidence: z\n .enum(AbuseConfidence)\n .optional()\n .describe(\n 'Confidence level of the abuse detection. Set only if userAbuseDetected is true.',\n ),\n userAbuseSummary: z\n .string()\n .max(500)\n .optional()\n .describe(\n 'Brief description of the abusive behavior detected. Always write in English. Set only if userAbuseDetected is true.',\n ),\n\n // --- LLM Quality Issues ---\n llmIssueDetected: z\n .boolean()\n .describe(\n 'Whether an LLM quality issue was detected. If false, llmIssueCategories MUST be empty.',\n ),\n llmIssueCategories: z\n .array(z.enum(LlmIssueCategory))\n .default([])\n .describe(\n 'LLM issue categories detected. Non-empty only if llmIssueDetected is true.',\n ),\n llmIssueSummary: z\n .string()\n .max(500)\n .optional()\n .describe(\n 'Brief description of the LLM quality issue detected. Always write in English. Set only if llmIssueDetected is true.',\n ),\n\n // --- Engagement ---\n userEngagement: z\n .enum(UserEngagement)\n .describe('Level of user engagement in the conversation.'),\n conversationGoalMet: z\n .boolean()\n .optional()\n .describe(\n 'Whether the user seems to have achieved what they came for. Leave undefined if unclear.',\n ),\n\n // --- Risk Score ---\n riskScore: z\n .number()\n .int()\n .min(0)\n .max(100)\n .describe(\n 'Overall risk score (0 = safe, 100 = critical). Combination of abuse severity, persistence and escalation.',\n ),\n})\n\nexport type ConversationAnalysis = z.infer<typeof ConversationAnalysisSchema>\n","import * as z from 'zod'\nimport { zodQs } from '../utils'\nimport type { UIMessage, LanguageModelUsage } from 'ai'\nimport { ConversationAnalysisSchema } from './ConversationAnalysis'\nimport {\n AgentBuiltInTool,\n AgentGatewayOptionsSchema,\n AgentReasoningSchema,\n AgentWebSearchSchema,\n AgentSearchMode,\n AgentRankingSchema,\n} from './Agent'\nimport { MIME_TYPE_REGEX } from './Media'\nimport type { PlatformContext } from './Platform'\n\nimport { DeviceContextSchema, type DeviceContext } from './DeviceContext'\n\nexport { DeviceContextSchema, type DeviceContext }\n\nconst TextPartSchema = z.object({\n type: z.literal('text'),\n text: z.string(),\n})\n\nconst FilePartSchema = z.object({\n type: z.literal('file'),\n mediaType: z.string().regex(MIME_TYPE_REGEX),\n url: z.url(),\n filename: z.string().optional(),\n providerMetadata: z\n .record(z.string(), z.record(z.string(), z.unknown()))\n .optional(),\n})\n\nconst MessagePartSchema = z.discriminatedUnion('type', [\n TextPartSchema,\n FilePartSchema,\n])\n\nexport const ChatRequestSchema = z.object({\n id: z.string(),\n messages: z.array(\n z.object({\n id: z.string().optional(),\n role: z.enum(['assistant', 'user']),\n content: z.string(),\n parts: z.array(MessagePartSchema),\n createdAt: z.string().optional(),\n }),\n ),\n model: z.string().optional(),\n temperature: z.number().optional(),\n prompt: z.string().optional(),\n maxOutputTokens: z.number().positive().optional(),\n presencePenalty: z.number().min(-2).max(2).optional(),\n frequencyPenalty: z.number().min(-2).max(2).optional(),\n searchMode: z.enum(AgentSearchMode).optional(),\n limit: z.number().optional(),\n ranking: AgentRankingSchema.optional(),\n reasoning: AgentReasoningSchema,\n webSearch: AgentWebSearchSchema.optional(),\n maxStepCount: z.number().int().min(1).max(40).optional(),\n disabledTools: z.array(z.enum(AgentBuiltInTool)).optional(),\n fallbackModels: z.array(z.string()).optional(),\n gatewayOptions: AgentGatewayOptionsSchema.partial().optional(),\n deviceContext: DeviceContextSchema.optional(),\n externalContext: z.record(z.string(), z.unknown()).optional(),\n smoothStream: z.boolean().optional(),\n})\n\nexport type ChatRequest = z.infer<typeof ChatRequestSchema>\n\nexport enum BlockedReasonCode {\n SevereAbuse = 'severe_abuse',\n HighRiskScore = 'high_risk_score',\n RepeatedWarnings = 'repeated_warnings',\n}\n\nexport type ChatMetadata = {\n ipAddress: string\n /** HTTP `Origin` of the request, empty for a server-to-server caller. */\n origin: string\n userAgent: string\n /**\n * Non-default transport the conversation arrived through (for example\n * `openai-api`), so cost and usage reports can isolate it. Absent for the\n * web and widget chat.\n */\n transport?: string\n}\n\n/**\n * Channel a conversation arrived through, as the analytics slice it.\n *\n * Derived at read time and never stored: a platform conversation is identified\n * by `chats.metadata.platform` ({@link PlatformType}), every other non-web\n * surface by `chats.metadata.transport` ({@link ChatTransport}), and a chat\n * carrying neither marker is the web chat or the widget (the historical\n * default, which is why those rows have nothing to read). `reasoning_chats`\n * and `agent_endpoint_logs` have no metadata at all, so each of those tables\n * is a channel by itself.\n *\n * Not to be confused with {@link AgentChannel}, which says where an agent is\n * published (frontoffice, app, widget): this says where a conversation came\n * from.\n *\n * Only the platforms we actually run are listed. `PlatformType` declares five\n * more, and one of those appearing in the data is reported under its own raw\n * value rather than folded into a bucket, so a channel nobody expected shows\n * up in the dashboard instead of hiding inside `other`.\n */\nexport enum ChatChannel {\n /** Web chat and embeddable widget: no marker on the row. */\n Web = 'web',\n WhatsApp = 'whatsapp',\n Teams = 'teams',\n /** Spoken session opened by us, `transport = voice`. */\n Voice = 'voice',\n /** OpenAI-compatible REST surface, `transport = openai-api`. */\n Api = 'api',\n /** Every row of `reasoning_chats`: the reasoning endpoint. */\n Reasoning = 'reasoning',\n /** Every row of `agent_endpoint_logs`: the custom agent endpoints. */\n Endpoint = 'endpoint',\n}\n\nexport const ChatChannelSchema = z.enum(ChatChannel)\n\nexport type ChatMessageActions =\n 'show-info' | 'revise' | 'regenerate' | 'upvote' | 'downvote' | 'feedback'\n\nexport type Chat = z.infer<typeof ChatSchema>\nexport type ChatsQuerystring = z.infer<typeof ChatsQuerystringSchema>\n\nexport type UIChatMessageDeviceContext = DeviceContext\n\nexport type UIChatMessageMetadata = {\n /** Unix timestamp (ms) when the stream started */\n createdAt?: number\n /** Unix timestamp (ms) when the stream finished */\n completedAt?: number\n /** Canonical model ID used for the request (e.g. `google/gemini-3-flash`) */\n model?: string\n /** Total tokens consumed across all steps */\n totalTokens?: number\n /** Per-tool-call durations in ms, keyed by tool call ID */\n partTimings?: Record<string, number>\n /** Client device context sent with the request */\n deviceContext?: UIChatMessageDeviceContext\n /** Platform channel context (WhatsApp/Teams), the device-context equivalent for platform turns */\n platformContext?: PlatformContext\n /** External context provided by the host application and validated server-side */\n externalContext?: Record<string, unknown>\n /** Provider that ultimately served the request (e.g. `vertex`, `openai`) */\n resolvedProvider?: string\n /** Actual model ID as exposed by the resolved provider (e.g. `gemini-3-flash-preview`) */\n resolvedModelId?: string\n /** Market cost of the request in USD, as a numeric string */\n cost?: string\n /** Number of model-level routing attempts made by the gateway */\n modelAttemptCount?: number\n /** Total number of provider-level attempts (includes retries across providers) */\n totalProviderAttemptCount?: number\n /** Whether Zero Data Retention was active for this request */\n zeroDataRetention?: boolean\n /** Whether the provider was instructed not to use the prompt for model training */\n disallowPromptTraining?: boolean\n /** Vercel AI Gateway generation ID, useful for tracing in the Vercel dashboard */\n generationId?: string\n /** Tokens served from the provider's prompt cache (e.g. Gemini context caching) */\n cachedTokens?: number\n /** Provider traffic tier (e.g. `PROVISIONED_THROUGHPUT`, `ON_DEMAND`) */\n trafficType?: string\n /**\n * Transport the message travelled through ({@link ChatTransport}), when it\n * was not the web chat itself: `voice` marks a spoken exchange (the user\n * text is the call transcription, the assistant text was read aloud),\n * `openai-api` an API turn. Absent on plain web messages.\n */\n transport?: string\n}\n\nexport type UIChatMessage = UIMessage & {\n metadata?: UIChatMessageMetadata\n}\n\n/**\n * States in which a tool invocation part waits for nothing more.\n *\n * Two readers, one meaning: the backend leaves such a part alone instead of\n * forcing it to a terminal state (`completeUnresolvedToolInvocations`), and the\n * web client counts it as answered when deciding whether to resume a suspended\n * turn (`sendAutomaticallyWhen` in `useChatbotStore`). They used to keep a copy\n * each, with different membership.\n */\nexport const TOOL_TERMINAL_STATES: ReadonlySet<string> = new Set([\n 'output-available',\n 'output-error',\n 'output-denied',\n])\n\nexport const ChatSchema = z.object({\n id: z.string(),\n messages: z.array(z.unknown()) as unknown as z.ZodType<UIChatMessage[]>,\n title: z.string().nullable(),\n summary: z.string().nullable(),\n messageCountAtLastSummary: z.string().nullable(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n metadata: z.record(z.string(), z.unknown()),\n totalCostInUSD: z.string(),\n usage: z.unknown() as unknown as z.ZodType<LanguageModelUsage>,\n agentId: z.string().nullable(),\n userId: z.string(),\n organizationId: z.string(),\n deleted: z.boolean(),\n deletedAt: z.coerce.date().nullable(),\n deletedBy: z.string().nullable(),\n conversationAnalysis: ConversationAnalysisSchema.nullable().optional(),\n blocked: z.boolean(),\n blockedAt: z.coerce.date().nullable(),\n blockedReasonCode: z.enum(BlockedReasonCode).nullable(),\n blockedReason: z.string().nullable(),\n warningCount: z.number(),\n lastMessageAt: z.coerce.date(),\n})\n\nexport const ChatsQuerystringSchema = z.object({\n ...zodQs.pagination(),\n ...zodQs.sort(['updatedAt', 'createdAt', 'lastMessageAt']),\n ...zodQs.filters(['agentId', 'userId']),\n ...zodQs.range('updatedAt'),\n ...zodQs.range('lastMessageAt'),\n ...zodQs.ids(),\n startDate: z.string().optional(),\n endDate: z.string().optional(),\n})\n\nexport const ChatsPublicSchema = z.object({\n id: z.string(),\n agentId: z.string().optional(),\n organizationId: z.string(),\n summary: z.string().optional(),\n title: z.string().optional(),\n userId: z.string(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n lastMessageAt: z.coerce.date(),\n messages: z.array(z.unknown()),\n blocked: z.boolean(),\n})\n\nexport type ChatPublic = z.infer<typeof ChatsPublicSchema>\n","var e=class{constructor(e,t){this.operator=e,this.value=t,Object.defineProperty(this,`_notes`,{writable:!0})}get notes(){return this._notes}addNote(e){this._notes=this._notes||[],this._notes.push(e)}},t=class extends e{},n=class extends t{constructor(e,t){if(!Array.isArray(t))throw Error(`\"${e}\" operator expects to receive an array of conditions`);super(e,t)}};const r=`__itself__`;var i=class extends e{constructor(e,t,n){super(e,n),this.field=t}};const a=new t(`__null__`,null),o=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t));function s(e,t){return t instanceof n&&t.operator===e}function c(e,t){let r;for(let i=0,a=t.length;i<a;i++){let a=t[i];if(a instanceof n){if(a.operator!==e){r&&r.push(a);continue}if(a.value.length===0)continue;r||(r=t.slice(0,i));let n=a.value;for(let e=0,t=n.length;e<t;e++)r.push(n[e])}else r&&r.push(a)}return r||t}function l(e,t){if(t.length===1)return t[0];if(t.length===0)return new n(e,t);let r=c(e,t);return r.length===1?r[0]:(r.length,new n(e,r))}const u=e=>e,d=()=>Object.create(null),f=Object.defineProperty(d(),`__@type@__`,{value:`ignore value`});function p(e,t,n=!1){if(!e||e&&e.constructor!==Object)return!1;for(let r in e)if(o(e,r)&&o(t,r)&&(!n||e[r]!==f))return!0;return!1}function m(e){let t=[];for(let n in e)o(e,n)&&e[n]!==f&&t.push(n);return t}function h(e,t){t!==a&&e.push(t)}const g=e=>l(`and`,e),_=e=>l(`or`,e);function v(e,t){let n=e[t];if(typeof n!=`function`)throw Error(`Unable to interpret \"${String(t)}\" condition. Did you forget to register interpreter for it?`);return n}function y(e){return e.operator}function b(e,t){let n=t,r=n&&n.getInterpreterName||y,i;switch(n?n.numberOfArguments:0){case 1:i=(t=>v(e,r(t,n))(t,a));break;case 3:i=((t,i,o)=>v(e,r(t,n))(t,i,o,a));break;default:i=((t,i)=>v(e,r(t,n))(t,i,a));break}let a={...n,interpret:i};return a.interpret}const x={compound(e,t,r){let i=(Array.isArray(t)?t:[t]).map(e=>r.parse(e));return new n(e.name,i)},field(e,t,n){return new i(e.name,n.field,t)},document(e,n){return new t(e.name,n)}};var S=class{constructor(e,t=d()){this.parse=this.parse.bind(this),this._options={operatorToConditionName:t.operatorToConditionName||u,defaultOperatorName:t.defaultOperatorName||`eq`,mergeFinalConditions:t.mergeFinalConditions||g},this._instructions=Object.keys(e).reduce((t,n)=>(t[n]={name:this._options.operatorToConditionName(n),...e[n]},t),{}),this._fieldInstructionContext={...t.fieldContext,field:``,query:{},parse:this.parse,hasOperators:e=>p(e,this._instructions,t.useIgnoreValue)},this._documentInstructionContext={...t.documentContext,parse:this.parse,query:{}},this._objectKeys=t.useIgnoreValue?m:Object.keys}setParse(e){this.parse=e,this._fieldInstructionContext.parse=e,this._documentInstructionContext.parse=e}parseField(e,t,n,r){let i=this._instructions[t];if(!i)throw Error(`Unsupported operator \"${t}\"`);if(i.type!==`field`)throw Error(`Unexpected ${i.type} operator \"${t}\" at field level`);return this._fieldInstructionContext.field=e,this._fieldInstructionContext.query=r,this.parseInstruction(i,n,this._fieldInstructionContext)}parseInstruction(e,t,n){return typeof e.validate==`function`&&e.validate(e,t),(e.parse||x[e.type])(e,t,n)}parseFieldOperators(e,t){let n=[],r=this._objectKeys(t);for(let i=0,a=r.length;i<a;i++){let a=r[i];if(!this._instructions[a])throw Error(`Field query for \"${e}\" may contain only operators or a plain object as a value`);h(n,this.parseField(e,a,t[a],t))}return n}parse(e){let t=[],n=this._objectKeys(e);this._documentInstructionContext.query=e;for(let r=0,i=n.length;r<i;r++){let i=n[r],a=e[i],o=this._instructions[i];if(o){if(o.type!==`document`&&o.type!==`compound`)throw Error(`Cannot use parsing instruction for operator \"${i}\" in \"document\" context as it is supposed to be used in \"${o.type}\" context`);h(t,this.parseInstruction(o,a,this._documentInstructionContext))}else this._fieldInstructionContext.hasOperators(a)?t.push(...this.parseFieldOperators(i,a)):h(t,this.parseField(i,this._options.defaultOperatorName,a,e))}return this._options.mergeFinalConditions(t)}};function C(e,t){return(n,...r)=>{let i=e(n,...r),a=t.bind(null,i);return Object.defineProperty(a,`ast`,{value:i}),a}}export{n as CompoundCondition,e as Condition,t as DocumentCondition,i as FieldCondition,r as ITSELF,a as NULL_CONDITION,S as ObjectQueryParser,g as buildAnd,_ as buildOr,b as createInterpreter,C as createTranslatorFactory,x as defaultInstructionParsers,p as hasOperators,u as identity,f as ignoreValue,s as isCompound,d as object,l as optimizedCompoundCondition};\n//# sourceMappingURL=index.mjs.map","import{CompoundCondition as e,FieldCondition as t,ITSELF as n,NULL_CONDITION as r,ObjectQueryParser as i,buildAnd as a,defaultInstructionParsers as o,optimizedCompoundCondition as s}from\"@ucast/core\";var c=Object.defineProperty,l=((e,t)=>{let n={};for(var r in e)c(n,r,{get:e[r],enumerable:!0});return t||c(n,Symbol.toStringTag,{value:`Module`}),n})({$all:()=>y,$and:()=>u,$elemMatch:()=>h,$eq:()=>E,$exists:()=>x,$gt:()=>C,$gte:()=>S,$in:()=>_,$lt:()=>w,$lte:()=>T,$mod:()=>b,$ne:()=>D,$nin:()=>v,$nor:()=>f,$not:()=>m,$options:()=>k,$or:()=>d,$regex:()=>O,$size:()=>g,$where:()=>A});const u={type:`compound`,validate:M,parse(e,t,n){let r=p(e,t,n);return s(e.name,r)}},d=u,f={type:`compound`,validate:M,parse(t,n,r){let i=p(t,n,r);return new e(t.name,i)}};function p(e,t,n){let r=Array(t.length);for(let i=0;i<t.length;i++){let a=t[i];F(e,a,i),r[i]=n.parse(a)}return r}const m={type:`field`,validate(e,t){if(!(t&&(t instanceof RegExp||t.constructor===Object)))throw Error(`\"${e.name}\" expects to receive either regular expression or object of field operators`)},parse(n,r,i){let a=r instanceof RegExp?new t(`regex`,i.field,r):i.parse(r,i);return new e(n.name,[a])}},h={type:`field`,validate(e,t){if(!t||t.constructor!==Object)throw Error(`\"${e.name}\" expects to receive an object with nested query or field level operators`)},parse(e,r,{parse:i,field:a,hasOperators:o}){let s=o(r)?i(r,{field:n}):i(r);return new t(e.name,a,s)}},g={type:`field`,validate:P(`number`)},_={type:`field`,validate:j},v=_,y=_,b={type:`field`,validate(e,t){if(!Array.isArray(t)||t.length!==2)throw Error(`\"${e.name}\" expects an array with 2 numeric elements`)}},x={type:`field`,validate:P(`boolean`)},S={type:`field`,validate:N},C=S,w=C,T=C,E={type:`field`},D=E,O={type:`field`,validate(e,t){if(!(t instanceof RegExp)&&typeof t!=`string`)throw Error(`\"${e.name}\" expects value to be a regular expression or a string that represents regular expression`)},parse(e,n,r){let i=typeof n==`string`?new RegExp(n,r.query.$options||``):n;return new t(e.name,r.field,i)}},k={type:`field`,parse:()=>r},A={type:`document`,validate:P(`function`)};function j(e,t){if(!Array.isArray(t))throw Error(`\"${e.name}\" expects value to be an array`)}function M(e,t){if(j(e,t),!t.length)throw Error(`\"${e.name}\" expects to have at least one element in array`)}function N(e,t){if(!(typeof t==`string`||typeof t==`number`||t instanceof Date))throw Error(`\"${e.name}\" expects value to be comparable (i.e., string, number or date)`)}function P(e){return(t,n)=>{if(typeof n!==e)throw Error(`\"${t.name}\" expects value to be a \"${e}\"`)}}function F(e,t,n){let r=t;if(!r||r.constructor!==Object)throw Error(`\"${e.name}\" expects item at index ${n} to be an object`)}var I=class extends i{constructor(e){super(e,{defaultOperatorName:`$eq`,operatorToConditionName:e=>e.slice(1)})}parse(e,t){return t&&t.field?a(this.parseFieldOperators(t.field,e)):super.parse(e)}};const L=l;export{y as $all,u as $and,h as $elemMatch,E as $eq,x as $exists,C as $gt,S as $gte,_ as $in,w as $lt,T as $lte,b as $mod,D as $ne,v as $nin,f as $nor,m as $not,k as $options,d as $or,O as $regex,g as $size,A as $where,I as MongoQueryParser,L as allParsingInstructions,o as defaultParsers};\n//# sourceMappingURL=index.mjs.map","import type { MongoQuery } from '@ucast/mongo2js'\n\n// Minimal structural shape of the better-auth session consumed here.\n// Declared locally to avoid a workspace dependency cycle with `auth`\n// (auth depends on `ability` for its access-control config).\n// The full `auth` Session is structurally assignable to this type.\nexport type Session = {\n session: {\n activeOrganizationId?: string | null\n organizationRole?: string | null\n }\n user: {\n id?: string\n role?: string | null\n }\n}\n\nexport enum Audience {\n Backoffice = 'backoffice',\n Frontoffice = 'frontoffice',\n System = 'system',\n Public = 'public',\n}\n\nexport enum Subject {\n All = 'all',\n Todo = 'todo',\n User = 'user',\n Chat = 'chat',\n Agent = 'agent',\n SubAgent = 'subAgent',\n Document = 'document',\n AgentDocument = 'agent_document',\n AgentAnalytic = 'agent_analytic',\n McpServer = 'mcp_server',\n Media = 'media',\n RevisedAnswer = 'revised_answer',\n Organization = 'organization',\n Member = 'member',\n Lead = 'lead',\n MessageFeedback = 'message_feedback',\n Backoffice = 'backoffice',\n Frontoffice = 'frontoffice',\n System = 'system',\n Invitation = 'invitation',\n Crawler = 'crawler',\n ReasoningChat = 'reasoning_chat',\n TimeTrackerChat = 'time_tracker_chat',\n OrganizationExternalAuth = 'organization_external_auth',\n AgentEndpoint = 'agent_endpoint',\n AgentEndpointLog = 'agent_endpoint_log',\n AgentApiTool = 'agent_api_tool',\n DocumentFolder = 'document_folder',\n Integration = 'integration',\n Notification = 'notification',\n PlatformConnection = 'platform_connection',\n}\n\n// action\nexport type Action =\n | 'create'\n | 'read'\n | 'update'\n | 'delete'\n | 'manage'\n | 'impersonate'\n | 'invite'\n | 'access'\n | 'clone'\n | 'ban'\n | 'unban'\n | 'change-role'\n | 'resend'\n | 'cancel'\n | 'execute'\n | 'refill'\n\nexport type Capability = {\n action: Action\n subject: Subject\n fields?: string[]\n condition?: MongoQuery\n inverted?: boolean\n}\n\nexport type CapabilitiesFactory = (\n currentSession?: Session | null,\n) => Capability[]\n","import { AgentStatus } from 'models'\nimport type { CapabilitiesFactory } from '../types'\nimport { Subject } from '../types'\n\nconst GuestCapabilities: CapabilitiesFactory = (currentSession) => {\n if (!currentSession) {\n return []\n }\n return [\n // chats\n {\n subject: Subject.Chat,\n action: 'create',\n },\n {\n subject: Subject.Chat,\n action: 'read',\n condition: {\n createdBy: {\n $eq: currentSession.user?.id,\n },\n },\n },\n {\n subject: Subject.Chat,\n action: 'update',\n },\n {\n subject: Subject.Chat,\n action: 'delete',\n },\n // agents\n {\n subject: Subject.Agent,\n action: 'read',\n condition: {\n status: {\n $eq: AgentStatus.Active,\n },\n },\n },\n // feedbacks\n {\n subject: Subject.MessageFeedback,\n action: 'create',\n },\n {\n subject: Subject.MessageFeedback,\n action: 'read',\n condition: {\n createdBy: {\n $eq: currentSession.user?.id,\n },\n },\n },\n ]\n}\nexport default GuestCapabilities\n","import type { MongoAbility, InferSubjects, ForcedSubject } from '@casl/ability'\nimport type { MongoQuery } from '@ucast/mongo2js'\nimport { Action, Capability, Subject, type Session } from './types'\nimport { $or } from '@ucast/mongo2js'\nimport {\n AbilityBuilder,\n createMongoAbility,\n buildMongoQueryMatcher,\n Ability as PureAbility,\n createAliasResolver,\n FieldMatcher,\n subject as caslSubject,\n} from '@casl/ability'\nimport { organizationCapabilitiesByRole, userCapabilitiesByRole } from './roles'\nimport DefaultCapabilities from './roles/User'\nimport { createAccessControl } from 'better-auth/plugins'\nimport {\n adminAc,\n defaultStatements,\n memberAc,\n ownerAc,\n} from 'better-auth/plugins/organization/access'\n\nexport const OrganizationRoles = {\n admin: 'admin',\n owner: 'owner',\n member: 'member',\n user: 'user',\n} as const\n\nexport const UserRoles = {\n admin: 'admin',\n user: 'user',\n} as const\n\n// action alias\nconst resolveAction = createAliasResolver({\n modify: ['read', 'update', 'delete'],\n})\n\n// subject\nexport type AbilitySubject =\n | InferSubjects<'all' | Subject, true>\n | ForcedSubject<InferSubjects<'all' | Subject, true>>\ntype Ability = MongoAbility<[Action, AbilitySubject]>\n\n// matcher\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst conditionsMatcher = buildMongoQueryMatcher({ $or } as Record<string, any>)\nconst fieldMatcher: FieldMatcher = (fields) => (field) => fields.includes(field)\n\n// ability\nexport const ability = new PureAbility<[Action, AbilitySubject], MongoQuery>(\n DefaultCapabilities(),\n {\n conditionsMatcher,\n resolveAction,\n fieldMatcher,\n },\n)\n\nexport const isValidOrganizationRole = (\n role?: string | null,\n): role is keyof typeof OrganizationRoles => {\n if (!role) {\n return false\n }\n return role in OrganizationRoles\n}\n\nexport const isValidUserRole = (\n role?: string | null,\n): role is keyof typeof UserRoles => {\n if (!role) {\n return false\n }\n return role in UserRoles\n}\n\nexport const getOrganizationRoleCapabilities = (\n currentSession?: Session | null,\n): Capability[] => {\n const organizationRole = currentSession?.session?.organizationRole\n if (!isValidOrganizationRole(organizationRole)) {\n return DefaultCapabilities(currentSession)\n }\n const capabilities = organizationCapabilitiesByRole[organizationRole]\n if (typeof capabilities === 'function') {\n return capabilities(currentSession)\n }\n return capabilities\n}\n\nexport const getUserRoleCapabilities = (\n currentSession?: Session | null,\n): Capability[] => {\n const userRole = currentSession?.user?.role\n if (!isValidUserRole(userRole)) {\n return DefaultCapabilities(currentSession)\n }\n const capabilities = userCapabilitiesByRole[userRole]\n if (typeof capabilities === 'function') {\n return capabilities(currentSession)\n }\n return capabilities\n}\n\n/**\n * Builds a standalone ability instance for a session, without touching the\n * shared singleton. Use for per-call checks outside the HTTP request flow\n * (e.g. MCP tool handlers).\n */\nexport const buildAbilityForSession = (\n currentSession?: Session | null,\n): Ability => {\n const { can, build, cannot } = new AbilityBuilder<Ability>(\n createMongoAbility,\n )\n const organizationRoleCapabilities =\n getOrganizationRoleCapabilities(currentSession)\n const userRoleCapabilities = getUserRoleCapabilities(currentSession)\n const capabilities = [\n ...organizationRoleCapabilities,\n ...userRoleCapabilities,\n ]\n capabilities.forEach((capability) => {\n const { action, subject, fields, condition, inverted } = capability\n if (inverted) {\n cannot(action, subject, fields, condition)\n return\n }\n can(action, subject, fields, condition)\n })\n return build({\n conditionsMatcher,\n resolveAction,\n fieldMatcher,\n })\n}\n\nexport const updateAbilityFromSession = (currentSession?: Session | null) => {\n ability.update(buildAbilityForSession(currentSession).rules)\n}\n\nexport type PermissionMap = Partial<Record<Action, Subject>>\n\n/**\n * Evaluates a route-style permission map ({ action: Subject }) against an\n * ability instance. When `payload` is provided it is bound as subject\n * conditions, same as the HTTP route preHandler does with `request.body`.\n * Returns the first denied pair, or null when every check passes.\n * Single source of truth for both the HTTP preHandler and the Platform MCP\n * tool handlers.\n */\nexport const findDeniedPermission = (\n abilityInstance: Pick<Ability, 'can'>,\n permissions: PermissionMap,\n payload?: unknown,\n): { action: Action; subject: Subject } | null => {\n let action: Action\n for (action in permissions) {\n const actionSubject = permissions[action]\n if (!actionSubject) {\n continue\n }\n const target = payload\n ? caslSubject(\n actionSubject,\n payload as Record<PropertyKey, unknown>,\n )\n : actionSubject\n if (!abilityInstance.can(action, target)) {\n return { action, subject: actionSubject }\n }\n }\n return null\n}\n\nconst ac = createAccessControl(defaultStatements)\nconst adminRole = ac.newRole(adminAc.statements)\nconst ownerRole = ac.newRole(ownerAc.statements)\nconst memberRole = ac.newRole(memberAc.statements)\nconst userRole = ac.newRole(memberAc.statements)\n\nexport const betterAuthOrganizationSettings = {\n ac,\n roles: {\n owner: ownerRole,\n admin: adminRole,\n member: memberRole,\n user: userRole,\n },\n}\n\nexport * from './types'\nexport { subject } from '@casl/ability'\n","import { removeTrailingSlash } from 'utils'\n\nexport interface ResolveShortUrlsOptions {\n /** Extra headers to send (e.g. auth). */\n headers?: Record<string, string>\n /** Fetch credentials mode. Defaults to `'include'`. */\n credentials?: RequestCredentials\n}\n\n/**\n * Single implementation of the short-url batch resolve used across apps\n * (chatbot api client, frontend app root). Maps `/api/r/<hash>` short urls back\n * to their real target via `POST <backend>/api/r/resolve`.\n *\n * The redirect endpoint lives at `/api/r`, outside the JSON:API basePath, and\n * is unauthenticated. Returns an empty map (short urls left untouched) on any\n * failure so callers never have to handle errors.\n */\nexport async function resolveShortUrls(\n backendUrl: string,\n hashes: string[],\n options: ResolveShortUrlsOptions = {},\n): Promise<Record<string, string>> {\n try {\n const root = removeTrailingSlash(backendUrl)\n const response = await fetch(`${root}/api/r/resolve`, {\n method: 'POST',\n credentials: options.credentials ?? 'include',\n headers: {\n ...options.headers,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ hashes }),\n })\n if (!response.ok) {\n return {}\n }\n const data = (await response.json()) as {\n urls?: Record<string, string>\n }\n return data.urls ?? {}\n } catch {\n return {}\n }\n}\n","import { Audience } from 'ability'\nimport { ChatSchema, ChatsPublicSchema, VoiceSessionSchema } from 'models'\nimport type {\n AgentAccess,\n Chat,\n DeviceContext,\n MessageFeedback,\n AgentPublic,\n MediaSource,\n VoiceSession,\n} from 'models'\nimport { addInitialSlash, removeTrailingSlash } from 'utils'\nimport { resolveShortUrls as resolveShortUrlsRequest } from './resolveShortUrls'\n\n// The chats endpoints respond with the full shape (frontoffice) or the\n// trimmed public one — same union the backend declares. Parsing coerces the\n// date fields (plain JSON strings otherwise); on mismatch keep the raw\n// payload instead of failing.\nconst ConversationSchema = ChatSchema.or(ChatsPublicSchema)\nfunction parseConversation(raw: unknown): Chat {\n const result = ConversationSchema.safeParse(raw)\n return (result.success ? result.data : raw) as Chat\n}\n\n/**\n * What went wrong, in words, from the problem+json the backend answers with\n * (`{ type, title, status, message }`). Falling straight back to the status\n * produced \"API error: 409\" on screen, which tells the reader nothing and hides\n * a message that was already there and already explains the fix.\n */\nasync function readErrorMessage(response: Response): Promise<string> {\n const fallback = `${response.status} ${response.statusText}`.trim()\n try {\n const body = (await response.json()) as {\n message?: string\n title?: string\n }\n return body.message?.trim() || body.title?.trim() || fallback\n } catch {\n return fallback\n }\n}\n\nexport interface ChatbotApiClientOptions {\n baseUrl: string\n basePath?: string\n headers?: () => Record<string, string> | undefined\n credentials?: RequestCredentials\n}\n\nexport interface SubmitFeedbackPayload {\n messageId: string\n chatId: string\n agentId: string\n vote?: 'upvote' | 'downvote'\n userQuestion: string\n assistantMessage: string\n comment?: string\n}\n\nexport interface SubmitLeadPayload {\n agentId: string\n chatId: string\n [key: string]: unknown\n}\n\n/** A file from the user's \"My files\" KB, as listed for a chat. */\nexport interface ChatbotFile {\n documentId: string\n name: string | null\n mimeType: string | null\n indexStatus: string\n createdAt: string\n}\n\nexport interface ChatbotApiClient {\n getConversations(\n agentId: string,\n userId: string | undefined,\n ): Promise<Chat[]>\n getChat(agentId: string, chatId: string): Promise<Chat | null>\n updateChatTitle(\n agentId: string,\n chatId: string,\n title: string,\n ): Promise<Chat>\n deleteChat(agentId: string, chatId: string): Promise<void>\n getMessageFeedbacks(chatId: string): Promise<MessageFeedback[]>\n submitMessageFeedback(\n payload: SubmitFeedbackPayload,\n ): Promise<MessageFeedback>\n submitLead(payload: SubmitLeadPayload): Promise<void>\n getAgent(orgSlug: string, agentId: string): Promise<AgentPublic>\n getAgentAccess(orgSlug: string, agentId: string): Promise<AgentAccess>\n getMediaUrl(agentId: string, chatId: string, storedFileName: string): string\n appendAuthToken(url: string): string\n uploadMedia(\n agentId: string,\n chatId: string,\n file: File,\n ): Promise<MediaSource>\n getChatEndpoint(agentId: string, type?: 'chat' | 'reasoning'): string\n expandSourceContext(\n agentId: string,\n documentId: string,\n chunkIndex: number,\n windowSize?: number,\n ): Promise<{ content: string }>\n downloadSourceDocument(\n agentId: string,\n documentId: string,\n ): Promise<{ downloadUrl: string; filename: string; mimeType: string }>\n reverseGeocode(\n lat: number,\n lon: number,\n lang?: string,\n ): Promise<string | undefined>\n forwardGeocode(\n query: string,\n lang?: string,\n ): Promise<\n { latitude: number; longitude: number; displayName: string } | undefined\n >\n getOAuthAuthorizeUrl(\n agentId: string,\n serverName: string,\n ): Promise<{ mcpServerId: string; authorizeUrl: string }>\n resolveShortUrls(hashes: string[]): Promise<Record<string, string>>\n getChatFiles(chatId: string): Promise<ChatbotFile[]>\n getChatFileDownloadUrl(documentId: string, inline?: boolean): string\n getChatFilePreviewUrl(documentId: string): string\n deleteChatFile(documentId: string): Promise<void>\n createVoiceSession(\n agentId: string,\n chatId?: string,\n /**\n * Everything the call inherits from the page it starts on. Sent once,\n * because the spoken turns arrive from the voice provider and carry\n * none of it.\n */\n context?: {\n deviceContext?: DeviceContext\n externalContext?: Record<string, unknown>\n },\n ): Promise<VoiceSession>\n closeVoiceSession(agentId: string, sessionId: string): Promise<void>\n}\n\nexport function createChatbotApiClient(\n options: ChatbotApiClientOptions,\n): ChatbotApiClient {\n const basePath = options.basePath\n ? addInitialSlash(options.basePath)\n : `/api/v1/${Audience.Public}`\n\n const baseUrl = `${removeTrailingSlash(options.baseUrl)}${basePath}`\n\n // \"My files\" lives under the frontoffice audience, not the agent's base\n // (which may be public, backoffice, …) — derive it by swapping the trailing\n // audience segment of basePath for `frontoffice`.\n const frontofficeBase = `${removeTrailingSlash(options.baseUrl)}${basePath.replace(\n /\\/[^/]+$/,\n `/${Audience.Frontoffice}`,\n )}`\n\n async function request<T>(\n url: string,\n init?: RequestInit,\n responseType: 'json' | 'void' = 'json',\n ): Promise<T> {\n const response = await fetch(`${baseUrl}${url}`, {\n credentials: options.credentials ?? 'include',\n ...init,\n headers: {\n ...options.headers?.(),\n ...init?.headers,\n },\n })\n\n if (!response.ok) {\n throw new Error(await readErrorMessage(response))\n }\n\n if (responseType === 'void' || response.status === 204) {\n return undefined as T\n }\n\n return response.json() as Promise<T>\n }\n\n return {\n async getConversations(agentId, userId) {\n const userFilter = userId\n ? `&filter[userId]=${encodeURIComponent(userId)}`\n : ''\n const conversations = await request<unknown[]>(\n `/agents/${encodeURIComponent(agentId)}/chats?sort=-lastMessageAt&page[size]=100${userFilter}`,\n )\n return conversations.map(parseConversation)\n },\n\n async getChatFiles(chatId) {\n const response = await fetch(\n `${frontofficeBase}/me/documents?filter[chatId]=${encodeURIComponent(chatId)}&page[size]=100`,\n {\n credentials: options.credentials ?? 'include',\n headers: { ...options.headers?.() },\n },\n )\n if (!response.ok) {\n throw new Error(\n `API error: ${response.status} ${response.statusText}`,\n )\n }\n return (await response.json()) as ChatbotFile[]\n },\n\n getChatFileDownloadUrl(documentId, inline) {\n const suffix = inline ? '?inline=true' : ''\n // appendAuthToken carries a bearer in the query so <img>/<a>\n // subresources (which can't set an Authorization header) authorize\n // cross-origin in the embedded widget; no-op for cookie auth.\n return this.appendAuthToken(\n `${frontofficeBase}/me/documents/${encodeURIComponent(documentId)}/download${suffix}`,\n )\n },\n\n getChatFilePreviewUrl(documentId) {\n // Small resized preview blob for row thumbnails (see download\n // endpoint ?preview=true); auth token carried for cross-origin <img>.\n return this.appendAuthToken(\n `${frontofficeBase}/me/documents/${encodeURIComponent(documentId)}/download?preview=true`,\n )\n },\n\n async deleteChatFile(documentId) {\n const response = await fetch(\n `${frontofficeBase}/me/documents/${encodeURIComponent(documentId)}`,\n {\n method: 'DELETE',\n credentials: options.credentials ?? 'include',\n headers: { ...options.headers?.() },\n },\n )\n if (!response.ok) {\n throw new Error(\n `API error: ${response.status} ${response.statusText}`,\n )\n }\n },\n\n async getChat(agentId, chatId) {\n const result = await request<Chat | undefined>(\n `/agents/${encodeURIComponent(agentId)}/chats/${encodeURIComponent(chatId)}`,\n )\n return result ? parseConversation(result) : null\n },\n\n async updateChatTitle(agentId, chatId, title) {\n return parseConversation(\n await request<Chat>(\n `/agents/${encodeURIComponent(agentId)}/chats/${encodeURIComponent(chatId)}`,\n {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ title }),\n },\n ),\n )\n },\n\n async deleteChat(agentId, chatId) {\n await request<void>(\n `/agents/${encodeURIComponent(agentId)}/chats/${encodeURIComponent(chatId)}`,\n { method: 'DELETE' },\n 'void',\n )\n },\n\n async getMessageFeedbacks(chatId) {\n return request<MessageFeedback[]>(\n `/message-feedbacks?filter[chatId]=${encodeURIComponent(chatId)}&page[size]=200`,\n )\n },\n\n async submitMessageFeedback(payload) {\n return request<MessageFeedback>('/message-feedbacks', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n })\n },\n\n async submitLead(payload) {\n await request<void>(\n '/leads',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n },\n 'void',\n )\n },\n\n async getAgent(orgSlug, agentId) {\n return request<AgentPublic>(\n `/organizations/${encodeURIComponent(orgSlug)}/agents/${encodeURIComponent(agentId)}`,\n )\n },\n\n async getAgentAccess(orgSlug, agentId) {\n return request<AgentAccess>(\n `/organizations/${encodeURIComponent(orgSlug)}/agents/${encodeURIComponent(agentId)}/access`,\n )\n },\n\n async uploadMedia(agentId, chatId, file) {\n const formData = new FormData()\n formData.append('file', file)\n const response = await fetch(\n `${baseUrl}/agents/${encodeURIComponent(agentId)}/chats/${encodeURIComponent(chatId)}/media/upload`,\n {\n method: 'POST',\n credentials: options.credentials ?? 'include',\n // Do NOT set Content-Type — browser sets multipart/form-data with boundary automatically\n headers: options.headers?.(),\n body: formData,\n },\n )\n if (!response.ok) {\n const text = await response.text().catch(() => '')\n let title = `Upload failed: ${response.status}`\n try {\n title =\n (JSON.parse(text) as { title?: string }).title ?? title\n } catch {\n // ignore parse errors\n }\n throw new Error(title)\n }\n return response.json() as Promise<MediaSource>\n },\n\n getChatEndpoint(agentId, type = 'chat') {\n const path = type === 'reasoning' ? 'reasoning-chat' : 'chat'\n return `${baseUrl}/agents/${encodeURIComponent(agentId)}/${path}`\n },\n\n appendAuthToken(url) {\n const bearer = options\n .headers?.()\n ?.[`Authorization`]?.slice('Bearer '.length)\n if (!bearer) {\n return url\n }\n const separator = url.includes('?') ? '&' : '?'\n return `${url}${separator}token=${encodeURIComponent(bearer)}`\n },\n\n getMediaUrl(agentId, chatId, storedFileName) {\n const base = `${baseUrl}/agents/${encodeURIComponent(agentId)}/chats/${encodeURIComponent(chatId)}/media/${encodeURIComponent(storedFileName)}/view`\n return this.appendAuthToken(base)\n },\n\n async expandSourceContext(\n agentId,\n documentId,\n chunkIndex,\n windowSize = 2,\n ) {\n return request<{ content: string }>(\n `/agents/${encodeURIComponent(agentId)}/sources/expand-context`,\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n documentId,\n chunkIndex,\n windowSize,\n }),\n },\n )\n },\n\n async downloadSourceDocument(agentId, documentId) {\n return request<{\n downloadUrl: string\n filename: string\n mimeType: string\n }>(\n `/agents/${encodeURIComponent(agentId)}/sources/documents/${encodeURIComponent(documentId)}/download`,\n )\n },\n\n async reverseGeocode(lat, lon, lang) {\n const params = new URLSearchParams({\n lat: String(lat),\n lon: String(lon),\n })\n if (lang) {\n params.set('lang', lang)\n }\n try {\n const data = await request<{ displayName?: string }>(\n `/geocoder/reverse?${params}`,\n )\n return data.displayName\n } catch {\n return undefined\n }\n },\n\n async forwardGeocode(query, lang) {\n const params = new URLSearchParams({ q: query })\n if (lang) {\n params.set('lang', lang)\n }\n try {\n return await request<{\n latitude: number\n longitude: number\n displayName: string\n }>(`/geocoder/forward?${params}`)\n } catch {\n return undefined\n }\n },\n\n async getOAuthAuthorizeUrl(agentId, serverName) {\n const params = new URLSearchParams({ serverName })\n return request<{ mcpServerId: string; authorizeUrl: string }>(\n `/agents/${encodeURIComponent(agentId)}/mcp-oauth/authorize?${params}`,\n )\n },\n\n /**\n * Opens a voice session on the conversation currently on screen, so the\n * spoken turns land in the same thread the user can keep typing into.\n * The signed URL it returns is short-lived and per session: the provider\n * credential stays on the server.\n */\n async createVoiceSession(agentId, chatId, context) {\n return VoiceSessionSchema.parse(\n await request<unknown>(\n `/agents/${encodeURIComponent(agentId)}/voice/session`,\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n ...(chatId ? { chatId } : {}),\n // Sent once for the whole call: the spoken turns\n // come from the provider and carry nothing about\n // this browser nor about the page it runs on.\n ...(context?.deviceContext\n ? { deviceContext: context.deviceContext }\n : {}),\n ...(context?.externalContext\n ? { externalContext: context.externalContext }\n : {}),\n }),\n },\n ),\n )\n },\n\n /**\n * `keepalive` on purpose: this is the call that settles the minutes of a\n * session, and it is often made while the page is going away (hang up on\n * unload, tab closed). Without it the browser is free to cancel it.\n */\n async closeVoiceSession(agentId, sessionId) {\n await request<void>(\n `/agents/${encodeURIComponent(agentId)}/voice/session/${encodeURIComponent(sessionId)}`,\n { method: 'DELETE', keepalive: true },\n 'void',\n )\n },\n\n resolveShortUrls(hashes) {\n return resolveShortUrlsRequest(options.baseUrl, hashes, {\n headers: options.headers?.(),\n credentials: options.credentials,\n })\n },\n }\n}\n"],"x_google_ignoreList":[2,3],"mappings":";;;;;;;;;AAEA,IAAY,KAAL,yBAAA,GAAA;QACH,EAAA,aAAA,cACA,EAAA,aAAA,eACA,EAAA,gBAAA,kBACA,EAAA,WAAA,aACA,EAAA,WAAA,YACA,EAAA,kBAAA,oBACA,EAAA,iBAAA,mBACA,EAAA,OAAA,QACA,EAAA,qBAAA,wBACA,EAAA,gBAAA;AACJ,EAAA,CAAA,CAAA,GAEY,KAAL,yBAAA,GAAA;QACH,EAAA,MAAA,OACA,EAAA,SAAA,UACA,EAAA,OAAA;AACJ,EAAA,CAAA,CAAA,GAEY,IAAL,yBAAA,GAAA;QACH,EAAA,eAAA,iBACA,EAAA,gBAAA,iBACA,EA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