langchain-agentx-cli 0.1.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.
- langchain_agentx_cli-0.1.0/LICENSE +201 -0
- langchain_agentx_cli-0.1.0/PKG-INFO +140 -0
- langchain_agentx_cli-0.1.0/README.md +108 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/__init__.py +3 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/__main__.py +8 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/app.py +149 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/bootstrap.py +49 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/bridge/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/bridge/session_bridge.py +261 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/cli.py +223 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/commands/__init__.py +19 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/commands/builtin/__init__.py +26 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/commands/builtin/clear.py +17 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/commands/builtin/compact.py +26 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/commands/builtin/help.py +27 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/commands/builtin/model.py +24 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/commands/builtin/quit.py +18 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/commands/builtin/theme.py +82 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/commands/parser.py +70 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/commands/providers/__init__.py +3 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/commands/providers/sdk_commands.py +44 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/commands/registry.py +95 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/completion/__init__.py +10 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/completion/base.py +26 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/completion/command_source.py +42 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/completion/history_source.py +34 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/config.py +131 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/history/__init__.py +3 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/history/store.py +129 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/keybindings/__init__.py +3 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/keybindings/bindings.py +43 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/llm_config.py +257 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/permissions/__init__.py +32 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/permissions/factory.py +93 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/permissions/policy.py +119 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/prompts/__init__.py +47 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/prompts/assembler.py +63 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/prompts/sections.py +59 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/prompts/system_prompt.py +105 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/screens/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/screens/repl.py +238 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/session_factory.py +110 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/session_options.py +56 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/theme/__init__.py +104 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/theme/colors.py +209 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/theme/detection.py +31 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/theme/manager.py +160 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/theme/settings.py +56 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/theme/system_theme.py +116 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/theme/themes.py +167 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/theme/watcher.py +56 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tools/__init__.py +13 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tools/registry.py +126 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tui/__init__.py +12 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tui/message_selection.py +64 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tui/permissions/__init__.py +39 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tui/permissions/cache.py +39 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tui/permissions/config.py +14 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tui/permissions/consumer.py +158 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tui/permissions/dialog.py +125 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tui/permissions/inject.py +57 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tui/permissions/models.py +27 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tui/permissions/presenters/__init__.py +63 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tui/permissions/presenters/base.py +68 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tui/permissions/presenters/bash.py +91 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tui/permissions/presenters/fallback.py +25 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tui/permissions/presenters/file.py +87 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/tui/safe_screen.py +50 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/welcome.py +48 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/__init__.py +25 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/completion_overlay.py +145 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/input_area.py +492 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/message_events.py +137 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/message_list.py +458 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/messages/__init__.py +57 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/messages/assistant_message.py +224 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/messages/error_message.py +33 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/messages/rendering.py +137 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/messages/thinking_message.py +78 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/pending_permission.py +69 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/permission_inline.py +141 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/spinner.py +318 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/__init__.py +103 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/agent/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/agent/widget.py +68 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/ask_user_question/__init__.py +7 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/ask_user_question/widget.py +61 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/base.py +178 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/bash/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/bash/widget.py +77 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/batch_edit/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/batch_edit/widget.py +62 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/edit/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/edit/widget.py +66 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/glob/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/glob/widget.py +49 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/grep/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/grep/widget.py +49 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/helpers.py +260 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/read/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/read/widget.py +92 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/skill/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/skill/widget.py +53 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/task_create/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/task_create/widget.py +43 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/task_get/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/task_get/widget.py +52 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/task_list/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/task_list/widget.py +49 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/task_update/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/task_update/widget.py +45 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/user_message/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/user_message/widget.py +93 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/webfetch/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/webfetch/widget.py +58 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/websearch/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/websearch/widget.py +53 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/write/__init__.py +5 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli/widgets/tools/write/widget.py +71 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli.egg-info/PKG-INFO +140 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli.egg-info/SOURCES.txt +132 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli.egg-info/dependency_links.txt +1 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli.egg-info/entry_points.txt +2 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli.egg-info/not-zip-safe +1 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli.egg-info/requires.txt +7 -0
- langchain_agentx_cli-0.1.0/langchain_agentx_cli.egg-info/top_level.txt +1 -0
- langchain_agentx_cli-0.1.0/pyproject.toml +58 -0
- langchain_agentx_cli-0.1.0/setup.cfg +4 -0
- langchain_agentx_cli-0.1.0/tests/test_app_interrupt.py +98 -0
- langchain_agentx_cli-0.1.0/tests/test_repl_commands.py +84 -0
- langchain_agentx_cli-0.1.0/tests/test_repl_submit_flow.py +69 -0
- langchain_agentx_cli-0.1.0/tests/test_repl_ui.py +90 -0
- langchain_agentx_cli-0.1.0/tests/test_smoke.py +124 -0
- langchain_agentx_cli-0.1.0/tests/test_welcome.py +59 -0
|
@@ -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.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: langchain-agentx-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Terminal CLI/TUI for AgentX: migrate Claude Code Ink UI, backed by langchain-agentx-python SDK.
|
|
5
|
+
Author: GoodMood2008
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/GoodMood2008/langchain-agentx-cli
|
|
8
|
+
Project-URL: Documentation, https://github.com/GoodMood2008/langchain-agentx-cli#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/GoodMood2008/langchain-agentx-cli.git
|
|
10
|
+
Project-URL: Python SDK, https://github.com/GoodMood2008/langchain_agentx_python
|
|
11
|
+
Keywords: ai,assistant,coding,claude,langchain,terminal,tui
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Environment :: Console
|
|
21
|
+
Classifier: Topic :: Software Development
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: langchain-agentx-python<0.4.0,>=0.3.0
|
|
26
|
+
Requires-Dist: click>=8.1
|
|
27
|
+
Requires-Dist: textual>=0.79.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == "dev"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# langchain-agentx-cli
|
|
34
|
+
|
|
35
|
+
**AgentX Code** — Terminal AI coding assistant with Claude Code compatible TUI.
|
|
36
|
+
|
|
37
|
+
依托 [langchain-agentx-python](https://github.com/GoodMood2008/langchain_agentx_python) SDK,提供功能完整的终端编码助手。
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install langchain-agentx-cli
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Requires Python 3.11+ and `ANTHROPIC_API_KEY` environment variable.
|
|
46
|
+
|
|
47
|
+
## Quick Start
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Navigate to your project directory
|
|
51
|
+
cd ~/my-project
|
|
52
|
+
|
|
53
|
+
# Start AgentX Code
|
|
54
|
+
agentx-code
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Environment Setup
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Set your Anthropic API key
|
|
61
|
+
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Command Options
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
agentx-code # Start in current directory
|
|
68
|
+
agentx-code --workspace-root /path/to/project # Specify workspace
|
|
69
|
+
agentx-code --model claude-sonnet-4-20250514 # Specify model
|
|
70
|
+
agentx-code --provider claude | openai # Choose provider
|
|
71
|
+
agentx-code -p # Skip permission prompts
|
|
72
|
+
agentx-code --show-config # Print merged config
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Input Habits (Claude Code Compatible)
|
|
76
|
+
|
|
77
|
+
| Key | Action |
|
|
78
|
+
|-----|--------|
|
|
79
|
+
| **Enter** | Send message |
|
|
80
|
+
| **Shift+Enter** | Insert newline |
|
|
81
|
+
| **\\ + Enter** | Insert newline (alternative) |
|
|
82
|
+
| **↑ / ↓** | Navigate history / move in multiline |
|
|
83
|
+
| **Tab** | Command completion |
|
|
84
|
+
| **Ctrl+R** | History search |
|
|
85
|
+
| **Ctrl+Shift+L** | Clear messages |
|
|
86
|
+
| **Ctrl+C** | Cancel generation / Quit (twice) |
|
|
87
|
+
|
|
88
|
+
Type `/help` in the REPL for full command list.
|
|
89
|
+
|
|
90
|
+
## Development
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Clone and install in editable mode
|
|
94
|
+
git clone https://github.com/GoodMood2008/langchain-agentx-cli.git
|
|
95
|
+
cd langchain-agentx-cli
|
|
96
|
+
pip install -e ".[dev]"
|
|
97
|
+
|
|
98
|
+
# Run tests
|
|
99
|
+
pytest tests -v
|
|
100
|
+
|
|
101
|
+
# Run directly (without install)
|
|
102
|
+
python -m langchain_agentx_cli
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Configuration
|
|
106
|
+
|
|
107
|
+
Config file location: `~/.config/langchain_agentx/langchain_agentx.json`
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"llm": {
|
|
112
|
+
"provider": "claude",
|
|
113
|
+
"model": "claude-sonnet-4-20250514",
|
|
114
|
+
"api_key": null,
|
|
115
|
+
"base_url": null
|
|
116
|
+
},
|
|
117
|
+
"theme": "dark",
|
|
118
|
+
"show_suppressed_text": false,
|
|
119
|
+
"user_message_preview_lines": 30
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Architecture
|
|
124
|
+
|
|
125
|
+
工程约定与开发说明见根目录 **`CLAUDE.md`**。
|
|
126
|
+
|
|
127
|
+
| Layer | Name | Description |
|
|
128
|
+
|-------|------|-------------|
|
|
129
|
+
| PyPI Package | `langchain-agentx-cli` | `pip install langchain-agentx-cli` |
|
|
130
|
+
| CLI Command | `agentx-code` | User types in terminal |
|
|
131
|
+
| Python Package | `langchain_agentx_cli` | `import` for use as library |
|
|
132
|
+
|
|
133
|
+
## Design Docs
|
|
134
|
+
|
|
135
|
+
- [D01: user_message Dual Output Fix](docs/design-docs/tools/D01-user-message-dual-output.html)
|
|
136
|
+
- [Implementation Plans](docs/exec-plan/tools/)
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
Apache License 2.0
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# langchain-agentx-cli
|
|
2
|
+
|
|
3
|
+
**AgentX Code** — Terminal AI coding assistant with Claude Code compatible TUI.
|
|
4
|
+
|
|
5
|
+
依托 [langchain-agentx-python](https://github.com/GoodMood2008/langchain_agentx_python) SDK,提供功能完整的终端编码助手。
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install langchain-agentx-cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Requires Python 3.11+ and `ANTHROPIC_API_KEY` environment variable.
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Navigate to your project directory
|
|
19
|
+
cd ~/my-project
|
|
20
|
+
|
|
21
|
+
# Start AgentX Code
|
|
22
|
+
agentx-code
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Environment Setup
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Set your Anthropic API key
|
|
29
|
+
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Command Options
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
agentx-code # Start in current directory
|
|
36
|
+
agentx-code --workspace-root /path/to/project # Specify workspace
|
|
37
|
+
agentx-code --model claude-sonnet-4-20250514 # Specify model
|
|
38
|
+
agentx-code --provider claude | openai # Choose provider
|
|
39
|
+
agentx-code -p # Skip permission prompts
|
|
40
|
+
agentx-code --show-config # Print merged config
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Input Habits (Claude Code Compatible)
|
|
44
|
+
|
|
45
|
+
| Key | Action |
|
|
46
|
+
|-----|--------|
|
|
47
|
+
| **Enter** | Send message |
|
|
48
|
+
| **Shift+Enter** | Insert newline |
|
|
49
|
+
| **\\ + Enter** | Insert newline (alternative) |
|
|
50
|
+
| **↑ / ↓** | Navigate history / move in multiline |
|
|
51
|
+
| **Tab** | Command completion |
|
|
52
|
+
| **Ctrl+R** | History search |
|
|
53
|
+
| **Ctrl+Shift+L** | Clear messages |
|
|
54
|
+
| **Ctrl+C** | Cancel generation / Quit (twice) |
|
|
55
|
+
|
|
56
|
+
Type `/help` in the REPL for full command list.
|
|
57
|
+
|
|
58
|
+
## Development
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Clone and install in editable mode
|
|
62
|
+
git clone https://github.com/GoodMood2008/langchain-agentx-cli.git
|
|
63
|
+
cd langchain-agentx-cli
|
|
64
|
+
pip install -e ".[dev]"
|
|
65
|
+
|
|
66
|
+
# Run tests
|
|
67
|
+
pytest tests -v
|
|
68
|
+
|
|
69
|
+
# Run directly (without install)
|
|
70
|
+
python -m langchain_agentx_cli
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Configuration
|
|
74
|
+
|
|
75
|
+
Config file location: `~/.config/langchain_agentx/langchain_agentx.json`
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"llm": {
|
|
80
|
+
"provider": "claude",
|
|
81
|
+
"model": "claude-sonnet-4-20250514",
|
|
82
|
+
"api_key": null,
|
|
83
|
+
"base_url": null
|
|
84
|
+
},
|
|
85
|
+
"theme": "dark",
|
|
86
|
+
"show_suppressed_text": false,
|
|
87
|
+
"user_message_preview_lines": 30
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Architecture
|
|
92
|
+
|
|
93
|
+
工程约定与开发说明见根目录 **`CLAUDE.md`**。
|
|
94
|
+
|
|
95
|
+
| Layer | Name | Description |
|
|
96
|
+
|-------|------|-------------|
|
|
97
|
+
| PyPI Package | `langchain-agentx-cli` | `pip install langchain-agentx-cli` |
|
|
98
|
+
| CLI Command | `agentx-code` | User types in terminal |
|
|
99
|
+
| Python Package | `langchain_agentx_cli` | `import` for use as library |
|
|
100
|
+
|
|
101
|
+
## Design Docs
|
|
102
|
+
|
|
103
|
+
- [D01: user_message Dual Output Fix](docs/design-docs/tools/D01-user-message-dual-output.html)
|
|
104
|
+
- [Implementation Plans](docs/exec-plan/tools/)
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
Apache License 2.0
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"""
|
|
2
|
+
app.py — Textual ReplApp 容器。
|
|
3
|
+
|
|
4
|
+
职责:
|
|
5
|
+
应用生命周期、SessionBridge、命令注册表、历史、双次 Ctrl+C 退出。
|
|
6
|
+
|
|
7
|
+
链路位置:
|
|
8
|
+
CliEntry._run_tui() 实例化并 run();session 关闭由 CliEntry finally 负责。
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from typing import TYPE_CHECKING
|
|
14
|
+
|
|
15
|
+
from textual import on
|
|
16
|
+
from textual.app import App
|
|
17
|
+
from textual.binding import Binding
|
|
18
|
+
|
|
19
|
+
from langchain_agentx_cli.bridge.session_bridge import SessionBridge
|
|
20
|
+
from langchain_agentx_cli.commands.builtin import register_builtin_commands
|
|
21
|
+
from langchain_agentx_cli.commands.providers import register_sdk_commands
|
|
22
|
+
from langchain_agentx_cli.commands.registry import CommandRegistry
|
|
23
|
+
from langchain_agentx_cli.config import (
|
|
24
|
+
AppPreferencesStore,
|
|
25
|
+
AppUserPreferences,
|
|
26
|
+
ReplLaunchConfig,
|
|
27
|
+
)
|
|
28
|
+
from langchain_agentx_cli.theme import ThemeManager
|
|
29
|
+
from langchain_agentx_cli.history.store import HistoryStore
|
|
30
|
+
from langchain_agentx_cli.screens import ReplScreen
|
|
31
|
+
from langchain_agentx_cli.tui.message_selection import try_copy_message_selection
|
|
32
|
+
from langchain_agentx_cli.tui.safe_screen import ReplScreenMessenger
|
|
33
|
+
from langchain_agentx_cli.widgets.permission_inline import InlinePermissionWidget
|
|
34
|
+
from langchain_agentx_cli.widgets.messages import UserMessage
|
|
35
|
+
|
|
36
|
+
if TYPE_CHECKING:
|
|
37
|
+
from langchain_agentx import AgentSession
|
|
38
|
+
|
|
39
|
+
_CANCEL_HINT = "已取消当前生成。再次按 Ctrl+C 退出。"
|
|
40
|
+
_EXIT_HINT = "再次按 Ctrl+C 退出。"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class ReplApp(App[None]):
|
|
44
|
+
"""AgentX 终端 REPL 应用(Textual)。"""
|
|
45
|
+
|
|
46
|
+
TITLE = "langchain-agentx-cli"
|
|
47
|
+
BINDINGS = [
|
|
48
|
+
("q", "quit", "Quit"),
|
|
49
|
+
("ctrl+c", "cancel_stream", "Cancel / Quit"),
|
|
50
|
+
Binding("ctrl+l", "clear_screen", "Clear", show=False, priority=True),
|
|
51
|
+
Binding(
|
|
52
|
+
"ctrl+shift+l",
|
|
53
|
+
"clear_screen",
|
|
54
|
+
"Clear (Win 备用)",
|
|
55
|
+
show=False,
|
|
56
|
+
priority=True,
|
|
57
|
+
),
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
def __init__(
|
|
61
|
+
self,
|
|
62
|
+
launch_config: ReplLaunchConfig,
|
|
63
|
+
session: AgentSession | None = None,
|
|
64
|
+
) -> None:
|
|
65
|
+
super().__init__()
|
|
66
|
+
self._launch_config = launch_config
|
|
67
|
+
self._session = session
|
|
68
|
+
self._bridge: SessionBridge | None = None
|
|
69
|
+
self._exit_armed = False
|
|
70
|
+
self.command_registry = CommandRegistry()
|
|
71
|
+
register_builtin_commands(self.command_registry)
|
|
72
|
+
self.history_store = HistoryStore()
|
|
73
|
+
self.theme_manager: ThemeManager | None = None
|
|
74
|
+
self._screen_messenger = ReplScreenMessenger(self)
|
|
75
|
+
# Phase 3: 加载用户偏好(供 MessageListWidget 和工具 Widget 使用)
|
|
76
|
+
self.preferences: AppUserPreferences = AppPreferencesStore().load()
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def screen_messenger(self) -> ReplScreenMessenger:
|
|
80
|
+
return self._screen_messenger
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def workspace_root(self):
|
|
84
|
+
return self._launch_config.workspace_root
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def launch_config(self) -> ReplLaunchConfig:
|
|
88
|
+
return self._launch_config
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def bridge(self) -> SessionBridge | None:
|
|
92
|
+
return self._bridge
|
|
93
|
+
|
|
94
|
+
def on_mount(self) -> None:
|
|
95
|
+
prefs = AppPreferencesStore().load()
|
|
96
|
+
initial_setting = self._launch_config.theme or prefs.theme
|
|
97
|
+
self.theme_manager = ThemeManager(self)
|
|
98
|
+
self.theme_manager.setup(initial=initial_setting)
|
|
99
|
+
if self._session is not None:
|
|
100
|
+
self._bridge = SessionBridge(self, self._session)
|
|
101
|
+
register_sdk_commands(self.command_registry, self._session)
|
|
102
|
+
self._bridge.permission_consumer.start()
|
|
103
|
+
self.push_screen(ReplScreen())
|
|
104
|
+
|
|
105
|
+
def on_unmount(self) -> None:
|
|
106
|
+
if self.theme_manager is not None:
|
|
107
|
+
self.theme_manager.stop_auto_watch()
|
|
108
|
+
if self._bridge is not None:
|
|
109
|
+
self._bridge.permission_consumer.stop()
|
|
110
|
+
self._bridge.cancel_stream()
|
|
111
|
+
|
|
112
|
+
def clear_messages(self) -> None:
|
|
113
|
+
screen = self.screen
|
|
114
|
+
if isinstance(screen, ReplScreen):
|
|
115
|
+
screen.clear_messages()
|
|
116
|
+
|
|
117
|
+
def action_clear_screen(self) -> None:
|
|
118
|
+
self.clear_messages()
|
|
119
|
+
self.notify("消息已清空", severity="information", timeout=2)
|
|
120
|
+
|
|
121
|
+
@on(UserMessage)
|
|
122
|
+
def _on_user_message_reset_exit_arm(self, _event: UserMessage) -> None:
|
|
123
|
+
self._exit_armed = False
|
|
124
|
+
|
|
125
|
+
def action_cancel_stream(self) -> None:
|
|
126
|
+
if try_copy_message_selection(self) is not None:
|
|
127
|
+
return
|
|
128
|
+
# Dismiss inline permission widget if active
|
|
129
|
+
try:
|
|
130
|
+
widget = self.screen.query_one(InlinePermissionWidget)
|
|
131
|
+
widget.dismiss_externally()
|
|
132
|
+
return
|
|
133
|
+
except Exception:
|
|
134
|
+
pass
|
|
135
|
+
if self._bridge is not None and self._bridge.is_streaming():
|
|
136
|
+
self._bridge.cancel_stream()
|
|
137
|
+
self._exit_armed = True
|
|
138
|
+
self.notify(_CANCEL_HINT, severity="warning", timeout=4)
|
|
139
|
+
return
|
|
140
|
+
if self._exit_armed:
|
|
141
|
+
self.action_quit()
|
|
142
|
+
return
|
|
143
|
+
self._exit_armed = True
|
|
144
|
+
self.notify(_EXIT_HINT, severity="information", timeout=4)
|
|
145
|
+
|
|
146
|
+
def action_quit(self) -> None:
|
|
147
|
+
if self._bridge is not None:
|
|
148
|
+
self._bridge.cancel_stream()
|
|
149
|
+
self.exit(0)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""
|
|
2
|
+
bootstrap.py — CLI 启动前环境检查。
|
|
3
|
+
|
|
4
|
+
职责:
|
|
5
|
+
校验 SDK 可导入、workspace_root 为有效目录。
|
|
6
|
+
|
|
7
|
+
链路位置:
|
|
8
|
+
CliEntry.run() 在创建 ReplApp 之前调用。
|
|
9
|
+
|
|
10
|
+
当前裁剪范围:
|
|
11
|
+
不校验 API Key;AgentSession 创建失败由 session_factory 抛出 CliEnvironmentError。
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import sys
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class CliEnvironmentError(Exception):
|
|
21
|
+
"""启动前环境不满足,应打印 stderr 并以非零码退出。"""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class EnvironmentChecker:
|
|
25
|
+
"""CLI 启动环境检查(OOP 协作者)。"""
|
|
26
|
+
|
|
27
|
+
def check_sdk_importable(self) -> None:
|
|
28
|
+
try:
|
|
29
|
+
import langchain_agentx # noqa: F401
|
|
30
|
+
except ImportError as exc:
|
|
31
|
+
raise CliEnvironmentError(
|
|
32
|
+
"无法导入 langchain_agentx。请安装 SDK:\n"
|
|
33
|
+
' pip install "langchain-agentx-python>=0.2.3"\n'
|
|
34
|
+
"或 editable:pip install -e <langchain_agentx_python 路径>"
|
|
35
|
+
) from exc
|
|
36
|
+
|
|
37
|
+
def check_workspace_root(self, workspace_root: Path) -> None:
|
|
38
|
+
if not workspace_root.exists():
|
|
39
|
+
raise CliEnvironmentError(
|
|
40
|
+
f"workspace_root 不存在: {workspace_root}"
|
|
41
|
+
)
|
|
42
|
+
if not workspace_root.is_dir():
|
|
43
|
+
raise CliEnvironmentError(
|
|
44
|
+
f"workspace_root 不是目录: {workspace_root}"
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
@staticmethod
|
|
48
|
+
def emit_error(message: str) -> None:
|
|
49
|
+
print(message, file=sys.stderr)
|