node-mantis 0.1.0__py3-none-win_amd64.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.
nodemantis/browser.py ADDED
@@ -0,0 +1,45 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Optional
5
+
6
+
7
+ @dataclass(frozen=True)
8
+ class BrowserCheckResult:
9
+ available: bool
10
+ error: Optional[str] = None
11
+
12
+
13
+ async def check_chrome() -> BrowserCheckResult:
14
+ """Open and close a real NodeMantis session: the runtime launches Chrome.
15
+
16
+ A navigation-only session needs no API key and makes no hosted-API calls.
17
+ """
18
+ from .session import NodeMantis
19
+
20
+ try:
21
+ mantis = await NodeMantis.start(_navigation_only=True, headless=True, shared_browser=False)
22
+ except Exception as exc: # noqa: BLE001 - surfaced as a user-facing diagnostic.
23
+ return BrowserCheckResult(available=False, error=str(exc))
24
+ await mantis.close()
25
+ return BrowserCheckResult(available=True)
26
+
27
+
28
+ def missing_chrome_message(details: Optional[str] = None) -> str:
29
+ message = "\n".join(
30
+ [
31
+ "Google Chrome was not found or could not be launched. "
32
+ "NodeMantis drives your installed Google Chrome.",
33
+ "Install it:",
34
+ " macOS: brew install --cask google-chrome "
35
+ "(or download from https://www.google.com/chrome/)",
36
+ " Windows: download from https://www.google.com/chrome/",
37
+ " Linux: download google-chrome-stable_current_amd64.deb from "
38
+ "https://www.google.com/chrome/ and run: "
39
+ "sudo apt install ./google-chrome-stable_current_amd64.deb",
40
+ "Or set CHROME_PATH to an existing Chrome executable.",
41
+ ]
42
+ )
43
+ if details:
44
+ message += f"\n\nDetails:\n{details}"
45
+ return message
nodemantis/cli.py ADDED
@@ -0,0 +1,236 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import asyncio
5
+ import inspect
6
+ import json
7
+ import re
8
+ import sys
9
+ from pathlib import Path
10
+
11
+ from .browser import check_chrome, missing_chrome_message
12
+ from .config import ConfigFile, mask_secret, read_config_file, resolve_config, write_config_file
13
+ from .runtime import broker_hello, runtime_platform_info
14
+ from .smoke import run_smoke
15
+ from .session import NodeMantis
16
+
17
+
18
+ def main(argv: list[str] | None = None) -> int:
19
+ parser = argparse.ArgumentParser(prog="nodemantis")
20
+ parser.add_argument("-V", "--version", action="version", version="nodemantis 0.1.0")
21
+ subparsers = parser.add_subparsers(dest="command", required=True)
22
+
23
+ configure = subparsers.add_parser("configure", help="write NodeMantis API credentials")
24
+ configure.add_argument("-k", "--api-key")
25
+ configure.add_argument("-a", "--auth-token")
26
+ configure.add_argument("-f", "--config")
27
+ configure.set_defaults(func=_configure)
28
+
29
+ doctor = subparsers.add_parser("doctor", help="check config, platform runtime, and Google Chrome")
30
+ doctor.add_argument("-k", "--api-key")
31
+ doctor.add_argument("-j", "--json", action="store_true")
32
+ doctor.set_defaults(func=_doctor)
33
+
34
+ smoke = subparsers.add_parser("smoke", help="run a customer installation smoke test")
35
+ smoke.add_argument("-k", "--api-key")
36
+ smoke.add_argument("-H", "--headed", action="store_true")
37
+ smoke.add_argument("--skip-backend", action="store_true", help="skip backend probe; intended for package tests only")
38
+ smoke.set_defaults(func=_smoke)
39
+
40
+ for command in ("run", "retrieve"):
41
+ task = subparsers.add_parser(command, help="complete a browser goal" if command == "run" else "read data from a page")
42
+ task.add_argument("prompt")
43
+ task.add_argument("-u", "--url", required=command == "retrieve")
44
+ task.add_argument("-k", "--api-key")
45
+ task.add_argument("-H", "--headed", action="store_true")
46
+ task.add_argument("-v", "--viewport", type=_viewport)
47
+ task.add_argument("-P", "--use-proxy", action="store_true", default=None)
48
+ task.add_argument("-l", "--log-level", choices=("off", "info", "debug"))
49
+ task.add_argument("-d", "--debug", action="store_true")
50
+ task.add_argument("-j", "--json", action="store_true")
51
+ task.add_argument("-q", "--quiet", action="store_true")
52
+ task.add_argument("-s", "--schema", type=_schema)
53
+ task.add_argument("-e", "--effort", choices=("low", "medium", "high", "xhigh"))
54
+ if command == "run":
55
+ task.add_argument("-n", "--max-iterations", type=int)
56
+ task.add_argument("-t", "--timeout-ms", type=int)
57
+ task.add_argument("-c", "--max-cost", type=float)
58
+ task.add_argument("--mock-llm", type=_schema, help=argparse.SUPPRESS)
59
+ task.set_defaults(func=_agent)
60
+
61
+ argv = list(sys.argv[1:] if argv is None else argv)
62
+ if argv and argv[0] in ("-p", "--prompt"):
63
+ argv[0] = "run"
64
+ args = parser.parse_args(argv)
65
+ try:
66
+ result = args.func(args)
67
+ return int((asyncio.run(result) if inspect.isawaitable(result) else result) or 0)
68
+ except Exception as exc: # noqa: BLE001 - CLI boundary.
69
+ if getattr(args, "json", False):
70
+ error = {"message": str(exc)}
71
+ if getattr(exc, "code", None):
72
+ error["code"] = exc.code
73
+ print(json.dumps({"error": error}))
74
+ else:
75
+ print(str(exc), file=sys.stderr)
76
+ return 1
77
+ except KeyboardInterrupt:
78
+ return 130
79
+
80
+
81
+ def _viewport(value: str) -> dict[str, int]:
82
+ match = re.fullmatch(r"([1-9][0-9]*)[xX]([1-9][0-9]*)", value)
83
+ if not match:
84
+ raise argparse.ArgumentTypeError("viewport must be WIDTHxHEIGHT, e.g. 1280x800")
85
+ return {"width": int(match[1]), "height": int(match[2])}
86
+
87
+
88
+ def _schema(value: str) -> dict:
89
+ try:
90
+ source = value if value.lstrip().startswith("{") else Path(value).read_text(encoding="utf-8")
91
+ schema = json.loads(source)
92
+ if not isinstance(schema, dict):
93
+ raise ValueError("expected a JSON object")
94
+ return schema
95
+ except (OSError, ValueError) as error:
96
+ raise argparse.ArgumentTypeError(str(error)) from error
97
+
98
+
99
+ def _cost(value: float | None) -> str:
100
+ return f"${value:.4f}" if value is not None else "unknown"
101
+
102
+
103
+ async def _agent(args: argparse.Namespace) -> int:
104
+ resolved = resolve_config(api_key=args.api_key)
105
+ if not args.prompt.strip() or not resolved.api_key:
106
+ message = "A non-empty prompt and API key are required. Set NODEMANTIS_API_KEY or run nodemantis configure."
107
+ if args.json:
108
+ print(json.dumps({"error": {"message": message}}))
109
+ else:
110
+ print(message, file=sys.stderr)
111
+ return 2
112
+ level = "debug" if args.debug else args.log_level
113
+
114
+ def progress(event):
115
+ if not args.quiet:
116
+ prefix = f"[{event.iteration}/{event.max_iterations}]" if event.max_iterations else f"[{event.iteration}]"
117
+ detail = " — ".join(part for part in (event.message, event.action) if part)
118
+ print(f"{prefix} {detail or 'working'}", file=sys.stderr)
119
+
120
+ async with await NodeMantis.start(
121
+ api_key=resolved.api_key, start_url=args.url, headless=not args.headed,
122
+ viewport=args.viewport, use_proxy=args.use_proxy,
123
+ logging={"level": level} if level else None,
124
+ ) as mantis:
125
+ if args.command == "run":
126
+ result = await mantis.run(
127
+ args.prompt, effort=args.effort, max_iterations=args.max_iterations,
128
+ timeout=args.timeout_ms, max_cost=args.max_cost, result_schema=args.schema,
129
+ mock_llm=args.mock_llm, on_progress=progress,
130
+ )
131
+ if args.json:
132
+ print(json.dumps(result.raw, indent=2))
133
+ else:
134
+ print(f"Result: {'success' if result.ok else 'failure'}")
135
+ print(f"Reason: {result.reason}")
136
+ if result.iterations is not None:
137
+ print(f"Iterations: {result.iterations}")
138
+ print(f"Cost: {_cost(result.cost_usd)}")
139
+ if result.value is not None:
140
+ print(f"Value: {json.dumps(result.value, indent=2)}")
141
+ if result.retrieval is not None:
142
+ print(f"Retrieval: {result.retrieval.status}")
143
+ print(f"Retrieval message: {result.retrieval.message}")
144
+ return 0 if result.ok else 1
145
+ result = await mantis.retrieve(args.prompt, schema=args.schema, effort=args.effort)
146
+ if args.json:
147
+ print(json.dumps(result.raw, indent=2))
148
+ else:
149
+ print(f"Status: {result.status}")
150
+ print(f"Message: {result.message}")
151
+ print(f"Cost: {_cost(result.cost_usd)}")
152
+ if result.status == "success":
153
+ print(f"Data: {json.dumps(result.data, indent=2)}")
154
+ else:
155
+ print(f"Retryable: {'yes' if result.retryable else 'no'}")
156
+ return 0 if result.status == "success" else 1
157
+
158
+
159
+ def _configure(args: argparse.Namespace) -> int:
160
+ existing = read_config_file(args.config)
161
+ credential = args.api_key or args.auth_token
162
+ if not credential and sys.stdin.isatty():
163
+ credential = input("NodeMantis API key: ").strip()
164
+
165
+ if args.api_key:
166
+ next_config = ConfigFile(api_key=args.api_key, auth_token=None)
167
+ elif args.auth_token:
168
+ next_config = ConfigFile(api_key=None, auth_token=args.auth_token)
169
+ elif credential:
170
+ next_config = ConfigFile(api_key=credential, auth_token=None)
171
+ else:
172
+ next_config = ConfigFile(
173
+ api_key=existing.api_key,
174
+ auth_token=existing.auth_token,
175
+ )
176
+
177
+ path = write_config_file(next_config, args.config)
178
+ resolved = resolve_config(config_path=path)
179
+ print(f"Wrote NodeMantis config: {resolved.config_path}")
180
+ print(f"API key: {mask_secret(resolved.api_key)}")
181
+ return 0
182
+
183
+
184
+ async def _doctor(args: argparse.Namespace) -> int:
185
+ resolved = resolve_config(api_key=args.api_key)
186
+ report: dict[str, object] = {
187
+ "configPath": str(resolved.config_path),
188
+ "apiKeySource": resolved.api_key_source or "missing",
189
+ "apiKey": mask_secret(resolved.api_key),
190
+ }
191
+
192
+ try:
193
+ report["platform"] = runtime_platform_info().__dict__
194
+ report["runtime"] = broker_hello()
195
+ except Exception as exc: # noqa: BLE001
196
+ report["runtimeError"] = str(exc)
197
+
198
+ browser_check = await check_chrome()
199
+ report["browser"] = {
200
+ "name": "chrome",
201
+ "available": browser_check.available,
202
+ "error": browser_check.error,
203
+ }
204
+
205
+ if args.json:
206
+ print(json.dumps(report, indent=2))
207
+ return 0
208
+
209
+ print(f"Config: {report['configPath']}")
210
+ source = f" ({resolved.api_key_source})" if resolved.api_key_source else ""
211
+ print(f"API key: {mask_secret(resolved.api_key)}{source}")
212
+ if "runtimeError" in report:
213
+ print(f"Runtime: failed - {report['runtimeError']}")
214
+ else:
215
+ print(f"Runtime: ok ({report['platform']})")
216
+ print(f"Browser: {'ok' if browser_check.available else 'missing'} (chrome)")
217
+ if not browser_check.available:
218
+ print(missing_chrome_message(browser_check.error))
219
+ return 0
220
+
221
+
222
+ async def _smoke(args: argparse.Namespace) -> int:
223
+ result = await run_smoke(
224
+ api_key=args.api_key,
225
+ headless=not args.headed,
226
+ skip_backend=args.skip_backend,
227
+ )
228
+ print("NodeMantis smoke passed.")
229
+ print(f"Hosted API: {'checked' if result.backend_checked else 'skipped'}")
230
+ print(f"Runtime: {result.runtime_platform}")
231
+ print(f"Assertion: {result.assertion}")
232
+ return 0
233
+
234
+
235
+ if __name__ == "__main__":
236
+ raise SystemExit(main())
nodemantis/config.py ADDED
@@ -0,0 +1,116 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import os
5
+ import platform
6
+ from dataclasses import dataclass
7
+ from pathlib import Path
8
+ from typing import Mapping, Optional
9
+
10
+
11
+ @dataclass(frozen=True)
12
+ class ConfigFile:
13
+ api_key: Optional[str] = None
14
+ auth_token: Optional[str] = None
15
+
16
+
17
+ @dataclass(frozen=True)
18
+ class ResolvedConfig:
19
+ api_key: Optional[str]
20
+ api_key_source: Optional[str]
21
+ config_path: Path
22
+ file_config: ConfigFile
23
+
24
+
25
+ def get_config_path(env: Mapping[str, str] | None = None) -> Path:
26
+ env = os.environ if env is None else env
27
+ override = _clean(env.get("NODEMANTIS_CONFIG_FILE"))
28
+ if override:
29
+ return Path(override)
30
+
31
+ home = Path.home()
32
+ system = platform.system().lower()
33
+ if system == "windows":
34
+ return Path(env.get("APPDATA", home / "AppData" / "Roaming")) / "nodemantis" / "config.json"
35
+ if system == "darwin":
36
+ return home / "Library" / "Application Support" / "nodemantis" / "config.json"
37
+ return Path(env.get("XDG_CONFIG_HOME", home / ".config")) / "nodemantis" / "config.json"
38
+
39
+
40
+ def read_config_file(config_path: Path | str | None = None) -> ConfigFile:
41
+ path = Path(config_path) if config_path else get_config_path()
42
+ if not path.exists():
43
+ return ConfigFile()
44
+
45
+ data = json.loads(path.read_text(encoding="utf-8") or "{}")
46
+ return ConfigFile(
47
+ api_key=_clean(data.get("apiKey") or data.get("api_key")),
48
+ auth_token=_clean(data.get("authToken") or data.get("auth_token")),
49
+ )
50
+
51
+
52
+ def write_config_file(config: ConfigFile, config_path: Path | str | None = None) -> Path:
53
+ path = Path(config_path) if config_path else get_config_path()
54
+ path.parent.mkdir(parents=True, exist_ok=True)
55
+ data = {
56
+ "apiKey": config.api_key,
57
+ "authToken": config.auth_token,
58
+ }
59
+ path.write_text(json.dumps({k: v for k, v in data.items() if v}, indent=2) + "\n", encoding="utf-8")
60
+ try:
61
+ path.chmod(0o600)
62
+ except OSError:
63
+ pass
64
+ return path
65
+
66
+
67
+ def resolve_config(
68
+ *,
69
+ api_key: str | None = None,
70
+ config_path: Path | str | None = None,
71
+ env: Mapping[str, str] | None = None,
72
+ ) -> ResolvedConfig:
73
+ env = os.environ if env is None else env
74
+ path = Path(config_path) if config_path else get_config_path(env)
75
+ file_config = read_config_file(path)
76
+
77
+ explicit_key = _clean(api_key)
78
+ env_api_key = _clean(env.get("NODEMANTIS_API_KEY"))
79
+ env_auth_token = _clean(env.get("NODEMANTIS_AUTH_TOKEN"))
80
+ legacy_key = _clean(env.get("AGENT_API_KEY"))
81
+ file_key = _clean(file_config.api_key) or _clean(file_config.auth_token)
82
+
83
+ if explicit_key:
84
+ resolved_key, key_source = explicit_key, "explicit"
85
+ elif env_api_key:
86
+ resolved_key, key_source = env_api_key, "NODEMANTIS_API_KEY"
87
+ elif env_auth_token:
88
+ resolved_key, key_source = env_auth_token, "NODEMANTIS_AUTH_TOKEN"
89
+ elif legacy_key:
90
+ resolved_key, key_source = legacy_key, "AGENT_API_KEY"
91
+ elif file_key:
92
+ resolved_key, key_source = file_key, "config"
93
+ else:
94
+ resolved_key, key_source = None, None
95
+
96
+ return ResolvedConfig(
97
+ api_key=resolved_key,
98
+ api_key_source=key_source,
99
+ config_path=path,
100
+ file_config=file_config,
101
+ )
102
+
103
+
104
+ def mask_secret(secret: str | None) -> str:
105
+ if not secret:
106
+ return "not configured"
107
+ if len(secret) <= 8:
108
+ return "configured"
109
+ return f"{secret[:4]}...{secret[-4:]}"
110
+
111
+
112
+ def _clean(value: object) -> Optional[str]:
113
+ if not isinstance(value, str):
114
+ return None
115
+ stripped = value.strip()
116
+ return stripped or None
nodemantis/errors.py ADDED
@@ -0,0 +1,203 @@
1
+ """Public exception hierarchy for the NodeMantis Python SDK.
2
+
3
+ Names and codes mirror the TypeScript SDK so cross-language docs and support
4
+ can speak about one set of failures.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from dataclasses import dataclass
10
+ from typing import Any, Optional
11
+
12
+
13
+ class NodeMantisError(Exception):
14
+ """Base class for every error raised by the NodeMantis SDK."""
15
+
16
+
17
+ class RuntimeRpcError(NodeMantisError):
18
+ """A JSON-RPC failure returned by (or about) the native runtime.
19
+
20
+ ``code`` is a string such as ``SESSION_BUSY`` or ``SCHEMA_UNSUPPORTED``
21
+ from the runtime, or a client-side code such as ``RPC_TIMEOUT``,
22
+ ``BAD_FRAME``, ``METHOD_NOT_FOUND``, ``HANDLER_ERROR``,
23
+ ``SERIALIZE_ERROR``, ``UNKNOWN_RESPONSE``.
24
+ """
25
+
26
+ def __init__(self, code: "str | int", message: str, data: Any = None) -> None:
27
+ super().__init__(message)
28
+ self.code = code
29
+ self.data = data
30
+
31
+ def __repr__(self) -> str: # pragma: no cover - debugging nicety
32
+ return f"RuntimeRpcError(code={self.code!r}, message={self.args[0]!r})"
33
+
34
+
35
+ class RetrievalRequestError(NodeMantisError):
36
+ """A retrieval request that did not complete.
37
+
38
+ The public code describes what a caller can do next. Internal model,
39
+ provider, and processing-stage diagnostics remain attached to ``trace_id``
40
+ in service logs.
41
+ """
42
+
43
+ def __init__(
44
+ self,
45
+ code: str,
46
+ message: str,
47
+ *,
48
+ retryable: bool,
49
+ trace_id: Optional[str] = None,
50
+ cost_usd: Optional[float] = None,
51
+ ) -> None:
52
+ super().__init__(message)
53
+ self.code = code
54
+ self.retryable = retryable
55
+ self.trace_id = trace_id
56
+ self.cost_usd = cost_usd
57
+
58
+
59
+ def as_retrieval_request_error(error: Exception) -> Optional[RetrievalRequestError]:
60
+ if not isinstance(error, RuntimeRpcError):
61
+ return None
62
+ runtime_code = str(error.code)
63
+ mappings = {
64
+ "BAD_REQUEST": ("INVALID_REQUEST", "The retrieval request is invalid.", False),
65
+ "SCHEMA_UNSUPPORTED": ("INVALID_REQUEST", "The retrieval request is invalid.", False),
66
+ "CAPABILITY_UNAVAILABLE": ("INVALID_REQUEST", "The retrieval request is invalid.", False),
67
+ "API_KEY_REQUIRED": (
68
+ "AUTHENTICATION_FAILED",
69
+ "Authentication or account access was denied.",
70
+ False,
71
+ ),
72
+ "AUTHENTICATION_FAILED": (
73
+ "AUTHENTICATION_FAILED",
74
+ "Authentication or account access was denied.",
75
+ False,
76
+ ),
77
+ "USAGE_LIMIT": ("USAGE_LIMIT", "The account usage limit was reached.", False),
78
+ "PAYMENT_REQUIRED": ("USAGE_LIMIT", "The account usage limit was reached.", False),
79
+ "ResponsibleAIPolicyViolation": ("REQUEST_BLOCKED", "The request was blocked.", False),
80
+ "REQUEST_BLOCKED": ("REQUEST_BLOCKED", "The request was blocked.", False),
81
+ "REQUEST_CANCELLED": ("CANCELLED", "The retrieval request was cancelled.", False),
82
+ "CANCELLED": ("CANCELLED", "The retrieval request was cancelled.", False),
83
+ "SERVICE_UNAVAILABLE": (
84
+ "SERVICE_UNAVAILABLE",
85
+ "The retrieval service is temporarily unavailable.",
86
+ True,
87
+ ),
88
+ "RETRIEVAL_ERROR": (
89
+ "SERVICE_UNAVAILABLE",
90
+ "The retrieval service is temporarily unavailable.",
91
+ True,
92
+ ),
93
+ "RPC_TIMEOUT": (
94
+ "SERVICE_UNAVAILABLE",
95
+ "The retrieval service is temporarily unavailable.",
96
+ True,
97
+ ),
98
+ "OPERATION_FAILED": (
99
+ "OPERATION_FAILED",
100
+ "The retrieval request could not be completed.",
101
+ True,
102
+ ),
103
+ "BROWSER_ERROR": (
104
+ "OPERATION_FAILED",
105
+ "The retrieval request could not be completed.",
106
+ True,
107
+ ),
108
+ "BRIDGE_ERROR": (
109
+ "OPERATION_FAILED",
110
+ "The retrieval request could not be completed.",
111
+ True,
112
+ ),
113
+ }
114
+ # Unknown native codes can name private processing stages or providers.
115
+ # Keep those details in trace-correlated logs and expose one stable error.
116
+ mapped = mappings.get(
117
+ runtime_code,
118
+ (
119
+ "OPERATION_FAILED",
120
+ "The retrieval request could not be completed.",
121
+ True,
122
+ ),
123
+ )
124
+ code, message, default_retryable = mapped
125
+ details = error.data if isinstance(error.data, dict) else {}
126
+ retryable = details.get("retryable")
127
+ return RetrievalRequestError(
128
+ code,
129
+ message,
130
+ retryable=retryable if isinstance(retryable, bool) else default_retryable,
131
+ trace_id=details.get("traceId") if isinstance(details.get("traceId"), str) else None,
132
+ cost_usd=(
133
+ details.get("costUsd")
134
+ if isinstance(details.get("costUsd"), (int, float))
135
+ and not isinstance(details.get("costUsd"), bool)
136
+ else None
137
+ ),
138
+ )
139
+
140
+
141
+ class RuntimeConnectionClosedError(NodeMantisError):
142
+ def __init__(self, message: str = "Native runtime connection closed") -> None:
143
+ super().__init__(message)
144
+
145
+
146
+ class RpcAbortedError(NodeMantisError):
147
+ """An in-flight RPC was aborted client-side (close or explicit abort)."""
148
+
149
+ def __init__(self, message: str = "RPC request aborted") -> None:
150
+ super().__init__(message)
151
+
152
+
153
+ @dataclass(frozen=True)
154
+ class RuntimeExit:
155
+ """How the runtime child process ended."""
156
+
157
+ code: Optional[int] = None
158
+ signal: Optional[int] = None
159
+ error: Optional[str] = None
160
+
161
+
162
+ class NativeRuntimeResolutionError(NodeMantisError):
163
+ """The runtime binary could not be resolved or validated.
164
+
165
+ Codes: ``UNSUPPORTED_PLATFORM``, ``RUNTIME_NOT_INSTALLED``,
166
+ ``INVALID_RUNTIME_PATH``, ``RUNTIME_CHECKSUM_MISMATCH``.
167
+ """
168
+
169
+ def __init__(self, code: str, message: str) -> None:
170
+ super().__init__(message)
171
+ self.code = code
172
+
173
+
174
+ class NativeRuntimeHandshakeError(NodeMantisError):
175
+ def __init__(self, message: str, stderr_tail: str = "") -> None:
176
+ super().__init__(message)
177
+ self.stderr_tail = stderr_tail
178
+
179
+
180
+ class NativeRuntimeExitedError(NodeMantisError):
181
+ def __init__(self, message: str, exit: RuntimeExit, stderr_tail: str = "") -> None:
182
+ super().__init__(message)
183
+ self.exit = exit
184
+ self.stderr_tail = stderr_tail
185
+
186
+
187
+ class NativeRuntimeTerminationError(NodeMantisError):
188
+ def __init__(self, message: str, stderr_tail: str = "") -> None:
189
+ super().__init__(message)
190
+ self.stderr_tail = stderr_tail
191
+
192
+
193
+ class SessionClosedError(NodeMantisError):
194
+ def __init__(self, message: str = "NodeMantis session is closed") -> None:
195
+ super().__init__(message)
196
+
197
+
198
+ class NavigationOnlyError(NodeMantisError):
199
+ def __init__(self, operation: str) -> None:
200
+ super().__init__(
201
+ f"{operation} is unavailable in a navigation-only session"
202
+ )
203
+ self.operation = operation
@@ -0,0 +1,22 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>NodeMantis CLI smoke</title>
6
+ <style>
7
+ body { font-family: system-ui, sans-serif; margin: 40px; }
8
+ button { font: inherit; padding: 8px 12px; }
9
+ #status { margin-top: 16px; font-weight: 700; }
10
+ </style>
11
+ </head>
12
+ <body>
13
+ <h1>NodeMantis Smoke Fixture</h1>
14
+ <button id="complete" type="button">Complete fixture</button>
15
+ <p id="status">waiting</p>
16
+ <script>
17
+ document.getElementById("complete").addEventListener("click", () => {
18
+ document.getElementById("status").textContent = "fixture success";
19
+ });
20
+ </script>
21
+ </body>
22
+ </html>