adk-code-mode 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.
- adk_code_mode/__about__.py +4 -0
- adk_code_mode/__init__.py +22 -0
- adk_code_mode/_artifact_tools.py +152 -0
- adk_code_mode/callback.py +81 -0
- adk_code_mode/executor.py +607 -0
- adk_code_mode/output.py +97 -0
- adk_code_mode/py.typed +1 -0
- adk_code_mode/runtime/__init__.py +9 -0
- adk_code_mode/runtime/base.py +88 -0
- adk_code_mode/runtime/docker.py +331 -0
- adk_code_mode/runtime/protocol.py +193 -0
- adk_code_mode/tools/__init__.py +4 -0
- adk_code_mode/tools/catalog.py +95 -0
- adk_code_mode/tools/dispatcher.py +290 -0
- adk_code_mode/tools/namespacing.py +200 -0
- adk_code_mode/tools/normaliser.py +69 -0
- adk_code_mode/tools/stubs.py +446 -0
- adk_code_mode/workspace/__init__.py +8 -0
- adk_code_mode/workspace/files.py +44 -0
- adk_code_mode-0.1.0.dist-info/METADATA +351 -0
- adk_code_mode-0.1.0.dist-info/RECORD +23 -0
- adk_code_mode-0.1.0.dist-info/WHEEL +4 -0
- adk_code_mode-0.1.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: adk-code-mode
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A "Code Mode" Code Executor for ADK for agents to interact with tools, files, and custom packages with Python
|
|
5
|
+
Project-URL: Documentation, https://github.com/A2ANet/adk-code-mode#readme
|
|
6
|
+
Project-URL: Issues, https://github.com/A2ANet/adk-code-mode/issues
|
|
7
|
+
Project-URL: Source, https://github.com/A2ANet/adk-code-mode
|
|
8
|
+
Author-email: A2A Net <hello@a2anet.com>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: a2a,adk,agents,code-executor,code-mode
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: docker>=7.0.0
|
|
21
|
+
Requires-Dist: google-adk<2.0.0,>=1.0.0
|
|
22
|
+
Requires-Dist: google-genai>=1.0.0
|
|
23
|
+
Requires-Dist: pydantic>=2.0.0
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# ADK Code Mode
|
|
27
|
+
|
|
28
|
+
A [Code Mode](https://blog.cloudflare.com/code-mode/) code executor for [Agent Development Kit (ADK)](https://github.com/google/adk-python).
|
|
29
|
+
The `CodeModeCodeExecutor` allows ADK to write Python code to call tools and list, save, and load Artifacts.
|
|
30
|
+
|
|
31
|
+
The code is executed in a Docker container, tool calls are forwarded to the host, and are run through ADK's normal tool pipeline (callbacks, plugins, error handling).
|
|
32
|
+
The default Docker image supports The Python Standard Library, extra Python packages can be added by building a custom Docker image.
|
|
33
|
+
Files can be added to a single execution with `input_files`, and saved files are output as `output_files`.
|
|
34
|
+
By default, `CodeModeCodeExecutor` adds `list_artifacts`, `save_artifact`, and `load_artifact` tools to the execution environment to use files between executions.
|
|
35
|
+
|
|
36
|
+
Inspired by Cloudflare's [Code Mode](https://blog.cloudflare.com/code-mode/) and Anthropic's [Code execution with MCP](https://www.anthropic.com/engineering/code-execution-with-mcp).
|
|
37
|
+
|
|
38
|
+
## ✨ Features
|
|
39
|
+
|
|
40
|
+
- **Call ADK tools from sandbox code** — imports against the `tools` package proxy back to the host and run through ADK's `before_tool` / `after_tool` / `on_error` callbacks and the plugin manager exactly as direct tool calls would.
|
|
41
|
+
- **Credentials stay on the host** — API keys, OAuth tokens, and connection strings never enter the container; only tool arguments and return values cross the boundary.
|
|
42
|
+
- **Bake any Python package into the image** — extend the published base image with anything the model's code needs to `import`, no runtime `pip install` required.
|
|
43
|
+
- **Cross-turn persistence via ADK Artifacts** — `save_artifact` / `load_artifact` / `list_artifacts` are auto-injected and route through your configured `ArtifactService`.
|
|
44
|
+
- **Bounded stdout/stderr** — overflow lands in a session artifact instead of poisoning the prompt.
|
|
45
|
+
- **Local development** — `DockerRuntime` runs the sandbox against your local Docker daemon for fast iteration.
|
|
46
|
+
|
|
47
|
+
| | BuiltIn | AgentEngineSandbox | VertexAi | Container | Gke | CodeMode |
|
|
48
|
+
| ----------------------------------- | ------- | -------------------------------- | ------------------------------- | --------- | --- | ------------------------ |
|
|
49
|
+
| Call ADK tools from code | no | no | no | no | no | yes (with limitations) |
|
|
50
|
+
| Extra Python packages | no | no (more than stdlib but fixed) | no (more than stdlib but fixed) | yes | yes | yes |
|
|
51
|
+
| Variables are stateful | no | yes | yes | no | no | no |
|
|
52
|
+
| Input files | no | yes | yes | no | no | yes |
|
|
53
|
+
| Output files | no | yes | yes | no | no | yes |
|
|
54
|
+
| Storage | no | yes (via variables) | yes (via variables) | no | no | yes (via ADK Artifacts) |
|
|
55
|
+
| Local development version available | no | no | no | yes | yes | yes |
|
|
56
|
+
| Bounded stdout/stderr | no | no | no | no | no | yes (`max_output_chars`) |
|
|
57
|
+
|
|
58
|
+
## 📋 Requirements
|
|
59
|
+
|
|
60
|
+
- Python 3.10+
|
|
61
|
+
- [Docker](https://docs.docker.com/get-docker/) — `DockerRuntime` launches the sandbox via the local Docker daemon, so the agent process needs to reach a Docker socket.
|
|
62
|
+
- (optional) [uv](https://docs.astral.sh/uv/) if you prefer it over pip.
|
|
63
|
+
|
|
64
|
+
## 📦 Install
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install adk-code-mode
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Or with uv:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
uv add adk-code-mode
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## 🚀 Usage
|
|
77
|
+
|
|
78
|
+
Build a `CodeModeCodeExecutor`, wire `code_mode_before_model_callback` into the agent, and put `CODE_MODE_SYSTEM_INSTRUCTION` somewhere in the agent's `instruction`:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from google.adk.agents import LlmAgent
|
|
82
|
+
from adk_code_mode import (
|
|
83
|
+
CODE_MODE_SYSTEM_INSTRUCTION,
|
|
84
|
+
CodeModeCodeExecutor,
|
|
85
|
+
DockerRuntime,
|
|
86
|
+
code_mode_before_model_callback,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
executor = CodeModeCodeExecutor(
|
|
90
|
+
tools=[my_fn_tool, McpToolset(...), OpenAPIToolset(...)],
|
|
91
|
+
runtime=DockerRuntime(image="ghcr.io/a2anet/adk-code-mode:0.1.0"),
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
root_agent = LlmAgent(
|
|
95
|
+
name="assistant",
|
|
96
|
+
model="gemini-2.5-pro",
|
|
97
|
+
instruction=f"You are a helpful assistant.\n\n{CODE_MODE_SYSTEM_INSTRUCTION}",
|
|
98
|
+
tools=[], # do NOT also bind tools here; the executor owns them.
|
|
99
|
+
code_executor=executor,
|
|
100
|
+
before_model_callback=code_mode_before_model_callback(executor),
|
|
101
|
+
)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The callback is what injects the tool catalog. Skip it and the model has no idea what tools exist.
|
|
105
|
+
|
|
106
|
+
Inside the sandbox, the model writes code like:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from tools.slack import send_message
|
|
110
|
+
print(send_message(channel="C123", text="hi"))
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## 🗂️ Storage
|
|
114
|
+
|
|
115
|
+
Code Mode exposes two separate file surfaces:
|
|
116
|
+
|
|
117
|
+
- **`/workspace`** — per-run working directory for ordinary I/O.
|
|
118
|
+
- **ADK Artifacts** — persistent, cross-turn files and data via `save_artifact` / `load_artifact` / `list_artifacts`.
|
|
119
|
+
|
|
120
|
+
### `/workspace`
|
|
121
|
+
|
|
122
|
+
`/workspace` is the sandbox's current working directory for a single execution. Any ADK `input_files` are staged there by filename before the code runs, so plain paths like `open("input.csv")` work.
|
|
123
|
+
|
|
124
|
+
Files created or modified under `/workspace` are returned as `CodeExecutionResult.output_files` at the end of the run — these are developer-internal, intended for things like staged inputs or generated reports a downstream tool consumes. They are not re-hydrated next turn unless the code explicitly persists them via `save_artifact`.
|
|
125
|
+
|
|
126
|
+
### Artifacts
|
|
127
|
+
|
|
128
|
+
`CodeModeCodeExecutor` injects three regular tools into the catalog so model code can persist files across turns. They appear as top-level `from tools import …` imports:
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
import json
|
|
132
|
+
from tools import save_artifact, load_artifact, list_artifacts
|
|
133
|
+
|
|
134
|
+
save_artifact(
|
|
135
|
+
filename="report.json",
|
|
136
|
+
content=json.dumps({"status": "ready"}),
|
|
137
|
+
mime_type="application/json",
|
|
138
|
+
)
|
|
139
|
+
print(list_artifacts())
|
|
140
|
+
report = load_artifact(filename="report.json")
|
|
141
|
+
if report is not None and report["kind"] == "text":
|
|
142
|
+
payload = json.loads(report["data"])
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
To opt out and supply your own artifact tools (or none), pass `include_artifact_tools=False`.
|
|
146
|
+
|
|
147
|
+
To react when the model saves an artifact (for example to surface it as an A2A artifact-update event), pass `on_artifacts_saved`:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
async def on_saved(invocation_context, delta):
|
|
151
|
+
# ``delta`` is ``{filename: version}`` for everything saved this turn.
|
|
152
|
+
...
|
|
153
|
+
|
|
154
|
+
CodeModeCodeExecutor(tools=..., runtime=..., on_artifacts_saved=on_saved)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The hook fires once per `execute_code` call, after the sandbox closes, only when the dispatcher recorded at least one save. Exceptions raised inside the hook are logged and swallowed.
|
|
158
|
+
|
|
159
|
+
## 🐳 Sandbox Image
|
|
160
|
+
|
|
161
|
+
### Building
|
|
162
|
+
|
|
163
|
+
The published base image (`ghcr.io/a2anet/adk-code-mode` on GitHub Container Registry) ships with `adk-code-mode-sandbox` already installed and works as-is for any tools whose execution is fully host-side. To bake in extra Python packages the model's code can `import`, extend it from your project's Dockerfile:
|
|
164
|
+
|
|
165
|
+
```dockerfile
|
|
166
|
+
FROM ghcr.io/a2anet/adk-code-mode:0.1.0
|
|
167
|
+
RUN pip install --no-cache-dir pandas==2.2.*
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
docker build -t myorg/code-mode:1.0 .
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The same tag works for both local `DockerRuntime` and any future cloud runtime. Packages are baked in at build time — there is no runtime `pip install`. To build the local development image directly from this repo instead of the published one, run `make docker-image` (it builds the sandbox wheel and tags `adk-code-mode:local`).
|
|
175
|
+
|
|
176
|
+
### Deploying with GCP
|
|
177
|
+
|
|
178
|
+
`DockerRuntime` launches the sandbox via the Docker daemon on the agent host's machine, so the agent process must run somewhere it can reach a Docker socket. Supported targets today:
|
|
179
|
+
|
|
180
|
+
- **Compute Engine VMs** with Docker installed.
|
|
181
|
+
- **GKE pods** that mount the host's Docker socket (or run Docker-in-Docker).
|
|
182
|
+
|
|
183
|
+
To deploy to a supported GCP environment, mirror the published image into your project's [Artifact Registry](https://cloud.google.com/artifact-registry) and point `DockerRuntime` at the registry tag:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# One-time per project / region.
|
|
187
|
+
gcloud auth configure-docker <region>-docker.pkg.dev
|
|
188
|
+
gcloud artifacts repositories create adk-code-mode \
|
|
189
|
+
--repository-format=docker \
|
|
190
|
+
--location=<region>
|
|
191
|
+
|
|
192
|
+
# Pull, retag, push.
|
|
193
|
+
docker pull ghcr.io/a2anet/adk-code-mode:0.1.0
|
|
194
|
+
docker tag ghcr.io/a2anet/adk-code-mode:0.1.0 \
|
|
195
|
+
<region>-docker.pkg.dev/<project>/adk-code-mode/adk-code-mode:0.1.0
|
|
196
|
+
docker push <region>-docker.pkg.dev/<project>/adk-code-mode/adk-code-mode:0.1.0
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Then in the agent:
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
DockerRuntime(
|
|
203
|
+
image="<region>-docker.pkg.dev/<project>/adk-code-mode/adk-code-mode:0.1.0",
|
|
204
|
+
)
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
If you extended the base image to install extra Python packages, push that derived image instead.
|
|
208
|
+
|
|
209
|
+
## ⚙️ Configuration
|
|
210
|
+
|
|
211
|
+
### Catalog overflow
|
|
212
|
+
|
|
213
|
+
For very large tool surfaces the rendered catalog can dominate the prompt. `CodeModeCodeExecutor.max_catalog_chars` (default `50_000`) is a soft cap. When the catalog exceeds it, the callback drops every tool section and replaces it with a short prose note telling the model how to navigate `/tools/` from Python:
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
<tools>
|
|
217
|
+
A `tools` package is available in the sandbox. List `/tools/` with
|
|
218
|
+
`pathlib.Path('/tools').iterdir()`. Each entry is either a `.py` file
|
|
219
|
+
(a top-level tool, importable as `from tools import <name>`) or a
|
|
220
|
+
subdirectory (a namespace, with tools importable as
|
|
221
|
+
`from tools.<namespace> import <name>`). To see a tool's signature and
|
|
222
|
+
docstring, read its `.py` file with `open(...).read()`.
|
|
223
|
+
</tools>
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Tune `max_catalog_chars` for your model's context budget. Pass it on the executor:
|
|
227
|
+
|
|
228
|
+
```python
|
|
229
|
+
CodeModeCodeExecutor(tools=..., runtime=..., max_catalog_chars=20_000)
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Output truncation
|
|
233
|
+
|
|
234
|
+
`max_output_chars=50_000` (default) caps the stdout and stderr handed back to the model. If either stream exceeds the cap, the model sees a head-and-tail view plus an inline marker:
|
|
235
|
+
|
|
236
|
+
```
|
|
237
|
+
Output exceeded 50,000 characters. Try again with a smaller output.
|
|
238
|
+
Full stdout saved as artifact: code_mode/stdout/<execution-id>.txt
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
The full stream is saved as a regular session-scoped ADK artifact at the path printed in the marker. The model can recover it on demand the same way it loads anything else:
|
|
242
|
+
|
|
243
|
+
```python
|
|
244
|
+
from tools import load_artifact
|
|
245
|
+
spilled = load_artifact(filename="code_mode/stdout/<execution-id>.txt")
|
|
246
|
+
print(spilled["data"][-2000:])
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
So oversize output stays out of context but remains addressable. Developers can also fetch the same artifact directly via the configured `ArtifactService`.
|
|
250
|
+
|
|
251
|
+
## 🏗️ Architecture
|
|
252
|
+
|
|
253
|
+
ADK Code Mode has two pieces:
|
|
254
|
+
|
|
255
|
+
**Host wheel (`adk-code-mode`).** Lives in the same Python process as your `LlmAgent`. Extends ADK's `BaseCodeExecutor`. The `before_model_callback` resolves your tools (including any `BaseToolset` instances), renders the catalog, and appends it to the system prompt. The catalog rendering and tool resolution are cached per-invocation so the follow-up `execute_code` call doesn't re-resolve toolsets. At code-execution time, the executor: (a) generates a small `tools/` Python package whose functions are thin stubs, (b) prepends the built-in `save_artifact` / `load_artifact` / `list_artifacts` tools (unless `include_artifact_tools=False`), (c) stages any `input_files` into `/workspace`, and (d) launches the sandbox.
|
|
256
|
+
|
|
257
|
+
**Sandbox wheel (`adk-code-mode-sandbox`).** A stdlib-only package pre-installed in the container image. When the model's code calls a stub from `tools/…`, the stub sends a JSON-Lines frame over a TCP control connection to the host; the host runs the real tool (including ADK's `plugin_manager` / `before_tool` / `after_tool` callbacks) and sends the result back.
|
|
258
|
+
|
|
259
|
+
The only things crossing the host ↔ sandbox boundary are: your code, tool call arguments, tool return values, and log frames. Wire format lives in `src/adk_code_mode/runtime/protocol.py` (and a byte-identical copy in the sandbox wheel so the two sides cannot drift).
|
|
260
|
+
|
|
261
|
+
### What the model sees
|
|
262
|
+
|
|
263
|
+
The system prompt the model receives is your `instruction` (which contains `CODE_MODE_SYSTEM_INSTRUCTION`) followed by a `<tools>` block appended by the callback:
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
…your instruction…
|
|
267
|
+
|
|
268
|
+
<tools>
|
|
269
|
+
|
|
270
|
+
# tools.slack
|
|
271
|
+
|
|
272
|
+
from tools.slack import list_channels, send_message
|
|
273
|
+
|
|
274
|
+
def list_channels() -> Any:
|
|
275
|
+
"""List Slack channels."""
|
|
276
|
+
...
|
|
277
|
+
|
|
278
|
+
def send_message(*, channel: str, text: str, thread_ts: str | None = ...) -> Any:
|
|
279
|
+
"""Send a message to a Slack channel.
|
|
280
|
+
|
|
281
|
+
Args:
|
|
282
|
+
channel: Channel ID like C123.
|
|
283
|
+
text: Message text.
|
|
284
|
+
thread_ts: Thread timestamp.
|
|
285
|
+
"""
|
|
286
|
+
...
|
|
287
|
+
|
|
288
|
+
# tools
|
|
289
|
+
|
|
290
|
+
from tools import save_artifact, load_artifact, list_artifacts
|
|
291
|
+
|
|
292
|
+
def save_artifact(*, filename: str, content: str, mime_type: str | None = ...) -> int:
|
|
293
|
+
"""Save an artifact to the session. Returns the new version number.
|
|
294
|
+
…
|
|
295
|
+
"""
|
|
296
|
+
...
|
|
297
|
+
|
|
298
|
+
…
|
|
299
|
+
|
|
300
|
+
</tools>
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
Each module is one section. The first line of each section is the exact import the model should copy. Bodies are `...` placeholders — the on-disk stubs do the real work via the control channel. When the rendered catalog grows past `max_catalog_chars`, the per-tool sections are dropped in favour of the prose note shown in [Catalog overflow](#catalog-overflow). At code-execution time, oversize stdout/stderr is replaced with a head-and-tail view plus a marker pointing at a session artifact (`code_mode/stdout/<execution-id>.txt`) the model can `load_artifact(...)` on demand.
|
|
304
|
+
|
|
305
|
+
### Artifact wire format
|
|
306
|
+
|
|
307
|
+
The artifact tools' wire format is JSON. Text and JSON-like MIME types travel as plain strings; binary content is base64-encoded by the model before `save_artifact` and decoded by the model after `load_artifact` (`load_artifact` returns `{"kind": "text" | "bytes", "data": str, "mime_type": str | None}`). All three call ADK's `ToolContext` artifact APIs on the host, so callbacks, plugins, and the configured artifact service run normally.
|
|
308
|
+
|
|
309
|
+
## 🛡️ Safety
|
|
310
|
+
|
|
311
|
+
- **Credentials never enter the sandbox.** API keys, OAuth tokens, DB connection strings — anything your tools use — stay in the host process. The container only gets the result of a tool call, not the means to make it. Tool dispatch goes through `src/adk_code_mode/tools/dispatcher.py`.
|
|
312
|
+
- **Read-only rootfs by default.** `DockerRuntime(read_only=True)` is the default. The writable mount is `/workspace` for the current run; persistent data goes through host-side ADK artifact APIs.
|
|
313
|
+
- **Bounded stdout/stderr.** `max_output_chars` caps what the model sees; overflow lands in an artifact for you, not in the model's context. Prevents runaway printing from poisoning the context or pushing large payloads into chat history.
|
|
314
|
+
- **Bounded execution.** `timeout_seconds` caps overall runtime; `per_tool_timeout_seconds` caps each individual tool call.
|
|
315
|
+
- **Resource limits.** `DockerRuntime` defaults to `mem_limit="1g"` and one full vCPU (`cpu_period=100_000`, `cpu_quota=100_000`). Override any of them on the runtime to raise or remove the cap.
|
|
316
|
+
- **Network posture.** The container reaches the host over `host.docker.internal` for the control channel; outbound traffic otherwise follows Docker's default bridge. For stricter setups, pass a custom `network_mode` via `run_kwargs`.
|
|
317
|
+
- **Control channel is token-gated.** Each `DockerRuntime.start()` mints a per-run shared secret and refuses any TCP peer that does not present it as the first line on connect. Defends against a process on the host racing the real sandbox onto the listener.
|
|
318
|
+
- **Tool dispatch still runs ADK's guard callbacks.** `before_tool`, `after_tool`, `on_error`, and the plugin manager all fire for calls originating in sandbox code — any allow-list, redaction, or audit-log you already have keeps working.
|
|
319
|
+
|
|
320
|
+
What this does **not** protect against: sandbox escapes in the container runtime itself, malicious tool implementations you wrote, exfiltration through legitimate tool calls (e.g. `send_email("attacker", ...)`), or side channels over the control pipe. Keep your tool surface least-privilege.
|
|
321
|
+
|
|
322
|
+
## ⚠️ Limitations
|
|
323
|
+
|
|
324
|
+
- **Credential-requesting tools are not supported in this release.** Tools or toolsets that need ADK to request credentials should not be exposed through Code Mode yet. Tool calls that request credentials, confirmations, UI widgets, agent transfer, escalation, compaction, agent state, rewind, or that yield without an immediate response (long-running tools) are rejected with a structured tool error — code mode has no resume path for an async function call.
|
|
325
|
+
- **`DockerRuntime` deployment targets.** Does **not** work on Cloud Run, Cloud Functions, or Vertex AI Agent Engine — none of those expose a Docker daemon to the workload. Supported targets are Compute Engine VMs and GKE pods that can reach a Docker socket. A managed-sandbox runtime that targets the serverless environments is on the roadmap but not in this release.
|
|
326
|
+
- **No state across executions.** Variables defined in one turn don't survive to the next; each `execute_code` call runs in a fresh sandbox. Use `save_artifact` / `load_artifact` to persist across turns, or `/workspace` within a single run.
|
|
327
|
+
- **Sandbox is stdlib-only at runtime.** Extra Python packages must be baked into the image at build time; there is no runtime `pip install` from inside the sandbox.
|
|
328
|
+
|
|
329
|
+
## 🛠️ Development
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
make install # uv sync --group dev
|
|
333
|
+
make ci # ruff + mypy + pytest
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
Docker integration tests are opt-in:
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
uv run pytest -m docker
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## 📄 License
|
|
343
|
+
|
|
344
|
+
`adk-code-mode` is distributed under the terms of the [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) license.
|
|
345
|
+
|
|
346
|
+
## 🤝 Join the A2A Net Community
|
|
347
|
+
|
|
348
|
+
A2A Net is a site to find and share AI agents and open-source community. Join to share your A2A agents, ask questions, stay up-to-date with the latest A2A news, be the first to hear about open-source releases, tutorials, and more!
|
|
349
|
+
|
|
350
|
+
- 🌍 Site: [A2A Net](https://a2anet.com)
|
|
351
|
+
- 🤖 Discord: [Join the Discord](https://discord.gg/674NGXpAjU)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
adk_code_mode/__about__.py,sha256=0H6GNBbcL8zIcc4LIjpBwyFNtiAFeTkZ5LAqPOl2X4o,156
|
|
2
|
+
adk_code_mode/__init__.py,sha256=vxb4whv2Wh_X-RHkwgR6G5EwW_Qy7A6ScWcHoekwtXQ,658
|
|
3
|
+
adk_code_mode/_artifact_tools.py,sha256=vn-oGMbJfOMYNcS8VlCz0zhRYrf4SCf-hhYEL0LluxE,4739
|
|
4
|
+
adk_code_mode/callback.py,sha256=u4-I04FFWs64NfUKLlal9VxO-mgNBovMg5EDf_C437E,2823
|
|
5
|
+
adk_code_mode/executor.py,sha256=A1ks8g1usuG0xqy5Jc9GwM7qXPUa3oQWPKtwIf3uWPc,21894
|
|
6
|
+
adk_code_mode/output.py,sha256=pxL3NEbqSx8cNJ_3jWzJI5p3Y6B7r4hLE39elW0PEtc,3249
|
|
7
|
+
adk_code_mode/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
8
|
+
adk_code_mode/runtime/__init__.py,sha256=VXiP49KMxv5stYW0QH2EOrcCZ6QOuHyPBzZGMGQG9_8,344
|
|
9
|
+
adk_code_mode/runtime/base.py,sha256=AGBouDeC9Y_aY6KJlslaOIzRFNKxXZcINDJWuHzdaCY,2520
|
|
10
|
+
adk_code_mode/runtime/docker.py,sha256=K5L19TkvX7UMOjBeQct7RDWm_Fd3Mu2RA-q_T34hy9s,11814
|
|
11
|
+
adk_code_mode/runtime/protocol.py,sha256=gybzBlaedv46mTMUF7s5Ux-Hsm4B_j42FnkOPJARLkk,5147
|
|
12
|
+
adk_code_mode/tools/__init__.py,sha256=ZqMv0SXvfHqpO7CTqnKF0XxZFzTAavZcoLAGpg439ZU,173
|
|
13
|
+
adk_code_mode/tools/catalog.py,sha256=in0bPqDOGFdN1TXSvQjbqr54Q12aLGbZNo2p1tGjhUQ,3462
|
|
14
|
+
adk_code_mode/tools/dispatcher.py,sha256=8NDuGB1qL-YAq2s00yE-l_XumYlrTpP7K01ZlpMTR4U,11425
|
|
15
|
+
adk_code_mode/tools/namespacing.py,sha256=Q83CIdEO7r6SluKEl1bxBPsM742SvBONOUIxBE__kw8,8112
|
|
16
|
+
adk_code_mode/tools/normaliser.py,sha256=mT8OuAZUlPwm1WHCgSsIf9SFSATCdubuX48X3Nhgk64,2299
|
|
17
|
+
adk_code_mode/tools/stubs.py,sha256=I5NsWctuRzlTGTZDXWnEKUOas-iI2b_F4Kmgx58fVGw,15942
|
|
18
|
+
adk_code_mode/workspace/__init__.py,sha256=B0RmC5eHn-sujQIUXKg0JWeFaqkKFlfBDPfgFBOO8no,269
|
|
19
|
+
adk_code_mode/workspace/files.py,sha256=FH3Y89ROkz2DteogVgt8kQkKmNFZNYccpMVPCPF_WcU,1268
|
|
20
|
+
adk_code_mode-0.1.0.dist-info/METADATA,sha256=49l1xefru4KTlbgvvhMzPi1KW9QHV9YH-4sIbeaamGU,19810
|
|
21
|
+
adk_code_mode-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
22
|
+
adk_code_mode-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
23
|
+
adk_code_mode-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|