@epam/ai-dial-chat-hooks 1.2.0-dev.99 → 1.3.0-dev.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/api-error/api-error.js +7 -4
  2. package/catalog/catalog-derivations.js +1 -1
  3. package/catalog/deployment-id.js +8 -2
  4. package/catalog/map-deployment-limits-to-catalog.js +16 -24
  5. package/catalog/map-deployment-limits-to-input.js +81 -9
  6. package/catalog/map-deployment-to-catalog-item.js +34 -34
  7. package/catalog/map-entity-details-to-catalog.js +237 -192
  8. package/catalog/map-skill-to-catalog-item.js +61 -54
  9. package/catalog/publish.js +4 -4
  10. package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +122 -101
  11. package/catalog/useCatalogItemDetails.js +9 -8
  12. package/catalog/usePublishFolders/usePublishFolders.js +1 -1
  13. package/catalog.d.ts +171 -34
  14. package/catalog.js +23 -23
  15. package/conversation/conversation-transfer/export-conversation.js +24 -16
  16. package/conversation/conversation-transfer/import-conversation.js +80 -31
  17. package/conversation/create-chat-stream-api.js +89 -49
  18. package/conversation/get-model-id-from-conversation-id.js +15 -9
  19. package/conversation/message-utils.js +44 -2
  20. package/conversation/stage.js +6 -2
  21. package/conversation/useActiveConversationSync/useActiveConversationSync.js +7 -8
  22. package/conversation/useConversationExport/useConversationExport.js +9 -9
  23. package/conversation/useConversationHandlers/message-utils.js +8 -5
  24. package/conversation/useConversationHandlers/useConversationHandlers.js +181 -167
  25. package/conversation/useConversationImport/useConversationImport.js +123 -121
  26. package/conversation/useConversationPanelItems/useConversationPanelItems.js +49 -31
  27. package/conversation/useConversationStream/frame-scheduler.js +39 -0
  28. package/conversation/useConversationStream/generation-resume.js +122 -64
  29. package/conversation/useConversationStream/useConversationStream.js +298 -118
  30. package/conversation/useMessageSelectionReply/useMessageSelectionReply.js +189 -0
  31. package/conversation-sources/useConversationSources/useConversationSources.js +31 -24
  32. package/conversation-sources.d.ts +1 -1
  33. package/conversation-transfer.d.ts +2 -1
  34. package/conversation.d.ts +218 -22
  35. package/conversation.js +32 -31
  36. package/file-manager-canvas.d.ts +27 -7
  37. package/file-manager.d.ts +87 -32
  38. package/file-manager.js +25 -24
  39. package/files/attachment-canvas.js +67 -44
  40. package/files/dial-file-manager-copy-move.util.js +9 -8
  41. package/files/dial-file-manager-mapping.util.js +2 -1
  42. package/files/dial-file-manager-path.util.js +24 -2
  43. package/files/dial-file-manager.model.js +23 -19
  44. package/files/dial-file-manager.types.js +3 -3
  45. package/files/file-manager-variant.js +1 -1
  46. package/files/resolve-dial-file-api-path.js +11 -12
  47. package/files/useDialFileListing/useDialFileListing.js +140 -127
  48. package/files/useDialFileManager/useDialFileManager.js +139 -135
  49. package/files/useDialFileManagerSections/useDialFileManagerSections.js +155 -0
  50. package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +20 -15
  51. package/files/useDialFileMutations/useDialFileMutations.js +65 -60
  52. package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +117 -110
  53. package/files/useFileAttachmentPicker/useFileAttachmentPicker.js +28 -23
  54. package/index.d.ts +643 -128
  55. package/index.js +136 -134
  56. package/mcp-apps/useMcpAppTools/useMcpAppTools.js +1 -1
  57. package/oauth/authorize-url.js +3 -3
  58. package/oauth/toolset-id.js +5 -3
  59. package/oauth/useToolsetLogin/useToolsetLogin.js +8 -8
  60. package/oauth.d.ts +34 -2
  61. package/oauth.js +9 -9
  62. package/package.json +19 -23
  63. package/scheduled-task/scheduled-task-description.js +43 -39
  64. package/scheduled-task/scheduled-task-trigger.js +74 -71
  65. package/scheduled-task/use-scheduled-task-runs.js +162 -50
  66. package/scheduled-task/use-scheduled-tasks.js +52 -48
  67. package/scheduled-tasks.d.ts +27 -6
  68. package/scheduled-tasks.js +2 -2
  69. package/shared/application-schema.js +5 -2
  70. package/shared/cron-day-of-month.js +13 -0
  71. package/skill/skill-archive.js +19 -0
  72. package/skill/skill-types.js +8 -7
  73. package/skill/skill.js +52 -29
  74. package/skill/useSkillArchiveImport/useSkillArchiveImport.js +38 -34
  75. package/skill/useSkillEditorLoad.js +65 -59
  76. package/skill/useSkillEditorSubmit.js +105 -93
  77. package/skill/useSkillFileActions.js +70 -58
  78. package/skill-editor.d.ts +62 -13
  79. package/skill-editor.js +9 -9
  80. package/usage/map-user-usage-to-model-limits.js +137 -95
  81. package/usage.d.ts +8 -3
  82. package/usePageFileDrag/usePageFileDrag.js +3 -3
  83. package/utils.d.ts +26 -6
  84. package/utils.js +10 -10
@@ -1,57 +1,57 @@
1
1
  import { collectAttachmentRefs as e, splitFileIdAnchor as t } from "./attachment-refs.js";
2
2
  import { resolveDialFileBucketAndPath as n } from "./dial-file-resolve.js";
3
- import { generateUUID as r, sanitizeConversationName as i, stripTrailingDots as a, truncateToUtf8Bytes as o } from "@epam/ai-dial-chat-shared";
3
+ import { PUBLIC_BUCKET as r, generateUUID as i, sanitizeConversationName as a, stripTrailingDots as o, truncateToUtf8Bytes as s } from "@epam/ai-dial-chat-shared";
4
4
  //#region src/conversation/conversation-transfer/import-conversation.ts
5
- var s = class extends Error {
5
+ var c = class extends Error {
6
6
  constructor(e) {
7
7
  super(e), this.name = "UnsupportedImportFormatError";
8
8
  }
9
- }, c = (e) => typeof e == "object" && !!e, l = 5, u = (e) => {
9
+ }, l = (e) => typeof e == "object" && !!e, u = 5, d = (e) => {
10
10
  let t;
11
11
  try {
12
12
  t = JSON.parse(e);
13
13
  } catch {
14
- throw new s("Import file is not valid JSON");
14
+ throw new c("Import file is not valid JSON");
15
15
  }
16
- if (!c(t) || t.version !== l || !Array.isArray(t.history)) throw new s("Import file is not a supported export format");
16
+ if (!l(t) || t.version !== u || !Array.isArray(t.history)) throw new c("Import file is not a supported export format");
17
17
  let n = Array.isArray(t.folders) ? t.folders : [];
18
18
  return {
19
- version: l,
19
+ version: u,
20
20
  history: t.history,
21
21
  folders: n
22
22
  };
23
- }, d = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, f = "__", p = 255, m = "applications", h = /[-+]/, g = /^\d+$/, _ = (e) => e ? e.split(h)[0].split(".").every((e) => g.test(e)) : !1, v = (e) => a(o(e.replace(/\r\n|\r/g, "\n").split("\n").map((e) => i(e).trim()).filter(Boolean)[0] ?? "", p)).trimEnd(), y = (e, t, n) => {
24
- let i = e.split(f);
25
- if (i.length < 2) return [e, r()].join(f);
26
- let a = n && _(i[1]) ? i.slice(0, 2) : i.slice(0, 1), o = a.length > 1 ? d.test(i[i.length - 1]) : i.length >= 3, s = i.slice(a.length, o ? -1 : void 0).join(f);
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) => o(s(e.replace(/\r\n|\r/g, "\n").split("\n").map((e) => a(e).trim()).filter(Boolean)[0] ?? "", m)).trimEnd(), b = (e, t, n) => {
24
+ let r = e.split(p);
25
+ if (r.length < 2) return [e, i()].join(p);
26
+ 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);
27
27
  return [
28
28
  ...a,
29
29
  t || s,
30
- r()
31
- ].join(f);
32
- }, b = "conversations/", x = (e) => e.startsWith(b) ? e.slice(14) : e, S = (e, t) => {
33
- let n = x(e.id), r = n.split("/"), i = x(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 = v(e.name), f = y(l, d, u[0] === m), p = [...u, f].join("/"), h = o.length ? `${t}/${o.join("/")}` : t;
30
+ i()
31
+ ].join(p);
32
+ }, x = "conversations/", S = (e) => e.startsWith(x) ? e.slice(14) : e, C = (e, t) => {
33
+ 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;
34
34
  return {
35
35
  conversation: {
36
36
  ...e,
37
37
  ...d ? { name: d } : {},
38
38
  id: `${t}/${p}`,
39
- folderId: h
39
+ folderId: m
40
40
  },
41
41
  subPath: p
42
42
  };
43
- }, C = (e) => {
44
- let t = x(e.folderId).split("/").filter(Boolean).slice(1);
43
+ }, w = (e) => {
44
+ let t = S(e.folderId).split("/").filter(Boolean).slice(1);
45
45
  return t.length ? t.join(" / ") : void 0;
46
- }, w = (e) => e.map((e) => `"${e}"`).join(", "), T = (e, n) => {
46
+ }, T = (e) => e.map((e) => `"${e}"`).join(", "), E = (e, n) => {
47
47
  if (!e) return;
48
48
  let { fileId: r, anchor: i } = t(e), a = n.get(r);
49
49
  if (a != null) return {
50
50
  ...a,
51
51
  url: `${a.url}${i}`
52
52
  };
53
- }, E = (e, t) => {
54
- let n = T(e.url, t), r = T(e.reference_url, t);
53
+ }, D = (e, t) => {
54
+ let n = E(e.url, t), r = E(e.reference_url, t);
55
55
  if (n == null && r == null) return;
56
56
  let i = n?.title ?? r?.title;
57
57
  return {
@@ -59,19 +59,19 @@ var s = class extends Error {
59
59
  ...r == null ? {} : { reference_url: r.url },
60
60
  ...i == null ? {} : { title: i }
61
61
  };
62
- }, D = (e, t) => e.map((e) => e.attachments?.length ? {
62
+ }, O = (e, t) => e.map((e) => e.attachments?.length ? {
63
63
  ...e,
64
64
  attachments: e.attachments.map((e) => {
65
- let n = E(e, t);
65
+ let n = D(e, t);
66
66
  return n ? {
67
67
  ...e,
68
68
  ...n
69
69
  } : e;
70
70
  })
71
- } : e), O = (e, t) => e.map((e) => {
71
+ } : e), k = (e, t) => e.map((e) => {
72
72
  let n = e.body?.source;
73
73
  if (n?.attachment == null) return e;
74
- let r = E(n.attachment, t);
74
+ let r = D(n.attachment, t);
75
75
  return r == null ? e : {
76
76
  ...e,
77
77
  body: {
@@ -85,7 +85,7 @@ var s = class extends Error {
85
85
  }
86
86
  }
87
87
  };
88
- }), k = (e, t) => ({
88
+ }), A = (e, t) => ({
89
89
  ...e,
90
90
  messages: e.messages.map((e) => {
91
91
  let n = e.custom_content;
@@ -96,23 +96,72 @@ var s = class extends Error {
96
96
  custom_content: {
97
97
  ...n,
98
98
  ...r?.length ? { attachments: r.map((e) => {
99
- let n = E(e, t);
99
+ let n = D(e, t);
100
100
  return n ? {
101
101
  ...e,
102
102
  ...n
103
103
  } : e;
104
104
  }) } : {},
105
- ...i?.length ? { stages: D(i, t) } : {},
106
- ...a?.length ? { annotations: O(a, t) } : {}
105
+ ...i?.length ? { stages: O(i, t) } : {},
106
+ ...a?.length ? { annotations: k(a, t) } : {}
107
107
  }
108
108
  };
109
109
  })
110
- }), A = (e) => e.split("/").pop() || e, j = (t, r, i) => {
110
+ }), j = (e, i) => {
111
+ if (!e) return;
112
+ let a = n(t(e).fileId);
113
+ if (!(!a || a.bucket === i || a.bucket === r)) return a.path.split("/").pop() || a.path;
114
+ }, M = (e, t, n) => e.flatMap((e) => {
115
+ let r = j(e.url, t);
116
+ if (r != null) return n.push(r), [];
117
+ let i = j(e.reference_url, t);
118
+ if (i == null) return [e];
119
+ n.push(i);
120
+ let { reference_url: a, reference_type: o, ...s } = e;
121
+ return s.url == null && s.data == null ? [] : [s];
122
+ }), N = (e, t, n) => e.map((e) => {
123
+ let r = e.body, i = j(r?.source?.attachment?.url, t);
124
+ if (r == null || i == null) return e;
125
+ n.push(i);
126
+ let { source: a, ...o } = r;
127
+ return {
128
+ ...e,
129
+ body: o
130
+ };
131
+ }), P = (e, t) => {
132
+ let n = [], r = e.messages.map((e) => {
133
+ let r = e.custom_content;
134
+ if (!r) return e;
135
+ let { attachments: i, stages: a, annotations: o } = r;
136
+ return !i?.length && !a?.length && !o?.length ? e : {
137
+ ...e,
138
+ custom_content: {
139
+ ...r,
140
+ ...i?.length ? { attachments: M(i, t, n) } : {},
141
+ ...a?.length ? { stages: a.map((e) => e.attachments?.length ? {
142
+ ...e,
143
+ attachments: M(e.attachments, t, n)
144
+ } : e) } : {},
145
+ ...o?.length ? { annotations: N(o, t, n) } : {}
146
+ }
147
+ };
148
+ });
149
+ return n.length ? {
150
+ conversation: {
151
+ ...e,
152
+ messages: r
153
+ },
154
+ droppedNames: n
155
+ } : {
156
+ conversation: e,
157
+ droppedNames: n
158
+ };
159
+ }, F = (e) => e.split("/").pop() || e, I = (t, r, i) => {
111
160
  let a = [], o = [];
112
161
  for (let s of e(t)) {
113
162
  let e = n(s.fileId);
114
163
  if (!e) {
115
- o.push(A(s.fileId));
164
+ o.push(F(s.fileId));
116
165
  continue;
117
166
  }
118
167
  let t = e.path.split("/").pop() ?? e.path, c = r.get(e.path);
@@ -133,4 +182,4 @@ var s = class extends Error {
133
182
  };
134
183
  };
135
184
  //#endregion
136
- export { s as UnsupportedImportFormatError, w as formatQuotedNameList, C as getFolderBreadcrumb, u as parseImportEnvelope, j as planAttachmentUploads, S as rebaseConversationId, k as rewriteAttachmentUrls };
185
+ 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 };
@@ -1,93 +1,133 @@
1
1
  //#region src/conversation/create-chat-stream-api.ts
2
- var e = { "Content-Type": "application/json" }, t = 409, n = "A response is already being generated in this conversation. Wait for it to finish or stop it before sending another message.", r = class extends Error {
3
- constructor(e = n) {
2
+ var e = { "Content-Type": "application/json" }, t = 409, n = "The response could not be saved. It is still shown here, but may be lost if you reload or leave this page. Copy it before continuing.", r = class extends Error {
3
+ static type = "conversation_save_failed";
4
+ status;
5
+ constructor(e) {
6
+ super(n), this.name = "GenerationPersistenceError", this.status = e;
7
+ }
8
+ }, i = "A response is already being generated in this conversation. Wait for it to finish or stop it before sending another message.", a = class extends Error {
9
+ constructor(e = i) {
4
10
  super(e), this.name = "GenerationConflictError";
5
11
  }
6
- }, i = (e, t, n) => {
7
- let r = e.trim();
8
- if (!r || r.startsWith(":") || !r.startsWith("data: ")) return;
9
- let i = r.slice(6);
10
- if (i !== "[DONE]") try {
11
- let e = JSON.parse(i);
12
+ }, o = class extends Error {
13
+ constructor(e) {
14
+ super(e), this.name = "StreamUpstreamError";
15
+ }
16
+ }, s = class extends Error {
17
+ constructor(e) {
18
+ super("The completion stream was interrupted", { cause: e }), this.name = "StreamInterruptedError";
19
+ }
20
+ }, c = 45e3, l = (e, t) => {
21
+ let n = Date.now(), r, i = !1, a = () => {
22
+ if (i) return;
23
+ let o = Date.now() - n;
24
+ if (o >= e) {
25
+ t();
26
+ return;
27
+ }
28
+ clearTimeout(r), r = setTimeout(a, e - o);
29
+ }, o = () => {
30
+ document.visibilityState === "visible" && a();
31
+ }, s = typeof window < "u" && typeof document < "u";
32
+ return s && (document.addEventListener("visibilitychange", o), window.addEventListener("online", a), window.addEventListener("pageshow", a)), r = setTimeout(a, e), {
33
+ touch: () => {
34
+ n = Date.now();
35
+ },
36
+ stop: () => {
37
+ i || (i = !0, clearTimeout(r), s && (document.removeEventListener("visibilitychange", o), window.removeEventListener("online", a), window.removeEventListener("pageshow", a)));
38
+ }
39
+ };
40
+ }, u = (e) => typeof e == "object" && !!e && e.name === "AbortError", d = (e) => {
41
+ let { status: t } = e;
42
+ return typeof t == "number" ? t : void 0;
43
+ }, f = (e, t, n) => {
44
+ let i = e.trim();
45
+ if (!i || i.startsWith(":") || !i.startsWith("data: ")) return;
46
+ let a = i.slice(6);
47
+ if (a !== "[DONE]") try {
48
+ let e = JSON.parse(a);
12
49
  if (e.error) {
13
- n(Error(e.error.message));
50
+ n(e.error.type === r.type ? new r(d(e.error)) : new o(e.error.message));
14
51
  return;
15
52
  }
16
53
  t(e);
17
54
  } catch {}
18
- }, a = (n) => {
19
- let { completionsBasePath: a } = n, o = (...e) => (n.fetchImpl ?? fetch)(...e);
55
+ }, p = (n) => {
56
+ let { completionsBasePath: r } = n, i = (...e) => (n.fetchImpl ?? fetch)(...e);
20
57
  return {
21
- streamCompletion: (s, c, l, u, d, f, p, m, h) => {
22
- let { onChunk: g, onComplete: _, onError: v, signal: y } = u;
58
+ streamCompletion: (o, c, d, p, m, h, g, _, v) => {
59
+ let { onChunk: y, onComplete: b, onError: x, signal: S } = p;
23
60
  (async () => {
24
- let u;
61
+ let p;
25
62
  try {
26
63
  let t = n.getTimezone?.();
27
- u = await o(`${a}/completions`, {
64
+ p = await i(`${r}/completions`, {
28
65
  method: "POST",
29
66
  credentials: "include",
30
- signal: y,
67
+ signal: S,
31
68
  headers: {
32
69
  ...e,
33
70
  ...n.getCsrfToken() == null ? {} : { "X-CSRF-Token": n.getCsrfToken() },
34
71
  ...t ? { "X-Timezone": t } : {}
35
72
  },
36
73
  body: JSON.stringify({
37
- path: s,
74
+ path: o,
38
75
  message: c ?? "",
39
- model: l,
40
- custom_content: d || {},
41
- ...f != null && { generationId: f },
42
- ...p != null && { mode: p },
43
- ...m != null && { messageIndex: m },
44
- ...h != null && { clientChannelId: h }
76
+ model: d,
77
+ custom_content: m || {},
78
+ ...h != null && { generationId: h },
79
+ ...g != null && { mode: g },
80
+ ..._ != null && { messageIndex: _ },
81
+ ...v != null && { clientChannelId: v }
45
82
  })
46
83
  });
47
84
  } catch (e) {
48
- if (e instanceof Error && e.name === "AbortError") return;
49
- v(e instanceof Error ? e : Error(String(e)));
85
+ if (u(e)) return;
86
+ x(new s(e));
50
87
  return;
51
88
  }
52
- let b = u.headers.get("x-csrf-token");
53
- if (b && n.setCsrfToken(b), !u.ok) {
54
- if (u.status === t) {
55
- v(new r());
89
+ let C = p.headers.get("x-csrf-token");
90
+ if (C && n.setCsrfToken(C), !p.ok) {
91
+ if (p.status === t) {
92
+ x(new a());
56
93
  return;
57
94
  }
58
- v(/* @__PURE__ */ Error(`Stream request failed with status ${u.status}`));
95
+ x(/* @__PURE__ */ Error(`Stream request failed with status ${p.status}`));
59
96
  return;
60
97
  }
61
- if (!u.body) {
62
- v(/* @__PURE__ */ Error("No response body"));
98
+ if (!p.body) {
99
+ x(/* @__PURE__ */ Error("No response body"));
63
100
  return;
64
101
  }
65
- let x = u.body.getReader(), S = new TextDecoder(), C = "", w = !1, T = (e) => {
66
- w = !0, v(e);
67
- };
102
+ let w = p.body.getReader(), T = new TextDecoder(), E = "", D = !1, O = !1, k = (e) => {
103
+ D || (D = !0, A.stop(), x(e));
104
+ }, A = l(n.idleTimeoutMs ?? 45e3, () => {
105
+ O = !0, k(new s()), w.cancel().catch(() => void 0);
106
+ });
68
107
  try {
69
108
  for (;;) {
70
- let { done: e, value: t } = await x.read();
109
+ let { done: e, value: t } = await w.read();
110
+ if (O) break;
71
111
  if (e) {
72
- C.trim() && i(C, g, T);
112
+ E.trim() && f(E, y, k);
73
113
  break;
74
114
  }
75
- C += S.decode(t, { stream: !0 });
76
- let n = C.split("\n");
77
- C = n.pop() ?? "";
78
- for (let e of n) i(e, g, T);
115
+ A.touch(), E += T.decode(t, { stream: !0 });
116
+ let n = E.split("\n");
117
+ E = n.pop() ?? "";
118
+ for (let e of n) f(e, y, k);
79
119
  }
80
- w || _();
120
+ D || (D = !0, b());
81
121
  } catch (e) {
82
- if (e instanceof Error && e.name === "AbortError") return;
83
- v(e instanceof Error ? e : Error(String(e)));
122
+ if (u(e)) return;
123
+ k(new s(e));
84
124
  } finally {
85
- x.releaseLock();
125
+ A.stop(), w.releaseLock();
86
126
  }
87
127
  })();
88
128
  },
89
129
  stopCompletion: async (t) => {
90
- let r = await o(`${a}/completions/stop`, {
130
+ let a = await i(`${r}/completions/stop`, {
91
131
  method: "POST",
92
132
  credentials: "include",
93
133
  headers: {
@@ -95,10 +135,10 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "A response is alre
95
135
  ...n.getCsrfToken() == null ? {} : { "X-CSRF-Token": n.getCsrfToken() }
96
136
  },
97
137
  body: JSON.stringify(t)
98
- }), i = r.headers.get("x-csrf-token");
99
- if (i && n.setCsrfToken(i), !r.ok) throw Error(`stopCompletion failed: ${r.status}`);
138
+ }), o = a.headers.get("x-csrf-token");
139
+ if (o && n.setCsrfToken(o), !a.ok) throw Error(`stopCompletion failed: ${a.status}`);
100
140
  }
101
141
  };
102
142
  };
103
143
  //#endregion
104
- export { n as DEFAULT_GENERATION_CONFLICT_MESSAGE, r as GenerationConflictError, a as createChatStreamApi };
144
+ export { i as DEFAULT_GENERATION_CONFLICT_MESSAGE, n as DEFAULT_GENERATION_PERSISTENCE_ERROR_MESSAGE, c as DEFAULT_STREAM_IDLE_TIMEOUT_MS, a as GenerationConflictError, r as GenerationPersistenceError, s as StreamInterruptedError, o as StreamUpstreamError, p as createChatStreamApi };
@@ -1,14 +1,20 @@
1
+ import { findDeploymentByIdOrReference as e } from "../catalog/deployment-id.js";
1
2
  //#region src/conversation/get-model-id-from-conversation-id.ts
2
- var e = "__", t = /[-+]/, n = /^\d+$/, r = ".scheduler", i = "applications", a = (e) => e ? e.split(t)[0].split(".").every((e) => n.test(e)) : !1, o = (t, n) => {
3
- let [r, i] = t.split(e);
4
- return n && a(i) ? [r, i].join(e) : r;
5
- }, s = (t) => {
6
- let n = t.split("/");
3
+ var t = "__", n = /[-+]/, r = /^\d+$/, i = ".scheduler", a = "applications", o = (e) => e ? e.split(n)[0].split(".").every((e) => r.test(e)) : !1, s = (e, n) => {
4
+ let [r, i] = e.split(t);
5
+ return n && o(i) ? [r, i].join(t) : r;
6
+ }, c = (e) => {
7
+ let n = e.split("/");
7
8
  if (n.length < 3) return;
8
- let a = n.slice(2), s = a[0] === r ? a.slice(2) : a, c = s.findIndex((t) => t.includes(e));
9
+ let r = n.slice(2), o = r[0] === i ? r.slice(2) : r, c = o.findIndex((e) => e.includes(t));
9
10
  if (c === -1) return;
10
- let l = s[c], u = s.slice(0, c).filter(Boolean), d = o(l, u[0] === i), f = [...u, d].filter(Boolean);
11
+ let l = o[c], u = o.slice(0, c).filter(Boolean), d = s(l, u.at(-2) === a), f = [...u, d].filter(Boolean);
11
12
  return f.length > 0 ? f.join("/") : void 0;
12
- };
13
+ }, l = (e) => {
14
+ let t = c(e);
15
+ if (!t) return [];
16
+ let n = t.split("/");
17
+ return n.map((e, t) => n.slice(t).join("/"));
18
+ }, u = (t, n) => l(n).map((n) => e(t, n)).find(Boolean);
13
19
  //#endregion
14
- export { s as getModelIdFromConversationId };
20
+ export { u as findDeploymentForConversationId, l as getModelIdCandidatesFromConversationId, c as getModelIdFromConversationId };
@@ -9,6 +9,48 @@ var i = (t, n, r, i) => i && n === r - 1 && t.role === e.Assistant, a = (e) => {
9
9
  return null;
10
10
  }, o = (t) => t.role === e.Assistant && (t.custom_content?.stages?.length ?? 0) > 0, s = (t) => {
11
11
  for (let n = t.length - 1; n >= 0; n--) if (t[n].role === e.User) return t[n].custom_content?.configuration_value;
12
- }, c = (e) => (e ?? "").toLowerCase().replace(/[^a-z]/g, "") === "plaintext" ? t.PlainText : t.Markdown;
12
+ }, c = (e) => {
13
+ if (typeof e.default == "boolean") return e.default;
14
+ let t = e.oneOf;
15
+ if (Array.isArray(t) && t.length === 1) {
16
+ let e = t[0];
17
+ if (typeof e == "object" && e && "const" in e && typeof e.const == "boolean") return e.const;
18
+ }
19
+ }, l = (e) => {
20
+ let t = e?.properties;
21
+ if (t == null) return;
22
+ let n = Object.entries(t).flatMap(([e, t]) => {
23
+ let n = c(t);
24
+ return n === void 0 ? [] : [[e, n]];
25
+ });
26
+ return n.length > 0 ? Object.fromEntries(n) : void 0;
27
+ }, u = (t) => {
28
+ let n = -1;
29
+ for (let r = t.length - 1; r >= 0; r--) if (t[r].role === e.User) {
30
+ n = r;
31
+ break;
32
+ }
33
+ let r = t[n]?.custom_content?.configuration_value;
34
+ for (let i = n + 1; i < t.length; i++) {
35
+ let n = t[i];
36
+ if (n.role !== e.Assistant) continue;
37
+ let a = l(n.custom_content?.form_schema);
38
+ a && (r = {
39
+ ...r,
40
+ ...a
41
+ });
42
+ }
43
+ return r;
44
+ }, d = (t, n, r) => {
45
+ let i = n.length - 1, a = n[i];
46
+ if (a?.role !== e.Assistant) return;
47
+ let o = l(a.custom_content?.form_schema);
48
+ if (!o) return;
49
+ let s = Object.fromEntries(r.filter((e) => e in o).sort().map((e) => [e, o[e]]));
50
+ if (Object.keys(s).length !== 0) return {
51
+ key: `${t}|${i}|${JSON.stringify(s)}`,
52
+ values: s
53
+ };
54
+ }, f = (e) => (e ?? "").toLowerCase().replace(/[^a-z]/g, "") === "plaintext" ? t.PlainText : t.Markdown;
13
55
  //#endregion
14
- export { a as getLastDeploymentId, s as getLastUserMessageToolConfiguration, i as isMessageStreaming, o as messageHasStages, c as normalizeResponseFormat };
56
+ export { d as getFormSchemaToolSyncKey, a as getLastDeploymentId, s as getLastUserMessageToolConfiguration, u as getLatestToolConfiguration, l as getToolConfigurationFromFormSchema, i as isMessageStreaming, o as messageHasStages, f as normalizeResponseFormat };
@@ -14,10 +14,14 @@ var t = (t) => t === e.Completed ? e.Completed : t === e.Failed ? e.Failed : nul
14
14
  status: t(e.status),
15
15
  ...e.content != null && { content: e.content },
16
16
  ...e.tag != null && { tag: e.tag },
17
- ...e.attachments?.length && { attachments: e.attachments.map(n) }
17
+ ...e.attachments?.length && { attachments: e.attachments.map(n) },
18
+ ...e.parent_stage_index != null && { parent_stage_index: e.parent_stage_index }
18
19
  }), i = (e) => {
19
20
  let t = Array.isArray(e) ? e : e?.custom_content?.stages ?? e?.customContent?.stages;
20
- if (t?.length) return t.map(r);
21
+ if (t?.length) return t.map((e, t) => r(e.index == null ? {
22
+ ...e,
23
+ index: t
24
+ } : e));
21
25
  };
22
26
  //#endregion
23
27
  export { i as mapStages, r as toStage };
@@ -2,17 +2,16 @@ import { useEffect as e, useMemo as t } from "react";
2
2
  //#region src/conversation/useActiveConversationSync/useActiveConversationSync.ts
3
3
  var n = ({ activeConversationId: n, items: r, refreshConversations: i, markConversationViewed: a, conversationIdsMatch: o, toPanelConversationId: s }) => {
4
4
  let c = t(() => n ? s(n) : void 0, [n, s]);
5
- return e(() => {
5
+ e(() => {
6
6
  c && (r.some((e) => o(e.id, c)) || i());
7
- }, [c, o]), e(() => {
8
- if (!c) return;
9
- let e = r.find((e) => o(e.id, c));
10
- e && a(e.id);
7
+ }, [c, o]);
8
+ let l = c ? r.find((e) => o(e.id, c))?.id : void 0;
9
+ return e(() => {
10
+ c && l && a(l);
11
11
  }, [
12
12
  c,
13
- r,
14
- a,
15
- o
13
+ l,
14
+ a
16
15
  ]), c;
17
16
  };
18
17
  //#endregion
@@ -171,12 +171,12 @@ var S = 5, C = 512 * 1024 * 1024, w = 429, T = 5, E = 2e3, D = (e) => e instance
171
171
  }, s);
172
172
  return I.startJob(c, (e) => R(c, t, i, o, s, e));
173
173
  }, [I, R]), B = b(async (e, t, n) => {
174
- let r = d.ExportAll, a = [], s;
174
+ let r = d.ExportAll, a = [], c;
175
175
  do {
176
176
  if (n.aborted) return;
177
177
  let t;
178
178
  try {
179
- t = await x.listConversations({ nextToken: s }, { signal: n });
179
+ t = await x.listConversations({ nextToken: c }, { signal: n });
180
180
  } catch (t) {
181
181
  if (n.aborted) return;
182
182
  if (E(t).isUnauthorized) F?.({
@@ -197,18 +197,18 @@ var S = 5, C = 512 * 1024 * 1024, w = 429, T = 5, E = 2e3, D = (e) => e instance
197
197
  a.push(...t.items.filter(j).map((e) => ({
198
198
  id: e.id,
199
199
  title: e.title
200
- }))), s = t.nextToken;
201
- } while (s);
200
+ }))), c = t.nextToken;
201
+ } while (c);
202
202
  I.setJobProgress(e, p({
203
203
  kind: r,
204
204
  phase: f.Prepare
205
205
  }));
206
- let c = [];
206
+ let l = [];
207
207
  for (let t of a) {
208
208
  if (n.aborted) return;
209
209
  try {
210
210
  let e = await A(x, T(t.id), n);
211
- c.push(e);
211
+ l.push(e);
212
212
  } catch (r) {
213
213
  if (n.aborted) return;
214
214
  let i = E(r);
@@ -240,17 +240,17 @@ var S = 5, C = 512 * 1024 * 1024, w = 429, T = 5, E = 2e3, D = (e) => e instance
240
240
  I.setJobProgress(e, p({
241
241
  kind: r,
242
242
  phase: f.Transfer,
243
- completed: c.length,
243
+ completed: l.length,
244
244
  total: a.length
245
245
  }, {
246
- completed: c.length,
246
+ completed: l.length,
247
247
  total: a.length,
248
248
  kind: v.Conversation
249
249
  }));
250
250
  }
251
251
  }
252
252
  if (!n.aborted) try {
253
- y(o(i(c, [])), t), k?.({ jobId: e }), I.succeedJob(e);
253
+ y(o(i(l.map(s), [])), t), k?.({ jobId: e }), I.succeedJob(e);
254
254
  } catch (t) {
255
255
  let n = M(t) ? g.FileTooLarge : g.Unknown, r = await D(t);
256
256
  F?.({
@@ -1,12 +1,15 @@
1
1
  import { MessageRole as e } from "@epam/ai-dial-chat-shared";
2
2
  //#region src/conversation/useConversationHandlers/message-utils.ts
3
- var t = (e) => e != null && Object.keys(e).length > 0, n = (e, t) => (e?.length ?? 0) === (t?.length ?? 0) ? (e ?? []).some((e, n) => e.url !== t?.[n]?.url) : !0, r = (e, t, r, i, a) => {
3
+ var t = (e) => e != null && Object.keys(e).length > 0, n = (e, n) => t(n) ? {
4
+ ...e,
5
+ configuration_value: n
6
+ } : e, r = (e, t) => (e?.length ?? 0) === (t?.length ?? 0) ? (e ?? []).some((e, n) => e.url !== t?.[n]?.url) : !0, i = (e, t, n, i, a) => {
4
7
  if (t !== e.content || i.length > 0) return !0;
5
8
  let o = e.custom_content?.attachments?.length ?? 0;
6
- return r.length === o ? a != null && n(e.custom_content?.skills, a) : !0;
7
- }, i = (t) => t == null || t.role !== e.Assistant || !!t.wasStoppedByUser || t.streamErrorMessage != null, a = (e, t, n, a, o, s) => {
9
+ return n.length === o ? a != null && r(e.custom_content?.skills, a) : !0;
10
+ }, a = (t) => t == null || t.role !== e.Assistant || !!t.wasStoppedByUser || t.streamErrorMessage != null, o = (e, t, n, r, o, s) => {
8
11
  let c = e[t];
9
- return c ? r(c, n, a, o, s) || i(e[t + 1]) : !1;
12
+ return c ? i(c, n, r, o, s) || a(e[t + 1]) : !1;
10
13
  };
11
14
  //#endregion
12
- export { t as hasActiveToolConfig, i as isAnswerIncomplete, r as isMessageChanged, a as shouldRerunGenerationOnEdit };
15
+ export { t as hasActiveToolConfig, a as isAnswerIncomplete, i as isMessageChanged, o as shouldRerunGenerationOnEdit, n as withToolConfiguration };