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.
- glaip_sdk/__init__.py +5 -2
- glaip_sdk/_version.py +9 -0
- glaip_sdk/agents/__init__.py +27 -0
- glaip_sdk/agents/base.py +1191 -0
- glaip_sdk/branding.py +13 -0
- glaip_sdk/cli/account_store.py +540 -0
- glaip_sdk/cli/auth.py +254 -15
- glaip_sdk/cli/commands/__init__.py +2 -2
- glaip_sdk/cli/commands/accounts.py +746 -0
- glaip_sdk/cli/commands/agents.py +213 -73
- glaip_sdk/cli/commands/common_config.py +101 -0
- glaip_sdk/cli/commands/configure.py +729 -113
- glaip_sdk/cli/commands/mcps.py +241 -72
- glaip_sdk/cli/commands/models.py +11 -5
- glaip_sdk/cli/commands/tools.py +49 -57
- glaip_sdk/cli/commands/transcripts.py +755 -0
- glaip_sdk/cli/config.py +48 -4
- glaip_sdk/cli/constants.py +38 -0
- glaip_sdk/cli/context.py +8 -0
- glaip_sdk/cli/core/__init__.py +79 -0
- glaip_sdk/cli/core/context.py +124 -0
- glaip_sdk/cli/core/output.py +846 -0
- glaip_sdk/cli/core/prompting.py +649 -0
- glaip_sdk/cli/core/rendering.py +187 -0
- glaip_sdk/cli/display.py +35 -19
- glaip_sdk/cli/hints.py +57 -0
- glaip_sdk/cli/io.py +6 -3
- glaip_sdk/cli/main.py +228 -119
- glaip_sdk/cli/masking.py +21 -33
- glaip_sdk/cli/pager.py +9 -10
- glaip_sdk/cli/parsers/__init__.py +1 -3
- glaip_sdk/cli/slash/__init__.py +0 -9
- glaip_sdk/cli/slash/accounts_controller.py +578 -0
- glaip_sdk/cli/slash/accounts_shared.py +75 -0
- glaip_sdk/cli/slash/agent_session.py +62 -21
- glaip_sdk/cli/slash/prompt.py +21 -0
- glaip_sdk/cli/slash/remote_runs_controller.py +566 -0
- glaip_sdk/cli/slash/session.py +771 -140
- glaip_sdk/cli/slash/tui/__init__.py +9 -0
- glaip_sdk/cli/slash/tui/accounts.tcss +86 -0
- glaip_sdk/cli/slash/tui/accounts_app.py +876 -0
- glaip_sdk/cli/slash/tui/background_tasks.py +72 -0
- glaip_sdk/cli/slash/tui/loading.py +58 -0
- glaip_sdk/cli/slash/tui/remote_runs_app.py +628 -0
- glaip_sdk/cli/transcript/__init__.py +12 -52
- glaip_sdk/cli/transcript/cache.py +255 -44
- glaip_sdk/cli/transcript/capture.py +27 -1
- glaip_sdk/cli/transcript/history.py +815 -0
- glaip_sdk/cli/transcript/viewer.py +72 -499
- glaip_sdk/cli/update_notifier.py +14 -5
- glaip_sdk/cli/utils.py +243 -1252
- glaip_sdk/cli/validators.py +5 -6
- glaip_sdk/client/__init__.py +2 -1
- glaip_sdk/client/_agent_payloads.py +45 -9
- glaip_sdk/client/agent_runs.py +147 -0
- glaip_sdk/client/agents.py +287 -29
- glaip_sdk/client/base.py +1 -0
- glaip_sdk/client/main.py +19 -10
- glaip_sdk/client/mcps.py +122 -12
- glaip_sdk/client/run_rendering.py +133 -88
- glaip_sdk/client/shared.py +21 -0
- glaip_sdk/client/tools.py +155 -10
- glaip_sdk/config/constants.py +11 -0
- glaip_sdk/mcps/__init__.py +21 -0
- glaip_sdk/mcps/base.py +345 -0
- glaip_sdk/models/__init__.py +90 -0
- glaip_sdk/models/agent.py +47 -0
- glaip_sdk/models/agent_runs.py +116 -0
- glaip_sdk/models/common.py +42 -0
- glaip_sdk/models/mcp.py +33 -0
- glaip_sdk/models/tool.py +33 -0
- glaip_sdk/payload_schemas/__init__.py +1 -13
- glaip_sdk/registry/__init__.py +55 -0
- glaip_sdk/registry/agent.py +164 -0
- glaip_sdk/registry/base.py +139 -0
- glaip_sdk/registry/mcp.py +253 -0
- glaip_sdk/registry/tool.py +232 -0
- glaip_sdk/rich_components.py +58 -2
- glaip_sdk/runner/__init__.py +59 -0
- glaip_sdk/runner/base.py +84 -0
- glaip_sdk/runner/deps.py +115 -0
- glaip_sdk/runner/langgraph.py +706 -0
- glaip_sdk/runner/mcp_adapter/__init__.py +13 -0
- glaip_sdk/runner/mcp_adapter/base_mcp_adapter.py +43 -0
- glaip_sdk/runner/mcp_adapter/langchain_mcp_adapter.py +257 -0
- glaip_sdk/runner/mcp_adapter/mcp_config_builder.py +95 -0
- glaip_sdk/runner/tool_adapter/__init__.py +18 -0
- glaip_sdk/runner/tool_adapter/base_tool_adapter.py +44 -0
- glaip_sdk/runner/tool_adapter/langchain_tool_adapter.py +219 -0
- glaip_sdk/tools/__init__.py +22 -0
- glaip_sdk/tools/base.py +435 -0
- glaip_sdk/utils/__init__.py +58 -12
- glaip_sdk/utils/a2a/__init__.py +34 -0
- glaip_sdk/utils/a2a/event_processor.py +188 -0
- glaip_sdk/utils/bundler.py +267 -0
- glaip_sdk/utils/client.py +111 -0
- glaip_sdk/utils/client_utils.py +39 -7
- glaip_sdk/utils/datetime_helpers.py +58 -0
- glaip_sdk/utils/discovery.py +78 -0
- glaip_sdk/utils/display.py +23 -15
- glaip_sdk/utils/export.py +143 -0
- glaip_sdk/utils/general.py +0 -33
- glaip_sdk/utils/import_export.py +12 -7
- glaip_sdk/utils/import_resolver.py +492 -0
- glaip_sdk/utils/instructions.py +101 -0
- glaip_sdk/utils/rendering/__init__.py +115 -1
- glaip_sdk/utils/rendering/formatting.py +5 -30
- glaip_sdk/utils/rendering/layout/__init__.py +64 -0
- glaip_sdk/utils/rendering/{renderer → layout}/panels.py +9 -0
- glaip_sdk/utils/rendering/{renderer → layout}/progress.py +70 -1
- glaip_sdk/utils/rendering/layout/summary.py +74 -0
- glaip_sdk/utils/rendering/layout/transcript.py +606 -0
- glaip_sdk/utils/rendering/models.py +1 -0
- glaip_sdk/utils/rendering/renderer/__init__.py +9 -47
- glaip_sdk/utils/rendering/renderer/base.py +217 -1476
- glaip_sdk/utils/rendering/renderer/debug.py +26 -20
- glaip_sdk/utils/rendering/renderer/factory.py +138 -0
- glaip_sdk/utils/rendering/renderer/stream.py +4 -12
- glaip_sdk/utils/rendering/renderer/thinking.py +273 -0
- glaip_sdk/utils/rendering/renderer/tool_panels.py +442 -0
- glaip_sdk/utils/rendering/renderer/transcript_mode.py +162 -0
- glaip_sdk/utils/rendering/state.py +204 -0
- glaip_sdk/utils/rendering/steps/__init__.py +34 -0
- glaip_sdk/utils/rendering/{steps.py → steps/event_processor.py} +53 -440
- glaip_sdk/utils/rendering/steps/format.py +176 -0
- glaip_sdk/utils/rendering/steps/manager.py +387 -0
- glaip_sdk/utils/rendering/timing.py +36 -0
- glaip_sdk/utils/rendering/viewer/__init__.py +21 -0
- glaip_sdk/utils/rendering/viewer/presenter.py +184 -0
- glaip_sdk/utils/resource_refs.py +25 -13
- glaip_sdk/utils/runtime_config.py +425 -0
- glaip_sdk/utils/serialization.py +18 -0
- glaip_sdk/utils/sync.py +142 -0
- glaip_sdk/utils/tool_detection.py +33 -0
- glaip_sdk/utils/validation.py +16 -24
- {glaip_sdk-0.1.3.dist-info → glaip_sdk-0.6.10.dist-info}/METADATA +42 -4
- glaip_sdk-0.6.10.dist-info/RECORD +159 -0
- {glaip_sdk-0.1.3.dist-info → glaip_sdk-0.6.10.dist-info}/WHEEL +1 -1
- glaip_sdk/models.py +0 -240
- glaip_sdk-0.1.3.dist-info/RECORD +0 -83
- {glaip_sdk-0.1.3.dist-info → glaip_sdk-0.6.10.dist-info}/entry_points.txt +0 -0
|
@@ -14,8 +14,10 @@ import click
|
|
|
14
14
|
from glaip_sdk.branding import ERROR_STYLE, HINT_PREFIX_STYLE
|
|
15
15
|
from glaip_sdk.cli.commands.agents import get as agents_get_command
|
|
16
16
|
from glaip_sdk.cli.commands.agents import run as agents_run_command
|
|
17
|
+
from glaip_sdk.cli.constants import DEFAULT_AGENT_INSTRUCTION_PREVIEW_LIMIT
|
|
18
|
+
from glaip_sdk.cli.hints import format_command_hint
|
|
17
19
|
from glaip_sdk.cli.slash.prompt import _HAS_PROMPT_TOOLKIT, FormattedText
|
|
18
|
-
from glaip_sdk.cli.utils import
|
|
20
|
+
from glaip_sdk.cli.utils import bind_slash_session_context
|
|
19
21
|
|
|
20
22
|
if TYPE_CHECKING: # pragma: no cover - type checking only
|
|
21
23
|
from glaip_sdk.cli.slash.session import SlashSession
|
|
@@ -36,13 +38,18 @@ class AgentRunSession:
|
|
|
36
38
|
self.console = session.console
|
|
37
39
|
self._agent_id = str(getattr(agent, "id", ""))
|
|
38
40
|
self._agent_name = getattr(agent, "name", "") or self._agent_id
|
|
39
|
-
self._prompt_placeholder: str =
|
|
41
|
+
self._prompt_placeholder: str = (
|
|
42
|
+
"Chat with this agent here; use / for shortcuts. "
|
|
43
|
+
"Alt+Enter inserts a newline. Ctrl+T opens the last transcript."
|
|
44
|
+
)
|
|
40
45
|
self._contextual_completion_help: dict[str, str] = {
|
|
41
|
-
"details": "Show this agent's
|
|
46
|
+
"details": "Show this agent's configuration (+ expands prompt).",
|
|
42
47
|
"help": "Display this context-aware menu.",
|
|
48
|
+
"runs": "✨ NEW · Browse remote run history for this agent.",
|
|
43
49
|
"exit": "Return to the command palette.",
|
|
44
50
|
"q": "Return to the command palette.",
|
|
45
51
|
}
|
|
52
|
+
self._instruction_preview_limit = DEFAULT_AGENT_INSTRUCTION_PREVIEW_LIMIT
|
|
46
53
|
|
|
47
54
|
def run(self) -> None:
|
|
48
55
|
"""Run the interactive agent session loop."""
|
|
@@ -86,6 +93,7 @@ class AgentRunSession:
|
|
|
86
93
|
try:
|
|
87
94
|
|
|
88
95
|
def _prompt_message() -> Any:
|
|
96
|
+
"""Get formatted prompt message for agent session."""
|
|
89
97
|
prompt_prefix = f"{self._agent_name} ({self._agent_id}) "
|
|
90
98
|
|
|
91
99
|
# Use FormattedText if prompt_toolkit is available, otherwise use simple string
|
|
@@ -122,7 +130,7 @@ class AgentRunSession:
|
|
|
122
130
|
if raw in {"/exit", "/back", "/q"}:
|
|
123
131
|
return self._handle_exit_command()
|
|
124
132
|
|
|
125
|
-
if raw
|
|
133
|
+
if raw == "/details":
|
|
126
134
|
return self._handle_details_command(agent_id)
|
|
127
135
|
|
|
128
136
|
if raw in {"/help", "/?"}:
|
|
@@ -151,16 +159,59 @@ class AgentRunSession:
|
|
|
151
159
|
self.session.handle_command(raw, invoked_from_agent=True)
|
|
152
160
|
return not self.session._should_exit
|
|
153
161
|
|
|
154
|
-
def _show_details(self, agent_id: str) -> None:
|
|
162
|
+
def _show_details(self, agent_id: str, *, enable_prompt: bool = True) -> None:
|
|
163
|
+
"""Render the agent's configuration export inside the command palette."""
|
|
155
164
|
try:
|
|
156
|
-
self.session.ctx.invoke(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
165
|
+
self.session.ctx.invoke(
|
|
166
|
+
agents_get_command,
|
|
167
|
+
agent_ref=agent_id,
|
|
168
|
+
instruction_preview=self._instruction_preview_limit,
|
|
160
169
|
)
|
|
170
|
+
if enable_prompt:
|
|
171
|
+
self._prompt_instruction_view_toggle(agent_id)
|
|
172
|
+
self.console.print(
|
|
173
|
+
f"[{HINT_PREFIX_STYLE}]Tip:[/] Continue the conversation in this prompt, or use "
|
|
174
|
+
f"{format_command_hint('/help') or '/help'} for shortcuts."
|
|
175
|
+
)
|
|
161
176
|
except click.ClickException as exc:
|
|
162
177
|
self.console.print(f"[{ERROR_STYLE}]{exc}[/]")
|
|
163
178
|
|
|
179
|
+
def _prompt_instruction_view_toggle(self, agent_id: str) -> None:
|
|
180
|
+
"""Offer a prompt to expand or collapse the instruction preview after details."""
|
|
181
|
+
if not getattr(self.console, "is_terminal", False):
|
|
182
|
+
return
|
|
183
|
+
|
|
184
|
+
while True:
|
|
185
|
+
mode = "expanded" if self._instruction_preview_limit == 0 else "trimmed"
|
|
186
|
+
self.console.print(f"[dim]Instruction view is {mode}. Press Ctrl+T to toggle, Enter to continue.[/dim]")
|
|
187
|
+
try:
|
|
188
|
+
ch = click.getchar()
|
|
189
|
+
except (EOFError, KeyboardInterrupt): # pragma: no cover - defensive guard
|
|
190
|
+
return
|
|
191
|
+
|
|
192
|
+
if not self._handle_instruction_toggle_input(agent_id, ch):
|
|
193
|
+
break
|
|
194
|
+
|
|
195
|
+
if self._instruction_preview_limit == 0:
|
|
196
|
+
self._instruction_preview_limit = DEFAULT_AGENT_INSTRUCTION_PREVIEW_LIMIT
|
|
197
|
+
self.console.print("")
|
|
198
|
+
|
|
199
|
+
def _handle_instruction_toggle_input(self, agent_id: str, ch: str) -> bool:
|
|
200
|
+
"""Process a single toggle keypress; return False when the loop should exit."""
|
|
201
|
+
if ch in {"\r", "\n"}:
|
|
202
|
+
return False
|
|
203
|
+
|
|
204
|
+
lowered = ch.lower()
|
|
205
|
+
if lowered == "t" or ch == "\x14": # support literal 't' or Ctrl+T
|
|
206
|
+
self._instruction_preview_limit = (
|
|
207
|
+
DEFAULT_AGENT_INSTRUCTION_PREVIEW_LIMIT if self._instruction_preview_limit == 0 else 0
|
|
208
|
+
)
|
|
209
|
+
self._show_details(agent_id, enable_prompt=False)
|
|
210
|
+
return True
|
|
211
|
+
|
|
212
|
+
# Ignore other keys and continue prompting.
|
|
213
|
+
return True
|
|
214
|
+
|
|
164
215
|
def _after_agent_run(self) -> None:
|
|
165
216
|
"""Handle transcript viewer behaviour after a successful run."""
|
|
166
217
|
payload, manifest = self.session._get_last_transcript()
|
|
@@ -206,21 +257,11 @@ class AgentRunSession:
|
|
|
206
257
|
@contextmanager
|
|
207
258
|
def _bind_session_context(self) -> Any:
|
|
208
259
|
"""Temporarily attach this slash session to the Click context."""
|
|
209
|
-
|
|
210
|
-
has_context = isinstance(ctx_obj, dict)
|
|
211
|
-
previous_session = ctx_obj.get("_slash_session") if has_context else None
|
|
212
|
-
if has_context:
|
|
213
|
-
ctx_obj["_slash_session"] = self.session
|
|
214
|
-
try:
|
|
260
|
+
with bind_slash_session_context(self.session.ctx, self.session):
|
|
215
261
|
yield
|
|
216
|
-
finally:
|
|
217
|
-
if has_context:
|
|
218
|
-
if previous_session is None:
|
|
219
|
-
ctx_obj.pop("_slash_session", None)
|
|
220
|
-
else:
|
|
221
|
-
ctx_obj["_slash_session"] = previous_session
|
|
222
262
|
|
|
223
263
|
def _run_agent(self, agent_id: str, message: str) -> None:
|
|
264
|
+
"""Execute the agents run command for the active agent."""
|
|
224
265
|
if not message:
|
|
225
266
|
return
|
|
226
267
|
|
glaip_sdk/cli/slash/prompt.py
CHANGED
|
@@ -123,6 +123,11 @@ def _create_key_bindings(_session: SlashSession) -> Any:
|
|
|
123
123
|
bindings = KeyBindings()
|
|
124
124
|
|
|
125
125
|
def _refresh_completions(buffer: Any) -> None: # type: ignore[no-any-return]
|
|
126
|
+
"""Refresh completions when slash command is typed.
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
buffer: Prompt buffer instance.
|
|
130
|
+
"""
|
|
126
131
|
text = buffer.document.text_before_cursor or ""
|
|
127
132
|
if text.startswith("/") and " " not in text:
|
|
128
133
|
buffer.start_completion(select_first=False)
|
|
@@ -157,12 +162,24 @@ def _create_key_bindings(_session: SlashSession) -> Any:
|
|
|
157
162
|
if buffer.complete_state is not None:
|
|
158
163
|
buffer.cancel_completion()
|
|
159
164
|
|
|
165
|
+
@bindings.add("c-t") # type: ignore[misc]
|
|
166
|
+
def _handle_ctrl_t_key(event: Any) -> None: # vulture: ignore
|
|
167
|
+
"""Handle Ctrl+T key - open the transcript viewer (when available)."""
|
|
168
|
+
buffer = event.app.current_buffer
|
|
169
|
+
if buffer.complete_state is not None:
|
|
170
|
+
buffer.cancel_completion()
|
|
171
|
+
|
|
172
|
+
open_viewer = getattr(_session, "open_transcript_viewer", None)
|
|
173
|
+
if callable(open_viewer):
|
|
174
|
+
open_viewer(announce=True)
|
|
175
|
+
|
|
160
176
|
return bindings
|
|
161
177
|
|
|
162
178
|
|
|
163
179
|
def _iter_command_completions(
|
|
164
180
|
session: SlashSession, text: str
|
|
165
181
|
) -> Iterable[Completion]: # pragma: no cover - thin wrapper
|
|
182
|
+
"""Yield completions for global slash commands."""
|
|
166
183
|
prefix = text[1:]
|
|
167
184
|
seen: set[str] = set()
|
|
168
185
|
|
|
@@ -171,8 +188,11 @@ def _iter_command_completions(
|
|
|
171
188
|
return []
|
|
172
189
|
|
|
173
190
|
commands = sorted(session._unique_commands.values(), key=lambda c: c.name)
|
|
191
|
+
agent_context = bool(getattr(session, "_current_agent", None))
|
|
174
192
|
|
|
175
193
|
for cmd in commands:
|
|
194
|
+
if getattr(cmd, "agent_only", False) and not agent_context:
|
|
195
|
+
continue
|
|
176
196
|
yield from _generate_command_completions(cmd, prefix, text, seen)
|
|
177
197
|
|
|
178
198
|
|
|
@@ -203,6 +223,7 @@ def _generate_command_completions(cmd: Any, prefix: str, text: str, seen: set[st
|
|
|
203
223
|
def _iter_contextual_completions(
|
|
204
224
|
session: SlashSession, text: str
|
|
205
225
|
) -> Iterable[Completion]: # pragma: no cover - thin wrapper
|
|
226
|
+
"""Yield completions for context-specific slash commands."""
|
|
206
227
|
prefix = text[1:]
|
|
207
228
|
seen: set[str] = set()
|
|
208
229
|
|