@copilotkitnext/react 0.0.3 → 0.0.4

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 (48) hide show
  1. package/package.json +3 -3
  2. package/.turbo/turbo-build$colon$css.log +0 -9
  3. package/.turbo/turbo-build.log +0 -30
  4. package/.turbo/turbo-check-types.log +0 -7
  5. package/.turbo/turbo-lint.log +0 -78
  6. package/.turbo/turbo-test.log +0 -79
  7. package/postcss.config.js +0 -7
  8. package/src/__tests__/setup.ts +0 -2
  9. package/src/components/chat/CopilotChat.tsx +0 -90
  10. package/src/components/chat/CopilotChatAssistantMessage.tsx +0 -478
  11. package/src/components/chat/CopilotChatAudioRecorder.tsx +0 -157
  12. package/src/components/chat/CopilotChatInput.tsx +0 -596
  13. package/src/components/chat/CopilotChatMessageView.tsx +0 -85
  14. package/src/components/chat/CopilotChatToolCallsView.tsx +0 -43
  15. package/src/components/chat/CopilotChatUserMessage.tsx +0 -337
  16. package/src/components/chat/CopilotChatView.tsx +0 -385
  17. package/src/components/chat/__tests__/CopilotChatAssistantMessage.test.tsx +0 -684
  18. package/src/components/chat/__tests__/CopilotChatInput.test.tsx +0 -531
  19. package/src/components/chat/__tests__/setup.ts +0 -1
  20. package/src/components/chat/index.ts +0 -35
  21. package/src/components/index.ts +0 -4
  22. package/src/components/ui/button.tsx +0 -123
  23. package/src/components/ui/dropdown-menu.tsx +0 -257
  24. package/src/components/ui/tooltip.tsx +0 -59
  25. package/src/hooks/index.ts +0 -6
  26. package/src/hooks/use-agent-context.tsx +0 -17
  27. package/src/hooks/use-agent.tsx +0 -48
  28. package/src/hooks/use-frontend-tool.tsx +0 -46
  29. package/src/hooks/use-human-in-the-loop.tsx +0 -76
  30. package/src/hooks/use-render-tool-call.tsx +0 -81
  31. package/src/index.ts +0 -4
  32. package/src/lib/__tests__/completePartialMarkdown.test.ts +0 -495
  33. package/src/lib/__tests__/renderSlot.test.tsx +0 -610
  34. package/src/lib/slots.tsx +0 -55
  35. package/src/lib/utils.ts +0 -6
  36. package/src/providers/CopilotChatConfigurationProvider.tsx +0 -81
  37. package/src/providers/CopilotKitProvider.tsx +0 -269
  38. package/src/providers/__tests__/CopilotKitProvider.test.tsx +0 -487
  39. package/src/providers/__tests__/CopilotKitProvider.wildcard.test.tsx +0 -261
  40. package/src/providers/index.ts +0 -14
  41. package/src/styles/globals.css +0 -302
  42. package/src/types/frontend-tool.ts +0 -8
  43. package/src/types/human-in-the-loop.ts +0 -33
  44. package/src/types/index.ts +0 -3
  45. package/src/types/react-tool-call-render.ts +0 -29
  46. package/tailwind.config.js +0 -9
  47. package/tsconfig.json +0 -23
  48. package/tsup.config.ts +0 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkitnext/react",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "React components for CopilotKit2",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -58,8 +58,8 @@
58
58
  "tw-animate-css": "^1.3.5",
59
59
  "use-stick-to-bottom": "^1.1.1",
60
60
  "zod": "^3.25.75",
61
- "@copilotkitnext/core": "0.0.3",
62
- "@copilotkitnext/shared": "0.0.3"
61
+ "@copilotkitnext/core": "0.0.4",
62
+ "@copilotkitnext/shared": "0.0.4"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "react": ">=16.8.0",
@@ -1,9 +0,0 @@
1
-
2
- 
3
- > @copilotkit/react@0.0.0 build:css /Users/mme/Code/CopilotKit2/packages/react
4
- > npx @tailwindcss/cli -i ./src/styles/globals.css -o ./dist/styles.css -m
5
-
6
- ⠙⠹⠸⠼⠴⠦⠧⠇⠏⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⠋⠙⠹⠸⠼⠴⠦≈ tailwindcss v4.1.11
7
-
8
- Done in 117ms
9
- ⠙
@@ -1,30 +0,0 @@
1
-
2
- 
3
- > @copilotkitnext/react@0.0.3 build /Users/mme/Code/vnext_experimental/packages/react
4
- > tsup && npm run build:css
5
-
6
- CLI Building entry: src/index.ts
7
- CLI Using tsconfig: tsconfig.json
8
- CLI tsup v8.5.0
9
- CLI Using tsup config: /Users/mme/Code/vnext_experimental/packages/react/tsup.config.ts
10
- CLI Target: es2022
11
- CJS Build start
12
- ESM Build start
13
- CJS dist/index.js 80.60 KB
14
- CJS dist/index.js.map 136.95 KB
15
- CJS ⚡️ Build success in 40ms
16
- ESM dist/index.mjs 72.83 KB
17
- ESM dist/index.mjs.map 138.31 KB
18
- ESM ⚡️ Build success in 40ms
19
- DTS Build start
20
- DTS ⚡️ Build success in 3124ms
21
- DTS dist/index.d.ts 17.44 KB
22
- DTS dist/index.d.mts 17.44 KB
23
-
24
- > @copilotkitnext/react@0.0.3 build:css
25
- > npx @tailwindcss/cli -i ./src/styles/globals.css -o ./dist/styles.css -m
26
-
27
- ⠙⠹⠸⠼⠴⠦⠧⠇⠏⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⠋⠙⠹⠸⠼⠴⠦⠧≈ tailwindcss v4.1.11
28
-
29
- Done in 130ms
30
- ⠙⠙
@@ -1,7 +0,0 @@
1
-
2
- > @copilotkitnext/react@0.0.2 check-types /Users/mme/Code/vnext_experimental/packages/react
3
- > tsc --noEmit
4
-
5
- src/components/chat/__tests__/CopilotChatAssistantMessage.test.tsx(28,25): error TS2322: Type '{ children: Element; publicApiKey: string; }' is not assignable to type 'IntrinsicAttributes & CopilotKitProviderProps'.
6
- Property 'publicApiKey' does not exist on type 'IntrinsicAttributes & CopilotKitProviderProps'.
7
-  ELIFECYCLE  Command failed with exit code 2.
@@ -1,78 +0,0 @@
1
-
2
- > @copilotkit/react@0.0.0 lint /Users/mme/Code/CopilotKit2/packages/react
3
- > eslint . --max-warnings 0
4
-
5
-
6
- /Users/mme/Code/CopilotKit2/packages/react/src/components/chat/CopilotChatAudioRecorder.tsx
7
- 16:3 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
8
-
9
- /Users/mme/Code/CopilotKit2/packages/react/src/components/chat/CopilotChatInput.tsx
10
- 538:10 warning React Hook useEffect has a missing dependency: 'adjustHeight'. Either include it or remove the dependency array react-hooks/exhaustive-deps
11
-
12
- /Users/mme/Code/CopilotKit2/packages/react/src/components/chat/CopilotChatView.tsx
13
- 165:8 warning ES2015 module syntax is preferred over namespaces @typescript-eslint/no-namespace
14
-
15
- /Users/mme/Code/CopilotKit2/packages/react/src/hooks/use-agent-context.tsx
16
- 16:6 warning React Hook useEffect has a missing dependency: 'context'. Either include it or remove the dependency array react-hooks/exhaustive-deps
17
-
18
- /Users/mme/Code/CopilotKit2/packages/react/src/hooks/use-agent.tsx
19
- 19:6 warning React Hook useMemo has a missing dependency: 'copilotkit'. Either include it or remove the dependency array react-hooks/exhaustive-deps
20
- 23:25 warning 'params' is defined but never used @typescript-eslint/no-unused-vars
21
- 26:22 warning 'params' is defined but never used @typescript-eslint/no-unused-vars
22
- 29:24 warning 'params' is defined but never used @typescript-eslint/no-unused-vars
23
- 32:22 warning 'params' is defined but never used @typescript-eslint/no-unused-vars
24
- 35:19 warning 'params' is defined but never used @typescript-eslint/no-unused-vars
25
-
26
- /Users/mme/Code/CopilotKit2/packages/react/src/hooks/use-frontend-tool.tsx
27
- 6:56 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
28
- 6:63 warning The `{}` ("empty object") type allows any non-nullish value, including literals like `0` and `""`.
29
- - If that's what you want, disable this lint rule with an inline comment or configure the 'allowObjectTypes' rule option.
30
- - If you want a type meaning "any object", you probably want `object` instead.
31
- - If you want a type meaning "any value", you probably want `unknown` instead @typescript-eslint/no-empty-object-type
32
- 11:58 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
33
- 11:65 warning The `{}` ("empty object") type allows any non-nullish value, including literals like `0` and `""`.
34
- - If that's what you want, disable this lint rule with an inline comment or configure the 'allowObjectTypes' rule option.
35
- - If you want a type meaning "any object", you probably want `object` instead.
36
- - If you want a type meaning "any value", you probably want `unknown` instead @typescript-eslint/no-empty-object-type
37
- 40:6 warning React Hook useEffect has missing dependencies: 'renderToolCalls' and 'setCurrentRenderToolCalls'. Either include them or remove the dependency array react-hooks/exhaustive-deps
38
-
39
- /Users/mme/Code/CopilotKit2/packages/react/src/hooks/use-human-in-the-loop.tsx
40
- 7:58 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
41
- 7:65 warning The `{}` ("empty object") type allows any non-nullish value, including literals like `0` and `""`.
42
- - If that's what you want, disable this lint rule with an inline comment or configure the 'allowObjectTypes' rule option.
43
- - If you want a type meaning "any object", you probably want `object` instead.
44
- - If you want a type meaning "any value", you probably want `unknown` instead @typescript-eslint/no-empty-object-type
45
- 39:60 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
46
- 39:67 warning The `{}` ("empty object") type allows any non-nullish value, including literals like `0` and `""`.
47
- - If that's what you want, disable this lint rule with an inline comment or configure the 'allowObjectTypes' rule option.
48
- - If you want a type meaning "any object", you probably want `object` instead.
49
- - If you want a type meaning "any value", you probably want `unknown` instead @typescript-eslint/no-empty-object-type
50
- 55:38 warning 'args' is defined but never used @typescript-eslint/no-unused-vars
51
- 88:58 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
52
-
53
- /Users/mme/Code/CopilotKit2/packages/react/src/lib/__tests__/renderSlot.test.tsx
54
- 222:27 warning Component definition is missing display name react/display-name
55
- 372:50 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
56
-
57
- /Users/mme/Code/CopilotKit2/packages/react/src/lib/slots.tsx
58
- 10:53 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
59
- 19:48 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
60
- 20:10 warning The `{}` ("empty object") type allows any non-nullish value, including literals like `0` and `""`.
61
- - If that's what you want, disable this lint rule with an inline comment or configure the 'allowObjectTypes' rule option.
62
- - If you want a type meaning "any object", you probably want `object` instead.
63
- - If you want a type meaning "any value", you probably want `unknown` instead @typescript-eslint/no-empty-object-type
64
- 29:33 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
65
-
66
- /Users/mme/Code/CopilotKit2/packages/react/src/providers/CopilotChatConfigurationProvider.tsx
67
- 1:55 warning 'useState' is defined but never used @typescript-eslint/no-unused-vars
68
-
69
- /Users/mme/Code/CopilotKit2/packages/react/src/providers/CopilotKitProvider.tsx
70
- 52:65 warning React Hook useMemo has a missing dependency: 'renderToolCalls'. Either include it or remove the dependency array react-hooks/exhaustive-deps
71
- 65:6 warning React Hook useEffect has a missing dependency: 'initialRenderToolCalls'. Either include it or remove the dependency array react-hooks/exhaustive-deps
72
- 76:6 warning React Hook useMemo has missing dependencies: 'agents', 'headers', and 'properties'. Either include them or remove the dependency array react-hooks/exhaustive-deps
73
- 83:6 warning React Hook useEffect has a missing dependency: 'copilotkit'. Either include it or remove the dependency array react-hooks/exhaustive-deps
74
-
75
- ✖ 32 problems (0 errors, 32 warnings)
76
-
77
- ESLint found too many warnings (maximum: 0).
78
-  ELIFECYCLE  Command failed with exit code 1.
@@ -1,79 +0,0 @@
1
-
2
- > @copilotkitnext/react@0.0.2 test /Users/mme/Code/vnext_experimental/packages/react
3
- > vitest run
4
-
5
-
6
- RUN v3.2.4 /Users/mme/Code/vnext_experimental/packages/react
7
-
8
- ✓ src/lib/__tests__/completePartialMarkdown.test.ts (68 tests) 22ms
9
- ✓ src/providers/__tests__/CopilotKitProvider.wildcard.test.tsx (9 tests) 143ms
10
- ✓ src/providers/__tests__/CopilotKitProvider.test.tsx (16 tests) 221ms
11
- stdout | src/lib/__tests__/renderSlot.test.tsx > renderSlot > Ref forwarding > forwards refs to custom component
12
- BUG: Custom component was not used by renderSlot
13
-
14
- stderr | src/lib/__tests__/renderSlot.test.tsx > renderSlot > Ref forwarding > forwards refs to custom component
15
- Invalid values for props `$$typeof`, `render` on <input> tag. Either remove them from the element, or pass a string or number value to keep them in the DOM. For details, see https://react.dev/link/attribute-behavior
16
- Invalid attribute name: `$$typeof`
17
-
18
- stdout | src/lib/__tests__/renderSlot.test.tsx > renderSlot > Complex prop merging > handles undefined and null prop values
19
- BUG: undefined slot props override base props
20
-
21
- stdout | src/lib/__tests__/renderSlot.test.tsx > renderSlot > Additional bug hunting > FINAL ANALYSIS: renderSlot function behavior
22
-
23
- === RENDERSLOT FUNCTION ANALYSIS ===
24
- ✅ String slots work correctly (become className)
25
- ✅ Function slots work correctly (custom components used)
26
- ✅ Object slots work correctly (props merged)
27
- ✅ Undefined slots work correctly (default component used)
28
- 📋 Undefined props in slot objects override base props (expected JS behavior)
29
- 📋 Complex ref forwarding may have edge cases but core function works
30
- 🎉 Overall: renderSlot function is working as designed!
31
-
32
- ✓ src/lib/__tests__/renderSlot.test.tsx (32 tests) 329ms
33
- stderr | src/components/chat/__tests__/CopilotChatInput.test.tsx > CopilotChatInput > shows cancel and finish buttons in transcribe mode
34
- Error: Not implemented: HTMLCanvasElement.prototype.getContext (without installing the canvas npm package)
35
- at module.exports (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/jsdom@26.1.0/node_modules/jsdom/lib/jsdom/browser/not-implemented.js:9:17)
36
- at HTMLCanvasElementImpl.getContext (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/jsdom@26.1.0/node_modules/jsdom/lib/jsdom/living/nodes/HTMLCanvasElement-impl.js:42:5)
37
- at HTMLCanvasElement.getContext (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/jsdom@26.1.0/node_modules/jsdom/lib/jsdom/living/generated/HTMLCanvasElement.js:131:58)
38
- at /Users/mme/Code/vnext_experimental/packages/react/src/components/chat/CopilotChatAudioRecorder.tsx:59:24
39
- at Object.react-stack-bottom-frame (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:23949:20)
40
- at runWithFiberInDEV (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:1522:13)
41
- at commitHookEffectListMount (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:11905:29)
42
- at commitHookPassiveMountEffects (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:12028:11)
43
- at commitPassiveMountOnFiber (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:13841:13)
44
- at recursivelyTraversePassiveMountEffects (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:13815:11) undefined
45
-
46
- stderr | src/components/chat/__tests__/CopilotChatInput.test.tsx > CopilotChatInput > disables add and tools buttons in transcribe mode
47
- Error: Not implemented: HTMLCanvasElement.prototype.getContext (without installing the canvas npm package)
48
- at module.exports (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/jsdom@26.1.0/node_modules/jsdom/lib/jsdom/browser/not-implemented.js:9:17)
49
- at HTMLCanvasElementImpl.getContext (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/jsdom@26.1.0/node_modules/jsdom/lib/jsdom/living/nodes/HTMLCanvasElement-impl.js:42:5)
50
- at HTMLCanvasElement.getContext (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/jsdom@26.1.0/node_modules/jsdom/lib/jsdom/living/generated/HTMLCanvasElement.js:131:58)
51
- at /Users/mme/Code/vnext_experimental/packages/react/src/components/chat/CopilotChatAudioRecorder.tsx:59:24
52
- at Object.react-stack-bottom-frame (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:23949:20)
53
- at runWithFiberInDEV (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:1522:13)
54
- at commitHookEffectListMount (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:11905:29)
55
- at commitHookPassiveMountEffects (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:12028:11)
56
- at commitPassiveMountOnFiber (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:13841:13)
57
- at recursivelyTraversePassiveMountEffects (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:13815:11) undefined
58
-
59
- stderr | src/components/chat/__tests__/CopilotChatInput.test.tsx > CopilotChatInput > shows recording indicator instead of textarea in transcribe mode
60
- Error: Not implemented: HTMLCanvasElement.prototype.getContext (without installing the canvas npm package)
61
- at module.exports (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/jsdom@26.1.0/node_modules/jsdom/lib/jsdom/browser/not-implemented.js:9:17)
62
- at HTMLCanvasElementImpl.getContext (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/jsdom@26.1.0/node_modules/jsdom/lib/jsdom/living/nodes/HTMLCanvasElement-impl.js:42:5)
63
- at HTMLCanvasElement.getContext (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/jsdom@26.1.0/node_modules/jsdom/lib/jsdom/living/generated/HTMLCanvasElement.js:131:58)
64
- at /Users/mme/Code/vnext_experimental/packages/react/src/components/chat/CopilotChatAudioRecorder.tsx:59:24
65
- at Object.react-stack-bottom-frame (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:23949:20)
66
- at runWithFiberInDEV (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:1522:13)
67
- at commitHookEffectListMount (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:11905:29)
68
- at commitHookPassiveMountEffects (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:12028:11)
69
- at commitPassiveMountOnFiber (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:13841:13)
70
- at recursivelyTraversePassiveMountEffects (/Users/mme/Code/vnext_experimental/node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-client.development.js:13815:11) undefined
71
-
72
- ✓ src/components/chat/__tests__/CopilotChatInput.test.tsx (24 tests) 491ms
73
- ✓ src/components/chat/__tests__/CopilotChatAssistantMessage.test.tsx (32 tests) 728ms
74
-
75
- Test Files 6 passed (6)
76
- Tests 181 passed (181)
77
- Start at 10:13:52
78
- Duration 4.92s (transform 1.38s, setup 108ms, collect 5.28s, tests 1.93s, environment 7.81s, prepare 4.84s)
79
-
package/postcss.config.js DELETED
@@ -1,7 +0,0 @@
1
- /** @type {import('postcss-load-config').Config} */
2
- const config = {
3
- plugins: { "@tailwindcss/postcss": {} },
4
- };
5
-
6
- // eslint-disable-next-line no-undef
7
- module.exports = config;
@@ -1,2 +0,0 @@
1
- // Test setup file for Vitest
2
- // Add any global test configuration here
@@ -1,90 +0,0 @@
1
- import { useAgent } from "@/hooks/use-agent";
2
- import { CopilotChatView, CopilotChatViewProps } from "./CopilotChatView";
3
- import { CopilotChatConfigurationProvider } from "@/providers/CopilotChatConfigurationProvider";
4
- import { DEFAULT_AGENT_ID, randomUUID } from "@copilotkitnext/shared";
5
- import { useCallback, useState, useEffect, useMemo } from "react";
6
- import { merge } from "ts-deepmerge";
7
-
8
- export type CopilotChatProps = Omit<CopilotChatViewProps, "messages"> & {
9
- agentId?: string;
10
- threadId?: string;
11
- };
12
-
13
- export function CopilotChat({
14
- agentId = DEFAULT_AGENT_ID,
15
- threadId,
16
- ...props
17
- }: CopilotChatProps) {
18
- const { agent } = useAgent({ agentId });
19
- const [isLoading, setIsLoading] = useState(false);
20
- threadId = threadId ?? useMemo(() => randomUUID(), []);
21
-
22
- const subscriber = {
23
- onTextMessageStartEvent: () => setIsLoading(false),
24
- onToolCallStartEvent: () => setIsLoading(false),
25
- };
26
-
27
- useEffect(() => {
28
- const connect = async () => {
29
- setIsLoading(true);
30
- await agent?.runAgent(
31
- {
32
- forwardedProps: { __copilotkitConnect: true },
33
- },
34
- subscriber
35
- );
36
- setIsLoading(false);
37
- };
38
- if (agent) {
39
- agent.threadId = threadId;
40
- if ("isCopilotKitAgent" in agent) {
41
- connect();
42
- } else {
43
- setIsLoading(false);
44
- }
45
- }
46
- return () => {};
47
- }, [threadId, agent]);
48
-
49
- const [inputValue, setInputValue] = useState("");
50
- const onSubmitInput = useCallback(
51
- async (value: string) => {
52
- setInputValue("");
53
- agent?.addMessage({
54
- id: randomUUID(),
55
- role: "user",
56
- content: value,
57
- });
58
- setIsLoading(true);
59
- await agent?.runAgent({}, subscriber);
60
- setIsLoading(false);
61
- },
62
- [agent]
63
- );
64
-
65
- const mergedProps = merge(
66
- {
67
- messageView: { isLoading },
68
- },
69
- {
70
- ...props,
71
- ...(typeof props.messageView === "string"
72
- ? { messageView: { className: props.messageView } }
73
- : props.messageView !== undefined
74
- ? { messageView: props.messageView }
75
- : {}),
76
- }
77
- );
78
-
79
- return (
80
- <CopilotChatConfigurationProvider
81
- inputValue={inputValue}
82
- onSubmitInput={onSubmitInput}
83
- onChangeInput={setInputValue}
84
- >
85
- <CopilotChatView
86
- {...{ messages: agent?.messages ?? [], ...mergedProps }}
87
- />
88
- </CopilotChatConfigurationProvider>
89
- );
90
- }