dex-agents-builtin-cli 0.6.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.
@@ -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-builtin`` command: a Dex built-in loop agent in the terminal.
10
+
11
+ It builds the agent session Flow with the Dex built-in agent loop on LiteLLM 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_builtin_cli.harness import (
22
+ BUILTIN_CLI_FLOW_TYPE,
23
+ DEFAULT_BUILTIN_MODEL,
24
+ DEFAULT_INSTRUCTIONS,
25
+ BuiltinHarness,
26
+ validate_builtin_section,
27
+ )
28
+ from dex_agents_cli_core import ConfigError, command_name, run_agent_cli
29
+
30
+ __all__ = [
31
+ "BUILTIN_CLI_FLOW_TYPE",
32
+ "DEFAULT_BUILTIN_MODEL",
33
+ "DEFAULT_INSTRUCTIONS",
34
+ "BuiltinHarness",
35
+ "main",
36
+ "run",
37
+ "validate_builtin_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 ``builtin`` section.
50
+ """
51
+ harness = BuiltinHarness()
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_builtin_cli`` runs the ``dex-agents-builtin`` command."""
10
+
11
+ from dex_agents_builtin_cli import run
12
+
13
+ if __name__ == "__main__":
14
+ run()
@@ -0,0 +1,112 @@
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 built-in harness: a Dex built-in loop agent on LiteLLM 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 dex_agents import AgentSessionFlow, BuiltInTool
21
+ from dex_agents.builtin_loop import AgentDefinition, InstructionContext, builtin_agent_session_flow
22
+ from dex_agents.litellm import LiteLLMModelClient
23
+ from dex_agents_cli_core import ConfigError, HarnessContext, LocalToolGroup
24
+
25
+ #: The Flow type of the command's sessions, before the CLI core namespaces it.
26
+ BUILTIN_CLI_FLOW_TYPE = "DexAgentsBuiltinCliSession"
27
+
28
+ #: The LiteLLM model the command uses when the configuration file sets none.
29
+ DEFAULT_BUILTIN_MODEL = "openai/gpt-5.2"
30
+
31
+ #: The instructions the agent gets when the configuration sets none.
32
+ DEFAULT_INSTRUCTIONS = (
33
+ "You are a helpful assistant. Use your tools to work with the files and commands "
34
+ "in your workspace and with the connected services."
35
+ )
36
+
37
+
38
+ class BuiltinHarness:
39
+ """The ``dex-agents-builtin`` command: a Dex built-in loop agent in the terminal.
40
+
41
+ Every model call is one LiteLLM request with the turn's model, so any
42
+ LiteLLM provider works with its standard environment variables. The
43
+ CLI core's connector and local tools are the agent's tools, with two
44
+ built-in tools: ``ask_user`` asks the user a question, and ``write_todos``
45
+ keeps the session's plan. Plan mode is on, so a ``plan_mode`` message
46
+ drafts a plan with ``write_todos`` and ``execute_plan`` runs it. Both
47
+ built-in names are reserved: no connector or local tool may use them.
48
+
49
+ .. versionchanged:: 0.6.0
50
+ Plan mode is on, and the agent has the ``write_todos`` built-in tool.
51
+ """
52
+
53
+ name = "builtin"
54
+ config_section = "builtin"
55
+ flow_type = BUILTIN_CLI_FLOW_TYPE
56
+ default_model: str | None = DEFAULT_BUILTIN_MODEL
57
+ replaced_local_tools: frozenset[LocalToolGroup] = frozenset()
58
+
59
+ def create_session_flow(self, context: HarnessContext) -> AgentSessionFlow:
60
+ """Build the built-in loop agent session Flow from the effective configuration.
61
+
62
+ Args:
63
+ context: The configuration, workspace, and tool sources.
64
+
65
+ Returns:
66
+ The Flow, with ``context.flow_type`` as its type.
67
+
68
+ Raises:
69
+ ConfigError: If the ``builtin`` section has a key; it has no options yet.
70
+ """
71
+ validate_builtin_section(context.harness_options)
72
+ models: dict[str, LiteLLMModelClient] = {}
73
+
74
+ def resolve_model(session_settings: Mapping[str, Any]) -> LiteLLMModelClient:
75
+ model_name = context.resolve_turn(session_settings).model
76
+ if model_name not in models:
77
+ models[model_name] = LiteLLMModelClient(model_name)
78
+ return models[model_name]
79
+
80
+ def instructions(instruction_context: InstructionContext) -> str:
81
+ turn = context.resolve_turn(instruction_context.session_settings)
82
+ return turn.instructions or DEFAULT_INSTRUCTIONS
83
+
84
+ definition = AgentDefinition(
85
+ name="builtin",
86
+ instructions=instructions,
87
+ model=LiteLLMModelClient(context.config.model),
88
+ resolve_model=resolve_model,
89
+ tool_sources=list(context.tool_sources),
90
+ built_in_tools=frozenset({BuiltInTool.ASK_USER, BuiltInTool.WRITE_TODOS}),
91
+ plan_mode_enabled=True,
92
+ )
93
+ return builtin_agent_session_flow(
94
+ definition,
95
+ flow_type=context.flow_type,
96
+ media_store=context.media_store,
97
+ summary_attributes_indexed=context.is_session_summary_indexed,
98
+ )
99
+
100
+
101
+ def validate_builtin_section(options: Mapping[str, Any]) -> None:
102
+ """Reject every key of the ``builtin`` section, which has no options yet.
103
+
104
+ Args:
105
+ options: The section, ``{}`` when the file omits it.
106
+
107
+ Raises:
108
+ ConfigError: ``schema`` with the first key's JSON Pointer.
109
+ """
110
+ for key in sorted(options):
111
+ escaped = key.replace("~", "~0").replace("/", "~1")
112
+ raise ConfigError("schema", f"/builtin/{escaped}", keyword="additionalProperties")
File without changes
@@ -0,0 +1,114 @@
1
+ Metadata-Version: 2.4
2
+ Name: dex-agents-builtin-cli
3
+ Version: 0.6.0
4
+ Summary: The dex-agents-builtin command: a durable Dex built-in loop 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[litellm]==0.6.0
13
+ Requires-Dist: dex-agents-cli-core==0.6.0
14
+ Requires-Dist: dex-python-sdk==1.45.0
15
+ Requires-Dist: litellm>=1.104,<1.106
16
+ Requires-Python: >=3.11
17
+ Project-URL: Homepage, https://github.com/superdurable/dex/tree/main/agents/cli/python/builtin
18
+ Project-URL: Repository, https://github.com/superdurable/dex
19
+ Project-URL: Changelog, https://github.com/superdurable/dex/blob/main/agents/CHANGELOG.md
20
+ Description-Content-Type: text/markdown
21
+
22
+ # dex-agents-builtin-cli
23
+
24
+ `dex-agents-builtin-cli` provides the `dex-agents-builtin` command. It runs
25
+ the Dex built-in agent loop as a durable Dex agent session
26
+ and chats with it in your terminal. No agent framework is involved: the
27
+ session's own `RunModel` Step makes one model call through
28
+ [LiteLLM](https://docs.litellm.ai/), and every tool call runs in its own Dex
29
+ tool Step. The shared CLI core, [`dex-agents-cli-core`](../core/README.md),
30
+ starts or reuses `dexcli dev`, connects the connectors MCP server, and runs
31
+ the Worker. This package only builds the built-in loop agent with the
32
+ [core's LiteLLM model client](../../../python/core/README.md).
33
+
34
+ ## Running it
35
+
36
+ The command needs Python 3.11 or later and a key for the model's provider:
37
+
38
+ ```bash
39
+ export OPENAI_API_KEY=sk-...
40
+ uvx --from dex-agents-builtin-cli dex-agents-builtin
41
+ ```
42
+
43
+ The first run asks the `init` questions and writes
44
+ `~/.dex/agents/builtin.yaml`. Then type a message at the `>` prompt. Approve
45
+ or reject tool calls with `y` or `n`, answer the agent's questions, and press
46
+ Ctrl-D to exit. The session stays in Dex, and the command prints the
47
+ `--resume` line that continues it. See the
48
+ [CLI core README](../core/README.md#running-a-command) for every subcommand
49
+ and option, and [`agents/cli`](../../README.md) for the configuration file.
50
+
51
+ LiteLLM reads each provider's standard environment variables, such as
52
+ `OPENAI_API_KEY` and `OPENAI_BASE_URL` for `openai/` models and
53
+ `ANTHROPIC_API_KEY` for `anthropic/` models. The command never prints or
54
+ stores a key.
55
+
56
+ ## Configuration
57
+
58
+ The model defaults to `openai/gpt-5.2`; set `model` in the file or pass
59
+ `--model` to change it. It is a LiteLLM model name, `<provider>/<model>`, such
60
+ as `anthropic/claude-opus-5-5`. A session's settings may change the model and
61
+ the instructions; each model call uses the values of its turn.
62
+ `system_prompt` replaces the default instructions. The `builtin` section has
63
+ no options yet, and any key in it is a configuration error.
64
+
65
+ ## Tools
66
+
67
+ The agent's tools are the CLI core's: its local tool source and the connector
68
+ tools of the connectors MCP server. Every call runs in its own Dex tool Step,
69
+ with the CLI core's policy. Reads run at once, file writes and shell commands
70
+ wait for approval unless the shell allow list has the command, and the file
71
+ tools stay in the workspace. See the
72
+ [CLI core README](../core/README.md) for the local tools.
73
+
74
+ The agent also has two built-in tools that the session runs itself:
75
+
76
+ - `ask_user` asks you a question, and the turn waits for your answer.
77
+ - `write_todos` replaces the session's plan, a short task list, with no
78
+ approval.
79
+
80
+ Plan mode is on. Use it through the terminal UI (`dexcli agents-tui`) or the
81
+ session API, not the plain chat, which sends `/plan` and `/run` as ordinary
82
+ messages. In the terminal UI, `/plan <message>` starts a planning turn: the
83
+ agent drafts a plan with `write_todos` and uses no other tool. `/run` approves
84
+ the draft, and the agent runs it with every tool.
85
+
86
+ The names `ask_user` and `write_todos` are reserved, so a connector or local
87
+ tool with one of these names fails the turn. This is a breaking change for
88
+ such a tool: rename the conflicting connector or local tool, or use another
89
+ harness.
90
+
91
+ ## Development
92
+
93
+ Develop with uv 0.12.2. The package resolves `dex-agents` and the CLI core
94
+ from this repository by path. `uv.lock` pins `litellm` to the version the
95
+ core's lock pins, and `ci.sh` checks that. `ci.sh` installs the locked
96
+ dependencies, checks lint and types, and runs the tests against a private
97
+ `dexcli dev`:
98
+
99
+ ```bash
100
+ cd agents/cli/python/builtin
101
+ DEXCLI=/path/to/dexcli ./ci.sh
102
+ ```
103
+
104
+ The tests run the command in a pseudo-terminal with a private home and an
105
+ allow-listed environment. LiteLLM sends `openai/` models to the scripted
106
+ Responses API of [`../testing`](../testing); a refused proxy stops any other
107
+ request. A fake connectors MCP server serves a connector read and write. The
108
+ tests cover a chat turn and `--resume`, `read_file` without approval and
109
+ `write_file` after approval, a connector read and an approved connector write
110
+ that runs once, session settings that change the model, and a key in the
111
+ `builtin` section.
112
+ They also cover a `system_prompt` set in the session settings, which reaches
113
+ the next model request, and a rejected file write and connector write, which
114
+ never run.
@@ -0,0 +1,9 @@
1
+ dex_agents_builtin_cli/__init__.py,sha256=h9jW9WUehJCUdNXpizlZ11d_ygSXGmNhd_wr10hFz_0,1744
2
+ dex_agents_builtin_cli/__main__.py,sha256=m4GBP6qOCphOjsVEJyk8hfJCuHmexevCxj0zMHo0-Ms,430
3
+ dex_agents_builtin_cli/harness.py,sha256=l_eAIbbFZA9ECzZYm9bPAStLieSghxgpVF2wJLjXseM,4496
4
+ dex_agents_builtin_cli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ dex_agents_builtin_cli-0.6.0.dist-info/licenses/LICENSE,sha256=0AJCV4ky-vrSnT08IIdYpyiFPPoF2UrtKsBAvuvt1G4,4220
6
+ dex_agents_builtin_cli-0.6.0.dist-info/WHEEL,sha256=q9Wah2_CgP24mRNSlTyb0F8Yrbz55SzVl8eHLkZ_wvE,80
7
+ dex_agents_builtin_cli-0.6.0.dist-info/entry_points.txt,sha256=lEEqNep3vNpoyKo3qmXAh05p8etqh5rL6bbOLaXJSzk,67
8
+ dex_agents_builtin_cli-0.6.0.dist-info/METADATA,sha256=35_CqdP_9Z02kclAYoTyggmJwMdl42d7jtdnGGnswEc,5225
9
+ dex_agents_builtin_cli-0.6.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.12.2
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ dex-agents-builtin = dex_agents_builtin_cli:run
3
+
@@ -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.