langstage-cli 0.6.50__tar.gz → 0.6.52__tar.gz
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.
- {langstage_cli-0.6.50/langstage_cli.egg-info → langstage_cli-0.6.52}/PKG-INFO +5 -5
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/README.md +2 -2
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/langstage_cli/cli.py +66 -54
- {langstage_cli-0.6.50 → langstage_cli-0.6.52/langstage_cli.egg-info}/PKG-INFO +5 -5
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/langstage_cli.egg-info/requires.txt +2 -2
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/pyproject.toml +3 -3
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_advertised_wave4.py +29 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_custom_decision_195.py +30 -16
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/LICENSE +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/deepagent_code/__init__.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/langstage_cli/__init__.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/langstage_cli/agui_stream.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/langstage_cli/config.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/langstage_cli/exit_codes.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/langstage_cli/sessions.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/langstage_cli.egg-info/SOURCES.txt +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/langstage_cli.egg-info/dependency_links.txt +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/langstage_cli.egg-info/entry_points.txt +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/langstage_cli.egg-info/top_level.txt +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/setup.cfg +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_agui_stream.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_approval_menu_abort.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_async_mode.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_checkpointer.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_cli.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_cli_help.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_codeconfig.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_config.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_config_command.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_configurable.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_ctrl_c_sync_tool.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_deferred_pass.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_dumb_term.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_exit_codes.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_generic_interrupt.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_help_render.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_hidden_option_suggestions.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_history_persist.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_hitl_approval_preview.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_hitl_resume_warning.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_init.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_interrupt_non_tty.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_legacy_config_home.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_load_error.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_menu_allowed_197.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_message_boundaries.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_no_color.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_no_interactive_approve.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_no_persist_resume.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_paused_session_message.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_persist_env.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_quiet_output.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_reasoning_render.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_rename_shim.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_render_markdown.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_routine_1024.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_session_lifecycle.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_sessions.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_show_config.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_show_config_malformed.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_spec_loading_core.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_spec_resolution.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_spinner_reply_survives.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_stdin_interactive.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_stdin_single_shot.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_stream_mode.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_streaming_marker.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_terminal_width.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_toml_relative_paths.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_tool_card_args.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_tool_output_escape.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_turn_error_verbose.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_turn_exit_and_render.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_unicode_console.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_usage_hint_186.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_verbose_command.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_verify_flag.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_workspace.py +0 -0
- {langstage_cli-0.6.50 → langstage_cli-0.6.52}/tests/test_wrong_type_graph.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: langstage-cli
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.52
|
|
4
4
|
Summary: The terminal stage for your LangGraph agent — Claude Code-style CLI for any CompiledGraph
|
|
5
5
|
Author-email: Kedar Dabhadkar <kdabhadk@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -19,7 +19,7 @@ Requires-Python: >=3.11
|
|
|
19
19
|
Description-Content-Type: text/markdown
|
|
20
20
|
License-File: LICENSE
|
|
21
21
|
Requires-Dist: langgraph>=0.2.0
|
|
22
|
-
Requires-Dist: langstage-core[agui]>=1.0.
|
|
22
|
+
Requires-Dist: langstage-core[agui]>=1.0.58
|
|
23
23
|
Requires-Dist: click>=8.0.0
|
|
24
24
|
Requires-Dist: python-dotenv
|
|
25
25
|
Requires-Dist: langgraph-checkpoint-sqlite>=2.0.0
|
|
@@ -33,7 +33,7 @@ Requires-Dist: deepagents>=0.3; extra == "dev"
|
|
|
33
33
|
Requires-Dist: ag-ui-langgraph>=0.0.41; extra == "dev"
|
|
34
34
|
Requires-Dist: fastapi; extra == "dev"
|
|
35
35
|
Provides-Extra: agui
|
|
36
|
-
Requires-Dist: langstage-core[agui]>=1.0.
|
|
36
|
+
Requires-Dist: langstage-core[agui]>=1.0.58; extra == "agui"
|
|
37
37
|
Dynamic: license-file
|
|
38
38
|
|
|
39
39
|
# langstage-cli
|
|
@@ -354,8 +354,8 @@ the reply it renders is the graph's `messages` channel. A graph whose state has
|
|
|
354
354
|
`state["query"]` fails with `KeyError`, and one that tolerates the missing key runs and
|
|
355
355
|
the CLI prints its final state as JSON, with a note on stderr. To drive such a graph from
|
|
356
356
|
the CLI, give it a `messages` channel, or a first node that copies the last message into
|
|
357
|
-
`query`.
|
|
358
|
-
|
|
357
|
+
`query`. `--verify` gives the same verdict as a run: it passes a turn that ends with
|
|
358
|
+
final state to show, and fails a turn with no message and no state (exit 1).
|
|
359
359
|
|
|
360
360
|
A spec's inline `:name` (`app.py:prod`) wins over `-g` / `[agent] graph_name`;
|
|
361
361
|
`--show-config` reports the graph that runs, and a run notes the ignored name.
|
|
@@ -316,8 +316,8 @@ the reply it renders is the graph's `messages` channel. A graph whose state has
|
|
|
316
316
|
`state["query"]` fails with `KeyError`, and one that tolerates the missing key runs and
|
|
317
317
|
the CLI prints its final state as JSON, with a note on stderr. To drive such a graph from
|
|
318
318
|
the CLI, give it a `messages` channel, or a first node that copies the last message into
|
|
319
|
-
`query`.
|
|
320
|
-
|
|
319
|
+
`query`. `--verify` gives the same verdict as a run: it passes a turn that ends with
|
|
320
|
+
final state to show, and fails a turn with no message and no state (exit 1).
|
|
321
321
|
|
|
322
322
|
A spec's inline `:name` (`app.py:prod`) wins over `-g` / `[agent] graph_name`;
|
|
323
323
|
`--show-config` reports the graph that runs, and a run notes the ignored name.
|
|
@@ -1997,36 +1997,30 @@ def _check_custom_decision(
|
|
|
1997
1997
|
else:
|
|
1998
1998
|
items = [value] * num_actions
|
|
1999
1999
|
|
|
2000
|
-
# The edited_action / message fields are LangChain HumanInTheLoopMiddleware's
|
|
2001
|
-
# shape (its interrupts carry review_configs); other interrupts read their own.
|
|
2002
|
-
middleware = _is_middleware_interrupt(interrupt)
|
|
2003
2000
|
for i, decision in enumerate(items):
|
|
2004
|
-
allowed = _allowed_verbs(interrupt, i)
|
|
2005
2001
|
if not isinstance(decision, dict) or not isinstance(decision.get("type"), str):
|
|
2006
2002
|
return [], (
|
|
2007
2003
|
'A decision is a JSON object with a "type", e.g. {"type": "approve"}; '
|
|
2008
|
-
f"allowed: {', '.join(
|
|
2004
|
+
f"allowed: {', '.join(_allowed_verbs(interrupt, i))}."
|
|
2009
2005
|
)
|
|
2010
|
-
|
|
2011
|
-
|
|
2006
|
+
|
|
2007
|
+
# LangChain HumanInTheLoopMiddleware interrupts (they carry review_configs) are
|
|
2008
|
+
# checked by core, with the same rules its resume path enforces (core gh #227).
|
|
2009
|
+
# Other interrupts read their own payload, so only the verb is checked here.
|
|
2010
|
+
if _is_middleware_interrupt(interrupt):
|
|
2011
|
+
from langstage_core import decision_problems
|
|
2012
|
+
|
|
2013
|
+
problems = decision_problems({"decisions": list(items)}, interrupt)
|
|
2014
|
+
if problems:
|
|
2015
|
+
return [], "; ".join(problems) + "."
|
|
2016
|
+
return list(items), None
|
|
2017
|
+
for i, decision in enumerate(items):
|
|
2018
|
+
allowed = _allowed_verbs(interrupt, i)
|
|
2019
|
+
if normalize_decision(decision["type"], allowed) is None:
|
|
2012
2020
|
return [], (
|
|
2013
2021
|
f"Decision type '{decision['type']}' is not allowed here; "
|
|
2014
2022
|
f"allowed: {', '.join(allowed)}."
|
|
2015
2023
|
)
|
|
2016
|
-
if not middleware:
|
|
2017
|
-
continue
|
|
2018
|
-
if verb == "edit":
|
|
2019
|
-
edited = decision.get("edited_action")
|
|
2020
|
-
if not (
|
|
2021
|
-
isinstance(edited, dict)
|
|
2022
|
-
and isinstance(edited.get("name"), str)
|
|
2023
|
-
and isinstance(edited.get("args"), dict)
|
|
2024
|
-
):
|
|
2025
|
-
return [], 'An edit needs "edited_action": {"name": "<tool>", "args": {...}}.'
|
|
2026
|
-
elif verb == "respond" and not isinstance(decision.get("message"), str):
|
|
2027
|
-
return [], 'A respond decision needs a "message" string.'
|
|
2028
|
-
elif verb == "reject" and not isinstance(decision.get("message", ""), str):
|
|
2029
|
-
return [], 'The "message" of a reject decision must be a string.'
|
|
2030
2024
|
return list(items), None
|
|
2031
2025
|
|
|
2032
2026
|
|
|
@@ -2569,36 +2563,6 @@ async def _pending_interrupt(agent: Any, thread_id: str) -> bool:
|
|
|
2569
2563
|
return any(getattr(task, "interrupts", None) for task in getattr(state, "tasks", ()) or ())
|
|
2570
2564
|
|
|
2571
2565
|
|
|
2572
|
-
async def _discard_failed_resume(agent: Any, thread_id: str) -> None:
|
|
2573
|
-
"""Drop the answer a failed resume left on the thread, so the next one is used.
|
|
2574
|
-
|
|
2575
|
-
When resuming an interrupt raises (a decision the agent refused), LangGraph keeps
|
|
2576
|
-
that resume value on the checkpoint and replays it on every later resume, so the
|
|
2577
|
-
approval could never be answered again, even with ``-c`` (gh #195). The failed
|
|
2578
|
-
task still shows its interrupt and carries the error. A checkpoint with no new
|
|
2579
|
-
values drops the stale answer: the interrupted step runs again and takes the new
|
|
2580
|
-
one. If that isn't possible the stale answer stays, and the error says so again.
|
|
2581
|
-
"""
|
|
2582
|
-
graph = getattr(agent, "graph", None)
|
|
2583
|
-
if not thread_id or graph is None or not hasattr(graph, "aupdate_state"):
|
|
2584
|
-
return
|
|
2585
|
-
config = {"configurable": {"thread_id": thread_id}}
|
|
2586
|
-
try:
|
|
2587
|
-
state = await graph.aget_state(config)
|
|
2588
|
-
except Exception: # noqa: BLE001 - no checkpointer / no state: nothing to clear
|
|
2589
|
-
return
|
|
2590
|
-
tasks = getattr(state, "tasks", ()) or ()
|
|
2591
|
-
if not any(getattr(t, "interrupts", None) and getattr(t, "error", None) for t in tasks):
|
|
2592
|
-
return
|
|
2593
|
-
try:
|
|
2594
|
-
await graph.aupdate_state(config, None)
|
|
2595
|
-
except Exception as e: # noqa: BLE001 - leave the thread as it is
|
|
2596
|
-
_status(
|
|
2597
|
-
f"{YELLOW}⏺ Couldn't clear the refused answer on this session ({e}); "
|
|
2598
|
-
f"start a new session if the approval keeps failing.{RESET}"
|
|
2599
|
-
)
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
2566
|
async def _stream_turn(
|
|
2603
2567
|
agent: Any, message: str, thread_id: str, interactive: bool, verbose: bool
|
|
2604
2568
|
) -> tuple[bool, bool, bool]:
|
|
@@ -2626,8 +2590,6 @@ async def _stream_turn(
|
|
|
2626
2590
|
spinner = None if _QUIET else Spinner("Thinking")
|
|
2627
2591
|
if spinner:
|
|
2628
2592
|
spinner.start()
|
|
2629
|
-
if resume is not None:
|
|
2630
|
-
await _discard_failed_resume(agent, thread_id)
|
|
2631
2593
|
try:
|
|
2632
2594
|
with _debug_tracebacks(verbose):
|
|
2633
2595
|
async for chunk in agui_stream_updates(agent, message, thread_id, resume=resume):
|
|
@@ -2739,6 +2701,28 @@ async def _render_empty_turn(agent: Any, thread_id: str) -> bool:
|
|
|
2739
2701
|
return False
|
|
2740
2702
|
|
|
2741
2703
|
|
|
2704
|
+
def _empty_turn_state_keys(graph: Any, thread_id: str, result: Any) -> List[str]:
|
|
2705
|
+
"""The non-``messages`` state keys behind a ``--verify`` "no content" failure.
|
|
2706
|
+
|
|
2707
|
+
Core's verdict fails a turn that completed cleanly with no content, which is right
|
|
2708
|
+
for surfaces that only show messages. The CLI also shows a graph's final state
|
|
2709
|
+
when there's no message (``_render_empty_turn``, gh #120), so a single-shot run
|
|
2710
|
+
passed a ``{"query", "answer"}`` graph that ``--verify`` failed (gh #200). Return
|
|
2711
|
+
the keys that run would show, or ``[]`` when the failure is anything else (an
|
|
2712
|
+
error, no completion) or there is no state, so both paths give one verdict.
|
|
2713
|
+
"""
|
|
2714
|
+
if result.saw_error or not result.saw_complete or result.content_chars:
|
|
2715
|
+
return []
|
|
2716
|
+
try:
|
|
2717
|
+
state = graph.get_state({"configurable": {"thread_id": thread_id}})
|
|
2718
|
+
except Exception: # noqa: BLE001 - no readable state: keep core's verdict
|
|
2719
|
+
return []
|
|
2720
|
+
raw = getattr(state, "values", None)
|
|
2721
|
+
if not isinstance(raw, dict):
|
|
2722
|
+
return []
|
|
2723
|
+
return [k for k in raw if k != "messages"]
|
|
2724
|
+
|
|
2725
|
+
|
|
2742
2726
|
class _DaemonThreadPool(concurrent.futures.ThreadPoolExecutor):
|
|
2743
2727
|
"""The turn loop's default executor: daemon worker threads nothing waits for (gh #192).
|
|
2744
2728
|
|
|
@@ -3889,10 +3873,38 @@ def main(
|
|
|
3889
3873
|
if verify_agent:
|
|
3890
3874
|
from langstage_core.agui import verify as _core_verify
|
|
3891
3875
|
|
|
3892
|
-
|
|
3876
|
+
# A checkpointer and a known thread let us read the graph's final state
|
|
3877
|
+
# when core reports an empty turn (gh #200, below). The in-memory one is
|
|
3878
|
+
# only for this probe: restore the graph after, since the module (and so
|
|
3879
|
+
# the graph object) stays cached in this process.
|
|
3880
|
+
own_checkpointer = getattr(graph, "checkpointer", None)
|
|
3881
|
+
_ensure_checkpointer(graph)
|
|
3882
|
+
verify_thread = f"verify-{uuid.uuid4().hex}"
|
|
3883
|
+
try:
|
|
3884
|
+
result = _core_verify(graph, thread_id=verify_thread)
|
|
3885
|
+
state_keys = (
|
|
3886
|
+
[] if result.ok else _empty_turn_state_keys(graph, verify_thread, result)
|
|
3887
|
+
)
|
|
3888
|
+
finally:
|
|
3889
|
+
if own_checkpointer is None:
|
|
3890
|
+
try:
|
|
3891
|
+
graph.checkpointer = None
|
|
3892
|
+
except Exception: # noqa: BLE001 - best effort
|
|
3893
|
+
pass
|
|
3893
3894
|
if result.ok:
|
|
3894
3895
|
print(f"{GREEN}✓{RESET} agent verified: {result.reason}")
|
|
3895
3896
|
sys.exit(0)
|
|
3897
|
+
if state_keys:
|
|
3898
|
+
print(
|
|
3899
|
+
'note: the agent produced no message (langstage-cli renders the "messages" '
|
|
3900
|
+
"channel); its final state is what a run shows instead.",
|
|
3901
|
+
file=sys.stderr,
|
|
3902
|
+
)
|
|
3903
|
+
print(
|
|
3904
|
+
f"{GREEN}✓{RESET} agent verified: turn completed with final state "
|
|
3905
|
+
f"({', '.join(state_keys)})"
|
|
3906
|
+
)
|
|
3907
|
+
sys.exit(0)
|
|
3896
3908
|
_status(f"{RED}✗ agent verification failed: {result.reason}{RESET}")
|
|
3897
3909
|
sys.exit(1)
|
|
3898
3910
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: langstage-cli
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.52
|
|
4
4
|
Summary: The terminal stage for your LangGraph agent — Claude Code-style CLI for any CompiledGraph
|
|
5
5
|
Author-email: Kedar Dabhadkar <kdabhadk@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -19,7 +19,7 @@ Requires-Python: >=3.11
|
|
|
19
19
|
Description-Content-Type: text/markdown
|
|
20
20
|
License-File: LICENSE
|
|
21
21
|
Requires-Dist: langgraph>=0.2.0
|
|
22
|
-
Requires-Dist: langstage-core[agui]>=1.0.
|
|
22
|
+
Requires-Dist: langstage-core[agui]>=1.0.58
|
|
23
23
|
Requires-Dist: click>=8.0.0
|
|
24
24
|
Requires-Dist: python-dotenv
|
|
25
25
|
Requires-Dist: langgraph-checkpoint-sqlite>=2.0.0
|
|
@@ -33,7 +33,7 @@ Requires-Dist: deepagents>=0.3; extra == "dev"
|
|
|
33
33
|
Requires-Dist: ag-ui-langgraph>=0.0.41; extra == "dev"
|
|
34
34
|
Requires-Dist: fastapi; extra == "dev"
|
|
35
35
|
Provides-Extra: agui
|
|
36
|
-
Requires-Dist: langstage-core[agui]>=1.0.
|
|
36
|
+
Requires-Dist: langstage-core[agui]>=1.0.58; extra == "agui"
|
|
37
37
|
Dynamic: license-file
|
|
38
38
|
|
|
39
39
|
# langstage-cli
|
|
@@ -354,8 +354,8 @@ the reply it renders is the graph's `messages` channel. A graph whose state has
|
|
|
354
354
|
`state["query"]` fails with `KeyError`, and one that tolerates the missing key runs and
|
|
355
355
|
the CLI prints its final state as JSON, with a note on stderr. To drive such a graph from
|
|
356
356
|
the CLI, give it a `messages` channel, or a first node that copies the last message into
|
|
357
|
-
`query`.
|
|
358
|
-
|
|
357
|
+
`query`. `--verify` gives the same verdict as a run: it passes a turn that ends with
|
|
358
|
+
final state to show, and fails a turn with no message and no state (exit 1).
|
|
359
359
|
|
|
360
360
|
A spec's inline `:name` (`app.py:prod`) wins over `-g` / `[agent] graph_name`;
|
|
361
361
|
`--show-config` reports the graph that runs, and a run notes the ignored name.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "langstage-cli"
|
|
7
|
-
version = "0.6.
|
|
7
|
+
version = "0.6.52"
|
|
8
8
|
description = "The terminal stage for your LangGraph agent — Claude Code-style CLI for any CompiledGraph"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -36,7 +36,7 @@ dependencies = [
|
|
|
36
36
|
# reporting, the non-deprecated HITL resume wire, message_id frames, and
|
|
37
37
|
# langstage_core.console (gh #154, #153, #149, #145, #141, #140, #137, #136, #132,
|
|
38
38
|
# #126, #119).
|
|
39
|
-
"langstage-core[agui]>=1.0.
|
|
39
|
+
"langstage-core[agui]>=1.0.58",
|
|
40
40
|
"click>=8.0.0",
|
|
41
41
|
"python-dotenv",
|
|
42
42
|
# Durable, cross-invocation session persistence (--continue / --resume, gh #102).
|
|
@@ -65,7 +65,7 @@ dev = [
|
|
|
65
65
|
]
|
|
66
66
|
# Redundant since AG-UI moved into base deps (core 1.0); kept as a no-op alias so
|
|
67
67
|
# existing `pip install langstage-cli[agui]` scripts/READMEs still resolve.
|
|
68
|
-
agui = ["langstage-core[agui]>=1.0.
|
|
68
|
+
agui = ["langstage-core[agui]>=1.0.58"]
|
|
69
69
|
|
|
70
70
|
[project.scripts]
|
|
71
71
|
langstage-cli = "langstage_cli.cli:main"
|
|
@@ -278,3 +278,32 @@ def test_no_agent_error_without_toml_is_unchanged(tmp_path, monkeypatch):
|
|
|
278
278
|
assert r.exit_code == 1, r.output
|
|
279
279
|
assert "No agent specified" in r.output
|
|
280
280
|
assert "unknown" not in r.output
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
# --- gh #200: --verify agrees with a single-shot run on a no-`messages` graph ---
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def test_verify_passes_a_graph_whose_run_shows_final_state(tmp_path, monkeypatch):
|
|
287
|
+
_ws(tmp_path, monkeypatch, {"custom_state_200.py": _CUSTOM_STATE})
|
|
288
|
+
run = CliRunner().invoke(main, ["-a", "custom_state_200.py:graph", "hello"])
|
|
289
|
+
ver = CliRunner().invoke(main, ["--verify", "-a", "custom_state_200.py:graph"])
|
|
290
|
+
assert run.exit_code == 0, run.output
|
|
291
|
+
assert ver.exit_code == 0, ver.output # one verdict for the run and the CI gate
|
|
292
|
+
assert "verified" in ver.stdout and "answer" in ver.stdout, ver.stdout
|
|
293
|
+
assert "no message" in ver.stderr, ver.stderr
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def test_verify_still_fails_a_turn_with_no_message_and_no_state(tmp_path, monkeypatch):
|
|
297
|
+
_ws(tmp_path, monkeypatch, {"silent_200.py": _SILENT})
|
|
298
|
+
run = CliRunner().invoke(main, ["-a", "silent_200.py:graph", "hello"])
|
|
299
|
+
ver = CliRunner().invoke(main, ["--verify", "-a", "silent_200.py:graph"])
|
|
300
|
+
assert run.exit_code == 1, run.output
|
|
301
|
+
assert ver.exit_code == 1, ver.output
|
|
302
|
+
assert "no content" in ver.stderr, ver.stderr
|
|
303
|
+
assert ver.stdout.strip() == "", ver.stdout
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
def test_verify_passes_a_final_state_graph_with_no_persist(tmp_path, monkeypatch):
|
|
307
|
+
_ws(tmp_path, monkeypatch, {"custom_state_200b.py": _CUSTOM_STATE})
|
|
308
|
+
ver = CliRunner().invoke(main, ["--no-persist", "--verify", "-a", "custom_state_200b.py:graph"])
|
|
309
|
+
assert ver.exit_code == 0, ver.output
|
|
@@ -13,6 +13,7 @@ and a thread already holding a refused answer drops it before the next resume.
|
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
15
|
import io
|
|
16
|
+
import logging
|
|
16
17
|
import textwrap
|
|
17
18
|
from contextlib import redirect_stdout
|
|
18
19
|
|
|
@@ -101,7 +102,7 @@ def tty(monkeypatch):
|
|
|
101
102
|
[
|
|
102
103
|
(
|
|
103
104
|
{"type": "aprove"},
|
|
104
|
-
"
|
|
105
|
+
"decision 1 (send_email): type 'aprove' is not allowed; allowed: approve, reject",
|
|
105
106
|
),
|
|
106
107
|
(
|
|
107
108
|
{"type": "edit", "edited_action": {"name": "send_email", "args": {}}},
|
|
@@ -110,7 +111,7 @@ def tty(monkeypatch):
|
|
|
110
111
|
(None, 'A decision is a JSON object with a "type"'),
|
|
111
112
|
({"decisions": [{"kind": "approve"}]}, 'A decision is a JSON object with a "type"'),
|
|
112
113
|
([{"type": "approve"}] * 3, "Got 3 decisions for 2 pending action(s)"),
|
|
113
|
-
({"type": "reject", "message": 5}, "must be
|
|
114
|
+
({"type": "reject", "message": 5}, 'a reject "message" must be text'),
|
|
114
115
|
],
|
|
115
116
|
)
|
|
116
117
|
def test_bad_decisions_are_refused(value, problem):
|
|
@@ -120,17 +121,20 @@ def test_bad_decisions_are_refused(value, problem):
|
|
|
120
121
|
assert problem in got
|
|
121
122
|
|
|
122
123
|
|
|
124
|
+
_FRAME2 = {**_FRAME, "action_requests": _FRAME["action_requests"] * 2}
|
|
125
|
+
|
|
126
|
+
|
|
123
127
|
def test_one_decision_applies_to_every_action():
|
|
124
|
-
decisions, problem = cli._check_custom_decision({"type": "reject", "message": "no"}, 2,
|
|
128
|
+
decisions, problem = cli._check_custom_decision({"type": "reject", "message": "no"}, 2, _FRAME2)
|
|
125
129
|
assert problem is None
|
|
126
130
|
assert decisions == [{"type": "reject", "message": "no"}] * 2
|
|
127
131
|
|
|
128
132
|
|
|
129
133
|
def test_a_pasted_envelope_is_unwrapped():
|
|
130
134
|
one = {"decisions": [{"type": "approve"}]}
|
|
131
|
-
assert cli._check_custom_decision(one, 2,
|
|
135
|
+
assert cli._check_custom_decision(one, 2, _FRAME2) == ([{"type": "approve"}] * 2, None)
|
|
132
136
|
each = {"decisions": [{"type": "approve"}, {"type": "reject"}]}
|
|
133
|
-
assert cli._check_custom_decision(each, 2,
|
|
137
|
+
assert cli._check_custom_decision(each, 2, _FRAME2) == (each["decisions"], None)
|
|
134
138
|
|
|
135
139
|
|
|
136
140
|
def test_legacy_alias_verbs_pass():
|
|
@@ -144,7 +148,10 @@ def test_langchain_shapes_are_checked_only_for_its_interrupts():
|
|
|
144
148
|
"review_configs": [{"action_name": "send_email", "allowed_decisions": ["edit", "respond"]}],
|
|
145
149
|
}
|
|
146
150
|
assert "edited_action" in cli._check_custom_decision({"type": "edit"}, 1, frame)[1]
|
|
147
|
-
assert
|
|
151
|
+
assert (
|
|
152
|
+
'respond needs a text "message"'
|
|
153
|
+
in cli._check_custom_decision({"type": "respond"}, 1, frame)[1]
|
|
154
|
+
)
|
|
148
155
|
edit = {"type": "edit", "edited_action": {"name": "send_email", "args": {"to": "b"}}}
|
|
149
156
|
assert cli._check_custom_decision(edit, 1, frame) == ([edit], None)
|
|
150
157
|
# A plain interrupt() payload (no review_configs) reads its own edit shape.
|
|
@@ -178,7 +185,7 @@ def test_menu_reprompts_on_a_refused_decision_and_shows_the_shapes(tty, monkeypa
|
|
|
178
185
|
resume = cli.handle_interrupt_input(1, interrupt=_FRAME)
|
|
179
186
|
out = buf.getvalue()
|
|
180
187
|
assert resume == {"decisions": [{"type": "approve"}]}
|
|
181
|
-
assert "'aprove' is not allowed
|
|
188
|
+
assert "type 'aprove' is not allowed" in out and "Nothing was sent" in out
|
|
182
189
|
assert '{"type": "approve"} | {"type": "reject", "message": "why"}' in out
|
|
183
190
|
assert '"edit"' not in out # not offered for this tool
|
|
184
191
|
assert len(shown) == 1 # re-prompted in place
|
|
@@ -206,7 +213,7 @@ async def test_a_typo_is_refused_then_the_corrected_decision_runs_the_tool(tty,
|
|
|
206
213
|
assert "done: sent to a@example.org" in out, out
|
|
207
214
|
|
|
208
215
|
|
|
209
|
-
async def test_a_thread_holding_a_refused_answer_takes_the_next_one(monkeypatch):
|
|
216
|
+
async def test_a_thread_holding_a_refused_answer_takes_the_next_one(monkeypatch, caplog, capsys):
|
|
210
217
|
# A thread wedged by an older CLI: the refused answer is already on the checkpoint.
|
|
211
218
|
pytest.importorskip("ag_ui_langgraph")
|
|
212
219
|
from langgraph.checkpoint.memory import MemorySaver
|
|
@@ -226,7 +233,7 @@ async def test_a_thread_holding_a_refused_answer_takes_the_next_one(monkeypatch)
|
|
|
226
233
|
|
|
227
234
|
agent = build_session_agent(graph)
|
|
228
235
|
buf = io.StringIO()
|
|
229
|
-
with redirect_stdout(buf):
|
|
236
|
+
with caplog.at_level(logging.WARNING), redirect_stdout(buf):
|
|
230
237
|
_elapsed, had_error = await cli.run_single_turn_agui(
|
|
231
238
|
agent, "and now?", "t-wedged", interactive=False
|
|
232
239
|
)
|
|
@@ -234,9 +241,14 @@ async def test_a_thread_holding_a_refused_answer_takes_the_next_one(monkeypatch)
|
|
|
234
241
|
assert had_error is False, out
|
|
235
242
|
assert "aprove" not in out, out
|
|
236
243
|
assert "done: sent to a@example.org" in out, out
|
|
244
|
+
# Recovered by core (gh #227), so ag-ui never falls back to the deprecated wire.
|
|
245
|
+
logs = caplog.text + capsys.readouterr().err
|
|
246
|
+
assert "forwardedProps.command.resume is deprecated" not in out + logs, out + logs
|
|
237
247
|
|
|
238
248
|
|
|
239
|
-
def test_continue_recovers_a_persisted_session_wedged_by_a_refused_answer(
|
|
249
|
+
def test_continue_recovers_a_persisted_session_wedged_by_a_refused_answer(
|
|
250
|
+
tmp_path, monkeypatch, caplog
|
|
251
|
+
):
|
|
240
252
|
pytest.importorskip("ag_ui_langgraph")
|
|
241
253
|
pytest.importorskip("langgraph.checkpoint.sqlite.aio")
|
|
242
254
|
ws = tmp_path / "ws"
|
|
@@ -258,18 +270,20 @@ def test_continue_recovers_a_persisted_session_wedged_by_a_refused_answer(tmp_pa
|
|
|
258
270
|
|
|
259
271
|
monkeypatch.setattr(cli, "_is_a_tty", lambda *a, **k: True)
|
|
260
272
|
monkeypatch.setattr(cli, "handle_interrupt_input", old_menu)
|
|
261
|
-
|
|
273
|
+
# ...and with a core older than 1.0.58, which didn't check it either.
|
|
274
|
+
monkeypatch.setattr("langstage_core.resume.decision_problems", lambda *_a, **_k: [])
|
|
262
275
|
r = runner.invoke(main, ["email them"])
|
|
263
276
|
assert "aprove" in r.output, r.output
|
|
264
277
|
monkeypatch.undo()
|
|
265
278
|
monkeypatch.setenv("LANGSTAGE_CONFIG_HOME", str(tmp_path / "empty_home"))
|
|
266
279
|
monkeypatch.chdir(ws)
|
|
267
280
|
|
|
268
|
-
|
|
281
|
+
# Core 1.0.58's resume path drops the stale answer (core gh #227), without the
|
|
282
|
+
# ag-ui "forwardedProps.command.resume is deprecated" log the cli's own recovery
|
|
283
|
+
# caused by clearing the interrupt before core read it.
|
|
284
|
+
with caplog.at_level(logging.WARNING):
|
|
285
|
+
r = runner.invoke(main, ["-c", "--no-interactive", "x"])
|
|
269
286
|
assert r.exit_code == 0, r.output
|
|
270
287
|
assert "aprove" not in r.output, r.output
|
|
271
288
|
assert "done: sent to a@example.org" in r.output, r.output
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
async def _no_discard(*_a, **_k):
|
|
275
|
-
return None
|
|
289
|
+
assert "deprecated" not in r.output + caplog.text, r.output + caplog.text
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|