@copilotkit/react-core 0.8.0-alpha.4 → 0.8.0-alpha.6

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 (77) hide show
  1. package/.turbo/turbo-build.log +85 -71
  2. package/CHANGELOG.md +12 -0
  3. package/dist/components/copilot-provider.d.ts +1 -0
  4. package/dist/components/copilot-provider.mjs +442 -5
  5. package/dist/components/copilot-provider.mjs.map +1 -1
  6. package/dist/components/index.d.ts +1 -0
  7. package/dist/components/index.mjs +442 -6
  8. package/dist/components/index.mjs.map +1 -1
  9. package/dist/context/copilot-context.d.ts +4 -0
  10. package/dist/context/copilot-context.mjs +67 -3
  11. package/dist/context/copilot-context.mjs.map +1 -1
  12. package/dist/context/index.d.ts +1 -0
  13. package/dist/context/index.mjs +67 -4
  14. package/dist/context/index.mjs.map +1 -1
  15. package/dist/hooks/index.d.ts +2 -0
  16. package/dist/hooks/index.mjs +220 -7
  17. package/dist/hooks/index.mjs.map +1 -1
  18. package/dist/hooks/use-copilot-chat.mjs +159 -4
  19. package/dist/hooks/use-copilot-chat.mjs.map +1 -1
  20. package/dist/hooks/use-flat-category-store.d.ts +9 -0
  21. package/dist/hooks/use-flat-category-store.mjs +75 -0
  22. package/dist/hooks/use-flat-category-store.mjs.map +1 -0
  23. package/dist/hooks/use-make-copilot-actionable.mjs +88 -4
  24. package/dist/hooks/use-make-copilot-actionable.mjs.map +1 -1
  25. package/dist/hooks/use-make-copilot-document-readable.d.ts +12 -0
  26. package/dist/hooks/use-make-copilot-document-readable.mjs +78 -0
  27. package/dist/hooks/use-make-copilot-document-readable.mjs.map +1 -0
  28. package/dist/hooks/use-make-copilot-readable.mjs +77 -4
  29. package/dist/hooks/use-make-copilot-readable.mjs.map +1 -1
  30. package/dist/hooks/use-tree.mjs +159 -3
  31. package/dist/hooks/use-tree.mjs.map +1 -1
  32. package/dist/index.d.ts +2 -0
  33. package/dist/index.mjs +589 -12
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/types/annotated-function.mjs +0 -2
  36. package/dist/types/annotated-function.mjs.map +1 -1
  37. package/dist/types/document-pointer.d.ts +9 -0
  38. package/dist/types/document-pointer.mjs +1 -0
  39. package/dist/types/document-pointer.mjs.map +1 -0
  40. package/dist/types/index.d.ts +1 -0
  41. package/dist/types/index.mjs +0 -2
  42. package/dist/types/index.mjs.map +1 -1
  43. package/dist/utils/utils.mjs +0 -2
  44. package/dist/utils/utils.mjs.map +1 -1
  45. package/dist/utils/utils.test.mjs +0 -1
  46. package/dist/utils/utils.test.mjs.map +1 -1
  47. package/package.json +3 -3
  48. package/src/components/copilot-provider.tsx +31 -1
  49. package/src/context/copilot-context.tsx +13 -0
  50. package/src/hooks/index.ts +1 -0
  51. package/src/hooks/use-copilot-chat.ts +0 -3
  52. package/src/hooks/use-flat-category-store.ts +114 -0
  53. package/src/hooks/use-make-copilot-document-readable.ts +32 -0
  54. package/src/types/document-pointer.ts +7 -0
  55. package/src/types/index.ts +1 -0
  56. package/dist/chunk-3BOHSSKR.mjs +0 -141
  57. package/dist/chunk-3BOHSSKR.mjs.map +0 -1
  58. package/dist/chunk-6VD2ABXH.mjs +0 -82
  59. package/dist/chunk-6VD2ABXH.mjs.map +0 -1
  60. package/dist/chunk-BVQRDAR7.mjs +0 -3
  61. package/dist/chunk-BVQRDAR7.mjs.map +0 -1
  62. package/dist/chunk-DFQJR3H5.mjs +0 -120
  63. package/dist/chunk-DFQJR3H5.mjs.map +0 -1
  64. package/dist/chunk-EFZPSZWO.mjs +0 -3
  65. package/dist/chunk-EFZPSZWO.mjs.map +0 -1
  66. package/dist/chunk-JD7BAH7U.mjs +0 -3
  67. package/dist/chunk-JD7BAH7U.mjs.map +0 -1
  68. package/dist/chunk-JLQULZT4.mjs +0 -19
  69. package/dist/chunk-JLQULZT4.mjs.map +0 -1
  70. package/dist/chunk-MRXNTQOX.mjs +0 -55
  71. package/dist/chunk-MRXNTQOX.mjs.map +0 -1
  72. package/dist/chunk-W6NBODX5.mjs +0 -30
  73. package/dist/chunk-W6NBODX5.mjs.map +0 -1
  74. package/dist/chunk-YPSGKPDA.mjs +0 -3
  75. package/dist/chunk-YPSGKPDA.mjs.map +0 -1
  76. package/dist/chunk-ZKO7HCZS.mjs +0 -40
  77. package/dist/chunk-ZKO7HCZS.mjs.map +0 -1
@@ -1,5 +1,89 @@
1
- export { useMakeCopilotActionable } from '../chunk-W6NBODX5.mjs';
2
- import '../chunk-ZKO7HCZS.mjs';
3
- import '../chunk-MRXNTQOX.mjs';
4
- //# sourceMappingURL=out.js.map
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+
22
+ // src/hooks/use-make-copilot-actionable.ts
23
+ import { useRef, useContext, useEffect, useMemo } from "react";
24
+
25
+ // src/context/copilot-context.tsx
26
+ import React from "react";
27
+ "use client";
28
+ var emptyCopilotContext = {
29
+ entryPoints: {},
30
+ setEntryPoint: () => {
31
+ },
32
+ removeEntryPoint: () => {
33
+ },
34
+ getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),
35
+ getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
36
+ })),
37
+ getContextString: () => returnAndThrowInDebug(""),
38
+ addContext: () => "",
39
+ removeContext: () => {
40
+ },
41
+ getDocumentsContext: () => returnAndThrowInDebug([]),
42
+ addDocumentContext: () => returnAndThrowInDebug(""),
43
+ removeDocumentContext: () => {
44
+ },
45
+ copilotApiConfig: new class {
46
+ get chatApiEndpoint() {
47
+ throw new Error(
48
+ "Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!"
49
+ );
50
+ }
51
+ }()
52
+ };
53
+ var CopilotContext = React.createContext(emptyCopilotContext);
54
+ function returnAndThrowInDebug(value) {
55
+ throw new Error(
56
+ "Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!"
57
+ );
58
+ return value;
59
+ }
60
+
61
+ // src/hooks/use-make-copilot-actionable.ts
62
+ import { nanoid } from "nanoid";
63
+ "use client";
64
+ function useMakeCopilotActionable(annotatedFunction, dependencies) {
65
+ const idRef = useRef(nanoid());
66
+ const { setEntryPoint, removeEntryPoint } = useContext(CopilotContext);
67
+ const memoizedAnnotatedFunction = useMemo(
68
+ () => ({
69
+ name: annotatedFunction.name,
70
+ description: annotatedFunction.description,
71
+ argumentAnnotations: annotatedFunction.argumentAnnotations,
72
+ implementation: annotatedFunction.implementation
73
+ }),
74
+ dependencies
75
+ );
76
+ useEffect(() => {
77
+ setEntryPoint(
78
+ idRef.current,
79
+ memoizedAnnotatedFunction
80
+ );
81
+ return () => {
82
+ removeEntryPoint(idRef.current);
83
+ };
84
+ }, [memoizedAnnotatedFunction, setEntryPoint, removeEntryPoint]);
85
+ }
86
+ export {
87
+ useMakeCopilotActionable
88
+ };
5
89
  //# sourceMappingURL=use-make-copilot-actionable.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":["../../src/hooks/use-make-copilot-actionable.ts","../../src/context/copilot-context.tsx"],"sourcesContent":["\"use client\";\n\nimport { useRef, useContext, useEffect, useMemo } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { AnnotatedFunction } from \"../types/annotated-function\";\nimport { nanoid } from \"nanoid\";\n\nexport function useMakeCopilotActionable<ActionInput extends any[]>(\n annotatedFunction: AnnotatedFunction<ActionInput>,\n dependencies: any[]\n) {\n const idRef = useRef(nanoid()); // generate a unique id\n const { setEntryPoint, removeEntryPoint } = useContext(CopilotContext);\n\n const memoizedAnnotatedFunction: AnnotatedFunction<ActionInput> = useMemo(\n () => ({\n name: annotatedFunction.name,\n description: annotatedFunction.description,\n argumentAnnotations: annotatedFunction.argumentAnnotations,\n implementation: annotatedFunction.implementation,\n }),\n dependencies\n );\n\n useEffect(() => {\n setEntryPoint(\n idRef.current,\n memoizedAnnotatedFunction as AnnotatedFunction<any[]>\n );\n\n return () => {\n removeEntryPoint(idRef.current);\n };\n }, [memoizedAnnotatedFunction, setEntryPoint, removeEntryPoint]);\n}\n","\"use client\";\n\nimport { FunctionCallHandler } from \"ai\";\nimport React from \"react\";\nimport { TreeNodeId } from \"../hooks/use-tree\";\nimport { AnnotatedFunction } from \"../types/annotated-function\";\nimport { ChatCompletionCreateParams } from \"openai/resources/chat\";\nimport { DocumentPointer } from \"../types\";\n\nexport interface CopilotApiConfig {\n chatApiEndpoint: string;\n}\n\nexport function copilotApiConfigExtrapolator(config: CopilotApiConfig) {\n return {\n get chatApiEndpoint(): string {\n return `${config.chatApiEndpoint}`;\n },\n };\n}\n\nexport interface CopilotContextParams {\n // function-calling\n entryPoints: Record<string, AnnotatedFunction<any[]>>;\n setEntryPoint: (id: string, entryPoint: AnnotatedFunction<any[]>) => void;\n removeEntryPoint: (id: string) => void;\n getChatCompletionFunctionDescriptions: () => ChatCompletionCreateParams.Function[];\n getFunctionCallHandler: () => FunctionCallHandler;\n\n // text context\n getContextString: (categories?: string[]) => string;\n addContext: (\n context: string,\n parentId?: string,\n categories?: string[]\n ) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n\n // document context\n getDocumentsContext: (categories?: string[]) => DocumentPointer[];\n addDocumentContext: (\n documentPointer: DocumentPointer,\n categories?: string[]\n ) => TreeNodeId;\n removeDocumentContext: (documentId: string) => void;\n\n // api endpoints\n copilotApiConfig: CopilotApiConfig;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n entryPoints: {},\n setEntryPoint: () => {},\n removeEntryPoint: () => {},\n getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n getContextString: () => returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n\n getDocumentsContext: () => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\n\n copilotApiConfig: new (class implements CopilotApiConfig {\n get chatApiEndpoint(): string {\n throw new Error(\n \"Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!\"\n );\n }\n })(),\n};\n\nexport const CopilotContext =\n React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nfunction returnAndThrowInDebug<T>(value: T): T {\n throw new Error(\n \"Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!\"\n );\n return value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,QAAQ,YAAY,WAAW,eAAe;;;ACCvD,OAAO,WAAW;AAHlB;AAkDA,IAAM,sBAA4C;AAAA,EAChD,aAAa,CAAC;AAAA,EACd,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB,kBAAkB,MAAM;AAAA,EAAC;AAAA,EACzB,uCAAuC,MAAM,sBAAsB,CAAC,CAAC;AAAA,EACrE,wBAAwB,MAAM,sBAAsB,MAAY;AAAA,EAAC,EAAC;AAAA,EAElE,kBAAkB,MAAM,sBAAsB,EAAE;AAAA,EAChD,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AAAA,EAEtB,qBAAqB,MAAM,sBAAsB,CAAC,CAAC;AAAA,EACnD,oBAAoB,MAAM,sBAAsB,EAAE;AAAA,EAClD,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAE9B,kBAAkB,IAAK,MAAkC;AAAA,IACvD,IAAI,kBAA0B;AAC5B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF,EAAG;AACL;AAEO,IAAM,iBACX,MAAM,cAAoC,mBAAmB;AAE/D,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACA,SAAO;AACT;;;AD7EA,SAAS,cAAc;AALvB;AAOO,SAAS,yBACd,mBACA,cACA;AACA,QAAM,QAAQ,OAAO,OAAO,CAAC;AAC7B,QAAM,EAAE,eAAe,iBAAiB,IAAI,WAAW,cAAc;AAErE,QAAM,4BAA4D;AAAA,IAChE,OAAO;AAAA,MACL,MAAM,kBAAkB;AAAA,MACxB,aAAa,kBAAkB;AAAA,MAC/B,qBAAqB,kBAAkB;AAAA,MACvC,gBAAgB,kBAAkB;AAAA,IACpC;AAAA,IACA;AAAA,EACF;AAEA,YAAU,MAAM;AACd;AAAA,MACE,MAAM;AAAA,MACN;AAAA,IACF;AAEA,WAAO,MAAM;AACX,uBAAiB,MAAM,OAAO;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,2BAA2B,eAAe,gBAAgB,CAAC;AACjE;","names":[]}
@@ -0,0 +1,12 @@
1
+ import { DocumentPointer } from '../types/document-pointer.js';
2
+
3
+ /**
4
+ * Adds the given information to the Copilot context to make it readable by Copilot.
5
+ * @param information - The information to be added to the Copilot context.
6
+ * @param parentId - The ID of the parent context, if any.
7
+ * @param categories - An array of categories to control which context are visible where. Particularly useful with CopilotTextarea (see `useMakeAutosuggestionFunction`)
8
+ * @returns The ID of the added context.
9
+ */
10
+ declare function useMakeCopilotDocumentReadable(document: DocumentPointer, categories?: string[]): string | undefined;
11
+
12
+ export { useMakeCopilotDocumentReadable };
@@ -0,0 +1,78 @@
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+
22
+ // src/hooks/use-make-copilot-document-readable.ts
23
+ import { useContext, useEffect, useRef } from "react";
24
+
25
+ // src/context/copilot-context.tsx
26
+ import React from "react";
27
+ "use client";
28
+ var emptyCopilotContext = {
29
+ entryPoints: {},
30
+ setEntryPoint: () => {
31
+ },
32
+ removeEntryPoint: () => {
33
+ },
34
+ getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),
35
+ getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
36
+ })),
37
+ getContextString: () => returnAndThrowInDebug(""),
38
+ addContext: () => "",
39
+ removeContext: () => {
40
+ },
41
+ getDocumentsContext: () => returnAndThrowInDebug([]),
42
+ addDocumentContext: () => returnAndThrowInDebug(""),
43
+ removeDocumentContext: () => {
44
+ },
45
+ copilotApiConfig: new class {
46
+ get chatApiEndpoint() {
47
+ throw new Error(
48
+ "Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!"
49
+ );
50
+ }
51
+ }()
52
+ };
53
+ var CopilotContext = React.createContext(emptyCopilotContext);
54
+ function returnAndThrowInDebug(value) {
55
+ throw new Error(
56
+ "Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!"
57
+ );
58
+ return value;
59
+ }
60
+
61
+ // src/hooks/use-make-copilot-document-readable.ts
62
+ "use client";
63
+ function useMakeCopilotDocumentReadable(document, categories) {
64
+ const { addDocumentContext, removeDocumentContext } = useContext(CopilotContext);
65
+ const idRef = useRef();
66
+ useEffect(() => {
67
+ const id = addDocumentContext(document, categories);
68
+ idRef.current = id;
69
+ return () => {
70
+ removeDocumentContext(id);
71
+ };
72
+ }, [document, categories, addDocumentContext, removeDocumentContext]);
73
+ return idRef.current;
74
+ }
75
+ export {
76
+ useMakeCopilotDocumentReadable
77
+ };
78
+ //# sourceMappingURL=use-make-copilot-document-readable.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/use-make-copilot-document-readable.ts","../../src/context/copilot-context.tsx"],"sourcesContent":["\"use client\";\n\nimport { useContext, useEffect, useRef } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { DocumentPointer } from \"../types\";\n\n/**\n * Adds the given information to the Copilot context to make it readable by Copilot.\n * @param information - The information to be added to the Copilot context.\n * @param parentId - The ID of the parent context, if any.\n * @param categories - An array of categories to control which context are visible where. Particularly useful with CopilotTextarea (see `useMakeAutosuggestionFunction`)\n * @returns The ID of the added context.\n */\nexport function useMakeCopilotDocumentReadable(\n document: DocumentPointer,\n categories?: string[]\n): string | undefined {\n const { addDocumentContext, removeDocumentContext } =\n useContext(CopilotContext);\n const idRef = useRef<string>();\n\n useEffect(() => {\n const id = addDocumentContext(document, categories);\n idRef.current = id;\n\n return () => {\n removeDocumentContext(id);\n };\n }, [document, categories, addDocumentContext, removeDocumentContext]);\n\n return idRef.current;\n}\n","\"use client\";\n\nimport { FunctionCallHandler } from \"ai\";\nimport React from \"react\";\nimport { TreeNodeId } from \"../hooks/use-tree\";\nimport { AnnotatedFunction } from \"../types/annotated-function\";\nimport { ChatCompletionCreateParams } from \"openai/resources/chat\";\nimport { DocumentPointer } from \"../types\";\n\nexport interface CopilotApiConfig {\n chatApiEndpoint: string;\n}\n\nexport function copilotApiConfigExtrapolator(config: CopilotApiConfig) {\n return {\n get chatApiEndpoint(): string {\n return `${config.chatApiEndpoint}`;\n },\n };\n}\n\nexport interface CopilotContextParams {\n // function-calling\n entryPoints: Record<string, AnnotatedFunction<any[]>>;\n setEntryPoint: (id: string, entryPoint: AnnotatedFunction<any[]>) => void;\n removeEntryPoint: (id: string) => void;\n getChatCompletionFunctionDescriptions: () => ChatCompletionCreateParams.Function[];\n getFunctionCallHandler: () => FunctionCallHandler;\n\n // text context\n getContextString: (categories?: string[]) => string;\n addContext: (\n context: string,\n parentId?: string,\n categories?: string[]\n ) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n\n // document context\n getDocumentsContext: (categories?: string[]) => DocumentPointer[];\n addDocumentContext: (\n documentPointer: DocumentPointer,\n categories?: string[]\n ) => TreeNodeId;\n removeDocumentContext: (documentId: string) => void;\n\n // api endpoints\n copilotApiConfig: CopilotApiConfig;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n entryPoints: {},\n setEntryPoint: () => {},\n removeEntryPoint: () => {},\n getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n getContextString: () => returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n\n getDocumentsContext: () => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\n\n copilotApiConfig: new (class implements CopilotApiConfig {\n get chatApiEndpoint(): string {\n throw new Error(\n \"Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!\"\n );\n }\n })(),\n};\n\nexport const CopilotContext =\n React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nfunction returnAndThrowInDebug<T>(value: T): T {\n throw new Error(\n \"Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!\"\n );\n return value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,YAAY,WAAW,cAAc;;;ACC9C,OAAO,WAAW;AAHlB;AAkDA,IAAM,sBAA4C;AAAA,EAChD,aAAa,CAAC;AAAA,EACd,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB,kBAAkB,MAAM;AAAA,EAAC;AAAA,EACzB,uCAAuC,MAAM,sBAAsB,CAAC,CAAC;AAAA,EACrE,wBAAwB,MAAM,sBAAsB,MAAY;AAAA,EAAC,EAAC;AAAA,EAElE,kBAAkB,MAAM,sBAAsB,EAAE;AAAA,EAChD,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AAAA,EAEtB,qBAAqB,MAAM,sBAAsB,CAAC,CAAC;AAAA,EACnD,oBAAoB,MAAM,sBAAsB,EAAE;AAAA,EAClD,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAE9B,kBAAkB,IAAK,MAAkC;AAAA,IACvD,IAAI,kBAA0B;AAC5B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF,EAAG;AACL;AAEO,IAAM,iBACX,MAAM,cAAoC,mBAAmB;AAE/D,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACA,SAAO;AACT;;;ADlFA;AAaO,SAAS,+BACd,UACA,YACoB;AACpB,QAAM,EAAE,oBAAoB,sBAAsB,IAChD,WAAW,cAAc;AAC3B,QAAM,QAAQ,OAAe;AAE7B,YAAU,MAAM;AACd,UAAM,KAAK,mBAAmB,UAAU,UAAU;AAClD,UAAM,UAAU;AAEhB,WAAO,MAAM;AACX,4BAAsB,EAAE;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,UAAU,YAAY,oBAAoB,qBAAqB,CAAC;AAEpE,SAAO,MAAM;AACf;","names":[]}
@@ -1,5 +1,78 @@
1
- export { useMakeCopilotReadable } from '../chunk-JLQULZT4.mjs';
2
- import '../chunk-ZKO7HCZS.mjs';
3
- import '../chunk-MRXNTQOX.mjs';
4
- //# sourceMappingURL=out.js.map
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+
22
+ // src/hooks/use-make-copilot-readable.ts
23
+ import { useContext, useEffect, useRef } from "react";
24
+
25
+ // src/context/copilot-context.tsx
26
+ import React from "react";
27
+ "use client";
28
+ var emptyCopilotContext = {
29
+ entryPoints: {},
30
+ setEntryPoint: () => {
31
+ },
32
+ removeEntryPoint: () => {
33
+ },
34
+ getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),
35
+ getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
36
+ })),
37
+ getContextString: () => returnAndThrowInDebug(""),
38
+ addContext: () => "",
39
+ removeContext: () => {
40
+ },
41
+ getDocumentsContext: () => returnAndThrowInDebug([]),
42
+ addDocumentContext: () => returnAndThrowInDebug(""),
43
+ removeDocumentContext: () => {
44
+ },
45
+ copilotApiConfig: new class {
46
+ get chatApiEndpoint() {
47
+ throw new Error(
48
+ "Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!"
49
+ );
50
+ }
51
+ }()
52
+ };
53
+ var CopilotContext = React.createContext(emptyCopilotContext);
54
+ function returnAndThrowInDebug(value) {
55
+ throw new Error(
56
+ "Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!"
57
+ );
58
+ return value;
59
+ }
60
+
61
+ // src/hooks/use-make-copilot-readable.ts
62
+ "use client";
63
+ function useMakeCopilotReadable(information, parentId, categories) {
64
+ const { addContext, removeContext } = useContext(CopilotContext);
65
+ const idRef = useRef();
66
+ useEffect(() => {
67
+ const id = addContext(information, parentId, categories);
68
+ idRef.current = id;
69
+ return () => {
70
+ removeContext(id);
71
+ };
72
+ }, [information, parentId, addContext, removeContext]);
73
+ return idRef.current;
74
+ }
75
+ export {
76
+ useMakeCopilotReadable
77
+ };
5
78
  //# sourceMappingURL=use-make-copilot-readable.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":["../../src/hooks/use-make-copilot-readable.ts","../../src/context/copilot-context.tsx"],"sourcesContent":["\"use client\";\n\nimport { useContext, useEffect, useRef } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\n\n/**\n * Adds the given information to the Copilot context to make it readable by Copilot.\n * @param information - The information to be added to the Copilot context.\n * @param parentId - The ID of the parent context, if any.\n * @param categories - An array of categories to control which context are visible where. Particularly useful with CopilotTextarea (see `useMakeAutosuggestionFunction`)\n * @returns The ID of the added context.\n */\nexport function useMakeCopilotReadable(\n information: string,\n parentId?: string,\n categories?: string[]\n): string | undefined {\n const { addContext, removeContext } = useContext(CopilotContext);\n const idRef = useRef<string>();\n\n useEffect(() => {\n const id = addContext(information, parentId, categories);\n idRef.current = id;\n\n return () => {\n removeContext(id);\n };\n }, [information, parentId, addContext, removeContext]);\n\n return idRef.current;\n}\n","\"use client\";\n\nimport { FunctionCallHandler } from \"ai\";\nimport React from \"react\";\nimport { TreeNodeId } from \"../hooks/use-tree\";\nimport { AnnotatedFunction } from \"../types/annotated-function\";\nimport { ChatCompletionCreateParams } from \"openai/resources/chat\";\nimport { DocumentPointer } from \"../types\";\n\nexport interface CopilotApiConfig {\n chatApiEndpoint: string;\n}\n\nexport function copilotApiConfigExtrapolator(config: CopilotApiConfig) {\n return {\n get chatApiEndpoint(): string {\n return `${config.chatApiEndpoint}`;\n },\n };\n}\n\nexport interface CopilotContextParams {\n // function-calling\n entryPoints: Record<string, AnnotatedFunction<any[]>>;\n setEntryPoint: (id: string, entryPoint: AnnotatedFunction<any[]>) => void;\n removeEntryPoint: (id: string) => void;\n getChatCompletionFunctionDescriptions: () => ChatCompletionCreateParams.Function[];\n getFunctionCallHandler: () => FunctionCallHandler;\n\n // text context\n getContextString: (categories?: string[]) => string;\n addContext: (\n context: string,\n parentId?: string,\n categories?: string[]\n ) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n\n // document context\n getDocumentsContext: (categories?: string[]) => DocumentPointer[];\n addDocumentContext: (\n documentPointer: DocumentPointer,\n categories?: string[]\n ) => TreeNodeId;\n removeDocumentContext: (documentId: string) => void;\n\n // api endpoints\n copilotApiConfig: CopilotApiConfig;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n entryPoints: {},\n setEntryPoint: () => {},\n removeEntryPoint: () => {},\n getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n getContextString: () => returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n\n getDocumentsContext: () => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\n\n copilotApiConfig: new (class implements CopilotApiConfig {\n get chatApiEndpoint(): string {\n throw new Error(\n \"Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!\"\n );\n }\n })(),\n};\n\nexport const CopilotContext =\n React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nfunction returnAndThrowInDebug<T>(value: T): T {\n throw new Error(\n \"Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!\"\n );\n return value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,YAAY,WAAW,cAAc;;;ACC9C,OAAO,WAAW;AAHlB;AAkDA,IAAM,sBAA4C;AAAA,EAChD,aAAa,CAAC;AAAA,EACd,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB,kBAAkB,MAAM;AAAA,EAAC;AAAA,EACzB,uCAAuC,MAAM,sBAAsB,CAAC,CAAC;AAAA,EACrE,wBAAwB,MAAM,sBAAsB,MAAY;AAAA,EAAC,EAAC;AAAA,EAElE,kBAAkB,MAAM,sBAAsB,EAAE;AAAA,EAChD,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AAAA,EAEtB,qBAAqB,MAAM,sBAAsB,CAAC,CAAC;AAAA,EACnD,oBAAoB,MAAM,sBAAsB,EAAE;AAAA,EAClD,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAE9B,kBAAkB,IAAK,MAAkC;AAAA,IACvD,IAAI,kBAA0B;AAC5B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF,EAAG;AACL;AAEO,IAAM,iBACX,MAAM,cAAoC,mBAAmB;AAE/D,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACA,SAAO;AACT;;;ADlFA;AAYO,SAAS,uBACd,aACA,UACA,YACoB;AACpB,QAAM,EAAE,YAAY,cAAc,IAAI,WAAW,cAAc;AAC/D,QAAM,QAAQ,OAAe;AAE7B,YAAU,MAAM;AACd,UAAM,KAAK,WAAW,aAAa,UAAU,UAAU;AACvD,UAAM,UAAU;AAEhB,WAAO,MAAM;AACX,oBAAc,EAAE;AAAA,IAClB;AAAA,EACF,GAAG,CAAC,aAAa,UAAU,YAAY,aAAa,CAAC;AAErD,SAAO,MAAM;AACf;","names":[]}
@@ -1,4 +1,160 @@
1
- export { use_tree_default as default } from '../chunk-3BOHSSKR.mjs';
2
- import '../chunk-MRXNTQOX.mjs';
3
- //# sourceMappingURL=out.js.map
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+
21
+ // src/hooks/use-tree.ts
22
+ import { nanoid } from "nanoid";
23
+ import { useCallback, useReducer } from "react";
24
+ var removeNode = (nodes, id) => {
25
+ return nodes.reduce((result, node) => {
26
+ if (node.id !== id) {
27
+ const newNode = __spreadProps(__spreadValues({}, node), { children: removeNode(node.children, id) });
28
+ result.push(newNode);
29
+ }
30
+ return result;
31
+ }, []);
32
+ };
33
+ var addNode = (nodes, newNode, parentId) => {
34
+ if (!parentId) {
35
+ return [...nodes, newNode];
36
+ }
37
+ return nodes.map((node) => {
38
+ if (node.id === parentId) {
39
+ return __spreadProps(__spreadValues({}, node), { children: [...node.children, newNode] });
40
+ } else if (node.children.length) {
41
+ return __spreadProps(__spreadValues({}, node), { children: addNode(node.children, newNode, parentId) });
42
+ }
43
+ return node;
44
+ });
45
+ };
46
+ var treeIndentationRepresentation = (index, indentLevel) => {
47
+ if (indentLevel === 0) {
48
+ return (index + 1).toString();
49
+ } else if (indentLevel === 1) {
50
+ return String.fromCharCode(65 + index);
51
+ } else if (indentLevel === 2) {
52
+ return String.fromCharCode(97 + index);
53
+ } else {
54
+ return "-";
55
+ }
56
+ };
57
+ var printNode = (node, prefix = "", indentLevel = 0) => {
58
+ const indent = " ".repeat(3).repeat(indentLevel);
59
+ const prefixPlusIndentLength = prefix.length + indent.length;
60
+ const subsequentLinesPrefix = " ".repeat(prefixPlusIndentLength);
61
+ const valueLines = node.value.split("\n");
62
+ const outputFirstLine = `${indent}${prefix}${valueLines[0]}`;
63
+ const outputSubsequentLines = valueLines.slice(1).map((line) => `${subsequentLinesPrefix}${line}`).join("\n");
64
+ let output = `${outputFirstLine}
65
+ `;
66
+ if (outputSubsequentLines) {
67
+ output += `${outputSubsequentLines}
68
+ `;
69
+ }
70
+ const childPrePrefix = " ".repeat(prefix.length);
71
+ node.children.forEach(
72
+ (child, index) => output += printNode(
73
+ child,
74
+ `${childPrePrefix}${treeIndentationRepresentation(
75
+ index,
76
+ indentLevel + 1
77
+ )}. `,
78
+ indentLevel + 1
79
+ )
80
+ );
81
+ return output;
82
+ };
83
+ function treeReducer(state, action) {
84
+ switch (action.type) {
85
+ case "ADD_NODE": {
86
+ const { value, parentId, id: newNodeId } = action;
87
+ const newNode = {
88
+ id: newNodeId,
89
+ value,
90
+ children: [],
91
+ categories: new Set(action.categories)
92
+ };
93
+ try {
94
+ return addNode(state, newNode, parentId);
95
+ } catch (error) {
96
+ console.error(`Error while adding node with id ${newNodeId}: ${error}`);
97
+ return state;
98
+ }
99
+ }
100
+ case "REMOVE_NODE":
101
+ return removeNode(state, action.id);
102
+ default:
103
+ return state;
104
+ }
105
+ }
106
+ var useTree = () => {
107
+ const [tree, dispatch] = useReducer(treeReducer, []);
108
+ const addElement = useCallback(
109
+ (value, categories, parentId) => {
110
+ const newNodeId = nanoid();
111
+ dispatch({
112
+ type: "ADD_NODE",
113
+ value,
114
+ parentId,
115
+ id: newNodeId,
116
+ categories
117
+ });
118
+ return newNodeId;
119
+ },
120
+ []
121
+ );
122
+ const removeElement = useCallback((id) => {
123
+ dispatch({ type: "REMOVE_NODE", id });
124
+ }, []);
125
+ const printTree = useCallback(
126
+ (categories) => {
127
+ const categoriesSet = new Set(categories);
128
+ let output = "";
129
+ tree.forEach((node, index) => {
130
+ if (!setsHaveIntersection(categoriesSet, node.categories)) {
131
+ return;
132
+ }
133
+ if (index !== 0) {
134
+ output += "\n";
135
+ }
136
+ output += printNode(
137
+ node,
138
+ `${treeIndentationRepresentation(index, 0)}. `
139
+ );
140
+ });
141
+ return output;
142
+ },
143
+ [tree]
144
+ );
145
+ return { tree, addElement, printTree, removeElement };
146
+ };
147
+ var use_tree_default = useTree;
148
+ function setsHaveIntersection(setA, setB) {
149
+ const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];
150
+ for (let item of smallerSet) {
151
+ if (largerSet.has(item)) {
152
+ return true;
153
+ }
154
+ }
155
+ return false;
156
+ }
157
+ export {
158
+ use_tree_default as default
159
+ };
4
160
  //# sourceMappingURL=use-tree.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":["../../src/hooks/use-tree.ts"],"sourcesContent":["import { nanoid } from \"nanoid\";\nimport { useCallback, useReducer } from \"react\";\n\nexport type TreeNodeId = string;\n\nexport interface TreeNode {\n id: TreeNodeId;\n value: string;\n children: TreeNode[];\n parentId?: TreeNodeId;\n categories: Set<string>;\n}\n\nexport type Tree = TreeNode[];\n\nexport interface UseTreeReturn {\n tree: Tree;\n addElement: (\n value: string,\n categories: string[],\n parentId?: TreeNodeId\n ) => TreeNodeId;\n printTree: (categories: string[]) => string;\n removeElement: (id: TreeNodeId) => void;\n}\n\nconst findNode = (nodes: Tree, id: TreeNodeId): TreeNode | undefined => {\n for (const node of nodes) {\n if (node.id === id) {\n return node;\n }\n const result = findNode(node.children, id);\n if (result) {\n return result;\n }\n }\n return undefined;\n};\n\nconst removeNode = (nodes: Tree, id: TreeNodeId): Tree => {\n return nodes.reduce((result: Tree, node) => {\n if (node.id !== id) {\n const newNode = { ...node, children: removeNode(node.children, id) };\n result.push(newNode);\n }\n return result;\n }, []);\n};\n\nconst addNode = (\n nodes: Tree,\n newNode: TreeNode,\n parentId?: TreeNodeId\n): Tree => {\n if (!parentId) {\n return [...nodes, newNode];\n }\n return nodes.map((node) => {\n if (node.id === parentId) {\n return { ...node, children: [...node.children, newNode] };\n } else if (node.children.length) {\n return { ...node, children: addNode(node.children, newNode, parentId) };\n }\n return node;\n });\n};\n\nconst treeIndentationRepresentation = (\n index: number,\n indentLevel: number\n): string => {\n if (indentLevel === 0) {\n return (index + 1).toString();\n } else if (indentLevel === 1) {\n return String.fromCharCode(65 + index); // 65 is the ASCII value for 'A'\n } else if (indentLevel === 2) {\n return String.fromCharCode(97 + index); // 97 is the ASCII value for 'a'\n } else {\n return \"-\";\n }\n};\n\nconst printNode = (node: TreeNode, prefix = \"\", indentLevel = 0): string => {\n const indent = \" \".repeat(3).repeat(indentLevel);\n\n const prefixPlusIndentLength = prefix.length + indent.length;\n const subsequentLinesPrefix = \" \".repeat(prefixPlusIndentLength);\n\n const valueLines = node.value.split(\"\\n\");\n\n const outputFirstLine = `${indent}${prefix}${valueLines[0]}`;\n const outputSubsequentLines = valueLines\n .slice(1)\n .map((line) => `${subsequentLinesPrefix}${line}`)\n .join(\"\\n\");\n\n let output = `${outputFirstLine}\\n`;\n if (outputSubsequentLines) {\n output += `${outputSubsequentLines}\\n`;\n }\n\n const childPrePrefix = \" \".repeat(prefix.length);\n\n node.children.forEach(\n (child, index) =>\n (output += printNode(\n child,\n `${childPrePrefix}${treeIndentationRepresentation(\n index,\n indentLevel + 1\n )}. `,\n indentLevel + 1\n ))\n );\n return output;\n};\n\n// Action types\ntype Action =\n | {\n type: \"ADD_NODE\";\n value: string;\n parentId?: string;\n id: string;\n categories: string[];\n }\n | { type: \"REMOVE_NODE\"; id: string };\n\n// Reducer function\nfunction treeReducer(state: Tree, action: Action): Tree {\n switch (action.type) {\n case \"ADD_NODE\": {\n const { value, parentId, id: newNodeId } = action;\n const newNode: TreeNode = {\n id: newNodeId,\n value,\n children: [],\n categories: new Set(action.categories),\n };\n\n try {\n return addNode(state, newNode, parentId);\n } catch (error) {\n console.error(`Error while adding node with id ${newNodeId}: ${error}`);\n return state;\n }\n }\n case \"REMOVE_NODE\":\n return removeNode(state, action.id);\n default:\n return state;\n }\n}\n\n// useTree hook\nconst useTree = (): UseTreeReturn => {\n const [tree, dispatch] = useReducer(treeReducer, []);\n\n const addElement = useCallback(\n (value: string, categories: string[], parentId?: string): TreeNodeId => {\n const newNodeId = nanoid(); // Generate new ID outside of dispatch\n dispatch({\n type: \"ADD_NODE\",\n value,\n parentId,\n id: newNodeId,\n categories: categories,\n });\n return newNodeId; // Return the new ID\n },\n []\n );\n\n const removeElement = useCallback((id: TreeNodeId): void => {\n dispatch({ type: \"REMOVE_NODE\", id });\n }, []);\n\n const printTree = useCallback(\n (categories: string[]): string => {\n const categoriesSet = new Set(categories);\n\n let output = \"\";\n tree.forEach((node, index) => {\n // if the node does not have any of the desired categories, continue to the next node\n if (!setsHaveIntersection(categoriesSet, node.categories)) {\n return;\n }\n\n // add a new line before each node except the first one\n if (index !== 0) {\n output += \"\\n\";\n }\n\n output += printNode(\n node,\n `${treeIndentationRepresentation(index, 0)}. `\n );\n });\n return output;\n },\n [tree]\n );\n\n return { tree, addElement, printTree, removeElement };\n};\n\nexport default useTree;\n\nfunction setsHaveIntersection<T>(setA: Set<T>, setB: Set<T>): boolean {\n const [smallerSet, largerSet] =\n setA.size <= setB.size ? [setA, setB] : [setB, setA];\n\n for (let item of smallerSet) {\n if (largerSet.has(item)) {\n return true;\n }\n }\n\n return false;\n}\n"],"mappings":"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","names":[]}
package/dist/index.d.ts CHANGED
@@ -3,7 +3,9 @@ export { CopilotApiConfig, CopilotContext, CopilotContextParams, copilotApiConfi
3
3
  export { UseCopilotChatOptions, UseCopilotChatReturn, useCopilotChat } from './hooks/use-copilot-chat.js';
4
4
  export { useMakeCopilotActionable } from './hooks/use-make-copilot-actionable.js';
5
5
  export { useMakeCopilotReadable } from './hooks/use-make-copilot-readable.js';
6
+ export { useMakeCopilotDocumentReadable } from './hooks/use-make-copilot-document-readable.js';
6
7
  export { AnnotatedFunction, AnnotatedFunctionArgument } from './types/annotated-function.js';
8
+ export { DocumentPointer } from './types/document-pointer.js';
7
9
  import 'react';
8
10
  import 'ai';
9
11
  import './hooks/use-tree.js';