glaip-sdk 0.6.24__py3-none-any.whl → 0.6.26__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 (52) hide show
  1. glaip_sdk/cli/commands/agents/__init__.py +119 -0
  2. glaip_sdk/cli/commands/agents/_common.py +561 -0
  3. glaip_sdk/cli/commands/agents/create.py +151 -0
  4. glaip_sdk/cli/commands/agents/delete.py +64 -0
  5. glaip_sdk/cli/commands/agents/get.py +89 -0
  6. glaip_sdk/cli/commands/agents/list.py +129 -0
  7. glaip_sdk/cli/commands/agents/run.py +264 -0
  8. glaip_sdk/cli/commands/agents/sync_langflow.py +72 -0
  9. glaip_sdk/cli/commands/agents/update.py +112 -0
  10. glaip_sdk/cli/commands/mcps/__init__.py +98 -0
  11. glaip_sdk/cli/commands/mcps/_common.py +490 -0
  12. glaip_sdk/cli/commands/mcps/connect.py +82 -0
  13. glaip_sdk/cli/commands/mcps/create.py +153 -0
  14. glaip_sdk/cli/commands/mcps/delete.py +73 -0
  15. glaip_sdk/cli/commands/mcps/get.py +212 -0
  16. glaip_sdk/cli/commands/mcps/list.py +69 -0
  17. glaip_sdk/cli/commands/mcps/tools.py +235 -0
  18. glaip_sdk/cli/commands/mcps/update.py +146 -0
  19. glaip_sdk/cli/commands/shared/__init__.py +21 -0
  20. glaip_sdk/cli/commands/shared/formatters.py +91 -0
  21. glaip_sdk/cli/commands/tools/__init__.py +69 -0
  22. glaip_sdk/cli/commands/tools/_common.py +80 -0
  23. glaip_sdk/cli/commands/tools/create.py +228 -0
  24. glaip_sdk/cli/commands/tools/delete.py +61 -0
  25. glaip_sdk/cli/commands/tools/get.py +103 -0
  26. glaip_sdk/cli/commands/tools/list.py +69 -0
  27. glaip_sdk/cli/commands/tools/script.py +49 -0
  28. glaip_sdk/cli/commands/tools/update.py +102 -0
  29. glaip_sdk/cli/commands/transcripts/__init__.py +90 -0
  30. glaip_sdk/cli/commands/transcripts/_common.py +9 -0
  31. glaip_sdk/cli/commands/transcripts/clear.py +5 -0
  32. glaip_sdk/cli/commands/transcripts/detail.py +5 -0
  33. glaip_sdk/client/_agent_payloads.py +32 -500
  34. glaip_sdk/client/agents.py +1 -1
  35. glaip_sdk/client/main.py +1 -1
  36. glaip_sdk/client/mcps.py +44 -13
  37. glaip_sdk/client/payloads/agent/__init__.py +23 -0
  38. glaip_sdk/client/payloads/agent/requests.py +495 -0
  39. glaip_sdk/client/payloads/agent/responses.py +43 -0
  40. glaip_sdk/client/tools.py +38 -3
  41. glaip_sdk/registry/tool.py +54 -5
  42. glaip_sdk/tools/base.py +41 -10
  43. glaip_sdk/utils/import_resolver.py +40 -2
  44. {glaip_sdk-0.6.24.dist-info → glaip_sdk-0.6.26.dist-info}/METADATA +1 -1
  45. {glaip_sdk-0.6.24.dist-info → glaip_sdk-0.6.26.dist-info}/RECORD +49 -17
  46. glaip_sdk/cli/commands/agents.py +0 -1502
  47. glaip_sdk/cli/commands/mcps.py +0 -1355
  48. glaip_sdk/cli/commands/tools.py +0 -575
  49. /glaip_sdk/cli/commands/{transcripts.py → transcripts_original.py} +0 -0
  50. {glaip_sdk-0.6.24.dist-info → glaip_sdk-0.6.26.dist-info}/WHEEL +0 -0
  51. {glaip_sdk-0.6.24.dist-info → glaip_sdk-0.6.26.dist-info}/entry_points.txt +0 -0
  52. {glaip_sdk-0.6.24.dist-info → glaip_sdk-0.6.26.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)
@@ -0,0 +1,98 @@
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
+ _assemble_update_data_from_import_payload,
18
+ _assemble_update_data_from_cli_options,
19
+ _strip_server_only_fields,
20
+ _coerce_cli_string,
21
+ _collect_cli_overrides,
22
+ _merge_config_field,
23
+ _merge_auth_field,
24
+ _get_config_transport,
25
+ _generate_update_preview,
26
+ )
27
+ from glaip_sdk.cli.commands.mcps.connect import connect # noqa: E402
28
+ from glaip_sdk.cli.commands.mcps.create import create # noqa: E402
29
+ from glaip_sdk.cli.commands.mcps.delete import delete # noqa: E402
30
+ from glaip_sdk.cli.commands.mcps.get import get # noqa: E402
31
+ from glaip_sdk.cli.commands.mcps.list import list_mcps # noqa: E402
32
+ from glaip_sdk.cli.commands.mcps.tools import list_tools, _get_tools_from_config # noqa: E402
33
+ from glaip_sdk.cli.commands.mcps.update import update # noqa: E402
34
+
35
+ # Import core functions for test compatibility
36
+ from glaip_sdk.cli.core.context import get_client # noqa: E402
37
+ from glaip_sdk.cli.core.output import ( # noqa: E402
38
+ output_list,
39
+ output_result,
40
+ )
41
+ from glaip_sdk.cli.core.rendering import ( # noqa: E402
42
+ spinner_context,
43
+ with_client_and_spinner,
44
+ )
45
+
46
+ # Import validators for test compatibility
47
+ from glaip_sdk.cli.mcp_validators import ( # noqa: E402
48
+ validate_mcp_auth_structure,
49
+ validate_mcp_config_structure,
50
+ )
51
+
52
+ # Import import/export utilities for test compatibility
53
+ from glaip_sdk.utils.import_export import convert_export_to_import_format # noqa: E402
54
+ from glaip_sdk.cli.io import load_resource_from_file_with_validation # noqa: E402
55
+
56
+ # Import shared formatters for test compatibility
57
+ from glaip_sdk.cli.commands.shared.formatters import ( # noqa: E402
58
+ _format_dict_value,
59
+ _redact_sensitive_dict,
60
+ _is_sensitive_data,
61
+ )
62
+
63
+ __all__ = [
64
+ "mcps_group",
65
+ "connect",
66
+ "create",
67
+ "delete",
68
+ "get",
69
+ "list_mcps",
70
+ "list_tools",
71
+ "update",
72
+ "_resolve_mcp",
73
+ "console",
74
+ "_load_import_ready_payload",
75
+ "_merge_import_payload",
76
+ "_assemble_update_data_from_import_payload",
77
+ "_assemble_update_data_from_cli_options",
78
+ "_strip_server_only_fields",
79
+ "_coerce_cli_string",
80
+ "_collect_cli_overrides",
81
+ "_merge_config_field",
82
+ "_merge_auth_field",
83
+ "_get_config_transport",
84
+ "_generate_update_preview",
85
+ "_get_tools_from_config",
86
+ "_format_dict_value",
87
+ "_redact_sensitive_dict",
88
+ "_is_sensitive_data",
89
+ "get_client",
90
+ "output_list",
91
+ "output_result",
92
+ "spinner_context",
93
+ "with_client_and_spinner",
94
+ "validate_mcp_auth_structure",
95
+ "validate_mcp_config_structure",
96
+ "convert_export_to_import_format",
97
+ "load_resource_from_file_with_validation",
98
+ ]