mashpy 0.2.2__tar.gz → 0.2.4__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.
Files changed (91) hide show
  1. {mashpy-0.2.2 → mashpy-0.2.4}/PKG-INFO +1 -1
  2. {mashpy-0.2.2 → mashpy-0.2.4}/pyproject.toml +1 -1
  3. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/logging/__init__.py +2 -1
  4. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/logging/trace_context.py +12 -1
  5. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/memory/compaction.py +24 -16
  6. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/runtime/runtime.py +33 -31
  7. {mashpy-0.2.2 → mashpy-0.2.4}/src/mashpy.egg-info/PKG-INFO +1 -1
  8. {mashpy-0.2.2 → mashpy-0.2.4}/README.md +0 -0
  9. {mashpy-0.2.2 → mashpy-0.2.4}/setup.cfg +0 -0
  10. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/__init__.py +0 -0
  11. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/agents/__init__.py +0 -0
  12. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/agents/masher/__init__.py +0 -0
  13. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/agents/masher/spec.py +0 -0
  14. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/agents/masher/tool.py +0 -0
  15. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/api/__init__.py +0 -0
  16. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/api/app.py +0 -0
  17. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/api/config.py +0 -0
  18. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/api/main.py +0 -0
  19. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/api/static/telemetry/assets/index-BO7oh6gk.css +0 -0
  20. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/api/static/telemetry/assets/index-CGIrz-UH.js +0 -0
  21. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/api/static/telemetry/index.html +0 -0
  22. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/api/telemetry_ui.py +0 -0
  23. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/api/types.py +0 -0
  24. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/cli/__init__.py +0 -0
  25. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/cli/chain_renderer.py +0 -0
  26. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/cli/client.py +0 -0
  27. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/cli/commands.py +0 -0
  28. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/cli/config.py +0 -0
  29. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/cli/default_commands.py +0 -0
  30. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/cli/main.py +0 -0
  31. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/cli/render.py +0 -0
  32. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/cli/repl.py +0 -0
  33. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/cli/shell.py +0 -0
  34. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/cli/types.py +0 -0
  35. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/core/__init__.py +0 -0
  36. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/core/agent.py +0 -0
  37. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/core/config.py +0 -0
  38. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/core/context.py +0 -0
  39. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/core/llm/__init__.py +0 -0
  40. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/core/llm/anthropic.py +0 -0
  41. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/core/llm/base.py +0 -0
  42. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/core/llm/openai.py +0 -0
  43. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/core/llm/types.py +0 -0
  44. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/core/llm/utils.py +0 -0
  45. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/logging/events.py +0 -0
  46. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/logging/logger.py +0 -0
  47. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/mcp/__init__.py +0 -0
  48. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/mcp/client.py +0 -0
  49. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/mcp/host.py +0 -0
  50. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/mcp/manager.py +0 -0
  51. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/mcp/server.py +0 -0
  52. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/mcp/types.py +0 -0
  53. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/memory/__init__.py +0 -0
  54. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/memory/search/__init__.py +0 -0
  55. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/memory/search/parser.py +0 -0
  56. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/memory/search/rerank.py +0 -0
  57. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/memory/search/retrieval.py +0 -0
  58. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/memory/search/service.py +0 -0
  59. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/memory/search/types.py +0 -0
  60. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/memory/signals.py +0 -0
  61. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/memory/store/__init__.py +0 -0
  62. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/memory/store/backends/__init__.py +0 -0
  63. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/memory/store/backends/sqlite/__init__.py +0 -0
  64. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/memory/store/backends/sqlite/store.py +0 -0
  65. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/memory/store/protocol.py +0 -0
  66. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/runtime/__init__.py +0 -0
  67. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/runtime/client.py +0 -0
  68. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/runtime/errors.py +0 -0
  69. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/runtime/host.py +0 -0
  70. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/runtime/server.py +0 -0
  71. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/runtime/session.py +0 -0
  72. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/runtime/spec.py +0 -0
  73. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/runtime/types.py +0 -0
  74. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/skills/__init__.py +0 -0
  75. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/skills/base.py +0 -0
  76. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/skills/registry.py +0 -0
  77. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/skills/tool.py +0 -0
  78. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/testing/__init__.py +0 -0
  79. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/testing/runtime_fixtures.py +0 -0
  80. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/tools/__init__.py +0 -0
  81. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/tools/base.py +0 -0
  82. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/tools/bash.py +0 -0
  83. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/tools/mcp.py +0 -0
  84. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/tools/registry.py +0 -0
  85. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/tools/runtime.py +0 -0
  86. {mashpy-0.2.2 → mashpy-0.2.4}/src/mash/tools/subagent.py +0 -0
  87. {mashpy-0.2.2 → mashpy-0.2.4}/src/mashpy.egg-info/SOURCES.txt +0 -0
  88. {mashpy-0.2.2 → mashpy-0.2.4}/src/mashpy.egg-info/dependency_links.txt +0 -0
  89. {mashpy-0.2.2 → mashpy-0.2.4}/src/mashpy.egg-info/entry_points.txt +0 -0
  90. {mashpy-0.2.2 → mashpy-0.2.4}/src/mashpy.egg-info/requires.txt +0 -0
  91. {mashpy-0.2.2 → mashpy-0.2.4}/src/mashpy.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mashpy
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: SDK for building hosted multi-agent Mash applications.
5
5
  Author: imsid
6
6
  License: Proprietary
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mashpy"
3
- version = "0.2.2"
3
+ version = "0.2.4"
4
4
  description = "SDK for building hosted multi-agent Mash applications."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -10,7 +10,7 @@ from .events import (
10
10
  MCPEvent,
11
11
  )
12
12
  from .logger import EventLogger
13
- from .trace_context import clear_trace_id, get_trace_id, set_trace_id
13
+ from .trace_context import bound_trace_id, clear_trace_id, get_trace_id, set_trace_id
14
14
 
15
15
  __all__ = [
16
16
  "LogEvent",
@@ -21,6 +21,7 @@ __all__ = [
21
21
  "MemorySearchEvent",
22
22
  "DebugEvent",
23
23
  "EventLogger",
24
+ "bound_trace_id",
24
25
  "set_trace_id",
25
26
  "get_trace_id",
26
27
  "clear_trace_id",
@@ -3,7 +3,8 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import contextvars
6
- from typing import Optional
6
+ from contextlib import contextmanager
7
+ from typing import Iterator, Optional
7
8
 
8
9
  _trace_id: contextvars.ContextVar[str | None] = contextvars.ContextVar(
9
10
  "mash_trace_id",
@@ -24,3 +25,13 @@ def get_trace_id() -> Optional[str]:
24
25
  def clear_trace_id() -> None:
25
26
  """Clear the trace ID for the current task context."""
26
27
  _trace_id.set(None)
28
+
29
+
30
+ @contextmanager
31
+ def bound_trace_id(trace_id: Optional[str]) -> Iterator[None]:
32
+ """Temporarily bind a trace ID for the current task context."""
33
+ token = _trace_id.set(trace_id)
34
+ try:
35
+ yield
36
+ finally:
37
+ _trace_id.reset(token)
@@ -7,6 +7,7 @@ from typing import Any, Dict, List, Tuple
7
7
 
8
8
  from ..core.llm import LLMProvider
9
9
  from ..core.llm.types import LLMContentBlock, LLMMessage, LLMRequest
10
+ from ..logging import bound_trace_id
10
11
  from .store import MemoryStore
11
12
 
12
13
  COMPACTION_SYSTEM_PROMPT = """You are a conversation compactor.
@@ -75,23 +76,31 @@ async def compact_conversation(
75
76
  if not lines:
76
77
  return "", ""
77
78
 
79
+ trace_id = str(uuid.uuid4())
78
80
  conversation_text = "\n".join(lines)
79
- response = await llm.send(
80
- LLMRequest(
81
- model=llm.model,
82
- system=COMPACTION_SYSTEM_PROMPT,
83
- messages=[
84
- LLMMessage(
85
- role="user",
86
- content=[LLMContentBlock.text(conversation_text)],
81
+ if hasattr(llm, "set_trace_id"):
82
+ llm.set_trace_id(trace_id)
83
+ try:
84
+ with bound_trace_id(trace_id):
85
+ response = await llm.send(
86
+ LLMRequest(
87
+ model=llm.model,
88
+ system=COMPACTION_SYSTEM_PROMPT,
89
+ messages=[
90
+ LLMMessage(
91
+ role="user",
92
+ content=[LLMContentBlock.text(conversation_text)],
93
+ )
94
+ ],
95
+ tools=[],
96
+ max_tokens=max_tokens,
97
+ temperature=temperature,
98
+ use_prompt_caching=False,
87
99
  )
88
- ],
89
- tools=[],
90
- max_tokens=max_tokens,
91
- temperature=temperature,
92
- use_prompt_caching=False,
93
- )
94
- )
100
+ )
101
+ finally:
102
+ if hasattr(llm, "set_trace_id"):
103
+ llm.set_trace_id(None)
95
104
  summary_text = response.text.strip()
96
105
 
97
106
  metadata: Dict[str, Any] = {
@@ -102,7 +111,6 @@ async def compact_conversation(
102
111
  "app_id": app_id,
103
112
  "token_usage": {"input": 0, "output": 0},
104
113
  }
105
- trace_id = str(uuid.uuid4())
106
114
  turn_id = await store.save_turn(
107
115
  trace_id=trace_id,
108
116
  session_id=session_id,
@@ -223,38 +223,40 @@ class MashAgentRuntime:
223
223
  manager = self.mcp_manager
224
224
  try:
225
225
  for server in mcp_servers:
226
- manager.add_server(
227
- name=server.name,
228
- url=server.url,
229
- description=server.description,
230
- headers=server.headers,
231
- allowed_tools=server.allowed_tools,
232
- auto_connect=True,
233
- )
234
- mcp_tools = manager.get_flattened_tools(prefix="mcp_")
235
- for mcp_tool in mcp_tools:
236
- server_name = mcp_tool.get("metadata", {}).get("server")
237
- original_name = mcp_tool.get("metadata", {}).get("original_name")
238
- if not server_name or not original_name:
239
- continue
240
-
241
- def make_executor(srv_name: str, tool_name: str):
242
- def executor(args):
243
- try:
244
- result = manager.call_tool(srv_name, tool_name, args)
245
- return extract_mcp_text(result)
246
- except Exception as exc: # pragma: no cover
247
- return f"Error: {exc}"
248
-
249
- return executor
250
-
251
- adapter = MCPToolAdapter.from_mcp_tool(
252
- mcp_tool=mcp_tool,
253
- executor=make_executor(server_name, original_name),
254
- prefix="",
226
+ if manager.get_server(server.name) is None:
227
+ manager.add_server(
228
+ name=server.name,
229
+ url=server.url,
230
+ description=server.description,
231
+ headers=server.headers,
232
+ allowed_tools=server.allowed_tools,
233
+ auto_connect=True,
255
234
  )
256
- if adapter.name not in agent.tools:
257
- agent.tools.register(adapter)
235
+
236
+ mcp_tools = manager.get_flattened_tools(prefix="mcp_")
237
+ for mcp_tool in mcp_tools:
238
+ server_name = mcp_tool.get("metadata", {}).get("server")
239
+ original_name = mcp_tool.get("metadata", {}).get("original_name")
240
+ if not server_name or not original_name:
241
+ continue
242
+
243
+ def make_executor(srv_name: str, tool_name: str):
244
+ def executor(args):
245
+ try:
246
+ result = manager.call_tool(srv_name, tool_name, args)
247
+ return extract_mcp_text(result)
248
+ except Exception as exc: # pragma: no cover
249
+ return f"Error: {exc}"
250
+
251
+ return executor
252
+
253
+ adapter = MCPToolAdapter.from_mcp_tool(
254
+ mcp_tool=mcp_tool,
255
+ executor=make_executor(server_name, original_name),
256
+ prefix="",
257
+ )
258
+ if adapter.name not in agent.tools:
259
+ agent.tools.register(adapter)
258
260
  except MCPClientError:
259
261
  return
260
262
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mashpy
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: SDK for building hosted multi-agent Mash applications.
5
5
  Author: imsid
6
6
  License: Proprietary
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
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
File without changes
File without changes
File without changes