glaip-sdk 0.6.12__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.
- glaip_sdk/__init__.py +42 -5
- {glaip_sdk-0.6.12.dist-info → glaip_sdk-0.6.14.dist-info}/METADATA +31 -37
- glaip_sdk-0.6.14.dist-info/RECORD +12 -0
- {glaip_sdk-0.6.12.dist-info → glaip_sdk-0.6.14.dist-info}/WHEEL +2 -1
- glaip_sdk-0.6.14.dist-info/entry_points.txt +2 -0
- glaip_sdk-0.6.14.dist-info/top_level.txt +1 -0
- glaip_sdk/agents/__init__.py +0 -27
- glaip_sdk/agents/base.py +0 -1191
- glaip_sdk/cli/__init__.py +0 -9
- glaip_sdk/cli/account_store.py +0 -540
- glaip_sdk/cli/agent_config.py +0 -78
- glaip_sdk/cli/auth.py +0 -699
- glaip_sdk/cli/commands/__init__.py +0 -5
- glaip_sdk/cli/commands/accounts.py +0 -746
- glaip_sdk/cli/commands/agents.py +0 -1509
- glaip_sdk/cli/commands/common_config.py +0 -101
- glaip_sdk/cli/commands/configure.py +0 -896
- glaip_sdk/cli/commands/mcps.py +0 -1356
- glaip_sdk/cli/commands/models.py +0 -69
- glaip_sdk/cli/commands/tools.py +0 -576
- glaip_sdk/cli/commands/transcripts.py +0 -755
- glaip_sdk/cli/commands/update.py +0 -61
- glaip_sdk/cli/config.py +0 -95
- glaip_sdk/cli/constants.py +0 -38
- glaip_sdk/cli/context.py +0 -150
- glaip_sdk/cli/core/__init__.py +0 -79
- glaip_sdk/cli/core/context.py +0 -124
- glaip_sdk/cli/core/output.py +0 -846
- glaip_sdk/cli/core/prompting.py +0 -649
- glaip_sdk/cli/core/rendering.py +0 -187
- glaip_sdk/cli/display.py +0 -355
- glaip_sdk/cli/hints.py +0 -57
- glaip_sdk/cli/io.py +0 -112
- glaip_sdk/cli/main.py +0 -604
- glaip_sdk/cli/masking.py +0 -136
- glaip_sdk/cli/mcp_validators.py +0 -287
- glaip_sdk/cli/pager.py +0 -266
- glaip_sdk/cli/parsers/__init__.py +0 -7
- glaip_sdk/cli/parsers/json_input.py +0 -177
- glaip_sdk/cli/resolution.py +0 -67
- glaip_sdk/cli/rich_helpers.py +0 -27
- glaip_sdk/cli/slash/__init__.py +0 -15
- glaip_sdk/cli/slash/accounts_controller.py +0 -578
- glaip_sdk/cli/slash/accounts_shared.py +0 -75
- glaip_sdk/cli/slash/agent_session.py +0 -285
- glaip_sdk/cli/slash/prompt.py +0 -256
- glaip_sdk/cli/slash/remote_runs_controller.py +0 -566
- glaip_sdk/cli/slash/session.py +0 -1708
- glaip_sdk/cli/slash/tui/__init__.py +0 -9
- glaip_sdk/cli/slash/tui/accounts_app.py +0 -876
- glaip_sdk/cli/slash/tui/background_tasks.py +0 -72
- glaip_sdk/cli/slash/tui/loading.py +0 -58
- glaip_sdk/cli/slash/tui/remote_runs_app.py +0 -628
- glaip_sdk/cli/transcript/__init__.py +0 -31
- glaip_sdk/cli/transcript/cache.py +0 -536
- glaip_sdk/cli/transcript/capture.py +0 -329
- glaip_sdk/cli/transcript/export.py +0 -38
- glaip_sdk/cli/transcript/history.py +0 -815
- glaip_sdk/cli/transcript/launcher.py +0 -77
- glaip_sdk/cli/transcript/viewer.py +0 -374
- glaip_sdk/cli/update_notifier.py +0 -290
- glaip_sdk/cli/utils.py +0 -263
- glaip_sdk/cli/validators.py +0 -238
- glaip_sdk/client/__init__.py +0 -11
- glaip_sdk/client/_agent_payloads.py +0 -520
- glaip_sdk/client/agent_runs.py +0 -147
- glaip_sdk/client/agents.py +0 -1335
- glaip_sdk/client/base.py +0 -502
- glaip_sdk/client/main.py +0 -249
- glaip_sdk/client/mcps.py +0 -370
- glaip_sdk/client/run_rendering.py +0 -700
- glaip_sdk/client/shared.py +0 -21
- glaip_sdk/client/tools.py +0 -661
- glaip_sdk/client/validators.py +0 -198
- glaip_sdk/config/constants.py +0 -52
- glaip_sdk/mcps/__init__.py +0 -21
- glaip_sdk/mcps/base.py +0 -345
- glaip_sdk/models/__init__.py +0 -90
- glaip_sdk/models/agent.py +0 -47
- glaip_sdk/models/agent_runs.py +0 -116
- glaip_sdk/models/common.py +0 -42
- glaip_sdk/models/mcp.py +0 -33
- glaip_sdk/models/tool.py +0 -33
- glaip_sdk/payload_schemas/__init__.py +0 -7
- glaip_sdk/payload_schemas/agent.py +0 -85
- glaip_sdk/registry/__init__.py +0 -55
- glaip_sdk/registry/agent.py +0 -164
- glaip_sdk/registry/base.py +0 -139
- glaip_sdk/registry/mcp.py +0 -253
- glaip_sdk/registry/tool.py +0 -232
- glaip_sdk/runner/__init__.py +0 -59
- glaip_sdk/runner/base.py +0 -84
- glaip_sdk/runner/deps.py +0 -115
- glaip_sdk/runner/langgraph.py +0 -782
- glaip_sdk/runner/mcp_adapter/__init__.py +0 -13
- glaip_sdk/runner/mcp_adapter/base_mcp_adapter.py +0 -43
- glaip_sdk/runner/mcp_adapter/langchain_mcp_adapter.py +0 -257
- glaip_sdk/runner/mcp_adapter/mcp_config_builder.py +0 -95
- glaip_sdk/runner/tool_adapter/__init__.py +0 -18
- glaip_sdk/runner/tool_adapter/base_tool_adapter.py +0 -44
- glaip_sdk/runner/tool_adapter/langchain_tool_adapter.py +0 -219
- glaip_sdk/tools/__init__.py +0 -22
- glaip_sdk/tools/base.py +0 -435
- glaip_sdk/utils/__init__.py +0 -86
- glaip_sdk/utils/a2a/__init__.py +0 -34
- glaip_sdk/utils/a2a/event_processor.py +0 -188
- glaip_sdk/utils/agent_config.py +0 -194
- glaip_sdk/utils/bundler.py +0 -267
- glaip_sdk/utils/client.py +0 -111
- glaip_sdk/utils/client_utils.py +0 -486
- glaip_sdk/utils/datetime_helpers.py +0 -58
- glaip_sdk/utils/discovery.py +0 -78
- glaip_sdk/utils/display.py +0 -135
- glaip_sdk/utils/export.py +0 -143
- glaip_sdk/utils/general.py +0 -61
- glaip_sdk/utils/import_export.py +0 -168
- glaip_sdk/utils/import_resolver.py +0 -492
- glaip_sdk/utils/instructions.py +0 -101
- glaip_sdk/utils/rendering/__init__.py +0 -115
- glaip_sdk/utils/rendering/formatting.py +0 -264
- glaip_sdk/utils/rendering/layout/__init__.py +0 -64
- glaip_sdk/utils/rendering/layout/panels.py +0 -156
- glaip_sdk/utils/rendering/layout/progress.py +0 -202
- glaip_sdk/utils/rendering/layout/summary.py +0 -74
- glaip_sdk/utils/rendering/layout/transcript.py +0 -606
- glaip_sdk/utils/rendering/models.py +0 -85
- glaip_sdk/utils/rendering/renderer/__init__.py +0 -55
- glaip_sdk/utils/rendering/renderer/base.py +0 -1024
- glaip_sdk/utils/rendering/renderer/config.py +0 -27
- glaip_sdk/utils/rendering/renderer/console.py +0 -55
- glaip_sdk/utils/rendering/renderer/debug.py +0 -178
- glaip_sdk/utils/rendering/renderer/factory.py +0 -138
- glaip_sdk/utils/rendering/renderer/stream.py +0 -202
- glaip_sdk/utils/rendering/renderer/summary_window.py +0 -79
- glaip_sdk/utils/rendering/renderer/thinking.py +0 -273
- glaip_sdk/utils/rendering/renderer/toggle.py +0 -182
- glaip_sdk/utils/rendering/renderer/tool_panels.py +0 -442
- glaip_sdk/utils/rendering/renderer/transcript_mode.py +0 -162
- glaip_sdk/utils/rendering/state.py +0 -204
- glaip_sdk/utils/rendering/step_tree_state.py +0 -100
- glaip_sdk/utils/rendering/steps/__init__.py +0 -34
- glaip_sdk/utils/rendering/steps/event_processor.py +0 -778
- glaip_sdk/utils/rendering/steps/format.py +0 -176
- glaip_sdk/utils/rendering/steps/manager.py +0 -387
- glaip_sdk/utils/rendering/timing.py +0 -36
- glaip_sdk/utils/rendering/viewer/__init__.py +0 -21
- glaip_sdk/utils/rendering/viewer/presenter.py +0 -184
- glaip_sdk/utils/resource_refs.py +0 -195
- glaip_sdk/utils/run_renderer.py +0 -41
- glaip_sdk/utils/runtime_config.py +0 -425
- glaip_sdk/utils/serialization.py +0 -424
- glaip_sdk/utils/sync.py +0 -142
- glaip_sdk/utils/tool_detection.py +0 -33
- glaip_sdk/utils/validation.py +0 -264
- glaip_sdk-0.6.12.dist-info/RECORD +0 -159
- glaip_sdk-0.6.12.dist-info/entry_points.txt +0 -3
glaip_sdk/models/__init__.py
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"""Models package for AIP SDK.
|
|
2
|
-
|
|
3
|
-
This package provides Pydantic models for API responses.
|
|
4
|
-
|
|
5
|
-
For the public runtime API with methods like run(), deploy(), update(), delete():
|
|
6
|
-
- glaip_sdk.agents.Agent
|
|
7
|
-
- glaip_sdk.tools.Tool
|
|
8
|
-
- glaip_sdk.mcps.MCP
|
|
9
|
-
|
|
10
|
-
The Agent, Tool, and MCP exports from this module are DEPRECATED.
|
|
11
|
-
They redirect to glaip_sdk.agents.Agent, glaip_sdk.tools.Tool, glaip_sdk.mcps.MCP
|
|
12
|
-
respectively with deprecation warnings.
|
|
13
|
-
|
|
14
|
-
Authors:
|
|
15
|
-
Raymond Christopher (raymond.christopher@gdplabs.id)
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
import warnings
|
|
19
|
-
|
|
20
|
-
# Pure Pydantic models for API responses (no runtime methods)
|
|
21
|
-
from glaip_sdk.models.agent import AgentResponse
|
|
22
|
-
from glaip_sdk.models.agent_runs import (
|
|
23
|
-
RunOutputChunk,
|
|
24
|
-
RunsPage,
|
|
25
|
-
RunSummary,
|
|
26
|
-
RunWithOutput,
|
|
27
|
-
)
|
|
28
|
-
from glaip_sdk.models.common import LanguageModelResponse, TTYRenderer
|
|
29
|
-
from glaip_sdk.models.mcp import MCPResponse
|
|
30
|
-
from glaip_sdk.models.tool import ToolResponse
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def __getattr__(name: str) -> type:
|
|
34
|
-
"""Deprecation warnings for backward compatibility."""
|
|
35
|
-
if name == "Agent":
|
|
36
|
-
warnings.warn(
|
|
37
|
-
"Importing Agent from glaip_sdk.models is deprecated. "
|
|
38
|
-
"Use 'from glaip_sdk.agents import Agent' instead. "
|
|
39
|
-
"This will be removed in v1.0.0",
|
|
40
|
-
DeprecationWarning,
|
|
41
|
-
stacklevel=2,
|
|
42
|
-
)
|
|
43
|
-
from glaip_sdk.agents import Agent # noqa: PLC0415
|
|
44
|
-
|
|
45
|
-
return Agent
|
|
46
|
-
|
|
47
|
-
if name == "Tool":
|
|
48
|
-
warnings.warn(
|
|
49
|
-
"Importing Tool from glaip_sdk.models is deprecated. "
|
|
50
|
-
"Use 'from glaip_sdk.tools import Tool' instead. "
|
|
51
|
-
"This will be removed in v1.0.0",
|
|
52
|
-
DeprecationWarning,
|
|
53
|
-
stacklevel=2,
|
|
54
|
-
)
|
|
55
|
-
from glaip_sdk.tools import Tool # noqa: PLC0415
|
|
56
|
-
|
|
57
|
-
return Tool
|
|
58
|
-
|
|
59
|
-
if name == "MCP":
|
|
60
|
-
warnings.warn(
|
|
61
|
-
"Importing MCP from glaip_sdk.models is deprecated. "
|
|
62
|
-
"Use 'from glaip_sdk.mcps import MCP' instead. "
|
|
63
|
-
"This will be removed in v1.0.0",
|
|
64
|
-
DeprecationWarning,
|
|
65
|
-
stacklevel=2,
|
|
66
|
-
)
|
|
67
|
-
from glaip_sdk.mcps import MCP # noqa: PLC0415
|
|
68
|
-
|
|
69
|
-
return MCP
|
|
70
|
-
|
|
71
|
-
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
__all__ = [
|
|
75
|
-
# Pure Pydantic response models (recommended for type hints)
|
|
76
|
-
"AgentResponse",
|
|
77
|
-
"ToolResponse",
|
|
78
|
-
"MCPResponse",
|
|
79
|
-
# Deprecated aliases (redirect to runtime classes with warning)
|
|
80
|
-
"Agent",
|
|
81
|
-
"Tool",
|
|
82
|
-
"MCP",
|
|
83
|
-
# Other models
|
|
84
|
-
"LanguageModelResponse",
|
|
85
|
-
"TTYRenderer",
|
|
86
|
-
"RunSummary",
|
|
87
|
-
"RunsPage",
|
|
88
|
-
"RunWithOutput",
|
|
89
|
-
"RunOutputChunk",
|
|
90
|
-
]
|
glaip_sdk/models/agent.py
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"""Agent response model for AIP SDK.
|
|
2
|
-
|
|
3
|
-
This module contains the Pydantic model for Agent API responses.
|
|
4
|
-
This is a pure data model with no runtime behavior.
|
|
5
|
-
|
|
6
|
-
For the runtime Agent class with deploy/run methods, use glaip_sdk.agents.Agent.
|
|
7
|
-
|
|
8
|
-
Authors:
|
|
9
|
-
Raymond Christopher (raymond.christopher@gdplabs.id)
|
|
10
|
-
Christian Trisno Sen Long Chen (christian.t.s.l.chen@gdplabs.id)
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
from datetime import datetime
|
|
14
|
-
from typing import Any
|
|
15
|
-
|
|
16
|
-
from glaip_sdk.config.constants import DEFAULT_AGENT_RUN_TIMEOUT
|
|
17
|
-
from pydantic import BaseModel
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class AgentResponse(BaseModel):
|
|
21
|
-
"""Pydantic model for Agent API responses.
|
|
22
|
-
|
|
23
|
-
This is a pure data model for deserializing API responses.
|
|
24
|
-
It does NOT have runtime methods (run, update, delete).
|
|
25
|
-
|
|
26
|
-
For the runtime Agent class, use glaip_sdk.agents.Agent.
|
|
27
|
-
"""
|
|
28
|
-
|
|
29
|
-
id: str
|
|
30
|
-
name: str
|
|
31
|
-
instruction: str | None = None
|
|
32
|
-
description: str | None = None
|
|
33
|
-
type: str | None = None
|
|
34
|
-
framework: str | None = None
|
|
35
|
-
version: str | None = None
|
|
36
|
-
tools: list[dict[str, Any]] | None = None
|
|
37
|
-
agents: list[dict[str, Any]] | None = None
|
|
38
|
-
mcps: list[dict[str, Any]] | None = None
|
|
39
|
-
tool_configs: dict[str, Any] | None = None
|
|
40
|
-
mcp_configs: dict[str, Any] | None = None
|
|
41
|
-
agent_config: dict[str, Any] | None = None
|
|
42
|
-
timeout: int = DEFAULT_AGENT_RUN_TIMEOUT
|
|
43
|
-
metadata: dict[str, Any] | None = None
|
|
44
|
-
language_model_id: str | None = None
|
|
45
|
-
a2a_profile: dict[str, Any] | None = None
|
|
46
|
-
created_at: datetime | None = None
|
|
47
|
-
updated_at: datetime | None = None
|
glaip_sdk/models/agent_runs.py
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Agent run models for AIP SDK.
|
|
3
|
-
|
|
4
|
-
Authors:
|
|
5
|
-
Raymond Christopher (raymond.christopher@gdplabs.id)
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
from datetime import datetime, timedelta
|
|
9
|
-
from typing import Any, Literal
|
|
10
|
-
from uuid import UUID
|
|
11
|
-
|
|
12
|
-
from pydantic import BaseModel, Field, field_validator, model_validator
|
|
13
|
-
|
|
14
|
-
# Type alias for SSE event dictionaries
|
|
15
|
-
RunOutputChunk = dict[str, Any]
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class RunSummary(BaseModel):
|
|
19
|
-
"""Represents a single agent run in list/table views with metadata only."""
|
|
20
|
-
|
|
21
|
-
id: UUID
|
|
22
|
-
agent_id: UUID
|
|
23
|
-
run_type: Literal["manual", "schedule"]
|
|
24
|
-
schedule_id: UUID | None = None
|
|
25
|
-
status: Literal["started", "success", "failed", "cancelled", "aborted", "unavailable"]
|
|
26
|
-
started_at: datetime
|
|
27
|
-
completed_at: datetime | None = None
|
|
28
|
-
input: str | None = None
|
|
29
|
-
config: dict[str, Any] | None = None
|
|
30
|
-
created_at: datetime
|
|
31
|
-
updated_at: datetime
|
|
32
|
-
|
|
33
|
-
@field_validator("completed_at")
|
|
34
|
-
@classmethod
|
|
35
|
-
def validate_completed_after_started(cls, v: datetime | None, info) -> datetime | None:
|
|
36
|
-
"""Validate that completed_at is after started_at if present."""
|
|
37
|
-
if v is not None and "started_at" in info.data:
|
|
38
|
-
started_at = info.data["started_at"]
|
|
39
|
-
if v < started_at:
|
|
40
|
-
raise ValueError("completed_at must be after started_at")
|
|
41
|
-
return v
|
|
42
|
-
|
|
43
|
-
def duration(self) -> timedelta | None:
|
|
44
|
-
"""Calculate duration from started_at to completed_at.
|
|
45
|
-
|
|
46
|
-
Returns:
|
|
47
|
-
Duration as timedelta if completed_at exists, None otherwise
|
|
48
|
-
"""
|
|
49
|
-
if self.completed_at is not None:
|
|
50
|
-
return self.completed_at - self.started_at
|
|
51
|
-
return None
|
|
52
|
-
|
|
53
|
-
def duration_formatted(self) -> str:
|
|
54
|
-
"""Format duration as HH:MM:SS string.
|
|
55
|
-
|
|
56
|
-
Returns:
|
|
57
|
-
Formatted duration string or "—" if not completed
|
|
58
|
-
"""
|
|
59
|
-
duration = self.duration()
|
|
60
|
-
if duration is None:
|
|
61
|
-
return "—"
|
|
62
|
-
total_seconds = int(duration.total_seconds())
|
|
63
|
-
hours = total_seconds // 3600
|
|
64
|
-
minutes = (total_seconds % 3600) // 60
|
|
65
|
-
seconds = total_seconds % 60
|
|
66
|
-
return f"{hours:02d}:{minutes:02d}:{seconds:02d}"
|
|
67
|
-
|
|
68
|
-
def input_preview(self, max_length: int = 120) -> str:
|
|
69
|
-
"""Generate truncated input preview for table display.
|
|
70
|
-
|
|
71
|
-
Args:
|
|
72
|
-
max_length: Maximum length of preview string
|
|
73
|
-
|
|
74
|
-
Returns:
|
|
75
|
-
Truncated input string or "—" if input is None or empty
|
|
76
|
-
"""
|
|
77
|
-
if not self.input:
|
|
78
|
-
return "—"
|
|
79
|
-
# Strip newlines and collapse whitespace
|
|
80
|
-
preview = " ".join(self.input.split())
|
|
81
|
-
if len(preview) > max_length:
|
|
82
|
-
return preview[:max_length] + "…"
|
|
83
|
-
return preview
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
class RunsPage(BaseModel):
|
|
87
|
-
"""Represents a paginated collection of run summaries from the list endpoint."""
|
|
88
|
-
|
|
89
|
-
data: list[RunSummary]
|
|
90
|
-
total: int = Field(ge=0)
|
|
91
|
-
page: int = Field(ge=1)
|
|
92
|
-
limit: int = Field(ge=1, le=100)
|
|
93
|
-
has_next: bool
|
|
94
|
-
has_prev: bool
|
|
95
|
-
|
|
96
|
-
@model_validator(mode="after")
|
|
97
|
-
def validate_pagination_consistency(self) -> "RunsPage":
|
|
98
|
-
"""Validate pagination consistency."""
|
|
99
|
-
# If has_next is True, then page * limit < total
|
|
100
|
-
if self.has_next and self.page * self.limit >= self.total:
|
|
101
|
-
raise ValueError("has_next inconsistency: page * limit must be < total when has_next is True")
|
|
102
|
-
return self
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
class RunWithOutput(RunSummary):
|
|
106
|
-
"""Extends RunSummary with the complete SSE event stream for detailed viewing."""
|
|
107
|
-
|
|
108
|
-
output: list[RunOutputChunk] = Field(default_factory=list)
|
|
109
|
-
|
|
110
|
-
@field_validator("output", mode="before")
|
|
111
|
-
@classmethod
|
|
112
|
-
def normalize_output(cls, v: Any) -> list[RunOutputChunk]:
|
|
113
|
-
"""Normalize output field to empty list when null."""
|
|
114
|
-
if v is None:
|
|
115
|
-
return []
|
|
116
|
-
return v
|
glaip_sdk/models/common.py
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"""Common models for AIP SDK.
|
|
2
|
-
|
|
3
|
-
This module contains common models that don't fit into specific categories.
|
|
4
|
-
|
|
5
|
-
Authors:
|
|
6
|
-
Raymond Christopher (raymond.christopher@gdplabs.id)
|
|
7
|
-
Christian Trisno Sen Long Chen (christian.t.s.l.chen@gdplabs.id)
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
from pydantic import BaseModel
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class LanguageModelResponse(BaseModel):
|
|
14
|
-
"""Language model response model."""
|
|
15
|
-
|
|
16
|
-
name: str
|
|
17
|
-
provider: str
|
|
18
|
-
description: str | None = None
|
|
19
|
-
capabilities: list[str] | None = None
|
|
20
|
-
max_tokens: int | None = None
|
|
21
|
-
supports_streaming: bool = False
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class TTYRenderer:
|
|
25
|
-
"""Simple TTY renderer for non-Rich environments."""
|
|
26
|
-
|
|
27
|
-
def __init__(self, use_color: bool = True):
|
|
28
|
-
"""Initialize the TTY renderer.
|
|
29
|
-
|
|
30
|
-
Args:
|
|
31
|
-
use_color: Whether to use color output
|
|
32
|
-
"""
|
|
33
|
-
self.use_color = use_color
|
|
34
|
-
|
|
35
|
-
def render_message(self, message: str, event_type: str = "message") -> None:
|
|
36
|
-
"""Render a message with optional color."""
|
|
37
|
-
if event_type == "error":
|
|
38
|
-
print(f"ERROR: {message}", flush=True)
|
|
39
|
-
elif event_type == "done":
|
|
40
|
-
print(f"\n✅ {message}", flush=True)
|
|
41
|
-
else:
|
|
42
|
-
print(message, flush=True)
|
glaip_sdk/models/mcp.py
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"""MCP response model for AIP SDK.
|
|
2
|
-
|
|
3
|
-
This module contains the Pydantic model for MCP API responses.
|
|
4
|
-
This is a pure data model with no runtime behavior.
|
|
5
|
-
|
|
6
|
-
For the runtime MCP class with update/delete methods, use glaip_sdk.mcps.MCP.
|
|
7
|
-
|
|
8
|
-
Authors:
|
|
9
|
-
Raymond Christopher (raymond.christopher@gdplabs.id)
|
|
10
|
-
Christian Trisno Sen Long Chen (christian.t.s.l.chen@gdplabs.id)
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
from typing import Any
|
|
14
|
-
|
|
15
|
-
from pydantic import BaseModel
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class MCPResponse(BaseModel):
|
|
19
|
-
"""Pydantic model for MCP API responses.
|
|
20
|
-
|
|
21
|
-
This is a pure data model for deserializing API responses.
|
|
22
|
-
It does NOT have runtime methods (update, delete, get_tools).
|
|
23
|
-
|
|
24
|
-
For the runtime MCP class, use glaip_sdk.mcps.MCP.
|
|
25
|
-
"""
|
|
26
|
-
|
|
27
|
-
id: str
|
|
28
|
-
name: str
|
|
29
|
-
description: str | None = None
|
|
30
|
-
config: dict[str, Any] | None = None
|
|
31
|
-
transport: str | None = None # "sse" or "http"
|
|
32
|
-
authentication: dict[str, Any] | None = None
|
|
33
|
-
metadata: dict[str, Any] | None = None
|
glaip_sdk/models/tool.py
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"""Tool response model for AIP SDK.
|
|
2
|
-
|
|
3
|
-
This module contains the Pydantic model for Tool API responses.
|
|
4
|
-
This is a pure data model with no runtime behavior.
|
|
5
|
-
|
|
6
|
-
For the runtime Tool class with update/delete methods, use glaip_sdk.tools.Tool.
|
|
7
|
-
|
|
8
|
-
Authors:
|
|
9
|
-
Raymond Christopher (raymond.christopher@gdplabs.id)
|
|
10
|
-
Christian Trisno Sen Long Chen (christian.t.s.l.chen@gdplabs.id)
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
from pydantic import BaseModel
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class ToolResponse(BaseModel):
|
|
17
|
-
"""Pydantic model for Tool API responses.
|
|
18
|
-
|
|
19
|
-
This is a pure data model for deserializing API responses.
|
|
20
|
-
It does NOT have runtime methods (update, delete, get_script).
|
|
21
|
-
|
|
22
|
-
For the runtime Tool class, use glaip_sdk.tools.Tool.
|
|
23
|
-
"""
|
|
24
|
-
|
|
25
|
-
id: str
|
|
26
|
-
name: str
|
|
27
|
-
tool_type: str | None = None
|
|
28
|
-
description: str | None = None
|
|
29
|
-
framework: str | None = None
|
|
30
|
-
version: str | None = None
|
|
31
|
-
tool_script: str | None = None
|
|
32
|
-
tool_file: str | None = None
|
|
33
|
-
tags: str | list[str] | None = None
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"""Agent payload schema metadata derived from agent_payloads.md.
|
|
2
|
-
|
|
3
|
-
Authors:
|
|
4
|
-
Raymond Christopher (raymond.christopher@gdplabs.id)
|
|
5
|
-
|
|
6
|
-
This module encodes which agent fields are mutable, server-managed, or require
|
|
7
|
-
additional sanitisation so that CLI and SDK flows can share the same rules.
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
from collections.abc import Collection, Mapping
|
|
11
|
-
from dataclasses import dataclass
|
|
12
|
-
from typing import Literal
|
|
13
|
-
|
|
14
|
-
AgentImportOperation = Literal["create", "update"]
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@dataclass(frozen=True)
|
|
18
|
-
class FieldRule:
|
|
19
|
-
"""Schema rule defining how a field should be treated."""
|
|
20
|
-
|
|
21
|
-
server_only: bool = False
|
|
22
|
-
cli_managed_create: bool = False
|
|
23
|
-
cli_managed_update: bool = False
|
|
24
|
-
requires_sanitization: bool = False
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@dataclass(frozen=True)
|
|
28
|
-
class ImportFieldPlan:
|
|
29
|
-
"""Plan for how an import pipeline should treat a specific field."""
|
|
30
|
-
|
|
31
|
-
copy: bool
|
|
32
|
-
sanitize: bool = False
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
_DEFAULT_RULE = FieldRule()
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
AGENT_FIELD_RULES: Mapping[str, FieldRule] = {
|
|
39
|
-
# Server-provided metadata (never send back)
|
|
40
|
-
"id": FieldRule(server_only=True),
|
|
41
|
-
"created_at": FieldRule(server_only=True),
|
|
42
|
-
"updated_at": FieldRule(server_only=True),
|
|
43
|
-
"deleted_at": FieldRule(server_only=True),
|
|
44
|
-
"success": FieldRule(server_only=True),
|
|
45
|
-
"message": FieldRule(server_only=True),
|
|
46
|
-
# Fields handled explicitly by CLI/SDK helpers for language model selection
|
|
47
|
-
"language_model_id": FieldRule(cli_managed_create=True, cli_managed_update=True),
|
|
48
|
-
"provider": FieldRule(cli_managed_create=True, cli_managed_update=True),
|
|
49
|
-
"model_name": FieldRule(cli_managed_create=True, cli_managed_update=True),
|
|
50
|
-
"model": FieldRule(cli_managed_create=True, cli_managed_update=True),
|
|
51
|
-
# Fields collected via CLI flags / explicit logic
|
|
52
|
-
"name": FieldRule(cli_managed_create=True, cli_managed_update=True),
|
|
53
|
-
"instruction": FieldRule(cli_managed_create=True, cli_managed_update=True),
|
|
54
|
-
"tools": FieldRule(cli_managed_create=True, cli_managed_update=True),
|
|
55
|
-
"agents": FieldRule(cli_managed_create=True, cli_managed_update=True),
|
|
56
|
-
"mcps": FieldRule(cli_managed_create=True, cli_managed_update=True),
|
|
57
|
-
"timeout": FieldRule(cli_managed_create=True, cli_managed_update=True),
|
|
58
|
-
# Fields requiring sanitisation before sending to the API
|
|
59
|
-
"agent_config": FieldRule(requires_sanitization=True),
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def get_import_field_plan(field_name: str, operation: AgentImportOperation) -> ImportFieldPlan:
|
|
64
|
-
"""Return the import handling plan for ``field_name`` under ``operation``.
|
|
65
|
-
|
|
66
|
-
Unknown fields default to being copied as-is so new API fields propagate
|
|
67
|
-
without additional code changes.
|
|
68
|
-
"""
|
|
69
|
-
rule = AGENT_FIELD_RULES.get(field_name, _DEFAULT_RULE)
|
|
70
|
-
|
|
71
|
-
if rule.server_only:
|
|
72
|
-
return ImportFieldPlan(copy=False)
|
|
73
|
-
|
|
74
|
-
if operation == "create" and rule.cli_managed_create:
|
|
75
|
-
return ImportFieldPlan(copy=False)
|
|
76
|
-
|
|
77
|
-
if operation == "update" and rule.cli_managed_update:
|
|
78
|
-
return ImportFieldPlan(copy=False)
|
|
79
|
-
|
|
80
|
-
return ImportFieldPlan(copy=True, sanitize=rule.requires_sanitization)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def list_server_only_fields() -> Collection[str]:
|
|
84
|
-
"""Expose the set of server-only fields for other tooling."""
|
|
85
|
-
return {name for name, rule in AGENT_FIELD_RULES.items() if rule.server_only}
|
glaip_sdk/registry/__init__.py
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"""Registry package for GL AIP platform.
|
|
2
|
-
|
|
3
|
-
This package provides registries that cache platform objects to avoid
|
|
4
|
-
redundant API calls when deploying multi-agent systems.
|
|
5
|
-
|
|
6
|
-
Example:
|
|
7
|
-
>>> from glaip_sdk.registry import get_agent_registry, get_tool_registry
|
|
8
|
-
>>> agent_registry = get_agent_registry()
|
|
9
|
-
>>> tool_registry = get_tool_registry()
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
from __future__ import annotations
|
|
13
|
-
|
|
14
|
-
import importlib
|
|
15
|
-
from typing import TYPE_CHECKING
|
|
16
|
-
|
|
17
|
-
from glaip_sdk.registry.base import BaseRegistry
|
|
18
|
-
|
|
19
|
-
# Lazy imports to avoid circular dependencies
|
|
20
|
-
if TYPE_CHECKING: # pragma: no cover
|
|
21
|
-
from glaip_sdk.registry.agent import AgentRegistry, get_agent_registry
|
|
22
|
-
from glaip_sdk.registry.mcp import MCPRegistry, get_mcp_registry
|
|
23
|
-
from glaip_sdk.registry.tool import ToolRegistry, get_tool_registry
|
|
24
|
-
|
|
25
|
-
__all__ = [
|
|
26
|
-
"BaseRegistry",
|
|
27
|
-
"AgentRegistry",
|
|
28
|
-
"get_agent_registry",
|
|
29
|
-
"ToolRegistry",
|
|
30
|
-
"get_tool_registry",
|
|
31
|
-
"MCPRegistry",
|
|
32
|
-
"get_mcp_registry",
|
|
33
|
-
]
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def __getattr__(name: str) -> type:
|
|
37
|
-
"""Lazy import to avoid circular dependencies."""
|
|
38
|
-
_agent_module = "glaip_sdk.registry.agent"
|
|
39
|
-
_tool_module = "glaip_sdk.registry.tool"
|
|
40
|
-
_mcp_module = "glaip_sdk.registry.mcp"
|
|
41
|
-
|
|
42
|
-
lazy_imports = {
|
|
43
|
-
"AgentRegistry": _agent_module,
|
|
44
|
-
"get_agent_registry": _agent_module,
|
|
45
|
-
"ToolRegistry": _tool_module,
|
|
46
|
-
"get_tool_registry": _tool_module,
|
|
47
|
-
"MCPRegistry": _mcp_module,
|
|
48
|
-
"get_mcp_registry": _mcp_module,
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if name in lazy_imports:
|
|
52
|
-
module = importlib.import_module(lazy_imports[name])
|
|
53
|
-
return getattr(module, name)
|
|
54
|
-
|
|
55
|
-
raise AttributeError(f"module 'glaip_sdk.registry' has no attribute '{name}'")
|
glaip_sdk/registry/agent.py
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"""Agent registry for glaip_sdk.
|
|
2
|
-
|
|
3
|
-
This module provides the AgentRegistry that caches deployed agents
|
|
4
|
-
to avoid redundant API calls when deploying multi-agent systems.
|
|
5
|
-
|
|
6
|
-
Authors:
|
|
7
|
-
Christian Trisno Sen Long Chen (christian.t.s.l.chen@gdplabs.id)
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
from __future__ import annotations
|
|
11
|
-
|
|
12
|
-
import logging
|
|
13
|
-
from typing import TYPE_CHECKING, Any
|
|
14
|
-
|
|
15
|
-
from glaip_sdk.registry.base import BaseRegistry
|
|
16
|
-
|
|
17
|
-
if TYPE_CHECKING:
|
|
18
|
-
from glaip_sdk.agents import Agent
|
|
19
|
-
|
|
20
|
-
logger = logging.getLogger(__name__)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class AgentRegistry(BaseRegistry["Agent"]):
|
|
24
|
-
"""Registry for agents.
|
|
25
|
-
|
|
26
|
-
Resolves agent references to glaip_sdk.models.Agent objects.
|
|
27
|
-
Caches results to avoid redundant API calls and duplicate deployments.
|
|
28
|
-
|
|
29
|
-
Handles:
|
|
30
|
-
- glaip_sdk.agents.Agent classes → deploy, cache, return Agent
|
|
31
|
-
- glaip_sdk.agents.Agent instances → deploy, cache, return Agent
|
|
32
|
-
- glaip_sdk.models.Agent → return as-is (uses agent.id)
|
|
33
|
-
- String names → lookup on platform, cache, return Agent
|
|
34
|
-
|
|
35
|
-
Attributes:
|
|
36
|
-
_cache: Internal cache mapping names to Agent objects.
|
|
37
|
-
|
|
38
|
-
Example:
|
|
39
|
-
>>> registry = get_agent_registry()
|
|
40
|
-
>>> agent = registry.resolve(GreeterAgent) # Returns deployed Agent
|
|
41
|
-
>>> print(agent.id) # "uuid-123"
|
|
42
|
-
>>> print(agent.name) # "greeter_agent"
|
|
43
|
-
"""
|
|
44
|
-
|
|
45
|
-
def _extract_name(self, ref: Any) -> str:
|
|
46
|
-
"""Extract agent name from a reference.
|
|
47
|
-
|
|
48
|
-
Args:
|
|
49
|
-
ref: An agent class, instance, or string name.
|
|
50
|
-
|
|
51
|
-
Returns:
|
|
52
|
-
The extracted agent name.
|
|
53
|
-
|
|
54
|
-
Raises:
|
|
55
|
-
ValueError: If name cannot be extracted from the reference.
|
|
56
|
-
"""
|
|
57
|
-
# Lazy import to avoid circular dependency
|
|
58
|
-
from glaip_sdk.agents.base import Agent # noqa: PLC0415
|
|
59
|
-
|
|
60
|
-
# Agent class
|
|
61
|
-
if isinstance(ref, type) and issubclass(ref, Agent):
|
|
62
|
-
return ref().name
|
|
63
|
-
|
|
64
|
-
# Agent instance
|
|
65
|
-
if isinstance(ref, Agent):
|
|
66
|
-
return ref.name
|
|
67
|
-
|
|
68
|
-
# Already deployed agent (glaip_sdk.models.Agent)
|
|
69
|
-
if hasattr(ref, "id") and hasattr(ref, "name") and not isinstance(ref, type):
|
|
70
|
-
return ref.name
|
|
71
|
-
|
|
72
|
-
# String name
|
|
73
|
-
if isinstance(ref, str):
|
|
74
|
-
return ref
|
|
75
|
-
|
|
76
|
-
raise ValueError(f"Cannot extract name from: {ref}")
|
|
77
|
-
|
|
78
|
-
def _resolve_and_cache(self, ref: Any, name: str) -> Agent:
|
|
79
|
-
"""Resolve agent reference - deploy if class/instance, find if string.
|
|
80
|
-
|
|
81
|
-
Args:
|
|
82
|
-
ref: The agent reference to resolve.
|
|
83
|
-
name: The extracted agent name.
|
|
84
|
-
|
|
85
|
-
Returns:
|
|
86
|
-
The resolved glaip_sdk.models.Agent object.
|
|
87
|
-
|
|
88
|
-
Raises:
|
|
89
|
-
ValueError: If the agent cannot be resolved.
|
|
90
|
-
"""
|
|
91
|
-
# Lazy imports to avoid circular dependency
|
|
92
|
-
from glaip_sdk.agents.base import Agent # noqa: PLC0415
|
|
93
|
-
from glaip_sdk.utils.discovery import find_agent # noqa: PLC0415
|
|
94
|
-
|
|
95
|
-
# Agent class
|
|
96
|
-
if isinstance(ref, type) and issubclass(ref, Agent):
|
|
97
|
-
logger.info("Deploying Agent class: %s", name)
|
|
98
|
-
deployed = ref().deploy()
|
|
99
|
-
self._cache[name] = deployed
|
|
100
|
-
return deployed
|
|
101
|
-
|
|
102
|
-
# Agent instance
|
|
103
|
-
if isinstance(ref, Agent):
|
|
104
|
-
logger.info("Deploying Agent instance: %s", name)
|
|
105
|
-
deployed = ref.deploy()
|
|
106
|
-
self._cache[name] = deployed
|
|
107
|
-
return deployed
|
|
108
|
-
|
|
109
|
-
# Already deployed agent (glaip_sdk.models.Agent) - just cache and return
|
|
110
|
-
if hasattr(ref, "id") and hasattr(ref, "name") and not isinstance(ref, type):
|
|
111
|
-
logger.debug("Caching already deployed agent: %s", name)
|
|
112
|
-
self._cache[name] = ref
|
|
113
|
-
return ref
|
|
114
|
-
|
|
115
|
-
# String name - look up on platform
|
|
116
|
-
if isinstance(ref, str):
|
|
117
|
-
logger.info("Looking up agent by name: %s", name)
|
|
118
|
-
agent = find_agent(name)
|
|
119
|
-
if agent:
|
|
120
|
-
self._cache[name] = agent
|
|
121
|
-
return agent
|
|
122
|
-
raise ValueError(f"Agent not found on platform: {name}")
|
|
123
|
-
|
|
124
|
-
raise ValueError(f"Could not resolve agent reference: {ref}")
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
class _AgentRegistrySingleton:
|
|
128
|
-
"""Singleton holder for AgentRegistry to avoid global statement."""
|
|
129
|
-
|
|
130
|
-
_instance: AgentRegistry | None = None
|
|
131
|
-
|
|
132
|
-
@classmethod
|
|
133
|
-
def get_instance(cls) -> AgentRegistry:
|
|
134
|
-
"""Get or create the singleton instance.
|
|
135
|
-
|
|
136
|
-
Returns:
|
|
137
|
-
The global AgentRegistry instance.
|
|
138
|
-
"""
|
|
139
|
-
if cls._instance is None:
|
|
140
|
-
cls._instance = AgentRegistry()
|
|
141
|
-
return cls._instance
|
|
142
|
-
|
|
143
|
-
@classmethod
|
|
144
|
-
def reset(cls) -> None:
|
|
145
|
-
"""Reset the singleton instance (for testing)."""
|
|
146
|
-
cls._instance = None
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
def get_agent_registry() -> AgentRegistry:
|
|
150
|
-
"""Get the singleton AgentRegistry instance.
|
|
151
|
-
|
|
152
|
-
Returns a global AgentRegistry that caches agents across the session.
|
|
153
|
-
Use this function to get the registry instead of creating instances directly.
|
|
154
|
-
|
|
155
|
-
Returns:
|
|
156
|
-
The global AgentRegistry instance.
|
|
157
|
-
|
|
158
|
-
Example:
|
|
159
|
-
>>> from glaip_sdk.registry import get_agent_registry
|
|
160
|
-
>>> registry = get_agent_registry()
|
|
161
|
-
>>> agent = registry.resolve("weather_agent")
|
|
162
|
-
>>> print(agent.name)
|
|
163
|
-
"""
|
|
164
|
-
return _AgentRegistrySingleton.get_instance()
|