plan-manager-client-dev 0.2.238__tar.gz → 0.2.239__tar.gz
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.
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/PKG-INFO +1 -1
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/client.py +14 -2
- plan_manager_client_dev-0.2.239/plan_manager_client/config.py +138 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/scenario_runtime.py +2 -9
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client_dev.egg-info/PKG-INFO +1 -1
- plan_manager_client_dev-0.2.238/plan_manager_client/config.py +0 -320
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/__init__.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/_version.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/authoring_diagnostics.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/delivery/__init__.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/delivery/archive.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/delivery/atomicity.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/delivery/commit.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/delivery/destination.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/delivery/provenance.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/delivery/upload.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/dispatch.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/export_fetch_chunks.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/export_fetch_request.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/export_fetch_unpack.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/export_fetch_verify.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/facade_agent_config_mixin.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/facade_bug_project_mixin.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/facade_context_gate_mixin.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/facade_entity_common_mixin.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/facade_hrs_file_mixin.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/facade_name_tree_mixin.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/facade_plan_hrs_mixin.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/facade_runtime_mixin/__init__.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/facade_runtime_mixin/authoring_part.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/facade_runtime_mixin/facade.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/facade_runtime_mixin/overlay_part.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/facade_step_graph_mixin.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/id_rule.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/info_walker.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/server_api.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/server_api_mutating.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client_dev.egg-info/SOURCES.txt +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client_dev.egg-info/dependency_links.txt +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client_dev.egg-info/requires.txt +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client_dev.egg-info/top_level.txt +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/pyproject.toml +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/setup.cfg +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/tests/test_client_server_api_sync.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/tests/test_dispatch_validation_error_classification.py +0 -0
- {plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/tests/test_matrix_check_facade_passthrough.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plan-manager-client-dev
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.239
|
|
4
4
|
Summary: First-class client library for the plan_manager JSON-RPC API: full command-surface facade plus export delivery module boundary.
|
|
5
5
|
Requires-Python: >=3.12
|
|
6
6
|
Requires-Dist: mcp-proxy-adapter>=8.11.21
|
{plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/client.py
RENAMED
|
@@ -6,10 +6,12 @@ email: vasilyvz@gmail.com
|
|
|
6
6
|
|
|
7
7
|
from __future__ import annotations
|
|
8
8
|
|
|
9
|
+
from pathlib import Path
|
|
9
10
|
from typing import Any
|
|
10
11
|
|
|
11
12
|
from mcp_proxy_adapter.client.jsonrpc_client.client import JsonRpcClient
|
|
12
13
|
|
|
14
|
+
from plan_manager_client.config import SECTION_NAME, ClientConnectionConfig
|
|
13
15
|
from plan_manager_client.dispatch import _CommandDispatchMixin
|
|
14
16
|
from plan_manager_client.facade_agent_config_mixin import AgentConfigCommandsMixin
|
|
15
17
|
from plan_manager_client.facade_bug_project_mixin import BugProjectCommandsMixin
|
|
@@ -38,7 +40,7 @@ class PlanManagerClient(
|
|
|
38
40
|
|
|
39
41
|
Composes (HOLDS, never inherits) a
|
|
40
42
|
mcp_proxy_adapter.client.jsonrpc_client.client.JsonRpcClient on the private
|
|
41
|
-
attribute ``self._rpc``, which supplies transport (
|
|
43
|
+
attribute ``self._rpc``, which supplies the transport (decided by the adapter alone), token
|
|
42
44
|
authentication, queued-job polling, and chunked file transfer with sha256
|
|
43
45
|
verification and resume. Because the transport client is held rather than
|
|
44
46
|
inherited, the network interaction is fully hidden: the public surface of
|
|
@@ -49,11 +51,21 @@ class PlanManagerClient(
|
|
|
49
51
|
plan_manager_client.server_api.COMMAND_NAMES. Construct directly with the
|
|
50
52
|
JsonRpcClient constructor arguments, or via
|
|
51
53
|
PlanManagerClient(**config.to_jsonrpc_kwargs()) using a
|
|
52
|
-
plan_manager_client.config.ClientConnectionConfig instance
|
|
54
|
+
plan_manager_client.config.ClientConnectionConfig instance, or
|
|
55
|
+
PlanManagerClient.from_document_path(path) from a client configuration document. Connections are
|
|
53
56
|
direct to the plan_manager server; this class performs no proxy call_server
|
|
54
57
|
routing.
|
|
55
58
|
"""
|
|
56
59
|
|
|
60
|
+
@classmethod
|
|
61
|
+
def from_document_path(cls, path: str | Path, section_name: str = SECTION_NAME) -> "PlanManagerClient":
|
|
62
|
+
"""Build the client from the named section of a JSON client configuration document.
|
|
63
|
+
|
|
64
|
+
The section follows ``plan_manager_client.config`` (the sectioned fleet shape); its transport values reach
|
|
65
|
+
the adapter ``JsonRpcClient`` unchanged.
|
|
66
|
+
"""
|
|
67
|
+
return cls(**ClientConnectionConfig.from_document_path(path, section_name).to_jsonrpc_kwargs())
|
|
68
|
+
|
|
57
69
|
def __init__(self, **jsonrpc_kwargs: Any) -> None:
|
|
58
70
|
"""Compose the underlying JsonRpcClient from JsonRpcClient constructor kwargs.
|
|
59
71
|
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"""Client configuration document of plan_manager_client.
|
|
2
|
+
|
|
3
|
+
The client is a thin layer on the mcp-proxy-adapter ``JsonRpcClient``. It takes no transport decision of its
|
|
4
|
+
own: protocol, host, port, certificate, key, CA and ``check_hostname`` are read from ONE configuration section in
|
|
5
|
+
the sectioned fleet shape (the shape the other fleet clients use, e.g. ``ai_devlease_client`` and
|
|
6
|
+
``ailogger_client``) and handed to the adapter client unchanged. The adapter alone decides what a protocol means,
|
|
7
|
+
how a certificate pair is attached, which port applies and whether the host name is verified.
|
|
8
|
+
|
|
9
|
+
Section shape (JSON object, section name ``plan_manager_client`` by default)::
|
|
10
|
+
|
|
11
|
+
{"protocol": "...", "server": {"host": "...", "port": 0},
|
|
12
|
+
"client": {"cert": "...", "key": "...", "ca": "...", "check_hostname": true, "timeout": 60},
|
|
13
|
+
"auth": {"token": "...", "token_header": "..."}}
|
|
14
|
+
|
|
15
|
+
``ssl`` is accepted as an alternative home of ``cert``/``key``/``ca``/``check_hostname``. Relative file paths are
|
|
16
|
+
resolved against the directory of the document.
|
|
17
|
+
|
|
18
|
+
Author: Vasiliy Zdanovskiy
|
|
19
|
+
email: vasilyvz@gmail.com
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import json
|
|
25
|
+
from collections.abc import Mapping
|
|
26
|
+
from dataclasses import dataclass
|
|
27
|
+
from pathlib import Path
|
|
28
|
+
from typing import Any, Optional
|
|
29
|
+
|
|
30
|
+
SECTION_NAME = "plan_manager_client"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class ClientConfigError(ValueError):
|
|
34
|
+
"""The configuration document or its section is missing or not an object of the documented shape."""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
MissingClientEndpointError = ClientConfigError # earlier name of the same refusal, kept for existing importers
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _mapping(node: Any, name: str) -> Mapping[str, Any]:
|
|
41
|
+
if node is None:
|
|
42
|
+
return {}
|
|
43
|
+
if not isinstance(node, Mapping):
|
|
44
|
+
raise ClientConfigError(f"'{name}' must be an object")
|
|
45
|
+
return node
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _path(value: Any, base_dir: Path | None) -> str | None:
|
|
49
|
+
if value in (None, ""):
|
|
50
|
+
return None
|
|
51
|
+
path = Path(str(value))
|
|
52
|
+
if not path.is_absolute() and base_dir is not None:
|
|
53
|
+
path = base_dir / path
|
|
54
|
+
return str(path)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@dataclass(frozen=True)
|
|
58
|
+
class ClientConnectionConfig:
|
|
59
|
+
"""The keyword arguments of ``JsonRpcClient``, read from the client configuration section and nothing else.
|
|
60
|
+
|
|
61
|
+
No field has a default: an absent protocol, host or port is refused, never invented. ``check_hostname`` stays
|
|
62
|
+
``None`` unless the document sets it, which leaves the adapter's own (verifying) default in force.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
protocol: str
|
|
66
|
+
host: str
|
|
67
|
+
port: int
|
|
68
|
+
token_header: Optional[str] = None
|
|
69
|
+
token: Optional[str] = None
|
|
70
|
+
cert: Optional[str] = None
|
|
71
|
+
key: Optional[str] = None
|
|
72
|
+
ca: Optional[str] = None
|
|
73
|
+
check_hostname: Optional[bool] = None
|
|
74
|
+
timeout: Optional[float] = None
|
|
75
|
+
|
|
76
|
+
@classmethod
|
|
77
|
+
def from_section(cls, section: Mapping[str, Any], base_dir: str | Path | None = None) -> "ClientConnectionConfig":
|
|
78
|
+
"""Translate one configuration section into the adapter client's keyword arguments."""
|
|
79
|
+
if not isinstance(section, Mapping):
|
|
80
|
+
raise ClientConfigError("client section must be an object")
|
|
81
|
+
server = _mapping(section.get("server"), "server")
|
|
82
|
+
client = _mapping(section.get("client"), "client")
|
|
83
|
+
ssl = _mapping(section.get("ssl"), "ssl")
|
|
84
|
+
auth = _mapping(section.get("auth"), "auth")
|
|
85
|
+
base = Path(base_dir) if base_dir is not None else None
|
|
86
|
+
|
|
87
|
+
def pick(name: str) -> Any:
|
|
88
|
+
return client.get(name, ssl.get(name))
|
|
89
|
+
|
|
90
|
+
missing = [
|
|
91
|
+
name
|
|
92
|
+
for name, value in (("protocol", section.get("protocol")), ("server.host", server.get("host")), ("server.port", server.get("port")))
|
|
93
|
+
if value in (None, "")
|
|
94
|
+
]
|
|
95
|
+
if missing:
|
|
96
|
+
raise ClientConfigError("missing required client section value(s): " + ", ".join(missing))
|
|
97
|
+
timeout = client.get("timeout")
|
|
98
|
+
return cls(
|
|
99
|
+
protocol=section["protocol"],
|
|
100
|
+
host=server["host"],
|
|
101
|
+
port=int(server["port"]),
|
|
102
|
+
token_header=auth.get("token_header"),
|
|
103
|
+
token=auth.get("token"),
|
|
104
|
+
cert=_path(pick("cert"), base),
|
|
105
|
+
key=_path(pick("key"), base),
|
|
106
|
+
ca=_path(pick("ca"), base),
|
|
107
|
+
check_hostname=pick("check_hostname"),
|
|
108
|
+
timeout=float(timeout) if timeout is not None else None,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
@classmethod
|
|
112
|
+
def from_document_path(cls, path: str | Path, section_name: str = SECTION_NAME) -> "ClientConnectionConfig":
|
|
113
|
+
"""Read the named section of a JSON configuration document."""
|
|
114
|
+
document_path = Path(path).resolve()
|
|
115
|
+
with open(document_path, encoding="utf-8") as handle:
|
|
116
|
+
document = json.load(handle)
|
|
117
|
+
section = document.get(section_name) if isinstance(document, Mapping) else None
|
|
118
|
+
if not isinstance(section, Mapping):
|
|
119
|
+
raise ClientConfigError(f"configuration document carries no '{section_name}' section")
|
|
120
|
+
return cls.from_section(section, document_path.parent)
|
|
121
|
+
|
|
122
|
+
def to_jsonrpc_kwargs(self) -> dict[str, Any]:
|
|
123
|
+
"""Return constructor kwargs for ``JsonRpcClient(**kwargs)``."""
|
|
124
|
+
return {
|
|
125
|
+
"protocol": self.protocol,
|
|
126
|
+
"host": self.host,
|
|
127
|
+
"port": self.port,
|
|
128
|
+
"token_header": self.token_header,
|
|
129
|
+
"token": self.token,
|
|
130
|
+
"cert": self.cert,
|
|
131
|
+
"key": self.key,
|
|
132
|
+
"ca": self.ca,
|
|
133
|
+
"check_hostname": self.check_hostname,
|
|
134
|
+
"timeout": self.timeout,
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
__all__ = ["SECTION_NAME", "ClientConfigError", "ClientConnectionConfig", "MissingClientEndpointError"]
|
|
@@ -23,15 +23,8 @@ def configure_call_watchdog(timeout: float | None, *, grace_seconds: float = _CA
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def build_config(args: argparse.Namespace) -> ClientConnectionConfig:
|
|
26
|
-
"""
|
|
27
|
-
return ClientConnectionConfig.
|
|
28
|
-
base_url=getattr(args, "base_url", None),
|
|
29
|
-
protocol=getattr(args, "protocol", None),
|
|
30
|
-
host=getattr(args, "host", None),
|
|
31
|
-
port=getattr(args, "port", None),
|
|
32
|
-
timeout=getattr(args, "timeout", None),
|
|
33
|
-
env_prefix="PLAN_MANAGER_",
|
|
34
|
-
)
|
|
26
|
+
"""Read the client configuration section named by the scenario's ``--config`` document (no transport logic here)."""
|
|
27
|
+
return ClientConnectionConfig.from_document_path(args.config)
|
|
35
28
|
|
|
36
29
|
|
|
37
30
|
def _unwrap(raw: Any) -> tuple[bool, Any]:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plan-manager-client-dev
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.239
|
|
4
4
|
Summary: First-class client library for the plan_manager JSON-RPC API: full command-surface facade plus export delivery module boundary.
|
|
5
5
|
Requires-Python: >=3.12
|
|
6
6
|
Requires-Dist: mcp-proxy-adapter>=8.11.21
|
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
"""Direct-connection configuration for a single plan_manager_client server.
|
|
2
|
-
|
|
3
|
-
Author: Vasiliy Zdanovskiy
|
|
4
|
-
email: vasilyvz@gmail.com
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
from __future__ import annotations
|
|
8
|
-
|
|
9
|
-
from dataclasses import dataclass
|
|
10
|
-
import os
|
|
11
|
-
from pathlib import Path
|
|
12
|
-
from typing import Any
|
|
13
|
-
from typing import Optional
|
|
14
|
-
from urllib.parse import urlsplit
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
ENDPOINT_ENV_NAMES = {
|
|
18
|
-
"base_url": "PLAN_MANAGER_BASE_URL",
|
|
19
|
-
"protocol": "PLAN_MANAGER_PROTOCOL",
|
|
20
|
-
"host": "PLAN_MANAGER_HOST",
|
|
21
|
-
"port": "PLAN_MANAGER_PORT",
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class MissingClientEndpointError(ValueError):
|
|
26
|
-
"""Raised when no complete client endpoint is provided by CLI, env, or .env."""
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def _read_dotenv(path: str | Path | None) -> dict[str, str]:
|
|
30
|
-
"""Read simple KEY=VALUE entries from a dotenv file without side effects."""
|
|
31
|
-
if path is None:
|
|
32
|
-
return {}
|
|
33
|
-
dotenv_path = Path(path)
|
|
34
|
-
if not dotenv_path.is_file():
|
|
35
|
-
return {}
|
|
36
|
-
values: dict[str, str] = {}
|
|
37
|
-
for raw_line in dotenv_path.read_text(encoding="utf-8").splitlines():
|
|
38
|
-
line = raw_line.strip()
|
|
39
|
-
if not line or line.startswith("#") or "=" not in line:
|
|
40
|
-
continue
|
|
41
|
-
key, value = line.split("=", 1)
|
|
42
|
-
values[key.strip()] = value.strip().strip("'\"")
|
|
43
|
-
return values
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def _split_base_url(base_url: str) -> tuple[str, str, int]:
|
|
47
|
-
parts = urlsplit(base_url)
|
|
48
|
-
protocol = parts.scheme
|
|
49
|
-
host = parts.hostname
|
|
50
|
-
if not protocol or not host:
|
|
51
|
-
raise MissingClientEndpointError(
|
|
52
|
-
f"invalid PLAN_MANAGER_BASE_URL/base_url {base_url!r}: protocol and host are required"
|
|
53
|
-
)
|
|
54
|
-
port = parts.port
|
|
55
|
-
if port is None:
|
|
56
|
-
if protocol == "https":
|
|
57
|
-
port = 443
|
|
58
|
-
elif protocol == "http":
|
|
59
|
-
port = 80
|
|
60
|
-
else:
|
|
61
|
-
raise MissingClientEndpointError(
|
|
62
|
-
f"invalid PLAN_MANAGER_BASE_URL/base_url {base_url!r}: explicit port is required for protocol {protocol!r}"
|
|
63
|
-
)
|
|
64
|
-
return protocol, host, port
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def resolve_endpoint_sources(
|
|
68
|
-
*,
|
|
69
|
-
base_url: str | None = None,
|
|
70
|
-
protocol: str | None = None,
|
|
71
|
-
host: str | None = None,
|
|
72
|
-
port: int | str | None = None,
|
|
73
|
-
dotenv_path: str | Path | None = ".env",
|
|
74
|
-
) -> tuple[str, str, int]:
|
|
75
|
-
"""Resolve endpoint as CLI values, then environment, then dotenv.
|
|
76
|
-
|
|
77
|
-
No default endpoint is invented. A caller that supplies neither a complete
|
|
78
|
-
URL nor a complete protocol/host/port triple gets a precise configuration
|
|
79
|
-
error instead of silently targeting localhost or a fleet host.
|
|
80
|
-
"""
|
|
81
|
-
dotenv = _read_dotenv(dotenv_path)
|
|
82
|
-
|
|
83
|
-
def _source(name: str, explicit: Any) -> Any:
|
|
84
|
-
if explicit not in (None, ""):
|
|
85
|
-
return explicit
|
|
86
|
-
env_name = ENDPOINT_ENV_NAMES[name]
|
|
87
|
-
env_value = os.environ.get(env_name)
|
|
88
|
-
if env_value not in (None, ""):
|
|
89
|
-
return env_value
|
|
90
|
-
return dotenv.get(env_name)
|
|
91
|
-
|
|
92
|
-
if base_url not in (None, ""):
|
|
93
|
-
return _split_base_url(str(base_url))
|
|
94
|
-
|
|
95
|
-
explicit_triple = any(value not in (None, "") for value in (protocol, host, port))
|
|
96
|
-
if explicit_triple:
|
|
97
|
-
dotenv = _read_dotenv(dotenv_path)
|
|
98
|
-
|
|
99
|
-
def _non_base_source(name: str, explicit: Any) -> Any:
|
|
100
|
-
if explicit not in (None, ""):
|
|
101
|
-
return explicit
|
|
102
|
-
env_name = ENDPOINT_ENV_NAMES[name]
|
|
103
|
-
env_value = os.environ.get(env_name)
|
|
104
|
-
if env_value not in (None, ""):
|
|
105
|
-
return env_value
|
|
106
|
-
return dotenv.get(env_name)
|
|
107
|
-
|
|
108
|
-
effective_protocol = _non_base_source("protocol", protocol)
|
|
109
|
-
effective_host = _non_base_source("host", host)
|
|
110
|
-
effective_port = _non_base_source("port", port)
|
|
111
|
-
else:
|
|
112
|
-
effective_base_url = _source("base_url", None)
|
|
113
|
-
if effective_base_url:
|
|
114
|
-
return _split_base_url(str(effective_base_url))
|
|
115
|
-
effective_protocol = _source("protocol", protocol)
|
|
116
|
-
effective_host = _source("host", host)
|
|
117
|
-
effective_port = _source("port", port)
|
|
118
|
-
missing = [
|
|
119
|
-
name for name, value in (
|
|
120
|
-
("protocol", effective_protocol),
|
|
121
|
-
("host", effective_host),
|
|
122
|
-
("port", effective_port),
|
|
123
|
-
)
|
|
124
|
-
if value in (None, "")
|
|
125
|
-
]
|
|
126
|
-
if missing:
|
|
127
|
-
raise MissingClientEndpointError(
|
|
128
|
-
"missing Plan Manager endpoint configuration: provide --base-url or "
|
|
129
|
-
"--protocol/--host/--port, or set PLAN_MANAGER_BASE_URL, or set "
|
|
130
|
-
f"{', '.join(ENDPOINT_ENV_NAMES[name] for name in missing)} in the environment/.env"
|
|
131
|
-
)
|
|
132
|
-
try:
|
|
133
|
-
parsed_port = int(effective_port)
|
|
134
|
-
except (TypeError, ValueError) as exc:
|
|
135
|
-
raise MissingClientEndpointError(f"invalid PLAN_MANAGER_PORT/port {effective_port!r}") from exc
|
|
136
|
-
return str(effective_protocol), str(effective_host), parsed_port
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
@dataclass(frozen=True)
|
|
140
|
-
class ClientConnectionConfig:
|
|
141
|
-
"""Direct-connection parameters for one JSON-RPC server.
|
|
142
|
-
|
|
143
|
-
Mirrors, field for field, the constructor of
|
|
144
|
-
mcp_proxy_adapter.client.jsonrpc_client.client.JsonRpcClient:
|
|
145
|
-
|
|
146
|
-
def __init__(
|
|
147
|
-
self,
|
|
148
|
-
protocol: str = "http",
|
|
149
|
-
host: str = "127.0.0.1",
|
|
150
|
-
port: int = 8080,
|
|
151
|
-
token_header: Optional[str] = None,
|
|
152
|
-
token: Optional[str] = None,
|
|
153
|
-
cert: Optional[str] = None,
|
|
154
|
-
key: Optional[str] = None,
|
|
155
|
-
ca: Optional[str] = None,
|
|
156
|
-
check_hostname: bool = False,
|
|
157
|
-
timeout: Optional[float] = None,
|
|
158
|
-
) -> None: ...
|
|
159
|
-
|
|
160
|
-
Instances are immutable. Use to_jsonrpc_kwargs() to build the keyword
|
|
161
|
-
arguments for JsonRpcClient(**kwargs) or for any other client built on the
|
|
162
|
-
same constructor shape (for example a code-analysis-client construction
|
|
163
|
-
helper), so one configuration entity serves either server.
|
|
164
|
-
"""
|
|
165
|
-
|
|
166
|
-
protocol: str = "http"
|
|
167
|
-
host: str = "127.0.0.1"
|
|
168
|
-
port: int = 8080
|
|
169
|
-
token_header: Optional[str] = None
|
|
170
|
-
token: Optional[str] = None
|
|
171
|
-
cert: Optional[str] = None
|
|
172
|
-
key: Optional[str] = None
|
|
173
|
-
ca: Optional[str] = None
|
|
174
|
-
check_hostname: bool = False
|
|
175
|
-
timeout: Optional[float] = None
|
|
176
|
-
|
|
177
|
-
@classmethod
|
|
178
|
-
def from_sources(
|
|
179
|
-
cls,
|
|
180
|
-
*,
|
|
181
|
-
base_url: str | None = None,
|
|
182
|
-
protocol: str | None = None,
|
|
183
|
-
host: str | None = None,
|
|
184
|
-
port: int | str | None = None,
|
|
185
|
-
timeout: Optional[float] = None,
|
|
186
|
-
env_prefix: str = "PLANMGR_CLIENT_",
|
|
187
|
-
dotenv_path: str | Path | None = ".env",
|
|
188
|
-
) -> "ClientConnectionConfig":
|
|
189
|
-
"""Resolve endpoint config with CLI > environment > .env precedence."""
|
|
190
|
-
dotenv = _read_dotenv(dotenv_path)
|
|
191
|
-
|
|
192
|
-
def source(name: str, cli_value: Any = None) -> Any:
|
|
193
|
-
if cli_value not in (None, ""):
|
|
194
|
-
return cli_value
|
|
195
|
-
env_name = f"{env_prefix}{name}"
|
|
196
|
-
env_value = os.environ.get(env_name)
|
|
197
|
-
if env_value not in (None, ""):
|
|
198
|
-
return env_value
|
|
199
|
-
value = dotenv.get(env_name)
|
|
200
|
-
if value not in (None, ""):
|
|
201
|
-
return value
|
|
202
|
-
return None
|
|
203
|
-
|
|
204
|
-
resolved_base_url = source("BASE_URL", base_url)
|
|
205
|
-
resolved_timeout = timeout
|
|
206
|
-
if resolved_timeout is None and source("TIMEOUT") is not None:
|
|
207
|
-
resolved_timeout = float(source("TIMEOUT"))
|
|
208
|
-
if resolved_base_url:
|
|
209
|
-
return cls.from_base_url(
|
|
210
|
-
str(resolved_base_url),
|
|
211
|
-
timeout=resolved_timeout,
|
|
212
|
-
env_prefix=env_prefix,
|
|
213
|
-
dotenv_path=dotenv_path,
|
|
214
|
-
)
|
|
215
|
-
resolved_protocol = source("PROTOCOL", protocol)
|
|
216
|
-
resolved_host = source("HOST", host)
|
|
217
|
-
resolved_port = source("PORT", port)
|
|
218
|
-
missing = [
|
|
219
|
-
name
|
|
220
|
-
for name, value in (("protocol", resolved_protocol), ("host", resolved_host), ("port", resolved_port))
|
|
221
|
-
if value in (None, "")
|
|
222
|
-
]
|
|
223
|
-
if missing:
|
|
224
|
-
joined = ", ".join(missing)
|
|
225
|
-
raise MissingClientEndpointError(f"missing required client endpoint value(s): {joined}")
|
|
226
|
-
cert = source("CERT")
|
|
227
|
-
key = source("KEY")
|
|
228
|
-
actual_protocol = str(resolved_protocol)
|
|
229
|
-
if actual_protocol == "https" and cert and key:
|
|
230
|
-
actual_protocol = "mtls"
|
|
231
|
-
return cls(
|
|
232
|
-
protocol=actual_protocol,
|
|
233
|
-
host=str(resolved_host),
|
|
234
|
-
port=int(resolved_port),
|
|
235
|
-
token_header=source("TOKEN_HEADER"),
|
|
236
|
-
token=source("TOKEN"),
|
|
237
|
-
cert=cert,
|
|
238
|
-
key=key,
|
|
239
|
-
ca=source("CA"),
|
|
240
|
-
check_hostname=False,
|
|
241
|
-
timeout=resolved_timeout,
|
|
242
|
-
)
|
|
243
|
-
|
|
244
|
-
@classmethod
|
|
245
|
-
def from_base_url(
|
|
246
|
-
cls,
|
|
247
|
-
base_url: str,
|
|
248
|
-
*,
|
|
249
|
-
timeout: Optional[float] = None,
|
|
250
|
-
env_prefix: str = "PLANMGR_CLIENT_",
|
|
251
|
-
dotenv_path: str | Path | None = ".env",
|
|
252
|
-
) -> "ClientConnectionConfig":
|
|
253
|
-
"""Build direct-connection configuration from a server base URL.
|
|
254
|
-
|
|
255
|
-
URL parsing and TLS/token environment handling live in the public
|
|
256
|
-
client package so pipeline callers do not implement transport logic.
|
|
257
|
-
"""
|
|
258
|
-
dotenv = _read_dotenv(dotenv_path)
|
|
259
|
-
|
|
260
|
-
def optional(name: str) -> str | None:
|
|
261
|
-
env_name = f"{env_prefix}{name}"
|
|
262
|
-
value = os.environ.get(env_name) or dotenv.get(env_name)
|
|
263
|
-
if value:
|
|
264
|
-
return value
|
|
265
|
-
return None
|
|
266
|
-
|
|
267
|
-
parsed = urlsplit(base_url)
|
|
268
|
-
protocol = parsed.scheme or optional("PROTOCOL")
|
|
269
|
-
host = parsed.hostname or optional("HOST")
|
|
270
|
-
port = parsed.port or optional("PORT")
|
|
271
|
-
missing = [
|
|
272
|
-
name
|
|
273
|
-
for name, value in (("protocol", protocol), ("host", host), ("port", port))
|
|
274
|
-
if value in (None, "")
|
|
275
|
-
]
|
|
276
|
-
if missing:
|
|
277
|
-
joined = ", ".join(missing)
|
|
278
|
-
raise MissingClientEndpointError(f"missing required client endpoint value(s): {joined}")
|
|
279
|
-
cert = optional("CERT")
|
|
280
|
-
key = optional("KEY")
|
|
281
|
-
if protocol == "https" and cert and key:
|
|
282
|
-
protocol = "mtls"
|
|
283
|
-
timeout_value = timeout
|
|
284
|
-
timeout_from_sources = optional("TIMEOUT")
|
|
285
|
-
if timeout_value is None and timeout_from_sources:
|
|
286
|
-
timeout_value = float(timeout_from_sources)
|
|
287
|
-
return cls(
|
|
288
|
-
protocol=str(protocol),
|
|
289
|
-
host=str(host),
|
|
290
|
-
port=int(port),
|
|
291
|
-
token_header=optional("TOKEN_HEADER"),
|
|
292
|
-
token=optional("TOKEN"),
|
|
293
|
-
cert=cert,
|
|
294
|
-
key=key,
|
|
295
|
-
ca=optional("CA"),
|
|
296
|
-
check_hostname=False,
|
|
297
|
-
timeout=timeout_value,
|
|
298
|
-
)
|
|
299
|
-
|
|
300
|
-
def to_jsonrpc_kwargs(self) -> dict[str, Any]:
|
|
301
|
-
"""Return constructor kwargs for JsonRpcClient(**kwargs)."""
|
|
302
|
-
return {
|
|
303
|
-
"protocol": self.protocol,
|
|
304
|
-
"host": self.host,
|
|
305
|
-
"port": self.port,
|
|
306
|
-
"token_header": self.token_header,
|
|
307
|
-
"token": self.token,
|
|
308
|
-
"cert": self.cert,
|
|
309
|
-
"key": self.key,
|
|
310
|
-
"ca": self.ca,
|
|
311
|
-
"check_hostname": self.check_hostname,
|
|
312
|
-
"timeout": self.timeout,
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
__all__ = [
|
|
317
|
-
"ClientConnectionConfig",
|
|
318
|
-
"MissingClientEndpointError",
|
|
319
|
-
"resolve_endpoint_sources",
|
|
320
|
-
]
|
{plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/__init__.py
RENAMED
|
File without changes
|
{plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/_version.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/dispatch.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{plan_manager_client_dev-0.2.238 → plan_manager_client_dev-0.2.239}/plan_manager_client/id_rule.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|