glaip-sdk 0.0.18__py3-none-any.whl → 0.0.20__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 (50) hide show
  1. glaip_sdk/_version.py +2 -2
  2. glaip_sdk/branding.py +27 -2
  3. glaip_sdk/cli/auth.py +93 -28
  4. glaip_sdk/cli/commands/__init__.py +2 -2
  5. glaip_sdk/cli/commands/agents.py +108 -21
  6. glaip_sdk/cli/commands/configure.py +141 -90
  7. glaip_sdk/cli/commands/mcps.py +371 -48
  8. glaip_sdk/cli/commands/models.py +4 -3
  9. glaip_sdk/cli/commands/tools.py +27 -14
  10. glaip_sdk/cli/commands/update.py +66 -0
  11. glaip_sdk/cli/config.py +13 -2
  12. glaip_sdk/cli/display.py +35 -26
  13. glaip_sdk/cli/io.py +14 -5
  14. glaip_sdk/cli/main.py +185 -73
  15. glaip_sdk/cli/pager.py +2 -1
  16. glaip_sdk/cli/parsers/json_input.py +62 -14
  17. glaip_sdk/cli/resolution.py +4 -1
  18. glaip_sdk/cli/slash/__init__.py +3 -4
  19. glaip_sdk/cli/slash/agent_session.py +88 -36
  20. glaip_sdk/cli/slash/prompt.py +20 -48
  21. glaip_sdk/cli/slash/session.py +440 -189
  22. glaip_sdk/cli/transcript/__init__.py +71 -0
  23. glaip_sdk/cli/transcript/cache.py +338 -0
  24. glaip_sdk/cli/transcript/capture.py +278 -0
  25. glaip_sdk/cli/transcript/export.py +38 -0
  26. glaip_sdk/cli/transcript/launcher.py +79 -0
  27. glaip_sdk/cli/transcript/viewer.py +624 -0
  28. glaip_sdk/cli/update_notifier.py +29 -5
  29. glaip_sdk/cli/utils.py +256 -74
  30. glaip_sdk/client/agents.py +3 -1
  31. glaip_sdk/client/run_rendering.py +2 -2
  32. glaip_sdk/icons.py +19 -0
  33. glaip_sdk/models.py +6 -0
  34. glaip_sdk/rich_components.py +29 -1
  35. glaip_sdk/utils/__init__.py +1 -1
  36. glaip_sdk/utils/client_utils.py +6 -4
  37. glaip_sdk/utils/display.py +61 -32
  38. glaip_sdk/utils/rendering/formatting.py +6 -5
  39. glaip_sdk/utils/rendering/renderer/base.py +213 -66
  40. glaip_sdk/utils/rendering/renderer/debug.py +73 -16
  41. glaip_sdk/utils/rendering/renderer/panels.py +27 -15
  42. glaip_sdk/utils/rendering/renderer/progress.py +61 -38
  43. glaip_sdk/utils/serialization.py +5 -2
  44. glaip_sdk/utils/validation.py +1 -2
  45. {glaip_sdk-0.0.18.dist-info → glaip_sdk-0.0.20.dist-info}/METADATA +1 -1
  46. glaip_sdk-0.0.20.dist-info/RECORD +80 -0
  47. glaip_sdk/utils/rich_utils.py +0 -29
  48. glaip_sdk-0.0.18.dist-info/RECORD +0 -73
  49. {glaip_sdk-0.0.18.dist-info → glaip_sdk-0.0.20.dist-info}/WHEEL +0 -0
  50. {glaip_sdk-0.0.18.dist-info → glaip_sdk-0.0.20.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,38 @@
1
+ """Shared helpers for transcript export workflows.
2
+
3
+ Authors:
4
+ Raymond Christopher (raymond.christopher@gdplabs.id)
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from pathlib import Path
10
+ from typing import Any
11
+
12
+ from glaip_sdk.cli.transcript.cache import (
13
+ latest_manifest_entry,
14
+ resolve_manifest_entry,
15
+ )
16
+
17
+
18
+ def resolve_manifest_for_export(ctx: Any, run_id: str | None) -> dict[str, Any] | None:
19
+ """Resolve a manifest entry for export based on run id or recent context."""
20
+ if run_id:
21
+ return resolve_manifest_entry(run_id)
22
+
23
+ ctx_obj = ctx if isinstance(ctx, dict) else getattr(ctx, "obj", None)
24
+ if isinstance(ctx_obj, dict):
25
+ candidate = ctx_obj.get("_last_transcript_manifest")
26
+ if isinstance(candidate, dict):
27
+ return candidate
28
+
29
+ return latest_manifest_entry()
30
+
31
+
32
+ def normalise_export_destination(path: Path) -> Path:
33
+ """Return an absolute path for the export destination."""
34
+ expanded = path.expanduser()
35
+ return expanded if expanded.is_absolute() else Path.cwd() / expanded
36
+
37
+
38
+ __all__ = ["resolve_manifest_for_export", "normalise_export_destination"]
@@ -0,0 +1,79 @@
1
+ """Utilities for launching the post-run transcript viewer.
2
+
3
+ Authors:
4
+ Raymond Christopher (raymond.christopher@gdplabs.id)
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import sys
10
+ from pathlib import Path
11
+ from typing import Any
12
+
13
+ from rich.console import Console
14
+
15
+ from glaip_sdk.cli.context import get_ctx_value
16
+ from glaip_sdk.cli.transcript.cache import (
17
+ export_transcript as export_cached_transcript,
18
+ )
19
+ from glaip_sdk.cli.transcript.capture import StoredTranscriptContext
20
+ from glaip_sdk.cli.transcript.viewer import ViewerContext, run_viewer_session
21
+
22
+
23
+ def should_launch_post_run_viewer(
24
+ ctx: Any, console: Console, *, slash_mode: bool
25
+ ) -> bool:
26
+ """Return True if the viewer should open automatically."""
27
+ if slash_mode:
28
+ return False
29
+ ctx_obj = getattr(ctx, "obj", None)
30
+ if isinstance(ctx_obj, dict) and ctx_obj.get("_slash_session"):
31
+ return False
32
+ if get_ctx_value(ctx, "view", "rich") != "rich":
33
+ return False
34
+ if not bool(get_ctx_value(ctx, "tty", True)):
35
+ return False
36
+ if not console.is_terminal:
37
+ return False
38
+ try:
39
+ if not sys.stdin.isatty():
40
+ return False
41
+ except Exception:
42
+ return False
43
+ return True
44
+
45
+
46
+ def maybe_launch_post_run_viewer(
47
+ ctx: Any,
48
+ transcript_context: StoredTranscriptContext | None,
49
+ *,
50
+ console: Console,
51
+ slash_mode: bool,
52
+ ) -> None:
53
+ """Launch the post-run viewer when context and settings allow it."""
54
+ if transcript_context is None:
55
+ return
56
+ if not should_launch_post_run_viewer(ctx, console, slash_mode=slash_mode):
57
+ return
58
+
59
+ manifest_entry = transcript_context.store_result.manifest_entry
60
+ run_id = manifest_entry.get("run_id")
61
+ if not run_id:
62
+ return
63
+
64
+ viewer_ctx = ViewerContext(
65
+ manifest_entry=manifest_entry,
66
+ events=transcript_context.payload.events,
67
+ default_output=transcript_context.payload.default_output,
68
+ final_output=transcript_context.payload.final_output,
69
+ stream_started_at=None,
70
+ meta=transcript_context.payload.meta,
71
+ )
72
+
73
+ def _export(destination: Path) -> Path:
74
+ return export_cached_transcript(destination=destination, run_id=run_id)
75
+
76
+ run_viewer_session(console, viewer_ctx, _export)
77
+
78
+
79
+ __all__ = ["should_launch_post_run_viewer", "maybe_launch_post_run_viewer"]