@copilotkit/sdk-js 1.75.0 → 1.75.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.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.mts","names":[],"sources":["../../src/langgraph/utils.ts"],"mappings":";;;;;;;AA4KA;;;;;;;;;;;;;;;AAwHA;;;;;;;;;AAmCA;;;;;;;;;;AAoDA;;;;;;iBA/MgB,yBAAA;;;;AAId,UAAA,EAAY,cAAA;;;;;;;;;;;;AAYZ,OAAA,GAAU,aAAA,GACT,cAAA;AAmUH;;;;;AA0DA;;;;;AAyBA;;;;;AAnFA,iBA5NsB,cAAA;;;;AAIpB,MAAA,EAAQ,cAAA,GAAc,OAAA;;;;;;;;;;;;;;;;iBA+BF,mBAAA;;;;AAIpB,MAAA,EAAQ,cAAA;;;;AAIR,KAAA,QAAU,OAAA;;;;;;;;;;;;;;;;;;;iBA4CU,qBAAA;;;;AAIpB,MAAA,EAAQ,cAAA;;;;AAIR,OAAA,WAAe,OAAA;;;;;;;;;;;;;;;;;;iBA2CK,sBAAA;;;;AAIpB,MAAA,EAAQ,cAAA;;;;AAIR,IAAA;;;;AAIA,IAAA;;;;AAIA,OAAA;;;;;;EAME,UAAA;AAAA,IAED,OAAA;AAAA,iBA0Da,oCAAA,CACd,WAAA,QACC,qBAAA;;;;;;;;;;;;;iBAwDa,sCAAA;;;;AAId,OAAA,UACC,qBAAA;AAAA,iBAoBa,mBAAA,CAAA;EACd,OAAA;EACA,MAAA;EACA;AAAA;EAEA,OAAA;EACA,MAAA;EACA,IAAA,GAAO,MAAA;AAAA"}
1
+ {"version":3,"file":"utils.d.mts","names":[],"sources":["../../src/langgraph/utils.ts"],"mappings":";;;;;;;AAuDA;;;;;;;;;;;;;;;AAwHA;;;;;;;;;AAmCA;;;;;;;;;;AAoDA;;;;;;iBA/MgB,yBAAA;;;;AAId,UAAA,EAAY,cAAA;;;;;;;;;;;;AAYZ,OAAA,GAAU,aAAA,GACT,cAAA;AAmUH;;;;;AA0DA;;;;;AAyBA;;;;;AAnFA,iBA5NsB,cAAA;;;;AAIpB,MAAA,EAAQ,cAAA,GAAc,OAAA;;;;;;;;;;;;;;;;iBA+BF,mBAAA;;;;AAIpB,MAAA,EAAQ,cAAA;;;;AAIR,KAAA,QAAU,OAAA;;;;;;;;;;;;;;;;;;;iBA4CU,qBAAA;;;;AAIpB,MAAA,EAAQ,cAAA;;;;AAIR,OAAA,WAAe,OAAA;;;;;;;;;;;;;;;;;;iBA2CK,sBAAA;;;;AAIpB,MAAA,EAAQ,cAAA;;;;AAIR,IAAA;;;;AAIA,IAAA;;;;AAIA,OAAA;;;;;;EAME,UAAA;AAAA,IAED,OAAA;AAAA,iBA0Da,oCAAA,CACd,WAAA,QACC,qBAAA;;;;;;;;;;;;;iBAwDa,sCAAA;;;;AAId,OAAA,UACC,qBAAA;AAAA,iBAoBa,mBAAA,CAAA;EACd,OAAA;EACA,MAAA;EACA;AAAA;EAEA,OAAA;EACA,MAAA;EACA,IAAA,GAAO,MAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","names":[],"sources":["../../src/langgraph/utils.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/sdk-js/langchain — convertActionsToDynamicStructuredTools:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/sdk-js/langchain — convertActionToDynamicStructuredTool:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/sdk-js/langchain — copilotKitCustomizeConfig:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/sdk-js/langchain — copilotKitEmitMessage:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/sdk-js/langchain — copilotKitEmitState:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/sdk-js/langchain — copilotKitEmitToolCall:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/sdk-js/langchain — copilotKitExit:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/sdk-js/langgraph — convertActionsToDynamicStructuredTools:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/sdk-js/langgraph — convertActionToDynamicStructuredTool:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/sdk-js/langgraph — copilotkitCustomizeConfig:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/sdk-js/langgraph — copilotkitEmitMessage:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/sdk-js/langgraph — copilotkitEmitState:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/sdk-js/langgraph — copilotkitEmitToolCall:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/sdk-js/langgraph — copilotkitExit:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/sdk-js/langgraph — copilotKitInterrupt:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport type { RunnableConfig } from \"@langchain/core/runnables\";\nimport { dispatchCustomEvent } from \"@langchain/core/callbacks/dispatch\";\nimport {\n convertJsonSchemaToZodSchema,\n randomId,\n randomUUID,\n CopilotKitMisuseError,\n} from \"@copilotkit/shared\";\nimport { interrupt } from \"@langchain/langgraph\";\nimport { DynamicStructuredTool } from \"@langchain/core/tools\";\nimport { AIMessage } from \"@langchain/core/messages\";\nimport type { OptionsConfig } from \"./types\";\n\n/**\n * Customize the LangGraph configuration for use in CopilotKit.\n *\n * To the CopilotKit SDK, run:\n *\n * ```bash\n * npm install @copilotkit/sdk-js\n * ```\n *\n * ### Examples\n *\n * Disable emitting messages and tool calls:\n *\n * ```typescript\n * import { copilotkitCustomizeConfig } from \"@copilotkit/sdk-js\";\n *\n * config = copilotkitCustomizeConfig(\n * config,\n * emitMessages=false,\n * emitToolCalls=false\n * )\n * ```\n *\n * To emit a tool call as streaming LangGraph state, pass the destination key in state,\n * the tool name and optionally the tool argument. (If you don't pass the argument name,\n * all arguments are emitted under the state key.)\n *\n * ```typescript\n * import { copilotkitCustomizeConfig } from \"@copilotkit/sdk-js\";\n *\n * config = copilotkitCustomizeConfig(\n * config,\n * emitIntermediateState=[\n * {\n * \"stateKey\": \"steps\",\n * \"tool\": \"SearchTool\",\n * \"toolArgument\": \"steps\",\n * },\n * ],\n * )\n * ```\n */\nexport function copilotkitCustomizeConfig(\n /**\n * The LangChain/LangGraph configuration to customize.\n */\n baseConfig: RunnableConfig,\n /**\n * Configuration options:\n * - `emitMessages: boolean?`\n * Configure how messages are emitted. By default, all messages are emitted. Pass false to\n * disable emitting messages.\n * - `emitToolCalls: boolean | string | string[]?`\n * Configure how tool calls are emitted. By default, all tool calls are emitted. Pass false to\n * disable emitting tool calls. Pass a string or list of strings to emit only specific tool calls.\n * - `emitIntermediateState: IntermediateStateConfig[]?`\n * Lets you emit tool calls as streaming LangGraph state.\n */\n options?: OptionsConfig,\n): RunnableConfig {\n if (baseConfig && typeof baseConfig !== \"object\") {\n throw new CopilotKitMisuseError({\n message: \"baseConfig must be an object or null/undefined\",\n });\n }\n\n if (options && typeof options !== \"object\") {\n throw new CopilotKitMisuseError({\n message: \"options must be an object when provided\",\n });\n }\n\n // Validate emitIntermediateState structure\n if (options?.emitIntermediateState) {\n if (!Array.isArray(options.emitIntermediateState)) {\n throw new CopilotKitMisuseError({\n message: \"emitIntermediateState must be an array when provided\",\n });\n }\n\n options.emitIntermediateState.forEach((state, index) => {\n if (!state || typeof state !== \"object\") {\n throw new CopilotKitMisuseError({\n message: `emitIntermediateState[${index}] must be an object`,\n });\n }\n\n if (!state.stateKey || typeof state.stateKey !== \"string\") {\n throw new CopilotKitMisuseError({\n message: `emitIntermediateState[${index}] must have a valid 'stateKey' string property`,\n });\n }\n\n if (!state.tool || typeof state.tool !== \"string\") {\n throw new CopilotKitMisuseError({\n message: `emitIntermediateState[${index}] must have a valid 'tool' string property`,\n });\n }\n\n if (state.toolArgument && typeof state.toolArgument !== \"string\") {\n throw new CopilotKitMisuseError({\n message: `emitIntermediateState[${index}].toolArgument must be a string when provided`,\n });\n }\n });\n }\n\n try {\n const metadata = baseConfig?.metadata || {};\n\n if (options?.emitAll) {\n metadata[\"copilotkit:emit-tool-calls\"] = true;\n metadata[\"copilotkit:emit-messages\"] = true;\n } else {\n if (options?.emitToolCalls !== undefined) {\n metadata[\"copilotkit:emit-tool-calls\"] = options.emitToolCalls;\n }\n if (options?.emitMessages !== undefined) {\n metadata[\"copilotkit:emit-messages\"] = options.emitMessages;\n }\n }\n\n if (options?.emitIntermediateState) {\n const snakeCaseIntermediateState = options.emitIntermediateState.map(\n (state) => ({\n tool: state.tool,\n tool_argument: state.toolArgument,\n state_key: state.stateKey,\n }),\n );\n\n metadata[\"copilotkit:emit-intermediate-state\"] =\n snakeCaseIntermediateState;\n }\n\n baseConfig = baseConfig || {};\n\n return {\n ...baseConfig,\n metadata: metadata,\n };\n } catch (error) {\n throw new CopilotKitMisuseError({\n message: `Failed to customize config: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n}\n/**\n * Exits the current agent after the run completes. Calling copilotkit_exit() will\n * not immediately stop the agent. Instead, it signals to CopilotKit to stop the agent after\n * the run completes.\n *\n * ### Examples\n *\n * ```typescript\n * import { copilotkitExit } from \"@copilotkit/sdk-js\";\n *\n * async function myNode(state: Any):\n * await copilotkitExit(config)\n * return state\n * ```\n */\nexport async function copilotkitExit(\n /**\n * The LangChain/LangGraph configuration.\n */\n config: RunnableConfig,\n) {\n if (!config) {\n throw new CopilotKitMisuseError({\n message: \"LangGraph configuration is required for copilotkitExit\",\n });\n }\n\n try {\n await dispatchCustomEvent(\"copilotkit_exit\", {}, config);\n } catch (error) {\n throw new CopilotKitMisuseError({\n message: `Failed to dispatch exit event: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n}\n/**\n * Emits intermediate state to CopilotKit. Useful if you have a longer running node and you want to\n * update the user with the current state of the node.\n *\n * ### Examples\n *\n * ```typescript\n * import { copilotkitEmitState } from \"@copilotkit/sdk-js\";\n *\n * for (let i = 0; i < 10; i++) {\n * await someLongRunningOperation(i);\n * await copilotkitEmitState(config, { progress: i });\n * }\n * ```\n */\nexport async function copilotkitEmitState(\n /**\n * The LangChain/LangGraph configuration.\n */\n config: RunnableConfig,\n /**\n * The state to emit.\n */\n state: any,\n) {\n if (!config) {\n throw new CopilotKitMisuseError({\n message: \"LangGraph configuration is required for copilotkitEmitState\",\n });\n }\n\n if (state === undefined) {\n throw new CopilotKitMisuseError({\n message: \"State is required for copilotkitEmitState\",\n });\n }\n\n try {\n await dispatchCustomEvent(\n \"copilotkit_manually_emit_intermediate_state\",\n state,\n config,\n );\n } catch (error) {\n throw new CopilotKitMisuseError({\n message: `Failed to emit state: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n}\n/**\n * Manually emits a message to CopilotKit. Useful in longer running nodes to update the user.\n * Important: You still need to return the messages from the node.\n *\n * ### Examples\n *\n * ```typescript\n * import { copilotkitEmitMessage } from \"@copilotkit/sdk-js\";\n *\n * const message = \"Step 1 of 10 complete\";\n * await copilotkitEmitMessage(config, message);\n *\n * // Return the message from the node\n * return {\n * \"messages\": [AIMessage(content=message)]\n * }\n * ```\n */\nexport async function copilotkitEmitMessage(\n /**\n * The LangChain/LangGraph configuration.\n */\n config: RunnableConfig,\n /**\n * The message to emit.\n */\n message: string,\n) {\n if (!config) {\n throw new CopilotKitMisuseError({\n message: \"LangGraph configuration is required for copilotkitEmitMessage\",\n });\n }\n\n if (!message || typeof message !== \"string\") {\n throw new CopilotKitMisuseError({\n message: \"Message must be a non-empty string for copilotkitEmitMessage\",\n });\n }\n\n try {\n await dispatchCustomEvent(\n \"copilotkit_manually_emit_message\",\n { message, message_id: randomId(), role: \"assistant\" },\n config,\n );\n } catch (error) {\n throw new CopilotKitMisuseError({\n message: `Failed to emit message: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n}\n/**\n * Manually emits a tool call to CopilotKit.\n *\n * ### Examples\n *\n * ```typescript\n * import { copilotkitEmitToolCall } from \"@copilotkit/sdk-js\";\n *\n * const autoId = await copilotkitEmitToolCall(config, \"SearchTool\", { steps: 10 });\n *\n * // With a custom ID for correlation/idempotency:\n * const customId = await copilotkitEmitToolCall(config, \"SearchTool\", { steps: 10 }, { toolCallId: \"my-custom-id\" });\n * ```\n *\n * @returns The tool call ID used for the emitted call — equals `options.toolCallId`\n * when provided, otherwise a randomly generated ID.\n */\nexport async function copilotkitEmitToolCall(\n /**\n * The LangChain/LangGraph configuration.\n */\n config: RunnableConfig,\n /**\n * The name of the tool to emit.\n */\n name: string,\n /**\n * The arguments to emit.\n */\n args: any,\n /**\n * Options for the tool call emission.\n */\n options?: {\n /**\n * Optional tool call ID. If not provided, a random ID is generated.\n * When provided, this ID is used as the toolCallId and parentMessageId\n * in AG-UI protocol events. The caller is responsible for ensuring uniqueness.\n */\n toolCallId?: string;\n },\n): Promise<string> {\n if (!config) {\n throw new CopilotKitMisuseError({\n message: \"LangGraph configuration is required for copilotkitEmitToolCall\",\n });\n }\n\n if (typeof name !== \"string\" || name.trim().length === 0) {\n throw new CopilotKitMisuseError({\n message:\n \"Tool name must be a non-empty string for copilotkitEmitToolCall\",\n });\n }\n\n if (\n options?.toolCallId !== undefined &&\n (typeof options.toolCallId !== \"string\" ||\n options.toolCallId.trim().length === 0)\n ) {\n throw new CopilotKitMisuseError({\n message:\n \"Tool call id must be a non-empty string when provided for copilotkitEmitToolCall\",\n });\n }\n\n if (args === undefined) {\n throw new CopilotKitMisuseError({\n message: \"Tool arguments are required for copilotkitEmitToolCall\",\n });\n }\n\n try {\n JSON.stringify(args);\n } catch (error) {\n throw new CopilotKitMisuseError({\n message: `Tool arguments for '${name}' are not JSON-serializable: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n\n const toolCallId = options?.toolCallId ?? randomUUID();\n\n try {\n await dispatchCustomEvent(\n \"copilotkit_manually_emit_tool_call\",\n { name, args, id: toolCallId },\n config,\n );\n } catch (error) {\n const wrapped = new Error(\n `copilotkitEmitToolCall dispatch failed for tool=\"${name}\" id=\"${toolCallId}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n (wrapped as any).cause = error;\n throw wrapped;\n }\n\n return toolCallId;\n}\n\nexport function convertActionToDynamicStructuredTool(\n actionInput: any,\n): DynamicStructuredTool<any> {\n if (!actionInput) {\n throw new CopilotKitMisuseError({\n message: \"Action input is required but was not provided\",\n });\n }\n\n if (!actionInput.name || typeof actionInput.name !== \"string\") {\n throw new CopilotKitMisuseError({\n message: \"Action must have a valid 'name' property of type string\",\n });\n }\n\n if (\n actionInput.description == undefined ||\n actionInput.description == null ||\n typeof actionInput.description !== \"string\"\n ) {\n throw new CopilotKitMisuseError({\n message: `Action '${actionInput.name}' must have a valid 'description' property of type string`,\n });\n }\n\n if (!actionInput.parameters) {\n throw new CopilotKitMisuseError({\n message: `Action '${actionInput.name}' must have a 'parameters' property`,\n });\n }\n\n try {\n return new DynamicStructuredTool({\n name: actionInput.name,\n description: actionInput.description,\n schema: convertJsonSchemaToZodSchema(actionInput.parameters, true),\n func: async () => {\n return \"\";\n },\n });\n } catch (error) {\n throw new CopilotKitMisuseError({\n message: `Failed to convert action '${actionInput.name}' to DynamicStructuredTool: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n}\n/**\n * Use this function to convert a list of actions you get from state\n * to a list of dynamic structured tools.\n *\n * ### Examples\n *\n * ```typescript\n * import { convertActionsToDynamicStructuredTools } from \"@copilotkit/sdk-js\";\n *\n * const tools = convertActionsToDynamicStructuredTools(state.copilotkit.actions);\n * ```\n */\nexport function convertActionsToDynamicStructuredTools(\n /**\n * The list of actions to convert.\n */\n actions: any[],\n): DynamicStructuredTool<any>[] {\n if (!Array.isArray(actions)) {\n throw new CopilotKitMisuseError({\n message: \"Actions must be an array\",\n });\n }\n\n return actions.map((action, index) => {\n try {\n return convertActionToDynamicStructuredTool(\n action.type === \"function\" ? action.function : action,\n );\n } catch (error) {\n throw new CopilotKitMisuseError({\n message: `Failed to convert action at index ${index}: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n });\n}\n\nexport function copilotKitInterrupt({\n message,\n action,\n args,\n}: {\n message?: string;\n action?: string;\n args?: Record<string, any>;\n}) {\n if (!message && !action) {\n throw new CopilotKitMisuseError({\n message:\n \"Either message or action (and optional arguments) must be provided for copilotKitInterrupt\",\n });\n }\n\n if (action && typeof action !== \"string\") {\n throw new CopilotKitMisuseError({\n message: \"Action must be a string when provided to copilotKitInterrupt\",\n });\n }\n\n if (message && typeof message !== \"string\") {\n throw new CopilotKitMisuseError({\n message: \"Message must be a string when provided to copilotKitInterrupt\",\n });\n }\n\n if (args && typeof args !== \"object\") {\n throw new CopilotKitMisuseError({\n message: \"Args must be an object when provided to copilotKitInterrupt\",\n });\n }\n\n let interruptValues = null;\n let interruptMessage = null;\n let answer = null;\n\n try {\n if (message) {\n interruptValues = message;\n interruptMessage = new AIMessage({ content: message, id: randomId() });\n } else {\n const toolId = randomId();\n interruptMessage = new AIMessage({\n content: \"\",\n tool_calls: [{ id: toolId, name: action, args: args ?? {} }],\n });\n interruptValues = {\n action,\n args: args ?? {},\n };\n }\n\n const response = interrupt({\n __copilotkit_interrupt_value__: interruptValues,\n __copilotkit_messages__: [interruptMessage],\n });\n answer = response[response.length - 1].content;\n\n return {\n answer,\n messages: response,\n };\n } catch (error) {\n throw new CopilotKitMisuseError({\n message: `Failed to create interrupt: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4KA,SAAgB,0BAId,YAYA,SACgB;AAChB,KAAI,cAAc,OAAO,eAAe,SACtC,OAAM,IAAI,sBAAsB,EAC9B,SAAS,kDACV,CAAC;AAGJ,KAAI,WAAW,OAAO,YAAY,SAChC,OAAM,IAAI,sBAAsB,EAC9B,SAAS,2CACV,CAAC;AAIJ,KAAI,SAAS,uBAAuB;AAClC,MAAI,CAAC,MAAM,QAAQ,QAAQ,sBAAsB,CAC/C,OAAM,IAAI,sBAAsB,EAC9B,SAAS,wDACV,CAAC;AAGJ,UAAQ,sBAAsB,SAAS,OAAO,UAAU;AACtD,OAAI,CAAC,SAAS,OAAO,UAAU,SAC7B,OAAM,IAAI,sBAAsB,EAC9B,SAAS,yBAAyB,MAAM,sBACzC,CAAC;AAGJ,OAAI,CAAC,MAAM,YAAY,OAAO,MAAM,aAAa,SAC/C,OAA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langgraph/utils.ts"],"sourcesContent":["import type { RunnableConfig } from \"@langchain/core/runnables\";\nimport { dispatchCustomEvent } from \"@langchain/core/callbacks/dispatch\";\nimport {\n convertJsonSchemaToZodSchema,\n randomId,\n randomUUID,\n CopilotKitMisuseError,\n} from \"@copilotkit/shared\";\nimport { interrupt } from \"@langchain/langgraph\";\nimport { DynamicStructuredTool } from \"@langchain/core/tools\";\nimport { AIMessage } from \"@langchain/core/messages\";\nimport type { OptionsConfig } from \"./types\";\n\n/**\n * Customize the LangGraph configuration for use in CopilotKit.\n *\n * To the CopilotKit SDK, run:\n *\n * ```bash\n * npm install @copilotkit/sdk-js\n * ```\n *\n * ### Examples\n *\n * Disable emitting messages and tool calls:\n *\n * ```typescript\n * import { copilotkitCustomizeConfig } from \"@copilotkit/sdk-js\";\n *\n * config = copilotkitCustomizeConfig(\n * config,\n * emitMessages=false,\n * emitToolCalls=false\n * )\n * ```\n *\n * To emit a tool call as streaming LangGraph state, pass the destination key in state,\n * the tool name and optionally the tool argument. (If you don't pass the argument name,\n * all arguments are emitted under the state key.)\n *\n * ```typescript\n * import { copilotkitCustomizeConfig } from \"@copilotkit/sdk-js\";\n *\n * config = copilotkitCustomizeConfig(\n * config,\n * emitIntermediateState=[\n * {\n * \"stateKey\": \"steps\",\n * \"tool\": \"SearchTool\",\n * \"toolArgument\": \"steps\",\n * },\n * ],\n * )\n * ```\n */\nexport function copilotkitCustomizeConfig(\n /**\n * The LangChain/LangGraph configuration to customize.\n */\n baseConfig: RunnableConfig,\n /**\n * Configuration options:\n * - `emitMessages: boolean?`\n * Configure how messages are emitted. By default, all messages are emitted. Pass false to\n * disable emitting messages.\n * - `emitToolCalls: boolean | string | string[]?`\n * Configure how tool calls are emitted. By default, all tool calls are emitted. Pass false to\n * disable emitting tool calls. Pass a string or list of strings to emit only specific tool calls.\n * - `emitIntermediateState: IntermediateStateConfig[]?`\n * Lets you emit tool calls as streaming LangGraph state.\n */\n options?: OptionsConfig,\n): RunnableConfig {\n if (baseConfig && typeof baseConfig !== \"object\") {\n throw new CopilotKitMisuseError({\n message: \"baseConfig must be an object or null/undefined\",\n });\n }\n\n if (options && typeof options !== \"object\") {\n throw new CopilotKitMisuseError({\n message: \"options must be an object when provided\",\n });\n }\n\n // Validate emitIntermediateState structure\n if (options?.emitIntermediateState) {\n if (!Array.isArray(options.emitIntermediateState)) {\n throw new CopilotKitMisuseError({\n message: \"emitIntermediateState must be an array when provided\",\n });\n }\n\n options.emitIntermediateState.forEach((state, index) => {\n if (!state || typeof state !== \"object\") {\n throw new CopilotKitMisuseError({\n message: `emitIntermediateState[${index}] must be an object`,\n });\n }\n\n if (!state.stateKey || typeof state.stateKey !== \"string\") {\n throw new CopilotKitMisuseError({\n message: `emitIntermediateState[${index}] must have a valid 'stateKey' string property`,\n });\n }\n\n if (!state.tool || typeof state.tool !== \"string\") {\n throw new CopilotKitMisuseError({\n message: `emitIntermediateState[${index}] must have a valid 'tool' string property`,\n });\n }\n\n if (state.toolArgument && typeof state.toolArgument !== \"string\") {\n throw new CopilotKitMisuseError({\n message: `emitIntermediateState[${index}].toolArgument must be a string when provided`,\n });\n }\n });\n }\n\n try {\n const metadata = baseConfig?.metadata || {};\n\n if (options?.emitAll) {\n metadata[\"copilotkit:emit-tool-calls\"] = true;\n metadata[\"copilotkit:emit-messages\"] = true;\n } else {\n if (options?.emitToolCalls !== undefined) {\n metadata[\"copilotkit:emit-tool-calls\"] = options.emitToolCalls;\n }\n if (options?.emitMessages !== undefined) {\n metadata[\"copilotkit:emit-messages\"] = options.emitMessages;\n }\n }\n\n if (options?.emitIntermediateState) {\n const snakeCaseIntermediateState = options.emitIntermediateState.map(\n (state) => ({\n tool: state.tool,\n tool_argument: state.toolArgument,\n state_key: state.stateKey,\n }),\n );\n\n metadata[\"copilotkit:emit-intermediate-state\"] =\n snakeCaseIntermediateState;\n }\n\n baseConfig = baseConfig || {};\n\n return {\n ...baseConfig,\n metadata: metadata,\n };\n } catch (error) {\n throw new CopilotKitMisuseError({\n message: `Failed to customize config: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n}\n/**\n * Exits the current agent after the run completes. Calling copilotkit_exit() will\n * not immediately stop the agent. Instead, it signals to CopilotKit to stop the agent after\n * the run completes.\n *\n * ### Examples\n *\n * ```typescript\n * import { copilotkitExit } from \"@copilotkit/sdk-js\";\n *\n * async function myNode(state: Any):\n * await copilotkitExit(config)\n * return state\n * ```\n */\nexport async function copilotkitExit(\n /**\n * The LangChain/LangGraph configuration.\n */\n config: RunnableConfig,\n) {\n if (!config) {\n throw new CopilotKitMisuseError({\n message: \"LangGraph configuration is required for copilotkitExit\",\n });\n }\n\n try {\n await dispatchCustomEvent(\"copilotkit_exit\", {}, config);\n } catch (error) {\n throw new CopilotKitMisuseError({\n message: `Failed to dispatch exit event: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n}\n/**\n * Emits intermediate state to CopilotKit. Useful if you have a longer running node and you want to\n * update the user with the current state of the node.\n *\n * ### Examples\n *\n * ```typescript\n * import { copilotkitEmitState } from \"@copilotkit/sdk-js\";\n *\n * for (let i = 0; i < 10; i++) {\n * await someLongRunningOperation(i);\n * await copilotkitEmitState(config, { progress: i });\n * }\n * ```\n */\nexport async function copilotkitEmitState(\n /**\n * The LangChain/LangGraph configuration.\n */\n config: RunnableConfig,\n /**\n * The state to emit.\n */\n state: any,\n) {\n if (!config) {\n throw new CopilotKitMisuseError({\n message: \"LangGraph configuration is required for copilotkitEmitState\",\n });\n }\n\n if (state === undefined) {\n throw new CopilotKitMisuseError({\n message: \"State is required for copilotkitEmitState\",\n });\n }\n\n try {\n await dispatchCustomEvent(\n \"copilotkit_manually_emit_intermediate_state\",\n state,\n config,\n );\n } catch (error) {\n throw new CopilotKitMisuseError({\n message: `Failed to emit state: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n}\n/**\n * Manually emits a message to CopilotKit. Useful in longer running nodes to update the user.\n * Important: You still need to return the messages from the node.\n *\n * ### Examples\n *\n * ```typescript\n * import { copilotkitEmitMessage } from \"@copilotkit/sdk-js\";\n *\n * const message = \"Step 1 of 10 complete\";\n * await copilotkitEmitMessage(config, message);\n *\n * // Return the message from the node\n * return {\n * \"messages\": [AIMessage(content=message)]\n * }\n * ```\n */\nexport async function copilotkitEmitMessage(\n /**\n * The LangChain/LangGraph configuration.\n */\n config: RunnableConfig,\n /**\n * The message to emit.\n */\n message: string,\n) {\n if (!config) {\n throw new CopilotKitMisuseError({\n message: \"LangGraph configuration is required for copilotkitEmitMessage\",\n });\n }\n\n if (!message || typeof message !== \"string\") {\n throw new CopilotKitMisuseError({\n message: \"Message must be a non-empty string for copilotkitEmitMessage\",\n });\n }\n\n try {\n await dispatchCustomEvent(\n \"copilotkit_manually_emit_message\",\n { message, message_id: randomId(), role: \"assistant\" },\n config,\n );\n } catch (error) {\n throw new CopilotKitMisuseError({\n message: `Failed to emit message: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n}\n/**\n * Manually emits a tool call to CopilotKit.\n *\n * ### Examples\n *\n * ```typescript\n * import { copilotkitEmitToolCall } from \"@copilotkit/sdk-js\";\n *\n * const autoId = await copilotkitEmitToolCall(config, \"SearchTool\", { steps: 10 });\n *\n * // With a custom ID for correlation/idempotency:\n * const customId = await copilotkitEmitToolCall(config, \"SearchTool\", { steps: 10 }, { toolCallId: \"my-custom-id\" });\n * ```\n *\n * @returns The tool call ID used for the emitted call — equals `options.toolCallId`\n * when provided, otherwise a randomly generated ID.\n */\nexport async function copilotkitEmitToolCall(\n /**\n * The LangChain/LangGraph configuration.\n */\n config: RunnableConfig,\n /**\n * The name of the tool to emit.\n */\n name: string,\n /**\n * The arguments to emit.\n */\n args: any,\n /**\n * Options for the tool call emission.\n */\n options?: {\n /**\n * Optional tool call ID. If not provided, a random ID is generated.\n * When provided, this ID is used as the toolCallId and parentMessageId\n * in AG-UI protocol events. The caller is responsible for ensuring uniqueness.\n */\n toolCallId?: string;\n },\n): Promise<string> {\n if (!config) {\n throw new CopilotKitMisuseError({\n message: \"LangGraph configuration is required for copilotkitEmitToolCall\",\n });\n }\n\n if (typeof name !== \"string\" || name.trim().length === 0) {\n throw new CopilotKitMisuseError({\n message:\n \"Tool name must be a non-empty string for copilotkitEmitToolCall\",\n });\n }\n\n if (\n options?.toolCallId !== undefined &&\n (typeof options.toolCallId !== \"string\" ||\n options.toolCallId.trim().length === 0)\n ) {\n throw new CopilotKitMisuseError({\n message:\n \"Tool call id must be a non-empty string when provided for copilotkitEmitToolCall\",\n });\n }\n\n if (args === undefined) {\n throw new CopilotKitMisuseError({\n message: \"Tool arguments are required for copilotkitEmitToolCall\",\n });\n }\n\n try {\n JSON.stringify(args);\n } catch (error) {\n throw new CopilotKitMisuseError({\n message: `Tool arguments for '${name}' are not JSON-serializable: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n\n const toolCallId = options?.toolCallId ?? randomUUID();\n\n try {\n await dispatchCustomEvent(\n \"copilotkit_manually_emit_tool_call\",\n { name, args, id: toolCallId },\n config,\n );\n } catch (error) {\n const wrapped = new Error(\n `copilotkitEmitToolCall dispatch failed for tool=\"${name}\" id=\"${toolCallId}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n (wrapped as any).cause = error;\n throw wrapped;\n }\n\n return toolCallId;\n}\n\nexport function convertActionToDynamicStructuredTool(\n actionInput: any,\n): DynamicStructuredTool<any> {\n if (!actionInput) {\n throw new CopilotKitMisuseError({\n message: \"Action input is required but was not provided\",\n });\n }\n\n if (!actionInput.name || typeof actionInput.name !== \"string\") {\n throw new CopilotKitMisuseError({\n message: \"Action must have a valid 'name' property of type string\",\n });\n }\n\n if (\n actionInput.description == undefined ||\n actionInput.description == null ||\n typeof actionInput.description !== \"string\"\n ) {\n throw new CopilotKitMisuseError({\n message: `Action '${actionInput.name}' must have a valid 'description' property of type string`,\n });\n }\n\n if (!actionInput.parameters) {\n throw new CopilotKitMisuseError({\n message: `Action '${actionInput.name}' must have a 'parameters' property`,\n });\n }\n\n try {\n return new DynamicStructuredTool({\n name: actionInput.name,\n description: actionInput.description,\n schema: convertJsonSchemaToZodSchema(actionInput.parameters, true),\n func: async () => {\n return \"\";\n },\n });\n } catch (error) {\n throw new CopilotKitMisuseError({\n message: `Failed to convert action '${actionInput.name}' to DynamicStructuredTool: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n}\n/**\n * Use this function to convert a list of actions you get from state\n * to a list of dynamic structured tools.\n *\n * ### Examples\n *\n * ```typescript\n * import { convertActionsToDynamicStructuredTools } from \"@copilotkit/sdk-js\";\n *\n * const tools = convertActionsToDynamicStructuredTools(state.copilotkit.actions);\n * ```\n */\nexport function convertActionsToDynamicStructuredTools(\n /**\n * The list of actions to convert.\n */\n actions: any[],\n): DynamicStructuredTool<any>[] {\n if (!Array.isArray(actions)) {\n throw new CopilotKitMisuseError({\n message: \"Actions must be an array\",\n });\n }\n\n return actions.map((action, index) => {\n try {\n return convertActionToDynamicStructuredTool(\n action.type === \"function\" ? action.function : action,\n );\n } catch (error) {\n throw new CopilotKitMisuseError({\n message: `Failed to convert action at index ${index}: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n });\n}\n\nexport function copilotKitInterrupt({\n message,\n action,\n args,\n}: {\n message?: string;\n action?: string;\n args?: Record<string, any>;\n}) {\n if (!message && !action) {\n throw new CopilotKitMisuseError({\n message:\n \"Either message or action (and optional arguments) must be provided for copilotKitInterrupt\",\n });\n }\n\n if (action && typeof action !== \"string\") {\n throw new CopilotKitMisuseError({\n message: \"Action must be a string when provided to copilotKitInterrupt\",\n });\n }\n\n if (message && typeof message !== \"string\") {\n throw new CopilotKitMisuseError({\n message: \"Message must be a string when provided to copilotKitInterrupt\",\n });\n }\n\n if (args && typeof args !== \"object\") {\n throw new CopilotKitMisuseError({\n message: \"Args must be an object when provided to copilotKitInterrupt\",\n });\n }\n\n let interruptValues = null;\n let interruptMessage = null;\n let answer = null;\n\n try {\n if (message) {\n interruptValues = message;\n interruptMessage = new AIMessage({ content: message, id: randomId() });\n } else {\n const toolId = randomId();\n interruptMessage = new AIMessage({\n content: \"\",\n tool_calls: [{ id: toolId, name: action, args: args ?? {} }],\n });\n interruptValues = {\n action,\n args: args ?? {},\n };\n }\n\n const response = interrupt({\n __copilotkit_interrupt_value__: interruptValues,\n __copilotkit_messages__: [interruptMessage],\n });\n answer = response[response.length - 1].content;\n\n return {\n answer,\n messages: response,\n };\n } catch (error) {\n throw new CopilotKitMisuseError({\n message: `Failed to create interrupt: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,SAAgB,0BAId,YAYA,SACgB;AAChB,KAAI,cAAc,OAAO,eAAe,SACtC,OAAM,IAAI,sBAAsB,EAC9B,SAAS,kDACV,CAAC;AAGJ,KAAI,WAAW,OAAO,YAAY,SAChC,OAAM,IAAI,sBAAsB,EAC9B,SAAS,2CACV,CAAC;AAIJ,KAAI,SAAS,uBAAuB;AAClC,MAAI,CAAC,MAAM,QAAQ,QAAQ,sBAAsB,CAC/C,OAAM,IAAI,sBAAsB,EAC9B,SAAS,wDACV,CAAC;AAGJ,UAAQ,sBAAsB,SAAS,OAAO,UAAU;AACtD,OAAI,CAAC,SAAS,OAAO,UAAU,SAC7B,OAAM,IAAI,sBAAsB,EAC9B,SAAS,yBAAyB,MAAM,sBACzC,CAAC;AAGJ,OAAI,CAAC,MAAM,YAAY,OAAO,MAAM,aAAa,SAC/C,OAAM,IAAI,sBAAsB,EAC9B,SAAS,yBAAyB,MAAM,iDACzC,CAAC;AAGJ,OAAI,CAAC,MAAM,QAAQ,OAAO,MAAM,SAAS,SACvC,OAAM,IAAI,sBAAsB,EAC9B,SAAS,yBAAyB,MAAM,6CACzC,CAAC;AAGJ,OAAI,MAAM,gBAAgB,OAAO,MAAM,iBAAiB,SACtD,OAAM,IAAI,sBAAsB,EAC9B,SAAS,yBAAyB,MAAM,gDACzC,CAAC;IAEJ;;AAGJ,KAAI;EACF,MAAM,WAAW,YAAY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,WAAW,SAC9B,OAAM,IAAI,sBAAsB,EAC9B,SAAS,gEACV,CAAC;AAGJ,KAAI,WAAW,OAAO,YAAY,SAChC,OAAM,IAAI,sBAAsB,EAC9B,SAAS,iEACV,CAAC;AAGJ,KAAI,QAAQ,OAAO,SAAS,SAC1B,OAAM,IAAI,sBAAsB,EAC9B,SAAS,+DACV,CAAC;CAGJ,IAAI,kBAAkB;CACtB,IAAI,mBAAmB;CACvB,IAAI,SAAS;AAEb,KAAI;AACF,MAAI,SAAS;AACX,qBAAkB;AAClB,sBAAmB,IAAI,UAAU;IAAE,SAAS;IAAS,IAAI,UAAU;IAAE,CAAC;SACjE;AAEL,sBAAmB,IAAI,UAAU;IAC/B,SAAS;IACT,YAAY,CAAC;KAAE,IAHF,UAAU;KAGI,MAAM;KAAQ,MAAM,QAAQ,EAAE;KAAE,CAAC;IAC7D,CAAC;AACF,qBAAkB;IAChB;IACA,MAAM,QAAQ,EAAE;IACjB;;EAGH,MAAM,WAAW,UAAU;GACzB,gCAAgC;GAChC,yBAAyB,CAAC,iBAAiB;GAC5C,CAAC;AACF,WAAS,SAAS,SAAS,SAAS,GAAG;AAEvC,SAAO;GACL;GACA,UAAU;GACX;UACM,OAAO;AACd,QAAM,IAAI,sBAAsB,EAC9B,SAAS,+BAA+B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IAC/F,CAAC"}
@@ -2,211 +2,4 @@ import { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropert
2
2
  import { convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit } from "./langgraph/utils.cjs";
3
3
  import { ExposeStateOption, copilotkitMiddleware, createCopilotkitMiddleware, zodState } from "./langgraph/middleware.cjs";
4
4
  import { CopilotKitSchemaState, CopilotKitSchemaUpdate, CopilotKitStateSchema } from "./langgraph/state-schema.cjs";
5
- export { /**
6
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
7
- * No 1:1 v2 replacement is available.
8
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
9
- * Start with `@copilotkit/runtime/v2`.
10
- * V2 docs: https://docs.copilotkit.ai/
11
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
12
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
13
- */
14
- type CopilotKitProperties, /**
15
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
16
- * No 1:1 v2 replacement is available.
17
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
18
- * Start with `@copilotkit/runtime/v2`.
19
- * V2 docs: https://docs.copilotkit.ai/
20
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
21
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
22
- */
23
- CopilotKitPropertiesAnnotation, /**
24
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
25
- * No 1:1 v2 replacement is available.
26
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
27
- * Start with `@copilotkit/runtime/v2`.
28
- * V2 docs: https://docs.copilotkit.ai/
29
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
30
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
31
- */
32
- CopilotKitPropertiesSchema, /**
33
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
34
- * No 1:1 v2 replacement is available.
35
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
36
- * Start with `@copilotkit/runtime/v2`.
37
- * V2 docs: https://docs.copilotkit.ai/
38
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
39
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
40
- */
41
- type CopilotKitSchemaState, /**
42
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
43
- * No 1:1 v2 replacement is available.
44
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
45
- * Start with `@copilotkit/runtime/v2`.
46
- * V2 docs: https://docs.copilotkit.ai/
47
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
48
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
49
- */
50
- type CopilotKitSchemaUpdate, /**
51
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
52
- * No 1:1 v2 replacement is available.
53
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
54
- * Start with `@copilotkit/runtime/v2`.
55
- * V2 docs: https://docs.copilotkit.ai/
56
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
57
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
58
- */
59
- type CopilotKitState, /**
60
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
61
- * No 1:1 v2 replacement is available.
62
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
63
- * Start with `@copilotkit/runtime/v2`.
64
- * V2 docs: https://docs.copilotkit.ai/
65
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
66
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
67
- */
68
- CopilotKitStateAnnotation, /**
69
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
70
- * No 1:1 v2 replacement is available.
71
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
72
- * Start with `@copilotkit/runtime/v2`.
73
- * V2 docs: https://docs.copilotkit.ai/
74
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
75
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
76
- */
77
- CopilotKitStateSchema, /**
78
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
79
- * No 1:1 v2 replacement is available.
80
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
81
- * Start with `@copilotkit/runtime/v2`.
82
- * V2 docs: https://docs.copilotkit.ai/
83
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
84
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
85
- */
86
- type ExposeStateOption, /**
87
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
88
- * No 1:1 v2 replacement is available.
89
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
90
- * Start with `@copilotkit/runtime/v2`.
91
- * V2 docs: https://docs.copilotkit.ai/
92
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
93
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
94
- */
95
- type IntermediateStateConfig, /**
96
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
97
- * No 1:1 v2 replacement is available.
98
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
99
- * Start with `@copilotkit/runtime/v2`.
100
- * V2 docs: https://docs.copilotkit.ai/
101
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
102
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
103
- */
104
- type OptionsConfig, /**
105
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
106
- * No 1:1 v2 replacement is available.
107
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
108
- * Start with `@copilotkit/runtime/v2`.
109
- * V2 docs: https://docs.copilotkit.ai/
110
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
111
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
112
- */
113
- type StandardSerializableSchema, /**
114
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
115
- * No 1:1 v2 replacement is available.
116
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
117
- * Start with `@copilotkit/runtime/v2`.
118
- * V2 docs: https://docs.copilotkit.ai/
119
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
120
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
121
- */
122
- convertActionToDynamicStructuredTool, /**
123
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
124
- * No 1:1 v2 replacement is available.
125
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
126
- * Start with `@copilotkit/runtime/v2`.
127
- * V2 docs: https://docs.copilotkit.ai/
128
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
129
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
130
- */
131
- convertActionsToDynamicStructuredTools, /**
132
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
133
- * No 1:1 v2 replacement is available.
134
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
135
- * Start with `@copilotkit/runtime/v2`.
136
- * V2 docs: https://docs.copilotkit.ai/
137
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
138
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
139
- */
140
- copilotKitInterrupt, /**
141
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
142
- * No 1:1 v2 replacement is available.
143
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
144
- * Start with `@copilotkit/runtime/v2`.
145
- * V2 docs: https://docs.copilotkit.ai/
146
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
147
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
148
- */
149
- copilotkitCustomizeConfig, /**
150
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
151
- * No 1:1 v2 replacement is available.
152
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
153
- * Start with `@copilotkit/runtime/v2`.
154
- * V2 docs: https://docs.copilotkit.ai/
155
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
156
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
157
- */
158
- copilotkitEmitMessage, /**
159
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
160
- * No 1:1 v2 replacement is available.
161
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
162
- * Start with `@copilotkit/runtime/v2`.
163
- * V2 docs: https://docs.copilotkit.ai/
164
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
165
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
166
- */
167
- copilotkitEmitState, /**
168
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
169
- * No 1:1 v2 replacement is available.
170
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
171
- * Start with `@copilotkit/runtime/v2`.
172
- * V2 docs: https://docs.copilotkit.ai/
173
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
174
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
175
- */
176
- copilotkitEmitToolCall, /**
177
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
178
- * No 1:1 v2 replacement is available.
179
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
180
- * Start with `@copilotkit/runtime/v2`.
181
- * V2 docs: https://docs.copilotkit.ai/
182
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
183
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
184
- */
185
- copilotkitExit, /**
186
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
187
- * No 1:1 v2 replacement is available.
188
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
189
- * Start with `@copilotkit/runtime/v2`.
190
- * V2 docs: https://docs.copilotkit.ai/
191
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
192
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
193
- */
194
- copilotkitMiddleware, /**
195
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
196
- * No 1:1 v2 replacement is available.
197
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
198
- * Start with `@copilotkit/runtime/v2`.
199
- * V2 docs: https://docs.copilotkit.ai/
200
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
201
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
202
- */
203
- createCopilotkitMiddleware, /**
204
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
205
- * No 1:1 v2 replacement is available.
206
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
207
- * Start with `@copilotkit/runtime/v2`.
208
- * V2 docs: https://docs.copilotkit.ai/
209
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
210
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
211
- */
212
- zodState };
5
+ export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitSchemaState, CopilotKitSchemaUpdate, CopilotKitState, CopilotKitStateAnnotation, CopilotKitStateSchema, ExposeStateOption, IntermediateStateConfig, OptionsConfig, StandardSerializableSchema, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit, copilotkitMiddleware, createCopilotkitMiddleware, zodState };
@@ -2,211 +2,4 @@ import { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropert
2
2
  import { convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit } from "./langgraph/utils.mjs";
3
3
  import { ExposeStateOption, copilotkitMiddleware, createCopilotkitMiddleware, zodState } from "./langgraph/middleware.mjs";
4
4
  import { CopilotKitSchemaState, CopilotKitSchemaUpdate, CopilotKitStateSchema } from "./langgraph/state-schema.mjs";
5
- export { /**
6
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
7
- * No 1:1 v2 replacement is available.
8
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
9
- * Start with `@copilotkit/runtime/v2`.
10
- * V2 docs: https://docs.copilotkit.ai/
11
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
12
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
13
- */
14
- type CopilotKitProperties, /**
15
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
16
- * No 1:1 v2 replacement is available.
17
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
18
- * Start with `@copilotkit/runtime/v2`.
19
- * V2 docs: https://docs.copilotkit.ai/
20
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
21
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
22
- */
23
- CopilotKitPropertiesAnnotation, /**
24
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
25
- * No 1:1 v2 replacement is available.
26
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
27
- * Start with `@copilotkit/runtime/v2`.
28
- * V2 docs: https://docs.copilotkit.ai/
29
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
30
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
31
- */
32
- CopilotKitPropertiesSchema, /**
33
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
34
- * No 1:1 v2 replacement is available.
35
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
36
- * Start with `@copilotkit/runtime/v2`.
37
- * V2 docs: https://docs.copilotkit.ai/
38
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
39
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
40
- */
41
- type CopilotKitSchemaState, /**
42
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
43
- * No 1:1 v2 replacement is available.
44
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
45
- * Start with `@copilotkit/runtime/v2`.
46
- * V2 docs: https://docs.copilotkit.ai/
47
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
48
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
49
- */
50
- type CopilotKitSchemaUpdate, /**
51
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
52
- * No 1:1 v2 replacement is available.
53
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
54
- * Start with `@copilotkit/runtime/v2`.
55
- * V2 docs: https://docs.copilotkit.ai/
56
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
57
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
58
- */
59
- type CopilotKitState, /**
60
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
61
- * No 1:1 v2 replacement is available.
62
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
63
- * Start with `@copilotkit/runtime/v2`.
64
- * V2 docs: https://docs.copilotkit.ai/
65
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
66
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
67
- */
68
- CopilotKitStateAnnotation, /**
69
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
70
- * No 1:1 v2 replacement is available.
71
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
72
- * Start with `@copilotkit/runtime/v2`.
73
- * V2 docs: https://docs.copilotkit.ai/
74
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
75
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
76
- */
77
- CopilotKitStateSchema, /**
78
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
79
- * No 1:1 v2 replacement is available.
80
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
81
- * Start with `@copilotkit/runtime/v2`.
82
- * V2 docs: https://docs.copilotkit.ai/
83
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
84
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
85
- */
86
- type ExposeStateOption, /**
87
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
88
- * No 1:1 v2 replacement is available.
89
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
90
- * Start with `@copilotkit/runtime/v2`.
91
- * V2 docs: https://docs.copilotkit.ai/
92
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
93
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
94
- */
95
- type IntermediateStateConfig, /**
96
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
97
- * No 1:1 v2 replacement is available.
98
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
99
- * Start with `@copilotkit/runtime/v2`.
100
- * V2 docs: https://docs.copilotkit.ai/
101
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
102
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
103
- */
104
- type OptionsConfig, /**
105
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
106
- * No 1:1 v2 replacement is available.
107
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
108
- * Start with `@copilotkit/runtime/v2`.
109
- * V2 docs: https://docs.copilotkit.ai/
110
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
111
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
112
- */
113
- type StandardSerializableSchema, /**
114
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
115
- * No 1:1 v2 replacement is available.
116
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
117
- * Start with `@copilotkit/runtime/v2`.
118
- * V2 docs: https://docs.copilotkit.ai/
119
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
120
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
121
- */
122
- convertActionToDynamicStructuredTool, /**
123
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
124
- * No 1:1 v2 replacement is available.
125
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
126
- * Start with `@copilotkit/runtime/v2`.
127
- * V2 docs: https://docs.copilotkit.ai/
128
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
129
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
130
- */
131
- convertActionsToDynamicStructuredTools, /**
132
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
133
- * No 1:1 v2 replacement is available.
134
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
135
- * Start with `@copilotkit/runtime/v2`.
136
- * V2 docs: https://docs.copilotkit.ai/
137
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
138
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
139
- */
140
- copilotKitInterrupt, /**
141
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
142
- * No 1:1 v2 replacement is available.
143
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
144
- * Start with `@copilotkit/runtime/v2`.
145
- * V2 docs: https://docs.copilotkit.ai/
146
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
147
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
148
- */
149
- copilotkitCustomizeConfig, /**
150
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
151
- * No 1:1 v2 replacement is available.
152
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
153
- * Start with `@copilotkit/runtime/v2`.
154
- * V2 docs: https://docs.copilotkit.ai/
155
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
156
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
157
- */
158
- copilotkitEmitMessage, /**
159
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
160
- * No 1:1 v2 replacement is available.
161
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
162
- * Start with `@copilotkit/runtime/v2`.
163
- * V2 docs: https://docs.copilotkit.ai/
164
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
165
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
166
- */
167
- copilotkitEmitState, /**
168
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
169
- * No 1:1 v2 replacement is available.
170
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
171
- * Start with `@copilotkit/runtime/v2`.
172
- * V2 docs: https://docs.copilotkit.ai/
173
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
174
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
175
- */
176
- copilotkitEmitToolCall, /**
177
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
178
- * No 1:1 v2 replacement is available.
179
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
180
- * Start with `@copilotkit/runtime/v2`.
181
- * V2 docs: https://docs.copilotkit.ai/
182
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
183
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
184
- */
185
- copilotkitExit, /**
186
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
187
- * No 1:1 v2 replacement is available.
188
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
189
- * Start with `@copilotkit/runtime/v2`.
190
- * V2 docs: https://docs.copilotkit.ai/
191
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
192
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
193
- */
194
- copilotkitMiddleware, /**
195
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
196
- * No 1:1 v2 replacement is available.
197
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
198
- * Start with `@copilotkit/runtime/v2`.
199
- * V2 docs: https://docs.copilotkit.ai/
200
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
201
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
202
- */
203
- createCopilotkitMiddleware, /**
204
- * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
205
- * No 1:1 v2 replacement is available.
206
- * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
207
- * Start with `@copilotkit/runtime/v2`.
208
- * V2 docs: https://docs.copilotkit.ai/
209
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
210
- * Migration guide: https://docs.copilotkit.ai/migrate/v2
211
- */
212
- zodState };
5
+ export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitSchemaState, CopilotKitSchemaUpdate, CopilotKitState, CopilotKitStateAnnotation, CopilotKitStateSchema, ExposeStateOption, IntermediateStateConfig, OptionsConfig, StandardSerializableSchema, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit, copilotkitMiddleware, createCopilotkitMiddleware, zodState };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkit/sdk-js",
3
- "version": "1.75.0",
3
+ "version": "1.75.1",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "ai",
@@ -50,7 +50,7 @@
50
50
  "dependencies": {
51
51
  "@ag-ui/langgraph": "0.0.42",
52
52
  "@standard-schema/spec": "^1.0.0",
53
- "@copilotkit/shared": "1.75.0"
53
+ "@copilotkit/shared": "1.75.1"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@langchain/core": "^1.1.41",
@@ -76,7 +76,7 @@
76
76
  "zod": "^3.23.3 || ^3.24.0 || ^3.25.0"
77
77
  },
78
78
  "scripts": {
79
- "build": "tsdown && node ../../scripts/deprecations/v1-dist-notices.mjs --entrypoint sdk-js,sdk-js-langchain,sdk-js-langgraph,sdk-js-langgraph-middlewares",
79
+ "build": "tsdown && node ../../scripts/deprecations/v1-dist-notices.mjs --entrypoint sdk-js,sdk-js-langchain,sdk-js-langgraph-middlewares",
80
80
  "dev": "tsdown --watch",
81
81
  "test": "vitest run",
82
82
  "test:watch": "vitest",