python-agent-harness 1.5.7.1__py3-none-any.whl → 1.5.7.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.
@@ -7,7 +7,7 @@ from .mcp.config import MCPConfig, MCPServerConfig
7
7
  from .mcp.manager import MCPManager
8
8
  from .session.session import Session
9
9
 
10
- __version__ = "1.5.7.1"
10
+ __version__ = "1.5.7.2"
11
11
 
12
12
  __all__ = [
13
13
  "Client",
@@ -1000,8 +1000,14 @@ class Client:
1000
1000
  {"id": "", "name": "", "arguments": ""},
1001
1001
  )
1002
1002
  fn = tc.get("function") or {}
1003
- entry["id"] += tc.get("id") or ""
1004
- entry["name"] += fn.get("name") or ""
1003
+ # id/name are not incremental like arguments: some backends and
1004
+ # proxies resend them in EVERY chunk, and appending blindly made
1005
+ # "ReadRead" (an unknown tool) out of a repeated "Read". A piece
1006
+ # equal to what is already accumulated is such a repeat and is
1007
+ # skipped; a genuinely split value ("Re" + "ad") still appends.
1008
+ for key, piece in (("id", tc.get("id")), ("name", fn.get("name"))):
1009
+ if isinstance(piece, str) and piece and piece != entry[key]:
1010
+ entry[key] += piece
1005
1011
  frag = fn.get("arguments") or ""
1006
1012
  if isinstance(frag, dict):
1007
1013
  frag = json.dumps(frag, ensure_ascii=False)
@@ -24,6 +24,7 @@ over this.
24
24
 
25
25
  from __future__ import annotations
26
26
 
27
+ import math
27
28
  from collections.abc import Mapping
28
29
  from dataclasses import dataclass, field
29
30
  from typing import Any
@@ -69,6 +70,17 @@ class MCPServerConfig:
69
70
  raise ValueError(f"MCP server {label!r}: stdio transport requires `command`")
70
71
  elif not self.url:
71
72
  raise ValueError(f"MCP server {label!r}: {self.transport} transport requires `url`")
73
+ # timeout flows into ``time.monotonic() + timeout`` and the SDK's
74
+ # read timeout; a string/bool/non-finite value from the JSON config
75
+ # would otherwise only fail mid-run with an opaque TypeError.
76
+ # bool is excluded explicitly because it is an int subclass.
77
+ t = self.timeout
78
+ if t is not None and (
79
+ isinstance(t, bool) or not isinstance(t, (int, float)) or not math.isfinite(t) or t <= 0
80
+ ):
81
+ raise ValueError(
82
+ f"MCP server {label!r}: `timeout` must be a positive number of seconds, got {t!r}"
83
+ )
72
84
 
73
85
 
74
86
  @dataclass
@@ -21,12 +21,11 @@ from __future__ import annotations
21
21
 
22
22
  import os
23
23
  import re
24
- import subprocess
25
24
  from collections.abc import Callable
26
25
  from pathlib import Path
27
26
  from typing import Any
28
27
 
29
- from ..prompts import read_prompt_file
28
+ from ..prompts import _git_toplevel, read_prompt_file
30
29
 
31
30
  PROMPTS_DIR = Path(__file__).parents[1] / "prompts"
32
31
  COMMANDS_DIR = PROMPTS_DIR / "commands"
@@ -56,22 +55,19 @@ def _substitute(text: str, path: str, extra: str | None) -> str:
56
55
 
57
56
 
58
57
  def _project_root(cwd: str) -> str:
59
- """Best-effort project root (git dir or parent with AGENTS.md)."""
58
+ """Best-effort project root (git worktree root, else parent with AGENTS.md).
59
+
60
+ Inside a git repository this delegates to ``prompts.core._git_toplevel``
61
+ so slash commands and project-context loading agree on the root.
62
+ Outside a repository the nearest ancestor holding ``AGENTS.md`` wins,
63
+ else *cwd* itself.
64
+ """
60
65
  d = Path(cwd).resolve()
61
- try:
62
- out = subprocess.run(
63
- ["git", "rev-parse", "--show-toplevel"],
64
- cwd=cwd,
65
- capture_output=True,
66
- text=True,
67
- timeout=10,
68
- )
69
- if out.returncode == 0 and out.stdout.strip():
70
- return out.stdout.strip()
71
- except (OSError, subprocess.TimeoutExpired):
72
- pass
73
- for parent in [d, *d.parents]:
74
- if (parent / "AGENTS.md").exists() or (parent / ".git").exists():
66
+ ancestors = [d, *d.parents]
67
+ if any((p / ".git").exists() for p in ancestors):
68
+ return _git_toplevel(cwd)
69
+ for parent in ancestors:
70
+ if (parent / "AGENTS.md").exists():
75
71
  return str(parent)
76
72
  return cwd
77
73
 
@@ -105,7 +101,7 @@ class SessionCommand:
105
101
  Used by the TUI slash commands, which run inside the current
106
102
  session.
107
103
  """
108
- cwd = project_dir or _project_root(__import__("os").getcwd())
104
+ cwd = project_dir or _project_root(os.getcwd())
109
105
  prompt = _substitute(read_prompt_file(self.prompt_file), cwd, extra)
110
106
  kickoff = self.kickoff
111
107
  if "${path}" in kickoff:
@@ -35,7 +35,7 @@ class Grep(Tool):
35
35
 
36
36
  **How to use `Grep`:**
37
37
  - Supports full regex syntax (ripgrep-based)
38
- - Can specify directory path and glon to narrow scope
38
+ - Can specify directory path and glob to narrow scope
39
39
  - Use `context_lines` parameter to see surrounding lines
40
40
  - Can perform multiple focused grep searches in parallel
41
41
  """
@@ -19,7 +19,7 @@ from .filesystem import READ_SIZE_LIMIT, _spool
19
19
  class Read(Tool):
20
20
  name = "Read"
21
21
  is_readonly = True
22
- instructions = """\
22
+ instructions = f"""\
23
23
  **When to use `Read`:**
24
24
  - You need to examine file contents
25
25
  - Before editing any file (required)
@@ -32,10 +32,10 @@ class Read(Tool):
32
32
  - You want to use shell commands like cat → use `Read` instead
33
33
 
34
34
  **How to use `Read`:**
35
- - Default behavior reads up to 2000 lines from the beginning
36
- - For large files, use offset and limit parameters to read specific sections
37
- - Recommended to read the whole file by omitting offset/limit when possible
38
- - Always read beforing - the `Edit` tool will error otherwise
35
+ - Omitting `start_line`/`end_line` reads the whole file (files over {READ_SIZE_LIMIT // 1024} KB require a line range)
36
+ - For large files, use `start_line`/`end_line` to read specific sections
37
+ - Recommended to read the whole file by omitting `start_line`/`end_line` when possible
38
+ - Always read before editing - the `Edit` tool will error otherwise
39
39
  - Can read multiple files in parallel by making multiple `Read` calls
40
40
  """
41
41
  description = (
@@ -89,4 +89,5 @@ class Write(Tool):
89
89
  diff_text = unified_diff(old_content, content, path)
90
90
  if diff_text:
91
91
  ctx.record_diff(diff_text)
92
- return f"Created file {filename} in {dir_path}"
92
+ verb = "Overwrote" if existed else "Created"
93
+ return f"{verb} file {filename} in {dir_path}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-agent-harness
3
- Version: 1.5.7.1
3
+ Version: 1.5.7.2
4
4
  Summary: A lightweight, hackable mini-OpenCode written in Python.
5
5
  Author-email: Huming Chen <chenhuming@gmail.com>
6
6
  License-Expression: MIT
@@ -1,4 +1,4 @@
1
- python_agent_harness/__init__.py,sha256=p9C9oi4sDY87c-esvQIP5VT40YjvbNy8oxRxSgikGTI,664
1
+ python_agent_harness/__init__.py,sha256=PBEmnIdeFgu69P-w-dR3n3O_RRwhsw2wI3vhNzMiwWw,664
2
2
  python_agent_harness/__main__.py,sha256=Z3IaoJ3frQAQm5Lg-1gON_hwwHUc7CkYFUg74JIVnPE,58
3
3
  python_agent_harness/core/__init__.py,sha256=AuGbAsl5rBoJdOgcaB5-9OGTVo3YtSVjJuQU7GEu9OU,77
4
4
  python_agent_harness/core/agent.py,sha256=VJrtbMVwFA7h2j-4UPF5Bdwu99e9hiRCLaQeuQPlqlo,41455
@@ -21,10 +21,10 @@ python_agent_harness/io/diffrender.py,sha256=HEOaAjKXZ6euPv-wlEP75304ceLME4ttRDp
21
21
  python_agent_harness/io/persistence.py,sha256=U2mEPJPBGmlcN0PstxKlbc4DJ5P1OAnYG2GQbRyo7AI,15941
22
22
  python_agent_harness/io/text_filter.py,sha256=B4RkF-cFu_lblQejne9_lC_ZjaOFcbRhrcxAmInGaLI,11507
23
23
  python_agent_harness/llm/__init__.py,sha256=osSA7cec8RtjDURa6kbTZwjv0t31opMmmPtjyaxKFjs,22
24
- python_agent_harness/llm/client.py,sha256=oI3hWfGT5cIJ-fNzGPuVGc37oXnZFq2PMPWYPgEh3pA,47931
24
+ python_agent_harness/llm/client.py,sha256=QS9MsB5LG_uXfkV3vlIOtRIyUSntYA6bAt9rh1r_T-k,48390
25
25
  python_agent_harness/mcp/__init__.py,sha256=dlgZRr_pljESu-aJfo3aq_fLDkZN7quwrPUR112Kohw,535
26
26
  python_agent_harness/mcp/client.py,sha256=BnBPuX5Pn9-3KBpWXPeC1bPVYOJl8eNpk0XvupD9eOw,6212
27
- python_agent_harness/mcp/config.py,sha256=XpeB0AzWTCI6BoDqScsKzjBt5BPHgaCc58WEJfsvPRM,4894
27
+ python_agent_harness/mcp/config.py,sha256=XMxBndLw_5EwGNbjyfIhxud6IYM2VHTsUVwU2cqkoy0,5506
28
28
  python_agent_harness/mcp/manager.py,sha256=5yAT7yf58SJEMLGBVihOtO11hjmIMUYI7aRNJtcVJMs,11814
29
29
  python_agent_harness/prompts/__init__.py,sha256=X8fYIv5aeWYCRYon5ksuX17L-ppZrtUvRNk1s7D3hw4,995
30
30
  python_agent_harness/prompts/agent.md,sha256=QeBtoZHT4oSjZ0wV3Kq45kwEAxekL7INQr35OTgbhF8,6361
@@ -42,7 +42,7 @@ python_agent_harness/prompts/title.md,sha256=56aEjroyjyjH6HCHTPBZHk7br5DXYCrY_f6
42
42
  python_agent_harness/prompts/agents/reviewer.md,sha256=rcj2jiY6S8PQhWfvXXt9h3T11PuofVcAvDKTBmDoYAs,414
43
43
  python_agent_harness/prompts/commands/explain.md,sha256=RMmP9L3TfPpW0dthlGobWbgqBIc7H2LJIMIJT2JDN3Y,539
44
44
  python_agent_harness/session/__init__.py,sha256=SdMrMuRupRhIyUjJLb0EEmB5KtgDmKORV_qDZUpEYEw,937
45
- python_agent_harness/session/commands.py,sha256=Gz7bAX3ymESSMTR9BOQT3gc9EvlaosVj3hBOIAjRGFY,8924
45
+ python_agent_harness/session/commands.py,sha256=kqp0JVOg2Ls9QEtx2ViA6p5xSnBcDp9y_aY2mNSaysM,8895
46
46
  python_agent_harness/session/config.py,sha256=5rg3heS-1vEIcPESLiXP-hNgKlj_XoT6haGXKrd6Jn0,31718
47
47
  python_agent_harness/session/hooks.py,sha256=JNIDOqI26Rb9NTPay8EHHCFx0mbSKilILEcfQFfRTS4,25329
48
48
  python_agent_harness/session/session.py,sha256=L1GxrmShGwNRmNjgBX83p3Gdo3M8GKwStEpdZ2OsB9g,51273
@@ -56,24 +56,24 @@ python_agent_harness/tools/edit_mac.py,sha256=XXTS5_4UtZ5YQtiYe1bk1Q4cdW5XqCtRCM
56
56
  python_agent_harness/tools/filesystem.py,sha256=btutgEVM6ssfmxBNbgUrflBN6qwUARAlw6ZGI7UpEsw,12069
57
57
  python_agent_harness/tools/glob.py,sha256=LFTLdQs_MUiSsk0ZN5Oc2JA0aY2qPCna3oCUhWxR6Cw,7107
58
58
  python_agent_harness/tools/glob_mac.py,sha256=xq-XxUujo24hIHMY89CRnqK03DaFaEZfNmEBPTl-394,4091
59
- python_agent_harness/tools/grep.py,sha256=_19FEw9j03DeiY2aZeWpz_fr7Yc4MtZXPrH1UXJjEMY,7124
59
+ python_agent_harness/tools/grep.py,sha256=4VCUzu-_h_wywdeMbMxzpWXBsv4jy7I7u8B0Coh-rE8,7124
60
60
  python_agent_harness/tools/grep_mac.py,sha256=UfMtVnhjgj_qlO3k79LjAF8_u7OJomsF9I0dM5e8s4A,5918
61
61
  python_agent_harness/tools/mcp.py,sha256=v_XMOfxGpaJ3xw3i4j3HOz03qhMluGfLotLZSQPD_Ac,7489
62
62
  python_agent_harness/tools/planexit.py,sha256=ogmoTBBQ0klNe0ktLiVn6dEU4j3J8CdqS7UwvKMZLxY,1935
63
63
  python_agent_harness/tools/question.py,sha256=G1d40hazlYnf1oBJCGpf4pri2gKPa1lGeO5QY61tpxk,3358
64
- python_agent_harness/tools/read.py,sha256=ISOH_8xQnsoBT0NGme0BlHwKlWsJsJxg2Ro9EaM3uiA,5081
64
+ python_agent_harness/tools/read.py,sha256=4c_Dj424ipTrtXq8Dqd0B2Juy3Za6QtSFsromSjw0Tg,5153
65
65
  python_agent_harness/tools/skill.py,sha256=Fk5i8UZ_Qamoc4v1owxjmDi2FCnKIezu_gZRuGfdTSg,1118
66
66
  python_agent_harness/tools/todo.py,sha256=1BO8ZAmfHlswujjy_gFL0eID8DZphyiCjPJJ7AqhaYY,4294
67
- python_agent_harness/tools/write.py,sha256=xQscOZdHVVMDKCHUGwqctU8Fzmn_YkGLzL3KZuCV0gY,3956
67
+ python_agent_harness/tools/write.py,sha256=PnLp86Cl0aMSPcL_3gNeoxExgj0yAX8-71fun_UhDwY,4008
68
68
  python_agent_harness/tui/__init__.py,sha256=Fgs8gTIzVgVUksKcjOopFDvwR9gQCaEeJ-aUTHpQbhE,1626
69
69
  python_agent_harness/tui/commands.py,sha256=Eat1nljKoD2z3MfPORHc-drWsnUdyfRMr_nUcP_T1_Y,33462
70
70
  python_agent_harness/tui/core.py,sha256=BjqOK3qIlHZVNzn5dRd9Vg30UgI76UgjM3cV398DTd4,25310
71
71
  python_agent_harness/tui/input.py,sha256=wRpPzSOKST2WAYeRQ3I72-64KzhztQ_FoFhTNpTtg7A,21192
72
72
  python_agent_harness/tui/mouse.py,sha256=VEKOqM0mrSn_sZNDHZtSn_xCYiEZOKQlL_3l-LXRj30,15262
73
73
  python_agent_harness/tui/render.py,sha256=0i22IOuTE0TPg8428t35uc6fR6wSjp6ZcjWBJ7v6xzk,55239
74
- python_agent_harness-1.5.7.1.dist-info/licenses/LICENSE,sha256=TiuVaM7FrBunbEua5l_01IT-mwccvS51CLrDLuKW96g,1066
75
- python_agent_harness-1.5.7.1.dist-info/METADATA,sha256=qpE5wojpRk5IbZyUOvCDQuSJa1B_-pDl5gYGHOtmF60,15752
76
- python_agent_harness-1.5.7.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
77
- python_agent_harness-1.5.7.1.dist-info/entry_points.txt,sha256=W0fmwiwUzs9ORhJRF3oG0i5ku3qg5k2wrDACUqWR0wk,77
78
- python_agent_harness-1.5.7.1.dist-info/top_level.txt,sha256=MQXIVidl0IBeeKnLHhy1JfzXNQMBKAehpdkqHVvIfwM,21
79
- python_agent_harness-1.5.7.1.dist-info/RECORD,,
74
+ python_agent_harness-1.5.7.2.dist-info/licenses/LICENSE,sha256=TiuVaM7FrBunbEua5l_01IT-mwccvS51CLrDLuKW96g,1066
75
+ python_agent_harness-1.5.7.2.dist-info/METADATA,sha256=9dLTRctgawS8XBUTZhaTH-Lr07wO5k1KCyd-_TSEIUU,15752
76
+ python_agent_harness-1.5.7.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
77
+ python_agent_harness-1.5.7.2.dist-info/entry_points.txt,sha256=W0fmwiwUzs9ORhJRF3oG0i5ku3qg5k2wrDACUqWR0wk,77
78
+ python_agent_harness-1.5.7.2.dist-info/top_level.txt,sha256=MQXIVidl0IBeeKnLHhy1JfzXNQMBKAehpdkqHVvIfwM,21
79
+ python_agent_harness-1.5.7.2.dist-info/RECORD,,