@epam/ai-dial-chat-hooks 1.3.0-dev.147 → 1.3.0-dev.149

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 { Conversation } from '@epam/ai-dial-chat-shared';
1
+ import { Annotation, Conversation } from '@epam/ai-dial-chat-shared';
2
2
  /**
3
3
  * The reference fields shared by every attachment shape a conversation can
4
4
  * carry — `MessageAttachment` on a message or a stage, and
@@ -27,13 +27,21 @@ export declare const splitFileIdAnchor: (url: string) => {
27
27
  fileId: string;
28
28
  anchor: string;
29
29
  };
30
+ /**
31
+ * Applies `mapAnnotation` to every readable entry of the citation pool,
32
+ * keeping unreadable entries and every other `customViewState` key as they
33
+ * are. Returns `conversation` itself when no entry changed, so a caller can
34
+ * tell by identity that the pool needed no work.
35
+ */
36
+ export declare const mapAnnotationPool: (conversation: Conversation, mapAnnotation: (annotation: Annotation) => Annotation) => Conversation;
30
37
  /** A unique DIAL file reference found in a conversation's messages. */
31
38
  export interface AttachmentRef {
32
39
  fileId: string;
33
40
  }
34
41
  /**
35
42
  * Collects unique attachment references across all messages — message
36
- * attachments, stage attachments, and citation source documents — with any
43
+ * attachments, stage attachments, and citation source documents — and the
44
+ * conversation-level citation pool, with any
37
45
  * `#…` anchor stripped. The same file can be referenced more than once (by a
38
46
  * later turn, by a stage and the message it belongs to, or by several
39
47
  * citations), so dedupe by file id and process it only once.
@@ -1 +1 @@
1
- {"version":3,"file":"attachment-refs.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/attachment-refs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAK9D;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,sFAAsF;IACtF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAeD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAC5B,KAAK,MAAM,KACV;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CASlC,CAAC;AAEF,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAoCD;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAChC,cAAc,YAAY,KACzB,aAAa,EAef,CAAC"}
1
+ {"version":3,"file":"attachment-refs.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/attachment-refs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAK1E;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,sFAAsF;IACtF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAeD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAC5B,KAAK,MAAM,KACV;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CASlC,CAAC;AAqBF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,cAAc,YAAY,EAC1B,eAAe,CAAC,UAAU,EAAE,UAAU,KAAK,UAAU,KACpD,YAgBF,CAAC;AAEF,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAgDD;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAChC,cAAc,YAAY,KACzB,aAAa,EAef,CAAC"}
@@ -10,7 +10,25 @@ var e = (e) => e.startsWith("files/"), t = /^#[\w.=%-]*$/, n = (e) => {
10
10
  fileId: e.slice(0, n),
11
11
  anchor: t.test(r) ? r : ""
12
12
  };
13
- }, r = (e, t) => {
13
+ }, r = (e) => typeof e == "object" && !!e, i = (e) => {
14
+ let t = e.customViewState?.annotations;
15
+ return Array.isArray(t) ? t.filter(r) : [];
16
+ }, a = (e, t) => {
17
+ let n = e.customViewState, i = n?.annotations;
18
+ if (!Array.isArray(i)) return e;
19
+ let a = !1, o = i.map((e) => {
20
+ if (!r(e)) return e;
21
+ let n = t(e);
22
+ return n !== e && (a = !0), n;
23
+ });
24
+ return a ? {
25
+ ...e,
26
+ customViewState: {
27
+ ...n,
28
+ annotations: o
29
+ }
30
+ } : e;
31
+ }, o = (e, t) => {
14
32
  for (let n of e.messages) {
15
33
  let e = n.custom_content;
16
34
  if (e) {
@@ -22,15 +40,19 @@ var e = (e) => e.startsWith("files/"), t = /^#[\w.=%-]*$/, n = (e) => {
22
40
  }
23
41
  }
24
42
  }
25
- }, i = (t) => {
26
- let i = /* @__PURE__ */ new Set(), a = (t) => {
43
+ for (let n of i(e)) {
44
+ let e = n.body?.source?.attachment;
45
+ e && t(e);
46
+ }
47
+ }, s = (t) => {
48
+ let r = /* @__PURE__ */ new Set(), i = (t) => {
27
49
  if (t == null) return;
28
- let { fileId: r } = n(t);
29
- e(r) && i.add(r);
50
+ let { fileId: i } = n(t);
51
+ e(i) && r.add(i);
30
52
  };
31
- return r(t, (e) => {
32
- a(e.url), a(e.reference_url);
33
- }), Array.from(i, (e) => ({ fileId: e }));
53
+ return o(t, (e) => {
54
+ i(e.url), i(e.reference_url);
55
+ }), Array.from(r, (e) => ({ fileId: e }));
34
56
  };
35
57
  //#endregion
36
- export { i as collectAttachmentRefs, n as splitFileIdAnchor };
58
+ export { s as collectAttachmentRefs, a as mapAnnotationPool, n as splitFileIdAnchor };
@@ -2,7 +2,11 @@ import { Conversation, ExportFolder, ExportFormat } from '@epam/ai-dial-chat-sha
2
2
  import { ExportFileNameKind } from './types';
3
3
  /** Placeholder app name used in every export file name — this branch has no app display-name config yet. */
4
4
  export declare const EXPORT_APP_NAME = "ai_dial";
5
- /** Returns the conversation with every message-, stage- and citation-level attachment reference removed. */
5
+ /**
6
+ * Returns the conversation with every message-, stage- and citation-level
7
+ * attachment reference removed, including the source documents of the
8
+ * conversation-level citation pool.
9
+ */
6
10
  export declare const stripConversationAttachments: (conversation: Conversation) => Conversation;
7
11
  export declare const buildExportEnvelope: (conversations: Conversation[], folders?: ExportFolder[]) => ExportFormat;
8
12
  export declare const serializeExportEnvelope: (envelope: ExportFormat) => Blob;
@@ -1 +1 @@
1
- {"version":3,"file":"export-conversation.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/export-conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,YAAY,EACZ,YAAY,EACZ,YAAY,EAGb,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,4GAA4G;AAC5G,eAAO,MAAM,eAAe,YAAY,CAAC;AA2CzC,4GAA4G;AAC5G,eAAO,MAAM,4BAA4B,GACvC,cAAc,YAAY,KACzB,YAGD,CAAC;AAEH,eAAO,MAAM,mBAAmB,GAC9B,eAAe,YAAY,EAAE,EAC7B,UAAS,YAAY,EAAO,KAC3B,YAID,CAAC;AAEH,eAAO,MAAM,uBAAuB,GAAI,UAAU,YAAY,KAAG,IACY,CAAC;AAQ9E,eAAO,MAAM,mBAAmB,GAC9B,MAAM,kBAAkB,EACxB,SAAS,MAAM,EACf,OAAM,IAAiB,KACtB,MACyE,CAAC"}
1
+ {"version":3,"file":"export-conversation.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/export-conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,YAAY,EACZ,YAAY,EACZ,YAAY,EAGb,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,4GAA4G;AAC5G,eAAO,MAAM,eAAe,YAAY,CAAC;AA8CzC;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,GACvC,cAAc,YAAY,KACzB,YAOA,CAAC;AAEJ,eAAO,MAAM,mBAAmB,GAC9B,eAAe,YAAY,EAAE,EAC7B,UAAS,YAAY,EAAO,KAC3B,YAID,CAAC;AAEH,eAAO,MAAM,uBAAuB,GAAI,UAAU,YAAY,KAAG,IACY,CAAC;AAQ9E,eAAO,MAAM,mBAAmB,GAC9B,MAAM,kBAAkB,EACxB,SAAS,MAAM,EACf,OAAM,IAAiB,KACtB,MACyE,CAAC"}
@@ -1,22 +1,23 @@
1
- import { formatDateYMD as e } from "./date.js";
2
- import { ExportFileNameKind as t } from "./types.js";
1
+ import { mapAnnotationPool as e } from "./attachment-refs.js";
2
+ import { formatDateYMD as t } from "./date.js";
3
+ import { ExportFileNameKind as n } from "./types.js";
3
4
  //#region src/conversation/conversation-transfer/export-conversation.ts
4
- var n = "ai_dial", r = (e) => e.map(({ attachments: e, ...t }) => t), i = (e) => e.map((e) => {
5
+ var r = "ai_dial", i = (e) => e.map(({ attachments: e, ...t }) => t), a = (e) => {
5
6
  if (e.body?.source == null) return e;
6
7
  let { source: t, ...n } = e.body;
7
8
  return {
8
9
  ...e,
9
10
  body: n
10
11
  };
11
- }), a = (e) => {
12
+ }, o = (e) => e.map(a), s = (e) => {
12
13
  let t = e.custom_content;
13
14
  if (!t) return e;
14
- let { attachments: n, stages: a, annotations: o, ...s } = t;
15
- if (n == null && a == null && o == null) return e;
15
+ let { attachments: n, stages: r, annotations: a, ...s } = t;
16
+ if (n == null && r == null && a == null) return e;
16
17
  let c = {
17
18
  ...s,
18
- ...a ? { stages: r(a) } : {},
19
- ...o ? { annotations: i(o) } : {}
19
+ ...r ? { stages: i(r) } : {},
20
+ ...a ? { annotations: o(a) } : {}
20
21
  };
21
22
  if (Object.keys(c).length > 0) return {
22
23
  ...e,
@@ -24,17 +25,17 @@ var n = "ai_dial", r = (e) => e.map(({ attachments: e, ...t }) => t), i = (e) =>
24
25
  };
25
26
  let { custom_content: l, ...u } = e;
26
27
  return u;
27
- }, o = (e) => ({
28
- ...e,
29
- messages: e.messages.map(a)
30
- }), s = (e, t = []) => ({
28
+ }, c = (t) => e({
29
+ ...t,
30
+ messages: t.messages.map(s)
31
+ }, a), l = (e, t = []) => ({
31
32
  version: 5,
32
33
  history: e,
33
34
  folders: t
34
- }), c = (e) => new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), l = {
35
- [t.SingleConversation]: "json",
36
- [t.SingleConversationWithAttachments]: "dial",
37
- [t.AllConversationsHistory]: "json"
38
- }, u = (t, n, r = /* @__PURE__ */ new Date()) => `${e(r)}_${n}_${t}.${l[t]}`;
35
+ }), u = (e) => new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), d = {
36
+ [n.SingleConversation]: "json",
37
+ [n.SingleConversationWithAttachments]: "dial",
38
+ [n.AllConversationsHistory]: "json"
39
+ }, f = (e, n, r = /* @__PURE__ */ new Date()) => `${t(r)}_${n}_${e}.${d[e]}`;
39
40
  //#endregion
40
- export { n as EXPORT_APP_NAME, s as buildExportEnvelope, u as buildExportFileName, c as serializeExportEnvelope, o as stripConversationAttachments };
41
+ export { r as EXPORT_APP_NAME, l as buildExportEnvelope, f as buildExportFileName, u as serializeExportEnvelope, c as stripConversationAttachments };
@@ -52,12 +52,13 @@ export interface RewrittenAttachmentTarget {
52
52
  title?: string;
53
53
  }
54
54
  /**
55
- * Rewrites every attachment reference a message carries — its own
56
- * `custom_content.attachments`, the attachments of each execution stage, and
57
- * the source document of each citation — from an old file id to its new
58
- * uploaded location, and its `title` when the target carries a renamed one.
59
- * References not present in `targetMap` are left untouched (immutable —
60
- * returns a new conversation).
55
+ * Rewrites every attachment reference a conversation carries — each
56
+ * message's own `custom_content.attachments`, the attachments of each
57
+ * execution stage, the source document of each citation, and the source
58
+ * document of each entry in the conversation-level citation pool — from an
59
+ * old file id to its new uploaded location, and its `title` when the target
60
+ * carries a renamed one. References not present in `targetMap` are left
61
+ * untouched (immutable — returns a new conversation).
61
62
  */
62
63
  export declare const rewriteAttachmentUrls: (conversation: Conversation, targetMap: Map<string, RewrittenAttachmentTarget>) => Conversation;
63
64
  /**
@@ -72,6 +73,10 @@ export declare const rewriteAttachmentUrls: (conversation: Conversation, targetM
72
73
  * user shared with the importing user is dropped too: nothing here can tell
73
74
  * it apart from one they never had access to.
74
75
  *
76
+ * The conversation-level citation pool is covered as well: a message
77
+ * citation stripped of its source would otherwise resolve its `<cit>` from
78
+ * the pool's copy, which still names the foreign file.
79
+ *
75
80
  * Returns the conversation (unchanged when nothing was foreign) and the name
76
81
  * of every dropped file, for the skipped-attachment warning.
77
82
  */
@@ -1 +1 @@
1
- {"version":3,"file":"import-conversation.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/import-conversation.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAEV,YAAY,EAEZ,YAAY,EAGb,MAAM,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAG7B,oFAAoF;AACpF,qBAAa,4BAA6B,SAAQ,KAAK;gBACzC,OAAO,EAAE,MAAM;CAI5B;AAOD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,KAAG,YA2BlD,CAAC;AAgGF,MAAM,WAAW,qBAAqB;IACpC,wGAAwG;IACxG,YAAY,EAAE,YAAY,CAAC;IAC3B,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;CACjB;AAgBD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAC/B,cAAc,YAAY,EAC1B,QAAQ,MAAM,KACb,qBAmDF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,cAAc,YAAY,KACzB,MAAM,GAAG,SAMX,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,EAAE,KAAG,MACV,CAAC;AAE9C,qGAAqG;AACrG,MAAM,WAAW,yBAAyB;IACxC,0EAA0E;IAC1E,GAAG,EAAE,MAAM,CAAC;IACZ,uFAAuF;IACvF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAoFD;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAChC,cAAc,YAAY,EAC1B,WAAW,GAAG,CAAC,MAAM,EAAE,yBAAyB,CAAC,KAChD,YA8BD,CAAC;AAmEH;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,GACpC,cAAc,YAAY,EAC1B,QAAQ,MAAM,KACb;IAAE,YAAY,EAAE,YAAY,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CAwDtD,CAAC;AAMF,0GAA0G;AAC1G,MAAM,WAAW,uBAAuB;IACtC,yGAAyG;IACzG,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,KAAK,EAAE,UAAU,CAAC;IAClB,+FAA+F;IAC/F,gBAAgB,EAAE,MAAM,CAAC;IACzB,0DAA0D;IAC1D,SAAS,EAAE,mBAAmB,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAChC,cAAc,YAAY,EAC1B,iBAAiB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACxC,WAAW,mBAAmB,KAC7B;IAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CA2B3D,CAAC"}
1
+ {"version":3,"file":"import-conversation.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/import-conversation.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAEV,YAAY,EAEZ,YAAY,EAGb,MAAM,2BAA2B,CAAC;AAOnC,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAG7B,oFAAoF;AACpF,qBAAa,4BAA6B,SAAQ,KAAK;gBACzC,OAAO,EAAE,MAAM;CAI5B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GAChC,cAAc,YAAY,EAC1B,iBAAiB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACxC,WAAW,mBAAmB,KAC7B;IAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CA2B3D,CAAC"}
@@ -1,39 +1,39 @@
1
- import { collectAttachmentRefs as e, splitFileIdAnchor as t } from "./attachment-refs.js";
2
- import { resolveDialFileBucketAndPath as n } from "./dial-file-resolve.js";
3
- import { PUBLIC_BUCKET as r, generateUUID as i, sanitizeConversationName as a, stripTrailingDots as o, truncateToUtf8Bytes as s } from "@epam/ai-dial-chat-shared";
1
+ import { collectAttachmentRefs as e, mapAnnotationPool as t, splitFileIdAnchor as n } from "./attachment-refs.js";
2
+ import { resolveDialFileBucketAndPath as r } from "./dial-file-resolve.js";
3
+ import { PUBLIC_BUCKET as i, generateUUID as a, sanitizeConversationName as o, stripTrailingDots as s, truncateToUtf8Bytes as c } from "@epam/ai-dial-chat-shared";
4
4
  //#region src/conversation/conversation-transfer/import-conversation.ts
5
- var c = class extends Error {
5
+ var l = class extends Error {
6
6
  constructor(e) {
7
7
  super(e), this.name = "UnsupportedImportFormatError";
8
8
  }
9
- }, l = (e) => typeof e == "object" && !!e, u = 5, d = (e) => {
9
+ }, u = (e) => typeof e == "object" && !!e, d = 5, f = (e) => {
10
10
  let t;
11
11
  try {
12
12
  t = JSON.parse(e);
13
13
  } catch {
14
- throw new c("Import file is not valid JSON");
14
+ throw new l("Import file is not valid JSON");
15
15
  }
16
- if (!l(t) || t.version !== u || !Array.isArray(t.history)) throw new c("Import file is not a supported export format");
16
+ if (!u(t) || t.version !== d || !Array.isArray(t.history)) throw new l("Import file is not a supported export format");
17
17
  let n = Array.isArray(t.folders) ? t.folders : [];
18
18
  return {
19
- version: u,
19
+ version: d,
20
20
  history: t.history,
21
21
  folders: n
22
22
  };
23
- }, f = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, p = "__", m = 255, h = "applications", g = /[-+]/, _ = /^\d+$/, v = (e) => e ? e.split(g)[0].split(".").every((e) => _.test(e)) : !1, y = (e) => {
24
- let t = e.replace(/\r\n|\r/g, "\n").split("\n").map((e) => a(e).trim()).filter(Boolean)[0] ?? "";
25
- return o(s(t, m)).trimEnd();
26
- }, b = (e, t, n) => {
27
- let r = e.split(p);
28
- if (r.length < 2) return [e, i()].join(p);
29
- let a = n && v(r[1]) ? r.slice(0, 2) : r.slice(0, 1), o = a.length > 1 ? f.test(r[r.length - 1]) : r.length >= 3, s = r.slice(a.length, o ? -1 : void 0).join(p);
23
+ }, p = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, m = "__", h = 255, g = "applications", _ = /[-+]/, v = /^\d+$/, y = (e) => e ? e.split(_)[0].split(".").every((e) => v.test(e)) : !1, b = (e) => {
24
+ let t = e.replace(/\r\n|\r/g, "\n").split("\n").map((e) => o(e).trim()).filter(Boolean)[0] ?? "";
25
+ return s(c(t, h)).trimEnd();
26
+ }, x = (e, t, n) => {
27
+ let r = e.split(m);
28
+ if (r.length < 2) return [e, a()].join(m);
29
+ let i = n && y(r[1]) ? r.slice(0, 2) : r.slice(0, 1), o = i.length > 1 ? p.test(r[r.length - 1]) : r.length >= 3, s = r.slice(i.length, o ? -1 : void 0).join(m);
30
30
  return [
31
- ...a,
31
+ ...i,
32
32
  t || s,
33
- i()
34
- ].join(p);
35
- }, x = "conversations/", S = (e) => e.startsWith(x) ? e.slice(14) : e, C = (e, t) => {
36
- let n = S(e.id), r = n.split("/"), i = S(e.folderId), a = r[0], o = i.startsWith(`${a}/`) ? i.slice(a.length + 1).split("/").filter(Boolean) : [], s = r.slice(1).slice(o.length), c = s.slice(0, -1), l = s.at(-1) ?? r.at(-1) ?? n, u = [...o, ...c], d = y(e.name), f = b(l, d, u[0] === h), p = [...u, f].join("/"), m = o.length ? `${t}/${o.join("/")}` : t;
33
+ a()
34
+ ].join(m);
35
+ }, S = "conversations/", C = (e) => e.startsWith(S) ? e.slice(14) : e, w = (e, t) => {
36
+ let n = C(e.id), r = n.split("/"), i = C(e.folderId), a = r[0], o = i.startsWith(`${a}/`) ? i.slice(a.length + 1).split("/").filter(Boolean) : [], s = r.slice(1).slice(o.length), c = s.slice(0, -1), l = s.at(-1) ?? r.at(-1) ?? n, u = [...o, ...c], d = b(e.name), f = x(l, d, u[0] === g), p = [...u, f].join("/"), m = o.length ? `${t}/${o.join("/")}` : t;
37
37
  return {
38
38
  conversation: {
39
39
  ...e,
@@ -43,18 +43,18 @@ var c = class extends Error {
43
43
  },
44
44
  subPath: p
45
45
  };
46
- }, w = (e) => {
47
- let t = S(e.folderId).split("/").filter(Boolean).slice(1);
46
+ }, T = (e) => {
47
+ let t = C(e.folderId).split("/").filter(Boolean).slice(1);
48
48
  return t.length ? t.join(" / ") : void 0;
49
- }, T = (e) => e.map((e) => `"${e}"`).join(", "), E = (e, n) => {
49
+ }, E = (e) => e.map((e) => `"${e}"`).join(", "), D = (e, t) => {
50
50
  if (!e) return;
51
- let { fileId: r, anchor: i } = t(e), a = n.get(r);
51
+ let { fileId: r, anchor: i } = n(e), a = t.get(r);
52
52
  if (a != null) return {
53
53
  ...a,
54
54
  url: `${a.url}${i}`
55
55
  };
56
- }, D = (e, t) => {
57
- let n = E(e.url, t), r = E(e.reference_url, t);
56
+ }, O = (e, t) => {
57
+ let n = D(e.url, t), r = D(e.reference_url, t);
58
58
  if (n == null && r == null) return;
59
59
  let i = n?.title ?? r?.title;
60
60
  return {
@@ -62,19 +62,19 @@ var c = class extends Error {
62
62
  ...r == null ? {} : { reference_url: r.url },
63
63
  ...i == null ? {} : { title: i }
64
64
  };
65
- }, O = (e, t) => e.map((e) => e.attachments?.length ? {
65
+ }, k = (e, t) => e.map((e) => e.attachments?.length ? {
66
66
  ...e,
67
67
  attachments: e.attachments.map((e) => {
68
- let n = D(e, t);
68
+ let n = O(e, t);
69
69
  return n ? {
70
70
  ...e,
71
71
  ...n
72
72
  } : e;
73
73
  })
74
- } : e), k = (e, t) => e.map((e) => {
74
+ } : e), A = (e, t) => {
75
75
  let n = e.body?.source;
76
76
  if (n?.attachment == null) return e;
77
- let r = D(n.attachment, t);
77
+ let r = O(n.attachment, t);
78
78
  return r == null ? e : {
79
79
  ...e,
80
80
  body: {
@@ -88,7 +88,7 @@ var c = class extends Error {
88
88
  }
89
89
  }
90
90
  };
91
- }), A = (e, t) => ({
91
+ }, j = (e, t) => e.map((e) => A(e, t)), M = (e, t) => ({
92
92
  ...e,
93
93
  messages: e.messages.map((e) => {
94
94
  let n = e.custom_content;
@@ -99,31 +99,31 @@ var c = class extends Error {
99
99
  custom_content: {
100
100
  ...n,
101
101
  ...r?.length ? { attachments: r.map((e) => {
102
- let n = D(e, t);
102
+ let n = O(e, t);
103
103
  return n ? {
104
104
  ...e,
105
105
  ...n
106
106
  } : e;
107
107
  }) } : {},
108
- ...i?.length ? { stages: O(i, t) } : {},
109
- ...a?.length ? { annotations: k(a, t) } : {}
108
+ ...i?.length ? { stages: k(i, t) } : {},
109
+ ...a?.length ? { annotations: j(a, t) } : {}
110
110
  }
111
111
  };
112
112
  })
113
- }), j = (e, i) => {
113
+ }), N = (e, n) => t(M(e, n), (e) => A(e, n)), P = (e, t) => {
114
114
  if (!e) return;
115
- let a = n(t(e).fileId);
116
- if (a && a.bucket !== i && a.bucket !== r) return a.path.split("/").pop() || a.path;
117
- }, M = (e, t, n) => e.flatMap((e) => {
118
- let r = j(e.url, t);
115
+ let a = r(n(e).fileId);
116
+ if (a && a.bucket !== t && a.bucket !== i) return a.path.split("/").pop() || a.path;
117
+ }, F = (e, t, n) => e.flatMap((e) => {
118
+ let r = P(e.url, t);
119
119
  if (r != null) return n.push(r), [];
120
- let i = j(e.reference_url, t);
120
+ let i = P(e.reference_url, t);
121
121
  if (i == null) return [e];
122
122
  n.push(i);
123
123
  let { reference_url: a, reference_type: o, ...s } = e;
124
124
  return s.url == null && s.data == null ? [] : [s];
125
- }), N = (e, t, n) => e.map((e) => {
126
- let r = e.body, i = j(r?.source?.attachment?.url, t);
125
+ }), I = (e, t, n) => {
126
+ let r = e.body, i = P(r?.source?.attachment?.url, t);
127
127
  if (r == null || i == null) return e;
128
128
  n.push(i);
129
129
  let { source: a, ...o } = r;
@@ -131,43 +131,40 @@ var c = class extends Error {
131
131
  ...e,
132
132
  body: o
133
133
  };
134
- }), P = (e, t) => {
135
- let n = [], r = e.messages.map((e) => {
136
- let r = e.custom_content;
137
- if (!r) return e;
138
- let { attachments: i, stages: a, annotations: o } = r;
134
+ }, L = (e, t, n) => e.map((e) => I(e, t, n)), R = (e, n) => {
135
+ let r = [], i = e.messages.map((e) => {
136
+ let t = e.custom_content;
137
+ if (!t) return e;
138
+ let { attachments: i, stages: a, annotations: o } = t;
139
139
  return !i?.length && !a?.length && !o?.length ? e : {
140
140
  ...e,
141
141
  custom_content: {
142
- ...r,
143
- ...i?.length ? { attachments: M(i, t, n) } : {},
142
+ ...t,
143
+ ...i?.length ? { attachments: F(i, n, r) } : {},
144
144
  ...a?.length ? { stages: a.map((e) => e.attachments?.length ? {
145
145
  ...e,
146
- attachments: M(e.attachments, t, n)
146
+ attachments: F(e.attachments, n, r)
147
147
  } : e) } : {},
148
- ...o?.length ? { annotations: N(o, t, n) } : {}
148
+ ...o?.length ? { annotations: L(o, n, r) } : {}
149
149
  }
150
150
  };
151
- });
152
- return n.length ? {
153
- conversation: {
154
- ...e,
155
- messages: r
156
- },
157
- droppedNames: n
158
- } : {
159
- conversation: e,
160
- droppedNames: n
151
+ }), a = r.length ? {
152
+ ...e,
153
+ messages: i
154
+ } : e;
155
+ return {
156
+ conversation: t(a, (e) => I(e, n, r)),
157
+ droppedNames: r
161
158
  };
162
- }, F = (e) => e.split("/").pop() || e, I = (t, r, i) => {
159
+ }, z = (e) => e.split("/").pop() || e, B = (t, n, i) => {
163
160
  let a = [], o = [];
164
161
  for (let s of e(t)) {
165
- let e = n(s.fileId);
162
+ let e = r(s.fileId);
166
163
  if (!e) {
167
- o.push(F(s.fileId));
164
+ o.push(z(s.fileId));
168
165
  continue;
169
166
  }
170
- let t = e.path.split("/").pop() ?? e.path, c = r.get(e.path);
167
+ let t = e.path.split("/").pop() ?? e.path, c = n.get(e.path);
171
168
  c ? a.push({
172
169
  fileId: s.fileId,
173
170
  bytes: c,
@@ -181,4 +178,4 @@ var c = class extends Error {
181
178
  };
182
179
  };
183
180
  //#endregion
184
- export { c as UnsupportedImportFormatError, P as dropForeignAttachmentRefs, T as formatQuotedNameList, w as getFolderBreadcrumb, d as parseImportEnvelope, I as planAttachmentUploads, C as rebaseConversationId, A as rewriteAttachmentUrls };
181
+ export { l as UnsupportedImportFormatError, R as dropForeignAttachmentRefs, E as formatQuotedNameList, T as getFolderBreadcrumb, f as parseImportEnvelope, B as planAttachmentUploads, w as rebaseConversationId, N as rewriteAttachmentUrls };
@@ -27,8 +27,9 @@ export declare class GenerationConflictError extends Error {
27
27
  }
28
28
  /**
29
29
  * Reported through `onError` when DIAL Core itself signals a failure with an
30
- * in-band `{ error: { message } }` SSE chunk. Its `message` is upstream text
31
- * intended for the user, unlike a transport failure (failed `fetch`, non-OK
30
+ * in-band `{ error: { message, display_message? } }` SSE chunk. Its `message`
31
+ * is upstream text intended for the user — the chunk's `display_message` when
32
+ * present, else its `message` — unlike a transport failure (failed `fetch`, non-OK
32
33
  * status, broken stream), whose message is technical detail. A custom
33
34
  * transport raises this for any user-facing upstream error text.
34
35
  */
@@ -1 +1 @@
1
- {"version":3,"file":"create-chat-stream-api.d.ts","sourceRoot":"","sources":["../../src/conversation/create-chat-stream-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,KAAK,EACV,oBAAoB,EACpB,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAOnC,mFAAmF;AACnF,eAAO,MAAM,4CAA4C,0IACgF,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AAM,MAAM,GAAG,SAAS,CAAC;IACvC,wFAAwF;IACxF,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AA4GD,wFAAwF;AACxF,MAAM,WAAW,aAAa;IAC5B,gBAAgB,EAAE,CAChB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,2BAA2B,EACpC,aAAa,CAAC,EAAE,oBAAoB,EACpC,YAAY,CAAC,EAAE,MAAM,EACrB,IAAI,CAAC,EAAE,yBAAyB,EAChC,YAAY,CAAC,EAAE,MAAM,EACrB,eAAe,CAAC,EAAE,MAAM,KACrB,IAAI,CAAC;IACV,cAAc,EAAE,CAAC,GAAG,EAAE;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,MAAM,uBAAuB,KAC5B,aAoKF,CAAC"}
1
+ {"version":3,"file":"create-chat-stream-api.d.ts","sourceRoot":"","sources":["../../src/conversation/create-chat-stream-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,KAAK,EACV,oBAAoB,EACpB,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAOnC,mFAAmF;AACnF,eAAO,MAAM,4CAA4C,0IACgF,CAAC;AAE1I,yFAAyF;AACzF,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,MAAM,CAAC,QAAQ,CAAC,IAAI,8BAA8B;IAElD,iFAAiF;IACjF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;gBACS,MAAM,CAAC,EAAE,MAAM;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AAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,2BAA2B,EACpC,aAAa,CAAC,EAAE,oBAAoB,EACpC,YAAY,CAAC,EAAE,MAAM,EACrB,IAAI,CAAC,EAAE,yBAAyB,EAChC,YAAY,CAAC,EAAE,MAAM,EACrB,eAAe,CAAC,EAAE,MAAM,KACrB,IAAI,CAAC;IACV,cAAc,EAAE,CAAC,GAAG,EAAE;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,MAAM,uBAAuB,KAC5B,aAoKF,CAAC"}
@@ -48,7 +48,7 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "The response could
48
48
  if (a !== "[DONE]") try {
49
49
  let e = JSON.parse(a);
50
50
  if (e.error) {
51
- n(e.error.type === r.type ? new r(f(e.error)) : new o(e.error.message));
51
+ n(e.error.type === r.type ? new r(f(e.error)) : new o(e.error.display_message ?? e.error.message));
52
52
  return;
53
53
  }
54
54
  t(e);
@@ -1,6 +1,6 @@
1
- import { ConversationExportMode as e, ConversationTransferWarningCode as t, ExportFileNameKind as n } from "../conversation-transfer/types.js";
2
- import { EXPORT_APP_NAME as r, buildExportEnvelope as i, buildExportFileName as a, serializeExportEnvelope as o, stripConversationAttachments as s } from "../conversation-transfer/export-conversation.js";
3
- import { collectAttachmentRefs as c } from "../conversation-transfer/attachment-refs.js";
1
+ import { collectAttachmentRefs as e } from "../conversation-transfer/attachment-refs.js";
2
+ import { ConversationExportMode as t, ConversationTransferWarningCode as n, ExportFileNameKind as r } from "../conversation-transfer/types.js";
3
+ import { EXPORT_APP_NAME as i, buildExportEnvelope as a, buildExportFileName as o, serializeExportEnvelope as s, stripConversationAttachments as c } from "../conversation-transfer/export-conversation.js";
4
4
  import { resolveDialFileBucketAndPath as l } from "../conversation-transfer/dial-file-resolve.js";
5
5
  import { runWithConcurrency as u } from "../conversation-transfer/async.js";
6
6
  import { ConversationTransferKind as d, ConversationTransferPhase as f, buildTransferProgress as p } from "../conversation-transfer/progress.js";
@@ -29,7 +29,7 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
29
29
  if (n.aborted || !D(e) || r >= T) throw e;
30
30
  await k(O(e, r), n);
31
31
  }
32
- }, j = (e) => !e.sharedWithMe && !e.publishedWithMe, M = (e) => e instanceof RangeError, N = (t) => t === e.WithoutAttachments ? d.ExportSingle : d.ExportSingleWithAttachments, P = ({ conversationsApi: x, filesApi: w, normalizeConversationPath: T, classifyTransferError: E = () => ({}), resolveErrorTraceId: D = async () => void 0, maxArchiveBytes: O = C, onSuccess: k, onWarning: P, onError: F }) => {
32
+ }, j = (e) => !e.sharedWithMe && !e.publishedWithMe, M = (e) => e instanceof RangeError, N = (e) => e === t.WithoutAttachments ? d.ExportSingle : d.ExportSingleWithAttachments, P = ({ conversationsApi: x, filesApi: w, normalizeConversationPath: T, classifyTransferError: E = () => ({}), resolveErrorTraceId: D = async () => void 0, maxArchiveBytes: O = C, onSuccess: k, onWarning: P, onError: F }) => {
33
33
  let I = m(), L = b(async (e, t, n) => {
34
34
  let r = !1, i = !1, a = 0, o = () => {
35
35
  a += 1, n(a, e.length);
@@ -61,44 +61,44 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
61
61
  anySkipped: !t.aborted && !i && r,
62
62
  isUnauthorized: !t.aborted && i
63
63
  };
64
- }, [E, w]), R = b(async (n, r, a, l, u, d) => {
64
+ }, [E, w]), R = b(async (r, i, o, l, u, d) => {
65
65
  let m = N(l), _;
66
66
  try {
67
- _ = await A(x, T(r), d);
67
+ _ = await A(x, T(i), d);
68
68
  } catch (e) {
69
69
  if (d.aborted) return;
70
70
  if (E(e).isUnauthorized) F?.({
71
- jobId: n,
71
+ jobId: r,
72
72
  code: g.Unauthorized
73
- }), I.failJob(n, g.Unauthorized);
73
+ }), I.failJob(r, g.Unauthorized);
74
74
  else {
75
75
  let t = await D(e);
76
76
  F?.({
77
- jobId: n,
77
+ jobId: r,
78
78
  code: g.Unknown,
79
- titles: [a],
79
+ titles: [o],
80
80
  traceId: t
81
- }), I.failJob(n, g.Unknown);
81
+ }), I.failJob(r, g.Unknown);
82
82
  }
83
83
  console.error("Failed to fetch conversation for export", e);
84
84
  return;
85
85
  }
86
86
  if (!d.aborted) {
87
- I.setJobProgress(n, p({
87
+ I.setJobProgress(r, p({
88
88
  kind: m,
89
89
  phase: f.Prepare
90
90
  }));
91
91
  try {
92
- if (l === e.WithoutAttachments) {
93
- let e = i([s(_)], []), t = o(e);
92
+ if (l === t.WithoutAttachments) {
93
+ let e = a([c(_)], []), t = s(e);
94
94
  y(t, u), k?.({
95
- jobId: n,
96
- titles: [a]
97
- }), I.succeedJob(n);
95
+ jobId: r,
96
+ titles: [o]
97
+ }), I.succeedJob(r);
98
98
  return;
99
99
  }
100
- let r = c(_), { entries: b, anySkipped: x, isUnauthorized: S } = await L(r, d, (e, t) => {
101
- I.setJobProgress(n, p({
100
+ let i = e(_), { entries: b, anySkipped: x, isUnauthorized: S } = await L(i, d, (e, t) => {
101
+ I.setJobProgress(r, p({
102
102
  kind: m,
103
103
  phase: f.Transfer,
104
104
  completed: e,
@@ -112,43 +112,43 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
112
112
  if (d.aborted) return;
113
113
  if (S) {
114
114
  F?.({
115
- jobId: n,
115
+ jobId: r,
116
116
  code: g.Unauthorized
117
- }), I.failJob(n, g.Unauthorized);
117
+ }), I.failJob(r, g.Unauthorized);
118
118
  return;
119
119
  }
120
- I.setJobProgress(n, p({
120
+ I.setJobProgress(r, p({
121
121
  kind: m,
122
122
  phase: f.Transfer,
123
- completed: r.length,
124
- total: r.length
123
+ completed: i.length,
124
+ total: i.length
125
125
  }));
126
126
  let C = b.reduce((e, t) => e + t.data.byteLength, 0);
127
127
  if (C > O) {
128
128
  F?.({
129
- jobId: n,
129
+ jobId: r,
130
130
  code: g.FileTooLarge,
131
- titles: [a]
132
- }), I.failJob(n, g.FileTooLarge), console.error(`Refused to build an export archive of ${C} bytes: over the ${O}-byte limit`);
131
+ titles: [o]
132
+ }), I.failJob(r, g.FileTooLarge), console.error(`Refused to build an export archive of ${C} bytes: over the ${O}-byte limit`);
133
133
  return;
134
134
  }
135
- let w = i([_], []), { blob: T, skippedPaths: E } = h(w, b), D = x || E.length > 0;
135
+ let w = a([_], []), { blob: T, skippedPaths: E } = h(w, b), D = x || E.length > 0;
136
136
  D && P?.({
137
- jobId: n,
138
- code: t.AttachmentSkipped
137
+ jobId: r,
138
+ code: n.AttachmentSkipped
139
139
  }), y(T, u), k?.({
140
- jobId: n,
141
- titles: [a]
142
- }), D ? I.warnJob(n, t.AttachmentSkipped) : I.succeedJob(n);
140
+ jobId: r,
141
+ titles: [o]
142
+ }), D ? I.warnJob(r, n.AttachmentSkipped) : I.succeedJob(r);
143
143
  } catch (e) {
144
144
  if (d.aborted) return;
145
- let t = M(e) ? g.FileTooLarge : g.Unknown, r = await D(e);
145
+ let t = M(e) ? g.FileTooLarge : g.Unknown, n = await D(e);
146
146
  F?.({
147
- jobId: n,
147
+ jobId: r,
148
148
  code: t,
149
- titles: [a],
150
- traceId: r
151
- }), I.failJob(n, t), console.error("Failed to build conversation export archive", e);
149
+ titles: [o],
150
+ traceId: n
151
+ }), I.failJob(r, t), console.error("Failed to build conversation export archive", e);
152
152
  }
153
153
  }
154
154
  }, [
@@ -162,19 +162,19 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
162
162
  P,
163
163
  I,
164
164
  D
165
- ]), z = b((t, i, o) => {
166
- let s = a(o === e.WithoutAttachments ? n.SingleConversation : n.SingleConversationWithAttachments, r), c = I.addJob({
165
+ ]), z = b((e, n, a) => {
166
+ let s = o(a === t.WithoutAttachments ? r.SingleConversation : r.SingleConversationWithAttachments, i), c = I.addJob({
167
167
  kind: _.Single,
168
- title: i
168
+ title: n
169
169
  }, s);
170
- return I.startJob(c, (e) => R(c, t, i, o, s, e));
170
+ return I.startJob(c, (t) => R(c, e, n, a, s, t));
171
171
  }, [I, R]), B = b(async (e, t, n) => {
172
- let r = d.ExportAll, a = [], c;
172
+ let r = d.ExportAll, i = [], o;
173
173
  do {
174
174
  if (n.aborted) return;
175
175
  let t;
176
176
  try {
177
- t = await x.listConversations({ nextToken: c }, { signal: n });
177
+ t = await x.listConversations({ nextToken: o }, { signal: n });
178
178
  } catch (t) {
179
179
  if (n.aborted) return;
180
180
  if (E(t).isUnauthorized) F?.({
@@ -192,17 +192,17 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
192
192
  console.error("Failed to list conversations for export", t);
193
193
  return;
194
194
  }
195
- a.push(...t.items.filter(j).map((e) => ({
195
+ i.push(...t.items.filter(j).map((e) => ({
196
196
  id: e.id,
197
197
  title: e.title
198
- }))), c = t.nextToken;
199
- } while (c);
198
+ }))), o = t.nextToken;
199
+ } while (o);
200
200
  I.setJobProgress(e, p({
201
201
  kind: r,
202
202
  phase: f.Prepare
203
203
  }));
204
204
  let l = [];
205
- for (let t of a) {
205
+ for (let t of i) {
206
206
  if (n.aborted) return;
207
207
  try {
208
208
  let e = await A(x, T(t.id), n);
@@ -239,16 +239,16 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
239
239
  kind: r,
240
240
  phase: f.Transfer,
241
241
  completed: l.length,
242
- total: a.length
242
+ total: i.length
243
243
  }, {
244
244
  completed: l.length,
245
- total: a.length,
245
+ total: i.length,
246
246
  kind: v.Conversation
247
247
  }));
248
248
  }
249
249
  }
250
250
  if (!n.aborted) try {
251
- let n = i(l.map(s), []), r = o(n);
251
+ let n = a(l.map(c), []), r = s(n);
252
252
  y(r, t), k?.({ jobId: e }), I.succeedJob(e);
253
253
  } catch (t) {
254
254
  let n = M(t) ? g.FileTooLarge : g.Unknown, r = await D(t);
@@ -267,7 +267,7 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
267
267
  I,
268
268
  D
269
269
  ]), V = b(() => {
270
- let e = a(n.AllConversationsHistory, r), t = I.addJob({ kind: _.All }, e);
270
+ let e = o(r.AllConversationsHistory, i), t = I.addJob({ kind: _.All }, e);
271
271
  return I.startJob(t, (n) => B(t, e, n));
272
272
  }, [I, B]);
273
273
  return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-chat-hooks",
3
3
  "description": "Framework-level React hooks extracted from AI DIAL Chat for building custom chat interfaces",
4
- "version": "1.3.0-dev.147",
4
+ "version": "1.3.0-dev.149",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -121,7 +121,7 @@
121
121
  }
122
122
  },
123
123
  "dependencies": {
124
- "@epam/ai-dial-chat-api-client": "1.3.0-dev.147",
124
+ "@epam/ai-dial-chat-api-client": "1.3.0-dev.149",
125
125
  "dompurify": "3.4.16",
126
126
  "fflate": "^0.8.3",
127
127
  "lru-cache": "^10.4.3",
@@ -130,22 +130,22 @@
130
130
  },
131
131
  "peerDependencies": {
132
132
  "react": "^19.2.8",
133
- "@epam/ai-dial-attachment-canvas": "1.3.0-dev.147",
134
- "@epam/ai-dial-attachment-input": "1.3.0-dev.147",
135
- "@epam/ai-dial-catalog": "1.3.0-dev.147",
136
- "@epam/ai-dial-chat-overlay": "1.3.0-dev.147",
137
- "@epam/ai-dial-chat-shared": "1.3.0-dev.147",
138
- "@epam/ai-dial-conversation-input": "1.3.0-dev.147",
139
- "@epam/ai-dial-mcp-apps": "1.3.0-dev.147",
140
- "@epam/ai-dial-publish-panel": "1.3.0-dev.147",
141
- "@epam/ai-dial-quotations": "1.3.0-dev.147",
133
+ "@epam/ai-dial-attachment-canvas": "1.3.0-dev.149",
134
+ "@epam/ai-dial-attachment-input": "1.3.0-dev.149",
135
+ "@epam/ai-dial-catalog": "1.3.0-dev.149",
136
+ "@epam/ai-dial-chat-overlay": "1.3.0-dev.149",
137
+ "@epam/ai-dial-chat-shared": "1.3.0-dev.149",
138
+ "@epam/ai-dial-conversation-input": "1.3.0-dev.149",
139
+ "@epam/ai-dial-mcp-apps": "1.3.0-dev.149",
140
+ "@epam/ai-dial-publish-panel": "1.3.0-dev.149",
141
+ "@epam/ai-dial-quotations": "1.3.0-dev.149",
142
142
  "@epam/ai-dial-react-file-manager": "^0.4.0-dev.11",
143
- "@epam/ai-dial-scheduled-tasks": "1.3.0-dev.147",
144
- "@epam/ai-dial-share": "1.3.0-dev.147",
145
- "@epam/ai-dial-skill-editor": "1.3.0-dev.147",
146
- "@epam/ai-dial-source-panel": "1.3.0-dev.147",
143
+ "@epam/ai-dial-scheduled-tasks": "1.3.0-dev.149",
144
+ "@epam/ai-dial-share": "1.3.0-dev.149",
145
+ "@epam/ai-dial-skill-editor": "1.3.0-dev.149",
146
+ "@epam/ai-dial-source-panel": "1.3.0-dev.149",
147
147
  "@epam/ai-dial-ui-kit": "^0.16.0-dev.22",
148
- "@epam/ai-dial-usage-dashboard": "1.3.0-dev.147",
148
+ "@epam/ai-dial-usage-dashboard": "1.3.0-dev.149",
149
149
  "@modelcontextprotocol/sdk": "^1.32.1",
150
150
  "@epam/pdf-highlighter-kit": "^0.0.19",
151
151
  "@mcp-ui/client": "^7.1.1"