copilotkit 0.1.75a0__py3-none-any.whl → 0.1.75a1__py3-none-any.whl

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,23 +1,3 @@
1
- """
2
- AG-UI Middleware for LangGraph agents.
3
-
4
- Enables:
5
- - Dynamic frontend tools from state['ag-ui']['tools']
6
- - Frontend tool routing (intercept calls, skip backend execution)
7
-
8
- Works with any agent (prebuilt or custom).
9
-
10
- Example:
11
- from langchain.agents import create_agent
12
- from copilotkit import CopilotKitMiddleware
13
-
14
- agent = create_agent(
15
- model="openai:gpt-4o",
16
- tools=[backend_tool],
17
- middleware=[CopilotKitMiddleware()],
18
- )
19
- """
20
-
21
1
  from typing import Any, Callable, Awaitable, Annotated
22
2
  from typing_extensions import TypedDict, NotRequired
23
3
 
@@ -32,9 +12,9 @@ from langgraph.runtime import Runtime
32
12
 
33
13
 
34
14
  class CopilotKitState(AgentState):
35
- """Extended state schema for AG-UI middleware."""
15
+ """Extended state schema for CopilotKit middleware."""
36
16
 
37
- # AG-UI frontend tools passed via state
17
+ # CopilotKit frontend tools passed via state
38
18
  actions: List[Any]
39
19
  context: List[CopilotContextItem]
40
20
 
@@ -42,13 +22,13 @@ class CopilotKitState(AgentState):
42
22
  copilotkit: NotRequired[dict[str, Any]]
43
23
 
44
24
 
45
- class CopilotKitMiddleware(AgentMiddleware[AGUIState, Any]):
46
- """AG-UI Middleware for LangGraph agents.
25
+ class CopilotKitMiddleware(AgentMiddleware[CopilotKitState, Any]):
26
+ """CopilotKit Middleware for LangGraph agents.
47
27
 
48
- Handles frontend tool injection and interception for AG-UI protocol.
28
+ Handles frontend tool injection and interception for CopilotKit.
49
29
  """
50
30
 
51
- state_schema = AGUIState
31
+ state_schema = CopilotKitState
52
32
  tools = []
53
33
 
54
34
  @property
@@ -61,7 +41,7 @@ class CopilotKitMiddleware(AgentMiddleware[AGUIState, Any]):
61
41
  request: ModelRequest,
62
42
  handler: Callable[[ModelRequest], ModelResponse],
63
43
  ) -> ModelResponse:
64
- frontend_tools = request.state.get("ag-ui", {}).get("tools", [])
44
+ frontend_tools = request.state.get("copilotkit", {}).get("tools", [])
65
45
 
66
46
  if not frontend_tools:
67
47
  return handler(request)
@@ -76,7 +56,7 @@ class CopilotKitMiddleware(AgentMiddleware[AGUIState, Any]):
76
56
  request: ModelRequest,
77
57
  handler: Callable[[ModelRequest], Awaitable[ModelResponse]],
78
58
  ) -> ModelResponse:
79
- frontend_tools = request.state.get("ag-ui", {}).get("tools", [])
59
+ frontend_tools = request.state.get("copilotkit", {}).get("tools", [])
80
60
 
81
61
  if not frontend_tools:
82
62
  return await handler(request)
@@ -89,10 +69,10 @@ class CopilotKitMiddleware(AgentMiddleware[AGUIState, Any]):
89
69
  # Intercept frontend tool calls after model returns, before ToolNode executes
90
70
  def after_model(
91
71
  self,
92
- state: AGUIState,
72
+ state: CopilotKitState,
93
73
  runtime: Runtime[Any],
94
74
  ) -> dict[str, Any] | None:
95
- frontend_tools = state.get("ag-ui", {}).get("tools", [])
75
+ frontend_tools = state.get("copilotkit", {}).get("tools", [])
96
76
  if not frontend_tools:
97
77
  return None
98
78
 
@@ -143,7 +123,7 @@ class CopilotKitMiddleware(AgentMiddleware[AGUIState, Any]):
143
123
 
144
124
  async def aafter_model(
145
125
  self,
146
- state: AGUIState,
126
+ state: CopilotKitState,
147
127
  runtime: Runtime[Any],
148
128
  ) -> dict[str, Any] | None:
149
129
  # Delegate to sync implementation
@@ -152,7 +132,7 @@ class CopilotKitMiddleware(AgentMiddleware[AGUIState, Any]):
152
132
  # Restore frontend tool calls to AIMessage before agent exits
153
133
  def after_agent(
154
134
  self,
155
- state: AGUIState,
135
+ state: CopilotKitState,
156
136
  runtime: Runtime[Any],
157
137
  ) -> dict[str, Any] | None:
158
138
  copilotkit_state = state.get("copilotkit", {})
@@ -186,7 +166,7 @@ class CopilotKitMiddleware(AgentMiddleware[AGUIState, Any]):
186
166
 
187
167
  async def aafter_agent(
188
168
  self,
189
- state: AGUIState,
169
+ state: CopilotKitState,
190
170
  runtime: Runtime[Any],
191
171
  ) -> dict[str, Any] | None:
192
172
  # Delegate to sync implementation
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: copilotkit
3
- Version: 0.1.75a0
3
+ Version: 0.1.75a1
4
4
  Summary: CopilotKit python SDK
5
5
  License: MIT
6
6
  Keywords: copilot,copilotkit,langgraph,langchain,ai,langsmith,langserve
@@ -1,7 +1,7 @@
1
1
  copilotkit/__init__.py,sha256=pK1UmbqWsd9blnIZ0p3wYHjkLthAavI2-gCyI5ulJzE,861
2
2
  copilotkit/action.py,sha256=bg_bPusEfN8TMQV1B3lVyMLbHyLn1E7yVYAvfE2_PXA,1691
3
3
  copilotkit/agent.py,sha256=e-jPsUQo18FOYUPdE3YNmSLcb5FEfWL6ARScOntyvb8,1663
4
- copilotkit/copilotkit_lg_middleware.py,sha256=_G71STMN6Kqi-b_VZIeY6XX189GQpD7GjhI5AnFMwv8,5900
4
+ copilotkit/copilotkit_lg_middleware.py,sha256=CHPtSJnc_wEA-pVsq-TwNexA3K8x87dCEORADGxCiSY,5497
5
5
  copilotkit/crewai/__init__.py,sha256=RAkBTwDpFuvD5prULUnoWdl5d8W373cm1ZlqOMeSGbY,1034
6
6
  copilotkit/crewai/copilotkit_integration.py,sha256=vd1LVhXo-cpA4PQ_-cZHdKgm67MvrHpx4VJweUvCzPE,14550
7
7
  copilotkit/crewai/crewai_agent.py,sha256=maoMnl0WIHUnFAK5ALUKD9z0GvjtfNGi31zi37LyyaE,15323
@@ -21,6 +21,6 @@ copilotkit/runloop.py,sha256=9pBqWeu4QCRPOizz00se1d0_BvCX3ZIABzNeiXhdyNM,10641
21
21
  copilotkit/sdk.py,sha256=VEQqA9QAXJS5MDLxtJJdtfrApX9EawCHzp-IXnat5vw,11882
22
22
  copilotkit/types.py,sha256=_YQluiHpJGGXYB4eWLk0EocDZp5C8rs3ZsMNFhmXEYU,972
23
23
  copilotkit/utils.py,sha256=rOAaaFBXgb3iv_cLH9S2steyGwHmnTjaxQTA53qdtQo,203
24
- copilotkit-0.1.75a0.dist-info/METADATA,sha256=8lYI9IdjJPpLdB3AWOtj5zPgYMEe89a2zp1-amB7l2c,2606
25
- copilotkit-0.1.75a0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
26
- copilotkit-0.1.75a0.dist-info/RECORD,,
24
+ copilotkit-0.1.75a1.dist-info/METADATA,sha256=N8BPWhy0GIjqbXa5JZF7nSEuJRTDHwDsuVGMrgex3dU,2606
25
+ copilotkit-0.1.75a1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
26
+ copilotkit-0.1.75a1.dist-info/RECORD,,