minimalcode 1.5.2__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 (58) hide show
  1. minimalcode/__init__.py +3 -0
  2. minimalcode/__main__.py +3 -0
  3. minimalcode/agent.py +1084 -0
  4. minimalcode/cli.py +1520 -0
  5. minimalcode/clipboard.py +212 -0
  6. minimalcode/config.py +1065 -0
  7. minimalcode/defaults.json +491 -0
  8. minimalcode/errors.py +31 -0
  9. minimalcode/highlight/__init__.py +47 -0
  10. minimalcode/highlight/code.py +261 -0
  11. minimalcode/highlight/color.py +58 -0
  12. minimalcode/highlight/markdown.py +710 -0
  13. minimalcode/highlight/palette.py +73 -0
  14. minimalcode/highlight/sanitize.py +175 -0
  15. minimalcode/highlight/thinking.py +71 -0
  16. minimalcode/httpclient.py +278 -0
  17. minimalcode/importer.py +253 -0
  18. minimalcode/prompt.py +195 -0
  19. minimalcode/provider/__init__.py +28 -0
  20. minimalcode/provider/anthropic.py +805 -0
  21. minimalcode/provider/anthropic_env.py +161 -0
  22. minimalcode/provider/chat.py +394 -0
  23. minimalcode/provider/client.py +243 -0
  24. minimalcode/provider/common.py +176 -0
  25. minimalcode/provider/deepseek_web.py +1158 -0
  26. minimalcode/provider/factory.py +63 -0
  27. minimalcode/provider/responses.py +692 -0
  28. minimalcode/provider/sha3_wasm_bg.wasm +0 -0
  29. minimalcode/provider/transport.py +241 -0
  30. minimalcode/provider/types.py +54 -0
  31. minimalcode/sandbox/__init__.py +64 -0
  32. minimalcode/sandbox/audit.py +120 -0
  33. minimalcode/sandbox/backends.py +343 -0
  34. minimalcode/sandbox/execution.py +435 -0
  35. minimalcode/sandbox/network.py +793 -0
  36. minimalcode/sandbox/policy.py +253 -0
  37. minimalcode/sandbox/runner.py +347 -0
  38. minimalcode/sandbox/sensitive.py +286 -0
  39. minimalcode/session.py +465 -0
  40. minimalcode/shell.py +333 -0
  41. minimalcode/subagent.py +120 -0
  42. minimalcode/tools/__init__.py +46 -0
  43. minimalcode/tools/files.py +1139 -0
  44. minimalcode/tools/process.py +164 -0
  45. minimalcode/tools/remote.py +74 -0
  46. minimalcode/tools/runtime.py +219 -0
  47. minimalcode/tools/schemas.py +418 -0
  48. minimalcode/tools/search.py +521 -0
  49. minimalcode/tools/search_tools.py +583 -0
  50. minimalcode/tools/validation.py +99 -0
  51. minimalcode/vision.py +231 -0
  52. minimalcode/web.py +238 -0
  53. minimalcode-1.5.2.dist-info/METADATA +646 -0
  54. minimalcode-1.5.2.dist-info/RECORD +58 -0
  55. minimalcode-1.5.2.dist-info/WHEEL +5 -0
  56. minimalcode-1.5.2.dist-info/entry_points.txt +2 -0
  57. minimalcode-1.5.2.dist-info/licenses/LICENSE +201 -0
  58. minimalcode-1.5.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,491 @@
1
+ {
2
+ "provider": "deepseek",
3
+ "model": "deepseek-flash",
4
+ "thinking": "high",
5
+ "max_turns": 1000,
6
+ "session": {
7
+ "save": true
8
+ },
9
+ "shell": {
10
+ "path": null,
11
+ "timeout_seconds": 120,
12
+ "max_output_chars": 60000
13
+ },
14
+ "tools": {
15
+ "allow": null,
16
+ "allow_outside_workspace": false,
17
+ "max_file_chars": 160000,
18
+ "max_file_bytes": 5000000,
19
+ "max_results": 200,
20
+ "max_parallel": 4
21
+ },
22
+ "sandbox": {
23
+ "enabled": false,
24
+ "backend": "local",
25
+ "allowed_roots": [],
26
+ "network_policy": "deny",
27
+ "allowed_hosts": [],
28
+ "timeout_seconds": 120,
29
+ "max_output_chars": 60000,
30
+ "allow_sensitive_files": false,
31
+ "max_memory_mb": 0,
32
+ "max_processes": 0,
33
+ "docker_image": "alpine:3"
34
+ },
35
+ "subagent": {
36
+ "enabled": true,
37
+ "max_depth": 2,
38
+ "max_turns": 40,
39
+ "max_parallel": 4,
40
+ "timeout_seconds": 900
41
+ },
42
+ "context": {
43
+ "compact_at": 0.8,
44
+ "keep_messages": 12,
45
+ "max_instruction_chars": 60000
46
+ },
47
+ "output": {
48
+ "markdown_highlight": true,
49
+ "theme": "dark"
50
+ },
51
+ "providers": {
52
+ "deepseek": {
53
+ "protocol": "openai_responses",
54
+ "base_url": "https://api.deepseek.com/v1",
55
+ "api_key_env": "DEEPSEEK_API_KEY",
56
+ "context_window": 1000000,
57
+ "timeout_seconds": 120,
58
+ "stream": true,
59
+ "include_usage": false,
60
+ "send_reasoning_effort": true,
61
+ "headers": {},
62
+ "extra_body": {},
63
+ "web_tools": {
64
+ "enabled": true,
65
+ "base_url": "https://api.deepseek.com/v1/tools",
66
+ "search_path": "search",
67
+ "fetch_path": "fetch",
68
+ "timeout_seconds": 60,
69
+ "default_count": 10,
70
+ "max_count": 50,
71
+ "max_content_chars": 120000,
72
+ "headers": {}
73
+ },
74
+ "vision": {
75
+ "enabled": true,
76
+ "base_url": "https://api.deepseek.com/v1",
77
+ "model": "deepseek-flash",
78
+ "timeout_seconds": 120,
79
+ "max_image_bytes": 33554432,
80
+ "max_chars": 8000,
81
+ "detail": "auto",
82
+ "headers": {}
83
+ }
84
+ },
85
+ "deepseek-anthropic": {
86
+ "protocol": "anthropic_messages",
87
+ "base_url": "https://api.deepseek.com/anthropic",
88
+ "api_key_env": "DEEPSEEK_API_KEY",
89
+ "model": "deepseek-flash",
90
+ "context_window": 1000000,
91
+ "timeout_seconds": 120,
92
+ "stream": true,
93
+ "send_reasoning_effort": true,
94
+ "max_tokens": 8192,
95
+ "headers": {},
96
+ "extra_body": {}
97
+ },
98
+ "deepseek-web": {
99
+ "protocol": "deepseek_web",
100
+ "base_url": "https://chat.deepseek.com",
101
+ "api_key_env": "DEEPSEEK_WEB_TOKEN",
102
+ "model": "default",
103
+ "cookie_env": "DEEPSEEK_WEB_COOKIE",
104
+ "context_window": 262000,
105
+ "timeout_seconds": 300,
106
+ "stream": true,
107
+ "tool_mode": "text",
108
+ "model_type": "default",
109
+ "web_search": false,
110
+ "headers": {
111
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
112
+ "Origin": "https://chat.deepseek.com",
113
+ "Referer": "https://chat.deepseek.com/"
114
+ },
115
+ "extra_body": {}
116
+ },
117
+ "openai": {
118
+ "protocol": "openai_responses",
119
+ "base_url": "https://api.openai.com/v1",
120
+ "api_key_env": "OPENAI_API_KEY",
121
+ "context_window": 128000,
122
+ "timeout_seconds": 120,
123
+ "stream": true,
124
+ "headers": {},
125
+ "extra_body": {}
126
+ },
127
+ "anthropic": {
128
+ "protocol": "anthropic_messages",
129
+ "base_url": "https://api.anthropic.com/v1",
130
+ "api_key_env": "ANTHROPIC_API_KEY",
131
+ "context_window": 200000,
132
+ "timeout_seconds": 120,
133
+ "stream": true,
134
+ "max_tokens": 8192,
135
+ "headers": {},
136
+ "extra_body": {}
137
+ },
138
+ "google": {
139
+ "protocol": "openai_chat",
140
+ "base_url": "https://generativelanguage.googleapis.com/v1beta/openai",
141
+ "api_key_env": "GEMINI_API_KEY",
142
+ "context_window": 1000000,
143
+ "timeout_seconds": 120,
144
+ "stream": true,
145
+ "include_usage": false,
146
+ "headers": {},
147
+ "extra_body": {}
148
+ },
149
+ "openrouter": {
150
+ "protocol": "openai_chat",
151
+ "base_url": "https://openrouter.ai/api/v1",
152
+ "api_key_env": "OPENROUTER_API_KEY",
153
+ "context_window": 128000,
154
+ "timeout_seconds": 120,
155
+ "stream": true,
156
+ "include_usage": false,
157
+ "headers": {},
158
+ "extra_body": {}
159
+ },
160
+ "groq": {
161
+ "protocol": "openai_chat",
162
+ "base_url": "https://api.groq.com/openai/v1",
163
+ "api_key_env": "GROQ_API_KEY",
164
+ "context_window": 128000,
165
+ "timeout_seconds": 120,
166
+ "stream": true,
167
+ "include_usage": false,
168
+ "headers": {},
169
+ "extra_body": {}
170
+ },
171
+ "mistral": {
172
+ "protocol": "openai_chat",
173
+ "base_url": "https://api.mistral.ai/v1",
174
+ "api_key_env": "MISTRAL_API_KEY",
175
+ "context_window": 128000,
176
+ "timeout_seconds": 120,
177
+ "stream": true,
178
+ "include_usage": false,
179
+ "headers": {},
180
+ "extra_body": {}
181
+ },
182
+ "xai": {
183
+ "protocol": "openai_chat",
184
+ "base_url": "https://api.x.ai/v1",
185
+ "api_key_env": "XAI_API_KEY",
186
+ "context_window": 256000,
187
+ "timeout_seconds": 120,
188
+ "stream": true,
189
+ "include_usage": false,
190
+ "headers": {},
191
+ "extra_body": {}
192
+ },
193
+ "moonshot": {
194
+ "protocol": "openai_chat",
195
+ "base_url": "https://api.moonshot.cn/v1",
196
+ "api_key_env": "MOONSHOT_API_KEY",
197
+ "context_window": 256000,
198
+ "timeout_seconds": 120,
199
+ "stream": true,
200
+ "include_usage": false,
201
+ "headers": {},
202
+ "extra_body": {}
203
+ },
204
+ "zhipu": {
205
+ "protocol": "openai_chat",
206
+ "base_url": "https://open.bigmodel.cn/api/paas/v4",
207
+ "api_key_env": "ZHIPUAI_API_KEY",
208
+ "context_window": 128000,
209
+ "timeout_seconds": 120,
210
+ "stream": true,
211
+ "include_usage": false,
212
+ "headers": {},
213
+ "extra_body": {}
214
+ },
215
+ "dashscope": {
216
+ "protocol": "openai_chat",
217
+ "base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
218
+ "api_key_env": "DASHSCOPE_API_KEY",
219
+ "context_window": 128000,
220
+ "timeout_seconds": 120,
221
+ "stream": true,
222
+ "include_usage": false,
223
+ "headers": {},
224
+ "extra_body": {}
225
+ },
226
+ "siliconflow": {
227
+ "protocol": "openai_chat",
228
+ "base_url": "https://api.siliconflow.cn/v1",
229
+ "api_key_env": "SILICONFLOW_API_KEY",
230
+ "context_window": 128000,
231
+ "timeout_seconds": 120,
232
+ "stream": true,
233
+ "include_usage": false,
234
+ "headers": {},
235
+ "extra_body": {}
236
+ },
237
+ "together": {
238
+ "protocol": "openai_chat",
239
+ "base_url": "https://api.together.ai/v1",
240
+ "api_key_env": "TOGETHER_API_KEY",
241
+ "context_window": 128000,
242
+ "timeout_seconds": 120,
243
+ "stream": true,
244
+ "include_usage": false,
245
+ "headers": {},
246
+ "extra_body": {}
247
+ },
248
+ "fireworks": {
249
+ "protocol": "openai_chat",
250
+ "base_url": "https://api.fireworks.ai/inference/v1",
251
+ "api_key_env": "FIREWORKS_API_KEY",
252
+ "context_window": 128000,
253
+ "timeout_seconds": 120,
254
+ "stream": true,
255
+ "include_usage": false,
256
+ "headers": {},
257
+ "extra_body": {}
258
+ },
259
+ "perplexity": {
260
+ "protocol": "openai_chat",
261
+ "base_url": "https://api.perplexity.ai",
262
+ "api_key_env": "PERPLEXITY_API_KEY",
263
+ "context_window": 128000,
264
+ "timeout_seconds": 120,
265
+ "stream": true,
266
+ "include_usage": false,
267
+ "headers": {},
268
+ "extra_body": {}
269
+ },
270
+ "cerebras": {
271
+ "protocol": "openai_chat",
272
+ "base_url": "https://api.cerebras.ai/v1",
273
+ "api_key_env": "CEREBRAS_API_KEY",
274
+ "context_window": 128000,
275
+ "timeout_seconds": 120,
276
+ "stream": true,
277
+ "include_usage": false,
278
+ "headers": {},
279
+ "extra_body": {}
280
+ },
281
+ "sambanova": {
282
+ "protocol": "openai_chat",
283
+ "base_url": "https://api.sambanova.ai/v1",
284
+ "api_key_env": "SAMBANOVA_API_KEY",
285
+ "context_window": 128000,
286
+ "timeout_seconds": 120,
287
+ "stream": true,
288
+ "include_usage": false,
289
+ "headers": {},
290
+ "extra_body": {}
291
+ },
292
+ "nebius": {
293
+ "protocol": "openai_chat",
294
+ "base_url": "https://api.studio.nebius.com/v1",
295
+ "api_key_env": "NEBIUS_API_KEY",
296
+ "context_window": 128000,
297
+ "timeout_seconds": 120,
298
+ "stream": true,
299
+ "include_usage": false,
300
+ "headers": {},
301
+ "extra_body": {}
302
+ },
303
+ "deepinfra": {
304
+ "protocol": "openai_chat",
305
+ "base_url": "https://api.deepinfra.com/v1/openai",
306
+ "api_key_env": "DEEPINFRA_TOKEN",
307
+ "context_window": 128000,
308
+ "timeout_seconds": 120,
309
+ "stream": true,
310
+ "include_usage": false,
311
+ "headers": {},
312
+ "extra_body": {}
313
+ },
314
+ "novita": {
315
+ "protocol": "openai_chat",
316
+ "base_url": "https://api.novita.ai/openai/v1",
317
+ "api_key_env": "NOVITA_API_KEY",
318
+ "context_window": 128000,
319
+ "timeout_seconds": 120,
320
+ "stream": true,
321
+ "include_usage": false,
322
+ "headers": {},
323
+ "extra_body": {}
324
+ },
325
+ "cohere": {
326
+ "protocol": "openai_chat",
327
+ "base_url": "https://api.cohere.ai/compatibility/v1",
328
+ "api_key_env": "COHERE_API_KEY",
329
+ "context_window": 128000,
330
+ "timeout_seconds": 120,
331
+ "stream": true,
332
+ "include_usage": false,
333
+ "headers": {},
334
+ "extra_body": {}
335
+ },
336
+ "github": {
337
+ "protocol": "openai_chat",
338
+ "base_url": "https://models.github.ai/inference",
339
+ "api_key_env": "GITHUB_TOKEN",
340
+ "context_window": 128000,
341
+ "timeout_seconds": 120,
342
+ "stream": true,
343
+ "include_usage": false,
344
+ "headers": {},
345
+ "extra_body": {}
346
+ },
347
+ "volcengine": {
348
+ "protocol": "openai_chat",
349
+ "base_url": "https://ark.cn-beijing.volces.com/api/v3",
350
+ "api_key_env": "ARK_API_KEY",
351
+ "context_window": 128000,
352
+ "timeout_seconds": 120,
353
+ "stream": true,
354
+ "include_usage": false,
355
+ "headers": {},
356
+ "extra_body": {}
357
+ },
358
+ "minimax": {
359
+ "protocol": "openai_chat",
360
+ "base_url": "https://api.minimax.io/v1",
361
+ "api_key_env": "MINIMAX_API_KEY",
362
+ "context_window": 1000000,
363
+ "timeout_seconds": 120,
364
+ "stream": true,
365
+ "include_usage": false,
366
+ "headers": {},
367
+ "extra_body": {}
368
+ },
369
+ "hunyuan": {
370
+ "protocol": "openai_chat",
371
+ "base_url": "https://api.hunyuan.cloud.tencent.com/v1",
372
+ "api_key_env": "HUNYUAN_API_KEY",
373
+ "context_window": 128000,
374
+ "timeout_seconds": 120,
375
+ "stream": true,
376
+ "include_usage": false,
377
+ "headers": {},
378
+ "extra_body": {}
379
+ },
380
+ "qianfan": {
381
+ "protocol": "openai_chat",
382
+ "base_url": "https://qianfan.baidubce.com/v2",
383
+ "api_key_env": "QIANFAN_API_KEY",
384
+ "context_window": 128000,
385
+ "timeout_seconds": 120,
386
+ "stream": true,
387
+ "include_usage": false,
388
+ "headers": {},
389
+ "extra_body": {}
390
+ },
391
+ "modelscope": {
392
+ "protocol": "openai_chat",
393
+ "base_url": "https://api-inference.modelscope.cn/v1",
394
+ "api_key_env": "MODELSCOPE_API_KEY",
395
+ "context_window": 128000,
396
+ "timeout_seconds": 120,
397
+ "stream": true,
398
+ "include_usage": false,
399
+ "headers": {},
400
+ "extra_body": {}
401
+ },
402
+ "baichuan": {
403
+ "protocol": "openai_chat",
404
+ "base_url": "https://api.baichuan-ai.com/v1",
405
+ "api_key_env": "BAICHUAN_API_KEY",
406
+ "context_window": 128000,
407
+ "timeout_seconds": 120,
408
+ "stream": true,
409
+ "include_usage": false,
410
+ "headers": {},
411
+ "extra_body": {}
412
+ },
413
+ "yi": {
414
+ "protocol": "openai_chat",
415
+ "base_url": "https://api.lingyiwanwu.com/v1",
416
+ "api_key_env": "YI_API_KEY",
417
+ "context_window": 128000,
418
+ "timeout_seconds": 120,
419
+ "stream": true,
420
+ "include_usage": false,
421
+ "headers": {},
422
+ "extra_body": {}
423
+ },
424
+ "stepfun": {
425
+ "protocol": "openai_chat",
426
+ "base_url": "https://api.stepfun.com/v1",
427
+ "api_key_env": "STEP_API_KEY",
428
+ "context_window": 128000,
429
+ "timeout_seconds": 120,
430
+ "stream": true,
431
+ "include_usage": false,
432
+ "headers": {},
433
+ "extra_body": {}
434
+ },
435
+ "spark": {
436
+ "protocol": "openai_chat",
437
+ "base_url": "https://spark-api-open.xf-yun.com/v1",
438
+ "api_key_env": "SPARK_API_PASSWORD",
439
+ "context_window": 128000,
440
+ "timeout_seconds": 120,
441
+ "stream": true,
442
+ "include_usage": false,
443
+ "headers": {},
444
+ "extra_body": {}
445
+ },
446
+ "ppio": {
447
+ "protocol": "openai_chat",
448
+ "base_url": "https://api.ppio.com/openai/v1",
449
+ "api_key_env": "PPIO_API_KEY",
450
+ "context_window": 128000,
451
+ "timeout_seconds": 120,
452
+ "stream": true,
453
+ "include_usage": false,
454
+ "headers": {},
455
+ "extra_body": {}
456
+ },
457
+ "ollama": {
458
+ "protocol": "openai_chat",
459
+ "base_url": "http://localhost:11434/v1",
460
+ "require_api_key": false,
461
+ "context_window": 32768,
462
+ "timeout_seconds": 120,
463
+ "stream": true,
464
+ "include_usage": false,
465
+ "headers": {},
466
+ "extra_body": {}
467
+ },
468
+ "lmstudio": {
469
+ "protocol": "openai_chat",
470
+ "base_url": "http://localhost:1234/v1",
471
+ "require_api_key": false,
472
+ "context_window": 32768,
473
+ "timeout_seconds": 120,
474
+ "stream": true,
475
+ "include_usage": false,
476
+ "headers": {},
477
+ "extra_body": {}
478
+ },
479
+ "vllm": {
480
+ "protocol": "openai_chat",
481
+ "base_url": "http://localhost:8000/v1",
482
+ "require_api_key": false,
483
+ "context_window": 32768,
484
+ "timeout_seconds": 120,
485
+ "stream": true,
486
+ "include_usage": false,
487
+ "headers": {},
488
+ "extra_body": {}
489
+ }
490
+ }
491
+ }
minimalcode/errors.py ADDED
@@ -0,0 +1,31 @@
1
+ class MinimalCodeError(RuntimeError):
2
+ """Base exception for expected MinimalCode failures."""
3
+
4
+
5
+ class ConfigError(MinimalCodeError):
6
+ """Raised when MinimalCode configuration is invalid."""
7
+
8
+
9
+ class ShellError(MinimalCodeError):
10
+ """Raised when no supported shell can be started."""
11
+
12
+
13
+ class ProviderError(MinimalCodeError):
14
+ def __init__(
15
+ self,
16
+ message: str,
17
+ *,
18
+ status_code: int | None = None,
19
+ body: str | None = None,
20
+ ):
21
+ super().__init__(message)
22
+ self.status_code = status_code
23
+ self.body = body
24
+
25
+
26
+ class ToolError(MinimalCodeError):
27
+ """Raised for invalid or unsafe tool input."""
28
+
29
+
30
+ class ClipboardError(MinimalCodeError):
31
+ """Raised when an image cannot be read from the system clipboard."""
@@ -0,0 +1,47 @@
1
+ """Streamed Markdown rendering and terminal color helpers.
2
+
3
+ The renderer turns assistant deltas into styled terminal output as they arrive,
4
+ so text appears while the model is still producing it, and it strips terminal
5
+ control sequences from untrusted text before that text reaches a real terminal.
6
+ ``__all__`` is the complete public surface: the renderer, the sanitizer and its
7
+ one-shot wrapper, the palette constants, and the helpers that color an activity
8
+ tag or remove SGR codes. Deciding what to print, drawing progress indicators, and
9
+ reading theme settings belong to ``cli``/``agent``, and the parser covers the
10
+ Markdown this project emits rather than all of CommonMark. Invariants: every byte
11
+ of untrusted input passes through ``TerminalSanitizer`` first, and with color
12
+ disabled the renderer writes the original Markdown unchanged so redirected and
13
+ JSON output stay parseable; the private helpers that lived on the pre-0.7 single
14
+ ``highlight`` module are imported from the submodule that defines them.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import re
20
+ from typing import TextIO
21
+
22
+ from . import color
23
+ from .markdown import MarkdownHighlighter
24
+ from .palette import ACTIVITY_TAG, RESET, strip_ansi
25
+ from .sanitize import TerminalSanitizer, sanitize_terminal_text
26
+ from .thinking import ThinkingRenderer
27
+
28
+ __all__ = [
29
+ "ACTIVITY_TAG",
30
+ "RESET",
31
+ "MarkdownHighlighter",
32
+ "TerminalSanitizer",
33
+ "ThinkingRenderer",
34
+ "sanitize_terminal_text",
35
+ "strip_ansi",
36
+ "style_activity_tag",
37
+ ]
38
+
39
+
40
+ def style_activity_tag(text: str, stream: TextIO) -> str:
41
+ """Color a leading ``[tool]`` activity tag when the stream supports ANSI."""
42
+ text = sanitize_terminal_text(text)
43
+ match = re.match(r"^(\[[^\]\n]+\])", text)
44
+ if match is None or not color._supports_color(stream):
45
+ return text
46
+ tag = match.group(1)
47
+ return f"{ACTIVITY_TAG}{tag}{RESET}{text[len(tag) :]}"