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.
- minimalcode/__init__.py +3 -0
- minimalcode/__main__.py +3 -0
- minimalcode/agent.py +1084 -0
- minimalcode/cli.py +1520 -0
- minimalcode/clipboard.py +212 -0
- minimalcode/config.py +1065 -0
- minimalcode/defaults.json +491 -0
- minimalcode/errors.py +31 -0
- minimalcode/highlight/__init__.py +47 -0
- minimalcode/highlight/code.py +261 -0
- minimalcode/highlight/color.py +58 -0
- minimalcode/highlight/markdown.py +710 -0
- minimalcode/highlight/palette.py +73 -0
- minimalcode/highlight/sanitize.py +175 -0
- minimalcode/highlight/thinking.py +71 -0
- minimalcode/httpclient.py +278 -0
- minimalcode/importer.py +253 -0
- minimalcode/prompt.py +195 -0
- minimalcode/provider/__init__.py +28 -0
- minimalcode/provider/anthropic.py +805 -0
- minimalcode/provider/anthropic_env.py +161 -0
- minimalcode/provider/chat.py +394 -0
- minimalcode/provider/client.py +243 -0
- minimalcode/provider/common.py +176 -0
- minimalcode/provider/deepseek_web.py +1158 -0
- minimalcode/provider/factory.py +63 -0
- minimalcode/provider/responses.py +692 -0
- minimalcode/provider/sha3_wasm_bg.wasm +0 -0
- minimalcode/provider/transport.py +241 -0
- minimalcode/provider/types.py +54 -0
- minimalcode/sandbox/__init__.py +64 -0
- minimalcode/sandbox/audit.py +120 -0
- minimalcode/sandbox/backends.py +343 -0
- minimalcode/sandbox/execution.py +435 -0
- minimalcode/sandbox/network.py +793 -0
- minimalcode/sandbox/policy.py +253 -0
- minimalcode/sandbox/runner.py +347 -0
- minimalcode/sandbox/sensitive.py +286 -0
- minimalcode/session.py +465 -0
- minimalcode/shell.py +333 -0
- minimalcode/subagent.py +120 -0
- minimalcode/tools/__init__.py +46 -0
- minimalcode/tools/files.py +1139 -0
- minimalcode/tools/process.py +164 -0
- minimalcode/tools/remote.py +74 -0
- minimalcode/tools/runtime.py +219 -0
- minimalcode/tools/schemas.py +418 -0
- minimalcode/tools/search.py +521 -0
- minimalcode/tools/search_tools.py +583 -0
- minimalcode/tools/validation.py +99 -0
- minimalcode/vision.py +231 -0
- minimalcode/web.py +238 -0
- minimalcode-1.5.2.dist-info/METADATA +646 -0
- minimalcode-1.5.2.dist-info/RECORD +58 -0
- minimalcode-1.5.2.dist-info/WHEEL +5 -0
- minimalcode-1.5.2.dist-info/entry_points.txt +2 -0
- minimalcode-1.5.2.dist-info/licenses/LICENSE +201 -0
- 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
|