@lzn1998/dsh-langgraph 0.0.0-stage → 0.13.0
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.
- package/LICENSE +21 -0
- package/README.md +51 -2
- package/client/index.tsx +418 -0
- package/cordis.patch.yml +16 -0
- package/docs/DETAIL.md +422 -0
- package/docs/ECOSYSTEM.md +134 -0
- package/docs/architecture.svg +117 -0
- package/dsh-chat-model.js +157 -0
- package/dsh-checkpointer.js +585 -0
- package/dsh-store.js +262 -0
- package/dsh-tools.js +56 -0
- package/dsh-trace.js +313 -0
- package/graphs/approval-gate.js +52 -0
- package/graphs/ask-subagent.js +48 -0
- package/graphs/ask-tools.js +57 -0
- package/graphs/ask-user.js +51 -0
- package/graphs/ask-workspace.js +48 -0
- package/graphs/scan-report.js +51 -0
- package/graphs/typed-report.ts +58 -0
- package/icon.svg +11 -0
- package/index.d.ts +155 -0
- package/index.js +1315 -0
- package/lib/client.js +273 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +71 -4
- package/scripts/build-client.mjs +126 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 lznnnnn1998
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,52 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-langgraph
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A DSH bundle that registers LangGraph workflows and exposes them to the agent as the
|
|
4
|
+
`langgraph_run` and `langgraph_threads` tools. Graph nodes call the session's own DSH
|
|
5
|
+
tools through `helpers.callTool`; threads are checkpointed in a DSH storage domain, so a
|
|
6
|
+
run survives the turn — and the Host process — and an `interrupt()`ed graph resumes
|
|
7
|
+
where it stopped.
|
|
8
|
+
|
|
9
|
+
- `langgraph_run` (`graph`, `input`, `thread`, `resume`, `maxSteps`, `run_in_background`;
|
|
10
|
+
omit `graph` to list). A background run returns a DSH job id; read it with `job_output`
|
|
11
|
+
and stop it with `job_kill`.
|
|
12
|
+
- `langgraph_threads` (`action`: `list` | `state` | `history` | `edit` | `topology` | `delete`).
|
|
13
|
+
`history` lists checkpoints, `state` reads one by `checkpoint`, and `edit` forks a
|
|
14
|
+
checkpoint with new values. Replay the fork with `langgraph_run({ graph, thread, checkpoint })`.
|
|
15
|
+
`topology` returns a graph's JSON-safe nodes and edges for a client view.
|
|
16
|
+
- Registry: `graphs/*.js` (and `graphs/*.ts` on Node 24.22+) in this package plus `config.graphs`.
|
|
17
|
+
- Node helpers: `helpers.callTool(name, args)` for DSH tools, `helpers.askUser(questions)`
|
|
18
|
+
for a question in DSH's native question UI, `helpers.subagent(prompt, options)` for a
|
|
19
|
+
caller-delivered DSH child agent, `helpers.callModel(prompt, options)` for this
|
|
20
|
+
deployment's model, and `helpers.chatModel()` / `helpers.tools([...])` /
|
|
21
|
+
`helpers.createReactAgent({...})` when you want LangGraph's prebuilt agent to drive DSH
|
|
22
|
+
tools with the DSH model. Node-level calls keep the agent's sandbox and approval scope.
|
|
23
|
+
- **Long-term memory:** graphs get a real LangGraph `BaseStore` over the
|
|
24
|
+
`langgraph_store` storage domain. A node reads it with LangGraph's own
|
|
25
|
+
`getStore(config)`, `build(api)` sees `api.store`, and a helper is available as
|
|
26
|
+
`helpers.store()`. It supports get/put/delete, filtered pagination, and namespace
|
|
27
|
+
listing; vector `query` search is rejected rather than faked. Without a storage domain
|
|
28
|
+
it falls back to `InMemoryStore`; `config.store: false` passes no store at all.
|
|
29
|
+
- **Model-facing guidance:** while loaded, a system-prompt section lists the registered
|
|
30
|
+
graph ids and descriptions, so the model can choose `langgraph_run` without first listing.
|
|
31
|
+
`config.prompt: false` disables it.
|
|
32
|
+
- **Trajectory trace:** each run shows up as one `langgraph_run` row; its graph nodes, DSH
|
|
33
|
+
tool calls, and model calls appear as nested sub-calls in **Trajectory** — `langgraph:node`,
|
|
34
|
+
`langgraph:tool`, `langgraph:model`, `langgraph:subagent`. The trace uses DSH's log-only
|
|
35
|
+
`tool/ptc-dispatch-start` / `tool/ptc-dispatch` events, so it never enters the model's
|
|
36
|
+
context. Neither DSH nor LangGraph source is modified: LangGraph's own callbacks are the
|
|
37
|
+
source, and DSH's existing session-event vocabulary is the sink. Background runs keep the
|
|
38
|
+
same trace under their `langgraph_run` row even though the events arrive after the tool result.
|
|
39
|
+
- Threads are owned by the session and graph that created them; another session cannot
|
|
40
|
+
resume or delete them. Each thread keeps at most `retention` checkpoints (default 200;
|
|
41
|
+
`0` keeps every checkpoint), with their writes pruned alongside.
|
|
42
|
+
- **Web panel:** in a Web profile the plugin contributes a **LangGraph** sidebar panel that
|
|
43
|
+
lists the registered workflows, their thread counts, and the selected graph's topology
|
|
44
|
+
(nodes, edges, conditional branches). It reads two owner-only `/api/plugins/langgraph/*`
|
|
45
|
+
routes; `config.ui: false` registers neither. Token-level streaming is not part of this
|
|
46
|
+
panel; runs stay visible in Trajectory.
|
|
47
|
+
- See `docs/DETAIL.md` for the graph module contract, trace mapping, thread semantics, and limits.
|
|
48
|
+
- See `docs/ECOSYSTEM.md` for adding LangChain packages, vector stores, prebuilt agents,
|
|
49
|
+
LangSmith tracing, and streaming.
|
|
50
|
+
|
|
51
|
+
From npm: `dsh plugin --profile <name> add @lzn1998/dsh-langgraph`, then restart that
|
|
52
|
+
profile's host. From a local checkout: `dsh plugin --profile <name> add <path-to-this-directory>`.
|
package/client/index.tsx
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser half of the LangGraph panel.
|
|
3
|
+
*
|
|
4
|
+
* Two slot contributions that share one id:
|
|
5
|
+
* - `main` key `langgraph`: the panel listing registered graphs and drawing the
|
|
6
|
+
* selected graph's topology.
|
|
7
|
+
* - `sidebar.panellist` id `langgraph`: the launcher row that selects it.
|
|
8
|
+
*
|
|
9
|
+
* The panel reads the Host plugin's authenticated routes (registered through
|
|
10
|
+
* `ctx.connection.fetch.register`, owner-only): `GET /api/plugins/langgraph/ui` for
|
|
11
|
+
* the registry and thread counts, and `GET /api/plugins/langgraph/topology?graph=`
|
|
12
|
+
* for one drawable graph. Runtime dependencies are `react` and
|
|
13
|
+
* `react/jsx-runtime` only; the Web shell seeds both into the module table.
|
|
14
|
+
* @module @lzn1998/dsh-langgraph/client
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { useCallback, useEffect, useMemo, useState } from 'react'
|
|
18
|
+
|
|
19
|
+
/** The main-panel key and the sidebar-list id: one identity for both seats. */
|
|
20
|
+
const PANEL_ID = 'langgraph'
|
|
21
|
+
|
|
22
|
+
/** Host routes served by the plugin's owner-only fetch registrations. */
|
|
23
|
+
const UI_URL = '/api/plugins/langgraph/ui'
|
|
24
|
+
const TOPOLOGY_URL = '/api/plugins/langgraph/topology'
|
|
25
|
+
|
|
26
|
+
/** Refresh cadence for the registry and thread counts. */
|
|
27
|
+
const POLL_MS = 5000
|
|
28
|
+
|
|
29
|
+
/** The injected stylesheet's ownership id. */
|
|
30
|
+
const STYLE_ID = '@lzn1998/dsh-langgraph/client.css'
|
|
31
|
+
|
|
32
|
+
/** One registered graph as `GET /ui` reports it. */
|
|
33
|
+
interface GraphItem {
|
|
34
|
+
id: string
|
|
35
|
+
description?: string
|
|
36
|
+
input?: unknown
|
|
37
|
+
error?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The registry plus durable-thread counts. */
|
|
41
|
+
interface UiPayload {
|
|
42
|
+
graphs: GraphItem[]
|
|
43
|
+
threads: { total: number; byGraph: Record<string, number>; durable: boolean }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** One drawable node. */
|
|
47
|
+
interface TopologyNode {
|
|
48
|
+
id: string
|
|
49
|
+
type?: string
|
|
50
|
+
name?: string
|
|
51
|
+
description?: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** One drawable edge; `conditional` marks a branch. */
|
|
55
|
+
interface TopologyEdge {
|
|
56
|
+
source: string
|
|
57
|
+
target: string
|
|
58
|
+
conditional?: boolean
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** One graph's drawable topology. */
|
|
62
|
+
interface TopologyPayload {
|
|
63
|
+
graph: string
|
|
64
|
+
description?: string
|
|
65
|
+
input?: unknown
|
|
66
|
+
nodes: TopologyNode[]
|
|
67
|
+
edges: TopologyEdge[]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The context slice this plugin uses, declared structurally. */
|
|
71
|
+
export interface PanelContext {
|
|
72
|
+
readonly slots: {
|
|
73
|
+
inject(key: string, factory: () => () => void): () => void
|
|
74
|
+
register(options: Readonly<Record<string, unknown>>, component: unknown): () => void
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Cordis services this browser plugin needs before it applies. */
|
|
79
|
+
export const inject = ['slots']
|
|
80
|
+
|
|
81
|
+
// ── host reads ───────────────────────────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
/** Read one JSON route, raising the Host's error message when it refuses. */
|
|
84
|
+
async function readJson<T>(url: string): Promise<T> {
|
|
85
|
+
const response = await fetch(url, { headers: { accept: 'application/json' } })
|
|
86
|
+
const payload = await response.json().catch(() => ({})) as { error?: unknown }
|
|
87
|
+
if (!response.ok) {
|
|
88
|
+
throw new Error(typeof payload?.error === 'string' ? payload.error : `HTTP ${response.status}`)
|
|
89
|
+
}
|
|
90
|
+
return payload as T
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** One-line message for an unknown thrown value. */
|
|
94
|
+
function messageOf(error: unknown): string {
|
|
95
|
+
return error instanceof Error ? error.message : String(error)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ── topology layout ──────────────────────────────────────────────────────────
|
|
99
|
+
|
|
100
|
+
const NODE_WIDTH = 150
|
|
101
|
+
const NODE_HEIGHT = 44
|
|
102
|
+
const COLUMN_GAP = 82
|
|
103
|
+
const ROW_GAP = 34
|
|
104
|
+
const PADDING = 24
|
|
105
|
+
|
|
106
|
+
interface PlacedNode extends TopologyNode {
|
|
107
|
+
x: number
|
|
108
|
+
y: number
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface PlacedEdge {
|
|
112
|
+
path: string
|
|
113
|
+
conditional: boolean
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
interface Drawing {
|
|
117
|
+
width: number
|
|
118
|
+
height: number
|
|
119
|
+
nodes: PlacedNode[]
|
|
120
|
+
edges: PlacedEdge[]
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Assign every node the BFS depth from `__start__` (unreachable nodes stay at 0). */
|
|
124
|
+
function levelsOf(topology: TopologyPayload): Map<string, number> {
|
|
125
|
+
const levels = new Map<string, number>()
|
|
126
|
+
const bySource = new Map<string, string[]>()
|
|
127
|
+
for (const edge of topology.edges) {
|
|
128
|
+
const targets = bySource.get(edge.source) ?? []
|
|
129
|
+
targets.push(edge.target)
|
|
130
|
+
bySource.set(edge.source, targets)
|
|
131
|
+
}
|
|
132
|
+
const start = topology.nodes.some(node => node.id === '__start__') ? '__start__' : topology.nodes[0]?.id
|
|
133
|
+
if (start === undefined) return levels
|
|
134
|
+
levels.set(start, 0)
|
|
135
|
+
const queue = [start]
|
|
136
|
+
while (queue.length > 0) {
|
|
137
|
+
const id = queue.shift() as string
|
|
138
|
+
for (const target of bySource.get(id) ?? []) {
|
|
139
|
+
if (levels.has(target)) continue
|
|
140
|
+
levels.set(target, (levels.get(id) ?? 0) + 1)
|
|
141
|
+
queue.push(target)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return levels
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Place columns by depth and rows within a column, then route every edge. */
|
|
148
|
+
function drawTopology(topology: TopologyPayload): Drawing {
|
|
149
|
+
const levels = levelsOf(topology)
|
|
150
|
+
const columns = new Map<number, TopologyNode[]>()
|
|
151
|
+
for (const node of topology.nodes) {
|
|
152
|
+
const level = levels.get(node.id) ?? 0
|
|
153
|
+
const column = columns.get(level) ?? []
|
|
154
|
+
column.push(node)
|
|
155
|
+
columns.set(level, column)
|
|
156
|
+
}
|
|
157
|
+
for (const column of columns.values()) {
|
|
158
|
+
column.sort((left, right) => {
|
|
159
|
+
const leftEnd = left.id === '__end__' ? 1 : 0
|
|
160
|
+
const rightEnd = right.id === '__end__' ? 1 : 0
|
|
161
|
+
return leftEnd - rightEnd
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
const placed = new Map<string, PlacedNode>()
|
|
165
|
+
const depths = [...columns.keys()].sort((left, right) => left - right)
|
|
166
|
+
let maxRows = 0
|
|
167
|
+
for (const depth of depths) {
|
|
168
|
+
const column = columns.get(depth) ?? []
|
|
169
|
+
maxRows = Math.max(maxRows, column.length)
|
|
170
|
+
column.forEach((node, row) => {
|
|
171
|
+
placed.set(node.id, {
|
|
172
|
+
...node,
|
|
173
|
+
x: PADDING + depth * (NODE_WIDTH + COLUMN_GAP),
|
|
174
|
+
y: PADDING + row * (NODE_HEIGHT + ROW_GAP),
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
const nodes = [...placed.values()]
|
|
179
|
+
const edges: PlacedEdge[] = []
|
|
180
|
+
for (const edge of topology.edges) {
|
|
181
|
+
const source = placed.get(edge.source)
|
|
182
|
+
const target = placed.get(edge.target)
|
|
183
|
+
if (source === undefined || target === undefined) continue
|
|
184
|
+
const sx = source.x + NODE_WIDTH
|
|
185
|
+
const sy = source.y + NODE_HEIGHT / 2
|
|
186
|
+
const tx = target.x
|
|
187
|
+
const ty = target.y + NODE_HEIGHT / 2
|
|
188
|
+
const bend = Math.max(40, Math.abs(tx - sx) / 2)
|
|
189
|
+
let path
|
|
190
|
+
if (tx > sx) {
|
|
191
|
+
path = `M ${sx} ${sy} C ${sx + bend} ${sy}, ${tx - bend} ${ty}, ${tx} ${ty}`
|
|
192
|
+
} else if (tx === sx) {
|
|
193
|
+
// Same column: leave to the right and come into the target's top edge.
|
|
194
|
+
const center = target.x + NODE_WIDTH / 2
|
|
195
|
+
path = `M ${sx} ${sy} C ${sx + 70} ${sy}, ${center + 70} ${target.y - 28}, ${center} ${target.y}`
|
|
196
|
+
} else {
|
|
197
|
+
path = `M ${sx} ${sy} C ${sx + bend} ${sy + 40}, ${tx - bend} ${ty + 40}, ${tx} ${ty}`
|
|
198
|
+
}
|
|
199
|
+
edges.push({ path, conditional: edge.conditional === true })
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
width: PADDING * 2 + Math.max(1, depths.length) * (NODE_WIDTH + COLUMN_GAP) - COLUMN_GAP,
|
|
203
|
+
height: PADDING * 2 + Math.max(1, maxRows) * (NODE_HEIGHT + ROW_GAP) - ROW_GAP,
|
|
204
|
+
nodes,
|
|
205
|
+
edges,
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** Draw one topology as a small left-to-right diagram. */
|
|
210
|
+
function TopologyView({ topology }: { topology: TopologyPayload }) {
|
|
211
|
+
const drawing = useMemo(() => drawTopology(topology), [topology])
|
|
212
|
+
return (
|
|
213
|
+
<div className="lg-topology">
|
|
214
|
+
<svg viewBox={`0 0 ${drawing.width} ${drawing.height}`} role="img" aria-label={`${topology.graph} topology`}>
|
|
215
|
+
<defs>
|
|
216
|
+
<marker id="lg-arrow" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
|
217
|
+
<path d="M 0 0 L 8 4 L 0 8 z" className="lg-arrow" />
|
|
218
|
+
</marker>
|
|
219
|
+
</defs>
|
|
220
|
+
{drawing.edges.map((edge, index) => (
|
|
221
|
+
<path
|
|
222
|
+
key={`edge-${index}`}
|
|
223
|
+
d={edge.path}
|
|
224
|
+
className={edge.conditional ? 'lg-edge lg-edge-conditional' : 'lg-edge'}
|
|
225
|
+
markerEnd="url(#lg-arrow)"
|
|
226
|
+
/>
|
|
227
|
+
))}
|
|
228
|
+
{drawing.nodes.map(node => (
|
|
229
|
+
<g key={node.id} transform={`translate(${node.x},${node.y})`}>
|
|
230
|
+
<rect
|
|
231
|
+
width={NODE_WIDTH}
|
|
232
|
+
height={NODE_HEIGHT}
|
|
233
|
+
rx={10}
|
|
234
|
+
className={node.id === '__start__' || node.id === '__end__' ? 'lg-node lg-node-terminal' : 'lg-node'}
|
|
235
|
+
/>
|
|
236
|
+
<text x={NODE_WIDTH / 2} y={NODE_HEIGHT / 2 + 4} textAnchor="middle" className="lg-node-label">
|
|
237
|
+
{node.id === '__start__' ? 'start' : node.id === '__end__' ? 'end' : node.name ?? node.id}
|
|
238
|
+
</text>
|
|
239
|
+
<title>{node.description ?? node.id}</title>
|
|
240
|
+
</g>
|
|
241
|
+
))}
|
|
242
|
+
</svg>
|
|
243
|
+
</div>
|
|
244
|
+
)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// ── panel ────────────────────────────────────────────────────────────────────
|
|
248
|
+
|
|
249
|
+
/** The panel body: registry on the left, selected topology on the right. */
|
|
250
|
+
function LangGraphPanel() {
|
|
251
|
+
const [ui, setUi] = useState<UiPayload>()
|
|
252
|
+
const [uiError, setUiError] = useState<string>()
|
|
253
|
+
const [selected, setSelected] = useState<string>()
|
|
254
|
+
const [topology, setTopology] = useState<TopologyPayload>()
|
|
255
|
+
const [topologyError, setTopologyError] = useState<string>()
|
|
256
|
+
const [busy, setBusy] = useState(false)
|
|
257
|
+
|
|
258
|
+
const refresh = useCallback(async () => {
|
|
259
|
+
try {
|
|
260
|
+
const next = await readJson<UiPayload>(UI_URL)
|
|
261
|
+
setUi(next)
|
|
262
|
+
setUiError(undefined)
|
|
263
|
+
setSelected(current => current !== undefined && next.graphs.some(graph => graph.id === current)
|
|
264
|
+
? current
|
|
265
|
+
: next.graphs[0]?.id)
|
|
266
|
+
} catch (error) {
|
|
267
|
+
setUiError(messageOf(error))
|
|
268
|
+
}
|
|
269
|
+
}, [])
|
|
270
|
+
|
|
271
|
+
useEffect(() => {
|
|
272
|
+
void refresh()
|
|
273
|
+
const timer = window.setInterval(() => { void refresh() }, POLL_MS)
|
|
274
|
+
return () => { window.clearInterval(timer) }
|
|
275
|
+
}, [refresh])
|
|
276
|
+
|
|
277
|
+
useEffect(() => {
|
|
278
|
+
if (selected === undefined) {
|
|
279
|
+
setTopology(undefined)
|
|
280
|
+
return undefined
|
|
281
|
+
}
|
|
282
|
+
let live = true
|
|
283
|
+
setBusy(true)
|
|
284
|
+
setTopologyError(undefined)
|
|
285
|
+
readJson<TopologyPayload>(`${TOPOLOGY_URL}?graph=${encodeURIComponent(selected)}`)
|
|
286
|
+
.then(next => { if (live) setTopology(next) })
|
|
287
|
+
.catch(error => {
|
|
288
|
+
if (!live) return
|
|
289
|
+
setTopology(undefined)
|
|
290
|
+
setTopologyError(messageOf(error))
|
|
291
|
+
})
|
|
292
|
+
.finally(() => { if (live) setBusy(false) })
|
|
293
|
+
return () => { live = false }
|
|
294
|
+
}, [selected])
|
|
295
|
+
|
|
296
|
+
const selectedGraph = ui?.graphs.find(graph => graph.id === selected)
|
|
297
|
+
return (
|
|
298
|
+
<section className="lg-panel" aria-label="LangGraph workflows">
|
|
299
|
+
<header className="lg-header">
|
|
300
|
+
<div>
|
|
301
|
+
<h2 className="lg-title">LangGraph</h2>
|
|
302
|
+
<p className="lg-muted">
|
|
303
|
+
{ui === undefined
|
|
304
|
+
? 'Loading workflows…'
|
|
305
|
+
: `${ui.graphs.length} workflow${ui.graphs.length === 1 ? '' : 's'} · ${ui.threads.total} durable thread${ui.threads.total === 1 ? '' : 's'}`}
|
|
306
|
+
</p>
|
|
307
|
+
</div>
|
|
308
|
+
<button type="button" className="lg-button" onClick={() => { void refresh() }}>Refresh</button>
|
|
309
|
+
</header>
|
|
310
|
+
|
|
311
|
+
{uiError !== undefined && <p className="lg-error">{uiError}</p>}
|
|
312
|
+
|
|
313
|
+
<div className="lg-grid">
|
|
314
|
+
<nav className="lg-list" aria-label="Registered graphs">
|
|
315
|
+
{(ui?.graphs ?? []).map(graph => (
|
|
316
|
+
<button
|
|
317
|
+
key={graph.id}
|
|
318
|
+
type="button"
|
|
319
|
+
className={graph.id === selected ? 'lg-item lg-item-active' : 'lg-item'}
|
|
320
|
+
onClick={() => setSelected(graph.id)}
|
|
321
|
+
>
|
|
322
|
+
<span className="lg-item-id">{graph.id}</span>
|
|
323
|
+
<span className="lg-item-meta">
|
|
324
|
+
{graph.error ?? `${ui?.threads.byGraph[graph.id] ?? 0} thread${(ui?.threads.byGraph[graph.id] ?? 0) === 1 ? '' : 's'}`}
|
|
325
|
+
</span>
|
|
326
|
+
{graph.error === undefined && graph.description !== undefined && (
|
|
327
|
+
<span className="lg-item-desc">{graph.description}</span>
|
|
328
|
+
)}
|
|
329
|
+
</button>
|
|
330
|
+
))}
|
|
331
|
+
{ui !== undefined && ui.graphs.length === 0 && <p className="lg-muted">No workflows registered.</p>}
|
|
332
|
+
</nav>
|
|
333
|
+
|
|
334
|
+
<div className="lg-canvas">
|
|
335
|
+
{topologyError !== undefined && <p className="lg-error">{topologyError}</p>}
|
|
336
|
+
{busy && <p className="lg-muted">Loading topology…</p>}
|
|
337
|
+
{!busy && topology !== undefined && <TopologyView topology={topology} />}
|
|
338
|
+
{!busy && topology === undefined && topologyError === undefined && (
|
|
339
|
+
<p className="lg-muted">Select a workflow to see its nodes and edges.</p>
|
|
340
|
+
)}
|
|
341
|
+
</div>
|
|
342
|
+
</div>
|
|
343
|
+
|
|
344
|
+
<footer className="lg-footer">
|
|
345
|
+
{selectedGraph?.description ?? 'Runs appear as langgraph_run rows in Trajectory.'}
|
|
346
|
+
</footer>
|
|
347
|
+
</section>
|
|
348
|
+
)
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** Sidebar launcher icon: one node feeding two others. */
|
|
352
|
+
function LangGraphIcon() {
|
|
353
|
+
return (
|
|
354
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
|
355
|
+
<rect x="2" y="9" width="6" height="6" rx="2" stroke="currentColor" strokeWidth="1.6" />
|
|
356
|
+
<rect x="16" y="2" width="6" height="6" rx="2" stroke="currentColor" strokeWidth="1.6" />
|
|
357
|
+
<rect x="16" y="16" width="6" height="6" rx="2" stroke="currentColor" strokeWidth="1.6" />
|
|
358
|
+
<path d="M8 12h4v-7h4M12 12v7h4" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" />
|
|
359
|
+
</svg>
|
|
360
|
+
)
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// ── styles ───────────────────────────────────────────────────────────────────
|
|
364
|
+
|
|
365
|
+
const PANEL_CSS = `
|
|
366
|
+
.lg-panel { display: flex; flex-direction: column; height: 100%; min-height: 0; padding: 18px 20px; gap: 14px; color: inherit; font: inherit; }
|
|
367
|
+
.lg-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
|
|
368
|
+
.lg-title { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: .01em; }
|
|
369
|
+
.lg-muted { margin: 2px 0 0; opacity: .62; font-size: 12px; }
|
|
370
|
+
.lg-error { margin: 0; padding: 8px 10px; border-radius: 8px; font-size: 12px; color: #ffb4ab; background: rgba(255, 80, 70, .12); border: 1px solid rgba(255, 80, 70, .28); white-space: pre-wrap; }
|
|
371
|
+
.lg-button { border: 1px solid color-mix(in srgb, currentColor 22%, transparent); background: transparent; color: inherit; border-radius: 8px; padding: 6px 12px; font: inherit; font-size: 12px; cursor: pointer; }
|
|
372
|
+
.lg-button:hover { background: color-mix(in srgb, currentColor 8%, transparent); }
|
|
373
|
+
.lg-grid { display: grid; grid-template-columns: minmax(190px, 250px) minmax(0, 1fr); gap: 14px; min-height: 0; flex: 1; }
|
|
374
|
+
.lg-list { display: flex; flex-direction: column; gap: 6px; overflow: auto; padding-right: 2px; }
|
|
375
|
+
.lg-item { display: flex; flex-direction: column; gap: 2px; text-align: left; border: 1px solid color-mix(in srgb, currentColor 14%, transparent); background: transparent; color: inherit; border-radius: 10px; padding: 8px 10px; font: inherit; cursor: pointer; }
|
|
376
|
+
.lg-item:hover { background: color-mix(in srgb, currentColor 6%, transparent); }
|
|
377
|
+
.lg-item-active { border-color: color-mix(in srgb, currentColor 40%, transparent); background: color-mix(in srgb, currentColor 9%, transparent); }
|
|
378
|
+
.lg-item-id { font-size: 13px; font-weight: 600; }
|
|
379
|
+
.lg-item-meta { font-size: 11px; opacity: .58; }
|
|
380
|
+
.lg-item-desc { font-size: 11px; opacity: .72; line-height: 1.35; }
|
|
381
|
+
.lg-canvas { min-height: 0; overflow: auto; border: 1px solid color-mix(in srgb, currentColor 12%, transparent); border-radius: 12px; padding: 12px; }
|
|
382
|
+
.lg-topology { min-width: min-content; }
|
|
383
|
+
.lg-topology svg { display: block; max-width: 100%; height: auto; overflow: visible; }
|
|
384
|
+
.lg-node { fill: color-mix(in srgb, currentColor 7%, transparent); stroke: color-mix(in srgb, currentColor 38%, transparent); stroke-width: 1.2; }
|
|
385
|
+
.lg-node-terminal { fill: transparent; stroke-dasharray: 4 4; }
|
|
386
|
+
.lg-node-label { fill: currentColor; font-size: 12px; font-weight: 550; }
|
|
387
|
+
.lg-edge { fill: none; stroke: color-mix(in srgb, currentColor 42%, transparent); stroke-width: 1.4; }
|
|
388
|
+
.lg-edge-conditional { stroke-dasharray: 6 4; }
|
|
389
|
+
.lg-arrow { fill: color-mix(in srgb, currentColor 55%, transparent); }
|
|
390
|
+
.lg-footer { font-size: 11px; opacity: .55; border-top: 1px solid color-mix(in srgb, currentColor 10%, transparent); padding-top: 9px; }
|
|
391
|
+
`
|
|
392
|
+
|
|
393
|
+
/** Inject the panel stylesheet once per page. */
|
|
394
|
+
function installStyles(): void {
|
|
395
|
+
if (document.querySelector(`style[data-plugin-css="${STYLE_ID}"]`) !== null) return
|
|
396
|
+
const tag = document.createElement('style')
|
|
397
|
+
tag.dataset.plugin = '@lzn1998/dsh-langgraph'
|
|
398
|
+
tag.dataset.pluginCss = STYLE_ID
|
|
399
|
+
tag.textContent = PANEL_CSS
|
|
400
|
+
document.head.appendChild(tag)
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Contribute the panel and its sidebar launcher. `slots.inject` waits for each
|
|
405
|
+
* slot's declaration, so activation order does not matter; the disposers
|
|
406
|
+
* belong to this plugin's fiber.
|
|
407
|
+
* @param ctx - browser context carrying the slot registry.
|
|
408
|
+
*/
|
|
409
|
+
export function apply(ctx: PanelContext): void {
|
|
410
|
+
installStyles()
|
|
411
|
+
ctx.slots.inject('main', () => ctx.slots.register({ name: 'main', key: PANEL_ID }, LangGraphPanel))
|
|
412
|
+
ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
|
|
413
|
+
name: 'sidebar.panellist',
|
|
414
|
+
id: PANEL_ID,
|
|
415
|
+
order: 32,
|
|
416
|
+
label: 'LangGraph',
|
|
417
|
+
}, LangGraphIcon))
|
|
418
|
+
}
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Registers the LangGraph workflow tools. Graphs live in the package's `graphs/`
|
|
2
|
+
# directory; `config.graphs` adds more modules, `config.recursionLimit` bounds a run,
|
|
3
|
+
# `config.model` overrides the route graph nodes use for model calls, `config.trace:
|
|
4
|
+
# false` turns off the Trajectory sub-call trace, `config.prompt: false` turns off
|
|
5
|
+
# the model-facing system-prompt graph guidance, `config.background: false` hides
|
|
6
|
+
# background runs, `config.subagentProvider` selects the provider for
|
|
7
|
+
# `helpers.subagent` (default `spawn`), and `config.store: false` passes no
|
|
8
|
+
# long-term BaseStore to graphs. Threads are checkpointed in the
|
|
9
|
+
# `langgraph_checkpoints` storage domain and keep `config.retention` checkpoints
|
|
10
|
+
# each (default 200; 0 is unlimited); long-term memories live in
|
|
11
|
+
# `langgraph_store`. In a Web profile `config.ui: false` also turns off the
|
|
12
|
+
# panel's owner-only routes.
|
|
13
|
+
- insert:
|
|
14
|
+
- id: langgraph
|
|
15
|
+
name: '@lzn1998/dsh-langgraph'
|
|
16
|
+
config: {}
|