@aintela/chat 0.3.0 → 0.3.2

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 (50) hide show
  1. package/README.md +14 -0
  2. package/dist/{atMentions-CCNBOf5W.js → atMentions-BhAwZTm1.js} +104 -88
  3. package/dist/atMentions-BhAwZTm1.js.map +1 -0
  4. package/dist/components.js +9822 -11029
  5. package/dist/components.js.map +1 -1
  6. package/dist/hooks.js +1 -1
  7. package/dist/{httpArtifactService-kXjuQtGa.js → httpArtifactService-qcYDyDh_.js} +47 -28
  8. package/dist/httpArtifactService-qcYDyDh_.js.map +1 -0
  9. package/dist/{httpSessionService-CMT6k-Nu.js → httpSessionService-DXlT2vxT.js} +33 -22
  10. package/dist/httpSessionService-DXlT2vxT.js.map +1 -0
  11. package/dist/index.js +237 -221
  12. package/dist/services.js +2 -2
  13. package/dist/src/components/AiChat/AiChatContext.d.ts +0 -3
  14. package/dist/src/components/AiChat/AiChatTypes.d.ts +0 -11
  15. package/dist/src/components/AiChat/ChatPane/ChatPane.test.d.ts +1 -0
  16. package/dist/src/components/AiChat/ChatPane/MessageAgent.d.ts +0 -1
  17. package/dist/src/components/AiChat/ChatPane/MessagePart.d.ts +5 -3
  18. package/dist/src/components/AiChat/ChatPane/MessagePart.test.d.ts +1 -0
  19. package/dist/src/components/AiChat/ChatPane/friendlyToolConfig.test.d.ts +1 -0
  20. package/dist/src/components/AiChat/ChatPane/messageAgentThoughts.test.d.ts +1 -0
  21. package/dist/src/components/AiChat/ChatPane/parts/uiToolDispatcher.test.d.ts +1 -0
  22. package/dist/src/components/AiChat/ChatPane/parts/uiToolRegistry.test.d.ts +1 -0
  23. package/dist/src/components/AiChat/index.d.ts +1 -3
  24. package/dist/src/components/index.d.ts +0 -3
  25. package/dist/src/components/v2/AiChatFloating.d.ts +3 -0
  26. package/dist/src/components/v2/PromptV2.d.ts +47 -6
  27. package/dist/src/components/v2/PromptV2.test.d.ts +1 -0
  28. package/dist/src/components/v2/icons.d.ts +1 -0
  29. package/dist/src/components/v2/index.d.ts +27 -25
  30. package/dist/src/components/v2/useVisualViewport.d.ts +20 -0
  31. package/dist/src/models/Notification.d.ts +11 -0
  32. package/dist/src/models/index.d.ts +1 -1
  33. package/dist/src/services/storageService.d.ts +18 -0
  34. package/dist/src/utils/index.d.ts +1 -0
  35. package/dist/src/utils/swallowNextClick.d.ts +16 -0
  36. package/dist/src/utils/urlParser.test.d.ts +1 -0
  37. package/dist/tests/fakes/fakeChatServices.d.ts +42 -0
  38. package/dist/{useChatSessions-CpHq0e1n.js → useChatSessions-1AAvAdPW.js} +2 -2
  39. package/dist/{useChatSessions-CpHq0e1n.js.map → useChatSessions-1AAvAdPW.js.map} +1 -1
  40. package/dist/utils.js +22 -21
  41. package/package.json +1 -1
  42. package/dist/atMentions-CCNBOf5W.js.map +0 -1
  43. package/dist/httpArtifactService-kXjuQtGa.js.map +0 -1
  44. package/dist/httpSessionService-CMT6k-Nu.js.map +0 -1
  45. package/dist/src/components/AiChat/AiChatFloating.d.ts +0 -3
  46. package/dist/src/components/AiChat/ChatPane/LastPrompts.d.ts +0 -9
  47. package/dist/src/components/AiChat/ChatPane/Prompt.d.ts +0 -9
  48. package/dist/src/components/AiChat/ChatPane/SubAgentBox.d.ts +0 -9
  49. package/dist/src/components/AiChat/ChatPane/TaskList.d.ts +0 -6
  50. package/dist/src/components/v2/AiChatFloatingV2.d.ts +0 -3
package/README.md CHANGED
@@ -103,6 +103,20 @@ flag is available on its own as `useTurnOpen()`
103
103
  (prefer it over `UiToolContext.onGoing`, which is a per-surface snapshot: `false`
104
104
  forever on a card that has settled into history, even while a later turn streams).
105
105
 
106
+ ### Component names (breaking in 0.3.0)
107
+
108
+ Every v2 component is exported under its **plain name** — `AppBar`, `Prompt`,
109
+ `TaskList`, `RunProgressStrip` — and again under its historical `…V2` name as an
110
+ alias, so no existing import breaks. Prefer the plain names.
111
+
112
+ The suffix existed to separate these from a v1 layer that no longer exists: the
113
+ last four v1 components (`Prompt`, `LastPrompts`, `TaskList`, `SubAgentBox`) were
114
+ deleted in 0.3.0 after confirming nothing consumed them, and the two
115
+ `AiChatFloating` implementations were merged into one. Gone with them are the
116
+ props that selected the v1 renderers — **`compactPrompt`**, **`showTaskList`**
117
+ and **`showSubAgents`**. The prompt is always the compact one now; the task list
118
+ and sub-agent trace live in the RunProgress panel.
119
+
106
120
  ### One engine, one agent (breaking in 0.3.0)
107
121
 
108
122
  The `AgentContext` — which agent answers — is owned by the **engine**, and by nothing
@@ -1,6 +1,8 @@
1
- var A = Object.defineProperty;
2
- var d = (n, t) => A(n, "name", { value: t, configurable: !0 });
3
- const H = /* @__PURE__ */ d((n, t, e) => {
1
+ var x = Object.defineProperty;
2
+ var $ = (n, t, e) => t in n ? x(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var d = (n, t) => x(n, "name", { value: t, configurable: !0 });
4
+ var E = (n, t, e) => $(n, typeof t != "symbol" ? t + "" : t, e);
5
+ const F = /* @__PURE__ */ d((n, t, e) => {
4
6
  let s = "URL", o = null, i = null, r = null;
5
7
  if (n[0] == "#") {
6
8
  const a = n.indexOf("-"), l = n.slice(1, a);
@@ -15,10 +17,10 @@ const H = /* @__PURE__ */ d((n, t, e) => {
15
17
  } else
16
18
  n.indexOf("http") > -1 ? (s = "URL", i = n) : (n = n.replaceAll("exported/", `exported/${t}/`), s = "Export");
17
19
  return { action: s, url: i, question: o, parameter: r };
18
- }, "extractLinkAction"), k = /* @__PURE__ */ d((n, t) => Array.from(
20
+ }, "extractLinkAction"), D = /* @__PURE__ */ d((n, t) => Array.from(
19
21
  { length: Math.ceil(n.length / t) },
20
22
  (e, s) => n.slice(s * t, s * t + t)
21
- ), "chunkArray"), _ = /* @__PURE__ */ d((n) => {
23
+ ), "chunkArray"), z = /* @__PURE__ */ d((n) => {
22
24
  n = n.replaceAll("\\n", `
23
25
  `);
24
26
  const t = 90, e = n.split(" "), s = [];
@@ -26,14 +28,14 @@ const H = /* @__PURE__ */ d((n, t, e) => {
26
28
  for (const i of e)
27
29
  if (i.length > t) {
28
30
  o = !0;
29
- const r = [...i], l = k(r, t).map((c) => c.join("")).join(`
31
+ const r = [...i], l = D(r, t).map((c) => c.join("")).join(`
30
32
  `);
31
33
  s.push(l);
32
34
  } else
33
35
  s.push(i);
34
36
  return o ? s.join(" ") : n;
35
37
  }, "splitBigLinesWithSpaces");
36
- function $(n) {
38
+ function I(n) {
37
39
  let t = parseFloat(n);
38
40
  if (!isNaN(t))
39
41
  return n = n.replaceAll(/[,\.]/g, ""), parseInt(n);
@@ -43,37 +45,37 @@ function $(n) {
43
45
  const s = e.length / n.length;
44
46
  return t = parseInt(e), !isNaN(t) && s > 0.5 ? t : NaN;
45
47
  }
46
- d($, "parseRawNumber");
47
- const I = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i, N = /^[0-9a-f]{32}/i;
48
- function z(n) {
48
+ d(I, "parseRawNumber");
49
+ const N = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i, W = /^[0-9a-f]{32}/i;
50
+ function B(n) {
49
51
  if (!n || typeof n != "string")
50
52
  return !1;
51
- const t = W(n);
53
+ const t = q(n);
52
54
  return t === null ? !1 : n.startsWith(t);
53
55
  }
54
- d(z, "startsWithInteractionId");
55
- function W(n) {
56
+ d(B, "startsWithInteractionId");
57
+ function q(n) {
56
58
  if (!n || typeof n != "string")
57
59
  return null;
58
- const t = n.match(I);
60
+ const t = n.match(N);
59
61
  if (t)
60
62
  return t[0];
61
- const e = n.match(N);
63
+ const e = n.match(W);
62
64
  return e ? e[0] : null;
63
65
  }
64
- d(W, "extractInteractionId");
65
- function B(n) {
66
+ d(q, "extractInteractionId");
67
+ function P(n) {
66
68
  if (n.length == 0)
67
69
  return n;
68
70
  const t = n.replaceAll("_", " ").replaceAll("-", " ");
69
71
  return t[0].toUpperCase() + t.slice(1);
70
72
  }
71
- d(B, "prettiffyPythonFunctionName");
72
- function F(n) {
73
+ d(P, "prettiffyPythonFunctionName");
74
+ function V(n) {
73
75
  return !n || typeof n != "string" ? !1 : !!(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n) || /^[0-9a-f]{32}$/i.test(n));
74
76
  }
75
- d(F, "isValidInteractionId");
76
- const x = /* @__PURE__ */ new Set(), C = class C {
77
+ d(V, "isValidInteractionId");
78
+ const L = /* @__PURE__ */ new Set(), v = class v {
77
79
  constructor(t = {}) {
78
80
  this.options = {
79
81
  // CSS class for sortable headers
@@ -184,7 +186,7 @@ const x = /* @__PURE__ */ new Set(), C = class C {
184
186
  direction: "none"
185
187
  }), t.hasAttribute("data-original-width") || t.setAttribute("data-original-width", t.getBoundingClientRect().width), this.applyTableStyles(t), this.originalColumnOrder.set(e, Array.from(i).map((a, l) => l)), i.forEach((a, l) => {
186
188
  this.options.excludeColumns.includes(l) || this.makeHeaderSortable(a, t, e, l);
187
- }), this.replaceExponentialValues(t), x.add(t);
189
+ }), this.replaceExponentialValues(t), L.add(t);
188
190
  }
189
191
  /**
190
192
  * Replace exponential values in table cells with full numbers
@@ -299,7 +301,7 @@ const x = /* @__PURE__ */ new Set(), C = class C {
299
301
  * Extract sortable value from cell
300
302
  */
301
303
  extractValue(t) {
302
- let e = t.textContent.trim(), s = $(e);
304
+ let e = t.textContent.trim(), s = I(e);
303
305
  if (!isNaN(s))
304
306
  return console.log(s), s;
305
307
  if (e = e.replace(/arrow_upward|arrow_downward|remove|keyboard_arrow_up|keyboard_arrow_down|unfold_more|expand_more|expand_less|trending_up|trending_down|↗|↘|↑|↓|→|←/g, "").trim(), /^(N\/A|N\/D|ND|N\/A|n\/a|n\/d|nd|N\/A|N\/D|ND|\s*)$/i.test(e))
@@ -592,9 +594,11 @@ const x = /* @__PURE__ */ new Set(), C = class C {
592
594
  const e = this.calculateTableWidth(t);
593
595
  t.style.width = e, t.style.maxWidth = "100%";
594
596
  }
595
- getCharWidth(t, e, s) {
596
- const i = document.createElement("canvas").getContext("2d");
597
- return i.fontFamily = e, i.fontMono = s, i.measureText("A ").width;
597
+ // Signature matches the single call site — `init()` passes (fontFamily,
598
+ // fontMono), which used to land on a leading `char` parameter nothing read.
599
+ getCharWidth(t, e) {
600
+ const s = document.createElement("canvas").getContext("2d");
601
+ return s ? (s.fontFamily = t, s.fontMono = e, s.measureText("A ").width) : v.DEFAULT_CHAR_WIDTH;
598
602
  }
599
603
  /**
600
604
  * Add CSS styles for sortable tables
@@ -748,7 +752,7 @@ const x = /* @__PURE__ */ new Set(), C = class C {
748
752
  });
749
753
  });
750
754
  const t = document.getElementById("sortable-table-styles");
751
- t && t.remove(), this.tables = [], this.sortStates.clear(), x.clear();
755
+ t && t.remove(), this.tables = [], this.sortStates.clear(), L.clear();
752
756
  }
753
757
  /**
754
758
  * Refresh the library (useful after DOM changes)
@@ -757,39 +761,40 @@ const x = /* @__PURE__ */ new Set(), C = class C {
757
761
  this.destroy(), this.init();
758
762
  }
759
763
  };
760
- d(C, "SortableTable");
761
- let S = C;
762
- typeof window < "u" && (window.SortableTable = S);
763
- const E = /* @__PURE__ */ new Set(["/", "@", "#"]), q = /* @__PURE__ */ d((n) => n === "/" ? "slash" : n === "@" ? "at" : "hash", "triggerTypeFor"), w = /[ \t\r\n\f\v]/, D = /\[[^\]\n]+\]/g, L = /* @__PURE__ */ d((n, t, e) => {
764
+ d(v, "SortableTable"), /** Fallback advance width, in px, for one character of the body font. */
765
+ E(v, "DEFAULT_CHAR_WIDTH", 8);
766
+ let C = v;
767
+ typeof window < "u" && (window.SortableTable = C);
768
+ const T = /* @__PURE__ */ new Set(["/", "@", "#"]), M = /* @__PURE__ */ d((n) => n === "/" ? "slash" : n === "@" ? "at" : "hash", "triggerTypeFor"), S = /[ \t\r\n\f\v]/, O = /\[[^\]\n]+\]/g, A = /* @__PURE__ */ d((n, t, e) => {
764
769
  let s = 0;
765
770
  const o = /* @__PURE__ */ d((i) => {
766
771
  const r = i === 0 ? t : n[i - 1];
767
- return r === void 0 || w.test(r);
772
+ return r === void 0 || S.test(r);
768
773
  }, "boundaryBefore");
769
774
  for (; s < n.length; ) {
770
775
  const i = n[s];
771
- if (o(s) && E.has(i)) {
776
+ if (o(s) && T.has(i)) {
772
777
  let r = s + 1;
773
- for (; r < n.length && !w.test(n[r]); ) r += 1;
774
- e.push({ type: q(i), text: n.slice(s, r) }), s = r;
778
+ for (; r < n.length && !S.test(n[r]); ) r += 1;
779
+ e.push({ type: M(i), text: n.slice(s, r) }), s = r;
775
780
  } else {
776
781
  let r = s + 1;
777
782
  for (; r < n.length; ) {
778
783
  const a = n[r];
779
- if (E.has(a) && w.test(n[r - 1])) break;
784
+ if (T.has(a) && S.test(n[r - 1])) break;
780
785
  r += 1;
781
786
  }
782
787
  e.push({ type: "plain", text: n.slice(s, r) }), s = r;
783
788
  }
784
789
  }
785
- }, "tokenizeSegment"), V = /* @__PURE__ */ d((n) => {
790
+ }, "tokenizeSegment"), U = /* @__PURE__ */ d((n) => {
786
791
  if (!n) return [];
787
- const t = [], e = new RegExp(D.source, "g");
792
+ const t = [], e = new RegExp(O.source, "g");
788
793
  let s = 0;
789
794
  for (let o = e.exec(n); o; o = e.exec(n))
790
- o.index > s && L(n.slice(s, o.index), s === 0 ? void 0 : n[s - 1], t), t.push({ type: "placeholder", text: o[0] }), s = o.index + o[0].length;
791
- return s < n.length && L(n.slice(s), s === 0 ? void 0 : n[s - 1], t), t;
792
- }, "tokenizeForHighlight"), P = /* @__PURE__ */ d((n, t) => {
795
+ o.index > s && A(n.slice(s, o.index), s === 0 ? void 0 : n[s - 1], t), t.push({ type: "placeholder", text: o[0] }), s = o.index + o[0].length;
796
+ return s < n.length && A(n.slice(s), s === 0 ? void 0 : n[s - 1], t), t;
797
+ }, "tokenizeForHighlight"), X = /* @__PURE__ */ d((n, t) => {
793
798
  const e = t.filter((o) => o.trim().length > 0).sort((o, i) => i.length - o.length);
794
799
  if (e.length === 0) return n;
795
800
  const s = [];
@@ -814,7 +819,7 @@ const E = /* @__PURE__ */ new Set(["/", "@", "#"]), q = /* @__PURE__ */ d((n) =>
814
819
  }
815
820
  return s;
816
821
  }, "chipLocations");
817
- function X(n, t, e = t, s = 600) {
822
+ function G(n, t, e = t, s = 600) {
818
823
  const o = n.value;
819
824
  let i = !1;
820
825
  const r = /* @__PURE__ */ d(() => {
@@ -832,9 +837,19 @@ function X(n, t, e = t, s = 600) {
832
837
  const c = window.setTimeout(r, s), p = window.setInterval(a, 50);
833
838
  return document.addEventListener("selectionchange", l), n.addEventListener("keydown", r), n.addEventListener("input", r), n.addEventListener("pointerdown", r), r;
834
839
  }
835
- d(X, "placeCaret");
836
- const M = 2;
837
- function U(n, t) {
840
+ d(G, "placeCaret");
841
+ function j() {
842
+ if (typeof document > "u") return;
843
+ const n = /* @__PURE__ */ d((s) => {
844
+ s.stopPropagation(), s.preventDefault(), t();
845
+ }, "onClick"), t = /* @__PURE__ */ d(() => {
846
+ document.removeEventListener("click", n, !0), window.clearTimeout(e);
847
+ }, "cleanup"), e = window.setTimeout(t, 500);
848
+ document.addEventListener("click", n, !0);
849
+ }
850
+ d(j, "swallowNextClick");
851
+ const H = 2;
852
+ function K(n, t) {
838
853
  let e = 0;
839
854
  for (let s = t - 1; s >= 0; s -= 1) {
840
855
  const o = n[s];
@@ -847,17 +862,17 @@ function U(n, t) {
847
862
  };
848
863
  if (o === " ") return null;
849
864
  if (o === " " || o === " ") {
850
- if (e += 1, e > M) return null;
865
+ if (e += 1, e > H) return null;
851
866
  continue;
852
867
  }
853
868
  if (/\s/.test(o)) return null;
854
869
  }
855
870
  return null;
856
871
  }
857
- d(U, "detectTrigger");
858
- const O = /\[[^\]\n]+\]/g;
859
- function v(n, t = 0) {
860
- const e = new RegExp(O.source, "g");
872
+ d(K, "detectTrigger");
873
+ const R = /\[[^\]\n]+\]/g;
874
+ function w(n, t = 0) {
875
+ const e = new RegExp(R.source, "g");
861
876
  e.lastIndex = t;
862
877
  const s = e.exec(n);
863
878
  if (!s) return null;
@@ -869,33 +884,33 @@ function v(n, t = 0) {
869
884
  endIdx: s.index + s[0].length
870
885
  };
871
886
  }
872
- d(v, "findPlaceholder");
873
- function G(n, t) {
887
+ d(w, "findPlaceholder");
888
+ function Z(n, t) {
874
889
  for (let e = 0; ; ) {
875
- const s = v(n, e);
890
+ const s = w(n, e);
876
891
  if (!s || s.startIdx > t) return null;
877
892
  if (t <= s.endIdx) return s;
878
893
  e = s.endIdx;
879
894
  }
880
895
  }
881
- d(G, "placeholderAt");
882
- function T(n, t) {
896
+ d(Z, "placeholderAt");
897
+ function k(n, t) {
883
898
  if (t.trigger) {
884
899
  const e = n.slice(0, t.startIdx) + t.trigger + n.slice(t.endIdx), s = t.startIdx + 1;
885
900
  return { next: e, selectionStart: s, selectionEnd: s, reopenTrigger: !0 };
886
901
  }
887
902
  return { next: n, selectionStart: t.startIdx, selectionEnd: t.endIdx, reopenTrigger: !1 };
888
903
  }
889
- d(T, "activatePlaceholder");
890
- function j(n, t) {
891
- const e = v(n, t) ?? v(n, 0);
892
- return e ? T(n, e) : null;
904
+ d(k, "activatePlaceholder");
905
+ function J(n, t) {
906
+ const e = w(n, t) ?? w(n, 0);
907
+ return e ? k(n, e) : null;
893
908
  }
894
- d(j, "advanceToPlaceholder");
895
- function K(n, t, e) {
896
- const s = n.slice(0, t.startIdx), o = n.slice(t.endIdx), i = v(e);
909
+ d(J, "advanceToPlaceholder");
910
+ function Y(n, t, e) {
911
+ const s = n.slice(0, t.startIdx), o = n.slice(t.endIdx), i = w(e);
897
912
  if (i) {
898
- const c = T(e, i);
913
+ const c = k(e, i);
899
914
  return {
900
915
  next: `${s}${c.next}${o}`,
901
916
  selectionStart: s.length + c.selectionStart,
@@ -911,8 +926,8 @@ function K(n, t, e) {
911
926
  const a = `${e} `, l = s.length + a.length;
912
927
  return { next: `${s}${a}${o}`, selectionStart: l, selectionEnd: l, reopenTrigger: !1 };
913
928
  }
914
- d(K, "applyTriggerInsertion");
915
- async function Z(n, { onAtQuery: t, onAtPersonQuery: e }, { personConfidence: s = 0, locationConfidence: o = 0, personFirstThreshold: i = 0.5 } = {}) {
929
+ d(Y, "applyTriggerInsertion");
930
+ async function Q(n, { onAtQuery: t, onAtPersonQuery: e }, { personConfidence: s = 0, locationConfidence: o = 0, personFirstThreshold: i = 0.5 } = {}) {
916
931
  const [r, a] = await Promise.all([
917
932
  t ? t(n).catch(() => []) : Promise.resolve([]),
918
933
  e ? e(n).catch(() => []) : Promise.resolve([])
@@ -923,32 +938,33 @@ async function Z(n, { onAtQuery: t, onAtPersonQuery: e }, { personConfidence: s
923
938
  }
924
939
  return [...a, ...r];
925
940
  }
926
- d(Z, "fetchAtMentions");
927
- function J(n, t) {
941
+ d(Q, "fetchAtMentions");
942
+ function tt(n, t) {
928
943
  var s, o;
929
944
  const e = (s = n[t]) == null ? void 0 : s.group;
930
945
  return e !== void 0 && (t === 0 || ((o = n[t - 1]) == null ? void 0 : o.group) !== e);
931
946
  }
932
- d(J, "isSectionStart");
947
+ d(tt, "isSectionStart");
933
948
  export {
934
- S,
935
- T as a,
936
- j as b,
937
- K as c,
938
- P as d,
939
- k as e,
940
- U as f,
941
- W as g,
942
- H as h,
943
- Z as i,
944
- v as j,
945
- J as k,
946
- F as l,
947
- G as m,
948
- B as n,
949
- z as o,
950
- X as p,
951
- _ as s,
952
- V as t
949
+ C as S,
950
+ k as a,
951
+ J as b,
952
+ Y as c,
953
+ X as d,
954
+ D as e,
955
+ K as f,
956
+ q as g,
957
+ F as h,
958
+ Q as i,
959
+ w as j,
960
+ tt as k,
961
+ V as l,
962
+ Z as m,
963
+ P as n,
964
+ B as o,
965
+ G as p,
966
+ j as q,
967
+ z as s,
968
+ U as t
953
969
  };
954
- //# sourceMappingURL=atMentions-CCNBOf5W.js.map
970
+ //# sourceMappingURL=atMentions-BhAwZTm1.js.map