@absolutejs/absolute 0.19.0-beta.364 → 0.19.0-beta.366

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 (60) hide show
  1. package/dist/ai/index.js +108 -2
  2. package/dist/ai/index.js.map +7 -6
  3. package/dist/ai-client/angular/ai/index.js +102 -0
  4. package/dist/ai-client/react/ai/index.js +176 -0
  5. package/dist/ai-client/vue/ai/index.js +172 -0
  6. package/dist/angular/ai/index.js +103 -1
  7. package/dist/angular/ai/index.js.map +5 -3
  8. package/dist/angular/browser.js +8 -12
  9. package/dist/angular/browser.js.map +4 -4
  10. package/dist/angular/index.js +4420 -4465
  11. package/dist/angular/index.js.map +8 -8
  12. package/dist/build.js +578 -23
  13. package/dist/build.js.map +10 -4
  14. package/dist/client/index.js +44 -45
  15. package/dist/client/index.js.map +4 -4
  16. package/dist/index.js +4340 -4363
  17. package/dist/index.js.map +15 -14
  18. package/dist/react/ai/index.js +177 -1
  19. package/dist/react/ai/index.js.map +7 -3
  20. package/dist/react/components/browser/index.js +18 -6
  21. package/dist/react/components/index.js +35 -16
  22. package/dist/react/components/index.js.map +6 -5
  23. package/dist/react/index.js +1774 -1803
  24. package/dist/react/index.js.map +12 -12
  25. package/dist/react/server.js +574 -3
  26. package/dist/react/server.js.map +11 -4
  27. package/dist/src/ai/client/ragClient.d.ts +16 -0
  28. package/dist/src/ai/index.d.ts +2 -1
  29. package/dist/src/ai/rag/chat.d.ts +41 -5
  30. package/dist/src/ai/rag/index.d.ts +1 -1
  31. package/dist/src/ai/rag/types.d.ts +1 -1
  32. package/dist/src/angular/ai/index.d.ts +1 -0
  33. package/dist/src/angular/ai/rag-client.service.d.ts +11 -0
  34. package/dist/src/core/pageHandlers.d.ts +0 -1
  35. package/dist/src/react/ai/index.d.ts +3 -0
  36. package/dist/src/react/ai/useRAGIngest.d.ts +8 -0
  37. package/dist/src/react/ai/useRAGSearch.d.ts +9 -0
  38. package/dist/src/react/ai/useRAGStatus.d.ts +9 -0
  39. package/dist/src/react/index.d.ts +1 -1
  40. package/dist/src/react/streamingSlotCollection.d.ts +9 -0
  41. package/dist/src/svelte/ai/createRAGIngest.d.ts +7 -0
  42. package/dist/src/svelte/ai/createRAGSearch.d.ts +7 -0
  43. package/dist/src/svelte/ai/createRAGStatus.d.ts +8 -0
  44. package/dist/src/svelte/ai/index.d.ts +3 -0
  45. package/dist/src/vue/ai/index.d.ts +3 -0
  46. package/dist/src/vue/ai/useRAGIngest.d.ts +7 -0
  47. package/dist/src/vue/ai/useRAGSearch.d.ts +21 -0
  48. package/dist/src/vue/ai/useRAGStatus.d.ts +8 -0
  49. package/dist/svelte/ai/index.js +171 -1
  50. package/dist/svelte/ai/index.js.map +8 -4
  51. package/dist/svelte/index.js +1881 -1926
  52. package/dist/svelte/index.js.map +8 -8
  53. package/dist/types/ai.d.ts +11 -0
  54. package/dist/vue/ai/index.js +173 -1
  55. package/dist/vue/ai/index.js.map +7 -3
  56. package/dist/vue/components/index.js +8 -12
  57. package/dist/vue/components/index.js.map +5 -5
  58. package/dist/vue/index.js +1929 -1976
  59. package/dist/vue/index.js.map +8 -8
  60. package/package.json +1 -1
@@ -665,10 +665,112 @@ class AIStreamService {
665
665
  AIStreamService = __legacyDecorateClassTS([
666
666
  Injectable({ providedIn: "root" })
667
667
  ], AIStreamService);
668
+ // src/angular/ai/rag-client.service.ts
669
+ import { Injectable as Injectable2 } from "@angular/core";
670
+
671
+ // src/ai/client/ragClient.ts
672
+ var jsonHeaders = {
673
+ "Content-Type": "application/json"
674
+ };
675
+ var normalizeBasePath = (path) => path.endsWith("/") ? path.slice(0, -1) : path;
676
+ var parseJson = async (response) => {
677
+ const payload = await response.json();
678
+ return payload;
679
+ };
680
+ var toErrorMessage = async (response) => {
681
+ try {
682
+ const payload = await response.json();
683
+ if (typeof payload.error === "string" && payload.error) {
684
+ return payload.error;
685
+ }
686
+ } catch {}
687
+ return `Request failed with status ${response.status}`;
688
+ };
689
+ var createRAGClient = (options) => {
690
+ const basePath = normalizeBasePath(options.path);
691
+ const fetchImpl = options.fetch ?? fetch;
692
+ return {
693
+ async ingest(chunks) {
694
+ const response = await fetchImpl(`${basePath}/ingest`, {
695
+ body: JSON.stringify({ chunks }),
696
+ headers: jsonHeaders,
697
+ method: "POST"
698
+ });
699
+ if (!response.ok) {
700
+ return {
701
+ ok: false,
702
+ error: await toErrorMessage(response)
703
+ };
704
+ }
705
+ return parseJson(response);
706
+ },
707
+ async search(input) {
708
+ const response = await fetchImpl(`${basePath}/search`, {
709
+ body: JSON.stringify(input),
710
+ headers: jsonHeaders,
711
+ method: "POST"
712
+ });
713
+ if (!response.ok) {
714
+ throw new Error(await toErrorMessage(response));
715
+ }
716
+ const payload = await parseJson(response);
717
+ if (!payload.ok) {
718
+ throw new Error(payload.error ?? "RAG search failed");
719
+ }
720
+ return payload.results ?? [];
721
+ },
722
+ async status() {
723
+ const response = await fetchImpl(`${basePath}/status`);
724
+ if (!response.ok) {
725
+ throw new Error(await toErrorMessage(response));
726
+ }
727
+ return parseJson(response);
728
+ },
729
+ async clearIndex() {
730
+ const response = await fetchImpl(`${basePath}/index`, {
731
+ method: "DELETE"
732
+ });
733
+ if (!response.ok) {
734
+ throw new Error(await toErrorMessage(response));
735
+ }
736
+ return parseJson(response);
737
+ }
738
+ };
739
+ };
740
+
741
+ // src/angular/ai/rag-client.service.ts
742
+ class RAGClientService {
743
+ clients = new Map;
744
+ client(path) {
745
+ const existing = this.clients.get(path);
746
+ if (existing) {
747
+ return existing;
748
+ }
749
+ const created = createRAGClient({ path });
750
+ this.clients.set(path, created);
751
+ return created;
752
+ }
753
+ ingest(path, chunks) {
754
+ return this.client(path).ingest(chunks);
755
+ }
756
+ search(path, input) {
757
+ return this.client(path).search(input);
758
+ }
759
+ status(path) {
760
+ return this.client(path).status();
761
+ }
762
+ clearIndex(path) {
763
+ return this.client(path).clearIndex();
764
+ }
765
+ }
766
+ RAGClientService = __legacyDecorateClassTS([
767
+ Injectable2({ providedIn: "root" })
768
+ ], RAGClientService);
668
769
  // src/angular/ai/ai-rag-stream.service.ts
669
770
  class RAGStreamService extends AIStreamService {
670
771
  }
671
772
  export {
672
773
  RAGStreamService,
774
+ RAGClientService,
673
775
  AIStreamService
674
776
  };
@@ -629,10 +629,186 @@ var useAIStream = (path, conversationId) => {
629
629
  send
630
630
  };
631
631
  };
632
+ // src/react/ai/useRAGIngest.ts
633
+ import { useCallback as useCallback2, useMemo, useState } from "react";
634
+
635
+ // src/ai/client/ragClient.ts
636
+ var jsonHeaders = {
637
+ "Content-Type": "application/json"
638
+ };
639
+ var normalizeBasePath = (path) => path.endsWith("/") ? path.slice(0, -1) : path;
640
+ var parseJson = async (response) => {
641
+ const payload = await response.json();
642
+ return payload;
643
+ };
644
+ var toErrorMessage = async (response) => {
645
+ try {
646
+ const payload = await response.json();
647
+ if (typeof payload.error === "string" && payload.error) {
648
+ return payload.error;
649
+ }
650
+ } catch {}
651
+ return `Request failed with status ${response.status}`;
652
+ };
653
+ var createRAGClient = (options) => {
654
+ const basePath = normalizeBasePath(options.path);
655
+ const fetchImpl = options.fetch ?? fetch;
656
+ return {
657
+ async ingest(chunks) {
658
+ const response = await fetchImpl(`${basePath}/ingest`, {
659
+ body: JSON.stringify({ chunks }),
660
+ headers: jsonHeaders,
661
+ method: "POST"
662
+ });
663
+ if (!response.ok) {
664
+ return {
665
+ ok: false,
666
+ error: await toErrorMessage(response)
667
+ };
668
+ }
669
+ return parseJson(response);
670
+ },
671
+ async search(input) {
672
+ const response = await fetchImpl(`${basePath}/search`, {
673
+ body: JSON.stringify(input),
674
+ headers: jsonHeaders,
675
+ method: "POST"
676
+ });
677
+ if (!response.ok) {
678
+ throw new Error(await toErrorMessage(response));
679
+ }
680
+ const payload = await parseJson(response);
681
+ if (!payload.ok) {
682
+ throw new Error(payload.error ?? "RAG search failed");
683
+ }
684
+ return payload.results ?? [];
685
+ },
686
+ async status() {
687
+ const response = await fetchImpl(`${basePath}/status`);
688
+ if (!response.ok) {
689
+ throw new Error(await toErrorMessage(response));
690
+ }
691
+ return parseJson(response);
692
+ },
693
+ async clearIndex() {
694
+ const response = await fetchImpl(`${basePath}/index`, {
695
+ method: "DELETE"
696
+ });
697
+ if (!response.ok) {
698
+ throw new Error(await toErrorMessage(response));
699
+ }
700
+ return parseJson(response);
701
+ }
702
+ };
703
+ };
704
+
705
+ // src/react/ai/useRAGIngest.ts
706
+ var useRAGIngest = (path) => {
707
+ const client = useMemo(() => createRAGClient({ path }), [path]);
708
+ const [error, setError] = useState(null);
709
+ const [isIngesting, setIsIngesting] = useState(false);
710
+ const [lastIngestCount, setLastIngestCount] = useState(null);
711
+ const ingest = useCallback2(async (chunks) => {
712
+ setIsIngesting(true);
713
+ setError(null);
714
+ try {
715
+ const response = await client.ingest(chunks);
716
+ if (!response.ok) {
717
+ throw new Error(response.error ?? "RAG ingest failed");
718
+ }
719
+ setLastIngestCount(response.count ?? chunks.length);
720
+ return response;
721
+ } catch (caught) {
722
+ const message = caught instanceof Error ? caught.message : String(caught);
723
+ setError(message);
724
+ throw caught;
725
+ } finally {
726
+ setIsIngesting(false);
727
+ }
728
+ }, [client]);
729
+ return {
730
+ error,
731
+ ingest,
732
+ isIngesting,
733
+ lastIngestCount
734
+ };
735
+ };
736
+ // src/react/ai/useRAGSearch.ts
737
+ import { useCallback as useCallback3, useMemo as useMemo2, useState as useState2 } from "react";
738
+ var useRAGSearch = (path) => {
739
+ const client = useMemo2(() => createRAGClient({ path }), [path]);
740
+ const [results, setResults] = useState2([]);
741
+ const [error, setError] = useState2(null);
742
+ const [isSearching, setIsSearching] = useState2(false);
743
+ const search = useCallback3(async (input) => {
744
+ setIsSearching(true);
745
+ setError(null);
746
+ try {
747
+ const nextResults = await client.search(input);
748
+ setResults(nextResults);
749
+ return nextResults;
750
+ } catch (caught) {
751
+ const message = caught instanceof Error ? caught.message : String(caught);
752
+ setError(message);
753
+ throw caught;
754
+ } finally {
755
+ setIsSearching(false);
756
+ }
757
+ }, [client]);
758
+ return {
759
+ error,
760
+ isSearching,
761
+ results,
762
+ search,
763
+ setResults
764
+ };
765
+ };
766
+ // src/react/ai/useRAGStatus.ts
767
+ import { useCallback as useCallback4, useEffect as useEffect3, useMemo as useMemo3, useState as useState3 } from "react";
768
+ var useRAGStatus = (path, autoLoad = true) => {
769
+ const client = useMemo3(() => createRAGClient({ path }), [path]);
770
+ const [status, setStatus] = useState3();
771
+ const [capabilities, setCapabilities] = useState3();
772
+ const [error, setError] = useState3(null);
773
+ const [isLoading, setIsLoading] = useState3(autoLoad);
774
+ const refresh = useCallback4(async () => {
775
+ setIsLoading(true);
776
+ setError(null);
777
+ try {
778
+ const response = await client.status();
779
+ setStatus(response.status);
780
+ setCapabilities(response.capabilities);
781
+ return response;
782
+ } catch (caught) {
783
+ const message = caught instanceof Error ? caught.message : String(caught);
784
+ setError(message);
785
+ throw caught;
786
+ } finally {
787
+ setIsLoading(false);
788
+ }
789
+ }, [client]);
790
+ useEffect3(() => {
791
+ if (!autoLoad) {
792
+ setIsLoading(false);
793
+ return;
794
+ }
795
+ refresh();
796
+ }, [autoLoad, refresh]);
797
+ return {
798
+ capabilities,
799
+ error,
800
+ isLoading,
801
+ refresh,
802
+ status
803
+ };
804
+ };
632
805
  // src/react/ai/useRAGStream.ts
633
806
  var useRAGStream = useAIStream;
634
807
  export {
635
808
  useRAGStream,
809
+ useRAGStatus,
810
+ useRAGSearch,
811
+ useRAGIngest,
636
812
  useAIStream,
637
813
  AIStreamProvider
638
814
  };
@@ -590,10 +590,182 @@ var useAIStream = (path, conversationId) => {
590
590
  send
591
591
  };
592
592
  };
593
+ // src/vue/ai/useRAGIngest.ts
594
+ import { ref as ref2 } from "vue";
595
+
596
+ // src/ai/client/ragClient.ts
597
+ var jsonHeaders = {
598
+ "Content-Type": "application/json"
599
+ };
600
+ var normalizeBasePath = (path) => path.endsWith("/") ? path.slice(0, -1) : path;
601
+ var parseJson = async (response) => {
602
+ const payload = await response.json();
603
+ return payload;
604
+ };
605
+ var toErrorMessage = async (response) => {
606
+ try {
607
+ const payload = await response.json();
608
+ if (typeof payload.error === "string" && payload.error) {
609
+ return payload.error;
610
+ }
611
+ } catch {}
612
+ return `Request failed with status ${response.status}`;
613
+ };
614
+ var createRAGClient = (options) => {
615
+ const basePath = normalizeBasePath(options.path);
616
+ const fetchImpl = options.fetch ?? fetch;
617
+ return {
618
+ async ingest(chunks) {
619
+ const response = await fetchImpl(`${basePath}/ingest`, {
620
+ body: JSON.stringify({ chunks }),
621
+ headers: jsonHeaders,
622
+ method: "POST"
623
+ });
624
+ if (!response.ok) {
625
+ return {
626
+ ok: false,
627
+ error: await toErrorMessage(response)
628
+ };
629
+ }
630
+ return parseJson(response);
631
+ },
632
+ async search(input) {
633
+ const response = await fetchImpl(`${basePath}/search`, {
634
+ body: JSON.stringify(input),
635
+ headers: jsonHeaders,
636
+ method: "POST"
637
+ });
638
+ if (!response.ok) {
639
+ throw new Error(await toErrorMessage(response));
640
+ }
641
+ const payload = await parseJson(response);
642
+ if (!payload.ok) {
643
+ throw new Error(payload.error ?? "RAG search failed");
644
+ }
645
+ return payload.results ?? [];
646
+ },
647
+ async status() {
648
+ const response = await fetchImpl(`${basePath}/status`);
649
+ if (!response.ok) {
650
+ throw new Error(await toErrorMessage(response));
651
+ }
652
+ return parseJson(response);
653
+ },
654
+ async clearIndex() {
655
+ const response = await fetchImpl(`${basePath}/index`, {
656
+ method: "DELETE"
657
+ });
658
+ if (!response.ok) {
659
+ throw new Error(await toErrorMessage(response));
660
+ }
661
+ return parseJson(response);
662
+ }
663
+ };
664
+ };
665
+
666
+ // src/vue/ai/useRAGIngest.ts
667
+ var useRAGIngest = (path) => {
668
+ const client = createRAGClient({ path });
669
+ const error = ref2(null);
670
+ const isIngesting = ref2(false);
671
+ const lastIngestCount = ref2(null);
672
+ const ingest = async (chunks) => {
673
+ isIngesting.value = true;
674
+ error.value = null;
675
+ try {
676
+ const response = await client.ingest(chunks);
677
+ if (!response.ok) {
678
+ throw new Error(response.error ?? "RAG ingest failed");
679
+ }
680
+ lastIngestCount.value = response.count ?? chunks.length;
681
+ return response;
682
+ } catch (caught) {
683
+ error.value = caught instanceof Error ? caught.message : String(caught);
684
+ throw caught;
685
+ } finally {
686
+ isIngesting.value = false;
687
+ }
688
+ };
689
+ return {
690
+ error,
691
+ ingest,
692
+ isIngesting,
693
+ lastIngestCount
694
+ };
695
+ };
696
+ // src/vue/ai/useRAGSearch.ts
697
+ import { ref as ref3 } from "vue";
698
+ var useRAGSearch = (path) => {
699
+ const client = createRAGClient({ path });
700
+ const results = ref3([]);
701
+ const error = ref3(null);
702
+ const isSearching = ref3(false);
703
+ const search = async (input) => {
704
+ isSearching.value = true;
705
+ error.value = null;
706
+ try {
707
+ const nextResults = await client.search(input);
708
+ results.value = nextResults;
709
+ return nextResults;
710
+ } catch (caught) {
711
+ error.value = caught instanceof Error ? caught.message : String(caught);
712
+ throw caught;
713
+ } finally {
714
+ isSearching.value = false;
715
+ }
716
+ };
717
+ return {
718
+ error,
719
+ isSearching,
720
+ results,
721
+ search
722
+ };
723
+ };
724
+ // src/vue/ai/useRAGStatus.ts
725
+ import { onMounted, ref as ref4 } from "vue";
726
+ var useRAGStatus = (path, autoLoad = true) => {
727
+ const client = createRAGClient({ path });
728
+ const status = ref4();
729
+ const capabilities = ref4();
730
+ const error = ref4(null);
731
+ const isLoading = ref4(autoLoad);
732
+ const refresh = async () => {
733
+ isLoading.value = true;
734
+ error.value = null;
735
+ try {
736
+ const response = await client.status();
737
+ status.value = response.status;
738
+ capabilities.value = response.capabilities;
739
+ return response;
740
+ } catch (caught) {
741
+ error.value = caught instanceof Error ? caught.message : String(caught);
742
+ throw caught;
743
+ } finally {
744
+ isLoading.value = false;
745
+ }
746
+ };
747
+ onMounted(() => {
748
+ if (!autoLoad) {
749
+ isLoading.value = false;
750
+ return;
751
+ }
752
+ refresh();
753
+ });
754
+ return {
755
+ capabilities,
756
+ error,
757
+ isLoading,
758
+ refresh,
759
+ status
760
+ };
761
+ };
593
762
  // src/vue/ai/useRAGStream.ts
594
763
  var useRAGStream = useAIStream;
595
764
  export {
596
765
  useRAGStream,
766
+ useRAGStatus,
767
+ useRAGSearch,
768
+ useRAGIngest,
597
769
  useAIStream,
598
770
  AIStreamKey
599
771
  };
@@ -802,13 +802,115 @@ class AIStreamService {
802
802
  AIStreamService = __legacyDecorateClassTS([
803
803
  Injectable({ providedIn: "root" })
804
804
  ], AIStreamService);
805
+ // src/angular/ai/rag-client.service.ts
806
+ import { Injectable as Injectable2 } from "@angular/core";
807
+
808
+ // src/ai/client/ragClient.ts
809
+ var jsonHeaders = {
810
+ "Content-Type": "application/json"
811
+ };
812
+ var normalizeBasePath = (path) => path.endsWith("/") ? path.slice(0, -1) : path;
813
+ var parseJson = async (response) => {
814
+ const payload = await response.json();
815
+ return payload;
816
+ };
817
+ var toErrorMessage = async (response) => {
818
+ try {
819
+ const payload = await response.json();
820
+ if (typeof payload.error === "string" && payload.error) {
821
+ return payload.error;
822
+ }
823
+ } catch {}
824
+ return `Request failed with status ${response.status}`;
825
+ };
826
+ var createRAGClient = (options) => {
827
+ const basePath = normalizeBasePath(options.path);
828
+ const fetchImpl = options.fetch ?? fetch;
829
+ return {
830
+ async ingest(chunks) {
831
+ const response = await fetchImpl(`${basePath}/ingest`, {
832
+ body: JSON.stringify({ chunks }),
833
+ headers: jsonHeaders,
834
+ method: "POST"
835
+ });
836
+ if (!response.ok) {
837
+ return {
838
+ ok: false,
839
+ error: await toErrorMessage(response)
840
+ };
841
+ }
842
+ return parseJson(response);
843
+ },
844
+ async search(input) {
845
+ const response = await fetchImpl(`${basePath}/search`, {
846
+ body: JSON.stringify(input),
847
+ headers: jsonHeaders,
848
+ method: "POST"
849
+ });
850
+ if (!response.ok) {
851
+ throw new Error(await toErrorMessage(response));
852
+ }
853
+ const payload = await parseJson(response);
854
+ if (!payload.ok) {
855
+ throw new Error(payload.error ?? "RAG search failed");
856
+ }
857
+ return payload.results ?? [];
858
+ },
859
+ async status() {
860
+ const response = await fetchImpl(`${basePath}/status`);
861
+ if (!response.ok) {
862
+ throw new Error(await toErrorMessage(response));
863
+ }
864
+ return parseJson(response);
865
+ },
866
+ async clearIndex() {
867
+ const response = await fetchImpl(`${basePath}/index`, {
868
+ method: "DELETE"
869
+ });
870
+ if (!response.ok) {
871
+ throw new Error(await toErrorMessage(response));
872
+ }
873
+ return parseJson(response);
874
+ }
875
+ };
876
+ };
877
+
878
+ // src/angular/ai/rag-client.service.ts
879
+ class RAGClientService {
880
+ clients = new Map;
881
+ client(path) {
882
+ const existing = this.clients.get(path);
883
+ if (existing) {
884
+ return existing;
885
+ }
886
+ const created = createRAGClient({ path });
887
+ this.clients.set(path, created);
888
+ return created;
889
+ }
890
+ ingest(path, chunks) {
891
+ return this.client(path).ingest(chunks);
892
+ }
893
+ search(path, input) {
894
+ return this.client(path).search(input);
895
+ }
896
+ status(path) {
897
+ return this.client(path).status();
898
+ }
899
+ clearIndex(path) {
900
+ return this.client(path).clearIndex();
901
+ }
902
+ }
903
+ RAGClientService = __legacyDecorateClassTS([
904
+ Injectable2({ providedIn: "root" })
905
+ ], RAGClientService);
805
906
  // src/angular/ai/ai-rag-stream.service.ts
806
907
  class RAGStreamService extends AIStreamService {
807
908
  }
808
909
  export {
809
910
  RAGStreamService,
911
+ RAGClientService,
810
912
  AIStreamService
811
913
  };
812
914
 
813
- //# debugId=495F18A29C25C48164756E2164756E21
915
+ //# debugId=B9F2B1CC9F729DCA64756E2164756E21
814
916
  //# sourceMappingURL=index.js.map