@kitn.ai/ui 0.23.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/{create-tween-vA7upv0h.js → create-tween-4z1XYLkR.js} +1 -1
  2. package/dist/{create-tween-CTT5l1bo.js → create-tween-B5Y4Im8G.js} +1 -1
  3. package/dist/{create-tween-BmBnlg25.js → create-tween-CUzOlaMS.js} +1 -1
  4. package/dist/elements/artifact.js +1 -1
  5. package/dist/elements/cards.js +1 -1
  6. package/dist/elements/chat-workspace.js +1 -1
  7. package/dist/elements/chat.js +1 -1
  8. package/dist/elements/choice.js +1 -1
  9. package/dist/elements/chunks/artifact-BSuPYFHY.js +1 -0
  10. package/dist/elements/chunks/{card-renderer-aNA0WRFH.js → card-renderer-CSoTL_e1.js} +1 -1
  11. package/dist/elements/chunks/card-routing-BK09BdmL.js +1 -0
  12. package/dist/elements/chunks/{chat-thread-DN9evldr.js → chat-thread-DxoKaStk.js} +1 -1
  13. package/dist/elements/chunks/{choice-card-kNsjU2m8.js → choice-card-CGMc3kek.js} +1 -1
  14. package/dist/elements/chunks/{confirm-card-CEvFmVhz.js → confirm-card-BWjf2-xo.js} +1 -1
  15. package/dist/elements/chunks/{form-lUuJjz6s.js → form-Cp8Y00Wn.js} +1 -1
  16. package/dist/elements/chunks/link-preview-Cf5KOP-i.js +1 -0
  17. package/dist/elements/chunks/link-preview-DNILK391.js +1 -0
  18. package/dist/elements/chunks/{markdown-BpAHnBJz.js → markdown-DbozyYqa.js} +16 -16
  19. package/dist/elements/chunks/{message-CoqLuLkd.js → message-CE4k-qaj.js} +1 -1
  20. package/dist/elements/chunks/{message-_oYx5mk1.js → message-DtXKPqiR.js} +1 -1
  21. package/dist/elements/chunks/{reasoning-D26Bb4p6.js → reasoning-BrxQfpfI.js} +1 -1
  22. package/dist/elements/chunks/source-w9V0NnBn.js +1 -0
  23. package/dist/elements/chunks/{tasks-card-CfqrkoVO.js → tasks-card-lPxoodlA.js} +1 -1
  24. package/dist/elements/compare.js +1 -1
  25. package/dist/elements/confirm-card.js +1 -1
  26. package/dist/elements/embed.js +1 -1
  27. package/dist/elements/form.js +1 -1
  28. package/dist/elements/link-preview.js +1 -1
  29. package/dist/elements/markdown.js +1 -1
  30. package/dist/elements/message.js +1 -1
  31. package/dist/elements/reasoning.js +1 -1
  32. package/dist/elements/remote.js +1 -1
  33. package/dist/elements/source.js +1 -1
  34. package/dist/elements/tasks.js +1 -1
  35. package/dist/elements/thread.js +1 -1
  36. package/dist/index.js +4011 -3936
  37. package/dist/index.server.js +3302 -3228
  38. package/dist/kai.es.js +1 -1
  39. package/dist/primitives/card-routing.d.ts +33 -0
  40. package/dist/{register-impl-C96AnOJn.js → register-impl-DGmGzrEM.js} +15 -15
  41. package/dist/{solid-C76UXJuy.js → solid-BMuDmFo_.js} +4427 -4352
  42. package/dist/{solid-BuqWLn6x.js → solid-CGYNdLRR.js} +3738 -3664
  43. package/dist/solid.js +1 -1
  44. package/dist/solid.server.js +1 -1
  45. package/dist/state/stream.d.ts +22 -4
  46. package/dist/{variant-aurora-CD35fdJF.js → variant-aurora-DwSOfraQ.js} +2 -2
  47. package/dist/{variant-aurora-Dau5Z4yR.js → variant-aurora-XEkPT0_z.js} +1 -1
  48. package/dist/{variant-aurora-Dc-2RVH9.js → variant-aurora-wKvAQ5wp.js} +2 -2
  49. package/dist/{variant-custom-CHr_jbMU.js → variant-custom-BhS9wIpU.js} +2 -2
  50. package/dist/{variant-custom-Df7QvXyZ.js → variant-custom-MkTNTycd.js} +1 -1
  51. package/dist/{variant-custom-Cyu8zx4A.js → variant-custom-eFIg2XWQ.js} +2 -2
  52. package/dist/{variant-wave-CXcaP_9W.js → variant-wave-BwzrHD1s.js} +1 -1
  53. package/dist/{variant-wave-BkVpxkVF.js → variant-wave-CUWGx9Bn.js} +2 -2
  54. package/dist/{variant-wave-DcGqjVnK.js → variant-wave-CbVsmgwT.js} +2 -2
  55. package/dist/wire.js +112 -105
  56. package/package.json +6 -6
  57. package/src/components/artifact.tsx +110 -24
  58. package/src/components/markdown.tsx +83 -5
  59. package/src/components/source.tsx +35 -3
  60. package/src/primitives/card-routing.ts +54 -2
  61. package/src/state/stream.ts +92 -3
  62. package/src/wire/formats/openai.ts +38 -2
  63. package/dist/elements/chunks/artifact-BhJIuh3D.js +0 -1
  64. package/dist/elements/chunks/card-routing-C986KuUA.js +0 -1
  65. package/dist/elements/chunks/link-preview-C9-jNJBf.js +0 -1
  66. package/dist/elements/chunks/source-eJurW_-L.js +0 -1
package/dist/wire.js CHANGED
@@ -1,6 +1,6 @@
1
- var z = Object.defineProperty;
2
- var G = (t, e, n) => e in t ? z(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var A = (t, e, n) => G(t, typeof e != "symbol" ? e + "" : e, n);
1
+ var H = Object.defineProperty;
2
+ var z = (t, e, n) => e in t ? H(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var A = (t, e, n) => z(t, typeof e != "symbol" ? e + "" : e, n);
4
4
  async function* X(t) {
5
5
  const e = t.getReader();
6
6
  let n = !1;
@@ -71,7 +71,7 @@ async function* Z(t) {
71
71
  }
72
72
  }
73
73
  }
74
- function E(t) {
74
+ function $(t) {
75
75
  const e = t.toLowerCase();
76
76
  return e ? e.includes("bash") || e.includes("command") || e.includes("shell") || e.includes("terminal") || e.includes("exec") ? "command" : e.includes("edit") || e.includes("write") || e.includes("patch") || e.includes("replace") || e.includes("delete") ? "file-change" : e.includes("search") || e.includes("grep") || e.includes("glob") || e.includes("find") ? "search" : e.includes("fetch") || e.includes("http") || e.includes("browse") || e.includes("crawl") ? "fetch" : e.includes("mcp") ? "mcp" : e.includes("image") || e.includes("screenshot") || e.includes("vision") ? "image" : "generic" : "generic";
77
77
  }
@@ -133,13 +133,13 @@ function it(t, e, n) {
133
133
  ...n,
134
134
  toolCallId: e
135
135
  };
136
- return i.kind = i.kind ?? E(i.type), [...t, { type: "tool", tool: i }];
136
+ return i.kind = i.kind ?? $(i.type), [...t, { type: "tool", tool: i }];
137
137
  }
138
138
  const r = t[o].tool, s = { ...r, ...n, toolCallId: e };
139
139
  return s.kind = st(r, n, s.type), s.raw === void 0 && r.raw !== void 0 && (s.raw = r.raw), ct(r, s) ? t : [...t.slice(0, o), { type: "tool", tool: s }, ...t.slice(o + 1)];
140
140
  }
141
141
  function st(t, e, n) {
142
- return e.kind !== void 0 ? e.kind : t.kind === void 0 || t.kind === E(t.type) ? E(n) : t.kind;
142
+ return e.kind !== void 0 ? e.kind : t.kind === void 0 || t.kind === $(t.type) ? $(n) : t.kind;
143
143
  }
144
144
  const at = [
145
145
  "type",
@@ -418,20 +418,27 @@ function _t(t) {
418
418
  }
419
419
  return e;
420
420
  }
421
- function j(t, e) {
421
+ function N(t, e) {
422
422
  for (const n of t)
423
423
  if (x(n) && n[e] !== void 0) return n[e];
424
424
  }
425
- function It(t, e) {
426
- const n = Array.isArray(t.reasoning_details) ? t.reasoning_details : void 0, o = b(t.reasoning), r = o !== void 0 && o !== "" ? o : void 0, s = n ? _t(n) : void 0, i = n !== void 0 && n.length > 0, a = r ?? s;
427
- if (a === void 0 && !i || (e.reasoning = a ?? "", !i)) return;
425
+ const It = ["reasoning", "reasoning_content"];
426
+ function At(t) {
427
+ for (const e of It) {
428
+ const n = b(t[e]);
429
+ if (n !== void 0 && n !== "") return n;
430
+ }
431
+ }
432
+ function Rt(t, e) {
433
+ const n = Array.isArray(t.reasoning_details) ? t.reasoning_details : void 0, o = At(t), r = n ? _t(n) : void 0, s = n !== void 0 && n.length > 0, i = o ?? r;
434
+ if (i === void 0 && !s || (e.reasoning = i ?? "", !s)) return;
428
435
  e.reasoningRaw = { source: "openai.reasoning_details", payload: n };
429
- const c = I(j(n, "index"));
430
- c !== void 0 && (e.reasoningIndex = c);
431
- const u = b(j(n, "signature"));
432
- u !== void 0 && (e.reasoningSignature = u);
436
+ const a = I(N(n, "index"));
437
+ a !== void 0 && (e.reasoningIndex = a);
438
+ const c = b(N(n, "signature"));
439
+ c !== void 0 && (e.reasoningSignature = c);
433
440
  }
434
- function At(t) {
441
+ function Ot(t) {
435
442
  if (!Array.isArray(t.annotations)) return [];
436
443
  const e = [];
437
444
  for (const n of t.annotations) {
@@ -445,7 +452,7 @@ function At(t) {
445
452
  }
446
453
  return e;
447
454
  }
448
- function Rt(t) {
455
+ function St(t) {
449
456
  if (!x(t)) return [];
450
457
  const e = {}, n = t.error;
451
458
  if (x(n)) {
@@ -463,11 +470,11 @@ function Rt(t) {
463
470
  const i = x(s.delta) ? s.delta : void 0;
464
471
  if (i) {
465
472
  const c = b(i.content);
466
- if (c && (e.text = c), It(i, e), Array.isArray(i.tool_calls) && i.tool_calls.length > 0) {
473
+ if (c && (e.text = c), Rt(i, e), Array.isArray(i.tool_calls) && i.tool_calls.length > 0) {
467
474
  const d = i.tool_calls.map((l, p) => vt(l, p)).filter((l) => l !== void 0);
468
475
  d.length > 0 && (e.toolCalls = d);
469
476
  }
470
- const u = At(i);
477
+ const u = Ot(i);
471
478
  u.length > 0 && (e.sources = u);
472
479
  }
473
480
  const a = b(s.finish_reason);
@@ -475,10 +482,10 @@ function Rt(t) {
475
482
  }
476
483
  return Object.keys(e).length > 0 ? [e] : [];
477
484
  }
478
- const Ot = {
485
+ const Et = {
479
486
  id: "openai.chat-completions",
480
487
  open() {
481
- return { push: Rt };
488
+ return { push: St };
482
489
  }
483
490
  };
484
491
  function w(t) {
@@ -499,7 +506,7 @@ function W(t) {
499
506
  const r = R(t.cache_read_input_tokens);
500
507
  return r !== void 0 && (e.cachedInputTokens = r), Object.keys(e).length > 0 ? e : void 0;
501
508
  }
502
- function St(t, e, n) {
509
+ function $t(t, e, n) {
503
510
  const o = R(t.index) ?? 0, r = t.content_block;
504
511
  if (!w(r)) return [];
505
512
  switch (g(r.type)) {
@@ -552,7 +559,7 @@ function St(t, e, n) {
552
559
  return e.set(o, { kind: "other", thinking: "" }), [];
553
560
  }
554
561
  }
555
- function $t(t, e) {
562
+ function Ct(t, e) {
556
563
  const n = R(t.index) ?? 0, o = t.delta;
557
564
  if (!w(o)) return [];
558
565
  switch (g(o.type)) {
@@ -584,7 +591,7 @@ function $t(t, e) {
584
591
  return [];
585
592
  }
586
593
  }
587
- function Et(t, e) {
594
+ function Ut(t, e) {
588
595
  const n = R(t.index) ?? 0, o = e.get(n);
589
596
  if (!o || o.kind !== "thinking") return [];
590
597
  const r = { type: "thinking", thinking: o.thinking };
@@ -596,7 +603,7 @@ function Et(t, e) {
596
603
  }
597
604
  ];
598
605
  }
599
- function Ct(t) {
606
+ function Ft(t) {
600
607
  const e = {}, n = t.delta;
601
608
  if (w(n)) {
602
609
  const r = g(n.stop_reason);
@@ -605,7 +612,7 @@ function Ct(t) {
605
612
  const o = W(t.usage);
606
613
  return o && (e.usage = o), Object.keys(e).length > 0 ? [e] : [];
607
614
  }
608
- function Ut(t) {
615
+ function Lt(t) {
609
616
  const e = t.error, n = w(e) ? g(e.message) : void 0, o = w(e) ? g(e.type) : void 0;
610
617
  return [
611
618
  {
@@ -616,7 +623,7 @@ function Ut(t) {
616
623
  }
617
624
  ];
618
625
  }
619
- const Ft = {
626
+ const Nt = {
620
627
  id: "anthropic.messages",
621
628
  open() {
622
629
  const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map();
@@ -631,15 +638,15 @@ const Ft = {
631
638
  return r ? [{ usage: r }] : [];
632
639
  }
633
640
  case "content_block_start":
634
- return St(n, t, e);
641
+ return $t(n, t, e);
635
642
  case "content_block_delta":
636
- return $t(n, t);
643
+ return Ct(n, t);
637
644
  case "content_block_stop":
638
- return Et(n, t);
645
+ return Ut(n, t);
639
646
  case "message_delta":
640
- return Ct(n);
647
+ return Ft(n);
641
648
  case "error":
642
- return Ut(n);
649
+ return Lt(n);
643
650
  default:
644
651
  return [];
645
652
  }
@@ -649,7 +656,7 @@ const Ft = {
649
656
  };
650
657
  class U extends Error {
651
658
  constructor(n, o, r, s) {
652
- super(jt(n, o, r, s));
659
+ super(Mt(n, o, r, s));
653
660
  A(this, "status");
654
661
  A(this, "statusText");
655
662
  /** The response body parsed as JSON, or undefined when it was not JSON (an
@@ -660,7 +667,7 @@ class U extends Error {
660
667
  Object.setPrototypeOf(this, U.prototype), this.name = "WireError", this.status = n, this.statusText = o, this.bodyText = r, this.body = s;
661
668
  }
662
669
  }
663
- function Lt(t) {
670
+ function jt(t) {
664
671
  if (typeof t != "object" || t === null) return;
665
672
  const e = t.error;
666
673
  if (typeof e == "string") return e;
@@ -671,16 +678,16 @@ function Lt(t) {
671
678
  const n = t.message;
672
679
  return typeof n == "string" ? n : void 0;
673
680
  }
674
- function jt(t, e, n, o) {
675
- const r = `Model request failed: HTTP ${t}${e ? ` ${e}` : ""}`, s = Lt(o);
681
+ function Mt(t, e, n, o) {
682
+ const r = `Model request failed: HTTP ${t}${e ? ` ${e}` : ""}`, s = jt(o);
676
683
  if (s) return `${r}: ${s}`;
677
684
  const i = n.trim().slice(0, 200);
678
685
  return i ? `${r}: ${i}` : r;
679
686
  }
680
- function Mt(t) {
687
+ function Pt(t) {
681
688
  return typeof t == "object" && t !== null && "ok" in t && "status" in t && "body" in t;
682
689
  }
683
- async function Nt(t) {
690
+ async function Dt(t) {
684
691
  const e = await t.text().catch(() => "");
685
692
  let n;
686
693
  try {
@@ -690,9 +697,9 @@ async function Nt(t) {
690
697
  }
691
698
  return new U(t.status, t.statusText, e, n);
692
699
  }
693
- async function Pt(t) {
694
- if (!Mt(t)) return t;
695
- if (!t.ok) throw await Nt(t);
700
+ async function Wt(t) {
701
+ if (!Pt(t)) return t;
702
+ if (!t.ok) throw await Dt(t);
696
703
  if (!t.body)
697
704
  throw new Error(
698
705
  "The model response has no body to stream. Check that the request set stream: true and that nothing between you and the provider buffered it."
@@ -700,26 +707,26 @@ async function Pt(t) {
700
707
  return t.body;
701
708
  }
702
709
  async function q(t, e, n) {
703
- const o = await Pt(t), r = n.format.open();
710
+ const o = await Wt(t), r = n.format.open();
704
711
  async function* s() {
705
712
  for await (const i of Z(o))
706
713
  for (const a of r.push(i)) yield a;
707
714
  }
708
715
  return wt(s(), e, n);
709
716
  }
710
- function se(t, e, n = {}) {
711
- return q(t, e, { ...n, format: Ot });
717
+ function ue(t, e, n = {}) {
718
+ return q(t, e, { ...n, format: Et });
712
719
  }
713
- function ae(t, e, n = {}) {
714
- return q(t, e, { ...n, format: Ft });
720
+ function ce(t, e, n = {}) {
721
+ return q(t, e, { ...n, format: Nt });
715
722
  }
716
- function ue(t, e, n) {
723
+ function de(t, e, n) {
717
724
  t.upsertTool(e, { state: "output-available", output: n });
718
725
  }
719
- function ce(t, e, n) {
726
+ function le(t, e, n) {
720
727
  t.upsertTool(e, { state: "output-error", errorText: n });
721
728
  }
722
- function de(t) {
729
+ function pe(t) {
723
730
  let e = "";
724
731
  return {
725
732
  appendText(n) {
@@ -745,33 +752,33 @@ const C = [
745
752
  { pattern: "application/xml", kind: "text" },
746
753
  { pattern: "application/x-yaml", kind: "text" },
747
754
  { pattern: "application/yaml", kind: "text" }
748
- ], J = "text/plain", Dt = ["", "application/octet-stream"], F = (t) => t.trim().toLowerCase(), B = (t) => Dt.includes(t === void 0 ? "" : F(t)), Wt = (t) => {
755
+ ], J = "text/plain", qt = ["", "application/octet-stream"], F = (t) => t.trim().toLowerCase(), B = (t) => qt.includes(t === void 0 ? "" : F(t)), Jt = (t) => {
749
756
  if (!t.startsWith(".")) return t;
750
757
  throw new Error(
751
758
  `\`accept\` entry "${t}" is a file extension, and this kit takes media types only. HTML's own accept attribute does take extensions, which is exactly why this throws rather than quietly matching nothing. Use a media type instead -- "text/*" covers source files, "image/*" images, "application/pdf" PDFs, and \`encodableMediaTypes()\` is the full set. You lose nothing by dropping the extension: a file the browser cannot name is decided by decoding its bytes, which is stronger than matching its name.`
752
759
  );
753
- }, qt = (t) => (typeof t == "string" ? t.split(",") : t).map(F).filter((e) => e !== "").map(Wt), M = (t) => {
760
+ }, Bt = (t) => (typeof t == "string" ? t.split(",") : t).map(F).filter((e) => e !== "").map(Jt), j = (t) => {
754
761
  const e = t.indexOf("/");
755
762
  return e === -1 ? [t, ""] : [t.slice(0, e), t.slice(e + 1)];
756
763
  }, S = (t, e) => {
757
- const [n, o] = M(t), [r, s] = M(e);
764
+ const [n, o] = j(t), [r, s] = j(e);
758
765
  return n !== "*" && n !== r ? !1 : o === "*" || o === s;
759
- }, Jt = (t, e) => {
766
+ }, Kt = (t, e) => {
760
767
  if (S(t, e)) return e;
761
768
  if (S(e, t)) return t;
762
769
  };
763
- function le() {
770
+ function fe() {
764
771
  return C.map((t) => t.pattern);
765
772
  }
766
773
  function L(t = {}) {
767
- const e = t.accept === void 0 ? void 0 : qt(t.accept), n = [];
774
+ const e = t.accept === void 0 ? void 0 : Bt(t.accept), n = [];
768
775
  for (const o of C) {
769
776
  if (e === void 0) {
770
777
  n.push({ ...o });
771
778
  continue;
772
779
  }
773
780
  for (const r of e) {
774
- const s = Jt(o.pattern, r);
781
+ const s = Kt(o.pattern, r);
775
782
  s !== void 0 && !n.some((i) => i.pattern === s) && n.push({ pattern: s, kind: o.kind });
776
783
  }
777
784
  }
@@ -793,7 +800,7 @@ function L(t = {}) {
793
800
  }
794
801
  };
795
802
  }
796
- const Bt = L(), Ht = /^data:([^;,]*);base64,([\s\S]*)$/, Kt = /^([a-z][a-z0-9+.-]*):/i, N = (t) => t.map((e) => `"${e}"`).join(", ");
803
+ const Yt = L(), Gt = /^data:([^;,]*);base64,([\s\S]*)$/, Ht = /^([a-z][a-z0-9+.-]*):/i, M = (t) => t.map((e) => `"${e}"`).join(", ");
797
804
  function P(t) {
798
805
  try {
799
806
  const e = atob(t), n = new Uint8Array(e.length);
@@ -803,14 +810,14 @@ function P(t) {
803
810
  return { ok: !1 };
804
811
  }
805
812
  }
806
- const D = (t) => t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/\r/g, "&#13;").replace(/\n/g, "&#10;"), Yt = /<(\/file\s*)>/gi;
807
- function H(t) {
808
- const e = D(t.filename ?? "attachment"), n = D(t.mediaType), o = t.text.replace(Yt, "&lt;$1&gt;");
813
+ const D = (t) => t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/\r/g, "&#13;").replace(/\n/g, "&#10;"), zt = /<(\/file\s*)>/gi;
814
+ function K(t) {
815
+ const e = D(t.filename ?? "attachment"), n = D(t.mediaType), o = t.text.replace(zt, "&lt;$1&gt;");
809
816
  return `<file name="${e}" type="${n}">
810
817
  ${o}
811
818
  </file>`;
812
819
  }
813
- function zt(t, e = Bt) {
820
+ function Xt(t, e = Yt) {
814
821
  var a, c, u;
815
822
  if (t.type === "source-document") return { status: "kit-side" };
816
823
  const n = t.url;
@@ -820,7 +827,7 @@ function zt(t, e = Bt) {
820
827
  reason: "it has no `url`, so there are no bytes and no address to send. Set `url` to a `data:` URI (read the File with FileReader.readAsDataURL before you stage it) or to an https URL the provider can fetch."
821
828
  };
822
829
  let o, r;
823
- const s = Ht.exec(n);
830
+ const s = Gt.exec(n);
824
831
  if (s) {
825
832
  const d = s[1].toLowerCase();
826
833
  r = B(d) ? ((a = t.mediaType) == null ? void 0 : a.toLowerCase()) ?? d : d, o = { type: "base64", mediaType: r, data: s[2], dataUri: n };
@@ -839,7 +846,7 @@ function zt(t, e = Bt) {
839
846
  reason: "its `url` is a `data:` URI that is not base64-encoded with an explicit media type. Both APIs need `data:<media type>;base64,<data>`."
840
847
  };
841
848
  {
842
- const d = (u = Kt.exec(n)) == null ? void 0 : u[1].toLowerCase(), l = d === "blob" ? "a `blob:` URL resolves only inside the browser tab that created it, so a model can never fetch it. Read the File with FileReader.readAsDataURL and stage the `data:` URI instead, or upload it and stage the resulting https URL" : `a "${d ?? n}" URL is not something a provider can fetch. Use a \`data:\` URI or an https URL`;
849
+ const d = (u = Ht.exec(n)) == null ? void 0 : u[1].toLowerCase(), l = d === "blob" ? "a `blob:` URL resolves only inside the browser tab that created it, so a model can never fetch it. Read the File with FileReader.readAsDataURL and stage the `data:` URI instead, or upload it and stage the resulting https URL" : `a "${d ?? n}" URL is not something a provider can fetch. Use a \`data:\` URI or an https URL`;
843
850
  return { status: "unencodable", reason: `its \`url\` is "${n}": ${l}.` };
844
851
  }
845
852
  }
@@ -868,12 +875,12 @@ function zt(t, e = Bt) {
868
875
  if (i.status === "filtered")
869
876
  return {
870
877
  status: "unencodable",
871
- reason: `its media type "${r}" is one this kit can encode, but your \`accept\` filter excludes it. The types you allowed are: ${N(e.types)}. Widen \`accept\` to include it, or stop staging it.`
878
+ reason: `its media type "${r}" is one this kit can encode, but your \`accept\` filter excludes it. The types you allowed are: ${M(e.types)}. Widen \`accept\` to include it, or stop staging it.`
872
879
  };
873
880
  if (i.status === "unsupported")
874
881
  return {
875
882
  status: "unencodable",
876
- reason: `its media type "${r}" is not one either API accepts as message content. Supported: ${N(e.types)}. Extract the content yourself and send it as text, or hand it to the model through a tool.`
883
+ reason: `its media type "${r}" is not one either API accepts as message content. Supported: ${M(e.types)}. Extract the content yourself and send it as text, or hand it to the model through a tool.`
877
884
  };
878
885
  if (i.kind === "text") {
879
886
  if (o.type !== "base64")
@@ -901,21 +908,21 @@ function zt(t, e = Bt) {
901
908
  file: { kind: i.kind, mediaType: r, source: o, filename: t.filename }
902
909
  };
903
910
  }
904
- class $ extends Error {
911
+ class E extends Error {
905
912
  constructor(n, o, r) {
906
913
  super(n);
907
914
  A(this, "messageId");
908
915
  A(this, "partIndex");
909
- Object.setPrototypeOf(this, $.prototype), this.name = "WireEncodeError", this.messageId = o, this.partIndex = r;
916
+ Object.setPrototypeOf(this, E.prototype), this.name = "WireEncodeError", this.messageId = o, this.partIndex = r;
910
917
  }
911
918
  }
912
- const Gt = (t) => t.type === "text", Xt = (t) => t.filter(Gt).map((e) => e.text).join("");
913
- function K(t, e, n, o, r, s) {
914
- const i = zt(t.attachment, r);
919
+ const Qt = (t) => t.type === "text", Vt = (t) => t.filter(Qt).map((e) => e.text).join("");
920
+ function Y(t, e, n, o, r, s) {
921
+ const i = Xt(t.attachment, r);
915
922
  if (i.status === "kit-side") return null;
916
923
  const a = (u) => {
917
924
  if (o === "skip") return null;
918
- throw new $(
925
+ throw new E(
919
926
  `Cannot encode file part ${n} of message "${e}": ${u} Pass { onUnencodableFile: 'skip' } to drop it instead of failing.`,
920
927
  e,
921
928
  n
@@ -925,7 +932,7 @@ function K(t, e, n, o, r, s) {
925
932
  const c = s(i.file);
926
933
  return c.ok ? c.block : a(c.reason);
927
934
  }
928
- const Qt = (t) => t.kind === "text" ? { ok: !0, block: { type: "text", text: H(t) } } : t.kind === "image" ? { ok: !0, block: { type: "image_url", image_url: { url: t.source.type === "base64" ? t.source.dataUri : t.source.url } } } : t.source.type === "remote" ? {
935
+ const Zt = (t) => t.kind === "text" ? { ok: !0, block: { type: "text", text: K(t) } } : t.kind === "image" ? { ok: !0, block: { type: "image_url", image_url: { url: t.source.type === "base64" ? t.source.dataUri : t.source.url } } } : t.source.type === "remote" ? {
929
936
  ok: !1,
930
937
  reason: `it is a PDF at a remote URL ("${t.source.url}"), and a chat-completions \`file\` content part carries only \`file_id\` or \`file_data\` -- this wire has no URL form for a document. Fetch it and stage it as a \`data:\` URI, or upload it through the Files API and send \`file_id\` yourself; fetching it HERE would put I/O in the encoder. The Anthropic wire does take a remote PDF, so toAnthropicMessages accepts this same message.`
931
938
  } : {
@@ -937,43 +944,43 @@ const Qt = (t) => t.kind === "text" ? { ok: !0, block: { type: "text", text: H(t
937
944
  file_data: t.source.dataUri
938
945
  }
939
946
  }
940
- }, Vt = (t) => t.kind === "text" ? { ok: !0, block: { type: "text", text: H(t) } } : {
947
+ }, te = (t) => t.kind === "text" ? { ok: !0, block: { type: "text", text: K(t) } } : {
941
948
  ok: !0,
942
949
  block: {
943
950
  type: t.kind === "image" ? "image" : "document",
944
951
  source: t.source.type === "base64" ? { type: "base64", media_type: t.source.mediaType, data: t.source.data } : { type: "url", url: t.source.url }
945
952
  }
946
- }, Y = (t) => typeof t.toolCallId == "string" && t.toolCallId !== "" && (t.output !== void 0 || t.errorText !== void 0);
947
- function Zt(t) {
953
+ }, G = (t) => typeof t.toolCallId == "string" && t.toolCallId !== "" && (t.output !== void 0 || t.errorText !== void 0);
954
+ function ee(t) {
948
955
  return t.rawInput !== void 0 && t.rawInput !== "" ? t.rawInput : t.input !== void 0 ? JSON.stringify(t.input) : "{}";
949
956
  }
950
- const te = (t) => ({
957
+ const ne = (t) => ({
951
958
  id: t.toolCallId,
952
959
  type: "function",
953
- function: { name: t.type, arguments: Zt(t) }
954
- }), ee = (t) => ({
960
+ function: { name: t.type, arguments: ee(t) }
961
+ }), oe = (t) => ({
955
962
  role: "tool",
956
963
  tool_call_id: t.toolCallId,
957
964
  name: t.type,
958
965
  content: t.errorText ?? JSON.stringify(t.output)
959
- }), ne = (t) => typeof t == "object" && t !== null && !Array.isArray(t);
960
- function oe(t) {
966
+ }), re = (t) => typeof t == "object" && t !== null && !Array.isArray(t);
967
+ function ie(t) {
961
968
  var s;
962
969
  if (((s = t.raw) == null ? void 0 : s.source) !== "openai.reasoning_details") return;
963
970
  const e = t.raw.payload;
964
971
  if (!Array.isArray(e)) return;
965
- const n = e.filter(ne), o = n.filter((i) => i.index === t.index), r = o.length > 0 ? o : n;
972
+ const n = e.filter(re), o = n.filter((i) => i.index === t.index), r = o.length > 0 ? o : n;
966
973
  return r[r.length - 1];
967
974
  }
968
- function re(t) {
969
- const e = oe(t);
975
+ function se(t) {
976
+ const e = ie(t);
970
977
  if (!e) return;
971
978
  if (e.type === "reasoning.encrypted" || typeof e.data == "string") return e;
972
979
  if (typeof t.signature != "string" || t.signature === "") return;
973
980
  const n = typeof e.type == "string" ? e.type : "reasoning.text", r = { type: n, [n === "reasoning.summary" ? "summary" : "text"]: t.text, signature: t.signature };
974
981
  return typeof e.format == "string" && (r.format = e.format), typeof e.id == "string" && (r.id = e.id), e.index !== void 0 && (r.index = e.index), r;
975
982
  }
976
- function pe(t, e = {}) {
983
+ function ge(t, e = {}) {
977
984
  const n = e.reasoning === "include", o = e.onUnencodableFile ?? "throw", r = L({ accept: e.accept }), s = [];
978
985
  for (const i of t) {
979
986
  if (i.role === "user") {
@@ -988,10 +995,10 @@ function pe(t, e = {}) {
988
995
  return;
989
996
  }
990
997
  if (m.type !== "file") return;
991
- const T = K(m, i.id, y, o, r, Qt);
998
+ const T = Y(m, i.id, y, o, r, Zt);
992
999
  T && (k(), l.push(T), h = !0);
993
1000
  }), k(), !h) {
994
- const m = Xt(i.parts);
1001
+ const m = Vt(i.parts);
995
1002
  m !== "" && s.push({ role: "user", content: m });
996
1003
  continue;
997
1004
  }
@@ -1005,9 +1012,9 @@ function pe(t, e = {}) {
1005
1012
  role: "assistant",
1006
1013
  content: a === "" ? null : a,
1007
1014
  ...u.length > 0 ? { reasoning_details: u } : {},
1008
- ...c.length > 0 ? { tool_calls: c.map(te) } : {}
1015
+ ...c.length > 0 ? { tool_calls: c.map(ne) } : {}
1009
1016
  });
1010
- for (const l of c) s.push(ee(l));
1017
+ for (const l of c) s.push(oe(l));
1011
1018
  a = "", c = [], u = [];
1012
1019
  }
1013
1020
  };
@@ -1019,17 +1026,17 @@ function pe(t, e = {}) {
1019
1026
  if (l.type === "reasoning") {
1020
1027
  if (!n) continue;
1021
1028
  c.length > 0 && d();
1022
- const p = re(l);
1029
+ const p = se(l);
1023
1030
  p && u.push(p);
1024
1031
  continue;
1025
1032
  }
1026
- l.type === "tool" && Y(l.tool) && c.push(l.tool);
1033
+ l.type === "tool" && G(l.tool) && c.push(l.tool);
1027
1034
  }
1028
1035
  d();
1029
1036
  }
1030
1037
  return s;
1031
1038
  }
1032
- function fe(t, e = {}) {
1039
+ function he(t, e = {}) {
1033
1040
  const n = e.onUnencodableFile ?? "throw", o = L({ accept: e.accept }), r = [], s = (i) => {
1034
1041
  const a = r[r.length - 1];
1035
1042
  (a == null ? void 0 : a.role) === "user" ? a.content = [...a.content, ...i] : r.push({ role: "user", content: i });
@@ -1043,7 +1050,7 @@ function fe(t, e = {}) {
1043
1050
  return;
1044
1051
  }
1045
1052
  if (l.type !== "file") return;
1046
- const h = K(l, i.id, p, n, o, Vt);
1053
+ const h = Y(l, i.id, p, n, o, te);
1047
1054
  h && d.push(h);
1048
1055
  }), d.length > 0 && s(d);
1049
1056
  continue;
@@ -1056,13 +1063,13 @@ function fe(t, e = {}) {
1056
1063
  switch (d.type) {
1057
1064
  case "reasoning": {
1058
1065
  if (!d.raw)
1059
- throw new $(
1066
+ throw new E(
1060
1067
  `Cannot encode reasoning part ${l} of message "${i.id}": it has no \`raw\` payload, and Anthropic requires a thinking block to be echoed back verbatim. Rebuilding one from text plus signature is the documented 400. Produce reasoning parts with readAnthropicStream, which attaches the provider's own block, and keep \`raw\` when you persist a message.`,
1061
1068
  i.id,
1062
1069
  l
1063
1070
  );
1064
1071
  if (!d.raw.source.startsWith("anthropic."))
1065
- throw new $(
1072
+ throw new E(
1066
1073
  `Cannot encode reasoning part ${l} of message "${i.id}": its \`raw\` came from "${d.raw.source}", not from the Anthropic Messages format. Only a payload tagged \`anthropic.\` can be echoed back verbatim. If you are talking to an Anthropic model through an OpenAI-compatible endpoint, use toOpenAIMessages.`,
1067
1074
  i.id,
1068
1075
  l
@@ -1077,7 +1084,7 @@ function fe(t, e = {}) {
1077
1084
  }
1078
1085
  case "tool": {
1079
1086
  const p = d.tool;
1080
- if (!Y(p)) break;
1087
+ if (!G(p)) break;
1081
1088
  a.push({
1082
1089
  type: "tool_use",
1083
1090
  id: p.toolCallId,
@@ -1103,24 +1110,24 @@ function fe(t, e = {}) {
1103
1110
  return r;
1104
1111
  }
1105
1112
  export {
1106
- $ as WireEncodeError,
1113
+ E as WireEncodeError,
1107
1114
  U as WireError,
1108
- Ft as anthropicMessagesFormat,
1109
- ce as applyToolFailure,
1110
- ue as applyToolOutput,
1111
- de as bufferText,
1115
+ Nt as anthropicMessagesFormat,
1116
+ le as applyToolFailure,
1117
+ de as applyToolOutput,
1118
+ pe as bufferText,
1112
1119
  wt as consumeModelStream,
1113
1120
  yt as createToolCallAccumulator,
1114
- le as encodableMediaTypes,
1121
+ fe as encodableMediaTypes,
1115
1122
  lt as normalizeStopReason,
1116
- Ot as openaiChatFormat,
1117
- ae as readAnthropicStream,
1123
+ Et as openaiChatFormat,
1124
+ ce as readAnthropicStream,
1118
1125
  q as readModelStream,
1119
- se as readOpenAIStream,
1126
+ ue as readOpenAIStream,
1120
1127
  X as readableToAsyncIterable,
1121
1128
  L as resolveMediaPolicy,
1122
1129
  V as sseDataFrames,
1123
1130
  Z as sseJson,
1124
- fe as toAnthropicMessages,
1125
- pe as toOpenAIMessages
1131
+ he as toAnthropicMessages,
1132
+ ge as toOpenAIMessages
1126
1133
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitn.ai/ui",
3
- "version": "0.23.0",
3
+ "version": "0.25.0",
4
4
  "nx": {
5
5
  "name": "ui",
6
6
  "targets": {
@@ -165,16 +165,16 @@
165
165
  "build:subpath-dts": "node scripts/emit-subpath-dts.mjs",
166
166
  "verify:card-validation": "node scripts/gen-card-validation-schemas.mjs --check",
167
167
  "verify:consumer": "node scripts/verify-consumer-sideeffects.mjs",
168
- "verify:dts": "node scripts/verify-dts-boundaries.mjs",
168
+ "verify:dts": "node scripts/verify-dts-boundaries.mjs --self-test && node scripts/verify-dts-boundaries.mjs",
169
169
  "verify:elements-bundle": "node scripts/verify-elements-bundle.mjs --self-test && node scripts/verify-elements-bundle.mjs",
170
170
  "verify:dts:consumer": "node scripts/verify-dts-consumer.mjs",
171
- "verify:generated": "node scripts/verify-generated-sync.mjs",
172
- "verify:quarantine": "node scripts/verify-quarantine.mjs",
171
+ "verify:generated": "node scripts/verify-generated-sync.mjs --self-test && node scripts/verify-generated-sync.mjs",
172
+ "verify:quarantine": "node scripts/verify-quarantine.mjs --self-test && node scripts/verify-quarantine.mjs",
173
173
  "verify:react-wrappers": "node scripts/verify-react-wrappers.mjs --self-test && node scripts/verify-react-wrappers.mjs",
174
174
  "verify:scaffold": "node scripts/verify-scaffold-compiles.mjs",
175
- "verify:schemas": "node scripts/verify-schemas-exported.mjs",
175
+ "verify:schemas": "node scripts/verify-schemas-exported.mjs --self-test && node scripts/verify-schemas-exported.mjs",
176
176
  "verify:shader-lazy": "node scripts/verify-shader-lazy.mjs --self-test && node scripts/verify-shader-lazy.mjs",
177
- "verify:solid-coverage": "node scripts/verify-solid-coverage.mjs",
177
+ "verify:solid-coverage": "node scripts/verify-solid-coverage.mjs --self-test && node scripts/verify-solid-coverage.mjs",
178
178
  "verify:tool-schemas": "node scripts/verify-tool-schemas.mjs",
179
179
  "verify:ssr": "node scripts/verify-ssr-imports.mjs && node scripts/verify-ssr-render.mjs",
180
180
  "verify:ssr:imports": "node scripts/verify-ssr-imports.mjs",