dex-agents-openai-sdk-cli 0.6.0__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_openai_sdk_cli-0.6.0/LICENSE +105 -0
- dex_agents_openai_sdk_cli-0.6.0/PKG-INFO +112 -0
- dex_agents_openai_sdk_cli-0.6.0/README.md +90 -0
- dex_agents_openai_sdk_cli-0.6.0/pyproject.toml +119 -0
- dex_agents_openai_sdk_cli-0.6.0/pyproject.toml.orig +89 -0
- dex_agents_openai_sdk_cli-0.6.0/src/dex_agents_openai_sdk_cli/__init__.py +63 -0
- dex_agents_openai_sdk_cli-0.6.0/src/dex_agents_openai_sdk_cli/__main__.py +14 -0
- dex_agents_openai_sdk_cli-0.6.0/src/dex_agents_openai_sdk_cli/harness.py +121 -0
- dex_agents_openai_sdk_cli-0.6.0/src/dex_agents_openai_sdk_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,112 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dex-agents-openai-sdk-cli
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: The dex-agents-openai-sdk command: a durable OpenAI Agents SDK 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.0
|
|
13
|
+
Requires-Dist: dex-agents-cli-core==0.6.0
|
|
14
|
+
Requires-Dist: dex-agents-openai-agents==0.6.0
|
|
15
|
+
Requires-Dist: dex-python-sdk==1.45.0
|
|
16
|
+
Requires-Dist: openai-agents>=0.24,<0.25
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Project-URL: Homepage, https://github.com/superdurable/dex/tree/main/agents/cli/python/openai-sdk
|
|
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-openai-sdk-cli
|
|
24
|
+
|
|
25
|
+
`dex-agents-openai-sdk-cli` provides the `dex-agents-openai-sdk` command. It
|
|
26
|
+
runs an [OpenAI Agents SDK](https://openai.github.io/openai-agents-python/)
|
|
27
|
+
agent as a durable Dex agent session and chats with it in your terminal. The
|
|
28
|
+
shared CLI core, [`dex-agents-cli-core`](../core/README.md), starts or reuses
|
|
29
|
+
`dexcli dev`, connects the connectors MCP server, and runs the Worker. This
|
|
30
|
+
package only builds the agent with the
|
|
31
|
+
[OpenAI Agents SDK adapter](../../../python/openai-agents/README.md).
|
|
32
|
+
|
|
33
|
+
## Running it
|
|
34
|
+
|
|
35
|
+
The command needs Python 3.11 or later and an OpenAI API key:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
export OPENAI_API_KEY=sk-...
|
|
39
|
+
uvx --from dex-agents-openai-sdk-cli dex-agents-openai-sdk
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The first run asks the `init` questions and writes
|
|
43
|
+
`~/.dex/agents/openai-sdk.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 SDK reads `OPENAI_API_KEY`, and `OPENAI_BASE_URL` for another endpoint.
|
|
51
|
+
The command never prints or stores the key. The SDK's own tracing is off, so
|
|
52
|
+
conversations are not uploaded to the OpenAI traces dashboard; Dex records
|
|
53
|
+
every model call and tool call in the session.
|
|
54
|
+
|
|
55
|
+
## Configuration
|
|
56
|
+
|
|
57
|
+
The model defaults to `gpt-5.2`; set `model` in the file or pass `--model` to
|
|
58
|
+
change it. It is an OpenAI Responses API model name. A session's settings may
|
|
59
|
+
change the model and the instructions; each model call uses the values of its
|
|
60
|
+
turn. `system_prompt` replaces the default instructions. The `openai` section
|
|
61
|
+
has no options yet, and any key in it is a configuration error.
|
|
62
|
+
|
|
63
|
+
## Tools
|
|
64
|
+
|
|
65
|
+
The agent's tools are the CLI core's: its local tool source and the connector
|
|
66
|
+
tools of the connectors MCP server. Every call runs in its own Dex tool Step,
|
|
67
|
+
with the CLI core's policy. Reads run at once, file writes and shell commands
|
|
68
|
+
wait for approval unless the shell allow list has the command, and the file
|
|
69
|
+
tools stay in the workspace. See the
|
|
70
|
+
[CLI core README](../core/README.md) for the local tools.
|
|
71
|
+
|
|
72
|
+
The SDK fixes an agent's tools when the command starts. The command offers
|
|
73
|
+
the connector tools that the configuration file enables and that the
|
|
74
|
+
connectors MCP server lists at startup. Session settings still narrow the
|
|
75
|
+
tools of each turn. Restart the command in two cases:
|
|
76
|
+
|
|
77
|
+
- The connectors MCP server did not answer at startup, such as while it was
|
|
78
|
+
still starting. The command warns that this run has no connector tools.
|
|
79
|
+
- You authorized a connection while the command ran.
|
|
80
|
+
|
|
81
|
+
## Images
|
|
82
|
+
|
|
83
|
+
`/image <path>` attaches an image file to the next message. The command gives
|
|
84
|
+
the OpenAI Agents SDK adapter the media store of `media.store`, so the model sees the
|
|
85
|
+
image, and images that tools return go to the same store. See
|
|
86
|
+
[Images](../../README.md#images).
|
|
87
|
+
|
|
88
|
+
## Development
|
|
89
|
+
|
|
90
|
+
Develop with uv 0.12.2. The package resolves `dex-agents`, the adapter, the
|
|
91
|
+
CLI core, and the shared test support from this repository by path. `uv.lock`
|
|
92
|
+
pins `openai-agents` and `openai` to the versions the adapter's lock pins, and
|
|
93
|
+
`ci.sh` checks that. `ci.sh` installs the locked dependencies, checks lint and
|
|
94
|
+
types, and runs the tests against a private `dexcli dev`:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
cd agents/cli/python/openai-sdk
|
|
98
|
+
DEXCLI=/path/to/dexcli ./ci.sh
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The tests run the command in a pseudo-terminal with a private home and an
|
|
102
|
+
allow-listed environment. The SDK calls the scripted Responses API of
|
|
103
|
+
[`../testing`](../testing); a refused proxy stops any other request. A fake
|
|
104
|
+
connectors MCP server serves a connector read and write. The tests cover a
|
|
105
|
+
chat turn and `--resume`, `read_file` without approval and `write_file` after
|
|
106
|
+
approval, a connector read and an approved connector write that runs once,
|
|
107
|
+
session settings that change the model, and a key in the `openai` section.
|
|
108
|
+
They also cover a `system_prompt` set in the session settings, which reaches
|
|
109
|
+
the next model request, and a rejected file write and connector write, which
|
|
110
|
+
never run.
|
|
111
|
+
The OpenAI Agents SDK command also warns to restart when the connectors MCP
|
|
112
|
+
server does not answer at startup.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# dex-agents-openai-sdk-cli
|
|
2
|
+
|
|
3
|
+
`dex-agents-openai-sdk-cli` provides the `dex-agents-openai-sdk` command. It
|
|
4
|
+
runs an [OpenAI Agents SDK](https://openai.github.io/openai-agents-python/)
|
|
5
|
+
agent as a durable Dex agent session and chats with it in your terminal. The
|
|
6
|
+
shared CLI core, [`dex-agents-cli-core`](../core/README.md), starts or reuses
|
|
7
|
+
`dexcli dev`, connects the connectors MCP server, and runs the Worker. This
|
|
8
|
+
package only builds the agent with the
|
|
9
|
+
[OpenAI Agents SDK adapter](../../../python/openai-agents/README.md).
|
|
10
|
+
|
|
11
|
+
## Running it
|
|
12
|
+
|
|
13
|
+
The command needs Python 3.11 or later and an OpenAI API key:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
export OPENAI_API_KEY=sk-...
|
|
17
|
+
uvx --from dex-agents-openai-sdk-cli dex-agents-openai-sdk
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The first run asks the `init` questions and writes
|
|
21
|
+
`~/.dex/agents/openai-sdk.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 SDK reads `OPENAI_API_KEY`, and `OPENAI_BASE_URL` for another endpoint.
|
|
29
|
+
The command never prints or stores the key. The SDK's own tracing is off, so
|
|
30
|
+
conversations are not uploaded to the OpenAI traces dashboard; Dex records
|
|
31
|
+
every model call and tool call in the session.
|
|
32
|
+
|
|
33
|
+
## Configuration
|
|
34
|
+
|
|
35
|
+
The model defaults to `gpt-5.2`; set `model` in the file or pass `--model` to
|
|
36
|
+
change it. It is an OpenAI Responses API model name. A session's settings may
|
|
37
|
+
change the model and the instructions; each model call uses the values of its
|
|
38
|
+
turn. `system_prompt` replaces the default instructions. The `openai` section
|
|
39
|
+
has no options yet, and any key in it is a configuration error.
|
|
40
|
+
|
|
41
|
+
## Tools
|
|
42
|
+
|
|
43
|
+
The agent's tools are the CLI core's: its local tool source and the connector
|
|
44
|
+
tools of the connectors MCP server. Every call runs in its own Dex tool Step,
|
|
45
|
+
with the CLI core's policy. Reads run at once, file writes and shell commands
|
|
46
|
+
wait for approval unless the shell allow list has the command, and the file
|
|
47
|
+
tools stay in the workspace. See the
|
|
48
|
+
[CLI core README](../core/README.md) for the local tools.
|
|
49
|
+
|
|
50
|
+
The SDK fixes an agent's tools when the command starts. The command offers
|
|
51
|
+
the connector tools that the configuration file enables and that the
|
|
52
|
+
connectors MCP server lists at startup. Session settings still narrow the
|
|
53
|
+
tools of each turn. Restart the command in two cases:
|
|
54
|
+
|
|
55
|
+
- The connectors MCP server did not answer at startup, such as while it was
|
|
56
|
+
still starting. The command warns that this run has no connector tools.
|
|
57
|
+
- You authorized a connection while the command ran.
|
|
58
|
+
|
|
59
|
+
## Images
|
|
60
|
+
|
|
61
|
+
`/image <path>` attaches an image file to the next message. The command gives
|
|
62
|
+
the OpenAI Agents SDK adapter the media store of `media.store`, so the model sees the
|
|
63
|
+
image, and images that tools return go to the same store. See
|
|
64
|
+
[Images](../../README.md#images).
|
|
65
|
+
|
|
66
|
+
## Development
|
|
67
|
+
|
|
68
|
+
Develop with uv 0.12.2. The package resolves `dex-agents`, the adapter, the
|
|
69
|
+
CLI core, and the shared test support from this repository by path. `uv.lock`
|
|
70
|
+
pins `openai-agents` and `openai` to the versions the adapter's lock pins, and
|
|
71
|
+
`ci.sh` checks that. `ci.sh` installs the locked dependencies, checks lint and
|
|
72
|
+
types, and runs the tests against a private `dexcli dev`:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
cd agents/cli/python/openai-sdk
|
|
76
|
+
DEXCLI=/path/to/dexcli ./ci.sh
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The tests run the command in a pseudo-terminal with a private home and an
|
|
80
|
+
allow-listed environment. The SDK calls the scripted Responses API of
|
|
81
|
+
[`../testing`](../testing); a refused proxy stops any other request. A fake
|
|
82
|
+
connectors MCP server serves a connector read and write. The tests cover a
|
|
83
|
+
chat turn and `--resume`, `read_file` without approval and `write_file` after
|
|
84
|
+
approval, a connector read and an approved connector write that runs once,
|
|
85
|
+
session settings that change the model, and a key in the `openai` section.
|
|
86
|
+
They also cover a `system_prompt` set in the session settings, which reaches
|
|
87
|
+
the next model request, and a rejected file write and connector write, which
|
|
88
|
+
never run.
|
|
89
|
+
The OpenAI Agents SDK command also warns to restart when the connectors MCP
|
|
90
|
+
server does not answer at startup.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "dex-agents-openai-sdk-cli"
|
|
3
|
+
version = "0.6.0"
|
|
4
|
+
description = "The dex-agents-openai-sdk command: a durable OpenAI Agents SDK 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.0",
|
|
17
|
+
"dex-agents-cli-core==0.6.0",
|
|
18
|
+
"dex-agents-openai-agents==0.6.0",
|
|
19
|
+
"dex-python-sdk==1.45.0",
|
|
20
|
+
"openai-agents>=0.24,<0.25",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[[project.authors]]
|
|
24
|
+
name = "Super Durable"
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
dex-agents-openai-sdk = "dex_agents_openai_sdk_cli:run"
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://github.com/superdurable/dex/tree/main/agents/cli/python/openai-sdk"
|
|
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-openai-agents]
|
|
64
|
+
path = "../../../python/openai-agents"
|
|
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_openai_agents",
|
|
93
|
+
"dex_agents_openai_sdk_cli",
|
|
94
|
+
"dex_agents_cli_core",
|
|
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-openai-sdk-cli"
|
|
3
|
+
# Every agents package shares one version; agents/script/stamp_agents_release_version.py sets it.
|
|
4
|
+
version = "0.6.0"
|
|
5
|
+
description = "The dex-agents-openai-sdk command: a durable OpenAI Agents SDK 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.0",
|
|
19
|
+
"dex-agents-cli-core==0.6.0",
|
|
20
|
+
"dex-agents-openai-agents==0.6.0",
|
|
21
|
+
"dex-python-sdk==1.45.0",
|
|
22
|
+
"openai-agents>=0.24,<0.25",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
dex-agents-openai-sdk = "dex_agents_openai_sdk_cli:run"
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://github.com/superdurable/dex/tree/main/agents/cli/python/openai-sdk"
|
|
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-openai-agents = { path = "../../../python/openai-agents", 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_openai_agents",
|
|
69
|
+
"dex_agents_openai_sdk_cli",
|
|
70
|
+
"dex_agents_cli_core",
|
|
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,63 @@
|
|
|
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-openai-sdk`` command: an OpenAI Agents SDK agent in the terminal.
|
|
10
|
+
|
|
11
|
+
It builds the agent session Flow with the OpenAI Agents SDK 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_openai_sdk_cli.harness import (
|
|
23
|
+
DEFAULT_INSTRUCTIONS,
|
|
24
|
+
DEFAULT_OPENAI_MODEL,
|
|
25
|
+
OPENAI_SDK_CLI_FLOW_TYPE,
|
|
26
|
+
OpenAISdkHarness,
|
|
27
|
+
TurnModelProvider,
|
|
28
|
+
validate_openai_section,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
__all__ = [
|
|
32
|
+
"DEFAULT_INSTRUCTIONS",
|
|
33
|
+
"DEFAULT_OPENAI_MODEL",
|
|
34
|
+
"OPENAI_SDK_CLI_FLOW_TYPE",
|
|
35
|
+
"OpenAISdkHarness",
|
|
36
|
+
"TurnModelProvider",
|
|
37
|
+
"main",
|
|
38
|
+
"run",
|
|
39
|
+
"validate_openai_section",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def main(argv: list[str] | None = None) -> int:
|
|
44
|
+
"""Run the command and return its exit code.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
argv: The arguments without the program name; ``None`` reads ``sys.argv``.
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
0 on success, 1 for a failure at run time, and 2 for a usage or
|
|
51
|
+
configuration error, such as a key in the ``openai`` section.
|
|
52
|
+
"""
|
|
53
|
+
harness = OpenAISdkHarness()
|
|
54
|
+
try:
|
|
55
|
+
return run_agent_cli(harness, argv)
|
|
56
|
+
except ConfigError as error:
|
|
57
|
+
print(f"{command_name(harness)}: {error}", file=sys.stderr)
|
|
58
|
+
return 2
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def run() -> None:
|
|
62
|
+
"""Run the command from its console script and exit with its code."""
|
|
63
|
+
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_openai_sdk_cli`` runs the ``dex-agents-openai-sdk`` command."""
|
|
10
|
+
|
|
11
|
+
from dex_agents_openai_sdk_cli import run
|
|
12
|
+
|
|
13
|
+
if __name__ == "__main__":
|
|
14
|
+
run()
|
|
@@ -0,0 +1,121 @@
|
|
|
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 OpenAI Agents SDK harness: an SDK 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 agents import Agent, Model, ModelProvider, MultiProvider, RunConfig, RunContextWrapper
|
|
21
|
+
|
|
22
|
+
from dex_agents import AgentSessionFlow
|
|
23
|
+
from dex_agents_cli_core import ConfigError, HarnessContext, LocalToolGroup, current_turn_config
|
|
24
|
+
from dex_agents_openai_agents import openai_agents_session_flow
|
|
25
|
+
|
|
26
|
+
#: The Flow type of the command's sessions, before the CLI core namespaces it.
|
|
27
|
+
OPENAI_SDK_CLI_FLOW_TYPE = "DexAgentsOpenAISdkCliSession"
|
|
28
|
+
|
|
29
|
+
#: The model the command uses when the configuration file sets none.
|
|
30
|
+
DEFAULT_OPENAI_MODEL = "gpt-5.2"
|
|
31
|
+
|
|
32
|
+
#: The instructions the agent gets when the configuration sets none.
|
|
33
|
+
DEFAULT_INSTRUCTIONS = (
|
|
34
|
+
"You are a helpful assistant. Use your tools to work with the files and commands "
|
|
35
|
+
"in your workspace and with the connected services."
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class OpenAISdkHarness:
|
|
40
|
+
"""The ``dex-agents-openai-sdk`` command: an OpenAI Agents SDK agent in the terminal.
|
|
41
|
+
|
|
42
|
+
Each model call uses the turn's model through the SDK's default model
|
|
43
|
+
provider, so ``OPENAI_API_KEY`` and ``OPENAI_BASE_URL`` apply, and a
|
|
44
|
+
``litellm/`` prefix needs LiteLLM installed. The CLI core's connector and
|
|
45
|
+
local tools are the agent's only tools. The SDK's own tracing is off, so
|
|
46
|
+
no conversation leaves the machine for the OpenAI traces dashboard.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
name = "openai-sdk"
|
|
50
|
+
config_section = "openai"
|
|
51
|
+
flow_type = OPENAI_SDK_CLI_FLOW_TYPE
|
|
52
|
+
default_model: str | None = DEFAULT_OPENAI_MODEL
|
|
53
|
+
replaced_local_tools: frozenset[LocalToolGroup] = frozenset()
|
|
54
|
+
# The SDK fixes an agent's tools when the runner is built.
|
|
55
|
+
is_tool_set_fixed_at_build = True
|
|
56
|
+
|
|
57
|
+
def create_session_flow(self, context: HarnessContext) -> AgentSessionFlow:
|
|
58
|
+
"""Build the OpenAI Agents SDK agent session Flow from the effective configuration.
|
|
59
|
+
|
|
60
|
+
The runner offers the connector tools the file enables when the
|
|
61
|
+
command starts; a connection authorized later needs a restart.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
context: The configuration, workspace, and tool sources.
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
The Flow, with ``context.flow_type`` as its type.
|
|
68
|
+
|
|
69
|
+
Raises:
|
|
70
|
+
ConfigError: If the ``openai`` section has a key; it has no options yet.
|
|
71
|
+
"""
|
|
72
|
+
validate_openai_section(context.harness_options)
|
|
73
|
+
|
|
74
|
+
def instructions(run_context: RunContextWrapper[Any], agent: Agent[Any]) -> str:
|
|
75
|
+
return context.current_turn().instructions or DEFAULT_INSTRUCTIONS
|
|
76
|
+
|
|
77
|
+
agent: Agent[Any] = Agent(
|
|
78
|
+
name="assistant", instructions=instructions, model=context.config.model
|
|
79
|
+
)
|
|
80
|
+
return openai_agents_session_flow(
|
|
81
|
+
agent,
|
|
82
|
+
flow_type=context.flow_type,
|
|
83
|
+
run_config=RunConfig(model_provider=TurnModelProvider(), tracing_disabled=True),
|
|
84
|
+
tool_sources=context.tool_sources,
|
|
85
|
+
media_store=context.media_store,
|
|
86
|
+
summary_attributes_indexed=context.is_session_summary_indexed,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class TurnModelProvider(ModelProvider):
|
|
91
|
+
"""Give every model call the running turn's model, which session settings may change."""
|
|
92
|
+
|
|
93
|
+
def __init__(self) -> None:
|
|
94
|
+
"""Wrap the SDK's default ``MultiProvider``."""
|
|
95
|
+
self._provider = MultiProvider()
|
|
96
|
+
|
|
97
|
+
def get_model(self, model_name: str | None) -> Model:
|
|
98
|
+
"""Return the running turn's model; ``model_name`` is the file's.
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
model_name: The agent's model, the configuration file's.
|
|
102
|
+
|
|
103
|
+
Returns:
|
|
104
|
+
The SDK model for the turn's model name.
|
|
105
|
+
"""
|
|
106
|
+
turn = current_turn_config()
|
|
107
|
+
return self._provider.get_model(turn.model if turn is not None else model_name)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def validate_openai_section(options: Mapping[str, Any]) -> None:
|
|
111
|
+
"""Reject every key of the ``openai`` section, which has no options yet.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
options: The section, ``{}`` when the file omits it.
|
|
115
|
+
|
|
116
|
+
Raises:
|
|
117
|
+
ConfigError: ``schema`` with the first key's JSON Pointer.
|
|
118
|
+
"""
|
|
119
|
+
for key in sorted(options):
|
|
120
|
+
escaped = key.replace("~", "~0").replace("/", "~1")
|
|
121
|
+
raise ConfigError("schema", f"/openai/{escaped}", keyword="additionalProperties")
|
|
File without changes
|