copilotkit 0.1.95a0__tar.gz → 0.1.95a2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/PKG-INFO +2 -2
  2. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/copilotkit_lg_middleware.py +51 -17
  3. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/pyproject.toml +2 -2
  4. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/README.md +0 -0
  5. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/__init__.py +0 -0
  6. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/a2ui.py +0 -0
  7. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/action.py +0 -0
  8. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/agent.py +0 -0
  9. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/crewai/__init__.py +0 -0
  10. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/crewai/copilotkit_integration.py +0 -0
  11. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/crewai/crewai_agent.py +0 -0
  12. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/crewai/crewai_sdk.py +0 -0
  13. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/exc.py +0 -0
  14. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/header_propagation.py +0 -0
  15. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/html.py +0 -0
  16. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/integrations/__init__.py +0 -0
  17. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/integrations/fastapi.py +0 -0
  18. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/langchain.py +0 -0
  19. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/langgraph.py +0 -0
  20. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/langgraph_agui_agent.py +0 -0
  21. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/logging.py +0 -0
  22. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/parameter.py +0 -0
  23. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/protocol.py +0 -0
  24. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/py.typed +0 -0
  25. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/runloop.py +0 -0
  26. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/sdk.py +0 -0
  27. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/types.py +0 -0
  28. {copilotkit-0.1.95a0 → copilotkit-0.1.95a2}/copilotkit/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: copilotkit
3
- Version: 0.1.95a0
3
+ Version: 0.1.95a2
4
4
  Summary: CopilotKit python SDK
5
5
  License: MIT
6
6
  Keywords: copilot,copilotkit,langgraph,langchain,ai,langsmith,langserve
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3.12
15
15
  Classifier: Programming Language :: Python :: 3.13
16
16
  Classifier: Programming Language :: Python :: 3.14
17
17
  Provides-Extra: crewai
18
- Requires-Dist: ag-ui-langgraph[fastapi] (>=0.0.42a0)
18
+ Requires-Dist: ag-ui-langgraph[fastapi] (==0.0.42-alpha.0)
19
19
  Requires-Dist: ag-ui-protocol (>=0.1.15)
20
20
  Requires-Dist: crewai (>=0.118.0) ; (python_version >= "3.10" and python_version < "3.14") and (extra == "crewai")
21
21
  Requires-Dist: fastapi (>=0.115.0,<1.0.0)
@@ -35,13 +35,9 @@ from .langgraph import CopilotKitProperties
35
35
  # "no auto-A2UI" instead of breaking the whole middleware import.
36
36
  try: # pragma: no cover - exercised indirectly via the a2ui injection path
37
37
  from ag_ui_langgraph import get_a2ui_tools, A2UIToolParams
38
- # Framework-agnostic catalog resolution shared with every A2UI adapter
39
- # (Strands, etc.) so the two-path lookup lives in one place.
40
- from ag_ui_a2ui_toolkit import resolve_a2ui_catalog
41
38
  except Exception: # noqa: BLE001 - any import failure means the feature is off
42
39
  get_a2ui_tools = None
43
40
  A2UIToolParams = None
44
- resolve_a2ui_catalog = None
45
41
 
46
42
  # Track which httpx clients already have the header-propagation hook installed
47
43
  # (by object id) so we never double-install on repeated model calls.
@@ -325,20 +321,58 @@ class CopilotKitMiddleware(AgentMiddleware[StateSchema, Any]):
325
321
 
326
322
  @staticmethod
327
323
  def _resolve_a2ui_catalog(state: dict) -> "tuple[str | None, str | None] | None":
328
- """Resolve ``(component_schema, catalog_id)`` from run state.
329
-
330
- Delegates to the framework-agnostic, ``ag-ui``-keyed resolver in
331
- ``ag-ui-a2ui-toolkit``. CopilotKit's LangGraph layer mirrors the SAME
332
- ag-ui state under a ``copilotkit`` alias key, so if the canonical
333
- ``ag-ui`` lookup comes up empty we retry against ``copilotkit`` (this
334
- copilotkit-side read is fine here; the OSS toolkit stays
335
- copilotkit-agnostic).
324
+ """Find the frontend-registered A2UI catalog wherever it was passed.
325
+
326
+ Returns ``(component_schema, catalog_id)`` when a catalog is present,
327
+ else ``None`` (so the tool is never advertised when the client can't
328
+ render A2UI). Two delivery paths are supported, because the catalog
329
+ lands in different places depending on how the agent is served:
330
+
331
+ - **AG-UI native endpoint** → ``state["ag-ui"]["a2ui_schema"]``, a JSON
332
+ string ``{"catalogId": ..., "components": [...]}``.
333
+ - **CopilotKit runtime proxy** → a ``state["copilotkit"]["context"]``
334
+ entry describing the A2UI catalog (catalog id + component schemas as
335
+ text).
336
+
337
+ ``component_schema`` is the text/JSON the subagent should compose from;
338
+ ``catalog_id`` binds generated surfaces to the frontend's catalog (so
339
+ BYOC custom catalogs render their own components, not the basic one).
336
340
  """
337
- if resolve_a2ui_catalog is None:
338
- return None
339
- return resolve_a2ui_catalog(state) or resolve_a2ui_catalog(
340
- {"ag-ui": state.get("copilotkit") or {}}
341
- )
341
+ # AG-UI native path.
342
+ ag_ui = state.get("ag-ui") or {}
343
+ a2ui_schema = ag_ui.get("a2ui_schema")
344
+ if a2ui_schema:
345
+ catalog_id = None
346
+ try:
347
+ parsed = (
348
+ json.loads(a2ui_schema)
349
+ if isinstance(a2ui_schema, str)
350
+ else a2ui_schema
351
+ )
352
+ if isinstance(parsed, dict):
353
+ catalog_id = parsed.get("catalogId")
354
+ except (TypeError, ValueError):
355
+ pass
356
+ # Native path: the toolkit reads ``a2ui_schema`` from state itself,
357
+ # so no composition_guide is needed — just surface the catalog id.
358
+ return None, catalog_id
359
+
360
+ # CopilotKit runtime-proxy path: the catalog arrives as a context entry.
361
+ context = (state.get("copilotkit") or {}).get("context") or []
362
+ for entry in context:
363
+ if not isinstance(entry, dict):
364
+ continue
365
+ description = entry.get("description") or ""
366
+ value = entry.get("value") or ""
367
+ if "A2UI catalog" not in description or not value:
368
+ continue
369
+ # The value lists catalogs as "- <catalogId>" lines; the first is
370
+ # the custom catalog the client registered.
371
+ match = re.search(r"(?m)^\s*-\s+(\S+)", value)
372
+ catalog_id = match.group(1) if match else None
373
+ return value, catalog_id
374
+
375
+ return None
342
376
 
343
377
  @staticmethod
344
378
  def _a2ui_inject_decision(state: dict) -> "bool | str | None":
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "copilotkit"
3
- version = "0.1.95-alpha.0"
3
+ version = "0.1.95-alpha.2"
4
4
  description = "CopilotKit python SDK"
5
5
  authors = ["Markus Ecker <markus.ecker@gmail.com>"]
6
6
  license = "MIT"
@@ -31,7 +31,7 @@ python = ">=3.10,<3.15"
31
31
  langgraph = { version = ">=0.3.25,<2" }
32
32
  langchain = { version = ">=0.3.0" }
33
33
  crewai = { version = ">=0.118.0", optional = true, python = ">=3.10,<3.14" }
34
- ag-ui-langgraph = { version = ">=0.0.42a0", extras = ["fastapi"] }
34
+ ag-ui-langgraph = { version = "0.0.42-alpha.0", extras = ["fastapi"] }
35
35
  ag-ui-protocol = ">=0.1.15"
36
36
  fastapi = ">=0.115.0,<1.0.0"
37
37
  partialjson = "^0.0.8"
File without changes