Complete name-first MCP write-plan composition
This commit is contained in:
@@ -82,12 +82,25 @@ def discover_object(base_url: str, base_id: str, source_table: str, timeout: flo
|
||||
def resolve_object(base_url: str, selector: dict[str, Any], source_table: str, timeout: float) -> dict[str, Any]:
|
||||
if not any(selector.get(key) for key in ("ref", "kind", "name", "guid")):
|
||||
return discover_object(base_url, str(selector["base_id"]), source_table, timeout)
|
||||
resolved = rpc(base_url, "metadata.object.get", selector | {"table": source_table}, timeout)
|
||||
resolved_object = resolved.get("object") if isinstance(resolved.get("object"), dict) else {}
|
||||
if resolved.get("status") == "ok" and resolved_object.get("guid"):
|
||||
return resolved_object
|
||||
if selector.get("kind") or selector.get("name") or selector.get("guid"):
|
||||
listed = rpc(base_url, "metadata.objects.list", selector | {"limit": 5, "table": source_table}, timeout)
|
||||
objects = [item for item in listed.get("objects") or [] if isinstance(item, dict)]
|
||||
if objects:
|
||||
return objects[0]
|
||||
found = rpc(base_url, "metadata.definition.find", selector | {"areas": ["metadata"], "include_storage": True}, timeout)
|
||||
definition_query = str(selector.get("ref") or selector.get("guid") or selector.get("name") or "").strip()
|
||||
found = rpc(
|
||||
base_url,
|
||||
"metadata.definition.find",
|
||||
selector | {"query": definition_query, "areas": ["metadata"], "include_storage": True},
|
||||
timeout,
|
||||
)
|
||||
found_object = found.get("object") if isinstance(found.get("object"), dict) else {}
|
||||
if found_object.get("guid"):
|
||||
return found_object
|
||||
matches = [item for item in found.get("matches") or found.get("items") or [] if isinstance(item, dict)]
|
||||
for item in matches:
|
||||
if item.get("guid") or (item.get("object") or {}).get("guid"):
|
||||
|
||||
Reference in New Issue
Block a user