one-agent 0.1.46__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.
Files changed (68) hide show
  1. one/__init__.py +22 -0
  2. one/__main__.py +6 -0
  3. one/cli/__init__.py +0 -0
  4. one/cli/args.py +313 -0
  5. one/cli/main.py +557 -0
  6. one/config.py +119 -0
  7. one/core/__init__.py +18 -0
  8. one/core/agent_session.py +3573 -0
  9. one/core/agent_session_runtime.py +226 -0
  10. one/core/attachments.py +610 -0
  11. one/core/auth_storage.py +195 -0
  12. one/core/clipboard_image.py +268 -0
  13. one/core/event_bus.py +25 -0
  14. one/core/model_registry.py +459 -0
  15. one/core/oauth.py +414 -0
  16. one/core/persistence.py +169 -0
  17. one/core/provider_login.py +254 -0
  18. one/core/sdk.py +96 -0
  19. one/core/session_manager.py +710 -0
  20. one/core/settings_manager.py +483 -0
  21. one/core/tool_output_pruning.py +78 -0
  22. one/core/types.py +43 -0
  23. one/extensions/__init__.py +0 -0
  24. one/extensions/runtime.py +21 -0
  25. one/mcp/__init__.py +3 -0
  26. one/mcp/client.py +676 -0
  27. one/modes/__init__.py +7 -0
  28. one/modes/interactive_mode.py +1381 -0
  29. one/modes/jsonl.py +28 -0
  30. one/modes/print_mode.py +39 -0
  31. one/modes/rpc_mode.py +505 -0
  32. one/modes/rpc_types.py +9 -0
  33. one/modes/run_mode.py +174 -0
  34. one/modes/tui_mode.py +3639 -0
  35. one/providers/__init__.py +3 -0
  36. one/providers/anthropic.py +330 -0
  37. one/providers/base.py +56 -0
  38. one/providers/codex_responses.py +455 -0
  39. one/providers/gemini.py +259 -0
  40. one/providers/ollama.py +143 -0
  41. one/providers/openai_compatible.py +376 -0
  42. one/providers/registry.py +59 -0
  43. one/py.typed +0 -0
  44. one/resources/__init__.py +3 -0
  45. one/resources/extension_runtime.py +351 -0
  46. one/resources/resource_loader.py +630 -0
  47. one/tools/__init__.py +3 -0
  48. one/tools/apply_patch.py +958 -0
  49. one/tools/ask_user.py +7 -0
  50. one/tools/bash.py +154 -0
  51. one/tools/common.py +134 -0
  52. one/tools/edit.py +99 -0
  53. one/tools/find.py +11 -0
  54. one/tools/finish.py +18 -0
  55. one/tools/grep.py +24 -0
  56. one/tools/index.py +65 -0
  57. one/tools/ls.py +16 -0
  58. one/tools/plan.py +16 -0
  59. one/tools/read.py +47 -0
  60. one/tools/read_image.py +87 -0
  61. one/tools/spawn_subagent.py +7 -0
  62. one/tools/write.py +13 -0
  63. one_agent-0.1.46.dist-info/METADATA +510 -0
  64. one_agent-0.1.46.dist-info/RECORD +68 -0
  65. one_agent-0.1.46.dist-info/WHEEL +5 -0
  66. one_agent-0.1.46.dist-info/entry_points.txt +2 -0
  67. one_agent-0.1.46.dist-info/licenses/LICENSE +21 -0
  68. one_agent-0.1.46.dist-info/top_level.txt +1 -0
one/__init__.py ADDED
@@ -0,0 +1,22 @@
1
+ from .config import APP_NAME, VERSION, get_agent_dir
2
+ from .core.agent_session import AgentSession
3
+ from .core.agent_session_runtime import AgentSessionRuntimeHost, create_agent_session_runtime
4
+ from .core.auth_storage import AuthStorage
5
+ from .core.model_registry import ModelRegistry
6
+ from .core.sdk import create_agent_session
7
+ from .core.session_manager import SessionManager
8
+ from .core.settings_manager import SettingsManager
9
+
10
+ __all__ = [
11
+ "APP_NAME",
12
+ "VERSION",
13
+ "get_agent_dir",
14
+ "AgentSession",
15
+ "AgentSessionRuntimeHost",
16
+ "create_agent_session_runtime",
17
+ "AuthStorage",
18
+ "ModelRegistry",
19
+ "create_agent_session",
20
+ "SessionManager",
21
+ "SettingsManager",
22
+ ]
one/__main__.py ADDED
@@ -0,0 +1,6 @@
1
+ from __future__ import annotations
2
+
3
+ from one.cli.main import run
4
+
5
+ if __name__ == "__main__":
6
+ run()
one/cli/__init__.py ADDED
File without changes
one/cli/args.py ADDED
@@ -0,0 +1,313 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ from dataclasses import dataclass, field
5
+
6
+ from one.config import APP_NAME
7
+
8
+ VALID_THINKING_LEVELS = {"off", "minimal", "low", "medium", "high", "xhigh"}
9
+ VALID_MODES = {"text", "json", "rpc", "tui"}
10
+
11
+
12
+ @dataclass
13
+ class ParsedArgs:
14
+ command: str | None = None
15
+ command_args: list[str] = field(default_factory=list)
16
+ provider: str | None = None
17
+ model: str | None = None
18
+ api_key: str | None = None
19
+ llama_cpp_url: str | None = None
20
+ ollama_url: str | None = None
21
+ system_prompt: str | None = None
22
+ append_system_prompt: str | None = None
23
+ thinking: str | None = None
24
+ continue_session: bool = False
25
+ resume: bool = False
26
+ help: bool = False
27
+ version: bool = False
28
+ mode: str | None = None
29
+ no_session: bool = False
30
+ session: str | None = None
31
+ fork: str | None = None
32
+ session_dir: str | None = None
33
+ models: list[str] | None = None
34
+ tools: list[str] | None = None
35
+ no_tools: bool = False
36
+ extensions: list[str] = field(default_factory=list)
37
+ no_extensions: bool = False
38
+ print_mode: bool = False
39
+ export: str | None = None
40
+ export_format: str = "html"
41
+ no_skills: bool = False
42
+ no_mcp: bool = False
43
+ skills: list[str] = field(default_factory=list)
44
+ prompt_templates: list[str] = field(default_factory=list)
45
+ no_prompt_templates: bool = False
46
+ themes: list[str] = field(default_factory=list)
47
+ no_themes: bool = False
48
+ list_models: str | bool | None = None
49
+ offline: bool = False
50
+ verbose: bool = False
51
+ cooperation: bool = False
52
+ no_subagents: bool = False
53
+ no_bash_output: bool = False
54
+ run_task: str | None = None
55
+ json_output: bool = False
56
+ answer_file: str | None = None
57
+ steer_file: str | None = None
58
+ params: list[str] = field(default_factory=list)
59
+ messages: list[str] = field(default_factory=list)
60
+ file_args: list[str] = field(default_factory=list)
61
+ image_paths: list[str] = field(default_factory=list)
62
+ errors: list[str] = field(default_factory=list)
63
+
64
+
65
+ def parse_args(argv: list[str]) -> ParsedArgs:
66
+ command = None
67
+ command_args: list[str] = []
68
+ run_task: str | None = None
69
+ if argv and not argv[0].startswith("-") and argv[0] in {"install", "remove", "update", "list", "config", "run"}:
70
+ command = argv[0]
71
+ command_args = argv[1:]
72
+ if command == "run":
73
+ # Flags may appear before/after the task text; re-inject them so
74
+ # argparse sees them, keep the rest as the task. Every value-taking
75
+ # flag keeps its value next to it (mirrors the add_argument calls
76
+ # below); boolean flags are re-injected alone. A value is paired
77
+ # only when the next token exists and does not look like a flag
78
+ # (this mirrors argparse's nargs="?" behaviour for --list-models).
79
+ _VALUE_FLAGS = {
80
+ "--provider", "--model", "--api-key", "--llama-cpp-url", "--ollama-url",
81
+ "--system-prompt", "--append-system-prompt", "--thinking", "--mode",
82
+ "--session", "--session-dir", "--models", "--tools", "--export",
83
+ "--export-format", "--theme", "--prompt-template", "--skill",
84
+ "--extension", "-e", "--list-models", "--answer-file", "--steer-file",
85
+ "--param", "-P", "--image",
86
+ }
87
+ flags: list[str] = []
88
+ rest: list[str] = []
89
+ i = 0
90
+ while i < len(command_args):
91
+ a = command_args[i]
92
+ if a in _VALUE_FLAGS and i + 1 < len(command_args) and not command_args[i + 1].startswith("-"):
93
+ flags.append(a)
94
+ flags.append(command_args[i + 1])
95
+ i += 2
96
+ continue
97
+ if a.startswith("-"):
98
+ flags.append(a)
99
+ else:
100
+ rest.append(a)
101
+ i += 1
102
+ argv = flags
103
+ run_task = " ".join(rest)
104
+ elif command is not None:
105
+ # Non-run subcommand (install/remove/update/list/config): pass through.
106
+ argv = command_args
107
+ else:
108
+ # No subcommand — use argv as-is (--print, --mode, etc.).
109
+ pass
110
+
111
+
112
+ parser = argparse.ArgumentParser(prog=APP_NAME, add_help=False)
113
+ parser.add_argument("messages", nargs="*")
114
+ parser.add_argument("--help", "-h", action="store_true")
115
+ parser.add_argument("--version", "-v", action="store_true")
116
+ parser.add_argument("--provider")
117
+ parser.add_argument("--model")
118
+ parser.add_argument("--api-key")
119
+ parser.add_argument("--llama-cpp-url")
120
+ parser.add_argument("--ollama-url")
121
+ parser.add_argument("--system-prompt")
122
+ parser.add_argument("--append-system-prompt")
123
+ parser.add_argument("--thinking")
124
+ parser.add_argument("--continue", "-c", dest="continue_session", action="store_true")
125
+ parser.add_argument("--resume", "-r", action="store_true")
126
+ parser.add_argument("--mode")
127
+ parser.add_argument("--no-session", action="store_true")
128
+ parser.add_argument("--session")
129
+ parser.add_argument("--fork")
130
+ parser.add_argument("--session-dir")
131
+ parser.add_argument("--models")
132
+ parser.add_argument("--tools")
133
+ parser.add_argument("--no-tools", action="store_true")
134
+ parser.add_argument("--extension", "-e", action="append", default=[])
135
+ parser.add_argument("--no-extensions", "-ne", action="store_true")
136
+ parser.add_argument("--print", "-p", action="store_true", dest="print_mode")
137
+ parser.add_argument("--export")
138
+ parser.add_argument("--export-format", choices=["html", "jsonl"], default="html")
139
+ parser.add_argument("--skill", action="append", default=[])
140
+ parser.add_argument("--no-skills", "-ns", action="store_true")
141
+ parser.add_argument("--no-mcp", action="store_true", dest="no_mcp", help="Do not start MCP servers from settings.json.")
142
+ parser.add_argument("--prompt-template", action="append", default=[])
143
+ parser.add_argument("--no-prompt-templates", "-np", action="store_true")
144
+ parser.add_argument("--theme", action="append", default=[])
145
+ parser.add_argument("--no-themes", action="store_true")
146
+ parser.add_argument("--list-models", nargs="?", const=True)
147
+ parser.add_argument("--offline", action="store_true")
148
+ parser.add_argument("--verbose", action="store_true")
149
+ parser.add_argument(
150
+ "--cooperation",
151
+ action="store_true",
152
+ help="Cooperation mode: ask the user before running mutating tools (bash/write/edit/plan/apply_patch); "
153
+ "rejections require a reason that is fed back to the model.",
154
+ )
155
+ parser.add_argument("--no-subagents", action="store_true", help="Disable subagents: the spawn_subagent tool is not registered.")
156
+ parser.add_argument("--no-bash-output", action="store_true", help="Do not print bash command output; show only the exit code.")
157
+ parser.add_argument("--json", action="store_true", dest="json_output", help="Print the run result as JSON (summary, goalSuccess, finished).")
158
+ parser.add_argument("--answer-file", dest="answer_file", help="Headless answer channel for ask_user: questions are written to this file and answers are read back (polled).")
159
+ parser.add_argument("--steer-file", dest="steer_file", help="Headless steering channel: write a message to this file while the run is active; it is read and cleared.")
160
+ parser.add_argument("--image", dest="image_paths", action="append", default=[], help="Image file path for vision input (repeatable); equivalent to the read_image tool.")
161
+ parser.add_argument("--param", "-P", action="append", default=[], help="Template parameter name=value (repeatable); {{name}} in @file content is replaced.")
162
+
163
+ ns = parser.parse_args(argv)
164
+ messages: list[str] = ns.messages or []
165
+ file_args: list[str] = []
166
+ plain: list[str] = []
167
+ for m in messages:
168
+ if m.startswith("@"):
169
+ file_args.append(m[1:])
170
+ else:
171
+ plain.append(m)
172
+
173
+ errors: list[str] = []
174
+ thinking = ns.thinking
175
+ if thinking and thinking not in VALID_THINKING_LEVELS:
176
+ errors.append(f"Invalid --thinking value: {thinking}. Allowed: {', '.join(sorted(VALID_THINKING_LEVELS))}")
177
+
178
+ mode = ns.mode
179
+ if mode and mode not in VALID_MODES:
180
+ errors.append(f"Invalid --mode value: {mode}. Allowed: {', '.join(sorted(VALID_MODES))}")
181
+
182
+ if ns.print_mode and mode == "rpc":
183
+ errors.append("--print cannot be combined with --mode rpc")
184
+
185
+ if ns.no_session and (ns.session or ns.continue_session or ns.resume or ns.fork):
186
+ errors.append("--no-session cannot be combined with --session/--continue/--resume/--fork")
187
+
188
+ if ns.session and ns.continue_session:
189
+ errors.append("--session cannot be combined with --continue")
190
+ if ns.session and ns.resume:
191
+ errors.append("--session cannot be combined with --resume")
192
+ if ns.continue_session and ns.resume:
193
+ errors.append("--continue cannot be combined with --resume")
194
+
195
+ if ns.fork and (ns.session or ns.continue_session or ns.resume):
196
+ errors.append("--fork cannot be combined with --session/--continue/--resume")
197
+
198
+ if command == "run" and not run_task and not ns.resume:
199
+ errors.append("Usage: one run <task>")
200
+
201
+ return ParsedArgs(
202
+ command=command,
203
+ command_args=command_args,
204
+ provider=ns.provider,
205
+ model=ns.model,
206
+ api_key=ns.api_key,
207
+ llama_cpp_url=ns.llama_cpp_url,
208
+ ollama_url=ns.ollama_url,
209
+ system_prompt=ns.system_prompt,
210
+ append_system_prompt=ns.append_system_prompt,
211
+ thinking=thinking,
212
+ continue_session=ns.continue_session,
213
+ resume=ns.resume,
214
+ help=ns.help,
215
+ version=ns.version,
216
+ mode=mode,
217
+ no_session=ns.no_session,
218
+ session=ns.session,
219
+ fork=ns.fork,
220
+ session_dir=ns.session_dir,
221
+ models=[x.strip() for x in ns.models.split(",")] if ns.models else None,
222
+ tools=[x.strip() for x in ns.tools.split(",")] if ns.tools else None,
223
+ no_tools=ns.no_tools,
224
+ extensions=list(ns.extension),
225
+ no_extensions=ns.no_extensions,
226
+ print_mode=ns.print_mode,
227
+ export=ns.export,
228
+ export_format=ns.export_format,
229
+ no_skills=ns.no_skills,
230
+ no_mcp=ns.no_mcp,
231
+ skills=list(ns.skill),
232
+ prompt_templates=list(ns.prompt_template),
233
+ no_prompt_templates=ns.no_prompt_templates,
234
+ themes=list(ns.theme),
235
+ no_themes=ns.no_themes,
236
+ list_models=ns.list_models,
237
+ offline=ns.offline,
238
+ verbose=ns.verbose,
239
+ cooperation=ns.cooperation,
240
+ no_subagents=ns.no_subagents,
241
+ no_bash_output=ns.no_bash_output,
242
+ run_task=run_task,
243
+ json_output=ns.json_output,
244
+ answer_file=ns.answer_file,
245
+ steer_file=ns.steer_file,
246
+ params=list(ns.param),
247
+ messages=plain,
248
+ file_args=file_args,
249
+ errors=errors,
250
+ image_paths=ns.image_paths or [],
251
+ )
252
+
253
+
254
+ def print_help() -> None:
255
+ print(
256
+ f"""{APP_NAME} - AI coding assistant with read, bash, edit, write tools
257
+
258
+ Usage:
259
+ {APP_NAME} [options] [@files...] [messages...]
260
+
261
+ Options:
262
+ --provider <name>
263
+ --model <pattern>
264
+ --api-key <key>
265
+ --llama-cpp-url <url>
266
+ --ollama-url <url>
267
+ --system-prompt <text>
268
+ --append-system-prompt <text>
269
+ --mode <text|json|rpc|tui>
270
+ --print, -p
271
+ --continue, -c
272
+ --resume, -r
273
+ --session <path>
274
+ --fork <path-or-id>
275
+ --session-dir <dir>
276
+ --no-session
277
+ --models <patterns>
278
+ --tools <read,read_image,bash,edit,write,grep,find,ls,finish,plan,spawn_subagent,ask_user,apply_patch>
279
+ --no-tools
280
+ --extension, -e <path>
281
+ --no-extensions
282
+ --no-mcp
283
+ --skill <path>
284
+ --no-skills
285
+ --prompt-template <path>
286
+ --no-prompt-templates
287
+ --theme <path>
288
+ --no-themes
289
+ --export <file>
290
+ --export-format <html|jsonl>
291
+ --list-models [search]
292
+ --offline
293
+ --verbose
294
+ --cooperation
295
+ --no-subagents
296
+ --no-bash-output
297
+ --json
298
+ --answer-file <file>
299
+ --steer-file <file>
300
+ --param <name=value>
301
+ --image <path>
302
+ --help, -h
303
+ --version, -v
304
+
305
+ Commands:
306
+ install <package>
307
+ remove <package>
308
+ update [package]
309
+ list
310
+ config [key] [value]
311
+ run <task>
312
+ """
313
+ )