@copilotkit/react-core 1.6.0-next.0 → 1.6.0-next.1

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.
package/dist/index.mjs CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  } from "./chunk-ZAU4EMBM.mjs";
11
11
  import {
12
12
  useLangGraphInterrupt
13
- } from "./chunk-7LZQFHNW.mjs";
13
+ } from "./chunk-4ED56DQX.mjs";
14
14
  import {
15
15
  useMakeCopilotDocumentReadable
16
16
  } from "./chunk-XOHLZIZK.mjs";
@@ -1,13 +1,13 @@
1
1
  import { LangGraphInterruptEvent } from '@copilotkit/runtime-client-gql';
2
2
  import { Condition } from '@copilotkit/shared';
3
3
 
4
- interface LangGraphInterruptRender {
4
+ interface LangGraphInterruptRender<TEventValue = any> {
5
5
  id: string;
6
6
  /**
7
7
  * The handler function to handle the event.
8
8
  */
9
9
  handler?: (props: {
10
- event: LangGraphInterruptEvent;
10
+ event: LangGraphInterruptEvent<TEventValue>;
11
11
  resolve: (resolution: string) => void;
12
12
  }) => unknown | Promise<unknown>;
13
13
  /**
@@ -15,7 +15,7 @@ interface LangGraphInterruptRender {
15
15
  */
16
16
  render?: (props: {
17
17
  result: unknown;
18
- event: LangGraphInterruptEvent;
18
+ event: LangGraphInterruptEvent<TEventValue>;
19
19
  resolve: (resolution: string) => void;
20
20
  }) => string | React.ReactElement;
21
21
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/interrupt-action.ts"],"sourcesContent":["import { LangGraphInterruptEvent } from \"@copilotkit/runtime-client-gql\";\nimport { Condition } from \"@copilotkit/shared\";\n\nexport interface LangGraphInterruptRender {\n id: string;\n /**\n * The handler function to handle the event.\n */\n handler?: (props: {\n event: LangGraphInterruptEvent;\n resolve: (resolution: string) => void;\n }) => unknown | Promise<unknown>;\n /**\n * The render function to handle the event.\n */\n render?: (props: {\n result: unknown;\n event: LangGraphInterruptEvent;\n resolve: (resolution: string) => void;\n }) => string | React.ReactElement;\n /**\n * Conditions to render based on.\n * Useful when using multiple interrupts\n */\n conditions?: Condition[];\n}\n\nexport type LangGraphInterruptAction = LangGraphInterruptRender & {\n event?: LangGraphInterruptEvent;\n};\n\nexport type LangGraphInterruptActionSetterArgs =\n | (Partial<LangGraphInterruptRender> & { event?: Partial<LangGraphInterruptEvent> })\n | null;\nexport type LangGraphInterruptActionSetter = (action: LangGraphInterruptActionSetterArgs) => void;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/interrupt-action.ts"],"sourcesContent":["import { LangGraphInterruptEvent } from \"@copilotkit/runtime-client-gql\";\nimport { Condition } from \"@copilotkit/shared\";\n\nexport interface LangGraphInterruptRender<TEventValue = any> {\n id: string;\n /**\n * The handler function to handle the event.\n */\n handler?: (props: {\n event: LangGraphInterruptEvent<TEventValue>;\n resolve: (resolution: string) => void;\n }) => unknown | Promise<unknown>;\n /**\n * The render function to handle the event.\n */\n render?: (props: {\n result: unknown;\n event: LangGraphInterruptEvent<TEventValue>;\n resolve: (resolution: string) => void;\n }) => string | React.ReactElement;\n /**\n * Conditions to render based on.\n * Useful when using multiple interrupts\n */\n conditions?: Condition[];\n}\n\nexport type LangGraphInterruptAction = LangGraphInterruptRender & {\n event?: LangGraphInterruptEvent;\n};\n\nexport type LangGraphInterruptActionSetterArgs =\n | (Partial<LangGraphInterruptRender> & { event?: Partial<LangGraphInterruptEvent> })\n | null;\nexport type LangGraphInterruptActionSetter = (action: LangGraphInterruptActionSetterArgs) => void;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
12
- "version": "1.6.0-next.0",
12
+ "version": "1.6.0-next.1",
13
13
  "sideEffects": false,
14
14
  "main": "./dist/index.js",
15
15
  "module": "./dist/index.mjs",
@@ -43,8 +43,8 @@
43
43
  "@scarf/scarf": "^1.3.0",
44
44
  "react-markdown": "^8.0.7",
45
45
  "untruncate-json": "^0.0.1",
46
- "@copilotkit/runtime-client-gql": "1.6.0-next.0",
47
- "@copilotkit/shared": "1.6.0-next.0"
46
+ "@copilotkit/runtime-client-gql": "1.6.0-next.1",
47
+ "@copilotkit/shared": "1.6.0-next.1"
48
48
  },
49
49
  "keywords": [
50
50
  "copilotkit",
@@ -5,8 +5,8 @@ import { useCopilotChat } from "./use-copilot-chat";
5
5
  import { useToast } from "../components/toast/toast-provider";
6
6
  import { dataToUUID } from "@copilotkit/shared";
7
7
 
8
- export function useLangGraphInterrupt(
9
- action: Omit<LangGraphInterruptRender, "id">,
8
+ export function useLangGraphInterrupt<TEventValue = any>(
9
+ action: Omit<LangGraphInterruptRender<TEventValue>, "id">,
10
10
  dependencies?: any[],
11
11
  ) {
12
12
  const { setLangGraphInterruptAction, removeLangGraphInterruptAction, langGraphInterruptAction } =
@@ -1,13 +1,13 @@
1
1
  import { LangGraphInterruptEvent } from "@copilotkit/runtime-client-gql";
2
2
  import { Condition } from "@copilotkit/shared";
3
3
 
4
- export interface LangGraphInterruptRender {
4
+ export interface LangGraphInterruptRender<TEventValue = any> {
5
5
  id: string;
6
6
  /**
7
7
  * The handler function to handle the event.
8
8
  */
9
9
  handler?: (props: {
10
- event: LangGraphInterruptEvent;
10
+ event: LangGraphInterruptEvent<TEventValue>;
11
11
  resolve: (resolution: string) => void;
12
12
  }) => unknown | Promise<unknown>;
13
13
  /**
@@ -15,7 +15,7 @@ export interface LangGraphInterruptRender {
15
15
  */
16
16
  render?: (props: {
17
17
  result: unknown;
18
- event: LangGraphInterruptEvent;
18
+ event: LangGraphInterruptEvent<TEventValue>;
19
19
  resolve: (resolution: string) => void;
20
20
  }) => string | React.ReactElement;
21
21
  /**
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/hooks/use-langgraph-interrupt.ts"],"sourcesContent":["import { useContext, useEffect, useMemo } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { LangGraphInterruptRender } from \"../types/interrupt-action\";\nimport { useCopilotChat } from \"./use-copilot-chat\";\nimport { useToast } from \"../components/toast/toast-provider\";\nimport { dataToUUID } from \"@copilotkit/shared\";\n\nexport function useLangGraphInterrupt(\n action: Omit<LangGraphInterruptRender, \"id\">,\n dependencies?: any[],\n) {\n const { setLangGraphInterruptAction, removeLangGraphInterruptAction, langGraphInterruptAction } =\n useContext(CopilotContext);\n const { runChatCompletion } = useCopilotChat();\n const { addToast } = useToast();\n\n const actionId = dataToUUID(JSON.stringify(action), \"lgAction\");\n // We only consider action to be defined once the ID is there\n const hasAction = useMemo(\n () => Boolean(langGraphInterruptAction?.id),\n [langGraphInterruptAction],\n );\n\n const isCurrentAction = useMemo(\n () => langGraphInterruptAction?.id && langGraphInterruptAction?.id === actionId,\n [langGraphInterruptAction],\n );\n\n // Run chat completion to submit a response event. Only if it's the current action\n useEffect(() => {\n if (hasAction && isCurrentAction && langGraphInterruptAction?.event?.response) {\n runChatCompletion();\n }\n }, [langGraphInterruptAction?.event?.response, runChatCompletion, hasAction, isCurrentAction]);\n\n useEffect(() => {\n if (!action) return;\n // console.log(2, { hasAction, isCurrentAction, conditions: action.conditions })\n // An action was already set, with no conditions and it's not the action we're using right now.\n // Show a warning, as this action will not be executed\n if (hasAction && !isCurrentAction && !action.conditions?.length) {\n addToast({\n type: \"warning\",\n message: \"An action is already registered for the interrupt event\",\n });\n return;\n }\n\n if (hasAction && isCurrentAction) {\n return;\n }\n\n setLangGraphInterruptAction({ ...action, id: actionId });\n }, [\n action,\n hasAction,\n isCurrentAction,\n setLangGraphInterruptAction,\n removeLangGraphInterruptAction,\n ...(dependencies || []),\n ]);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,YAAY,WAAW,eAAe;AAK/C,SAAS,kBAAkB;AAEpB,SAAS,sBACd,QACA,cACA;AAVF;AAWE,QAAM,EAAE,6BAA6B,gCAAgC,yBAAyB,IAC5F,WAAW,cAAc;AA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