yera 0.1.0__py3-none-any.whl → 0.2.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.
- infra_mvp/base_client.py +29 -0
- infra_mvp/base_server.py +68 -0
- infra_mvp/monitoring/__init__.py +15 -0
- infra_mvp/monitoring/metrics.py +185 -0
- infra_mvp/stream/README.md +56 -0
- infra_mvp/stream/__init__.py +14 -0
- infra_mvp/stream/__main__.py +101 -0
- infra_mvp/stream/agents/demos/financial/chart_additions_plan.md +170 -0
- infra_mvp/stream/agents/demos/financial/portfolio_assistant_stream.json +1571 -0
- infra_mvp/stream/agents/reference/blocks/action.json +170 -0
- infra_mvp/stream/agents/reference/blocks/button.json +66 -0
- infra_mvp/stream/agents/reference/blocks/date.json +65 -0
- infra_mvp/stream/agents/reference/blocks/input_prompt.json +94 -0
- infra_mvp/stream/agents/reference/blocks/layout.json +288 -0
- infra_mvp/stream/agents/reference/blocks/markdown.json +344 -0
- infra_mvp/stream/agents/reference/blocks/slider.json +67 -0
- infra_mvp/stream/agents/reference/blocks/spinner.json +110 -0
- infra_mvp/stream/agents/reference/blocks/table.json +56 -0
- infra_mvp/stream/agents/reference/chat_dynamics/branching_test_stream.json +145 -0
- infra_mvp/stream/app.py +49 -0
- infra_mvp/stream/container.py +112 -0
- infra_mvp/stream/schemas/__init__.py +16 -0
- infra_mvp/stream/schemas/agent.py +24 -0
- infra_mvp/stream/schemas/interaction.py +28 -0
- infra_mvp/stream/schemas/session.py +30 -0
- infra_mvp/stream/server.py +321 -0
- infra_mvp/stream/services/__init__.py +12 -0
- infra_mvp/stream/services/agent_service.py +40 -0
- infra_mvp/stream/services/event_converter.py +83 -0
- infra_mvp/stream/services/session_service.py +247 -0
- yera/__init__.py +50 -1
- yera/agents/__init__.py +2 -0
- yera/agents/context.py +41 -0
- yera/agents/dataclasses.py +69 -0
- yera/agents/decorator.py +207 -0
- yera/agents/discovery.py +124 -0
- yera/agents/typing/__init__.py +0 -0
- yera/agents/typing/coerce.py +408 -0
- yera/agents/typing/utils.py +19 -0
- yera/agents/typing/validate.py +206 -0
- yera/cli.py +377 -0
- yera/config/__init__.py +1 -0
- yera/config/config_utils.py +164 -0
- yera/config/function_config.py +55 -0
- yera/config/logging.py +18 -0
- yera/config/tool_config.py +8 -0
- yera/config2/__init__.py +8 -0
- yera/config2/dataclasses.py +534 -0
- yera/config2/keyring.py +270 -0
- yera/config2/paths.py +28 -0
- yera/config2/read.py +113 -0
- yera/config2/setup.py +109 -0
- yera/config2/setup_handlers/__init__.py +1 -0
- yera/config2/setup_handlers/anthropic.py +126 -0
- yera/config2/setup_handlers/azure.py +236 -0
- yera/config2/setup_handlers/base.py +125 -0
- yera/config2/setup_handlers/llama_cpp.py +205 -0
- yera/config2/setup_handlers/ollama.py +157 -0
- yera/config2/setup_handlers/openai.py +137 -0
- yera/config2/write.py +87 -0
- yera/dsl/__init__.py +0 -0
- yera/dsl/functions.py +94 -0
- yera/dsl/struct.py +20 -0
- yera/dsl/workspace.py +79 -0
- yera/events/__init__.py +57 -0
- yera/events/blocks/__init__.py +68 -0
- yera/events/blocks/action.py +57 -0
- yera/events/blocks/bar_chart.py +92 -0
- yera/events/blocks/base/__init__.py +20 -0
- yera/events/blocks/base/base.py +166 -0
- yera/events/blocks/base/chart.py +288 -0
- yera/events/blocks/base/layout.py +111 -0
- yera/events/blocks/buttons.py +37 -0
- yera/events/blocks/columns.py +26 -0
- yera/events/blocks/container.py +24 -0
- yera/events/blocks/date_picker.py +50 -0
- yera/events/blocks/exit.py +39 -0
- yera/events/blocks/form.py +24 -0
- yera/events/blocks/input_echo.py +22 -0
- yera/events/blocks/input_request.py +31 -0
- yera/events/blocks/line_chart.py +97 -0
- yera/events/blocks/markdown.py +67 -0
- yera/events/blocks/slider.py +54 -0
- yera/events/blocks/spinner.py +55 -0
- yera/events/blocks/system_prompt.py +22 -0
- yera/events/blocks/table.py +291 -0
- yera/events/models/__init__.py +39 -0
- yera/events/models/block_data.py +112 -0
- yera/events/models/in_event.py +7 -0
- yera/events/models/out_event.py +75 -0
- yera/events/runtime.py +187 -0
- yera/events/stream.py +91 -0
- yera/models/__init__.py +0 -0
- yera/models/data_classes.py +20 -0
- yera/models/llm_atlas_proxy.py +44 -0
- yera/models/llm_context.py +99 -0
- yera/models/llm_interfaces/__init__.py +0 -0
- yera/models/llm_interfaces/anthropic.py +153 -0
- yera/models/llm_interfaces/aws_bedrock.py +14 -0
- yera/models/llm_interfaces/azure_openai.py +143 -0
- yera/models/llm_interfaces/base.py +26 -0
- yera/models/llm_interfaces/interface_registry.py +74 -0
- yera/models/llm_interfaces/llama_cpp.py +136 -0
- yera/models/llm_interfaces/mock.py +29 -0
- yera/models/llm_interfaces/ollama_interface.py +118 -0
- yera/models/llm_interfaces/open_ai.py +150 -0
- yera/models/llm_workspace.py +19 -0
- yera/models/model_atlas.py +139 -0
- yera/models/model_definition.py +38 -0
- yera/models/model_factory.py +33 -0
- yera/opaque/__init__.py +9 -0
- yera/opaque/base.py +20 -0
- yera/opaque/decorator.py +8 -0
- yera/opaque/markdown.py +57 -0
- yera/opaque/opaque_function.py +25 -0
- yera/tools/__init__.py +29 -0
- yera/tools/atlas_tool.py +20 -0
- yera/tools/base.py +24 -0
- yera/tools/decorated_tool.py +18 -0
- yera/tools/decorator.py +35 -0
- yera/tools/tool_atlas.py +51 -0
- yera/tools/tool_utils.py +361 -0
- yera/ui/dist/404.html +1 -0
- yera/ui/dist/__next.__PAGE__.txt +10 -0
- yera/ui/dist/__next._full.txt +23 -0
- yera/ui/dist/__next._head.txt +6 -0
- yera/ui/dist/__next._index.txt +5 -0
- yera/ui/dist/__next._tree.txt +7 -0
- yera/ui/dist/_next/static/chunks/4c4688e1ff21ad98.js +1 -0
- yera/ui/dist/_next/static/chunks/652cd53c27924d50.js +4 -0
- yera/ui/dist/_next/static/chunks/786d2107b51e8499.css +1 -0
- yera/ui/dist/_next/static/chunks/7de9141b1af425c3.js +1 -0
- yera/ui/dist/_next/static/chunks/87ef65064d3524c1.js +2 -0
- yera/ui/dist/_next/static/chunks/a6dad97d9634a72d.js +1 -0
- yera/ui/dist/_next/static/chunks/a6dad97d9634a72d.js.map +1 -0
- yera/ui/dist/_next/static/chunks/c4c79d5d0b280aeb.js +1 -0
- yera/ui/dist/_next/static/chunks/dc2d2a247505d66f.css +5 -0
- yera/ui/dist/_next/static/chunks/f773f714b55ec620.js +37 -0
- yera/ui/dist/_next/static/chunks/turbopack-98b3031e1b1dbc33.js +4 -0
- yera/ui/dist/_next/static/lnhYLzJ1-a5EfNbW1uFF6/_buildManifest.js +11 -0
- yera/ui/dist/_next/static/lnhYLzJ1-a5EfNbW1uFF6/_clientMiddlewareManifest.json +1 -0
- yera/ui/dist/_next/static/lnhYLzJ1-a5EfNbW1uFF6/_ssgManifest.js +1 -0
- yera/ui/dist/_next/static/media/14e23f9b59180572-s.9c448f3c.woff2 +0 -0
- yera/ui/dist/_next/static/media/2a65768255d6b625-s.p.d19752fb.woff2 +0 -0
- yera/ui/dist/_next/static/media/2b2eb4836d2dad95-s.f36de3af.woff2 +0 -0
- yera/ui/dist/_next/static/media/31183d9fd602dc89-s.c4ff9b73.woff2 +0 -0
- yera/ui/dist/_next/static/media/3fcb63a1ac6a562e-s.2f77a576.woff2 +0 -0
- yera/ui/dist/_next/static/media/45ec8de98929b0f6-s.81056204.woff2 +0 -0
- yera/ui/dist/_next/static/media/4fa387ec64143e14-s.c1fdd6c2.woff2 +0 -0
- yera/ui/dist/_next/static/media/65c558afe41e89d6-s.e2c8389a.woff2 +0 -0
- yera/ui/dist/_next/static/media/67add6cc0f54b8cf-s.8ce53448.woff2 +0 -0
- yera/ui/dist/_next/static/media/7178b3e590c64307-s.b97b3418.woff2 +0 -0
- yera/ui/dist/_next/static/media/797e433ab948586e-s.p.dbea232f.woff2 +0 -0
- yera/ui/dist/_next/static/media/8a480f0b521d4e75-s.8e0177b5.woff2 +0 -0
- yera/ui/dist/_next/static/media/a8ff2d5d0ccb0d12-s.fc5b72a7.woff2 +0 -0
- yera/ui/dist/_next/static/media/aae5f0be330e13db-s.p.853e26d6.woff2 +0 -0
- yera/ui/dist/_next/static/media/b11a6ccf4a3edec7-s.2113d282.woff2 +0 -0
- yera/ui/dist/_next/static/media/b49b0d9b851e4899-s.4f3fa681.woff2 +0 -0
- yera/ui/dist/_next/static/media/bbc41e54d2fcbd21-s.799d8ef8.woff2 +0 -0
- yera/ui/dist/_next/static/media/caa3a2e1cccd8315-s.p.853070df.woff2 +0 -0
- yera/ui/dist/_next/static/media/favicon.0b3bf435.ico +0 -0
- yera/ui/dist/_not-found/__next._full.txt +14 -0
- yera/ui/dist/_not-found/__next._head.txt +6 -0
- yera/ui/dist/_not-found/__next._index.txt +5 -0
- yera/ui/dist/_not-found/__next._not-found.__PAGE__.txt +5 -0
- yera/ui/dist/_not-found/__next._not-found.txt +4 -0
- yera/ui/dist/_not-found/__next._tree.txt +2 -0
- yera/ui/dist/_not-found.html +1 -0
- yera/ui/dist/_not-found.txt +14 -0
- yera/ui/dist/agent-icon.svg +3 -0
- yera/ui/dist/favicon.ico +0 -0
- yera/ui/dist/file.svg +1 -0
- yera/ui/dist/globe.svg +1 -0
- yera/ui/dist/index.html +1 -0
- yera/ui/dist/index.txt +23 -0
- yera/ui/dist/logo/full_logo.png +0 -0
- yera/ui/dist/logo/rune_logo.png +0 -0
- yera/ui/dist/logo/rune_logo_borderless.png +0 -0
- yera/ui/dist/logo/text_logo.png +0 -0
- yera/ui/dist/next.svg +1 -0
- yera/ui/dist/send.png +0 -0
- yera/ui/dist/send_single.png +0 -0
- yera/ui/dist/vercel.svg +1 -0
- yera/ui/dist/window.svg +1 -0
- yera/utils/__init__.py +1 -0
- yera/utils/path_utils.py +38 -0
- yera-0.2.0.dist-info/METADATA +65 -0
- yera-0.2.0.dist-info/RECORD +190 -0
- {yera-0.1.0.dist-info → yera-0.2.0.dist-info}/WHEEL +1 -1
- yera-0.2.0.dist-info/entry_points.txt +2 -0
- yera-0.1.0.dist-info/METADATA +0 -11
- yera-0.1.0.dist-info/RECORD +0 -4
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Branching Test",
|
|
3
|
+
"description": "This agent demonstrates branching functionality where user choices determine which conversation branch to follow.",
|
|
4
|
+
"branches": {
|
|
5
|
+
"start": [
|
|
6
|
+
{
|
|
7
|
+
"message_type": "informational",
|
|
8
|
+
"block_type": "markdown",
|
|
9
|
+
"block_id": "welcome",
|
|
10
|
+
"data": {
|
|
11
|
+
"content": "Welcome! "
|
|
12
|
+
},
|
|
13
|
+
"timestamp": "2025-01-15T10:00:00Z",
|
|
14
|
+
"chunk_id": 1,
|
|
15
|
+
"agent": {
|
|
16
|
+
"name": "Branching Test Agent",
|
|
17
|
+
"instance_id": 1
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"message_type": "informational",
|
|
22
|
+
"block_type": "markdown",
|
|
23
|
+
"block_id": "welcome",
|
|
24
|
+
"data": {
|
|
25
|
+
"content": "Choose an option:"
|
|
26
|
+
},
|
|
27
|
+
"timestamp": "2025-01-15T10:00:00Z",
|
|
28
|
+
"chunk_id": 2,
|
|
29
|
+
"agent": {
|
|
30
|
+
"name": "Branching Test Agent",
|
|
31
|
+
"instance_id": 1
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"message_type": "await_user",
|
|
36
|
+
"block_type": "buttons",
|
|
37
|
+
"block_id": "test-choice",
|
|
38
|
+
"data": {
|
|
39
|
+
"options": ["Option A", "Option B"],
|
|
40
|
+
"label": "Select an option"
|
|
41
|
+
},
|
|
42
|
+
"branch_on": {
|
|
43
|
+
"Option A": "option-a-content",
|
|
44
|
+
"Option B": "option-b-content"
|
|
45
|
+
},
|
|
46
|
+
"timestamp": "2025-01-15T10:00:05Z",
|
|
47
|
+
"chunk_id": 1,
|
|
48
|
+
"agent": {
|
|
49
|
+
"name": "Branching Test Agent",
|
|
50
|
+
"instance_id": 1
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"should_skip": [
|
|
55
|
+
{
|
|
56
|
+
"message_type": "informational",
|
|
57
|
+
"block_type": "markdown",
|
|
58
|
+
"block_id": "should-skip",
|
|
59
|
+
"data": {
|
|
60
|
+
"content": "This should be skipped"
|
|
61
|
+
},
|
|
62
|
+
"timestamp": "2025-01-15T10:00:10Z",
|
|
63
|
+
"chunk_id": 1,
|
|
64
|
+
"agent": {
|
|
65
|
+
"name": "Branching Test Agent",
|
|
66
|
+
"instance_id": 1
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"message_type": "informational",
|
|
71
|
+
"block_type": "markdown",
|
|
72
|
+
"block_id": "should-skip",
|
|
73
|
+
"data": {
|
|
74
|
+
"content": "If you see this, branching failed"
|
|
75
|
+
},
|
|
76
|
+
"timestamp": "2025-01-15T10:00:10Z",
|
|
77
|
+
"chunk_id": 2,
|
|
78
|
+
"agent": {
|
|
79
|
+
"name": "Branching Test Agent",
|
|
80
|
+
"instance_id": 1
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"option-a-content": [
|
|
85
|
+
{
|
|
86
|
+
"message_type": "informational",
|
|
87
|
+
"block_type": "markdown",
|
|
88
|
+
"block_id": "option-a-content",
|
|
89
|
+
"data": {
|
|
90
|
+
"content": "You chose Option A!\n\n"
|
|
91
|
+
},
|
|
92
|
+
"timestamp": "2025-01-15T10:00:15Z",
|
|
93
|
+
"chunk_id": 1,
|
|
94
|
+
"agent": {
|
|
95
|
+
"name": "Branching Test Agent",
|
|
96
|
+
"instance_id": 1
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"message_type": "informational",
|
|
101
|
+
"block_type": "markdown",
|
|
102
|
+
"block_id": "option-a-content",
|
|
103
|
+
"data": {
|
|
104
|
+
"content": "This is the A branch."
|
|
105
|
+
},
|
|
106
|
+
"timestamp": "2025-01-15T10:00:15Z",
|
|
107
|
+
"chunk_id": 2,
|
|
108
|
+
"agent": {
|
|
109
|
+
"name": "Branching Test Agent",
|
|
110
|
+
"instance_id": 1
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"option-b-content": [
|
|
115
|
+
{
|
|
116
|
+
"message_type": "informational",
|
|
117
|
+
"block_type": "markdown",
|
|
118
|
+
"block_id": "option-b-content",
|
|
119
|
+
"data": {
|
|
120
|
+
"content": "You chose Option B!\n\n"
|
|
121
|
+
},
|
|
122
|
+
"timestamp": "2025-01-15T10:00:20Z",
|
|
123
|
+
"chunk_id": 1,
|
|
124
|
+
"agent": {
|
|
125
|
+
"name": "Branching Test Agent",
|
|
126
|
+
"instance_id": 1
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"message_type": "informational",
|
|
131
|
+
"block_type": "markdown",
|
|
132
|
+
"block_id": "option-b-content",
|
|
133
|
+
"data": {
|
|
134
|
+
"content": "This is the B branch."
|
|
135
|
+
},
|
|
136
|
+
"timestamp": "2025-01-15T10:00:20Z",
|
|
137
|
+
"chunk_id": 2,
|
|
138
|
+
"agent": {
|
|
139
|
+
"name": "Branching Test Agent",
|
|
140
|
+
"instance_id": 1
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
}
|
infra_mvp/stream/app.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""ASGI entrypoint for the StreamServer.
|
|
2
|
+
|
|
3
|
+
This exposes a FastAPI ``app`` so that you can run the stream server with
|
|
4
|
+
uvicorn's ``--reload`` for live updates during UI development.
|
|
5
|
+
|
|
6
|
+
Usage:
|
|
7
|
+
AGENT_PATH=demos/agents/basic_chatbot.py uv run uvicorn infra_mvp.stream.app:app --host 0.0.0.0 --port 8991 --reload
|
|
8
|
+
|
|
9
|
+
Note: AGENT_PATH environment variable is required and must point to a Python file containing an agent.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import os
|
|
13
|
+
import sys
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
from infra_mvp.stream.container import create_stream_server
|
|
17
|
+
from yera.agents.discovery import load_agent
|
|
18
|
+
|
|
19
|
+
# Create the container and underlying StreamServer.
|
|
20
|
+
# Respect HOST/PORT environment variables so that running via
|
|
21
|
+
# `uvicorn infra_mvp.stream.app:app` (as done by the container entrypoint)
|
|
22
|
+
# will bind to the intended network interface instead of defaulting to
|
|
23
|
+
# 127.0.0.1 which prevents external access from Kubernetes probes.
|
|
24
|
+
env_host = os.getenv("HOST", "0.0.0.0")
|
|
25
|
+
env_port = int(os.getenv("PORT", "8991"))
|
|
26
|
+
agent_path = os.getenv("AGENT_PATH")
|
|
27
|
+
|
|
28
|
+
if not agent_path:
|
|
29
|
+
print(
|
|
30
|
+
"Error: AGENT_PATH environment variable is required.",
|
|
31
|
+
"Example: AGENT_PATH=demos/agents/basic_chatbot.py",
|
|
32
|
+
file=sys.stderr,
|
|
33
|
+
)
|
|
34
|
+
sys.exit(1)
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
agent_wrapper = load_agent(Path(agent_path))
|
|
38
|
+
except (FileNotFoundError, ValueError) as e:
|
|
39
|
+
print(f"Error loading agent: {e}", file=sys.stderr)
|
|
40
|
+
sys.exit(1)
|
|
41
|
+
|
|
42
|
+
_server = create_stream_server(
|
|
43
|
+
agent=agent_wrapper,
|
|
44
|
+
host=env_host,
|
|
45
|
+
port=env_port,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
# Expose the FastAPI application configured by BaseServer (includes CORS middleware)
|
|
49
|
+
app = _server.app
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""Dependency injection container for stream module."""
|
|
2
|
+
|
|
3
|
+
from dependency_injector import containers, providers
|
|
4
|
+
|
|
5
|
+
from infra_mvp.stream.server import StreamServer
|
|
6
|
+
from yera.agents.decorator import AgentFunctionWrapper
|
|
7
|
+
|
|
8
|
+
from .services import AgentService, SessionService
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class StreamContainer(containers.DeclarativeContainer):
|
|
12
|
+
"""Dependency injection container for stream services."""
|
|
13
|
+
|
|
14
|
+
# Configuration
|
|
15
|
+
config = providers.Configuration()
|
|
16
|
+
config.host.from_value("0.0.0.0")
|
|
17
|
+
config.port.from_value(8991)
|
|
18
|
+
config.agents.from_value([])
|
|
19
|
+
config.dev_ui.from_value(False)
|
|
20
|
+
|
|
21
|
+
# Services - all singletons (stateless)
|
|
22
|
+
session_service: providers.Singleton[SessionService] | None = None
|
|
23
|
+
agent_service: providers.Singleton[AgentService] | None = None
|
|
24
|
+
|
|
25
|
+
# Stream server provider - creates fully-formed server
|
|
26
|
+
# Will be set by create_container
|
|
27
|
+
stream_server: providers.Singleton[StreamServer] | None = None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def create_container(
|
|
31
|
+
agents: list[AgentFunctionWrapper],
|
|
32
|
+
host: str = "0.0.0.0",
|
|
33
|
+
port: int = 8991,
|
|
34
|
+
log_events: bool = False,
|
|
35
|
+
dev_ui: bool = False,
|
|
36
|
+
) -> StreamContainer:
|
|
37
|
+
"""Create and configure a stream container for agent mode.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
agents: List of agent function wrappers.
|
|
41
|
+
host: Server host address. Defaults to "0.0.0.0".
|
|
42
|
+
port: Server port number. Defaults to 8991.
|
|
43
|
+
log_events: Enable logging of events to file.
|
|
44
|
+
dev_ui: If True, expect Next.js dev server (localhost:3000) instead of serving static UI.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
Configured stream container
|
|
48
|
+
"""
|
|
49
|
+
container = StreamContainer()
|
|
50
|
+
|
|
51
|
+
# Create SessionService
|
|
52
|
+
container.session_service = providers.Singleton(
|
|
53
|
+
SessionService,
|
|
54
|
+
log_events=log_events,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Create AgentService
|
|
58
|
+
container.agent_service = providers.Singleton(
|
|
59
|
+
AgentService,
|
|
60
|
+
agents=agents,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
# Configure host, port and UI serving
|
|
64
|
+
container.config.host.from_value(host)
|
|
65
|
+
container.config.port.from_value(port)
|
|
66
|
+
container.config.dev_ui.from_value(dev_ui)
|
|
67
|
+
|
|
68
|
+
# Store agents in config for factory to access
|
|
69
|
+
container.config.agents.from_value(agents)
|
|
70
|
+
|
|
71
|
+
# Create stream server factory that captures the container
|
|
72
|
+
def _create_stream_server() -> StreamServer:
|
|
73
|
+
return StreamServer(
|
|
74
|
+
session_service=container.session_service(),
|
|
75
|
+
agent_service=container.agent_service(),
|
|
76
|
+
host=container.config.host(),
|
|
77
|
+
port=container.config.port(),
|
|
78
|
+
dev_ui=container.config.dev_ui(),
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
container.stream_server = providers.Singleton(_create_stream_server)
|
|
82
|
+
|
|
83
|
+
return container
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def create_stream_server(
|
|
87
|
+
agents: list[AgentFunctionWrapper],
|
|
88
|
+
host: str = "0.0.0.0",
|
|
89
|
+
port: int = 8991,
|
|
90
|
+
log_events: bool = False,
|
|
91
|
+
dev_ui: bool = False,
|
|
92
|
+
) -> StreamServer:
|
|
93
|
+
"""Create a stream server for agent mode.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
agents: List of agent function wrappers.
|
|
97
|
+
host: Server host address. Defaults to "0.0.0.0".
|
|
98
|
+
port: Server port number. Defaults to 8991.
|
|
99
|
+
log_events: Enable logging of events to file.
|
|
100
|
+
dev_ui: If True, expect Next.js dev server (localhost:3000) instead of serving static UI.
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
Configured stream server instance
|
|
104
|
+
"""
|
|
105
|
+
container = create_container(
|
|
106
|
+
agents=agents,
|
|
107
|
+
host=host,
|
|
108
|
+
port=port,
|
|
109
|
+
log_events=log_events,
|
|
110
|
+
dev_ui=dev_ui,
|
|
111
|
+
)
|
|
112
|
+
return container.stream_server()
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Stream server Pydantic schemas package."""
|
|
2
|
+
|
|
3
|
+
from .agent import AgentMetadata, ListAgentsResponse
|
|
4
|
+
from .interaction import AddInteractionResponse, LayoutSubBlock, UserInteraction
|
|
5
|
+
from .session import CreateSessionResponse, SessionCreateRequest, SessionState
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"AddInteractionResponse",
|
|
9
|
+
"AgentMetadata",
|
|
10
|
+
"CreateSessionResponse",
|
|
11
|
+
"LayoutSubBlock",
|
|
12
|
+
"ListAgentsResponse",
|
|
13
|
+
"SessionCreateRequest",
|
|
14
|
+
"SessionState",
|
|
15
|
+
"UserInteraction",
|
|
16
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Agent metadata schemas for API responses."""
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, Field
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class AgentMetadata(BaseModel):
|
|
7
|
+
"""Minimal agent metadata for list endpoints.
|
|
8
|
+
|
|
9
|
+
Contains only the fields needed for displaying agents in lists,
|
|
10
|
+
cards, and hierarchical navigation.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
id: str = Field(description="Agent identifier (dotted module.function name)")
|
|
14
|
+
name: str = Field(description="Agent display name")
|
|
15
|
+
description: str | None = Field(default=None, description="Agent description")
|
|
16
|
+
path: list[str] = Field(
|
|
17
|
+
description="Folder hierarchy path (empty for single-agent CLI mode)"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ListAgentsResponse(BaseModel):
|
|
22
|
+
"""Response schema for listing agents."""
|
|
23
|
+
|
|
24
|
+
agents: list[AgentMetadata] = Field(description="List of agents")
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Interaction request and response schemas."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class LayoutSubBlock(BaseModel):
|
|
9
|
+
"""Schema for a layout sub-block in an interaction."""
|
|
10
|
+
|
|
11
|
+
sub_block_id: str
|
|
12
|
+
sub_block_type: str
|
|
13
|
+
value: Any
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class UserInteraction(BaseModel):
|
|
17
|
+
"""Schema for a user interaction."""
|
|
18
|
+
|
|
19
|
+
blockId: str
|
|
20
|
+
value: Any
|
|
21
|
+
blockType: str
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class AddInteractionResponse(BaseModel):
|
|
25
|
+
"""Response schema for interaction handling."""
|
|
26
|
+
|
|
27
|
+
status: str
|
|
28
|
+
session_id: str
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Session request and response schemas."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel
|
|
6
|
+
|
|
7
|
+
from yera.agents.decorator import AgentFunctionWrapper
|
|
8
|
+
from yera.events.runtime import PyRuntimeExecutor
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass
|
|
12
|
+
class SessionState:
|
|
13
|
+
"""Session state for Python agent sessions."""
|
|
14
|
+
|
|
15
|
+
agent: AgentFunctionWrapper
|
|
16
|
+
executor: PyRuntimeExecutor
|
|
17
|
+
session_id: str
|
|
18
|
+
interactions: list[dict] = field(default_factory=list)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class SessionCreateRequest(BaseModel):
|
|
22
|
+
"""Request schema for creating a session."""
|
|
23
|
+
|
|
24
|
+
agent_id: str
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class CreateSessionResponse(BaseModel):
|
|
28
|
+
"""Response schema for session creation."""
|
|
29
|
+
|
|
30
|
+
session_id: str
|