copilotkit 0.1.95a2__tar.gz → 0.1.95a3__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.95a2 → copilotkit-0.1.95a3}/PKG-INFO +1 -1
  2. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/copilotkit_lg_middleware.py +33 -6
  3. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/pyproject.toml +1 -1
  4. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/README.md +0 -0
  5. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/__init__.py +0 -0
  6. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/a2ui.py +0 -0
  7. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/action.py +0 -0
  8. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/agent.py +0 -0
  9. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/crewai/__init__.py +0 -0
  10. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/crewai/copilotkit_integration.py +0 -0
  11. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/crewai/crewai_agent.py +0 -0
  12. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/crewai/crewai_sdk.py +0 -0
  13. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/exc.py +0 -0
  14. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/header_propagation.py +0 -0
  15. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/html.py +0 -0
  16. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/integrations/__init__.py +0 -0
  17. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/integrations/fastapi.py +0 -0
  18. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/langchain.py +0 -0
  19. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/langgraph.py +0 -0
  20. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/langgraph_agui_agent.py +0 -0
  21. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/logging.py +0 -0
  22. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/parameter.py +0 -0
  23. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/protocol.py +0 -0
  24. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/py.typed +0 -0
  25. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/runloop.py +0 -0
  26. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/sdk.py +0 -0
  27. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/types.py +0 -0
  28. {copilotkit-0.1.95a2 → copilotkit-0.1.95a3}/copilotkit/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: copilotkit
3
- Version: 0.1.95a2
3
+ Version: 0.1.95a3
4
4
  Summary: CopilotKit python SDK
5
5
  License: MIT
6
6
  Keywords: copilot,copilotkit,langgraph,langchain,ai,langsmith,langserve
@@ -16,7 +16,7 @@ Example:
16
16
 
17
17
  import json
18
18
  import re
19
- from typing import Any, Callable, Awaitable, ClassVar, Iterable, Union
19
+ from typing import Any, Callable, Awaitable, ClassVar, Iterable, Optional, Union
20
20
 
21
21
  from langchain_core.messages import AIMessage, SystemMessage, ToolMessage
22
22
  from langchain.agents.middleware import (
@@ -231,6 +231,20 @@ class CopilotKitMiddleware(AgentMiddleware[StateSchema, Any]):
231
231
  - ``list``/``tuple``/``set[str]`` — only surface the named keys.
232
232
  Use this when you want explicit control over what the LLM
233
233
  sees (e.g. ``["liked", "todos"]``).
234
+ a2ui_params: Optional host overrides for the auto-injected
235
+ ``generate_a2ui`` tool, forwarded to ``get_a2ui_tools`` when A2UI
236
+ injection fires. An ``A2UIToolParams``-shaped dict: ``guidelines``
237
+ (``generation_guidelines`` / ``design_guidelines`` /
238
+ ``composition_guide``), ``default_catalog_id``,
239
+ ``default_surface_id``, ``tool_name``, ``recovery``, etc. Lets a
240
+ host steer the subagent (e.g. override the default design
241
+ guidelines to favor a repeating-card layout) on the auto-inject
242
+ path, which otherwise only ever uses the toolkit defaults.
243
+
244
+ The middleware always injects ``model`` from the bound request
245
+ model (the host cannot supply the live, header-hooked model), and
246
+ folds the registered catalog id + component schema into the params
247
+ unless the host already set them — so host values win.
234
248
  """
235
249
 
236
250
  state_schema = StateSchema
@@ -240,12 +254,18 @@ class CopilotKitMiddleware(AgentMiddleware[StateSchema, Any]):
240
254
  self,
241
255
  *,
242
256
  expose_state: Union[bool, Iterable[str]] = False,
257
+ a2ui_params: "Optional[A2UIToolParams]" = None,
243
258
  ):
244
259
  super().__init__()
245
260
  if isinstance(expose_state, bool):
246
261
  self._expose_state: Union[bool, frozenset[str]] = expose_state
247
262
  else:
248
263
  self._expose_state = frozenset(expose_state)
264
+ # Host-supplied A2UI tool overrides (guidelines, catalog id, tool name,
265
+ # recovery, ...). Copied so later mutation of the caller's dict can't
266
+ # bleed into the middleware. ``model`` + the registered catalog are
267
+ # layered in at build time; everything here is host-owned and wins.
268
+ self._a2ui_params: dict = dict(a2ui_params or {})
249
269
 
250
270
  @property
251
271
  def name(self) -> str:
@@ -422,15 +442,22 @@ class CopilotKitMiddleware(AgentMiddleware[StateSchema, Any]):
422
442
  component_schema, catalog_id = resolved if resolved else (None, None)
423
443
 
424
444
  # Shared A2UIToolParams: a single params object owned by the toolkit.
425
- # ``model`` lives inside it; ``composition_guide`` is folded into the
426
- # ``guidelines`` bag alongside generation/design overrides.
427
- params: "A2UIToolParams" = {"model": request.model}
428
- if catalog_id:
445
+ # Start from the host overrides (guidelines / catalog id / tool name /
446
+ # recovery) so a host can steer the subagent, then layer in only what
447
+ # the host cannot know — the bound model, and the registered catalog id
448
+ # + component schema — without clobbering any host-set value.
449
+ params: "A2UIToolParams" = dict(self._a2ui_params)
450
+ params["model"] = request.model
451
+ if catalog_id and "default_catalog_id" not in params:
429
452
  params["default_catalog_id"] = catalog_id
430
453
  # Feed the registered component schema to the subagent so it composes
431
454
  # only catalog components (the toolkit appends this to its prompt).
455
+ # Merge into any host ``guidelines`` bag; a host-set composition_guide
456
+ # wins, and host generation/design overrides are preserved.
432
457
  if component_schema:
433
- params["guidelines"] = {"composition_guide": component_schema}
458
+ guidelines = dict(params.get("guidelines") or {})
459
+ guidelines.setdefault("composition_guide", component_schema)
460
+ params["guidelines"] = guidelines
434
461
 
435
462
  tool = get_a2ui_tools(params)
436
463
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "copilotkit"
3
- version = "0.1.95-alpha.2"
3
+ version = "0.1.95-alpha.3"
4
4
  description = "CopilotKit python SDK"
5
5
  authors = ["Markus Ecker <markus.ecker@gmail.com>"]
6
6
  license = "MIT"
File without changes