google-adk-extras 0.2.5__tar.gz → 0.2.7__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.
- {google_adk_extras-0.2.5/src/google_adk_extras.egg-info → google_adk_extras-0.2.7}/PKG-INFO +12 -34
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/README.md +10 -32
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/docs/examples.md +1 -1
- google_adk_extras-0.2.7/docs/streaming.md +119 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/examples/README.md +1 -1
- google_adk_extras-0.2.7/examples/streaming_sse_ws.py +31 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/mkdocs.yml +2 -2
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/pyproject.toml +16 -2
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/__init__.py +3 -3
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/adk_builder.py +15 -292
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/artifacts/local_folder_artifact_service.py +0 -2
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/artifacts/mongo_artifact_service.py +0 -1
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/artifacts/s3_artifact_service.py +0 -1
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/artifacts/sql_artifact_service.py +0 -1
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/custom_agent_loader.py +1 -1
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/enhanced_adk_web_server.py +0 -2
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/enhanced_fastapi.py +97 -1
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/memory/mongo_memory_service.py +0 -1
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/memory/sql_memory_service.py +1 -1
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/memory/yaml_file_memory_service.py +1 -3
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/sessions/mongo_session_service.py +0 -1
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/sessions/redis_session_service.py +1 -1
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/sessions/yaml_file_session_service.py +0 -2
- google_adk_extras-0.2.7/src/google_adk_extras/streaming/__init__.py +12 -0
- google_adk_extras-0.2.7/src/google_adk_extras/streaming/streaming_controller.py +262 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7/src/google_adk_extras.egg-info}/PKG-INFO +12 -34
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras.egg-info/SOURCES.txt +4 -9
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/tests/test_a2a_helpers.py +1 -2
- google_adk_extras-0.2.5/docs/credentials.md +0 -31
- google_adk_extras-0.2.5/examples/credentials/google_oauth2.py +0 -27
- google_adk_extras-0.2.5/src/google_adk_extras/credentials/__init__.py +0 -34
- google_adk_extras-0.2.5/src/google_adk_extras/credentials/github_oauth2_credential_service.py +0 -213
- google_adk_extras-0.2.5/src/google_adk_extras/credentials/google_oauth2_credential_service.py +0 -216
- google_adk_extras-0.2.5/src/google_adk_extras/credentials/http_basic_auth_credential_service.py +0 -388
- google_adk_extras-0.2.5/src/google_adk_extras/credentials/jwt_credential_service.py +0 -345
- google_adk_extras-0.2.5/src/google_adk_extras/credentials/microsoft_oauth2_credential_service.py +0 -250
- google_adk_extras-0.2.5/src/google_adk_extras/credentials/x_oauth2_credential_service.py +0 -240
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/LICENSE +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/MANIFEST.in +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/docs/agent-loading.md +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/docs/fastapi.md +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/docs/getting-started.md +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/docs/index.md +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/docs/quickstarts.md +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/docs/services.md +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/docs/troubleshooting.md +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/docs/uris.md +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/examples/consume_remote_a2a.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/examples/custom_loader.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/examples/fastapi_app.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/examples/programmatic_a2a_expose.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/examples/runner_basic.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/examples/services/artifacts_local.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/examples/services/memory_yaml.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/examples/services/sessions_sql.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/setup.cfg +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/setup.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/artifacts/__init__.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/artifacts/base_custom_artifact_service.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/credentials/base_custom_credential_service.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/enhanced_runner.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/memory/__init__.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/memory/base_custom_memory_service.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/memory/redis_memory_service.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/sessions/__init__.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/sessions/base_custom_session_service.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras/sessions/sql_session_service.py +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras.egg-info/dependency_links.txt +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras.egg-info/requires.txt +0 -0
- {google_adk_extras-0.2.5 → google_adk_extras-0.2.7}/src/google_adk_extras.egg-info/top_level.txt +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: google-adk-extras
|
3
|
-
Version: 0.2.
|
4
|
-
Summary: Production-ready services
|
3
|
+
Version: 0.2.7
|
4
|
+
Summary: Production-ready services and FastAPI wiring for Google ADK
|
5
5
|
Home-page: https://github.com/DeadMeme5441/google-adk-extras
|
6
6
|
Author: DeadMeme5441
|
7
7
|
Author-email: DeadMeme5441 <deadunderscorememe@gmail.com>
|
@@ -49,7 +49,7 @@ Dynamic: requires-python
|
|
49
49
|
[](https://deadmeme5441.github.io/google-adk-extras/)
|
50
50
|
[](https://github.com/DeadMeme5441/google-adk-extras/actions/workflows/docs.yml)
|
51
51
|
|
52
|
-
Production-ready extensions for Google ADK (Agent Development Kit). This library adds durable service backends (sessions, artifacts, memory)
|
52
|
+
Production-ready extensions for Google ADK (Agent Development Kit). This library adds durable service backends (sessions, artifacts, memory) and clean FastAPI wiring (with optional streaming) so you can run ADK agents with real storage.
|
53
53
|
|
54
54
|
What this is not: a fork of ADK. It builds on ADK’s core runtime, agents, tools and callbacks, and drops in where ADK expects services and a web server.
|
55
55
|
|
@@ -58,10 +58,9 @@ What this is not: a fork of ADK. It builds on ADK’s core runtime, agents, tool
|
|
58
58
|
|
59
59
|
ADK provides the core primitives (Runner, Session/State, MemoryService, ArtifactService, CredentialService, Agents/Tools, callbacks, Dev UI, and deployment paths). See the official ADK docs for concepts and APIs.
|
60
60
|
|
61
|
-
This package focuses on
|
61
|
+
This package focuses on a few gaps common in real apps:
|
62
62
|
- Durable storage backends beyond in‑memory defaults
|
63
|
-
-
|
64
|
-
- FastAPI integration that accepts your credential service without hacks
|
63
|
+
- FastAPI integration with optional streaming (SSE/WS)
|
65
64
|
|
66
65
|
|
67
66
|
## Features
|
@@ -69,8 +68,7 @@ This package focuses on three gaps common in real apps:
|
|
69
68
|
- Session services: SQL (SQLite/Postgres/MySQL), MongoDB, Redis, YAML files
|
70
69
|
- Artifact services: Local folder (versioned), S3‑compatible, SQL, MongoDB
|
71
70
|
- Memory services: SQL, MongoDB, Redis, YAML files (term search over text parts)
|
72
|
-
-
|
73
|
-
- Enhanced FastAPI wiring that respects a provided credential service
|
71
|
+
- Enhanced FastAPI wiring for ADK apps (with optional streaming)
|
74
72
|
- Fluent builder (`AdkBuilder`) to assemble a FastAPI app or a Runner
|
75
73
|
- A2A helpers for exposing/consuming agents (see below)
|
76
74
|
|
@@ -95,17 +93,17 @@ If you plan to use specific backends, also install their clients (examples):
|
|
95
93
|
- MongoDB: `uv pip install pymongo`
|
96
94
|
- Redis: `uv pip install redis`
|
97
95
|
- S3: `uv pip install boto3`
|
98
|
-
|
96
|
+
|
97
|
+
Note on credentials (0.2.7): This release removes custom credential services and URI helpers from this package. For outbound credentials used by tools, rely on ADK’s experimental BaseCredentialService (e.g., InMemory/SessionState) or your own ADK-compatible implementation. Inbound API authentication (protecting /run and streaming routes) will be provided as an optional FastAPI layer separately.
|
99
98
|
|
100
99
|
|
101
100
|
## Quickstart (FastAPI)
|
102
101
|
|
103
|
-
Use the fluent builder to wire services
|
102
|
+
Use the fluent builder to wire services. Then run with uvicorn.
|
104
103
|
|
105
104
|
```python
|
106
105
|
# app.py
|
107
106
|
from google_adk_extras import AdkBuilder
|
108
|
-
from google_adk_extras.credentials import GoogleOAuth2CredentialService
|
109
107
|
|
110
108
|
app = (
|
111
109
|
AdkBuilder()
|
@@ -113,11 +111,7 @@ app = (
|
|
113
111
|
.with_session_service("sqlite:///./sessions.db") # or: mongodb://, redis://, yaml://
|
114
112
|
.with_artifact_service("local://./artifacts") # or: s3://bucket, mongodb://, sql://
|
115
113
|
.with_memory_service("yaml://./memory") # or: redis://, mongodb://, sql://
|
116
|
-
|
117
|
-
client_id="…apps.googleusercontent.com",
|
118
|
-
client_secret="…",
|
119
|
-
scopes=["openid", "email", "profile"],
|
120
|
-
))
|
114
|
+
# credentials: rely on ADK defaults or pass an ADK BaseCredentialService if needed
|
121
115
|
.with_web_ui(True) # serve ADK’s dev UI if assets available
|
122
116
|
.with_agent_reload(True)
|
123
117
|
.build_fastapi_app()
|
@@ -251,24 +245,8 @@ app = (
|
|
251
245
|
```
|
252
246
|
|
253
247
|
|
254
|
-
|
255
|
-
|
256
|
-
If you prefer URIs instead of constructing services:
|
257
|
-
|
258
|
-
- Google OAuth2: `oauth2-google://client_id:secret@scopes=openid,email,profile`
|
259
|
-
- GitHub OAuth2: `oauth2-github://client_id:secret@scopes=user,repo`
|
260
|
-
- Microsoft OAuth2: `oauth2-microsoft://<tenant>/<client_id>:<secret>@scopes=User.Read`
|
261
|
-
- X OAuth2: `oauth2-x://client_id:secret@scopes=tweet.read,users.read`
|
262
|
-
- JWT: `jwt://<secret>@algorithm=HS256&issuer=my-app&audience=api.example.com&expiration_minutes=60`
|
263
|
-
- Basic: `basic-auth://username:password@realm=My%20API`
|
264
|
-
|
265
|
-
```python
|
266
|
-
cred = (
|
267
|
-
AdkBuilder()
|
268
|
-
.with_credential_service_uri("jwt://secret@issuer=my-app")
|
269
|
-
._create_credential_service()
|
270
|
-
)
|
271
|
-
```
|
248
|
+
<!-- Credential URI helpers removed. Use ADK’s BaseCredentialService directly if needed,
|
249
|
+
and handle inbound API authentication at FastAPI level. -->
|
272
250
|
|
273
251
|
|
274
252
|
## Notes & limitations
|
@@ -6,7 +6,7 @@
|
|
6
6
|
[](https://deadmeme5441.github.io/google-adk-extras/)
|
7
7
|
[](https://github.com/DeadMeme5441/google-adk-extras/actions/workflows/docs.yml)
|
8
8
|
|
9
|
-
Production-ready extensions for Google ADK (Agent Development Kit). This library adds durable service backends (sessions, artifacts, memory)
|
9
|
+
Production-ready extensions for Google ADK (Agent Development Kit). This library adds durable service backends (sessions, artifacts, memory) and clean FastAPI wiring (with optional streaming) so you can run ADK agents with real storage.
|
10
10
|
|
11
11
|
What this is not: a fork of ADK. It builds on ADK’s core runtime, agents, tools and callbacks, and drops in where ADK expects services and a web server.
|
12
12
|
|
@@ -15,10 +15,9 @@ What this is not: a fork of ADK. It builds on ADK’s core runtime, agents, tool
|
|
15
15
|
|
16
16
|
ADK provides the core primitives (Runner, Session/State, MemoryService, ArtifactService, CredentialService, Agents/Tools, callbacks, Dev UI, and deployment paths). See the official ADK docs for concepts and APIs.
|
17
17
|
|
18
|
-
This package focuses on
|
18
|
+
This package focuses on a few gaps common in real apps:
|
19
19
|
- Durable storage backends beyond in‑memory defaults
|
20
|
-
-
|
21
|
-
- FastAPI integration that accepts your credential service without hacks
|
20
|
+
- FastAPI integration with optional streaming (SSE/WS)
|
22
21
|
|
23
22
|
|
24
23
|
## Features
|
@@ -26,8 +25,7 @@ This package focuses on three gaps common in real apps:
|
|
26
25
|
- Session services: SQL (SQLite/Postgres/MySQL), MongoDB, Redis, YAML files
|
27
26
|
- Artifact services: Local folder (versioned), S3‑compatible, SQL, MongoDB
|
28
27
|
- Memory services: SQL, MongoDB, Redis, YAML files (term search over text parts)
|
29
|
-
-
|
30
|
-
- Enhanced FastAPI wiring that respects a provided credential service
|
28
|
+
- Enhanced FastAPI wiring for ADK apps (with optional streaming)
|
31
29
|
- Fluent builder (`AdkBuilder`) to assemble a FastAPI app or a Runner
|
32
30
|
- A2A helpers for exposing/consuming agents (see below)
|
33
31
|
|
@@ -52,17 +50,17 @@ If you plan to use specific backends, also install their clients (examples):
|
|
52
50
|
- MongoDB: `uv pip install pymongo`
|
53
51
|
- Redis: `uv pip install redis`
|
54
52
|
- S3: `uv pip install boto3`
|
55
|
-
|
53
|
+
|
54
|
+
Note on credentials (0.2.7): This release removes custom credential services and URI helpers from this package. For outbound credentials used by tools, rely on ADK’s experimental BaseCredentialService (e.g., InMemory/SessionState) or your own ADK-compatible implementation. Inbound API authentication (protecting /run and streaming routes) will be provided as an optional FastAPI layer separately.
|
56
55
|
|
57
56
|
|
58
57
|
## Quickstart (FastAPI)
|
59
58
|
|
60
|
-
Use the fluent builder to wire services
|
59
|
+
Use the fluent builder to wire services. Then run with uvicorn.
|
61
60
|
|
62
61
|
```python
|
63
62
|
# app.py
|
64
63
|
from google_adk_extras import AdkBuilder
|
65
|
-
from google_adk_extras.credentials import GoogleOAuth2CredentialService
|
66
64
|
|
67
65
|
app = (
|
68
66
|
AdkBuilder()
|
@@ -70,11 +68,7 @@ app = (
|
|
70
68
|
.with_session_service("sqlite:///./sessions.db") # or: mongodb://, redis://, yaml://
|
71
69
|
.with_artifact_service("local://./artifacts") # or: s3://bucket, mongodb://, sql://
|
72
70
|
.with_memory_service("yaml://./memory") # or: redis://, mongodb://, sql://
|
73
|
-
|
74
|
-
client_id="…apps.googleusercontent.com",
|
75
|
-
client_secret="…",
|
76
|
-
scopes=["openid", "email", "profile"],
|
77
|
-
))
|
71
|
+
# credentials: rely on ADK defaults or pass an ADK BaseCredentialService if needed
|
78
72
|
.with_web_ui(True) # serve ADK’s dev UI if assets available
|
79
73
|
.with_agent_reload(True)
|
80
74
|
.build_fastapi_app()
|
@@ -208,24 +202,8 @@ app = (
|
|
208
202
|
```
|
209
203
|
|
210
204
|
|
211
|
-
|
212
|
-
|
213
|
-
If you prefer URIs instead of constructing services:
|
214
|
-
|
215
|
-
- Google OAuth2: `oauth2-google://client_id:secret@scopes=openid,email,profile`
|
216
|
-
- GitHub OAuth2: `oauth2-github://client_id:secret@scopes=user,repo`
|
217
|
-
- Microsoft OAuth2: `oauth2-microsoft://<tenant>/<client_id>:<secret>@scopes=User.Read`
|
218
|
-
- X OAuth2: `oauth2-x://client_id:secret@scopes=tweet.read,users.read`
|
219
|
-
- JWT: `jwt://<secret>@algorithm=HS256&issuer=my-app&audience=api.example.com&expiration_minutes=60`
|
220
|
-
- Basic: `basic-auth://username:password@realm=My%20API`
|
221
|
-
|
222
|
-
```python
|
223
|
-
cred = (
|
224
|
-
AdkBuilder()
|
225
|
-
.with_credential_service_uri("jwt://secret@issuer=my-app")
|
226
|
-
._create_credential_service()
|
227
|
-
)
|
228
|
-
```
|
205
|
+
<!-- Credential URI helpers removed. Use ADK’s BaseCredentialService directly if needed,
|
206
|
+
and handle inbound API authentication at FastAPI level. -->
|
229
207
|
|
230
208
|
|
231
209
|
## Notes & limitations
|
@@ -6,6 +6,6 @@ These examples are kept small and runnable; see the `examples/` folder.
|
|
6
6
|
- `examples/runner_basic.py` — runner without FastAPI.
|
7
7
|
- `examples/custom_loader.py` — programmatic agents.
|
8
8
|
- `examples/services/` — focused snippets per backend.
|
9
|
-
|
9
|
+
(credential service examples removed; rely on ADK defaults)
|
10
10
|
|
11
11
|
Install extras to match what you run, e.g. `uv pip install google-adk-extras[sql,yaml,web]`.
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# Streaming
|
2
|
+
|
3
|
+
The optional streaming layer adds a persistent, bi‑directional channel on top of
|
4
|
+
Google ADK’s existing `/run`, `/run_sse`, and `/run_live` primitives. It exposes
|
5
|
+
simple endpoints for a chat‑style UI while keeping strict ADK type parity.
|
6
|
+
|
7
|
+
- Uplink payload: the exact ADK `RunAgentRequest` (JSON)
|
8
|
+
- Downlink events: the exact ADK `Event` JSON
|
9
|
+
- Per‑channel binding to `(appName, userId, sessionId)`
|
10
|
+
|
11
|
+
## Enable
|
12
|
+
|
13
|
+
```python
|
14
|
+
from google_adk_extras import AdkBuilder
|
15
|
+
|
16
|
+
app = (
|
17
|
+
AdkBuilder()
|
18
|
+
.with_agents_dir("./agents") # or programmatic loader/instances
|
19
|
+
.build_fastapi_app(enable_streaming=True)
|
20
|
+
)
|
21
|
+
```
|
22
|
+
|
23
|
+
Optional config:
|
24
|
+
|
25
|
+
```python
|
26
|
+
from google_adk_extras.streaming import StreamingConfig
|
27
|
+
|
28
|
+
cfg = StreamingConfig(
|
29
|
+
streaming_path_base="/stream",
|
30
|
+
strict_types=True,
|
31
|
+
create_session_on_open=True, # create a new ADK session on first subscribe
|
32
|
+
ttl_seconds=900,
|
33
|
+
max_queue_size=128,
|
34
|
+
max_channels_per_user=20,
|
35
|
+
heartbeat_interval=20.0,
|
36
|
+
)
|
37
|
+
|
38
|
+
app = AdkBuilder().with_agents_dir("./agents").build_fastapi_app(
|
39
|
+
enable_streaming=True,
|
40
|
+
streaming_config=cfg,
|
41
|
+
)
|
42
|
+
```
|
43
|
+
|
44
|
+
## Endpoints (default base: `/stream`)
|
45
|
+
|
46
|
+
- `GET /stream/events/{channelId}?appName=&userId=&sessionId=` — SSE downlink
|
47
|
+
- If `sessionId` is omitted and `create_session_on_open=True`, a session is created.
|
48
|
+
- First, a control message is sent: `event: channel-bound` with `data: {appName,userId,sessionId}`.
|
49
|
+
- Subsequent `data: ...` lines contain raw ADK `Event` JSON.
|
50
|
+
|
51
|
+
- `POST /stream/send/{channelId}` — enqueue a single run on the bound channel
|
52
|
+
- Body must be a strict ADK `RunAgentRequest` JSON whose `(appName,userId,sessionId)`
|
53
|
+
match the channel binding.
|
54
|
+
|
55
|
+
- `WS /stream/ws/{channelId}?appName=&userId=&sessionId=` — WebSocket bidi
|
56
|
+
- On connect, a `{"event":"channel-bound",...}` JSON frame is sent with the final `sessionId`.
|
57
|
+
- Client sends strict `RunAgentRequest` JSON frames to enqueue runs.
|
58
|
+
- Server streams raw ADK `Event` JSON frames back.
|
59
|
+
|
60
|
+
## Minimal Client Examples
|
61
|
+
|
62
|
+
SSE (browser):
|
63
|
+
|
64
|
+
```html
|
65
|
+
<script>
|
66
|
+
const ch = crypto.randomUUID();
|
67
|
+
const src = new EventSource(`/stream/events/${ch}?appName=my_app&userId=u1`);
|
68
|
+
let sessionId;
|
69
|
+
src.addEventListener('channel-bound', (e) => {
|
70
|
+
const info = JSON.parse(e.data);
|
71
|
+
sessionId = info.sessionId;
|
72
|
+
// Now send a RunAgentRequest
|
73
|
+
fetch(`/stream/send/${ch}`, {
|
74
|
+
method: 'POST',
|
75
|
+
headers: {'Content-Type':'application/json'},
|
76
|
+
body: JSON.stringify({
|
77
|
+
appName: "my_app",
|
78
|
+
userId: "u1",
|
79
|
+
sessionId,
|
80
|
+
streaming: true,
|
81
|
+
newMessage: { parts: [{ text: "Hello!" }] }
|
82
|
+
})
|
83
|
+
});
|
84
|
+
});
|
85
|
+
|
86
|
+
src.onmessage = (e) => {
|
87
|
+
const event = JSON.parse(e.data); // ADK Event JSON
|
88
|
+
console.log('event', event);
|
89
|
+
};
|
90
|
+
</script>
|
91
|
+
```
|
92
|
+
|
93
|
+
WebSocket (browser):
|
94
|
+
|
95
|
+
```html
|
96
|
+
<script>
|
97
|
+
const ch = crypto.randomUUID();
|
98
|
+
const ws = new WebSocket(`ws://${location.host}/stream/ws/${ch}?appName=my_app&userId=u1`);
|
99
|
+
let sessionId;
|
100
|
+
ws.onmessage = (msg) => {
|
101
|
+
const data = JSON.parse(msg.data);
|
102
|
+
if (data.event === 'channel-bound') {
|
103
|
+
sessionId = data.sessionId;
|
104
|
+
ws.send(JSON.stringify({
|
105
|
+
appName: 'my_app', userId: 'u1', sessionId, streaming: true,
|
106
|
+
newMessage: { parts: [{ text: 'Hello!' }] }
|
107
|
+
}));
|
108
|
+
} else {
|
109
|
+
console.log('event', data); // ADK Event JSON
|
110
|
+
}
|
111
|
+
};
|
112
|
+
</script>
|
113
|
+
```
|
114
|
+
|
115
|
+
### Notes
|
116
|
+
- This layer is optional. The core ADK endpoints remain available.
|
117
|
+
- By default we preserve ADK wire types. If you need a convenience payload
|
118
|
+
(non‑strict), you can add your own translator at your API boundary.
|
119
|
+
|
@@ -2,7 +2,7 @@ Examples
|
|
2
2
|
|
3
3
|
This folder contains small, runnable examples that mirror the documentation. They are intentionally minimal and designed to be copy–pasted into your app.
|
4
4
|
|
5
|
-
- fastapi_app.py — Build a FastAPI app with durable services
|
5
|
+
- fastapi_app.py — Build a FastAPI app with durable services.
|
6
6
|
- runner_basic.py — Build a Runner for programmatic use without FastAPI.
|
7
7
|
- custom_loader.py — Register programmatic agents with `CustomAgentLoader`.
|
8
8
|
- services/ — Focused snippets for sessions, artifacts, memory backends.
|
@@ -0,0 +1,31 @@
|
|
1
|
+
"""Streaming (SSE + WebSocket) example using AdkBuilder.
|
2
|
+
|
3
|
+
Run:
|
4
|
+
uvicorn examples.streaming_sse_ws:app --reload
|
5
|
+
|
6
|
+
This example enables the optional streaming layer and exposes routes under
|
7
|
+
`/stream`:
|
8
|
+
- GET /stream/events/{channelId}?appName=&userId=&sessionId= (SSE)
|
9
|
+
- POST /stream/send/{channelId} (body = RunAgentRequest JSON)
|
10
|
+
- WS /stream/ws/{channelId}?appName=&userId=&sessionId=
|
11
|
+
|
12
|
+
Notes:
|
13
|
+
- On open, the server emits a channel-bound control message containing the
|
14
|
+
bound sessionId so the client can populate RunAgentRequest.
|
15
|
+
"""
|
16
|
+
|
17
|
+
from google_adk_extras import AdkBuilder
|
18
|
+
|
19
|
+
|
20
|
+
app = (
|
21
|
+
AdkBuilder()
|
22
|
+
# Use either on-disk agents or programmatic agents. For streaming layer,
|
23
|
+
# the agent loader is optional if you stub the runner in tests; in real apps
|
24
|
+
# provide your agents via one of these methods:
|
25
|
+
# .with_agents_dir("./agents")
|
26
|
+
|
27
|
+
# Enable streaming layer with defaults
|
28
|
+
.with_web_ui(False)
|
29
|
+
.build_fastapi_app(enable_streaming=True)
|
30
|
+
)
|
31
|
+
|
@@ -14,9 +14,9 @@ nav:
|
|
14
14
|
- Getting Started: getting-started.md
|
15
15
|
- Quickstarts: quickstarts.md
|
16
16
|
- FastAPI Integration: fastapi.md
|
17
|
+
- Streaming: streaming.md
|
17
18
|
- Services:
|
18
19
|
- Durable Services: services.md
|
19
|
-
- Credentials: credentials.md
|
20
20
|
- Programmatic Agents: agent-loading.md
|
21
21
|
- URIs & Configuration: uris.md
|
22
22
|
- Examples: examples.md
|
@@ -49,7 +49,7 @@ plugins:
|
|
49
49
|
Durable Services:
|
50
50
|
- services.md: Sessions, artifacts, memory backends and trade-offs
|
51
51
|
Credentials:
|
52
|
-
|
52
|
+
# credentials docs removed; use ADK documentation for outbound creds
|
53
53
|
Programmatic Agents:
|
54
54
|
- agent-loading.md: Custom loaders and in-memory registrations
|
55
55
|
Configuration:
|
@@ -1,7 +1,7 @@
|
|
1
1
|
[project]
|
2
2
|
name = "google-adk-extras"
|
3
|
-
version = "0.2.
|
4
|
-
description = "Production-ready services
|
3
|
+
version = "0.2.7"
|
4
|
+
description = "Production-ready services and FastAPI wiring for Google ADK"
|
5
5
|
readme = "README.md"
|
6
6
|
requires-python = ">=3.10,<3.13"
|
7
7
|
authors = [
|
@@ -38,6 +38,20 @@ all = [
|
|
38
38
|
"google-adk-extras[sql,mongodb,redis,yaml,s3,jwt,web,docs]",
|
39
39
|
]
|
40
40
|
|
41
|
+
[tool.ruff]
|
42
|
+
line-length = 100
|
43
|
+
target-version = "py312"
|
44
|
+
|
45
|
+
[tool.ruff.lint]
|
46
|
+
select = ["E", "F"]
|
47
|
+
ignore = [
|
48
|
+
"F401", # unused-import (common in optional backends)
|
49
|
+
"F841", # unused-variable (tests and examples)
|
50
|
+
"F821", # undefined-name (forward-ref type strings in optional extras)
|
51
|
+
"E402", # module-import-not-at-top-of-file (test-only patterns)
|
52
|
+
"E501", # line-too-long (permissive until we tighten rules)
|
53
|
+
]
|
54
|
+
|
41
55
|
[build-system]
|
42
56
|
requires = ["setuptools>=45", "wheel"]
|
43
57
|
build-backend = "setuptools.build_meta"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""Production-ready services
|
1
|
+
"""Production-ready services and FastAPI wiring for Google ADK.
|
2
2
|
|
3
3
|
Public API surface:
|
4
4
|
- AdkBuilder
|
@@ -11,7 +11,7 @@ Service groups are exposed via subpackages:
|
|
11
11
|
- google_adk_extras.sessions
|
12
12
|
- google_adk_extras.artifacts
|
13
13
|
- google_adk_extras.memory
|
14
|
-
|
14
|
+
(credential services are provided by ADK; no custom extras here)
|
15
15
|
"""
|
16
16
|
|
17
17
|
from .adk_builder import AdkBuilder
|
@@ -28,4 +28,4 @@ __all__ = [
|
|
28
28
|
"CustomAgentLoader",
|
29
29
|
]
|
30
30
|
|
31
|
-
__version__ = "0.2.
|
31
|
+
__version__ = "0.2.7"
|