@senpi-ai/runtime 3.0.4 → 3.0.5

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.
@@ -51,6 +51,8 @@ import json
51
51
  import threading
52
52
  from typing import Any, Iterable, Optional
53
53
 
54
+ from .loop_primitives import log_event
55
+
54
56
 
55
57
  # --------------------------------------------------------------------------
56
58
  # Producer MCP write boundary — read-only by default.
@@ -135,24 +137,40 @@ class SenpiMcpClient:
135
137
 
136
138
  Raises (loud, never a silent None) when the tool is a money/state
137
139
  mutation not on the write allowlist, when creds are missing, or when the
138
- tool reports `isError`.
140
+ tool reports `isError`. EVERY failure is logged (a `senpi_mcp_error`
141
+ scaffold event) before it is re-raised, so even when the author's scan()
142
+ swallows the exception in its own try/except, the failure still leaves a
143
+ visible record at this boundary instead of vanishing into an empty result.
139
144
  """
140
- # Read-only producer boundary, enforced PRE-CONNECT (no transport opened
141
- # for a blocked write). A mutation tool passes only if its exact name is
142
- # on the write allowlist (least privilege — one tool ≠ all).
143
- if name in MUTATION_TOOLS and name not in self._write_allowlist:
144
- raise PermissionError(
145
- f'senpi_mcp: tool "{name}" is a money/state-mutating MCP tool and '
146
- "is blocked — producers are READ-ONLY by default. The ONLY way to "
147
- f'permit it is to add "{name}" to the PRODUCER_WRITE_ALLOWLIST '
148
- "frozenset in src/scanners/external/scaffold/senpi_mcp.py "
149
- "(scaffold-maintainer-owned source; not operator/env-configurable; "
150
- "not reachable by authored producer code)."
151
- )
145
+ try:
146
+ # Read-only producer boundary, enforced PRE-CONNECT (no transport
147
+ # opened for a blocked write). A mutation tool passes only if its exact
148
+ # name is on the write allowlist (least privilege — one tool ≠ all).
149
+ if name in MUTATION_TOOLS and name not in self._write_allowlist:
150
+ raise PermissionError(
151
+ f'senpi_mcp: tool "{name}" is a money/state-mutating MCP tool and '
152
+ "is blocked — producers are READ-ONLY by default. The ONLY way to "
153
+ f'permit it is to add "{name}" to the PRODUCER_WRITE_ALLOWLIST '
154
+ "frozenset in src/scanners/external/scaffold/senpi_mcp.py "
155
+ "(scaffold-maintainer-owned source; not operator/env-configurable; "
156
+ "not reachable by authored producer code)."
157
+ )
152
158
 
153
- self._ensure_connected()
154
- result = self._run(self._session.call_tool(name, arguments=args))
155
- return self._unwrap(name, result)
159
+ self._ensure_connected()
160
+ result = self._run(self._session.call_tool(name, arguments=args))
161
+ return self._unwrap(name, result)
162
+ except Exception as exc:
163
+ # Catch every failure — mutation block, missing creds, the lazy
164
+ # `import mcp`, transport errors, tool `isError` — log it, then re-raise
165
+ # to the author's scan(). Scoped to Exception so a tick timeout
166
+ # (_TickTimeout, a BaseException) still unwinds the tick untouched.
167
+ log_event(
168
+ "senpi_mcp_error",
169
+ tool=name,
170
+ error_type=type(exc).__name__,
171
+ error=str(exc)[:500],
172
+ )
173
+ raise
156
174
 
157
175
  # -- persistent session lifecycle -------------------------------------
158
176
 
@@ -2,7 +2,7 @@
2
2
  "id": "runtime",
3
3
  "name": "Senpi Runtime",
4
4
  "description": "Senpi runtime plugin for OpenClaw. Orchestrates scanners, LLM-based trade decisions, and a DSL trailing stop-loss exit engine.",
5
- "version": "3.0.4",
5
+ "version": "3.0.5",
6
6
  "commandAliases": [
7
7
  {
8
8
  "name": "senpi"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@senpi-ai/runtime",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "Senpi runtime plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",