glaip-sdk 0.1.3__py3-none-any.whl → 0.6.10__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 (141) hide show
  1. glaip_sdk/__init__.py +5 -2
  2. glaip_sdk/_version.py +9 -0
  3. glaip_sdk/agents/__init__.py +27 -0
  4. glaip_sdk/agents/base.py +1191 -0
  5. glaip_sdk/branding.py +13 -0
  6. glaip_sdk/cli/account_store.py +540 -0
  7. glaip_sdk/cli/auth.py +254 -15
  8. glaip_sdk/cli/commands/__init__.py +2 -2
  9. glaip_sdk/cli/commands/accounts.py +746 -0
  10. glaip_sdk/cli/commands/agents.py +213 -73
  11. glaip_sdk/cli/commands/common_config.py +101 -0
  12. glaip_sdk/cli/commands/configure.py +729 -113
  13. glaip_sdk/cli/commands/mcps.py +241 -72
  14. glaip_sdk/cli/commands/models.py +11 -5
  15. glaip_sdk/cli/commands/tools.py +49 -57
  16. glaip_sdk/cli/commands/transcripts.py +755 -0
  17. glaip_sdk/cli/config.py +48 -4
  18. glaip_sdk/cli/constants.py +38 -0
  19. glaip_sdk/cli/context.py +8 -0
  20. glaip_sdk/cli/core/__init__.py +79 -0
  21. glaip_sdk/cli/core/context.py +124 -0
  22. glaip_sdk/cli/core/output.py +846 -0
  23. glaip_sdk/cli/core/prompting.py +649 -0
  24. glaip_sdk/cli/core/rendering.py +187 -0
  25. glaip_sdk/cli/display.py +35 -19
  26. glaip_sdk/cli/hints.py +57 -0
  27. glaip_sdk/cli/io.py +6 -3
  28. glaip_sdk/cli/main.py +228 -119
  29. glaip_sdk/cli/masking.py +21 -33
  30. glaip_sdk/cli/pager.py +9 -10
  31. glaip_sdk/cli/parsers/__init__.py +1 -3
  32. glaip_sdk/cli/slash/__init__.py +0 -9
  33. glaip_sdk/cli/slash/accounts_controller.py +578 -0
  34. glaip_sdk/cli/slash/accounts_shared.py +75 -0
  35. glaip_sdk/cli/slash/agent_session.py +62 -21
  36. glaip_sdk/cli/slash/prompt.py +21 -0
  37. glaip_sdk/cli/slash/remote_runs_controller.py +566 -0
  38. glaip_sdk/cli/slash/session.py +771 -140
  39. glaip_sdk/cli/slash/tui/__init__.py +9 -0
  40. glaip_sdk/cli/slash/tui/accounts.tcss +86 -0
  41. glaip_sdk/cli/slash/tui/accounts_app.py +876 -0
  42. glaip_sdk/cli/slash/tui/background_tasks.py +72 -0
  43. glaip_sdk/cli/slash/tui/loading.py +58 -0
  44. glaip_sdk/cli/slash/tui/remote_runs_app.py +628 -0
  45. glaip_sdk/cli/transcript/__init__.py +12 -52
  46. glaip_sdk/cli/transcript/cache.py +255 -44
  47. glaip_sdk/cli/transcript/capture.py +27 -1
  48. glaip_sdk/cli/transcript/history.py +815 -0
  49. glaip_sdk/cli/transcript/viewer.py +72 -499
  50. glaip_sdk/cli/update_notifier.py +14 -5
  51. glaip_sdk/cli/utils.py +243 -1252
  52. glaip_sdk/cli/validators.py +5 -6
  53. glaip_sdk/client/__init__.py +2 -1
  54. glaip_sdk/client/_agent_payloads.py +45 -9
  55. glaip_sdk/client/agent_runs.py +147 -0
  56. glaip_sdk/client/agents.py +287 -29
  57. glaip_sdk/client/base.py +1 -0
  58. glaip_sdk/client/main.py +19 -10
  59. glaip_sdk/client/mcps.py +122 -12
  60. glaip_sdk/client/run_rendering.py +133 -88
  61. glaip_sdk/client/shared.py +21 -0
  62. glaip_sdk/client/tools.py +155 -10
  63. glaip_sdk/config/constants.py +11 -0
  64. glaip_sdk/mcps/__init__.py +21 -0
  65. glaip_sdk/mcps/base.py +345 -0
  66. glaip_sdk/models/__init__.py +90 -0
  67. glaip_sdk/models/agent.py +47 -0
  68. glaip_sdk/models/agent_runs.py +116 -0
  69. glaip_sdk/models/common.py +42 -0
  70. glaip_sdk/models/mcp.py +33 -0
  71. glaip_sdk/models/tool.py +33 -0
  72. glaip_sdk/payload_schemas/__init__.py +1 -13
  73. glaip_sdk/registry/__init__.py +55 -0
  74. glaip_sdk/registry/agent.py +164 -0
  75. glaip_sdk/registry/base.py +139 -0
  76. glaip_sdk/registry/mcp.py +253 -0
  77. glaip_sdk/registry/tool.py +232 -0
  78. glaip_sdk/rich_components.py +58 -2
  79. glaip_sdk/runner/__init__.py +59 -0
  80. glaip_sdk/runner/base.py +84 -0
  81. glaip_sdk/runner/deps.py +115 -0
  82. glaip_sdk/runner/langgraph.py +706 -0
  83. glaip_sdk/runner/mcp_adapter/__init__.py +13 -0
  84. glaip_sdk/runner/mcp_adapter/base_mcp_adapter.py +43 -0
  85. glaip_sdk/runner/mcp_adapter/langchain_mcp_adapter.py +257 -0
  86. glaip_sdk/runner/mcp_adapter/mcp_config_builder.py +95 -0
  87. glaip_sdk/runner/tool_adapter/__init__.py +18 -0
  88. glaip_sdk/runner/tool_adapter/base_tool_adapter.py +44 -0
  89. glaip_sdk/runner/tool_adapter/langchain_tool_adapter.py +219 -0
  90. glaip_sdk/tools/__init__.py +22 -0
  91. glaip_sdk/tools/base.py +435 -0
  92. glaip_sdk/utils/__init__.py +58 -12
  93. glaip_sdk/utils/a2a/__init__.py +34 -0
  94. glaip_sdk/utils/a2a/event_processor.py +188 -0
  95. glaip_sdk/utils/bundler.py +267 -0
  96. glaip_sdk/utils/client.py +111 -0
  97. glaip_sdk/utils/client_utils.py +39 -7
  98. glaip_sdk/utils/datetime_helpers.py +58 -0
  99. glaip_sdk/utils/discovery.py +78 -0
  100. glaip_sdk/utils/display.py +23 -15
  101. glaip_sdk/utils/export.py +143 -0
  102. glaip_sdk/utils/general.py +0 -33
  103. glaip_sdk/utils/import_export.py +12 -7
  104. glaip_sdk/utils/import_resolver.py +492 -0
  105. glaip_sdk/utils/instructions.py +101 -0
  106. glaip_sdk/utils/rendering/__init__.py +115 -1
  107. glaip_sdk/utils/rendering/formatting.py +5 -30
  108. glaip_sdk/utils/rendering/layout/__init__.py +64 -0
  109. glaip_sdk/utils/rendering/{renderer → layout}/panels.py +9 -0
  110. glaip_sdk/utils/rendering/{renderer → layout}/progress.py +70 -1
  111. glaip_sdk/utils/rendering/layout/summary.py +74 -0
  112. glaip_sdk/utils/rendering/layout/transcript.py +606 -0
  113. glaip_sdk/utils/rendering/models.py +1 -0
  114. glaip_sdk/utils/rendering/renderer/__init__.py +9 -47
  115. glaip_sdk/utils/rendering/renderer/base.py +217 -1476
  116. glaip_sdk/utils/rendering/renderer/debug.py +26 -20
  117. glaip_sdk/utils/rendering/renderer/factory.py +138 -0
  118. glaip_sdk/utils/rendering/renderer/stream.py +4 -12
  119. glaip_sdk/utils/rendering/renderer/thinking.py +273 -0
  120. glaip_sdk/utils/rendering/renderer/tool_panels.py +442 -0
  121. glaip_sdk/utils/rendering/renderer/transcript_mode.py +162 -0
  122. glaip_sdk/utils/rendering/state.py +204 -0
  123. glaip_sdk/utils/rendering/steps/__init__.py +34 -0
  124. glaip_sdk/utils/rendering/{steps.py → steps/event_processor.py} +53 -440
  125. glaip_sdk/utils/rendering/steps/format.py +176 -0
  126. glaip_sdk/utils/rendering/steps/manager.py +387 -0
  127. glaip_sdk/utils/rendering/timing.py +36 -0
  128. glaip_sdk/utils/rendering/viewer/__init__.py +21 -0
  129. glaip_sdk/utils/rendering/viewer/presenter.py +184 -0
  130. glaip_sdk/utils/resource_refs.py +25 -13
  131. glaip_sdk/utils/runtime_config.py +425 -0
  132. glaip_sdk/utils/serialization.py +18 -0
  133. glaip_sdk/utils/sync.py +142 -0
  134. glaip_sdk/utils/tool_detection.py +33 -0
  135. glaip_sdk/utils/validation.py +16 -24
  136. {glaip_sdk-0.1.3.dist-info → glaip_sdk-0.6.10.dist-info}/METADATA +42 -4
  137. glaip_sdk-0.6.10.dist-info/RECORD +159 -0
  138. {glaip_sdk-0.1.3.dist-info → glaip_sdk-0.6.10.dist-info}/WHEEL +1 -1
  139. glaip_sdk/models.py +0 -240
  140. glaip_sdk-0.1.3.dist-info/RECORD +0 -83
  141. {glaip_sdk-0.1.3.dist-info → glaip_sdk-0.6.10.dist-info}/entry_points.txt +0 -0
glaip_sdk/cli/masking.py CHANGED
@@ -6,9 +6,10 @@ Authors:
6
6
 
7
7
  from __future__ import annotations
8
8
 
9
- import os
10
9
  from typing import Any
11
10
 
11
+ from glaip_sdk.cli.constants import MASK_SENSITIVE_FIELDS, MASKING_ENABLED
12
+
12
13
  __all__ = [
13
14
  "mask_payload",
14
15
  "mask_rows",
@@ -16,20 +17,9 @@ __all__ = [
16
17
  "_mask_any",
17
18
  "_maybe_mask_row",
18
19
  "_resolve_mask_fields",
20
+ "mask_api_key_display",
19
21
  ]
20
22
 
21
- _DEFAULT_MASK_FIELDS = {
22
- "api_key",
23
- "apikey",
24
- "token",
25
- "access_token",
26
- "secret",
27
- "client_secret",
28
- "password",
29
- "private_key",
30
- "bearer",
31
- }
32
-
33
23
 
34
24
  def _mask_value(raw: Any) -> str:
35
25
  """Return a masked representation of the provided value.
@@ -90,22 +80,10 @@ def _maybe_mask_row(row: dict[str, Any], mask_fields: set[str]) -> dict[str, Any
90
80
 
91
81
 
92
82
  def _resolve_mask_fields() -> set[str]:
93
- """Resolve the set of sensitive fields to mask based on environment.
94
-
95
- Returns:
96
- set[str]: Set of field names to mask. Empty set if masking is disabled
97
- via AIP_MASK_OFF environment variable, custom fields from
98
- AIP_MASK_FIELDS, or default fields if neither is set.
99
- """
100
- if os.getenv("AIP_MASK_OFF", "0") in {"1", "true", "on", "yes"}:
83
+ """Return the configured set of fields that should be masked."""
84
+ if not MASKING_ENABLED:
101
85
  return set()
102
-
103
- env_fields = (os.getenv("AIP_MASK_FIELDS") or "").strip()
104
- if env_fields:
105
- parts = [part.strip().lower() for part in env_fields.split(",") if part.strip()]
106
- return set(parts)
107
-
108
- return set(_DEFAULT_MASK_FIELDS)
86
+ return set(MASK_SENSITIVE_FIELDS)
109
87
 
110
88
 
111
89
  def mask_payload(payload: Any) -> Any:
@@ -115,9 +93,7 @@ def mask_payload(payload: Any) -> Any:
115
93
  payload: Any data structure (dict, list, or primitive) to mask.
116
94
 
117
95
  Returns:
118
- Any: The payload with sensitive fields masked based on environment
119
- configuration. Returns original payload if masking is disabled
120
- or if an error occurs during masking.
96
+ Any: The payload with sensitive fields masked based on configuration.
121
97
  """
122
98
  mask_fields = _resolve_mask_fields()
123
99
  if not mask_fields:
@@ -136,8 +112,8 @@ def mask_rows(rows: list[dict[str, Any]]) -> list[dict[str, Any]]:
136
112
 
137
113
  Returns:
138
114
  list[dict[str, Any]]: List of rows with sensitive fields masked based
139
- on environment configuration. Returns original
140
- rows if masking is disabled or if an error occurs.
115
+ on configuration. Returns original rows if
116
+ masking is disabled or if an error occurs.
141
117
  """
142
118
  mask_fields = _resolve_mask_fields()
143
119
  if not mask_fields:
@@ -146,3 +122,15 @@ def mask_rows(rows: list[dict[str, Any]]) -> list[dict[str, Any]]:
146
122
  return [_maybe_mask_row(row, mask_fields) for row in rows]
147
123
  except Exception:
148
124
  return rows
125
+
126
+
127
+ def mask_api_key_display(value: str | None) -> str:
128
+ """Mask API keys for CLI display while preserving readability for short keys."""
129
+ if not value:
130
+ return ""
131
+ length = len(value)
132
+ if length <= 4:
133
+ return "***"
134
+ if length <= 8:
135
+ return value[:1] + "••••" + value[-1:]
136
+ return value[:4] + "••••" + value[-4:]
glaip_sdk/cli/pager.py CHANGED
@@ -19,6 +19,8 @@ from typing import Any
19
19
 
20
20
  from rich.console import Console
21
21
 
22
+ from glaip_sdk.cli.constants import PAGER_HEADER_ENABLED, PAGER_MODE, PAGER_WRAP_LINES
23
+
22
24
  __all__ = [
23
25
  "console",
24
26
  "_prepare_pager_env",
@@ -64,8 +66,7 @@ def _prepare_pager_env(clear_on_exit: bool = True) -> None:
64
66
  -R : pass ANSI color escapes
65
67
  -S : chop long lines (horizontal scroll with ←/→)
66
68
  (No -F, no -X) so we open a full-screen pager and clear on exit.
67
- Toggle wrapping with AIP_PAGER_WRAP=1 to drop -S.
68
- Power users can override via AIP_LESS_FLAGS.
69
+ Toggle wrapping via `PAGER_WRAP_LINES` (True drops -S).
69
70
 
70
71
  Args:
71
72
  clear_on_exit: Whether to clear the pager on exit (default: True)
@@ -75,10 +76,9 @@ def _prepare_pager_env(clear_on_exit: bool = True) -> None:
75
76
  """
76
77
  os.environ.pop("LESSSECURE", None)
77
78
  if os.getenv("LESS") is None:
78
- want_wrap = os.getenv("AIP_PAGER_WRAP", "0") == "1"
79
- base = "-R" if want_wrap else "-RS"
79
+ base = "-R" if PAGER_WRAP_LINES else "-RS"
80
80
  default_flags = base if clear_on_exit else (base + "FX")
81
- os.environ["LESS"] = os.getenv("AIP_LESS_FLAGS", default_flags)
81
+ os.environ["LESS"] = default_flags
82
82
 
83
83
 
84
84
  def _render_ansi(renderable: Any) -> str:
@@ -111,8 +111,7 @@ def _pager_header() -> str:
111
111
  Returns:
112
112
  str: Header text containing navigation help, or empty string if disabled
113
113
  """
114
- v = (os.getenv("AIP_PAGER_HEADER", "1") or "1").strip().lower()
115
- if v in {"0", "false", "off"}:
114
+ if not PAGER_HEADER_ENABLED:
116
115
  return ""
117
116
  return "\n".join(
118
117
  [
@@ -254,10 +253,10 @@ def _should_page_output(row_count: int, is_tty: bool) -> bool:
254
253
  bool: True if output should be paginated, False otherwise
255
254
  """
256
255
  active_console = _get_console()
257
- pager_env = (os.getenv("AIP_PAGER", "auto") or "auto").lower()
258
- if pager_env in ("0", "off", "false"):
256
+ pager_mode = (PAGER_MODE or "auto").lower()
257
+ if pager_mode in ("0", "off", "false"):
259
258
  return False
260
- if pager_env in ("1", "on", "true"):
259
+ if pager_mode in ("1", "on", "true"):
261
260
  return is_tty
262
261
  try:
263
262
  term_h = active_console.size.height or 24
@@ -4,6 +4,4 @@ Authors:
4
4
  Putu Ravindra Wiguna (putu.r.wiguna@gdplabs.id)
5
5
  """
6
6
 
7
- from glaip_sdk.cli.parsers.json_input import parse_json_input
8
-
9
- __all__ = ["parse_json_input"]
7
+ __all__: list[str] = []
@@ -6,19 +6,10 @@ Authors:
6
6
 
7
7
  from glaip_sdk.cli.commands.agents import get as agents_get_command
8
8
  from glaip_sdk.cli.commands.agents import run as agents_run_command
9
- from glaip_sdk.cli.commands.configure import configure_command, load_config
10
- from glaip_sdk.cli.slash.agent_session import AgentRunSession
11
- from glaip_sdk.cli.slash.prompt import _HAS_PROMPT_TOOLKIT
12
9
  from glaip_sdk.cli.slash.session import SlashSession
13
- from glaip_sdk.cli.utils import get_client
14
10
 
15
11
  __all__ = [
16
- "AgentRunSession",
17
12
  "SlashSession",
18
- "_HAS_PROMPT_TOOLKIT",
19
13
  "agents_get_command",
20
14
  "agents_run_command",
21
- "configure_command",
22
- "get_client",
23
- "load_config",
24
15
  ]