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,63 @@
1
+ """Provider construction from merged settings."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+
7
+ import httpx2
8
+
9
+ from ..config import Settings
10
+ from .client import OpenAICompatibleProvider
11
+
12
+ _CONTEXT_SUFFIX = re.compile(r"^(?P<model>.+?)\[(?P<size>\d+)(?P<unit>[kKmM])\]$")
13
+
14
+
15
+ def _strip_context_suffix(
16
+ model: str, config: dict[str, object]
17
+ ) -> tuple[str, int | None]:
18
+ """Strip Claude Code's ``[1m]`` suffix and return the window it selects."""
19
+ if config.get("protocol") != "anthropic_messages":
20
+ return model, None
21
+ match = _CONTEXT_SUFFIX.match(model)
22
+ if match is None:
23
+ return model, None
24
+ multiplier = 1_000 if match.group("unit").lower() == "k" else 1_000_000
25
+ window = max(1, int(match.group("size")) * multiplier)
26
+ return match.group("model"), window
27
+
28
+
29
+ def create_provider(
30
+ settings: Settings,
31
+ *,
32
+ provider_name: str | None = None,
33
+ model: str | None = None,
34
+ thinking: str | None = None,
35
+ transport: httpx2.BaseTransport | None = None,
36
+ ) -> tuple[OpenAICompatibleProvider, str, str]:
37
+ """Resolve provider/model/effort and return a ready client.
38
+
39
+ An explicit argument wins over the provider default, which wins over the
40
+ global model setting.
41
+ """
42
+ name, config = settings.provider_config(provider_name)
43
+ provider_default_model = config.get("model")
44
+ effective_model = (
45
+ model
46
+ or (str(provider_default_model) if provider_default_model else None)
47
+ or settings.effective_model()
48
+ )
49
+ effective_thinking = thinking or str(settings.get("thinking", "high"))
50
+ effective_model, suffix_window = _strip_context_suffix(effective_model, config)
51
+ if suffix_window is not None:
52
+ # The suffix is a client-side window selector; it must never reach the
53
+ # wire, and it overrides a context_window that was configured without
54
+ # knowing which model suffix the user asked for.
55
+ config["context_window"] = suffix_window
56
+ provider = OpenAICompatibleProvider(
57
+ name=name,
58
+ config=config,
59
+ model=effective_model,
60
+ thinking=effective_thinking,
61
+ transport=transport,
62
+ )
63
+ return provider, name, effective_model