idun-agent-engine 0.2.5__py3-none-any.whl → 0.2.7__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,3 +1,3 @@
1
1
  """Version information for Idun Agent Engine."""
2
2
 
3
- __version__ = "0.2.5"
3
+ __version__ = "0.2.7"
@@ -39,6 +39,15 @@ class BaseAgent[ConfigType: BaseAgentConfig](ABC):
39
39
  """
40
40
  pass
41
41
 
42
+ @property
43
+ @abstractmethod
44
+ def copilotkit_agent_instance(self) -> Any:
45
+ """Get the CopilotKit agent instance.
46
+
47
+ This might be set after initialization.
48
+ """
49
+ pass
50
+
42
51
  @property
43
52
  def configuration(self) -> ConfigType:
44
53
  """Return current configuration settings for the agent.
@@ -70,6 +70,15 @@ class HaystackAgent(BaseAgent):
70
70
  raise RuntimeError("Agent not initialized. Call initialize() first.")
71
71
  return self._agent_instance
72
72
 
73
+ @property
74
+ def copilotkit_agent_instance(self) -> Any:
75
+ """Return the CopilotKit agent instance.
76
+
77
+ Raises:
78
+ RuntimeError: If the CopilotKit agent is not yet initialized.
79
+ """
80
+ raise NotImplementedError("CopilotKit agent instance not supported yet for Haystack agent.")
81
+
73
82
  @property
74
83
  def configuration(self) -> HaystackAgentConfig:
75
84
  """Return validated configuration.
@@ -17,6 +17,7 @@ from langgraph.graph import StateGraph
17
17
 
18
18
  from idun_agent_engine import observability
19
19
  from idun_agent_engine.agent import base as agent_base
20
+ from copilotkit import LangGraphAGUIAgent
20
21
 
21
22
 
22
23
  class LanggraphAgent(agent_base.BaseAgent):
@@ -29,6 +30,7 @@ class LanggraphAgent(agent_base.BaseAgent):
29
30
  self._input_schema: Any = None
30
31
  self._output_schema: Any = None
31
32
  self._agent_instance: Any = None
33
+ self._copilotkit_agent_instance: LangGraphAGUIAgent | None = None
32
34
  self._checkpointer: Any = None
33
35
  self._store: Any = None
34
36
  self._connection: Any = None
@@ -79,6 +81,17 @@ class LanggraphAgent(agent_base.BaseAgent):
79
81
  raise RuntimeError("Agent not initialized. Call initialize() first.")
80
82
  return self._agent_instance
81
83
 
84
+ @property
85
+ def copilotkit_agent_instance(self) -> LangGraphAGUIAgent:
86
+ """Return the CopilotKit agent instance.
87
+
88
+ Raises:
89
+ RuntimeError: If the CopilotKit agent is not yet initialized.
90
+ """
91
+ if self._copilotkit_agent_instance is None:
92
+ raise RuntimeError("CopilotKit agent not initialized. Call initialize() first.")
93
+ return self._copilotkit_agent_instance
94
+
82
95
  @property
83
96
  def configuration(self) -> LangGraphAgentConfig:
84
97
  """Return validated configuration.
@@ -158,6 +171,12 @@ class LanggraphAgent(agent_base.BaseAgent):
158
171
  checkpointer=self._checkpointer, store=self._store
159
172
  )
160
173
 
174
+ self._copilotkit_agent_instance = LangGraphAGUIAgent(
175
+ name=self._name,
176
+ description="Agent description", # TODO: add agent description
177
+ graph=self._agent_instance,
178
+ )
179
+
161
180
  if self._agent_instance:
162
181
  self._input_schema = self._agent_instance.input_schema
163
182
  self._output_schema = self._agent_instance.output_schema
@@ -14,6 +14,7 @@ from ..server.routers.agent import agent_router
14
14
  from ..server.routers.base import base_router
15
15
  from .config_builder import ConfigBuilder
16
16
  from .engine_config import EngineConfig
17
+ from .._version import __version__
17
18
 
18
19
 
19
20
  def create_app(
@@ -48,7 +49,7 @@ def create_app(
48
49
  lifespan=lifespan,
49
50
  title="Idun Agent Engine Server",
50
51
  description="A production-ready server for conversational AI agents",
51
- version="0.1.0",
52
+ version=__version__,
52
53
  docs_url="/docs",
53
54
  redoc_url="/redoc",
54
55
  )
@@ -139,7 +139,7 @@ class ConfigBuilder:
139
139
  langgraph_config = LangGraphAgentConfig.model_validate(agent_config_dict)
140
140
 
141
141
  # Create the agent config (store as strongly-typed model, not dict)
142
- self._agent_config = AgentConfig(type="langgraph", config=langgraph_config)
142
+ self._agent_config = AgentConfig(type=AgentFramework.LANGGRAPH, config=langgraph_config)
143
143
  return self
144
144
 
145
145
  def with_custom_agent(
@@ -160,12 +160,12 @@ class ConfigBuilder:
160
160
  """
161
161
  if agent_type == AgentFramework.LANGGRAPH:
162
162
  self._agent_config = AgentConfig(
163
- type="langgraph", config=LangGraphAgentConfig.model_validate(config)
163
+ type=AgentFramework.LANGGRAPH, config=LangGraphAgentConfig.model_validate(config)
164
164
  )
165
165
 
166
166
  elif agent_type == AgentFramework.HAYSTACK:
167
167
  self._agent_config = AgentConfig(
168
- type="haystack", config=HaystackAgentConfig.model_validate(config)
168
+ type=AgentFramework.HAYSTACK, config=HaystackAgentConfig.model_validate(config)
169
169
  )
170
170
  else:
171
171
  raise ValueError(f"Unsupported agent type: {agent_type}")
@@ -21,3 +21,20 @@ async def get_agent(request: Request):
21
21
  app_config = ConfigBuilder.load_from_file()
22
22
  agent = await ConfigBuilder.initialize_agent_from_config(app_config)
23
23
  return agent
24
+
25
+ async def get_copilotkit_agent(request: Request):
26
+ """Return the pre-initialized agent instance from the app state.
27
+
28
+ Falls back to loading from the default config if not present (e.g., tests).
29
+ """
30
+ if hasattr(request.app.state, "copilotkit_agent"):
31
+ return request.app.state.copilotkit_agent
32
+ else:
33
+ # This is a fallback for cases where the lifespan event did not run,
34
+ # like in some testing scenarios.
35
+ # Consider logging a warning here.
36
+ print("⚠️ CopilotKit agent not found in app state, initializing fallback agent...")
37
+
38
+ app_config = ConfigBuilder.load_from_file()
39
+ copilotkit_agent = await ConfigBuilder.initialize_agent_from_config(app_config)
40
+ return copilotkit_agent
@@ -8,7 +8,11 @@ from fastapi.responses import StreamingResponse
8
8
  from idun_agent_schema.engine.api import ChatRequest, ChatResponse
9
9
 
10
10
  from idun_agent_engine.agent.base import BaseAgent
11
- from idun_agent_engine.server.dependencies import get_agent
11
+ from idun_agent_engine.server.dependencies import get_agent, get_copilotkit_agent
12
+
13
+ from ag_ui.core.types import RunAgentInput
14
+ from ag_ui.encoder import EventEncoder
15
+ from copilotkit import LangGraphAGUIAgent
12
16
 
13
17
  logging.basicConfig(
14
18
  format="%(asctime)s %(levelname)-8s %(message)s",
@@ -57,7 +61,6 @@ async def stream(
57
61
  ):
58
62
  """Process a message with the agent, streaming ag-ui events."""
59
63
  try:
60
-
61
64
  async def event_stream():
62
65
  message = {"query": request.query, "session_id": request.session_id}
63
66
  async for event in agent.stream(message):
@@ -66,3 +69,28 @@ async def stream(
66
69
  return StreamingResponse(event_stream(), media_type="text/event-stream")
67
70
  except Exception as e: # noqa: BLE001
68
71
  raise HTTPException(status_code=500, detail=str(e)) from e
72
+
73
+ @agent_router.post("/copilotkit/stream")
74
+ async def copilotkit_stream(
75
+ input_data: RunAgentInput,
76
+ request: Request,
77
+ copilotkit_agent: Annotated[LangGraphAGUIAgent, Depends(get_copilotkit_agent)],
78
+ ):
79
+ """Process a message with the agent, streaming ag-ui events."""
80
+ try:
81
+ # Get the accept header from the request
82
+ accept_header = request.headers.get("accept")
83
+
84
+ # Create an event encoder to properly format SSE events
85
+ encoder = EventEncoder(accept=accept_header or "") # type: ignore[arg-type]
86
+
87
+ async def event_generator():
88
+ async for event in copilotkit_agent.run(input_data):
89
+ yield encoder.encode(event)
90
+
91
+ return StreamingResponse(
92
+ event_generator(), # type: ignore[arg-type]
93
+ media_type=encoder.get_content_type()
94
+ )
95
+ except Exception as e: # noqa: BLE001
96
+ raise HTTPException(status_code=500, detail=str(e)) from e
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: idun-agent-engine
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Summary: Python SDK and runtime to serve AI agents with FastAPI, LangGraph, and observability.
5
5
  Project-URL: Homepage, https://github.com/geoffreyharrazi/idun-agent-platform
6
6
  Project-URL: Repository, https://github.com/geoffreyharrazi/idun-agent-platform
@@ -19,15 +19,17 @@ Classifier: Programming Language :: Python :: 3.13
19
19
  Classifier: Topic :: Software Development :: Libraries
20
20
  Classifier: Typing :: Typed
21
21
  Requires-Python: <3.14,>=3.12
22
+ Requires-Dist: ag-ui-langgraph<0.1.0,>=0.0.20
22
23
  Requires-Dist: ag-ui-protocol<0.2.0,>=0.1.8
23
24
  Requires-Dist: aiosqlite<0.22.0,>=0.21.0
24
25
  Requires-Dist: arize-phoenix-otel<1.0.0,>=0.2.0
25
26
  Requires-Dist: arize-phoenix<12.0.0,>=11.22.0
26
27
  Requires-Dist: click>=8.2.1
27
- Requires-Dist: fastapi<0.117.0,>=0.116.1
28
+ Requires-Dist: copilotkit<0.2.0,>=0.1.72
29
+ Requires-Dist: fastapi<0.116.0,>=0.115.0
28
30
  Requires-Dist: google-adk<2.0.0,>=1.9.0
29
31
  Requires-Dist: httpx<0.29.0,>=0.28.1
30
- Requires-Dist: idun-agent-schema<0.3.0,>=0.2.5
32
+ Requires-Dist: idun-agent-schema<0.3.0,>=0.2.7
31
33
  Requires-Dist: langchain-core<0.4.0,>=0.3.72
32
34
  Requires-Dist: langchain-google-vertexai<3.0.0,>=2.0.27
33
35
  Requires-Dist: langchain<0.4,>=0.3.27
@@ -1,18 +1,18 @@
1
1
  idun_agent_engine/__init__.py,sha256=PhOL6foq5V0eXaoXw7xKUeCWXIWrOHrAFB8OuJnBqyM,550
2
- idun_agent_engine/_version.py,sha256=I5-7-uhpm_19BECbYd0Vlz1Feg_ET0sWIZldIalT69c,72
2
+ idun_agent_engine/_version.py,sha256=o2wtvcZFXHMC9HdGCpCMglFAwq-cYBJIAi_MTK4BIFo,72
3
3
  idun_agent_engine/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  idun_agent_engine/agent/__init__.py,sha256=foyOoRdI_04q1b6f2A5EXEpWSCKjZxpgWMWrKcsHNl8,220
5
- idun_agent_engine/agent/base.py,sha256=xzuHIV_P7EwGyK7V2qbFUZccpm5xHaAjAkIxJL4tAwo,2856
5
+ idun_agent_engine/agent/base.py,sha256=JT_U4tgC6yPi0IYbDjSQ2a6W2YwABiC9NSGjYPCe8Yw,3059
6
6
  idun_agent_engine/agent/haystack/__init__.py,sha256=y5ADrD8gWBeYIvV7tmu6OpPdJ8POHt-tyraIL7RkkWI,179
7
- idun_agent_engine/agent/haystack/haystack.py,sha256=6xq7tOlvQxyc2w9KxikpS5S6vmXjUlK9Giwhmzg2X0w,10556
7
+ idun_agent_engine/agent/haystack/haystack.py,sha256=6WHW9z9LqMa5hHkfxUEaxyMMFw7y9nUu9wnXavxdsg8,10872
8
8
  idun_agent_engine/agent/haystack/haystack_model.py,sha256=EtOYnsWRufcrQufTRMeB3V-rZVQqfnmwKwPsYGfZdCs,362
9
9
  idun_agent_engine/agent/haystack/utils.py,sha256=sKRoPhzZWFw1NPsYwCockafzMBCCq3lGOrndbNE_C3M,609
10
10
  idun_agent_engine/agent/langgraph/__init__.py,sha256=CoBdkp9P4livdy5B0bvj9o7ftoqKmXEr9cZv4TZLncs,107
11
- idun_agent_engine/agent/langgraph/langgraph.py,sha256=Fm6t-TeG_7s0tJHev5sIbKcD7gLLXv22pJH0S14Hp2k,17412
11
+ idun_agent_engine/agent/langgraph/langgraph.py,sha256=eawnV6XgC9gxplTogyKioeqnHvdBwCtwobA8tLYmaYk,18167
12
12
  idun_agent_engine/cli/__init__.py,sha256=5S_Oo7n7YwKk5VPyqborrRqKVz6lvwODQ5olj70wbnQ,490
13
13
  idun_agent_engine/core/__init__.py,sha256=F0DMDlWcSWS_1dvh3xMbrdcVvZRHVnoAFFgREuSJfBI,408
14
- idun_agent_engine/core/app_factory.py,sha256=fqxX6n4huCAsEY5lzPQPtBb7nWWaxzvhYaPsRUbZuEY,2333
15
- idun_agent_engine/core/config_builder.py,sha256=nqlFEASHN9zlZhUnu5NAhRo2DeFkFVQ0rpx-yfnBuIw,16283
14
+ idun_agent_engine/core/app_factory.py,sha256=Af57kuEic6g4RA3JyLr9-gl_MQh41xcpHGA_wx92cO8,2372
15
+ idun_agent_engine/core/config_builder.py,sha256=lLyAvnatPSWR5PqTj4sWPNxnMBKgXdtFuxzqAYzhxcY,16322
16
16
  idun_agent_engine/core/engine_config.py,sha256=pHa-qiYUS7mvzW2eb6sXJoxxJCxC5fwcNUTcqiO90c0,584
17
17
  idun_agent_engine/core/server_runner.py,sha256=01_aAJC-s0C5fdkEUQzwk4Vlf1SX4lsZwRTkVaJx0VE,4898
18
18
  idun_agent_engine/observability/__init__.py,sha256=Jei-E8SgYulxFu5HkJz9HfcorIfQ6O7WZWGzP41ZK-4,298
@@ -24,20 +24,20 @@ idun_agent_engine/observability/phoenix/phoenix_handler.py,sha256=lGqSq-L1vmoEhA
24
24
  idun_agent_engine/observability/phoenix_local/__init__.py,sha256=m9dIw1GWGKAW4wP08jxA7j4yrOg0Nxq_08bwVh8YogE,146
25
25
  idun_agent_engine/observability/phoenix_local/phoenix_local_handler.py,sha256=wjOZuMpAxdD5D33rzxycNEzFMunETpPnYjiHjbjz5GA,4252
26
26
  idun_agent_engine/server/__init__.py,sha256=WaFektUsy37bNg2niAUy_TykzStukgWPnxC-t49CEwo,177
27
- idun_agent_engine/server/dependencies.py,sha256=7yGYWxqbL4xNafpj8g8-S-TQ_GmGlPnSB_wRbW_lfMA,824
27
+ idun_agent_engine/server/dependencies.py,sha256=3b9ADxZWMqDsye2yOPsZ_uPlj1hHynN5vnv0sW2SLkI,1580
28
28
  idun_agent_engine/server/lifespan.py,sha256=BC914qErOmKLNZY0-XkMkYnA0aVhLZFY7nhpKXx2D_g,1301
29
29
  idun_agent_engine/server/server_config.py,sha256=RYA7Y0c5aRw_WXaX8svFUIEtTPqzn3o-WQRm2p52C6g,213
30
30
  idun_agent_engine/server/routers/__init__.py,sha256=BgNzSVvHtGPGn5zhXhomwpKlDYBkeFi7xCbdcWVOgc8,102
31
- idun_agent_engine/server/routers/agent.py,sha256=7vVzhnKXYv6yZEKP8o-ETMWhIa0Hd2qyMu63MhoiLL0,2361
31
+ idun_agent_engine/server/routers/agent.py,sha256=PIdSZjrrskvaLRYksE7qWIyfrOwvRCSiPr07xTt4XiA,3456
32
32
  idun_agent_engine/server/routers/base.py,sha256=BWueBPN7ecdNWOyQaxpdpnd6GxOcN78N8bFWN_aNgmU,1899
33
33
  idun_platform_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  idun_platform_cli/main.py,sha256=jWL7Ob0p4KdRUqgPTP_EB68n7z2LyMKC2DeUsfWlBO4,200
35
35
  idun_platform_cli/groups/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
36
  idun_platform_cli/groups/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  idun_platform_cli/groups/agent/main.py,sha256=QMGQi3JZ76SeFI3miIjVWpMt0L-hGz5FwxtTPQX4-Uw,301
38
- idun_platform_cli/groups/agent/package.py,sha256=5VuEHSkcAqTbNQjwRy3tBz1sbm9kaJHqIhshFhRc19Q,2525
38
+ idun_platform_cli/groups/agent/package.py,sha256=gc7HoA2wtHlFC9f7rDXgGEBZUvibEwh9Vmlr-C1C1uA,2525
39
39
  idun_platform_cli/groups/agent/serve.py,sha256=IHC3vp_R45RW4enkNQCE-SP_J9GkmapAycktKcxT9Y8,3800
40
- idun_agent_engine-0.2.5.dist-info/METADATA,sha256=3xUtr_6v8iNIg2vSd5-TTEhAYIAes5sCkV03KD5nyNo,8660
41
- idun_agent_engine-0.2.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
42
- idun_agent_engine-0.2.5.dist-info/entry_points.txt,sha256=XG3oxlSOaCrYKT1oyhKa0Ag1iJPMZ-WF6gaV_mzIJW4,52
43
- idun_agent_engine-0.2.5.dist-info/RECORD,,
40
+ idun_agent_engine-0.2.7.dist-info/METADATA,sha256=Zg4GQA7qBy5Zl1FgrFHAbVYTrUXCL9GgwSK4zKtFnE0,8747
41
+ idun_agent_engine-0.2.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
42
+ idun_agent_engine-0.2.7.dist-info/entry_points.txt,sha256=XG3oxlSOaCrYKT1oyhKa0Ag1iJPMZ-WF6gaV_mzIJW4,52
43
+ idun_agent_engine-0.2.7.dist-info/RECORD,,
@@ -39,8 +39,8 @@ def generate_dockerfile(dependency: Dependency) -> str:
39
39
  requirements_dockerfile = f"""FROM python:3.13-slim
40
40
  RUN apt-get update && pip install uv
41
41
 
42
- RUN uv pip install idun-agent-schema==0.2.5 --system
43
- RUN uv pip install idun-agent-engine==0.2.5 --system
42
+ RUN uv pip install idun-agent-schema==0.2.7 --system
43
+ RUN uv pip install idun-agent-engine==0.2.7 --system
44
44
 
45
45
  COPY . .
46
46
  RUN uv pip install -r requirements.txt --system