glaip-sdk 0.6.24__py3-none-any.whl → 0.6.25__py3-none-any.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.
@@ -66,9 +66,16 @@ class ToolRegistry(BaseRegistry["Tool"]):
66
66
  Raises:
67
67
  ValueError: If name cannot be extracted from the reference.
68
68
  """
69
+ # Lazy import to avoid circular dependency
70
+ from glaip_sdk.tools.base import Tool # noqa: PLC0415
71
+
69
72
  if isinstance(ref, str):
70
73
  return ref
71
74
 
75
+ # Tool instance (from Tool.from_langchain() or Tool.from_native())
76
+ if isinstance(ref, Tool):
77
+ return ref.get_name()
78
+
72
79
  # Dict from API response - extract name or id
73
80
  if isinstance(ref, dict):
74
81
  return ref.get("name") or ref.get("id") or ""
@@ -101,17 +108,61 @@ class ToolRegistry(BaseRegistry["Tool"]):
101
108
  ValueError: If the tool cannot be resolved.
102
109
  """
103
110
  # Lazy imports to avoid circular dependency
111
+ from glaip_sdk.tools.base import Tool as ToolClass # noqa: PLC0415
112
+ from glaip_sdk.tools.base import ToolType # noqa: PLC0415
104
113
  from glaip_sdk.utils.discovery import find_tool # noqa: PLC0415
105
114
  from glaip_sdk.utils.sync import update_or_create_tool # noqa: PLC0415
106
115
 
107
- # Already deployed tool (glaip_sdk.models.Tool with ID) - just cache and return
116
+ # Tool instance from Tool.from_native() or Tool.from_langchain()
117
+ # Use try/except to handle mocked Tool class in tests
118
+ try:
119
+ is_tool_instance = isinstance(ref, ToolClass)
120
+ except TypeError:
121
+ is_tool_instance = False
122
+
123
+ if is_tool_instance:
124
+ # If Tool has an ID, it's already deployed - return as-is
125
+ if ref.id is not None:
126
+ logger.debug("Caching already deployed tool: %s", name)
127
+ self._cache[name] = ref
128
+ # Also cache by id for consistency with other resolution branches
129
+ self._cache[ref.id] = ref
130
+ return ref
131
+
132
+ # Tool.from_native() - look up on platform
133
+ if ref.tool_type == ToolType.NATIVE:
134
+ logger.info("Looking up native tool: %s", name)
135
+ tool = find_tool(name)
136
+ if tool:
137
+ self._cache[name] = tool
138
+ return tool
139
+ raise ValueError(f"Native tool not found on platform: {name}")
140
+
141
+ # Tool.from_langchain() - upload the tool_class
142
+ if ref.tool_class is not None:
143
+ logger.info("Uploading custom tool: %s", name)
144
+ tool = update_or_create_tool(ref.tool_class)
145
+ self._cache[name] = tool
146
+ if tool.id:
147
+ self._cache[tool.id] = tool
148
+ return tool
149
+
150
+ # Unresolvable Tool instance - neither native nor has tool_class
151
+ raise ValueError(
152
+ f"Cannot resolve Tool instance: {ref}. "
153
+ f"Tool has no id, is not NATIVE type, and has no tool_class. "
154
+ f"Ensure Tool is created via Tool.from_native() or Tool.from_langchain()."
155
+ )
156
+
157
+ # Already deployed tool (not a ToolClass, but has id/name) - just cache and return
158
+ # This handles API response objects and backward compatibility
108
159
  if hasattr(ref, "id") and hasattr(ref, "name") and not isinstance(ref, type):
109
160
  if ref.id is not None:
110
161
  logger.debug("Caching already deployed tool: %s", name)
111
162
  self._cache[name] = ref
112
163
  return ref
113
164
 
114
- # Tool without ID (e.g., Tool.from_native()) - look up on platform
165
+ # Tool without ID (backward compatibility) - look up on platform
115
166
  logger.info("Looking up native tool: %s", name)
116
167
  tool = find_tool(name)
117
168
  if tool:
@@ -132,9 +183,7 @@ class ToolRegistry(BaseRegistry["Tool"]):
132
183
  if isinstance(ref, dict):
133
184
  tool_id = ref.get("id")
134
185
  if tool_id:
135
- from glaip_sdk.tools.base import Tool # noqa: PLC0415
136
-
137
- tool = Tool(id=tool_id, name=ref.get("name", ""))
186
+ tool = ToolClass(id=tool_id, name=ref.get("name", ""))
138
187
  self._cache[name] = tool
139
188
  return tool
140
189
  raise ValueError(f"Tool dict missing 'id': {ref}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: glaip-sdk
3
- Version: 0.6.24
3
+ Version: 0.6.25
4
4
  Summary: Python SDK and CLI for GL AIP (GDP Labs AI Agent Package) - Build, run, and manage AI agents
5
5
  Author-email: Raymond Christopher <raymond.christopher@gdplabs.id>
6
6
  License: MIT
@@ -92,7 +92,7 @@ glaip_sdk/registry/__init__.py,sha256=mjvElYE-wwmbriGe-c6qy4on0ccEuWxW_EWWrSbptC
92
92
  glaip_sdk/registry/agent.py,sha256=F0axW4BIUODqnttIOzxnoS5AqQkLZ1i48FTeZNnYkhA,5203
93
93
  glaip_sdk/registry/base.py,sha256=0x2ZBhiERGUcf9mQeWlksSYs5TxDG6FxBYQToYZa5D4,4143
94
94
  glaip_sdk/registry/mcp.py,sha256=kNJmiijIbZL9Btx5o2tFtbaT-WG6O4Xf_nl3wz356Ow,7978
95
- glaip_sdk/registry/tool.py,sha256=rxrVxnO_VwO6E5kccqxxEUC337J9qbKpje-Gwl5a3sY,7699
95
+ glaip_sdk/registry/tool.py,sha256=rLORO-Y5z-zo_qcomF-VKsfZrNKiZ1o36MMg86L1X9w,9885
96
96
  glaip_sdk/runner/__init__.py,sha256=8RrngoGfpF8x9X27RPdX4gJjch75ZvhtVt_6UV0ULLQ,1615
97
97
  glaip_sdk/runner/base.py,sha256=KIjcSAyDCP9_mn2H4rXR5gu1FZlwD9pe0gkTBmr6Yi4,2663
98
98
  glaip_sdk/runner/deps.py,sha256=Du3hr2R5RHOYCRAv7RVmx661x-ayVXIeZ8JD7ODirTA,3884
@@ -160,8 +160,8 @@ glaip_sdk/utils/rendering/steps/format.py,sha256=Chnq7OBaj8XMeBntSBxrX5zSmrYeGcO
160
160
  glaip_sdk/utils/rendering/steps/manager.py,sha256=BiBmTeQMQhjRMykgICXsXNYh1hGsss-fH9BIGVMWFi0,13194
161
161
  glaip_sdk/utils/rendering/viewer/__init__.py,sha256=XrxmE2cMAozqrzo1jtDFm8HqNtvDcYi2mAhXLXn5CjI,457
162
162
  glaip_sdk/utils/rendering/viewer/presenter.py,sha256=mlLMTjnyeyPVtsyrAbz1BJu9lFGQSlS-voZ-_Cuugv0,5725
163
- glaip_sdk-0.6.24.dist-info/METADATA,sha256=mZ9OCm5VvtAtoEpJ7ATbyggUegM709JmEHVL1QjQAPc,8299
164
- glaip_sdk-0.6.24.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
165
- glaip_sdk-0.6.24.dist-info/entry_points.txt,sha256=65vNPUggyYnVGhuw7RhNJ8Fp2jygTcX0yxJBcBY3iLU,48
166
- glaip_sdk-0.6.24.dist-info/top_level.txt,sha256=td7yXttiYX2s94-4wFhv-5KdT0rSZ-pnJRSire341hw,10
167
- glaip_sdk-0.6.24.dist-info/RECORD,,
163
+ glaip_sdk-0.6.25.dist-info/METADATA,sha256=sxk3u4tpSPNCUAIgfGy3MfxJhnPEPgQgueua3pSrIOw,8299
164
+ glaip_sdk-0.6.25.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
165
+ glaip_sdk-0.6.25.dist-info/entry_points.txt,sha256=65vNPUggyYnVGhuw7RhNJ8Fp2jygTcX0yxJBcBY3iLU,48
166
+ glaip_sdk-0.6.25.dist-info/top_level.txt,sha256=td7yXttiYX2s94-4wFhv-5KdT0rSZ-pnJRSire341hw,10
167
+ glaip_sdk-0.6.25.dist-info/RECORD,,