Spaces:
Configuration error
Configuration error
fix: compat shim for legacy observe callers - map sessionId/cwd to folderPath/agentId
Browse files- src/routes/mcp.py +22 -2
- src/routes/observations.py +16 -0
src/routes/mcp.py
CHANGED
|
@@ -294,8 +294,28 @@ def mcp_tools_call():
|
|
| 294 |
folder_path = args.get("folderPath")
|
| 295 |
agent_id = args.get("agentId")
|
| 296 |
text = args.get("text") or args.get("content") or ""
|
| 297 |
-
|
| 298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
timestamp = args.get("timestamp") or _datetime_now_iso()
|
| 300 |
payload = {
|
| 301 |
"folderPath": folder_path,
|
|
|
|
| 294 |
folder_path = args.get("folderPath")
|
| 295 |
agent_id = args.get("agentId")
|
| 296 |
text = args.get("text") or args.get("content") or ""
|
| 297 |
+
|
| 298 |
+
# Compat shim: old plugin scripts send sessionId/project/cwd instead of
|
| 299 |
+
# folderPath/agentId. Map them across so legacy callers keep working.
|
| 300 |
+
if not folder_path:
|
| 301 |
+
# Use cwd first, then project, then a sensible default
|
| 302 |
+
folder_path = (
|
| 303 |
+
args.get("cwd")
|
| 304 |
+
or args.get("project")
|
| 305 |
+
or os.getenv("AGENTMEMORY_CWD")
|
| 306 |
+
or "/unknown"
|
| 307 |
+
)
|
| 308 |
+
if not agent_id:
|
| 309 |
+
agent_id = (
|
| 310 |
+
args.get("sessionId")
|
| 311 |
+
or functions.get_agent_id()
|
| 312 |
+
or os.getenv("AGENT_ID")
|
| 313 |
+
or "agent"
|
| 314 |
+
)
|
| 315 |
+
|
| 316 |
+
if not text:
|
| 317 |
+
return jsonify({"error": "text (or content) is required"}), 400
|
| 318 |
+
|
| 319 |
timestamp = args.get("timestamp") or _datetime_now_iso()
|
| 320 |
payload = {
|
| 321 |
"folderPath": folder_path,
|
src/routes/observations.py
CHANGED
|
@@ -61,6 +61,22 @@ def api_observe():
|
|
| 61 |
agent_id = body.get("agentId")
|
| 62 |
text = body.get("text") or body.get("content") or ""
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
if folder_path and agent_id:
|
| 65 |
# New folder-based model — delegate to folder_observe
|
| 66 |
payload = {
|
|
|
|
| 61 |
agent_id = body.get("agentId")
|
| 62 |
text = body.get("text") or body.get("content") or ""
|
| 63 |
|
| 64 |
+
# Compat shim: old clients send sessionId/project/cwd — map to folder model.
|
| 65 |
+
if not folder_path:
|
| 66 |
+
folder_path = (
|
| 67 |
+
body.get("cwd")
|
| 68 |
+
or body.get("project")
|
| 69 |
+
or os.getenv("AGENTMEMORY_CWD")
|
| 70 |
+
or "/unknown"
|
| 71 |
+
)
|
| 72 |
+
if not agent_id:
|
| 73 |
+
agent_id = (
|
| 74 |
+
body.get("sessionId")
|
| 75 |
+
or functions.get_agent_id()
|
| 76 |
+
or os.getenv("AGENT_ID")
|
| 77 |
+
or "agent"
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
if folder_path and agent_id:
|
| 81 |
# New folder-based model — delegate to folder_observe
|
| 82 |
payload = {
|