omnihub 0.1.0__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.
- omnihub/__init__.py +3 -0
- omnihub/adapters/__init__.py +21 -0
- omnihub/adapters/base.py +141 -0
- omnihub/adapters/builtin.py +120 -0
- omnihub/adapters/cli.py +74 -0
- omnihub/adapters/daemon.py +1084 -0
- omnihub/adapters/http.py +36 -0
- omnihub/adapters/opencli.py +111 -0
- omnihub/adapters/registry.py +29 -0
- omnihub/cli.py +1069 -0
- omnihub/core/__init__.py +1 -0
- omnihub/core/clock.py +61 -0
- omnihub/core/config.py +140 -0
- omnihub/core/context.py +521 -0
- omnihub/core/doctor.py +251 -0
- omnihub/core/enrich.py +165 -0
- omnihub/core/normalize.py +114 -0
- omnihub/core/pipeline.py +739 -0
- omnihub/core/plugins.py +124 -0
- omnihub/core/policy.py +156 -0
- omnihub/core/ratelimit.py +401 -0
- omnihub/core/registry.py +604 -0
- omnihub/core/result.py +180 -0
- omnihub/core/router.py +234 -0
- omnihub/core/schema/envelope.schema.json +70 -0
- omnihub/core/schema/platform.schema.json +200 -0
- omnihub/core/schema/routing.schema.json +44 -0
- omnihub/core/schema/tool.schema.json +34 -0
- omnihub/core/scripts.py +114 -0
- omnihub/core/skill.py +143 -0
- omnihub/core/template.py +98 -0
- omnihub/parse/__init__.py +5 -0
- omnihub/parse/daemon.py +35 -0
- omnihub/parse/generic.py +266 -0
- omnihub/parse/web.py +217 -0
- omnihub/platforms/bilibili/SKILL.md +81 -0
- omnihub/platforms/bilibili/fixtures/api_nav.json +12 -0
- omnihub/platforms/bilibili/fixtures/api_search.json +74 -0
- omnihub/platforms/bilibili/fixtures/search.json +12 -0
- omnihub/platforms/bilibili/platform.yaml +88 -0
- omnihub/platforms/bilibili/scripts/parse.py +306 -0
- omnihub/platforms/bilibili/scripts/read.js +121 -0
- omnihub/platforms/bilibili/scripts/search.py +237 -0
- omnihub/platforms/deepwiki/SKILL.md +62 -0
- omnihub/platforms/deepwiki/fixtures/read.json +12 -0
- omnihub/platforms/deepwiki/platform.yaml +33 -0
- omnihub/platforms/deepwiki/scripts/read.py +139 -0
- omnihub/platforms/github/SKILL.md +75 -0
- omnihub/platforms/github/fixtures/issue.json +11 -0
- omnihub/platforms/github/fixtures/issue_comments.json +7 -0
- omnihub/platforms/github/fixtures/readme.md +18 -0
- omnihub/platforms/github/fixtures/repository.json +15 -0
- omnihub/platforms/github/fixtures/search.json +34 -0
- omnihub/platforms/github/platform.yaml +92 -0
- omnihub/platforms/github/scripts/parse.py +73 -0
- omnihub/platforms/github/scripts/read.py +191 -0
- omnihub/platforms/linkedin/SKILL.md +70 -0
- omnihub/platforms/linkedin/platform.yaml +86 -0
- omnihub/platforms/linkedin/scripts/read.js +53 -0
- omnihub/platforms/linkedin/scripts/search.js +58 -0
- omnihub/platforms/noop/SKILL.md +66 -0
- omnihub/platforms/noop/platform.yaml +43 -0
- omnihub/platforms/noop/scripts/read.py +18 -0
- omnihub/platforms/noop/scripts/search.py +20 -0
- omnihub/platforms/notebooklm/SKILL.md +75 -0
- omnihub/platforms/notebooklm/fixtures/read.json +9 -0
- omnihub/platforms/notebooklm/fixtures/search.json +26 -0
- omnihub/platforms/notebooklm/platform.yaml +58 -0
- omnihub/platforms/notebooklm/scripts/read.py +67 -0
- omnihub/platforms/notebooklm/scripts/search.py +86 -0
- omnihub/platforms/reddit/SKILL.md +70 -0
- omnihub/platforms/reddit/fixtures/read.json +12 -0
- omnihub/platforms/reddit/fixtures/search.json +12 -0
- omnihub/platforms/reddit/platform.yaml +118 -0
- omnihub/platforms/reddit/scripts/search.js +46 -0
- omnihub/platforms/twitter/SKILL.md +70 -0
- omnihub/platforms/twitter/platform.yaml +104 -0
- omnihub/platforms/twitter/scripts/read.js +21 -0
- omnihub/platforms/twitter/scripts/search.js +32 -0
- omnihub/platforms/v2ex/SKILL.md +70 -0
- omnihub/platforms/v2ex/fixtures/replies.json +16 -0
- omnihub/platforms/v2ex/fixtures/search.json +34 -0
- omnihub/platforms/v2ex/fixtures/topic.json +23 -0
- omnihub/platforms/v2ex/platform.yaml +83 -0
- omnihub/platforms/v2ex/scripts/parse.py +83 -0
- omnihub/platforms/v2ex/scripts/read.py +109 -0
- omnihub/platforms/web/SKILL.md +70 -0
- omnihub/platforms/web/platform.yaml +100 -0
- omnihub/platforms/wechat/SKILL.md +71 -0
- omnihub/platforms/wechat/platform.yaml +111 -0
- omnihub/platforms/wechat/scripts/read.js +82 -0
- omnihub/platforms/wechat/scripts/search.js +31 -0
- omnihub/platforms/xiaohongshu/SKILL.md +83 -0
- omnihub/platforms/xiaohongshu/platform.yaml +82 -0
- omnihub/platforms/xiaohongshu/references/xiaohongshu-cli.md +80 -0
- omnihub/platforms/xiaohongshu/scripts/read.js +22 -0
- omnihub/platforms/xiaohongshu/scripts/search.js +37 -0
- omnihub/platforms/xiaohongshu/scripts/xiaohongshu_cli.py +877 -0
- omnihub/platforms/xiaoyuzhou/SKILL.md +84 -0
- omnihub/platforms/xiaoyuzhou/platform.yaml +138 -0
- omnihub/platforms/xiaoyuzhou/scripts/transcribe.py +196 -0
- omnihub/platforms/xueqiu/SKILL.md +69 -0
- omnihub/platforms/xueqiu/platform.yaml +76 -0
- omnihub/platforms/xueqiu/scripts/read.js +24 -0
- omnihub/platforms/xueqiu/scripts/search.js +32 -0
- omnihub/platforms/youtube/SKILL.md +69 -0
- omnihub/platforms/youtube/fixtures/read.json +12 -0
- omnihub/platforms/youtube/fixtures/search.json +12 -0
- omnihub/platforms/youtube/platform.yaml +97 -0
- omnihub/transcribe.py +662 -0
- omnihub/utils/__init__.py +1 -0
- omnihub/utils/process.py +18 -0
- omnihub/utils/text.py +27 -0
- omnihub/utils/url.py +121 -0
- omnihub-0.1.0.dist-info/METADATA +381 -0
- omnihub-0.1.0.dist-info/RECORD +119 -0
- omnihub-0.1.0.dist-info/WHEEL +4 -0
- omnihub-0.1.0.dist-info/entry_points.txt +3 -0
- omnihub-0.1.0.dist-info/licenses/LICENSE +23 -0
omnihub/__init__.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Shared tool adapters used by platform manifests."""
|
|
2
|
+
|
|
3
|
+
from omnihub.adapters.base import (
|
|
4
|
+
ADAPTER_KINDS,
|
|
5
|
+
Adapter,
|
|
6
|
+
AdapterError,
|
|
7
|
+
Context,
|
|
8
|
+
Health,
|
|
9
|
+
RawResult,
|
|
10
|
+
ToolCall,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"ADAPTER_KINDS",
|
|
15
|
+
"Adapter",
|
|
16
|
+
"AdapterError",
|
|
17
|
+
"Context",
|
|
18
|
+
"Health",
|
|
19
|
+
"RawResult",
|
|
20
|
+
"ToolCall",
|
|
21
|
+
]
|
omnihub/adapters/base.py
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"""Contracts shared by every tool adapter.
|
|
2
|
+
|
|
3
|
+
Platform manifests never spawn processes or touch the network directly. They
|
|
4
|
+
name an adapter (``http``, ``cli``, ``opencli``, ``daemon``, ``mcp``, ...) plus
|
|
5
|
+
the call to make; the adapter owns transport, timeouts, output limits and
|
|
6
|
+
error mapping. Keeping that boundary narrow is what makes a platform
|
|
7
|
+
deletable without touching shared code.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from dataclasses import dataclass, field
|
|
13
|
+
from typing import Any, Mapping, Optional, Protocol, Sequence, runtime_checkable
|
|
14
|
+
|
|
15
|
+
#: Adapter kinds a manifest may reference. ``builtin`` is for platforms that
|
|
16
|
+
#: ship their own Python implementation and need no external tool.
|
|
17
|
+
ADAPTER_KINDS = frozenset(
|
|
18
|
+
{"builtin", "http", "cli", "opencli", "daemon", "mcp", "browser"}
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class AdapterError(Exception):
|
|
23
|
+
"""A transport/tool failure carrying a unified OmniHub error code."""
|
|
24
|
+
|
|
25
|
+
def __init__(
|
|
26
|
+
self,
|
|
27
|
+
code: str,
|
|
28
|
+
message: str,
|
|
29
|
+
*,
|
|
30
|
+
retryable: bool = False,
|
|
31
|
+
details: Optional[Mapping[str, Any]] = None,
|
|
32
|
+
) -> None:
|
|
33
|
+
super().__init__(message)
|
|
34
|
+
self.code = code
|
|
35
|
+
self.message = message
|
|
36
|
+
self.retryable = retryable
|
|
37
|
+
self.details = dict(details or {})
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass(frozen=True)
|
|
41
|
+
class Health:
|
|
42
|
+
"""Result of probing a tool or daemon before an action."""
|
|
43
|
+
|
|
44
|
+
ok: bool
|
|
45
|
+
version: Optional[str] = None
|
|
46
|
+
detail: str = ""
|
|
47
|
+
logged_in: Optional[bool] = None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass(frozen=True)
|
|
51
|
+
class ToolCall:
|
|
52
|
+
"""One resolved call from a platform manifest source."""
|
|
53
|
+
|
|
54
|
+
adapter: str
|
|
55
|
+
call: Optional[str] = None
|
|
56
|
+
action: Optional[str] = None
|
|
57
|
+
tool: Optional[str] = None
|
|
58
|
+
#: Absolute path to a script bundled by the platform. The adapter reads
|
|
59
|
+
#: it; script text is never templated or sent as a resolved argument.
|
|
60
|
+
script: Optional[str] = None
|
|
61
|
+
args: Mapping[str, Any] = field(default_factory=dict)
|
|
62
|
+
params: Mapping[str, Any] = field(default_factory=dict)
|
|
63
|
+
argv: Optional[tuple[str, ...]] = None
|
|
64
|
+
method: str = "GET"
|
|
65
|
+
headers: Mapping[str, str] = field(default_factory=dict)
|
|
66
|
+
body: Optional[Mapping[str, Any]] = None
|
|
67
|
+
data: Optional[Any] = None
|
|
68
|
+
output: str = "json"
|
|
69
|
+
url: Optional[str] = None
|
|
70
|
+
site: Optional[str] = None
|
|
71
|
+
session: Optional[str] = None
|
|
72
|
+
parse: tuple[str, ...] = ()
|
|
73
|
+
timeout: Optional[float] = None
|
|
74
|
+
max_bytes: Optional[int] = None
|
|
75
|
+
raw: Mapping[str, Any] = field(default_factory=dict)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@dataclass
|
|
79
|
+
class RawResult:
|
|
80
|
+
"""Unparsed adapter output. ``data`` is set for structured transports."""
|
|
81
|
+
|
|
82
|
+
ok: bool = True
|
|
83
|
+
data: Any = None
|
|
84
|
+
text: Optional[str] = None
|
|
85
|
+
content_type: str = "application/json"
|
|
86
|
+
meta: dict[str, Any] = field(default_factory=dict)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
@dataclass
|
|
90
|
+
class ProcessResult:
|
|
91
|
+
stdout: str
|
|
92
|
+
stderr: str
|
|
93
|
+
returncode: int
|
|
94
|
+
truncated: bool = False
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@runtime_checkable
|
|
98
|
+
class Context(Protocol):
|
|
99
|
+
"""Everything an adapter is allowed to use for one action."""
|
|
100
|
+
|
|
101
|
+
timeout: float
|
|
102
|
+
|
|
103
|
+
def run(
|
|
104
|
+
self,
|
|
105
|
+
argv: Sequence[str],
|
|
106
|
+
*,
|
|
107
|
+
timeout: Optional[float] = None,
|
|
108
|
+
env: Optional[Mapping[str, str]] = None,
|
|
109
|
+
input_data: Optional[str] = None,
|
|
110
|
+
cwd: Optional[str] = None,
|
|
111
|
+
max_bytes: Optional[int] = None,
|
|
112
|
+
) -> ProcessResult:
|
|
113
|
+
...
|
|
114
|
+
|
|
115
|
+
def http(
|
|
116
|
+
self,
|
|
117
|
+
url: str,
|
|
118
|
+
*,
|
|
119
|
+
method: str = "GET",
|
|
120
|
+
headers: Optional[Mapping[str, str]] = None,
|
|
121
|
+
data: Any = None,
|
|
122
|
+
timeout: Optional[float] = None,
|
|
123
|
+
max_bytes: Optional[int] = None,
|
|
124
|
+
) -> RawResult:
|
|
125
|
+
...
|
|
126
|
+
|
|
127
|
+
def secret(self, name: str) -> Optional[str]:
|
|
128
|
+
...
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
@runtime_checkable
|
|
132
|
+
class Adapter(Protocol):
|
|
133
|
+
"""Transport implementation. Adapters are stateless between actions."""
|
|
134
|
+
|
|
135
|
+
kind: str
|
|
136
|
+
|
|
137
|
+
def probe(self) -> Health:
|
|
138
|
+
...
|
|
139
|
+
|
|
140
|
+
def invoke(self, call: ToolCall, *, ctx: Context) -> RawResult:
|
|
141
|
+
...
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""Built-in Python hooks shipped inside a platform directory.
|
|
2
|
+
|
|
3
|
+
Declarative manifests should cover most platforms. When a platform genuinely
|
|
4
|
+
needs code, ``search.py`` / ``read.py`` may export a function named by the
|
|
5
|
+
source's ``call``. Third-party platforms are deliberately not executed: only
|
|
6
|
+
``origin == "builtin"`` is trusted until an explicit trust flag exists.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import importlib.util
|
|
12
|
+
import threading
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from typing import Any
|
|
15
|
+
|
|
16
|
+
from omnihub.adapters.base import Health, RawResult, ToolCall
|
|
17
|
+
from omnihub.core.result import NEED_SETUP, OmniHubError, classify
|
|
18
|
+
|
|
19
|
+
_LOCK = threading.Lock()
|
|
20
|
+
_MODULES: dict[tuple[str, int, int], Any] = {}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _load_module(path: Path, platform_id: str) -> Any:
|
|
24
|
+
stat = path.stat()
|
|
25
|
+
key = (str(path), stat.st_mtime_ns, stat.st_size)
|
|
26
|
+
with _LOCK:
|
|
27
|
+
cached = _MODULES.get(key)
|
|
28
|
+
if cached is not None:
|
|
29
|
+
return cached
|
|
30
|
+
spec = importlib.util.spec_from_file_location(
|
|
31
|
+
f"omnihub_platform_{platform_id}_{path.stem}_{abs(hash(key))}", path
|
|
32
|
+
)
|
|
33
|
+
if spec is None or spec.loader is None:
|
|
34
|
+
raise OmniHubError(NEED_SETUP, f"cannot load {path}")
|
|
35
|
+
module = importlib.util.module_from_spec(spec)
|
|
36
|
+
spec.loader.exec_module(module)
|
|
37
|
+
_MODULES[key] = module
|
|
38
|
+
return module
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class BuiltinAdapter:
|
|
42
|
+
kind = "builtin"
|
|
43
|
+
|
|
44
|
+
def probe(self) -> Health:
|
|
45
|
+
return Health(ok=True)
|
|
46
|
+
|
|
47
|
+
def invoke(self, call: ToolCall, *, ctx: Any) -> RawResult:
|
|
48
|
+
platform_path = call.raw.get("platform_path")
|
|
49
|
+
platform_id = call.raw.get("platform_id") or "platform"
|
|
50
|
+
origin = call.raw.get("platform_origin")
|
|
51
|
+
trusted = call.raw.get("platform_trusted") is True
|
|
52
|
+
if origin != "builtin" and not trusted:
|
|
53
|
+
raise OmniHubError(
|
|
54
|
+
NEED_SETUP,
|
|
55
|
+
f"third-party platform {platform_id!r} ships Python hooks but is not "
|
|
56
|
+
f"trusted; add `--trust-plugin {platform_id}` or set "
|
|
57
|
+
"OMNIHUB_TRUSTED_PLUGINS",
|
|
58
|
+
)
|
|
59
|
+
if not platform_path:
|
|
60
|
+
raise OmniHubError(NEED_SETUP, "platform path missing from builtin call")
|
|
61
|
+
if not call.call:
|
|
62
|
+
raise OmniHubError(NEED_SETUP, "builtin source requires a call")
|
|
63
|
+
|
|
64
|
+
if call.script:
|
|
65
|
+
module_path = Path(call.script)
|
|
66
|
+
if module_path.suffix != ".py":
|
|
67
|
+
raise OmniHubError(
|
|
68
|
+
NEED_SETUP,
|
|
69
|
+
f"builtin script must be a .py file: {module_path.name}",
|
|
70
|
+
)
|
|
71
|
+
else:
|
|
72
|
+
module_path = Path(platform_path) / f"{call.action or 'action'}.py"
|
|
73
|
+
if not module_path.is_file():
|
|
74
|
+
raise OmniHubError(NEED_SETUP, f"platform has no {module_path.name}")
|
|
75
|
+
try:
|
|
76
|
+
module = _load_module(module_path, str(platform_id))
|
|
77
|
+
function = getattr(module, call.call)
|
|
78
|
+
except OmniHubError:
|
|
79
|
+
raise
|
|
80
|
+
except (OSError, AttributeError, ImportError) as exc:
|
|
81
|
+
raise OmniHubError(NEED_SETUP, f"cannot load {module_path.name}: {exc}") from None
|
|
82
|
+
|
|
83
|
+
params = dict(call.params)
|
|
84
|
+
params.update(call.args)
|
|
85
|
+
try:
|
|
86
|
+
if call.action == "search":
|
|
87
|
+
result = function(
|
|
88
|
+
params.get("query"),
|
|
89
|
+
limit=params.get("limit", 5),
|
|
90
|
+
params=params,
|
|
91
|
+
ctx=ctx,
|
|
92
|
+
)
|
|
93
|
+
elif call.action == "read":
|
|
94
|
+
result = function(
|
|
95
|
+
params.get("target"),
|
|
96
|
+
params=params,
|
|
97
|
+
ctx=ctx,
|
|
98
|
+
)
|
|
99
|
+
else:
|
|
100
|
+
result = function(params=params, ctx=ctx)
|
|
101
|
+
except OmniHubError:
|
|
102
|
+
raise
|
|
103
|
+
except Exception as exc:
|
|
104
|
+
raise classify(exc) from None
|
|
105
|
+
|
|
106
|
+
return _wrap(result)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def _wrap(result: Any) -> RawResult:
|
|
110
|
+
if isinstance(result, RawResult):
|
|
111
|
+
return result
|
|
112
|
+
if isinstance(result, dict):
|
|
113
|
+
if any(key in result for key in ("items", "results", "search_results", "hits", "data")):
|
|
114
|
+
return RawResult(data=result)
|
|
115
|
+
return RawResult(data=[result])
|
|
116
|
+
if isinstance(result, (list, tuple)):
|
|
117
|
+
return RawResult(data=list(result))
|
|
118
|
+
if isinstance(result, str):
|
|
119
|
+
return RawResult(text=result, content_type="text/plain")
|
|
120
|
+
return RawResult(data=result)
|
omnihub/adapters/cli.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""Generic CLI adapter.
|
|
2
|
+
|
|
3
|
+
The manifest either gives an explicit ``argv`` (recommended, unambiguous) or
|
|
4
|
+
names an executable/tool plus a call. In the latter case mapping is simple:
|
|
5
|
+
``{"query": "x", "limit": 5}`` becomes ``--query x --limit 5``; booleans become
|
|
6
|
+
a bare flag. No shell is ever involved.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from typing import Any, Sequence
|
|
12
|
+
|
|
13
|
+
from omnihub.adapters.base import Health, RawResult, ToolCall
|
|
14
|
+
from omnihub.core.result import BAD_INPUT, OmniHubError
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _flag(key: str) -> str:
|
|
18
|
+
return "--" + key.strip().lstrip("-").replace("_", "-")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def args_to_argv(args: dict[str, Any]) -> list[str]:
|
|
22
|
+
argv: list[str] = []
|
|
23
|
+
for key, value in args.items():
|
|
24
|
+
if value is None or value is False:
|
|
25
|
+
continue
|
|
26
|
+
flag = _flag(str(key))
|
|
27
|
+
if value is True:
|
|
28
|
+
argv.append(flag)
|
|
29
|
+
elif isinstance(value, (list, tuple)):
|
|
30
|
+
for entry in value:
|
|
31
|
+
argv.extend([flag, str(entry)])
|
|
32
|
+
else:
|
|
33
|
+
argv.extend([flag, str(value)])
|
|
34
|
+
return argv
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def build_argv(call: ToolCall) -> tuple[str, ...]:
|
|
38
|
+
if call.argv:
|
|
39
|
+
return tuple(str(part) for part in call.argv)
|
|
40
|
+
executable = call.tool or call.call
|
|
41
|
+
if not executable:
|
|
42
|
+
raise OmniHubError(BAD_INPUT, "cli source requires argv or tool/call")
|
|
43
|
+
argv: list[str] = [executable]
|
|
44
|
+
if call.tool and call.call:
|
|
45
|
+
argv.append(call.call)
|
|
46
|
+
argv.extend(args_to_argv(dict(call.args) or dict(call.params)))
|
|
47
|
+
return tuple(argv)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class CliAdapter:
|
|
51
|
+
kind = "cli"
|
|
52
|
+
|
|
53
|
+
def probe(self) -> Health:
|
|
54
|
+
return Health(ok=True)
|
|
55
|
+
|
|
56
|
+
def invoke(self, call: ToolCall, *, ctx: Any) -> RawResult:
|
|
57
|
+
argv: Sequence[str] = build_argv(call)
|
|
58
|
+
process = ctx.run(
|
|
59
|
+
argv,
|
|
60
|
+
timeout=call.timeout,
|
|
61
|
+
max_bytes=call.max_bytes,
|
|
62
|
+
)
|
|
63
|
+
return RawResult(
|
|
64
|
+
ok=True,
|
|
65
|
+
data=None,
|
|
66
|
+
text=process.stdout,
|
|
67
|
+
content_type="text/plain",
|
|
68
|
+
meta={
|
|
69
|
+
"argv": list(argv),
|
|
70
|
+
"returncode": process.returncode,
|
|
71
|
+
"truncated": process.truncated,
|
|
72
|
+
"stderr": process.stderr[-500:] if process.stderr else "",
|
|
73
|
+
},
|
|
74
|
+
)
|