glaip-sdk 0.6.11__py3-none-any.whl → 0.6.14__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.
Files changed (156) hide show
  1. glaip_sdk/__init__.py +42 -5
  2. {glaip_sdk-0.6.11.dist-info → glaip_sdk-0.6.14.dist-info}/METADATA +31 -37
  3. glaip_sdk-0.6.14.dist-info/RECORD +12 -0
  4. {glaip_sdk-0.6.11.dist-info → glaip_sdk-0.6.14.dist-info}/WHEEL +2 -1
  5. glaip_sdk-0.6.14.dist-info/entry_points.txt +2 -0
  6. glaip_sdk-0.6.14.dist-info/top_level.txt +1 -0
  7. glaip_sdk/agents/__init__.py +0 -27
  8. glaip_sdk/agents/base.py +0 -1191
  9. glaip_sdk/cli/__init__.py +0 -9
  10. glaip_sdk/cli/account_store.py +0 -540
  11. glaip_sdk/cli/agent_config.py +0 -78
  12. glaip_sdk/cli/auth.py +0 -699
  13. glaip_sdk/cli/commands/__init__.py +0 -5
  14. glaip_sdk/cli/commands/accounts.py +0 -746
  15. glaip_sdk/cli/commands/agents.py +0 -1509
  16. glaip_sdk/cli/commands/common_config.py +0 -101
  17. glaip_sdk/cli/commands/configure.py +0 -896
  18. glaip_sdk/cli/commands/mcps.py +0 -1356
  19. glaip_sdk/cli/commands/models.py +0 -69
  20. glaip_sdk/cli/commands/tools.py +0 -576
  21. glaip_sdk/cli/commands/transcripts.py +0 -755
  22. glaip_sdk/cli/commands/update.py +0 -61
  23. glaip_sdk/cli/config.py +0 -95
  24. glaip_sdk/cli/constants.py +0 -38
  25. glaip_sdk/cli/context.py +0 -150
  26. glaip_sdk/cli/core/__init__.py +0 -79
  27. glaip_sdk/cli/core/context.py +0 -124
  28. glaip_sdk/cli/core/output.py +0 -846
  29. glaip_sdk/cli/core/prompting.py +0 -649
  30. glaip_sdk/cli/core/rendering.py +0 -187
  31. glaip_sdk/cli/display.py +0 -355
  32. glaip_sdk/cli/hints.py +0 -57
  33. glaip_sdk/cli/io.py +0 -112
  34. glaip_sdk/cli/main.py +0 -604
  35. glaip_sdk/cli/masking.py +0 -136
  36. glaip_sdk/cli/mcp_validators.py +0 -287
  37. glaip_sdk/cli/pager.py +0 -266
  38. glaip_sdk/cli/parsers/__init__.py +0 -7
  39. glaip_sdk/cli/parsers/json_input.py +0 -177
  40. glaip_sdk/cli/resolution.py +0 -67
  41. glaip_sdk/cli/rich_helpers.py +0 -27
  42. glaip_sdk/cli/slash/__init__.py +0 -15
  43. glaip_sdk/cli/slash/accounts_controller.py +0 -578
  44. glaip_sdk/cli/slash/accounts_shared.py +0 -75
  45. glaip_sdk/cli/slash/agent_session.py +0 -285
  46. glaip_sdk/cli/slash/prompt.py +0 -256
  47. glaip_sdk/cli/slash/remote_runs_controller.py +0 -566
  48. glaip_sdk/cli/slash/session.py +0 -1708
  49. glaip_sdk/cli/slash/tui/__init__.py +0 -9
  50. glaip_sdk/cli/slash/tui/accounts_app.py +0 -876
  51. glaip_sdk/cli/slash/tui/background_tasks.py +0 -72
  52. glaip_sdk/cli/slash/tui/loading.py +0 -58
  53. glaip_sdk/cli/slash/tui/remote_runs_app.py +0 -628
  54. glaip_sdk/cli/transcript/__init__.py +0 -31
  55. glaip_sdk/cli/transcript/cache.py +0 -536
  56. glaip_sdk/cli/transcript/capture.py +0 -329
  57. glaip_sdk/cli/transcript/export.py +0 -38
  58. glaip_sdk/cli/transcript/history.py +0 -815
  59. glaip_sdk/cli/transcript/launcher.py +0 -77
  60. glaip_sdk/cli/transcript/viewer.py +0 -374
  61. glaip_sdk/cli/update_notifier.py +0 -290
  62. glaip_sdk/cli/utils.py +0 -263
  63. glaip_sdk/cli/validators.py +0 -238
  64. glaip_sdk/client/__init__.py +0 -11
  65. glaip_sdk/client/_agent_payloads.py +0 -520
  66. glaip_sdk/client/agent_runs.py +0 -147
  67. glaip_sdk/client/agents.py +0 -1335
  68. glaip_sdk/client/base.py +0 -502
  69. glaip_sdk/client/main.py +0 -249
  70. glaip_sdk/client/mcps.py +0 -370
  71. glaip_sdk/client/run_rendering.py +0 -700
  72. glaip_sdk/client/shared.py +0 -21
  73. glaip_sdk/client/tools.py +0 -661
  74. glaip_sdk/client/validators.py +0 -198
  75. glaip_sdk/config/constants.py +0 -52
  76. glaip_sdk/mcps/__init__.py +0 -21
  77. glaip_sdk/mcps/base.py +0 -345
  78. glaip_sdk/models/__init__.py +0 -90
  79. glaip_sdk/models/agent.py +0 -47
  80. glaip_sdk/models/agent_runs.py +0 -116
  81. glaip_sdk/models/common.py +0 -42
  82. glaip_sdk/models/mcp.py +0 -33
  83. glaip_sdk/models/tool.py +0 -33
  84. glaip_sdk/payload_schemas/__init__.py +0 -7
  85. glaip_sdk/payload_schemas/agent.py +0 -85
  86. glaip_sdk/registry/__init__.py +0 -55
  87. glaip_sdk/registry/agent.py +0 -164
  88. glaip_sdk/registry/base.py +0 -139
  89. glaip_sdk/registry/mcp.py +0 -253
  90. glaip_sdk/registry/tool.py +0 -232
  91. glaip_sdk/runner/__init__.py +0 -59
  92. glaip_sdk/runner/base.py +0 -84
  93. glaip_sdk/runner/deps.py +0 -115
  94. glaip_sdk/runner/langgraph.py +0 -782
  95. glaip_sdk/runner/mcp_adapter/__init__.py +0 -13
  96. glaip_sdk/runner/mcp_adapter/base_mcp_adapter.py +0 -43
  97. glaip_sdk/runner/mcp_adapter/langchain_mcp_adapter.py +0 -257
  98. glaip_sdk/runner/mcp_adapter/mcp_config_builder.py +0 -95
  99. glaip_sdk/runner/tool_adapter/__init__.py +0 -18
  100. glaip_sdk/runner/tool_adapter/base_tool_adapter.py +0 -44
  101. glaip_sdk/runner/tool_adapter/langchain_tool_adapter.py +0 -219
  102. glaip_sdk/tools/__init__.py +0 -22
  103. glaip_sdk/tools/base.py +0 -435
  104. glaip_sdk/utils/__init__.py +0 -86
  105. glaip_sdk/utils/a2a/__init__.py +0 -34
  106. glaip_sdk/utils/a2a/event_processor.py +0 -188
  107. glaip_sdk/utils/agent_config.py +0 -194
  108. glaip_sdk/utils/bundler.py +0 -267
  109. glaip_sdk/utils/client.py +0 -111
  110. glaip_sdk/utils/client_utils.py +0 -486
  111. glaip_sdk/utils/datetime_helpers.py +0 -58
  112. glaip_sdk/utils/discovery.py +0 -78
  113. glaip_sdk/utils/display.py +0 -135
  114. glaip_sdk/utils/export.py +0 -143
  115. glaip_sdk/utils/general.py +0 -61
  116. glaip_sdk/utils/import_export.py +0 -168
  117. glaip_sdk/utils/import_resolver.py +0 -492
  118. glaip_sdk/utils/instructions.py +0 -101
  119. glaip_sdk/utils/rendering/__init__.py +0 -115
  120. glaip_sdk/utils/rendering/formatting.py +0 -264
  121. glaip_sdk/utils/rendering/layout/__init__.py +0 -64
  122. glaip_sdk/utils/rendering/layout/panels.py +0 -156
  123. glaip_sdk/utils/rendering/layout/progress.py +0 -202
  124. glaip_sdk/utils/rendering/layout/summary.py +0 -74
  125. glaip_sdk/utils/rendering/layout/transcript.py +0 -606
  126. glaip_sdk/utils/rendering/models.py +0 -85
  127. glaip_sdk/utils/rendering/renderer/__init__.py +0 -55
  128. glaip_sdk/utils/rendering/renderer/base.py +0 -1024
  129. glaip_sdk/utils/rendering/renderer/config.py +0 -27
  130. glaip_sdk/utils/rendering/renderer/console.py +0 -55
  131. glaip_sdk/utils/rendering/renderer/debug.py +0 -178
  132. glaip_sdk/utils/rendering/renderer/factory.py +0 -138
  133. glaip_sdk/utils/rendering/renderer/stream.py +0 -202
  134. glaip_sdk/utils/rendering/renderer/summary_window.py +0 -79
  135. glaip_sdk/utils/rendering/renderer/thinking.py +0 -273
  136. glaip_sdk/utils/rendering/renderer/toggle.py +0 -182
  137. glaip_sdk/utils/rendering/renderer/tool_panels.py +0 -442
  138. glaip_sdk/utils/rendering/renderer/transcript_mode.py +0 -162
  139. glaip_sdk/utils/rendering/state.py +0 -204
  140. glaip_sdk/utils/rendering/step_tree_state.py +0 -100
  141. glaip_sdk/utils/rendering/steps/__init__.py +0 -34
  142. glaip_sdk/utils/rendering/steps/event_processor.py +0 -778
  143. glaip_sdk/utils/rendering/steps/format.py +0 -176
  144. glaip_sdk/utils/rendering/steps/manager.py +0 -387
  145. glaip_sdk/utils/rendering/timing.py +0 -36
  146. glaip_sdk/utils/rendering/viewer/__init__.py +0 -21
  147. glaip_sdk/utils/rendering/viewer/presenter.py +0 -184
  148. glaip_sdk/utils/resource_refs.py +0 -195
  149. glaip_sdk/utils/run_renderer.py +0 -41
  150. glaip_sdk/utils/runtime_config.py +0 -425
  151. glaip_sdk/utils/serialization.py +0 -424
  152. glaip_sdk/utils/sync.py +0 -142
  153. glaip_sdk/utils/tool_detection.py +0 -33
  154. glaip_sdk/utils/validation.py +0 -264
  155. glaip_sdk-0.6.11.dist-info/RECORD +0 -159
  156. glaip_sdk-0.6.11.dist-info/entry_points.txt +0 -3
@@ -1,22 +0,0 @@
1
- """Tool package for GL AIP platform.
2
-
3
- This package provides the Tool class, ToolType enum, and ToolRegistry
4
- for managing tools on the GL AIP platform.
5
-
6
- Example:
7
- >>> from glaip_sdk.tools import Tool, ToolType, get_tool_registry
8
- >>> native_tool = Tool.from_native("web_search")
9
- >>> custom_tool = Tool.from_langchain(MyCustomTool)
10
- """
11
-
12
- from __future__ import annotations
13
-
14
- from glaip_sdk.registry.tool import ToolRegistry, get_tool_registry
15
- from glaip_sdk.tools.base import Tool, ToolType
16
-
17
- __all__ = [
18
- "Tool",
19
- "ToolType",
20
- "ToolRegistry",
21
- "get_tool_registry",
22
- ]
glaip_sdk/tools/base.py DELETED
@@ -1,435 +0,0 @@
1
- """Tool class for lazy tool references.
2
-
3
- This module provides the Tool class that serves as a lazy reference
4
- to tools on the GL AIP platform. Tools are only resolved when
5
- Agent.deploy() is called.
6
-
7
- The Tool class also supports runtime operations (update, delete, get_script)
8
- when retrieved from the API via client.tools.get().
9
-
10
- Authors:
11
- Christian Trisno Sen Long Chen (christian.t.s.l.chen@gdplabs.id)
12
-
13
- Example - Lazy Reference:
14
- >>> from glaip_sdk.tools import Tool
15
- >>>
16
- >>> # Reference a native platform tool
17
- >>> time_tool = Tool.from_native("time_tool")
18
- >>>
19
- >>> # Reference a custom LangChain tool
20
- >>> greeting_tool = Tool.from_langchain(GreetingTool)
21
- >>>
22
- >>> # Use in an agent
23
- >>> class MyAgent(Agent):
24
- ... @property
25
- ... def tools(self) -> list:
26
- ... return [time_tool, greeting_tool]
27
-
28
- Example - Runtime Operations:
29
- >>> from glaip_sdk import Glaip
30
- >>>
31
- >>> client = Glaip()
32
- >>> tool = client.tools.get("tool-123")
33
- >>> script = tool.get_script() # Get tool script content
34
- >>> tool.update(description="Updated description")
35
- >>> tool.delete()
36
- """
37
-
38
- from __future__ import annotations
39
-
40
- from enum import StrEnum
41
- from typing import TYPE_CHECKING, Any
42
-
43
- if TYPE_CHECKING:
44
- from glaip_sdk.models import ToolResponse
45
-
46
- _TOOL_NOT_DEPLOYED_MSG = "Tool not available on platform. No ID set."
47
- _CLIENT_NOT_AVAILABLE_MSG = "Client not available. Use client.tools.get() to get a client-connected tool."
48
-
49
-
50
- class ToolType(StrEnum):
51
- """Type of tool reference."""
52
-
53
- NATIVE = "native"
54
- CUSTOM = "custom"
55
-
56
-
57
- class Tool:
58
- """Tool class for GL AIP platform.
59
-
60
- Supports both lazy references and runtime operations:
61
- - Lazy reference: Created via from_native() or from_langchain()
62
- - Runtime: Created via from_response() or client.tools.get()
63
-
64
- Use factory methods to create Tool instances:
65
- - Tool.from_native(name) - Reference a native platform tool
66
- - Tool.from_langchain(tool_class) - Reference a custom LangChain tool
67
- - Tool.from_response(response, client) - From API response
68
-
69
- Attributes:
70
- name: Tool name (for native tools) or from tool_class.
71
- id: Tool ID on the platform (set after deployment or from API).
72
- tool_class: LangChain BaseTool class (for custom tools) or None.
73
- tool_type: Type of tool (native or custom).
74
- description: Tool description (from API response).
75
- tool_script: Tool script content (from API response).
76
-
77
- Example - Lazy Reference:
78
- >>> # Native tool
79
- >>> time_tool = Tool.from_native("time_tool")
80
- >>>
81
- >>> # Custom tool
82
- >>> greeting_tool = Tool.from_langchain(GreetingTool)
83
-
84
- Example - Runtime Operations:
85
- >>> tool = client.tools.get("tool-123")
86
- >>> tool.update(description="New description")
87
- >>> tool.delete()
88
- """
89
-
90
- def __init__(
91
- self,
92
- name: str | None = None,
93
- tool_class: type | None = None,
94
- tool_type: str | ToolType | None = None,
95
- *,
96
- id: str | None = None, # noqa: A002 - Allow shadowing builtin for API compat
97
- description: str | None = None,
98
- tool_script: str | None = None,
99
- tool_file: str | None = None,
100
- framework: str | None = None,
101
- version: str | None = None,
102
- tags: str | list[str] | None = None,
103
- type: (str | ToolType | None) = None, # noqa: A002 - Backward compat alias for tool_type
104
- _client: Any = None,
105
- ) -> None:
106
- """Initialize a Tool.
107
-
108
- Args:
109
- name: Tool name (for native tools).
110
- tool_class: LangChain BaseTool class (for custom tools).
111
- tool_type: Type of tool (native or custom). Accepts str or ToolType.
112
- id: Tool ID on the platform.
113
- description: Tool description.
114
- tool_script: Tool script content.
115
- tool_file: Tool file path.
116
- framework: Tool framework.
117
- version: Tool version.
118
- tags: Tool tags.
119
- type: Backward compatibility alias for tool_type.
120
- _client: Internal client reference.
121
- """
122
- self.name = name
123
- self.tool_class = tool_class
124
- # Use type as alias for tool_type (backward compatibility)
125
- effective_type = tool_type if tool_type is not None else type
126
- if effective_type is None:
127
- effective_type = ToolType.NATIVE
128
- # Normalize type to ToolType enum
129
- if isinstance(effective_type, str):
130
- self._type = ToolType(effective_type) if effective_type in ToolType.__members__.values() else effective_type
131
- else:
132
- self._type = effective_type
133
- self._id = id
134
- self.description = description
135
- self.tool_script = tool_script
136
- self.tool_file = tool_file
137
- self.framework = framework
138
- self.version = version
139
- self.tags = tags
140
- self._client = _client
141
-
142
- @property
143
- def tool_type(self) -> str | ToolType:
144
- """Tool type (native or custom)."""
145
- return self._type
146
-
147
- @tool_type.setter
148
- def tool_type(self, value: str | ToolType) -> None:
149
- """Set the tool type."""
150
- if isinstance(value, str):
151
- self._type = ToolType(value) if value in ToolType.__members__.values() else value
152
- else:
153
- self._type = value
154
-
155
- @property
156
- def type(
157
- self,
158
- ) -> str | ToolType: # noqa: A003 - Allow shadowing builtin for API compat
159
- """Tool type (native or custom). Alias for 'tool_type' for backward compatibility."""
160
- return self._type
161
-
162
- @type.setter
163
- def type(self, value: str | ToolType) -> None: # noqa: A003
164
- """Set the tool type. Alias for 'tool_type' for backward compatibility."""
165
- self.tool_type = value
166
-
167
- @property
168
- def id(self) -> str | None: # noqa: A003 - Allow shadowing builtin for API compat
169
- """Tool ID on the platform."""
170
- return self._id
171
-
172
- @id.setter
173
- def id(self, value: str | None) -> None: # noqa: A003
174
- """Set the tool ID."""
175
- self._id = value
176
-
177
- def __repr__(self) -> str:
178
- """Return string representation."""
179
- if self._id:
180
- return f"Tool(id={self._id!r}, name={self.name!r})"
181
- if self.type == ToolType.NATIVE:
182
- return f"Tool.from_native({self.name!r})"
183
- if self.tool_class is not None:
184
- return f"Tool.from_langchain({self.tool_class.__name__})"
185
- return f"Tool(name={self.name!r}, type={self.type})"
186
-
187
- def __eq__(self, other: object) -> bool:
188
- """Check equality based on id if available, else name and type."""
189
- if not isinstance(other, Tool):
190
- return NotImplemented
191
- if self._id and other._id:
192
- return self._id == other._id
193
- return self.name == other.name and self.type == other.type
194
-
195
- def __hash__(self) -> int:
196
- """Hash based on id if available, else name and type."""
197
- if self._id:
198
- return hash(self._id)
199
- return hash((self.name, self.type))
200
-
201
- def model_dump(self, *, exclude_none: bool = False) -> dict[str, Any]:
202
- """Return a dict representation of the Tool.
203
-
204
- Provides Pydantic-style serialization for backward compatibility.
205
-
206
- Args:
207
- exclude_none: If True, exclude None values from the output.
208
-
209
- Returns:
210
- Dictionary containing Tool attributes.
211
- """
212
- data = {
213
- "id": self._id,
214
- "name": self.name,
215
- "type": str(self.type) if self.type else None,
216
- "description": self.description,
217
- "tool_script": self.tool_script,
218
- "tool_file": self.tool_file,
219
- "framework": self.framework,
220
- "version": self.version,
221
- "tags": self.tags,
222
- }
223
- if exclude_none:
224
- return {k: v for k, v in data.items() if v is not None}
225
- return data
226
-
227
- @classmethod
228
- def from_native(cls, name: str) -> Tool:
229
- """Create a reference to a native platform tool.
230
-
231
- Native tools are pre-existing tools on the GL AIP platform
232
- that don't require uploading (e.g., "time_tool", "web_search").
233
-
234
- Args:
235
- name: The name of the native tool on the platform.
236
-
237
- Returns:
238
- A Tool reference that will be resolved during Agent.deploy().
239
-
240
- Example:
241
- >>> time_tool = Tool.from_native("time_tool")
242
- >>> web_search = Tool.from_native("web_search")
243
- """
244
- return cls(name=name, type=ToolType.NATIVE)
245
-
246
- @classmethod
247
- def from_langchain(cls, tool_class: type) -> Tool:
248
- """Create a reference to a custom LangChain tool.
249
-
250
- Custom tools are user-defined LangChain BaseTool subclasses
251
- that will be uploaded to the platform during deployment.
252
-
253
- Args:
254
- tool_class: A LangChain BaseTool subclass.
255
-
256
- Returns:
257
- A Tool reference that will be uploaded during Agent.deploy().
258
-
259
- Example:
260
- >>> from langchain_core.tools import BaseTool
261
- >>>
262
- >>> class GreetingTool(BaseTool):
263
- ... name: str = "greeting_tool"
264
- ... description: str = "Greets the user"
265
- ... def _run(self, name: str) -> str:
266
- ... return f"Hello, {name}!"
267
- >>>
268
- >>> greeting_tool = Tool.from_langchain(GreetingTool)
269
- """
270
- return cls(tool_class=tool_class, type=ToolType.CUSTOM)
271
-
272
- def get_import_path(self) -> str | None:
273
- """Get the import path for custom tools.
274
-
275
- Returns:
276
- Import path string for custom tools, None for native tools.
277
- """
278
- if self.tool_class is None:
279
- return None
280
- return f"{self.tool_class.__module__}.{self.tool_class.__name__}"
281
-
282
- def get_name(self) -> str:
283
- """Get the tool name.
284
-
285
- Returns:
286
- The tool name (from name attribute or tool_class).
287
-
288
- Raises:
289
- ValueError: If name cannot be determined.
290
- """
291
- if self.name is not None:
292
- return self.name
293
-
294
- if self.tool_class is not None:
295
- # LangChain BaseTool - get name from model_fields
296
- if hasattr(self.tool_class, "model_fields"):
297
- name_field = self.tool_class.model_fields.get("name")
298
- if name_field and name_field.default:
299
- return name_field.default
300
-
301
- # Direct name attribute
302
- if hasattr(self.tool_class, "name"):
303
- return self.tool_class.name
304
-
305
- raise ValueError(f"Cannot determine name for tool: {self}")
306
-
307
- # ─────────────────────────────────────────────────────────────────
308
- # Runtime Methods (require client connection)
309
- # ─────────────────────────────────────────────────────────────────
310
-
311
- def _set_client(self, client: Any) -> Tool:
312
- """Set the client reference for this tool.
313
-
314
- Args:
315
- client: The Glaip client instance.
316
-
317
- Returns:
318
- Self for method chaining.
319
- """
320
- self._client = client
321
- return self
322
-
323
- def get_script(self) -> str:
324
- """Get the tool script content.
325
-
326
- Returns:
327
- The tool script content, or a placeholder message.
328
- """
329
- if self.tool_script:
330
- return self.tool_script
331
- elif self.tool_file:
332
- return f"Script content from file: {self.tool_file}"
333
- else:
334
- return "No script content available"
335
-
336
- def update(self, **kwargs: Any) -> Tool:
337
- """Update the tool with new configuration.
338
-
339
- Supports both metadata updates and file uploads.
340
- Pass 'file' parameter to update tool code via file upload.
341
-
342
- Args:
343
- **kwargs: Tool properties to update (name, description, etc.).
344
-
345
- Returns:
346
- Self with updated properties.
347
-
348
- Raises:
349
- ValueError: If the tool has no ID.
350
- RuntimeError: If client is not available.
351
- """
352
- if not self._id:
353
- raise ValueError(_TOOL_NOT_DEPLOYED_MSG)
354
- if not self._client:
355
- raise RuntimeError(_CLIENT_NOT_AVAILABLE_MSG)
356
-
357
- # Check if file upload is requested
358
- if "file" in kwargs:
359
- file_path = kwargs.pop("file")
360
- response = self._client.tools.update_via_file(self._id, file_path, **kwargs)
361
- else:
362
- response = self._client.tools.update(tool_id=self._id, **kwargs)
363
-
364
- # Update local properties from response
365
- if hasattr(response, "name") and response.name:
366
- self.name = response.name
367
- if hasattr(response, "description"):
368
- self.description = response.description
369
- if hasattr(response, "tool_script"):
370
- self.tool_script = response.tool_script
371
-
372
- return self
373
-
374
- def delete(self) -> None:
375
- """Delete the tool from the platform.
376
-
377
- Raises:
378
- ValueError: If the tool has no ID.
379
- RuntimeError: If client is not available.
380
- """
381
- if not self._id:
382
- raise ValueError(_TOOL_NOT_DEPLOYED_MSG)
383
- if not self._client:
384
- raise RuntimeError(_CLIENT_NOT_AVAILABLE_MSG)
385
-
386
- self._client.tools.delete(tool_id=self._id)
387
- self._id = None
388
- self._client = None
389
-
390
- @classmethod
391
- def from_response(
392
- cls,
393
- response: ToolResponse,
394
- client: Any = None,
395
- ) -> Tool:
396
- """Create a Tool instance from an API response.
397
-
398
- This allows you to work with tools retrieved from the API
399
- as full Tool instances with all methods available.
400
-
401
- Args:
402
- response: The ToolResponse from an API call.
403
- client: The Glaip client instance for API operations.
404
-
405
- Returns:
406
- A Tool instance initialized from the response.
407
-
408
- Example:
409
- >>> response = client.tools.get("tool-123")
410
- >>> tool = Tool.from_response(response, client)
411
- >>> script = tool.get_script()
412
- """
413
- # Use tool_type from backend; infer CUSTOM when code is present but tool_type is missing
414
- raw_type = getattr(response, "tool_type", None)
415
- if raw_type is None and (
416
- getattr(response, "tool_script", None) is not None or getattr(response, "tool_file", None) is not None
417
- ):
418
- raw_type = ToolType.CUSTOM
419
-
420
- tool = cls(
421
- name=response.name,
422
- id=response.id,
423
- tool_type=raw_type,
424
- description=getattr(response, "description", None),
425
- tool_script=getattr(response, "tool_script", None),
426
- tool_file=getattr(response, "tool_file", None),
427
- framework=getattr(response, "framework", None),
428
- version=getattr(response, "version", None),
429
- tags=getattr(response, "tags", None),
430
- )
431
-
432
- if client:
433
- tool._set_client(client)
434
-
435
- return tool
@@ -1,86 +0,0 @@
1
- """Utility modules for AIP SDK.
2
-
3
- Authors:
4
- Raymond Christopher (raymond.christopher@gdplabs.id)
5
- """
6
-
7
- import importlib
8
- from typing import TYPE_CHECKING
9
-
10
- from glaip_sdk.utils.datetime_helpers import coerce_datetime, from_numeric_timestamp
11
- from glaip_sdk.utils.display import (
12
- RICH_AVAILABLE,
13
- print_agent_created,
14
- print_agent_deleted,
15
- print_agent_output,
16
- print_agent_updated,
17
- )
18
- from glaip_sdk.utils.general import format_datetime, format_file_size, progress_bar
19
- from glaip_sdk.utils.rendering.models import RunStats, Step
20
- from glaip_sdk.utils.rendering.renderer.base import RichStreamRenderer
21
- from glaip_sdk.utils.rendering.steps import StepManager
22
- from glaip_sdk.utils.resource_refs import is_uuid, sanitize_name
23
-
24
- # Lazy imports to avoid circular dependencies
25
- if TYPE_CHECKING: # pragma: no cover
26
- from glaip_sdk.utils.bundler import ToolBundler
27
- from glaip_sdk.utils.client import get_client, reset_client, set_client
28
- from glaip_sdk.utils.discovery import find_agent, find_tool
29
- from glaip_sdk.utils.import_resolver import ImportResolver
30
- from glaip_sdk.utils.instructions import load_instruction_from_file
31
- from glaip_sdk.utils.sync import update_or_create_agent, update_or_create_tool
32
-
33
- __all__ = [
34
- "RICH_AVAILABLE",
35
- "format_datetime",
36
- "format_file_size",
37
- "is_uuid",
38
- "print_agent_created",
39
- "print_agent_deleted",
40
- "print_agent_output",
41
- "print_agent_updated",
42
- "progress_bar",
43
- "sanitize_name",
44
- "RichStreamRenderer",
45
- "RunStats",
46
- "Step",
47
- "StepManager",
48
- "coerce_datetime",
49
- "from_numeric_timestamp",
50
- "ToolBundler",
51
- "ImportResolver",
52
- "load_instruction_from_file",
53
- "find_agent",
54
- "find_tool",
55
- "update_or_create_agent",
56
- "update_or_create_tool",
57
- "get_client",
58
- "set_client",
59
- "reset_client",
60
- ]
61
-
62
-
63
- def __getattr__(name: str) -> type:
64
- """Lazy import to avoid circular dependencies."""
65
- _client_module = "glaip_sdk.utils.client"
66
- _discovery_module = "glaip_sdk.utils.discovery"
67
- _sync_module = "glaip_sdk.utils.sync"
68
-
69
- lazy_imports = {
70
- "ToolBundler": "glaip_sdk.utils.bundler",
71
- "ImportResolver": "glaip_sdk.utils.import_resolver",
72
- "load_instruction_from_file": "glaip_sdk.utils.instructions",
73
- "find_agent": _discovery_module,
74
- "find_tool": _discovery_module,
75
- "update_or_create_agent": _sync_module,
76
- "update_or_create_tool": _sync_module,
77
- "get_client": _client_module,
78
- "set_client": _client_module,
79
- "reset_client": _client_module,
80
- }
81
-
82
- if name in lazy_imports:
83
- module = importlib.import_module(lazy_imports[name])
84
- return getattr(module, name)
85
-
86
- raise AttributeError(f"module 'glaip_sdk.utils' has no attribute '{name}'")
@@ -1,34 +0,0 @@
1
- """A2A (Agent-to-Agent) event processing utilities.
2
-
3
- This module provides utilities for processing A2A stream events emitted by
4
- agent execution backends. Used by the runner module and CLI rendering.
5
-
6
- Authors:
7
- Christian Trisno Sen Long Chen (christian.t.s.l.chen@gdplabs.id)
8
- """
9
-
10
- from glaip_sdk.utils.a2a.event_processor import (
11
- EVENT_TYPE_ERROR,
12
- EVENT_TYPE_FINAL_RESPONSE,
13
- EVENT_TYPE_STATUS_UPDATE,
14
- EVENT_TYPE_TOOL_CALL,
15
- EVENT_TYPE_TOOL_RESULT,
16
- A2AEventStreamProcessor,
17
- extract_final_response,
18
- get_event_type,
19
- is_error_event,
20
- is_tool_event,
21
- )
22
-
23
- __all__ = [
24
- "A2AEventStreamProcessor",
25
- "EVENT_TYPE_ERROR",
26
- "EVENT_TYPE_FINAL_RESPONSE",
27
- "EVENT_TYPE_STATUS_UPDATE",
28
- "EVENT_TYPE_TOOL_CALL",
29
- "EVENT_TYPE_TOOL_RESULT",
30
- "extract_final_response",
31
- "get_event_type",
32
- "is_error_event",
33
- "is_tool_event",
34
- ]