glaip-sdk 0.3.0__py3-none-any.whl → 0.5.0__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 (58) hide show
  1. glaip_sdk/cli/account_store.py +522 -0
  2. glaip_sdk/cli/auth.py +224 -8
  3. glaip_sdk/cli/commands/accounts.py +414 -0
  4. glaip_sdk/cli/commands/agents.py +2 -2
  5. glaip_sdk/cli/commands/common_config.py +65 -0
  6. glaip_sdk/cli/commands/configure.py +153 -87
  7. glaip_sdk/cli/commands/mcps.py +191 -44
  8. glaip_sdk/cli/commands/transcripts.py +1 -1
  9. glaip_sdk/cli/config.py +31 -3
  10. glaip_sdk/cli/display.py +1 -1
  11. glaip_sdk/cli/hints.py +57 -0
  12. glaip_sdk/cli/io.py +6 -3
  13. glaip_sdk/cli/main.py +181 -79
  14. glaip_sdk/cli/masking.py +14 -1
  15. glaip_sdk/cli/slash/agent_session.py +2 -1
  16. glaip_sdk/cli/slash/remote_runs_controller.py +1 -1
  17. glaip_sdk/cli/slash/session.py +11 -9
  18. glaip_sdk/cli/slash/tui/remote_runs_app.py +2 -3
  19. glaip_sdk/cli/transcript/capture.py +12 -18
  20. glaip_sdk/cli/transcript/viewer.py +13 -646
  21. glaip_sdk/cli/update_notifier.py +2 -1
  22. glaip_sdk/cli/utils.py +95 -139
  23. glaip_sdk/client/agents.py +2 -4
  24. glaip_sdk/client/main.py +2 -18
  25. glaip_sdk/client/mcps.py +11 -1
  26. glaip_sdk/client/run_rendering.py +90 -111
  27. glaip_sdk/client/shared.py +21 -0
  28. glaip_sdk/models.py +8 -7
  29. glaip_sdk/utils/display.py +23 -15
  30. glaip_sdk/utils/rendering/__init__.py +6 -13
  31. glaip_sdk/utils/rendering/formatting.py +5 -30
  32. glaip_sdk/utils/rendering/layout/__init__.py +64 -0
  33. glaip_sdk/utils/rendering/{renderer → layout}/panels.py +9 -0
  34. glaip_sdk/utils/rendering/{renderer → layout}/progress.py +70 -1
  35. glaip_sdk/utils/rendering/layout/summary.py +74 -0
  36. glaip_sdk/utils/rendering/layout/transcript.py +606 -0
  37. glaip_sdk/utils/rendering/models.py +1 -0
  38. glaip_sdk/utils/rendering/renderer/__init__.py +10 -28
  39. glaip_sdk/utils/rendering/renderer/base.py +214 -1469
  40. glaip_sdk/utils/rendering/renderer/debug.py +24 -0
  41. glaip_sdk/utils/rendering/renderer/factory.py +138 -0
  42. glaip_sdk/utils/rendering/renderer/thinking.py +273 -0
  43. glaip_sdk/utils/rendering/renderer/tool_panels.py +442 -0
  44. glaip_sdk/utils/rendering/renderer/transcript_mode.py +162 -0
  45. glaip_sdk/utils/rendering/state.py +204 -0
  46. glaip_sdk/utils/rendering/steps/__init__.py +34 -0
  47. glaip_sdk/utils/rendering/{steps.py → steps/event_processor.py} +53 -440
  48. glaip_sdk/utils/rendering/steps/format.py +176 -0
  49. glaip_sdk/utils/rendering/steps/manager.py +387 -0
  50. glaip_sdk/utils/rendering/timing.py +36 -0
  51. glaip_sdk/utils/rendering/viewer/__init__.py +21 -0
  52. glaip_sdk/utils/rendering/viewer/presenter.py +184 -0
  53. glaip_sdk/utils/validation.py +13 -21
  54. {glaip_sdk-0.3.0.dist-info → glaip_sdk-0.5.0.dist-info}/METADATA +1 -1
  55. glaip_sdk-0.5.0.dist-info/RECORD +113 -0
  56. glaip_sdk-0.3.0.dist-info/RECORD +0 -94
  57. {glaip_sdk-0.3.0.dist-info → glaip_sdk-0.5.0.dist-info}/WHEEL +0 -0
  58. {glaip_sdk-0.3.0.dist-info → glaip_sdk-0.5.0.dist-info}/entry_points.txt +0 -0
@@ -30,6 +30,7 @@ from glaip_sdk.branding import (
30
30
  )
31
31
  from glaip_sdk.cli.constants import DEFAULT_REMOTE_RUNS_PAGE_LIMIT
32
32
  from glaip_sdk.cli.slash.tui.remote_runs_app import RemoteRunsTUICallbacks, run_remote_runs_textual
33
+ from glaip_sdk.cli.utils import prompt_export_choice_questionary, questionary_safe_ask
33
34
  from glaip_sdk.exceptions import (
34
35
  AuthenticationError,
35
36
  ForbiddenError,
@@ -40,7 +41,6 @@ from glaip_sdk.exceptions import (
40
41
  from glaip_sdk.rich_components import RemoteRunsTable
41
42
  from glaip_sdk.utils.export import export_remote_transcript_jsonl
42
43
  from glaip_sdk.utils.rendering import render_remote_sse_transcript
43
- from glaip_sdk.cli.utils import prompt_export_choice_questionary, questionary_safe_ask
44
44
 
45
45
  if TYPE_CHECKING: # pragma: no cover - type checking only
46
46
  from glaip_sdk.cli.slash.session import SlashSession
@@ -33,11 +33,12 @@ from glaip_sdk.branding import (
33
33
  WARNING_STYLE,
34
34
  AIPBranding,
35
35
  )
36
+ from glaip_sdk.cli.auth import resolve_api_url_from_context
36
37
  from glaip_sdk.cli.commands import transcripts as transcripts_cmd
37
38
  from glaip_sdk.cli.commands.configure import configure_command, load_config
38
39
  from glaip_sdk.cli.commands.update import update_command
40
+ from glaip_sdk.cli.hints import format_command_hint
39
41
  from glaip_sdk.cli.slash.agent_session import AgentRunSession
40
- from glaip_sdk.cli.slash.remote_runs_controller import RemoteRunsController
41
42
  from glaip_sdk.cli.slash.prompt import (
42
43
  FormattedText,
43
44
  PromptSession,
@@ -46,6 +47,7 @@ from glaip_sdk.cli.slash.prompt import (
46
47
  setup_prompt_toolkit,
47
48
  to_formatted_text,
48
49
  )
50
+ from glaip_sdk.cli.slash.remote_runs_controller import RemoteRunsController
49
51
  from glaip_sdk.cli.transcript import (
50
52
  export_cached_transcript,
51
53
  load_history_snapshot,
@@ -55,7 +57,6 @@ from glaip_sdk.cli.update_notifier import maybe_notify_update
55
57
  from glaip_sdk.cli.utils import (
56
58
  _fuzzy_pick_for_resources,
57
59
  command_hint,
58
- format_command_hint,
59
60
  format_size,
60
61
  get_client,
61
62
  restore_slash_session_context,
@@ -278,7 +279,11 @@ class SlashSession:
278
279
  def _ensure_configuration(self) -> bool:
279
280
  """Ensure the CLI has both API URL and credentials before continuing."""
280
281
  while not self._configuration_ready():
281
- self.console.print(f"[{WARNING_STYLE}]Configuration required.[/] Launching `/login` wizard...")
282
+ self.console.print(
283
+ f"[{WARNING_STYLE}]Configuration required.[/] "
284
+ "Slash mode cannot run 'aip accounts ...'. Run setup from your terminal (e.g., "
285
+ "'aip accounts add default' or 'aip configure'), or continue with the `/login` wizard here..."
286
+ )
282
287
  self._suppress_login_layout = True
283
288
  try:
284
289
  self._cmd_login([], False)
@@ -1285,12 +1290,9 @@ class SlashSession:
1285
1290
  )
1286
1291
  )
1287
1292
 
1288
- def _get_api_url(self, config: dict[str, Any]) -> str | None:
1289
- """Get the API URL from various sources."""
1290
- api_url = None
1291
- if isinstance(self.ctx.obj, dict):
1292
- api_url = self.ctx.obj.get("api_url")
1293
- return api_url or config.get("api_url") or os.getenv("AIP_API_URL")
1293
+ def _get_api_url(self, _config: dict[str, Any] | None = None) -> str | None:
1294
+ """Get the API URL from context or account store (CLI/palette ignores env credentials)."""
1295
+ return resolve_api_url_from_context(self.ctx)
1294
1296
 
1295
1297
  def _build_agent_status_line(self, active_agent: Any | None) -> str | None:
1296
1298
  """Return a short status line about the active or recent agent."""
@@ -12,18 +12,17 @@ from __future__ import annotations
12
12
  import asyncio
13
13
  import json
14
14
  import logging
15
+ from collections.abc import Callable
15
16
  from dataclasses import dataclass
16
17
  from typing import Any
17
- from collections.abc import Callable
18
18
 
19
19
  from rich.text import Text
20
-
21
20
  from textual.app import App, ComposeResult
22
21
  from textual.binding import Binding
23
22
  from textual.containers import Container, Horizontal
24
23
  from textual.reactive import ReactiveError
25
24
  from textual.screen import ModalScreen
26
- from textual.widgets import DataTable, Footer, Header, LoadingIndicator, Static, RichLog
25
+ from textual.widgets import DataTable, Footer, Header, LoadingIndicator, RichLog, Static
27
26
 
28
27
  logger = logging.getLogger(__name__)
29
28
 
@@ -7,14 +7,13 @@ Authors:
7
7
  from __future__ import annotations
8
8
 
9
9
  import json
10
- import os
11
10
  from dataclasses import dataclass
12
11
  from io import StringIO
13
12
  from typing import Any
14
13
 
15
14
  from rich.console import Console
16
15
 
17
- from glaip_sdk.cli.config import load_config
16
+ from glaip_sdk.cli.auth import resolve_api_url_from_context
18
17
  from glaip_sdk.cli.context import get_ctx_value
19
18
  from glaip_sdk.cli.transcript.cache import (
20
19
  TranscriptPayload,
@@ -24,7 +23,7 @@ from glaip_sdk.cli.transcript.cache import (
24
23
  from glaip_sdk.cli.transcript.cache import (
25
24
  build_payload as build_transcript_payload,
26
25
  )
27
- from glaip_sdk.utils.rendering.renderer.progress import format_tool_title
26
+ from glaip_sdk.utils.rendering.layout.progress import format_tool_title
28
27
 
29
28
 
30
29
  @dataclass(slots=True)
@@ -118,20 +117,12 @@ def register_last_transcript(ctx: Any, payload: TranscriptPayload, store_result:
118
117
 
119
118
 
120
119
  def _resolve_api_url(ctx: Any) -> str | None:
121
- """Resolve API URL from context, environment, or config file."""
122
- api_url = get_ctx_value(ctx, "api_url")
123
- if api_url:
124
- return str(api_url)
125
-
126
- env_url = os.getenv("AIP_API_URL")
127
- if env_url:
128
- return env_url
129
-
130
- try:
131
- config = load_config()
132
- except Exception:
133
- return None
134
- return str(config.get("api_url")) if config.get("api_url") else None
120
+ """Resolve API URL from context or account store (CLI/palette ignores env creds)."""
121
+ return resolve_api_url_from_context(
122
+ ctx,
123
+ get_api_url=lambda c: get_ctx_value(c, "api_url"),
124
+ get_account_name=lambda c: get_ctx_value(c, "account_name"),
125
+ )
135
126
 
136
127
 
137
128
  def _extract_step_summaries(renderer: Any) -> list[dict[str, Any]]:
@@ -300,7 +291,10 @@ def store_transcript_for_session(
300
291
 
301
292
  meta, stream_started_at, finished_at, model_name = _derive_transcript_meta(renderer, model)
302
293
 
303
- api_url = _resolve_api_url(ctx)
294
+ try:
295
+ api_url = _resolve_api_url(ctx)
296
+ except Exception:
297
+ api_url = None
304
298
  if api_url:
305
299
  meta["api_url"] = api_url
306
300