zai-adk-python-preview 0.1.0__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.
Files changed (66) hide show
  1. zai_adk/__init__.py +18 -0
  2. zai_adk/agent/__init__.py +26 -0
  3. zai_adk/agent/events.py +127 -0
  4. zai_adk/agent/service.py +1092 -0
  5. zai_adk/agent/types.py +66 -0
  6. zai_adk/context/__init__.py +13 -0
  7. zai_adk/context/compaction.py +312 -0
  8. zai_adk/context/models.py +127 -0
  9. zai_adk/llm/__init__.py +45 -0
  10. zai_adk/llm/anthropic/chat.py +344 -0
  11. zai_adk/llm/anthropic/serializer.py +490 -0
  12. zai_adk/llm/base.py +118 -0
  13. zai_adk/llm/exceptions.py +29 -0
  14. zai_adk/llm/messages.py +436 -0
  15. zai_adk/llm/openai/chat.py +386 -0
  16. zai_adk/llm/openai/serializer.py +315 -0
  17. zai_adk/llm/schema.py +293 -0
  18. zai_adk/llm/views.py +80 -0
  19. zai_adk/mcp/__init__.py +11 -0
  20. zai_adk/mcp/client.py +273 -0
  21. zai_adk/mcp/config.py +29 -0
  22. zai_adk/observability/__init__.py +7 -0
  23. zai_adk/observability/observability.py +281 -0
  24. zai_adk/protocols/__init__.py +49 -0
  25. zai_adk/protocols/agui/__init__.py +57 -0
  26. zai_adk/protocols/agui/converter.py +267 -0
  27. zai_adk/protocols/agui/encoder.py +51 -0
  28. zai_adk/protocols/agui/events.py +167 -0
  29. zai_adk/protocols/agui/protocol.py +93 -0
  30. zai_adk/protocols/base.py +71 -0
  31. zai_adk/sandbox/__init__.py +24 -0
  32. zai_adk/sandbox/base.py +178 -0
  33. zai_adk/sandbox/config.py +48 -0
  34. zai_adk/sandbox/factory.py +71 -0
  35. zai_adk/sandbox/local.py +260 -0
  36. zai_adk/skills/__init__.py +16 -0
  37. zai_adk/skills/manager.py +353 -0
  38. zai_adk/skills/parser.py +79 -0
  39. zai_adk/skills/types.py +49 -0
  40. zai_adk/skills/xml_generator.py +81 -0
  41. zai_adk/todo/__init__.py +5 -0
  42. zai_adk/todo/service.py +206 -0
  43. zai_adk/tokens/__init__.py +21 -0
  44. zai_adk/tokens/custom_pricing.py +11 -0
  45. zai_adk/tokens/mappings.py +6 -0
  46. zai_adk/tokens/service.py +420 -0
  47. zai_adk/tokens/views.py +112 -0
  48. zai_adk/tools/__init__.py +10 -0
  49. zai_adk/tools/builtin/__init__.py +38 -0
  50. zai_adk/tools/builtin/bash.py +36 -0
  51. zai_adk/tools/builtin/fs_edit.py +44 -0
  52. zai_adk/tools/builtin/fs_glob.py +32 -0
  53. zai_adk/tools/builtin/fs_grep.py +94 -0
  54. zai_adk/tools/builtin/fs_read.py +29 -0
  55. zai_adk/tools/builtin/fs_stat.py +33 -0
  56. zai_adk/tools/builtin/fs_write.py +31 -0
  57. zai_adk/tools/builtin/skill_exec.py +110 -0
  58. zai_adk/tools/builtin/skills.py +103 -0
  59. zai_adk/tools/builtin/task_run.py +129 -0
  60. zai_adk/tools/builtin/todo.py +107 -0
  61. zai_adk/tools/decorator.py +406 -0
  62. zai_adk/tools/depends.py +79 -0
  63. zai_adk_python_preview-0.1.0.dist-info/METADATA +369 -0
  64. zai_adk_python_preview-0.1.0.dist-info/RECORD +66 -0
  65. zai_adk_python_preview-0.1.0.dist-info/WHEEL +4 -0
  66. zai_adk_python_preview-0.1.0.dist-info/licenses/LICENSE +21 -0
zai_adk/__init__.py ADDED
@@ -0,0 +1,18 @@
1
+ from zai_adk.agent import (
2
+ Agent,
3
+ AgentTemplate,
4
+ SubagentResult,
5
+ SubagentStatus,
6
+ )
7
+ from zai_adk.skills import SkillsManager, Skill, SkillMetadata, SkillContent
8
+
9
+ __all__ = [
10
+ "Agent",
11
+ "AgentTemplate",
12
+ "SubagentResult",
13
+ "SubagentStatus",
14
+ "SkillsManager",
15
+ "Skill",
16
+ "SkillMetadata",
17
+ "SkillContent",
18
+ ]
@@ -0,0 +1,26 @@
1
+ from zai_adk.agent.events import (
2
+ AgentEvent,
3
+ FinalResponseEvent,
4
+ TextEvent,
5
+ ThinkingEvent,
6
+ ToolCallEvent,
7
+ ToolResultEvent,
8
+ )
9
+ from zai_adk.agent.service import Agent, TaskComplete
10
+ from zai_adk.agent.types import AgentTemplate, SubagentResult, SubagentStatus
11
+
12
+ __all__ = [
13
+ "Agent",
14
+ "TaskComplete",
15
+ # Events
16
+ "AgentEvent",
17
+ "FinalResponseEvent",
18
+ "TextEvent",
19
+ "ThinkingEvent",
20
+ "ToolCallEvent",
21
+ "ToolResultEvent",
22
+ # Subagent types
23
+ "AgentTemplate",
24
+ "SubagentResult",
25
+ "SubagentStatus",
26
+ ]
@@ -0,0 +1,127 @@
1
+ """
2
+ Event types for agent streaming.
3
+
4
+ These events are yielded by `agent.query_stream()` to provide visibility
5
+ into the agent's execution.
6
+
7
+ Usage:
8
+ async for event in agent.query_stream("do something"):
9
+ match event:
10
+ case ToolCallEvent(tool=name, args=args):
11
+ print(f"Calling {name} with {args}")
12
+ case ToolResultEvent(tool=name, result=result):
13
+ print(f"{name} returned: {result}")
14
+ case TextEvent(content=text):
15
+ print(f"Assistant: {text}")
16
+ """
17
+
18
+ import json
19
+ from dataclasses import dataclass
20
+ from typing import Any
21
+
22
+
23
+ @dataclass
24
+ class TextEvent:
25
+ """Emitted when the assistant produces text content."""
26
+
27
+ content: str
28
+ """The text content from the assistant."""
29
+
30
+ def __str__(self) -> str:
31
+ preview = self.content[:100] + '...' if len(self.content) > 100 else self.content
32
+ return f'💬 {preview}'
33
+
34
+
35
+ @dataclass
36
+ class ThinkingEvent:
37
+ """Emitted when the model produces thinking/reasoning content."""
38
+
39
+ content: str
40
+ """The thinking content."""
41
+
42
+ def __str__(self) -> str:
43
+ preview = self.content[:80] + '...' if len(self.content) > 80 else self.content
44
+ return f'🧠 {preview}'
45
+
46
+
47
+ @dataclass
48
+ class ToolCallEvent:
49
+ """Emitted when the assistant calls a tool."""
50
+
51
+ tool: str
52
+ """The name of the tool being called."""
53
+
54
+ args: dict[str, Any]
55
+ """The arguments passed to the tool."""
56
+
57
+ tool_call_id: str
58
+ """The unique ID of this tool call."""
59
+
60
+ display_name: str = ''
61
+ """Human-readable description of the tool call (e.g., 'Browsing https://...')."""
62
+
63
+ def __str__(self) -> str:
64
+ if self.display_name:
65
+ return f'🔧 {self.display_name}'
66
+ args_str = json.dumps(self.args, default=str)
67
+ if len(args_str) > 80:
68
+ args_str = args_str[:77] + '...'
69
+ return f'🔧 {self.tool}({args_str})'
70
+
71
+
72
+ @dataclass
73
+ class ToolResultEvent:
74
+ """Emitted when a tool returns a result."""
75
+
76
+ tool: str
77
+ """The name of the tool that was called."""
78
+
79
+ result: str
80
+ """The result returned by the tool."""
81
+
82
+ tool_call_id: str
83
+ """The unique ID of the tool call this result corresponds to."""
84
+
85
+ is_error: bool = False
86
+ """Whether the tool execution resulted in an error."""
87
+
88
+ def __str__(self) -> str:
89
+ prefix = '❌' if self.is_error else '✓'
90
+ preview = self.result[:80] + '...' if len(self.result) > 80 else self.result
91
+ return f' {prefix} {self.tool}: {preview}'
92
+
93
+
94
+ @dataclass
95
+ class FinalResponseEvent:
96
+ """Emitted when the agent produces its final response."""
97
+
98
+ content: str
99
+ """The final response content."""
100
+
101
+ def __str__(self) -> str:
102
+ return f'✅ Final: {self.content[:100]}...' if len(self.content) > 100 else f'✅ Final: {self.content}'
103
+
104
+
105
+ @dataclass
106
+ class HiddenUserMessageEvent:
107
+ """Emitted when the agent injects a hidden user message (ex: incomplete todos prompt).
108
+ Hidden messages are saved to history and sent to the LLM but not displayed in the UI.
109
+ """
110
+
111
+ content: str
112
+ """The content of the hidden user message."""
113
+
114
+ def __str__(self) -> str:
115
+ preview = self.content[:80] + '...' if len(self.content) > 80 else self.content
116
+ return f'👻 Hidden: {preview}'
117
+
118
+
119
+ # Union type for all events
120
+ AgentEvent = (
121
+ TextEvent
122
+ | ThinkingEvent
123
+ | ToolCallEvent
124
+ | ToolResultEvent
125
+ | FinalResponseEvent
126
+ | HiddenUserMessageEvent
127
+ )