deepagent-vscode 0.2.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.
@@ -0,0 +1,11 @@
1
+ """deepagent-vscode — Python stdio sidecar for the VS Code chat extension.
2
+
3
+ The extension spawns ``python -m deepagent_vscode`` (or the
4
+ ``deepagent-vscode-sidecar`` console script); the sidecar bridges a
5
+ LangGraph/deepagents agent to the chat participant over newline-delimited JSON.
6
+ """
7
+ from .sidecar import main, run
8
+
9
+ __version__ = "0.1.0"
10
+
11
+ __all__ = ["main", "run", "__version__"]
@@ -0,0 +1,3 @@
1
+ from .sidecar import main
2
+
3
+ raise SystemExit(main())
@@ -0,0 +1,189 @@
1
+ """stdio sidecar bridging a LangGraph agent to the deepagent-vscode extension.
2
+
3
+ Reads newline-delimited JSON commands on stdin, runs the agent through
4
+ ``langgraph-stream-parser``, and writes newline-delimited JSON events on
5
+ stdout. The events are exactly ``event.to_dict()`` shapes — the same wire
6
+ vocabulary every other deep-agent surface (FastAPI WebSocket/SSE, Jupyter, CLI)
7
+ emits — so the TS extension's dispatcher renders them the same way.
8
+
9
+ Commands (client -> sidecar), one JSON object per line:
10
+ {"type": "message", "session_id": "s1", "content": "..."}
11
+ {"type": "decision", "session_id": "s1", "decisions": [{"type": "approve"}]}
12
+ {"type": "shutdown"}
13
+
14
+ Events (sidecar -> client), one JSON object per line:
15
+ {"type": "ready"} # once, at startup
16
+ {"type": "ack", "ref": "message|decision"} # command accepted
17
+ <event_to_dict(...)> # content/tool_start/tool_end/
18
+ # reasoning/extraction/interrupt
19
+ {"type": "complete"} | {"type": "error", "error": "..."}
20
+ {"type": "turn_end", "session_id": "s1"} # one turn finished
21
+ """
22
+ from __future__ import annotations
23
+
24
+ import json
25
+ from typing import Any, Callable, Iterable, TextIO
26
+
27
+ from langgraph_stream_parser import (
28
+ StreamParser,
29
+ create_resume_input,
30
+ event_to_dict,
31
+ load_agent_spec,
32
+ prepare_agent_input,
33
+ )
34
+
35
+ DEFAULT_STREAM_MODE = ["updates", "messages"]
36
+ DEFAULT_MAX_RESULT_LEN = 50_000
37
+
38
+
39
+ def run(
40
+ graph: Any,
41
+ stdin: Iterable[str],
42
+ stdout: TextIO,
43
+ *,
44
+ stream_mode: str | list[str] = DEFAULT_STREAM_MODE,
45
+ max_result_len: int = DEFAULT_MAX_RESULT_LEN,
46
+ ) -> None:
47
+ """Drive the command/event loop over the given streams.
48
+
49
+ Factored out from ``main`` so it can be tested with in-memory streams and
50
+ a fake graph. ``stdin`` is any line iterable; ``stdout`` needs ``write``.
51
+ """
52
+ mode = list(stream_mode) if isinstance(stream_mode, tuple) else stream_mode
53
+
54
+ def emit(obj: dict[str, Any]) -> None:
55
+ stdout.write(json.dumps(obj) + "\n")
56
+ stdout.flush()
57
+
58
+ emit({"type": "ready"})
59
+
60
+ for raw in stdin:
61
+ line = raw.strip()
62
+ if not line:
63
+ continue
64
+ try:
65
+ cmd = json.loads(line)
66
+ except json.JSONDecodeError as e:
67
+ emit({"type": "error", "error": f"invalid JSON: {e}"})
68
+ continue
69
+
70
+ ctype = cmd.get("type")
71
+ if ctype == "shutdown":
72
+ break
73
+
74
+ session_id = cmd.get("session_id", "default")
75
+ config = {"configurable": {"thread_id": session_id}}
76
+
77
+ if ctype == "message":
78
+ content = cmd.get("content", "")
79
+ if not content:
80
+ emit({"type": "error", "error": "message requires 'content'"})
81
+ continue
82
+ emit({"type": "ack", "ref": "message"})
83
+ input_data = prepare_agent_input(message=content)
84
+ elif ctype == "decision":
85
+ decisions = cmd.get("decisions")
86
+ if not isinstance(decisions, list):
87
+ emit({"type": "error", "error": "decision requires 'decisions' list"})
88
+ continue
89
+ emit({"type": "ack", "ref": "decision"})
90
+ input_data = create_resume_input(decisions=decisions)
91
+ else:
92
+ emit({"type": "error", "error": f"unknown command type: {ctype!r}"})
93
+ continue
94
+
95
+ _run_turn(graph, input_data, config, mode, max_result_len, emit)
96
+ emit({"type": "turn_end", "session_id": session_id})
97
+
98
+
99
+ def _run_turn(
100
+ graph: Any,
101
+ input_data: Any,
102
+ config: dict[str, Any],
103
+ stream_mode: str | list[str],
104
+ max_result_len: int,
105
+ emit: Callable[[dict[str, Any]], None],
106
+ ) -> None:
107
+ """Stream one turn; the parser emits the terminal complete/error event."""
108
+ parser = StreamParser(stream_mode=stream_mode)
109
+ try:
110
+ stream = graph.stream(input_data, config=config, stream_mode=stream_mode)
111
+ for event in parser.parse(stream):
112
+ emit(event_to_dict(event, max_result_len=max_result_len))
113
+ except Exception as exc: # noqa: BLE001 — surfaced to the client as an event
114
+ emit({"type": "error", "error": f"{type(exc).__name__}: {exc}"})
115
+
116
+
117
+ # The keyless echo agent shipped with the shared core — see `--demo`.
118
+ DEMO_AGENT_SPEC = "langgraph_stream_parser.demo.stub:graph"
119
+
120
+
121
+ def main(argv: list[str] | None = None) -> int:
122
+ import argparse
123
+ import os
124
+ import sys
125
+
126
+ from langgraph_stream_parser.host import HostConfig
127
+
128
+ parser = argparse.ArgumentParser(prog="deepagent-vscode-sidecar")
129
+ parser.add_argument(
130
+ "--agent",
131
+ default=None,
132
+ help="Agent spec 'path.py:var' or 'module:var' "
133
+ "(overrides DEEPAGENT_AGENT_SPEC / deepagents.toml [agent].spec).",
134
+ )
135
+ parser.add_argument(
136
+ "--workspace",
137
+ default=None,
138
+ help="Workspace root (overrides DEEPAGENT_WORKSPACE_ROOT / deepagents.toml).",
139
+ )
140
+ parser.add_argument(
141
+ "--demo",
142
+ action="store_true",
143
+ help="Run with the built-in keyless demo agent — no API key needed.",
144
+ )
145
+ parser.add_argument(
146
+ "--show-config",
147
+ action="store_true",
148
+ help="Print the resolved configuration (defaults < deepagents.toml < env < CLI) and exit.",
149
+ )
150
+ args = parser.parse_args(argv)
151
+
152
+ # Same resolution chain as every other deep-agent surface:
153
+ # defaults < deepagents.toml < DEEPAGENT_* env < CLI flags.
154
+ cfg = HostConfig.resolve(
155
+ overrides={"agent_spec": args.agent, "workspace_root": args.workspace}
156
+ )
157
+
158
+ if args.show_config:
159
+ print(cfg.describe())
160
+ return 0
161
+
162
+ def fail(msg: str) -> int:
163
+ sys.stdout.write(json.dumps({"type": "error", "error": msg}) + "\n")
164
+ sys.stdout.flush()
165
+ return 1
166
+
167
+ spec = cfg.agent_spec
168
+ if args.demo:
169
+ if args.agent:
170
+ return fail("--demo and --agent are mutually exclusive")
171
+ spec = DEMO_AGENT_SPEC
172
+ if not spec:
173
+ return fail(
174
+ "no agent spec (pass --agent or --demo, set DEEPAGENT_AGENT_SPEC, "
175
+ "or set [agent].spec in deepagents.toml)"
176
+ )
177
+
178
+ os.environ.setdefault("DEEPAGENT_WORKSPACE_ROOT", str(cfg.workspace_root))
179
+ try:
180
+ graph = load_agent_spec(spec)
181
+ except Exception as exc: # noqa: BLE001
182
+ return fail(f"failed to load agent {spec!r}: {type(exc).__name__}: {exc}")
183
+
184
+ run(graph, sys.stdin, sys.stdout)
185
+ return 0
186
+
187
+
188
+ if __name__ == "__main__":
189
+ raise SystemExit(main())
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: deepagent-vscode
3
+ Version: 0.2.0
4
+ Summary: Python stdio sidecar bridging LangGraph/deepagents agents to the deepagent-vscode chat extension
5
+ Author: Kedar Dabhadkar
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Keywords: agents,ai,deepagents,langgraph,vscode
9
+ Requires-Python: >=3.11
10
+ Requires-Dist: langgraph-stream-parser<0.3,>=0.2.2
11
+ Provides-Extra: demo
12
+ Requires-Dist: deepagents>=0.3; extra == 'demo'
13
+ Provides-Extra: dev
14
+ Requires-Dist: langchain-core>=1.4.0; extra == 'dev'
15
+ Requires-Dist: langgraph>=1.1.0; extra == 'dev'
16
+ Requires-Dist: pytest>=8; extra == 'dev'
@@ -0,0 +1,8 @@
1
+ deepagent_vscode/__init__.py,sha256=3U6HSl8042VuKq64EFv9qoyzfkQ-PXe_suelN5E2y8s,386
2
+ deepagent_vscode/__main__.py,sha256=Tc7pfmkcYgucfsbN_gdW_poelCZStkBzGgReUW2kVHI,52
3
+ deepagent_vscode/sidecar.py,sha256=wem9FbE36RoOAxHShBFsB2exD3pOvsicbRfVpSN_FDE,6691
4
+ deepagent_vscode-0.2.0.dist-info/METADATA,sha256=YeRUUwaVaYNrQkCMt9QaLzdtPEibOC8fa2zgJF0gbb8,590
5
+ deepagent_vscode-0.2.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
6
+ deepagent_vscode-0.2.0.dist-info/entry_points.txt,sha256=rhfu2oSJhuWoI_RMoxlttMfc7GFe43GXMeKJRWjt6-c,75
7
+ deepagent_vscode-0.2.0.dist-info/licenses/LICENSE,sha256=OLXlqkaie9PXKulFRTpr3D482_sWP8tO4xOHDu87SFo,1093
8
+ deepagent_vscode-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.30.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ deepagent-vscode-sidecar = deepagent_vscode.sidecar:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kedar Dabhadkar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.