glaip-sdk 0.6.19__py3-none-any.whl → 0.7.27__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 (135) hide show
  1. glaip_sdk/agents/base.py +283 -30
  2. glaip_sdk/agents/component.py +233 -0
  3. glaip_sdk/branding.py +113 -2
  4. glaip_sdk/cli/account_store.py +15 -0
  5. glaip_sdk/cli/auth.py +14 -8
  6. glaip_sdk/cli/commands/accounts.py +1 -1
  7. glaip_sdk/cli/commands/agents/__init__.py +116 -0
  8. glaip_sdk/cli/commands/agents/_common.py +562 -0
  9. glaip_sdk/cli/commands/agents/create.py +155 -0
  10. glaip_sdk/cli/commands/agents/delete.py +64 -0
  11. glaip_sdk/cli/commands/agents/get.py +89 -0
  12. glaip_sdk/cli/commands/agents/list.py +129 -0
  13. glaip_sdk/cli/commands/agents/run.py +264 -0
  14. glaip_sdk/cli/commands/agents/sync_langflow.py +72 -0
  15. glaip_sdk/cli/commands/agents/update.py +112 -0
  16. glaip_sdk/cli/commands/common_config.py +1 -1
  17. glaip_sdk/cli/commands/configure.py +1 -2
  18. glaip_sdk/cli/commands/mcps/__init__.py +94 -0
  19. glaip_sdk/cli/commands/mcps/_common.py +459 -0
  20. glaip_sdk/cli/commands/mcps/connect.py +82 -0
  21. glaip_sdk/cli/commands/mcps/create.py +152 -0
  22. glaip_sdk/cli/commands/mcps/delete.py +73 -0
  23. glaip_sdk/cli/commands/mcps/get.py +212 -0
  24. glaip_sdk/cli/commands/mcps/list.py +69 -0
  25. glaip_sdk/cli/commands/mcps/tools.py +235 -0
  26. glaip_sdk/cli/commands/mcps/update.py +190 -0
  27. glaip_sdk/cli/commands/models.py +2 -4
  28. glaip_sdk/cli/commands/shared/__init__.py +21 -0
  29. glaip_sdk/cli/commands/shared/formatters.py +91 -0
  30. glaip_sdk/cli/commands/tools/__init__.py +69 -0
  31. glaip_sdk/cli/commands/tools/_common.py +80 -0
  32. glaip_sdk/cli/commands/tools/create.py +228 -0
  33. glaip_sdk/cli/commands/tools/delete.py +61 -0
  34. glaip_sdk/cli/commands/tools/get.py +103 -0
  35. glaip_sdk/cli/commands/tools/list.py +69 -0
  36. glaip_sdk/cli/commands/tools/script.py +49 -0
  37. glaip_sdk/cli/commands/tools/update.py +102 -0
  38. glaip_sdk/cli/commands/transcripts/__init__.py +90 -0
  39. glaip_sdk/cli/commands/transcripts/_common.py +9 -0
  40. glaip_sdk/cli/commands/transcripts/clear.py +5 -0
  41. glaip_sdk/cli/commands/transcripts/detail.py +5 -0
  42. glaip_sdk/cli/commands/{transcripts.py → transcripts_original.py} +2 -1
  43. glaip_sdk/cli/commands/update.py +163 -17
  44. glaip_sdk/cli/config.py +1 -0
  45. glaip_sdk/cli/entrypoint.py +20 -0
  46. glaip_sdk/cli/main.py +112 -35
  47. glaip_sdk/cli/pager.py +3 -3
  48. glaip_sdk/cli/resolution.py +2 -1
  49. glaip_sdk/cli/slash/accounts_controller.py +3 -1
  50. glaip_sdk/cli/slash/agent_session.py +1 -1
  51. glaip_sdk/cli/slash/remote_runs_controller.py +3 -1
  52. glaip_sdk/cli/slash/session.py +343 -20
  53. glaip_sdk/cli/slash/tui/__init__.py +29 -1
  54. glaip_sdk/cli/slash/tui/accounts.tcss +97 -6
  55. glaip_sdk/cli/slash/tui/accounts_app.py +1117 -126
  56. glaip_sdk/cli/slash/tui/clipboard.py +316 -0
  57. glaip_sdk/cli/slash/tui/context.py +92 -0
  58. glaip_sdk/cli/slash/tui/indicators.py +341 -0
  59. glaip_sdk/cli/slash/tui/keybind_registry.py +235 -0
  60. glaip_sdk/cli/slash/tui/layouts/__init__.py +14 -0
  61. glaip_sdk/cli/slash/tui/layouts/harlequin.py +184 -0
  62. glaip_sdk/cli/slash/tui/loading.py +43 -21
  63. glaip_sdk/cli/slash/tui/remote_runs_app.py +178 -20
  64. glaip_sdk/cli/slash/tui/terminal.py +407 -0
  65. glaip_sdk/cli/slash/tui/theme/__init__.py +15 -0
  66. glaip_sdk/cli/slash/tui/theme/catalog.py +79 -0
  67. glaip_sdk/cli/slash/tui/theme/manager.py +112 -0
  68. glaip_sdk/cli/slash/tui/theme/tokens.py +55 -0
  69. glaip_sdk/cli/slash/tui/toast.py +388 -0
  70. glaip_sdk/cli/transcript/history.py +1 -1
  71. glaip_sdk/cli/transcript/viewer.py +1 -1
  72. glaip_sdk/cli/tui_settings.py +125 -0
  73. glaip_sdk/cli/update_notifier.py +215 -7
  74. glaip_sdk/cli/validators.py +1 -1
  75. glaip_sdk/client/__init__.py +2 -1
  76. glaip_sdk/client/_schedule_payloads.py +89 -0
  77. glaip_sdk/client/agents.py +293 -17
  78. glaip_sdk/client/base.py +25 -0
  79. glaip_sdk/client/hitl.py +136 -0
  80. glaip_sdk/client/main.py +7 -5
  81. glaip_sdk/client/mcps.py +44 -13
  82. glaip_sdk/client/payloads/agent/__init__.py +23 -0
  83. glaip_sdk/client/{_agent_payloads.py → payloads/agent/requests.py} +28 -48
  84. glaip_sdk/client/payloads/agent/responses.py +43 -0
  85. glaip_sdk/client/run_rendering.py +109 -30
  86. glaip_sdk/client/schedules.py +439 -0
  87. glaip_sdk/client/tools.py +52 -23
  88. glaip_sdk/config/constants.py +22 -2
  89. glaip_sdk/guardrails/__init__.py +80 -0
  90. glaip_sdk/guardrails/serializer.py +91 -0
  91. glaip_sdk/hitl/__init__.py +35 -2
  92. glaip_sdk/hitl/base.py +64 -0
  93. glaip_sdk/hitl/callback.py +43 -0
  94. glaip_sdk/hitl/local.py +1 -31
  95. glaip_sdk/hitl/remote.py +523 -0
  96. glaip_sdk/models/__init__.py +47 -1
  97. glaip_sdk/models/_provider_mappings.py +101 -0
  98. glaip_sdk/models/_validation.py +97 -0
  99. glaip_sdk/models/agent.py +2 -1
  100. glaip_sdk/models/agent_runs.py +2 -1
  101. glaip_sdk/models/constants.py +141 -0
  102. glaip_sdk/models/model.py +170 -0
  103. glaip_sdk/models/schedule.py +224 -0
  104. glaip_sdk/payload_schemas/agent.py +1 -0
  105. glaip_sdk/payload_schemas/guardrails.py +34 -0
  106. glaip_sdk/ptc.py +145 -0
  107. glaip_sdk/registry/tool.py +270 -57
  108. glaip_sdk/runner/__init__.py +20 -3
  109. glaip_sdk/runner/deps.py +4 -1
  110. glaip_sdk/runner/langgraph.py +251 -27
  111. glaip_sdk/runner/logging_config.py +77 -0
  112. glaip_sdk/runner/mcp_adapter/mcp_config_builder.py +30 -9
  113. glaip_sdk/runner/ptc_adapter.py +98 -0
  114. glaip_sdk/runner/tool_adapter/langchain_tool_adapter.py +25 -2
  115. glaip_sdk/schedules/__init__.py +22 -0
  116. glaip_sdk/schedules/base.py +291 -0
  117. glaip_sdk/tools/base.py +67 -14
  118. glaip_sdk/utils/__init__.py +1 -0
  119. glaip_sdk/utils/agent_config.py +8 -2
  120. glaip_sdk/utils/bundler.py +138 -2
  121. glaip_sdk/utils/import_resolver.py +427 -49
  122. glaip_sdk/utils/runtime_config.py +3 -2
  123. glaip_sdk/utils/sync.py +31 -11
  124. glaip_sdk/utils/tool_detection.py +274 -6
  125. {glaip_sdk-0.6.19.dist-info → glaip_sdk-0.7.27.dist-info}/METADATA +22 -8
  126. glaip_sdk-0.7.27.dist-info/RECORD +227 -0
  127. {glaip_sdk-0.6.19.dist-info → glaip_sdk-0.7.27.dist-info}/WHEEL +1 -1
  128. glaip_sdk-0.7.27.dist-info/entry_points.txt +2 -0
  129. glaip_sdk/cli/commands/agents.py +0 -1509
  130. glaip_sdk/cli/commands/mcps.py +0 -1356
  131. glaip_sdk/cli/commands/tools.py +0 -576
  132. glaip_sdk/cli/utils.py +0 -263
  133. glaip_sdk-0.6.19.dist-info/RECORD +0 -163
  134. glaip_sdk-0.6.19.dist-info/entry_points.txt +0 -2
  135. {glaip_sdk-0.6.19.dist-info → glaip_sdk-0.7.27.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,72 @@
1
+ """Sync LangFlow agents command.
2
+
3
+ Authors:
4
+ Raymond Christopher (raymond.christopher@gdplabs.id)
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from typing import Any
10
+
11
+ import click
12
+
13
+ from glaip_sdk.cli.context import get_ctx_value, output_flags
14
+ from glaip_sdk.cli.display import handle_json_output, handle_rich_output
15
+ from glaip_sdk.cli.core.context import get_client
16
+ from glaip_sdk.cli.rich_helpers import markup_text
17
+
18
+ from ._common import _handle_command_exception, agents_group
19
+
20
+ from glaip_sdk.branding import SUCCESS_STYLE
21
+
22
+
23
+ @agents_group.command()
24
+ @click.option(
25
+ "--base-url",
26
+ help="Custom LangFlow server base URL (overrides LANGFLOW_BASE_URL env var)",
27
+ )
28
+ @click.option("--api-key", help="Custom LangFlow API key (overrides LANGFLOW_API_KEY env var)")
29
+ @output_flags()
30
+ @click.pass_context
31
+ def sync_langflow(ctx: Any, base_url: str | None, api_key: str | None) -> None:
32
+ r"""Sync agents with LangFlow server flows.
33
+
34
+ This command fetches all flows from the configured LangFlow server and
35
+ creates/updates corresponding agents in the platform.
36
+
37
+ The LangFlow server configuration can be provided via:
38
+ - Command options (--base-url, --api-key)
39
+ - Environment variables (LANGFLOW_BASE_URL, LANGFLOW_API_KEY)
40
+
41
+ \b
42
+ Examples:
43
+ aip agents sync-langflow
44
+ aip agents sync-langflow --base-url https://my-langflow.com --api-key my-key
45
+ """
46
+ try:
47
+ client = get_client(ctx)
48
+
49
+ # Perform the sync
50
+ result = client.sync_langflow_agents(base_url=base_url, api_key=api_key)
51
+
52
+ # Handle output format
53
+ handle_json_output(ctx, result)
54
+
55
+ # Show success message for non-JSON output
56
+ if get_ctx_value(ctx, "view") != "json":
57
+ # Extract some useful info from the result
58
+ success_count = result.get("data", {}).get("created_count", 0) + result.get("data", {}).get(
59
+ "updated_count", 0
60
+ )
61
+ total_count = result.get("data", {}).get("total_processed", 0)
62
+
63
+ handle_rich_output(
64
+ ctx,
65
+ markup_text(
66
+ f"[{SUCCESS_STYLE}]✅ Successfully synced {success_count} LangFlow agents "
67
+ f"({total_count} total processed)[/]"
68
+ ),
69
+ )
70
+
71
+ except Exception as e:
72
+ _handle_command_exception(ctx, e)
@@ -0,0 +1,112 @@
1
+ """Update agent command.
2
+
3
+ Authors:
4
+ Raymond Christopher (raymond.christopher@gdplabs.id)
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from typing import Any
10
+
11
+ import click
12
+
13
+ from glaip_sdk.cli.context import output_flags
14
+ from glaip_sdk.cli.display import (
15
+ display_agent_run_suggestions,
16
+ display_update_success,
17
+ handle_json_output,
18
+ handle_rich_output,
19
+ )
20
+ from glaip_sdk.cli.core.context import get_client
21
+
22
+ from ._common import (
23
+ _get_agent_for_update,
24
+ _handle_click_exception_for_json,
25
+ _handle_command_exception,
26
+ _prepare_agent_output,
27
+ _resolve_resources_by_name,
28
+ _split_comma_separated_refs,
29
+ agents_group,
30
+ )
31
+
32
+
33
+ @agents_group.command()
34
+ @click.argument("agent_id")
35
+ @click.option("--name", help="New agent name")
36
+ @click.option("--instruction", help="New instruction")
37
+ @click.option("--tools", multiple=True, help="New tool names or IDs")
38
+ @click.option("--agents", multiple=True, help="New sub-agent names")
39
+ @click.option("--mcps", multiple=True, help="New MCP names or IDs")
40
+ @click.option("--timeout", type=int, help="New timeout value")
41
+ @click.option(
42
+ "--import",
43
+ "import_file",
44
+ type=click.Path(exists=True, dir_okay=False),
45
+ help="Import agent configuration from JSON file",
46
+ )
47
+ @output_flags()
48
+ @click.pass_context
49
+ def update(
50
+ ctx: Any,
51
+ agent_id: str,
52
+ name: str | None,
53
+ instruction: str | None,
54
+ tools: tuple[str, ...] | None,
55
+ agents: tuple[str, ...] | None,
56
+ mcps: tuple[str, ...] | None,
57
+ timeout: float | None,
58
+ import_file: str | None,
59
+ ) -> None:
60
+ r"""Update an existing agent.
61
+
62
+ \b
63
+ Examples:
64
+ aip agents update my-agent --instruction "New instruction"
65
+ aip agents update my-agent --import agent.json
66
+ """
67
+ try:
68
+ client = get_client(ctx)
69
+ tools = _split_comma_separated_refs(tools)
70
+ agents = _split_comma_separated_refs(agents)
71
+ mcps = _split_comma_separated_refs(mcps)
72
+
73
+ has_updates = bool(import_file) or any(
74
+ [
75
+ name is not None,
76
+ instruction is not None,
77
+ bool(tools),
78
+ bool(agents),
79
+ bool(mcps),
80
+ timeout is not None,
81
+ ]
82
+ )
83
+ if not has_updates:
84
+ raise click.ClickException("No update fields specified")
85
+
86
+ agent = _get_agent_for_update(client, agent_id)
87
+
88
+ resolved_tools = _resolve_resources_by_name(client, tools, "tool", client.find_tools, "Tool") if tools else None
89
+ resolved_agents = (
90
+ _resolve_resources_by_name(client, agents, "agent", client.find_agents, "Agent") if agents else None
91
+ )
92
+ resolved_mcps = _resolve_resources_by_name(client, mcps, "mcp", client.find_mcps, "MCP") if mcps else None
93
+
94
+ updated_agent = client.agents.update_agent(
95
+ agent.id,
96
+ file=import_file,
97
+ name=name,
98
+ instruction=instruction,
99
+ tools=resolved_tools,
100
+ agents=resolved_agents,
101
+ mcps=resolved_mcps,
102
+ timeout=timeout,
103
+ )
104
+
105
+ handle_json_output(ctx, _prepare_agent_output(updated_agent))
106
+ handle_rich_output(ctx, display_update_success("Agent", updated_agent.name))
107
+ handle_rich_output(ctx, display_agent_run_suggestions(updated_agent))
108
+
109
+ except click.ClickException as e:
110
+ _handle_click_exception_for_json(ctx, e)
111
+ except Exception as e:
112
+ _handle_command_exception(ctx, e)
@@ -9,7 +9,7 @@ import click
9
9
  from rich.console import Console
10
10
  from rich.text import Text
11
11
  from glaip_sdk.branding import PRIMARY, SUCCESS_STYLE, WARNING_STYLE, AIPBranding
12
- from glaip_sdk.cli.utils import sdk_version
12
+ from glaip_sdk.cli.core.output import sdk_version
13
13
 
14
14
  if TYPE_CHECKING: # pragma: no cover - type checking only
15
15
  from glaip_sdk import Client
@@ -27,10 +27,9 @@ except ImportError: # pragma: no cover - optional dependency
27
27
  from glaip_sdk.cli.account_store import get_account_store
28
28
  from glaip_sdk.cli.commands.common_config import check_connection, render_branding_header
29
29
  from glaip_sdk.cli.config import CONFIG_FILE, load_config, save_config
30
- from glaip_sdk.cli.hints import format_command_hint
30
+ from glaip_sdk.cli.hints import command_hint, format_command_hint
31
31
  from glaip_sdk.cli.masking import mask_api_key_display
32
32
  from glaip_sdk.cli.rich_helpers import markup_text
33
- from glaip_sdk.cli.utils import command_hint
34
33
  from glaip_sdk.rich_components import AIPTable
35
34
 
36
35
  console = Console()
@@ -0,0 +1,94 @@
1
+ """MCP CLI commands package.
2
+
3
+ This package contains MCP management commands split by operation.
4
+ The package is the canonical import surface.
5
+
6
+ Authors:
7
+ Raymond Christopher (raymond.christopher@gdplabs.id)
8
+ """
9
+
10
+ # pylint: disable=duplicate-code
11
+ from glaip_sdk.cli.commands.mcps._common import ( # noqa: E402
12
+ mcps_group,
13
+ _resolve_mcp,
14
+ console,
15
+ _load_import_ready_payload,
16
+ _merge_import_payload,
17
+ _strip_server_only_fields,
18
+ _coerce_cli_string,
19
+ _collect_cli_overrides,
20
+ _merge_config_field,
21
+ _merge_auth_field,
22
+ _get_config_transport,
23
+ _generate_update_preview,
24
+ )
25
+ from glaip_sdk.cli.commands.mcps.connect import connect # noqa: E402
26
+ from glaip_sdk.cli.commands.mcps.create import create # noqa: E402
27
+ from glaip_sdk.cli.commands.mcps.delete import delete # noqa: E402
28
+ from glaip_sdk.cli.commands.mcps.get import get # noqa: E402
29
+ from glaip_sdk.cli.commands.mcps.list import list_mcps # noqa: E402
30
+ from glaip_sdk.cli.commands.mcps.tools import list_tools, _get_tools_from_config # noqa: E402
31
+ from glaip_sdk.cli.commands.mcps.update import update # noqa: E402
32
+
33
+ # Import core functions for test compatibility
34
+ from glaip_sdk.cli.core.context import get_client # noqa: E402
35
+ from glaip_sdk.cli.core.output import ( # noqa: E402
36
+ output_list,
37
+ output_result,
38
+ )
39
+ from glaip_sdk.cli.core.rendering import ( # noqa: E402
40
+ spinner_context,
41
+ with_client_and_spinner,
42
+ )
43
+
44
+ # Import validators for test compatibility
45
+ from glaip_sdk.cli.mcp_validators import ( # noqa: E402
46
+ validate_mcp_auth_structure,
47
+ validate_mcp_config_structure,
48
+ )
49
+
50
+ # Import import/export utilities for test compatibility
51
+ from glaip_sdk.utils.import_export import convert_export_to_import_format # noqa: E402
52
+ from glaip_sdk.cli.io import load_resource_from_file_with_validation # noqa: E402
53
+
54
+ # Import shared formatters for test compatibility
55
+ from glaip_sdk.cli.commands.shared.formatters import ( # noqa: E402
56
+ _format_dict_value,
57
+ _redact_sensitive_dict,
58
+ _is_sensitive_data,
59
+ )
60
+
61
+ __all__ = [
62
+ "mcps_group",
63
+ "connect",
64
+ "create",
65
+ "delete",
66
+ "get",
67
+ "list_mcps",
68
+ "list_tools",
69
+ "update",
70
+ "_resolve_mcp",
71
+ "console",
72
+ "_load_import_ready_payload",
73
+ "_merge_import_payload",
74
+ "_strip_server_only_fields",
75
+ "_coerce_cli_string",
76
+ "_collect_cli_overrides",
77
+ "_merge_config_field",
78
+ "_merge_auth_field",
79
+ "_get_config_transport",
80
+ "_generate_update_preview",
81
+ "_get_tools_from_config",
82
+ "_format_dict_value",
83
+ "_redact_sensitive_dict",
84
+ "_is_sensitive_data",
85
+ "get_client",
86
+ "output_list",
87
+ "output_result",
88
+ "spinner_context",
89
+ "with_client_and_spinner",
90
+ "validate_mcp_auth_structure",
91
+ "validate_mcp_config_structure",
92
+ "convert_export_to_import_format",
93
+ "load_resource_from_file_with_validation",
94
+ ]