dex-agents-pydantic-ai-cli 0.6.1__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.
- dex_agents_pydantic_ai_cli-0.6.1/LICENSE +105 -0
- dex_agents_pydantic_ai_cli-0.6.1/PKG-INFO +109 -0
- dex_agents_pydantic_ai_cli-0.6.1/README.md +87 -0
- dex_agents_pydantic_ai_cli-0.6.1/pyproject.toml +119 -0
- dex_agents_pydantic_ai_cli-0.6.1/pyproject.toml.orig +89 -0
- dex_agents_pydantic_ai_cli-0.6.1/src/dex_agents_pydantic_ai_cli/__init__.py +61 -0
- dex_agents_pydantic_ai_cli-0.6.1/src/dex_agents_pydantic_ai_cli/__main__.py +14 -0
- dex_agents_pydantic_ai_cli-0.6.1/src/dex_agents_pydantic_ai_cli/harness.py +124 -0
- dex_agents_pydantic_ai_cli-0.6.1/src/dex_agents_pydantic_ai_cli/py.typed +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Super Durable, Inc.
|
|
4
|
+
|
|
5
|
+
Portions of this software are licensed as follows:
|
|
6
|
+
|
|
7
|
+
- Legacy Materials remain under their original licenses as described in
|
|
8
|
+
`LEGACY_NOTICES.md`.
|
|
9
|
+
- Third-Party Materials remain under the licenses provided by their owners.
|
|
10
|
+
- The `docs/` and `examples/` directories are not licensed under the
|
|
11
|
+
Sustainable Use License and retain their existing licensing status.
|
|
12
|
+
- All other material owned or licensable by Super Durable, Inc. is available
|
|
13
|
+
under the Sustainable Use License below.
|
|
14
|
+
|
|
15
|
+
See `LEGACY_NOTICES.md` for the applicable legacy and third-party notices.
|
|
16
|
+
|
|
17
|
+
## Sustainable Use License
|
|
18
|
+
|
|
19
|
+
Version 1.0
|
|
20
|
+
|
|
21
|
+
### Acceptance
|
|
22
|
+
|
|
23
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
24
|
+
|
|
25
|
+
### Copyright License
|
|
26
|
+
|
|
27
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
28
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
29
|
+
available, and prepare derivative works of the software, in each case subject
|
|
30
|
+
to the limitations below.
|
|
31
|
+
|
|
32
|
+
### Limitations
|
|
33
|
+
|
|
34
|
+
You may use or modify the software only for your own internal business purposes
|
|
35
|
+
or for non-commercial or personal use. You may distribute the software or
|
|
36
|
+
provide it to others only if you do so free of charge for non-commercial
|
|
37
|
+
purposes. You may not alter, remove, or obscure any licensing, copyright, or
|
|
38
|
+
other notices of the licensor in the software. Any use of the licensor's
|
|
39
|
+
trademarks is subject to applicable law.
|
|
40
|
+
|
|
41
|
+
### Patents
|
|
42
|
+
|
|
43
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
44
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
45
|
+
sale, import and have imported the software, in each case subject to the
|
|
46
|
+
limitations and conditions in this license. This license does not cover any
|
|
47
|
+
patent claims that you cause to be infringed by modifications or additions to
|
|
48
|
+
the software.
|
|
49
|
+
|
|
50
|
+
If you or your company make any written claim that the software infringes or
|
|
51
|
+
contributes to infringement of any patent, your patent license for the software
|
|
52
|
+
granted under these terms ends immediately. If your company makes such a claim,
|
|
53
|
+
your patent license ends immediately for work on behalf of your company.
|
|
54
|
+
|
|
55
|
+
### Notices
|
|
56
|
+
|
|
57
|
+
You must ensure that anyone who gets a copy of any part of the software from
|
|
58
|
+
you also gets a copy of these terms. If you modify the software, you must
|
|
59
|
+
include in any modified copies of the software a prominent notice stating that
|
|
60
|
+
you have modified the software.
|
|
61
|
+
|
|
62
|
+
### No Other Rights
|
|
63
|
+
|
|
64
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
65
|
+
these terms.
|
|
66
|
+
|
|
67
|
+
### Termination
|
|
68
|
+
|
|
69
|
+
If you use the software in violation of these terms, such use is not licensed,
|
|
70
|
+
and your license will automatically terminate. If the licensor provides you
|
|
71
|
+
with a notice of your violation, and you cease all violation of this license no
|
|
72
|
+
later than 30 days after you receive that notice, your license will be
|
|
73
|
+
reinstated retroactively. However, if you violate these terms after such
|
|
74
|
+
reinstatement, any additional violation of these terms will cause your license
|
|
75
|
+
to terminate automatically and permanently.
|
|
76
|
+
|
|
77
|
+
### No Liability
|
|
78
|
+
|
|
79
|
+
As far as the law allows, the software comes as is, without any warranty or
|
|
80
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
81
|
+
out of these terms or the use or nature of the software, under any kind of
|
|
82
|
+
legal claim.
|
|
83
|
+
|
|
84
|
+
### Definitions
|
|
85
|
+
|
|
86
|
+
The "licensor" is the entity offering these terms.
|
|
87
|
+
|
|
88
|
+
The "software" is the software the licensor makes available under these terms,
|
|
89
|
+
including any portion of it.
|
|
90
|
+
|
|
91
|
+
"You" refers to the individual or entity agreeing to these terms.
|
|
92
|
+
|
|
93
|
+
"Your company" is any legal entity, sole proprietorship, or other kind of
|
|
94
|
+
organization that you work for, plus all organizations that have control over,
|
|
95
|
+
are under the control of, or are under common control with that organization.
|
|
96
|
+
Control means ownership of substantially all the assets of an entity, or the
|
|
97
|
+
power to direct its management and policies by vote, contract, or otherwise.
|
|
98
|
+
Control can be direct or indirect.
|
|
99
|
+
|
|
100
|
+
"Your license" is the license granted to you for the software under these
|
|
101
|
+
terms.
|
|
102
|
+
|
|
103
|
+
"Use" means anything you do with the software requiring your license.
|
|
104
|
+
|
|
105
|
+
"Trademark" means trademarks, service marks, and similar rights.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dex-agents-pydantic-ai-cli
|
|
3
|
+
Version: 0.6.1
|
|
4
|
+
Summary: The dex-agents-pydantic-ai command: a durable Pydantic AI agent in your terminal
|
|
5
|
+
Author: Super Durable
|
|
6
|
+
License-Expression: LicenseRef-Sustainable-Use-1.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
+
Classifier: Typing :: Typed
|
|
12
|
+
Requires-Dist: dex-agents==0.6.1
|
|
13
|
+
Requires-Dist: dex-agents-cli-core==0.6.1
|
|
14
|
+
Requires-Dist: dex-agents-pydantic-ai==0.6.1
|
|
15
|
+
Requires-Dist: dex-python-sdk==1.45.0
|
|
16
|
+
Requires-Dist: pydantic-ai-slim[anthropic,google,openai]>=2.64,<3
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Project-URL: Homepage, https://github.com/superdurable/dex/tree/main/agents/cli/python/pydantic-ai
|
|
19
|
+
Project-URL: Repository, https://github.com/superdurable/dex
|
|
20
|
+
Project-URL: Changelog, https://github.com/superdurable/dex/blob/main/agents/CHANGELOG.md
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# dex-agents-pydantic-ai-cli
|
|
24
|
+
|
|
25
|
+
`dex-agents-pydantic-ai-cli` provides the `dex-agents-pydantic-ai` command. It
|
|
26
|
+
runs a [Pydantic AI](https://ai.pydantic.dev/) agent as a durable Dex agent
|
|
27
|
+
session and chats with it in your terminal. The shared CLI core,
|
|
28
|
+
[`dex-agents-cli-core`](../core/README.md), starts or reuses `dexcli dev`,
|
|
29
|
+
connects the connectors MCP server, and runs the Worker. This package only
|
|
30
|
+
builds the agent with the
|
|
31
|
+
[Pydantic AI adapter](../../../python/pydantic-ai/README.md).
|
|
32
|
+
|
|
33
|
+
## Running it
|
|
34
|
+
|
|
35
|
+
The command needs Python 3.11 or later and a key for the model's provider:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
export OPENAI_API_KEY=sk-...
|
|
39
|
+
uvx --from dex-agents-pydantic-ai-cli dex-agents-pydantic-ai
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The first run asks the `init` questions and writes
|
|
43
|
+
`~/.dex/agents/pydantic-ai.yaml`. Then type a message at the `>` prompt.
|
|
44
|
+
Approve or reject tool calls with `y` or `n`, and press Ctrl-D to exit. The
|
|
45
|
+
session stays in Dex, and the command prints the `--resume` line that
|
|
46
|
+
continues it. See the [CLI core README](../core/README.md#running-a-command)
|
|
47
|
+
for every subcommand and option, and [`agents/cli`](../../README.md) for the
|
|
48
|
+
configuration file.
|
|
49
|
+
|
|
50
|
+
The provider reads its key from its standard environment variable. The
|
|
51
|
+
package includes the OpenAI, Anthropic, and Google providers:
|
|
52
|
+
|
|
53
|
+
| Model prefix | Environment variables |
|
|
54
|
+
| --- | --- |
|
|
55
|
+
| `openai:` | `OPENAI_API_KEY`; `OPENAI_BASE_URL` for another endpoint |
|
|
56
|
+
| `anthropic:` | `ANTHROPIC_API_KEY`; `ANTHROPIC_BASE_URL` for another endpoint |
|
|
57
|
+
| `google-gla:` | `GOOGLE_API_KEY` |
|
|
58
|
+
|
|
59
|
+
The command never prints or stores a key.
|
|
60
|
+
|
|
61
|
+
## Configuration
|
|
62
|
+
|
|
63
|
+
The model defaults to `openai:gpt-5.2`; set `model` in the file or pass
|
|
64
|
+
`--model` to change it. It is a Pydantic AI model name, `<provider>:<model>`,
|
|
65
|
+
such as `anthropic:claude-opus-5-5`. A session's settings may change the model
|
|
66
|
+
and the instructions; each model call uses the values of its turn.
|
|
67
|
+
`system_prompt` replaces the default instructions. The `pydantic_ai` section
|
|
68
|
+
has no options yet, and any key in it is a configuration error.
|
|
69
|
+
|
|
70
|
+
## Tools
|
|
71
|
+
|
|
72
|
+
The agent's tools are the CLI core's: its local tool source and the connector
|
|
73
|
+
tools of the connectors MCP server. Every call runs in its own Dex tool Step,
|
|
74
|
+
with the CLI core's policy. Reads run at once, file writes and shell commands
|
|
75
|
+
wait for approval unless the shell allow list has the command, and the file
|
|
76
|
+
tools stay in the workspace. See the
|
|
77
|
+
[CLI core README](../core/README.md) for the local tools.
|
|
78
|
+
|
|
79
|
+
## Images
|
|
80
|
+
|
|
81
|
+
`/image <path>` attaches an image file to the next message. The command gives
|
|
82
|
+
the Pydantic AI adapter the media store of `media.store`, so the model sees the
|
|
83
|
+
image, and images that tools return go to the same store. See
|
|
84
|
+
[Images](../../README.md#images).
|
|
85
|
+
|
|
86
|
+
## Development
|
|
87
|
+
|
|
88
|
+
Develop with uv 0.12.2. The package resolves `dex-agents`, the adapter, the
|
|
89
|
+
CLI core, and the shared test support from this repository by path. `uv.lock`
|
|
90
|
+
pins `pydantic-ai-slim` to the version the adapter's lock pins, and `ci.sh`
|
|
91
|
+
checks that. `ci.sh` installs the locked dependencies, checks lint and types,
|
|
92
|
+
and runs the tests against a private `dexcli dev`:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
cd agents/cli/python/pydantic-ai
|
|
96
|
+
DEXCLI=/path/to/dexcli ./ci.sh
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The tests run the command in a pseudo-terminal with a private home and an
|
|
100
|
+
allow-listed environment. Pydantic AI's OpenAI provider calls the scripted
|
|
101
|
+
Responses API of [`../testing`](../testing); a refused proxy stops any other
|
|
102
|
+
request. A fake connectors MCP server serves a connector read and write. The
|
|
103
|
+
tests cover a chat turn and `--resume`, `read_file` without approval and
|
|
104
|
+
`write_file` after approval, a connector read and an approved connector write
|
|
105
|
+
that runs once, session settings that change the model, and a key in the
|
|
106
|
+
`pydantic_ai` section.
|
|
107
|
+
They also cover a `system_prompt` set in the session settings, which reaches
|
|
108
|
+
the next model request, and a rejected file write and connector write, which
|
|
109
|
+
never run.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# dex-agents-pydantic-ai-cli
|
|
2
|
+
|
|
3
|
+
`dex-agents-pydantic-ai-cli` provides the `dex-agents-pydantic-ai` command. It
|
|
4
|
+
runs a [Pydantic AI](https://ai.pydantic.dev/) agent as a durable Dex agent
|
|
5
|
+
session and chats with it in your terminal. The shared CLI core,
|
|
6
|
+
[`dex-agents-cli-core`](../core/README.md), starts or reuses `dexcli dev`,
|
|
7
|
+
connects the connectors MCP server, and runs the Worker. This package only
|
|
8
|
+
builds the agent with the
|
|
9
|
+
[Pydantic AI adapter](../../../python/pydantic-ai/README.md).
|
|
10
|
+
|
|
11
|
+
## Running it
|
|
12
|
+
|
|
13
|
+
The command needs Python 3.11 or later and a key for the model's provider:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
export OPENAI_API_KEY=sk-...
|
|
17
|
+
uvx --from dex-agents-pydantic-ai-cli dex-agents-pydantic-ai
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The first run asks the `init` questions and writes
|
|
21
|
+
`~/.dex/agents/pydantic-ai.yaml`. Then type a message at the `>` prompt.
|
|
22
|
+
Approve or reject tool calls with `y` or `n`, and press Ctrl-D to exit. The
|
|
23
|
+
session stays in Dex, and the command prints the `--resume` line that
|
|
24
|
+
continues it. See the [CLI core README](../core/README.md#running-a-command)
|
|
25
|
+
for every subcommand and option, and [`agents/cli`](../../README.md) for the
|
|
26
|
+
configuration file.
|
|
27
|
+
|
|
28
|
+
The provider reads its key from its standard environment variable. The
|
|
29
|
+
package includes the OpenAI, Anthropic, and Google providers:
|
|
30
|
+
|
|
31
|
+
| Model prefix | Environment variables |
|
|
32
|
+
| --- | --- |
|
|
33
|
+
| `openai:` | `OPENAI_API_KEY`; `OPENAI_BASE_URL` for another endpoint |
|
|
34
|
+
| `anthropic:` | `ANTHROPIC_API_KEY`; `ANTHROPIC_BASE_URL` for another endpoint |
|
|
35
|
+
| `google-gla:` | `GOOGLE_API_KEY` |
|
|
36
|
+
|
|
37
|
+
The command never prints or stores a key.
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
The model defaults to `openai:gpt-5.2`; set `model` in the file or pass
|
|
42
|
+
`--model` to change it. It is a Pydantic AI model name, `<provider>:<model>`,
|
|
43
|
+
such as `anthropic:claude-opus-5-5`. A session's settings may change the model
|
|
44
|
+
and the instructions; each model call uses the values of its turn.
|
|
45
|
+
`system_prompt` replaces the default instructions. The `pydantic_ai` section
|
|
46
|
+
has no options yet, and any key in it is a configuration error.
|
|
47
|
+
|
|
48
|
+
## Tools
|
|
49
|
+
|
|
50
|
+
The agent's tools are the CLI core's: its local tool source and the connector
|
|
51
|
+
tools of the connectors MCP server. Every call runs in its own Dex tool Step,
|
|
52
|
+
with the CLI core's policy. Reads run at once, file writes and shell commands
|
|
53
|
+
wait for approval unless the shell allow list has the command, and the file
|
|
54
|
+
tools stay in the workspace. See the
|
|
55
|
+
[CLI core README](../core/README.md) for the local tools.
|
|
56
|
+
|
|
57
|
+
## Images
|
|
58
|
+
|
|
59
|
+
`/image <path>` attaches an image file to the next message. The command gives
|
|
60
|
+
the Pydantic AI adapter the media store of `media.store`, so the model sees the
|
|
61
|
+
image, and images that tools return go to the same store. See
|
|
62
|
+
[Images](../../README.md#images).
|
|
63
|
+
|
|
64
|
+
## Development
|
|
65
|
+
|
|
66
|
+
Develop with uv 0.12.2. The package resolves `dex-agents`, the adapter, the
|
|
67
|
+
CLI core, and the shared test support from this repository by path. `uv.lock`
|
|
68
|
+
pins `pydantic-ai-slim` to the version the adapter's lock pins, and `ci.sh`
|
|
69
|
+
checks that. `ci.sh` installs the locked dependencies, checks lint and types,
|
|
70
|
+
and runs the tests against a private `dexcli dev`:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
cd agents/cli/python/pydantic-ai
|
|
74
|
+
DEXCLI=/path/to/dexcli ./ci.sh
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The tests run the command in a pseudo-terminal with a private home and an
|
|
78
|
+
allow-listed environment. Pydantic AI's OpenAI provider calls the scripted
|
|
79
|
+
Responses API of [`../testing`](../testing); a refused proxy stops any other
|
|
80
|
+
request. A fake connectors MCP server serves a connector read and write. The
|
|
81
|
+
tests cover a chat turn and `--resume`, `read_file` without approval and
|
|
82
|
+
`write_file` after approval, a connector read and an approved connector write
|
|
83
|
+
that runs once, session settings that change the model, and a key in the
|
|
84
|
+
`pydantic_ai` section.
|
|
85
|
+
They also cover a `system_prompt` set in the session settings, which reaches
|
|
86
|
+
the next model request, and a rejected file write and connector write, which
|
|
87
|
+
never run.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "dex-agents-pydantic-ai-cli"
|
|
3
|
+
version = "0.6.1"
|
|
4
|
+
description = "The dex-agents-pydantic-ai command: a durable Pydantic AI agent in your terminal"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "LicenseRef-Sustainable-Use-1.0"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.11"
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 3 - Alpha",
|
|
11
|
+
"Programming Language :: Python :: 3",
|
|
12
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
13
|
+
"Typing :: Typed",
|
|
14
|
+
]
|
|
15
|
+
dependencies = [
|
|
16
|
+
"dex-agents==0.6.1",
|
|
17
|
+
"dex-agents-cli-core==0.6.1",
|
|
18
|
+
"dex-agents-pydantic-ai==0.6.1",
|
|
19
|
+
"dex-python-sdk==1.45.0",
|
|
20
|
+
"pydantic-ai-slim[anthropic,google,openai]>=2.64,<3",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[[project.authors]]
|
|
24
|
+
name = "Super Durable"
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
dex-agents-pydantic-ai = "dex_agents_pydantic_ai_cli:run"
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://github.com/superdurable/dex/tree/main/agents/cli/python/pydantic-ai"
|
|
31
|
+
Repository = "https://github.com/superdurable/dex"
|
|
32
|
+
Changelog = "https://github.com/superdurable/dex/blob/main/agents/CHANGELOG.md"
|
|
33
|
+
|
|
34
|
+
[dependency-groups]
|
|
35
|
+
dev = [
|
|
36
|
+
"dex-agents-cli-testing",
|
|
37
|
+
"mypy>=1.15,<2",
|
|
38
|
+
"pexpect>=4.9,<5",
|
|
39
|
+
"pytest>=8.3,<9",
|
|
40
|
+
"pytest-asyncio>=0.26,<2",
|
|
41
|
+
"ruff>=0.8,<0.9",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[build-system]
|
|
45
|
+
requires = ["uv_build>=0.12.2,<0.13"]
|
|
46
|
+
build-backend = "uv_build"
|
|
47
|
+
|
|
48
|
+
[tool.uv]
|
|
49
|
+
required-version = "==0.12.2"
|
|
50
|
+
|
|
51
|
+
[tool.uv.sources.dex-agents]
|
|
52
|
+
path = "../../../python/core"
|
|
53
|
+
editable = true
|
|
54
|
+
|
|
55
|
+
[tool.uv.sources.dex-agents-cli-core]
|
|
56
|
+
path = "../core"
|
|
57
|
+
editable = true
|
|
58
|
+
|
|
59
|
+
[tool.uv.sources.dex-agents-cli-testing]
|
|
60
|
+
path = "../testing"
|
|
61
|
+
editable = true
|
|
62
|
+
|
|
63
|
+
[tool.uv.sources.dex-agents-pydantic-ai]
|
|
64
|
+
path = "../../../python/pydantic-ai"
|
|
65
|
+
editable = true
|
|
66
|
+
|
|
67
|
+
[tool.ruff]
|
|
68
|
+
target-version = "py311"
|
|
69
|
+
line-length = 100
|
|
70
|
+
|
|
71
|
+
[tool.ruff.lint]
|
|
72
|
+
select = [
|
|
73
|
+
"E",
|
|
74
|
+
"F",
|
|
75
|
+
"W",
|
|
76
|
+
"I",
|
|
77
|
+
"B",
|
|
78
|
+
"UP",
|
|
79
|
+
"ASYNC",
|
|
80
|
+
"RUF",
|
|
81
|
+
]
|
|
82
|
+
ignore = [
|
|
83
|
+
"ASYNC109",
|
|
84
|
+
"ASYNC110",
|
|
85
|
+
"ASYNC220",
|
|
86
|
+
"ASYNC221",
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
[tool.ruff.lint.isort]
|
|
90
|
+
known-first-party = [
|
|
91
|
+
"dex_agents",
|
|
92
|
+
"dex_agents_cli_core",
|
|
93
|
+
"dex_agents_pydantic_ai",
|
|
94
|
+
"dex_agents_pydantic_ai_cli",
|
|
95
|
+
"dex_agents_cli_testing",
|
|
96
|
+
"tests",
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
[tool.mypy]
|
|
100
|
+
python_version = "3.11"
|
|
101
|
+
strict = true
|
|
102
|
+
files = [
|
|
103
|
+
"src",
|
|
104
|
+
"tests",
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
[[tool.mypy.overrides]]
|
|
108
|
+
module = [
|
|
109
|
+
"pexpect",
|
|
110
|
+
"pexpect.*",
|
|
111
|
+
]
|
|
112
|
+
ignore_missing_imports = true
|
|
113
|
+
|
|
114
|
+
[tool.pytest.ini_options]
|
|
115
|
+
testpaths = ["tests"]
|
|
116
|
+
pythonpath = ["."]
|
|
117
|
+
asyncio_mode = "auto"
|
|
118
|
+
asyncio_default_fixture_loop_scope = "session"
|
|
119
|
+
asyncio_default_test_loop_scope = "session"
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "dex-agents-pydantic-ai-cli"
|
|
3
|
+
# Every agents package shares one version; agents/script/stamp_agents_release_version.py sets it.
|
|
4
|
+
version = "0.6.1"
|
|
5
|
+
description = "The dex-agents-pydantic-ai command: a durable Pydantic AI agent in your terminal"
|
|
6
|
+
authors = [{name = "Super Durable"}]
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
license = "LicenseRef-Sustainable-Use-1.0"
|
|
9
|
+
license-files = ["LICENSE"]
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 3 - Alpha",
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
15
|
+
"Typing :: Typed",
|
|
16
|
+
]
|
|
17
|
+
dependencies = [
|
|
18
|
+
"dex-agents==0.6.1",
|
|
19
|
+
"dex-agents-cli-core==0.6.1",
|
|
20
|
+
"dex-agents-pydantic-ai==0.6.1",
|
|
21
|
+
"dex-python-sdk==1.45.0",
|
|
22
|
+
"pydantic-ai-slim[anthropic,google,openai]>=2.64,<3",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
dex-agents-pydantic-ai = "dex_agents_pydantic_ai_cli:run"
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://github.com/superdurable/dex/tree/main/agents/cli/python/pydantic-ai"
|
|
30
|
+
Repository = "https://github.com/superdurable/dex"
|
|
31
|
+
Changelog = "https://github.com/superdurable/dex/blob/main/agents/CHANGELOG.md"
|
|
32
|
+
|
|
33
|
+
[dependency-groups]
|
|
34
|
+
dev = [
|
|
35
|
+
"dex-agents-cli-testing",
|
|
36
|
+
"mypy>=1.15,<2",
|
|
37
|
+
"pexpect>=4.9,<5",
|
|
38
|
+
"pytest>=8.3,<9",
|
|
39
|
+
"pytest-asyncio>=0.26,<2",
|
|
40
|
+
"ruff>=0.8,<0.9",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[build-system]
|
|
44
|
+
requires = ["uv_build>=0.12.2,<0.13"]
|
|
45
|
+
build-backend = "uv_build"
|
|
46
|
+
|
|
47
|
+
[tool.uv]
|
|
48
|
+
required-version = "==0.12.2"
|
|
49
|
+
|
|
50
|
+
[tool.uv.sources]
|
|
51
|
+
dex-agents = { path = "../../../python/core", editable = true }
|
|
52
|
+
dex-agents-cli-core = { path = "../core", editable = true }
|
|
53
|
+
dex-agents-cli-testing = { path = "../testing", editable = true }
|
|
54
|
+
dex-agents-pydantic-ai = { path = "../../../python/pydantic-ai", editable = true }
|
|
55
|
+
|
|
56
|
+
[tool.ruff]
|
|
57
|
+
target-version = "py311"
|
|
58
|
+
line-length = 100
|
|
59
|
+
|
|
60
|
+
[tool.ruff.lint]
|
|
61
|
+
select = ["E", "F", "W", "I", "B", "UP", "ASYNC", "RUF"]
|
|
62
|
+
# Test helpers poll files and spawn children on purpose.
|
|
63
|
+
ignore = ["ASYNC109", "ASYNC110", "ASYNC220", "ASYNC221"]
|
|
64
|
+
|
|
65
|
+
[tool.ruff.lint.isort]
|
|
66
|
+
known-first-party = [
|
|
67
|
+
"dex_agents",
|
|
68
|
+
"dex_agents_cli_core",
|
|
69
|
+
"dex_agents_pydantic_ai",
|
|
70
|
+
"dex_agents_pydantic_ai_cli",
|
|
71
|
+
"dex_agents_cli_testing",
|
|
72
|
+
"tests",
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
[tool.mypy]
|
|
76
|
+
python_version = "3.11"
|
|
77
|
+
strict = true
|
|
78
|
+
files = ["src", "tests"]
|
|
79
|
+
|
|
80
|
+
[[tool.mypy.overrides]]
|
|
81
|
+
module = ["pexpect", "pexpect.*"]
|
|
82
|
+
ignore_missing_imports = true
|
|
83
|
+
|
|
84
|
+
[tool.pytest.ini_options]
|
|
85
|
+
testpaths = ["tests"]
|
|
86
|
+
pythonpath = ["."]
|
|
87
|
+
asyncio_mode = "auto"
|
|
88
|
+
asyncio_default_fixture_loop_scope = "session"
|
|
89
|
+
asyncio_default_test_loop_scope = "session"
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Sustainable Use License 1.0.
|
|
4
|
+
# You may not use this file except in compliance with the License.
|
|
5
|
+
# See the LICENSE file in the repository root.
|
|
6
|
+
#
|
|
7
|
+
# SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
|
|
8
|
+
|
|
9
|
+
"""The ``dex-agents-pydantic-ai`` command: a Pydantic AI agent in the terminal.
|
|
10
|
+
|
|
11
|
+
It builds the agent session Flow with the Dex Pydantic AI adapter and
|
|
12
|
+
runs it with the shared Dex Agents CLI core. See the package README.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import dex_agents_cli_core # noqa: F401 # first: it configures gRPC before anything imports it
|
|
16
|
+
|
|
17
|
+
# isort: split
|
|
18
|
+
|
|
19
|
+
import sys
|
|
20
|
+
|
|
21
|
+
from dex_agents_cli_core import ConfigError, command_name, run_agent_cli
|
|
22
|
+
from dex_agents_pydantic_ai_cli.harness import (
|
|
23
|
+
DEFAULT_INSTRUCTIONS,
|
|
24
|
+
DEFAULT_PYDANTIC_AI_MODEL,
|
|
25
|
+
PYDANTIC_AI_CLI_FLOW_TYPE,
|
|
26
|
+
PydanticAiHarness,
|
|
27
|
+
validate_pydantic_ai_section,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"DEFAULT_INSTRUCTIONS",
|
|
32
|
+
"DEFAULT_PYDANTIC_AI_MODEL",
|
|
33
|
+
"PYDANTIC_AI_CLI_FLOW_TYPE",
|
|
34
|
+
"PydanticAiHarness",
|
|
35
|
+
"main",
|
|
36
|
+
"run",
|
|
37
|
+
"validate_pydantic_ai_section",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def main(argv: list[str] | None = None) -> int:
|
|
42
|
+
"""Run the command and return its exit code.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
argv: The arguments without the program name; ``None`` reads ``sys.argv``.
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
0 on success, 1 for a failure at run time, and 2 for a usage or
|
|
49
|
+
configuration error, such as a key in the ``pydantic_ai`` section.
|
|
50
|
+
"""
|
|
51
|
+
harness = PydanticAiHarness()
|
|
52
|
+
try:
|
|
53
|
+
return run_agent_cli(harness, argv)
|
|
54
|
+
except ConfigError as error:
|
|
55
|
+
print(f"{command_name(harness)}: {error}", file=sys.stderr)
|
|
56
|
+
return 2
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def run() -> None:
|
|
60
|
+
"""Run the command from its console script and exit with its code."""
|
|
61
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Sustainable Use License 1.0.
|
|
4
|
+
# You may not use this file except in compliance with the License.
|
|
5
|
+
# See the LICENSE file in the repository root.
|
|
6
|
+
#
|
|
7
|
+
# SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
|
|
8
|
+
|
|
9
|
+
"""``python -m dex_agents_pydantic_ai_cli`` runs the ``dex-agents-pydantic-ai`` command."""
|
|
10
|
+
|
|
11
|
+
from dex_agents_pydantic_ai_cli import run
|
|
12
|
+
|
|
13
|
+
if __name__ == "__main__":
|
|
14
|
+
run()
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Sustainable Use License 1.0.
|
|
4
|
+
# You may not use this file except in compliance with the License.
|
|
5
|
+
# See the LICENSE file in the repository root.
|
|
6
|
+
#
|
|
7
|
+
# SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
|
|
8
|
+
|
|
9
|
+
"""The Pydantic AI harness: a Pydantic AI agent with the CLI core's tools."""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from collections.abc import Mapping
|
|
14
|
+
from typing import Any
|
|
15
|
+
|
|
16
|
+
import dex_agents_cli_core # noqa: F401 # first: it configures gRPC before anything imports it
|
|
17
|
+
|
|
18
|
+
# isort: split
|
|
19
|
+
|
|
20
|
+
from pydantic_ai import Agent
|
|
21
|
+
from pydantic_ai.models import Model, infer_model
|
|
22
|
+
from pydantic_ai.models.wrapper import WrapperModel
|
|
23
|
+
|
|
24
|
+
from dex_agents import AgentSessionFlow
|
|
25
|
+
from dex_agents_cli_core import ConfigError, HarnessContext, LocalToolGroup, current_turn_config
|
|
26
|
+
from dex_agents_pydantic_ai import pydantic_ai_session_flow
|
|
27
|
+
|
|
28
|
+
#: The Flow type of the command's sessions, before the CLI core namespaces it.
|
|
29
|
+
PYDANTIC_AI_CLI_FLOW_TYPE = "DexAgentsPydanticAiCliSession"
|
|
30
|
+
|
|
31
|
+
#: The Pydantic AI model the command uses when the configuration file sets none.
|
|
32
|
+
DEFAULT_PYDANTIC_AI_MODEL = "openai:gpt-5.2"
|
|
33
|
+
|
|
34
|
+
#: The instructions the agent gets when the configuration sets none.
|
|
35
|
+
DEFAULT_INSTRUCTIONS = (
|
|
36
|
+
"You are a helpful assistant. Use your tools to work with the files and commands "
|
|
37
|
+
"in your workspace and with the connected services."
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class PydanticAiHarness:
|
|
42
|
+
"""The ``dex-agents-pydantic-ai`` command: a Pydantic AI agent in the terminal.
|
|
43
|
+
|
|
44
|
+
Every model call uses the turn's model, a Pydantic AI model name such as
|
|
45
|
+
``openai:gpt-5.2`` or ``anthropic:claude-opus-5-5``, and the turn's
|
|
46
|
+
instructions. The provider reads its standard environment variables. The
|
|
47
|
+
CLI core's connector and local tools are the agent's only tools.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
name = "pydantic-ai"
|
|
51
|
+
config_section = "pydantic_ai"
|
|
52
|
+
flow_type = PYDANTIC_AI_CLI_FLOW_TYPE
|
|
53
|
+
default_model: str | None = DEFAULT_PYDANTIC_AI_MODEL
|
|
54
|
+
replaced_local_tools: frozenset[LocalToolGroup] = frozenset()
|
|
55
|
+
|
|
56
|
+
def create_session_flow(self, context: HarnessContext) -> AgentSessionFlow:
|
|
57
|
+
"""Build the Pydantic AI agent session Flow from the effective configuration.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
context: The configuration, workspace, and tool sources.
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
The Flow, with ``context.flow_type`` as its type.
|
|
64
|
+
|
|
65
|
+
Raises:
|
|
66
|
+
ConfigError: If the ``pydantic_ai`` section has a key; it has no options yet.
|
|
67
|
+
"""
|
|
68
|
+
validate_pydantic_ai_section(context.harness_options)
|
|
69
|
+
|
|
70
|
+
def instructions() -> str:
|
|
71
|
+
return context.current_turn().instructions or DEFAULT_INSTRUCTIONS
|
|
72
|
+
|
|
73
|
+
agent: Agent[None, str] = Agent(
|
|
74
|
+
TurnModel(context.config.model), instructions=instructions, name="pydantic-ai"
|
|
75
|
+
)
|
|
76
|
+
return pydantic_ai_session_flow(
|
|
77
|
+
agent,
|
|
78
|
+
flow_type=context.flow_type,
|
|
79
|
+
tool_sources=context.tool_sources,
|
|
80
|
+
media_store=context.media_store,
|
|
81
|
+
summary_attributes_indexed=context.is_session_summary_indexed,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class TurnModel(WrapperModel):
|
|
86
|
+
"""Call the running turn's model, so session settings can change it between turns.
|
|
87
|
+
|
|
88
|
+
Outside a turn, such as in a compaction summary call, it calls the file's model.
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
def __init__(self, file_model: str) -> None:
|
|
92
|
+
"""Create the model without resolving any provider yet.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
file_model: The configuration file's model name.
|
|
96
|
+
"""
|
|
97
|
+
Model.__init__(self)
|
|
98
|
+
self._file_model = file_model
|
|
99
|
+
self._models: dict[str, Model] = {}
|
|
100
|
+
|
|
101
|
+
@property
|
|
102
|
+
def wrapped(self) -> Model: # type: ignore[override]
|
|
103
|
+
"""Return the running turn's model, resolved once per name."""
|
|
104
|
+
turn = current_turn_config()
|
|
105
|
+
model_name = self._file_model if turn is None else turn.model
|
|
106
|
+
model = self._models.get(model_name)
|
|
107
|
+
if model is None:
|
|
108
|
+
model = infer_model(model_name)
|
|
109
|
+
self._models[model_name] = model
|
|
110
|
+
return model
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def validate_pydantic_ai_section(options: Mapping[str, Any]) -> None:
|
|
114
|
+
"""Reject every key of the ``pydantic_ai`` section, which has no options yet.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
options: The section, ``{}`` when the file omits it.
|
|
118
|
+
|
|
119
|
+
Raises:
|
|
120
|
+
ConfigError: ``schema`` with the first key's JSON Pointer.
|
|
121
|
+
"""
|
|
122
|
+
for key in sorted(options):
|
|
123
|
+
escaped = key.replace("~", "~0").replace("/", "~1")
|
|
124
|
+
raise ConfigError("schema", f"/pydantic_ai/{escaped}", keyword="additionalProperties")
|
|
File without changes
|