@lzn1998/dsh-langgraph 0.13.0 → 1.0.1
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/README.md +7 -4
- package/client/index.tsx +5 -5
- package/docs/CONTEXT.md +117 -0
- package/docs/DETAIL.md +22 -8
- package/graphs/approval-gate.js +1 -1
- package/graphs/ask-tools.js +1 -1
- package/graphs/ask-workspace.js +1 -1
- package/graphs/scan-report.js +1 -1
- package/index.js +44 -28
- package/lib/client.js +3 -3
- package/locale/en.json +2 -2
- package/locale/zh.json +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-langgraph
|
|
2
2
|
|
|
3
|
-
A DSH bundle that registers LangGraph
|
|
3
|
+
A DSH bundle that registers LangGraph graphs and exposes them to the agent as the
|
|
4
4
|
`langgraph_run` and `langgraph_threads` tools. Graph nodes call the session's own DSH
|
|
5
5
|
tools through `helpers.callTool`; threads are checkpointed in a DSH storage domain, so a
|
|
6
6
|
run survives the turn — and the Host process — and an `interrupt()`ed graph resumes
|
|
@@ -27,8 +27,9 @@ where it stopped.
|
|
|
27
27
|
listing; vector `query` search is rejected rather than faked. Without a storage domain
|
|
28
28
|
it falls back to `InMemoryStore`; `config.store: false` passes no store at all.
|
|
29
29
|
- **Model-facing guidance:** while loaded, a system-prompt section lists the registered
|
|
30
|
-
graph ids and descriptions,
|
|
31
|
-
`config.prompt: false`
|
|
30
|
+
graph ids and descriptions, distinguishes `langgraph_run` from the `workflow` tool, and
|
|
31
|
+
tells the model to use a matching graph rather than reimplement it. `config.prompt: false`
|
|
32
|
+
disables it.
|
|
32
33
|
- **Trajectory trace:** each run shows up as one `langgraph_run` row; its graph nodes, DSH
|
|
33
34
|
tool calls, and model calls appear as nested sub-calls in **Trajectory** — `langgraph:node`,
|
|
34
35
|
`langgraph:tool`, `langgraph:model`, `langgraph:subagent`. The trace uses DSH's log-only
|
|
@@ -40,11 +41,13 @@ where it stopped.
|
|
|
40
41
|
resume or delete them. Each thread keeps at most `retention` checkpoints (default 200;
|
|
41
42
|
`0` keeps every checkpoint), with their writes pruned alongside.
|
|
42
43
|
- **Web panel:** in a Web profile the plugin contributes a **LangGraph** sidebar panel that
|
|
43
|
-
lists the registered
|
|
44
|
+
lists the registered graphs, their thread counts, and the selected graph's topology
|
|
44
45
|
(nodes, edges, conditional branches). It reads two owner-only `/api/plugins/langgraph/*`
|
|
45
46
|
routes; `config.ui: false` registers neither. Token-level streaming is not part of this
|
|
46
47
|
panel; runs stay visible in Trajectory.
|
|
47
48
|
- See `docs/DETAIL.md` for the graph module contract, trace mapping, thread semantics, and limits.
|
|
49
|
+
- See `docs/CONTEXT.md` for what is injected into the model context, the vocabulary, and
|
|
50
|
+
how it stays distinct from DSH's `workflow`, `subagent`, and question tools.
|
|
48
51
|
- See `docs/ECOSYSTEM.md` for adding LangChain packages, vector stores, prebuilt agents,
|
|
49
52
|
LangSmith tracing, and streaming.
|
|
50
53
|
|
package/client/index.tsx
CHANGED
|
@@ -295,14 +295,14 @@ function LangGraphPanel() {
|
|
|
295
295
|
|
|
296
296
|
const selectedGraph = ui?.graphs.find(graph => graph.id === selected)
|
|
297
297
|
return (
|
|
298
|
-
<section className="lg-panel" aria-label="LangGraph
|
|
298
|
+
<section className="lg-panel" aria-label="LangGraph graphs">
|
|
299
299
|
<header className="lg-header">
|
|
300
300
|
<div>
|
|
301
301
|
<h2 className="lg-title">LangGraph</h2>
|
|
302
302
|
<p className="lg-muted">
|
|
303
303
|
{ui === undefined
|
|
304
|
-
? 'Loading
|
|
305
|
-
: `${ui.graphs.length}
|
|
304
|
+
? 'Loading graphs…'
|
|
305
|
+
: `${ui.graphs.length} graph${ui.graphs.length === 1 ? '' : 's'} · ${ui.threads.total} durable thread${ui.threads.total === 1 ? '' : 's'}`}
|
|
306
306
|
</p>
|
|
307
307
|
</div>
|
|
308
308
|
<button type="button" className="lg-button" onClick={() => { void refresh() }}>Refresh</button>
|
|
@@ -328,7 +328,7 @@ function LangGraphPanel() {
|
|
|
328
328
|
)}
|
|
329
329
|
</button>
|
|
330
330
|
))}
|
|
331
|
-
{ui !== undefined && ui.graphs.length === 0 && <p className="lg-muted">No
|
|
331
|
+
{ui !== undefined && ui.graphs.length === 0 && <p className="lg-muted">No graphs registered.</p>}
|
|
332
332
|
</nav>
|
|
333
333
|
|
|
334
334
|
<div className="lg-canvas">
|
|
@@ -336,7 +336,7 @@ function LangGraphPanel() {
|
|
|
336
336
|
{busy && <p className="lg-muted">Loading topology…</p>}
|
|
337
337
|
{!busy && topology !== undefined && <TopologyView topology={topology} />}
|
|
338
338
|
{!busy && topology === undefined && topologyError === undefined && (
|
|
339
|
-
<p className="lg-muted">Select a
|
|
339
|
+
<p className="lg-muted">Select a graph to see its nodes and edges.</p>
|
|
340
340
|
)}
|
|
341
341
|
</div>
|
|
342
342
|
</div>
|
package/docs/CONTEXT.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Context and prompt design
|
|
2
|
+
|
|
3
|
+
This plugin adds one vocabulary and two tools to a DSH profile. This page records
|
|
4
|
+
exactly what it injects, what it deliberately does not inject, and how that layer stays
|
|
5
|
+
distinct from DSH's own prompt and tools.
|
|
6
|
+
|
|
7
|
+
## What is injected
|
|
8
|
+
|
|
9
|
+
| Layer | Contribution | Lifetime |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| Tool schemas | `langgraph_run`, `langgraph_threads` | While the plugin is loaded; `config.prompt: false` does not remove them. |
|
|
12
|
+
| System-prompt section | `tool:langgraph`, order `TOOL_SUBAGENT - 10` | Effect-owned by the plugin; `config.prompt: false` disables it. |
|
|
13
|
+
| Runtime context | **none** | — |
|
|
14
|
+
| Session events | none from the model's point of view | Traces are log-only DSH PTC events for Trajectory. |
|
|
15
|
+
|
|
16
|
+
The section is a text function, so the model sees a short "call it to list" hint until
|
|
17
|
+
the asynchronous registry scan finishes, then the graph list (up to 24 ids and one-line
|
|
18
|
+
descriptions; input schemas stay out of the prompt). `langgraph_run` with no `graph`
|
|
19
|
+
always returns the full list and schemas.
|
|
20
|
+
|
|
21
|
+
### Why no runtime context
|
|
22
|
+
|
|
23
|
+
`ctx.systemPrompt.context` materializes durable user-role snapshots. The plugin does not
|
|
24
|
+
use it because:
|
|
25
|
+
|
|
26
|
+
- The graph catalog is a profile-level fact, not a per-turn fact; a section is the right
|
|
27
|
+
layer and can be cached.
|
|
28
|
+
- The only genuinely dynamic facts are the calling session's threads and checkpoints.
|
|
29
|
+
Those are read on demand with `langgraph_threads`; injecting them every turn would
|
|
30
|
+
duplicate state, grow tokens, and go stale.
|
|
31
|
+
- `AssembleContext` carries no session identity, so a context contribution could not be
|
|
32
|
+
scoped to the calling session without a new DSH seam. The plugin does not invent one.
|
|
33
|
+
|
|
34
|
+
## Vocabulary
|
|
35
|
+
|
|
36
|
+
| Term | Meaning in this plugin | Not |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| **graph** | A module registered with the profile (`id`, `description`, `input`, `build`). | The `workflow` tool's ad-hoc JavaScript script. |
|
|
39
|
+
| **graph run** | One execution with an input, returning a state. | A DSH turn or Session. |
|
|
40
|
+
| **thread** | A durable LangGraph checkpoint chain for one graph run, owned by the session and graph that created it. | A DSH Session. |
|
|
41
|
+
| **checkpoint** | One snapshot in a thread; `history`, `edit`, and replay address it by id. | A DSH session checkpoint. |
|
|
42
|
+
| **background run** | A graph run started as a DSH job; read with `job_output`, stop with `job_kill`. | A detached process. |
|
|
43
|
+
| **Trajectory record** | The log-only `langgraph:node` / `langgraph:tool` / `langgraph:model` sub-calls under the `langgraph_run` row. | Model-visible conversation content. |
|
|
44
|
+
| **store** | An optional graph-owned `BaseStore`; not a model-facing facility by itself. | A reason to call `langgraph_run`. |
|
|
45
|
+
|
|
46
|
+
## Trigger policy
|
|
47
|
+
|
|
48
|
+
The section states one policy, in the same words the model sees:
|
|
49
|
+
|
|
50
|
+
1. **Name** — the user names one of the registered graph ids.
|
|
51
|
+
2. **Match** — a graph's description matches the **requested output**, not merely the
|
|
52
|
+
same files or tools. `scan-report` matches “is this a lot?”; an exact file count is a
|
|
53
|
+
glob/bash task, so the graph is not a match even though it also counts.
|
|
54
|
+
3. **Property** — the task needs a durable thread, a background run (DSH job),
|
|
55
|
+
checkpoint history or replay, a Trajectory sub-call record, or a graph that interrupts.
|
|
56
|
+
|
|
57
|
+
It also says what *not* to do: when no graph's output matches, use ordinary DSH tools;
|
|
58
|
+
do not wrap a single tool call in a graph for ceremony, and do not reimplement a matching
|
|
59
|
+
graph with `bash`, `subagent`, or ad-hoc steps. This keeps graph
|
|
60
|
+
use from becoming ceremony while still letting a matching graph win over a hand-rolled
|
|
61
|
+
sequence.
|
|
62
|
+
|
|
63
|
+
The tool description covers mechanics (arguments, thread/resume/checkpoint, background
|
|
64
|
+
job), not selection; the section covers selection, not mechanics. This split is the main
|
|
65
|
+
rule for future edits.
|
|
66
|
+
|
|
67
|
+
## Leaving the shape open
|
|
68
|
+
|
|
69
|
+
The prompt does not prescribe a decision tree or concrete examples. It states the
|
|
70
|
+
boundaries and the available moves:
|
|
71
|
+
|
|
72
|
+
- a graph that is already registered and whose output matches → `langgraph_run`;
|
|
73
|
+
- a one-off task, or a task whose shape is still unclear → ordinary DSH tools;
|
|
74
|
+
- an ad-hoc fan-out whose shape is generated for this run → `workflow`;
|
|
75
|
+
- a shape worth reusing → a profile graph module (authored outside this tool).
|
|
76
|
+
|
|
77
|
+
`langgraph_run` cannot define a graph; the model is told not to invent an id. The only
|
|
78
|
+
concrete list in the prompt is the registry itself — data the model must select from, not
|
|
79
|
+
an example to copy. This is deliberate: the model should choose or compose the shape,
|
|
80
|
+
not imitate a canned one.
|
|
81
|
+
|
|
82
|
+
## Boundaries with DSH's own context
|
|
83
|
+
|
|
84
|
+
| DSH facility | Boundary |
|
|
85
|
+
|---|---|
|
|
86
|
+
| `workflow` tool | `workflow` writes an ad-hoc JavaScript fan-out script; `langgraph_run` runs a profile-registered, named graph with a durable thread. The section sits **after** the workflow tool's "only when the user asks" rule and **before** subagent guidance (`TOOL_SUBAGENT - 10`), so that rule cannot read as part of this section. |
|
|
87
|
+
| `subagent` | One-off delegation stays `subagent`; a graph may delegate internally, and `helpers.subagent` creates a normal DSH child. |
|
|
88
|
+
| `ask_user_question` | The native question tool is the default for one question; the `ask-user` graph only adds value when a graph or thread is wanted. |
|
|
89
|
+
| `job_output` / `job_kill` | A background graph run is a DSH job; use the stock job tools. |
|
|
90
|
+
| DSH Session | A LangGraph thread is not a Session; the prompt and tool schema say so explicitly. |
|
|
91
|
+
| Trajectory | Graph activity appears as nested log-only sub-calls; it is not injected into model context. |
|
|
92
|
+
| Goals, schedules | Out of scope; the plugin does not create either. |
|
|
93
|
+
|
|
94
|
+
## Placement
|
|
95
|
+
|
|
96
|
+
- Order: `ctx.systemPrompt.getSectionOrder('TOOL_SUBAGENT') - 10`, fallback `2790`.
|
|
97
|
+
The earlier `TOOL_WORKFLOW` (2600) placement put the section between two copies of the
|
|
98
|
+
workflow tool's "ONLY when..." guidance and made the two "workflow" instructions read
|
|
99
|
+
as one.
|
|
100
|
+
- The section is global to the profile while the plugin is active, including agents whose
|
|
101
|
+
tool policy hides `langgraph_run`; `config.prompt: false` is the escape hatch.
|
|
102
|
+
- Registry entries are sorted by id; broken modules are skipped from the list.
|
|
103
|
+
|
|
104
|
+
## Maintenance checklist
|
|
105
|
+
|
|
106
|
+
When changing this layer:
|
|
107
|
+
|
|
108
|
+
1. Keep the words **graph**, **thread**, **checkpoint**, and **DSH job** consistent in the
|
|
109
|
+
prompt, tool descriptions, error messages, UI, and docs.
|
|
110
|
+
2. Do not use "workflow" as a synonym for a graph; it belongs only in the explicit
|
|
111
|
+
distinction from the `workflow` tool.
|
|
112
|
+
3. Add a trigger only if it is a property the plugin actually provides; do not advertise
|
|
113
|
+
long-term memory unless a graph uses the store.
|
|
114
|
+
4. Keep the section about selection and the tool descriptions about mechanics.
|
|
115
|
+
5. Keep graph descriptions one line, unique, and specific about the graph's value; avoid
|
|
116
|
+
demo overlap.
|
|
117
|
+
6. Re-check section order when a DSH release adds or renames prompt sections.
|
package/docs/DETAIL.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# LangGraph
|
|
1
|
+
# LangGraph graphs
|
|
2
2
|
|
|
3
3
|
Run a LangGraph graph from inside a DSH agent session, and continue it later.
|
|
4
4
|
|
|
@@ -47,11 +47,25 @@ Run a LangGraph graph from inside a DSH agent session, and continue it later.
|
|
|
47
47
|
## Model-facing guidance
|
|
48
48
|
|
|
49
49
|
While the plugin is active it registers a system-prompt section through DSH's public
|
|
50
|
-
`ctx.systemPrompt.section` API — no DSH source change. The section
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
`ctx.systemPrompt.section` API — no DSH source change. The section defines the vocabulary
|
|
51
|
+
(profile-registered graphs, not the `workflow` tool), the trigger policy (a named graph,
|
|
52
|
+
a description match, or a graph-specific need such as a durable thread, background job,
|
|
53
|
+
interrupt/resume, checkpoint replay, or Trajectory sub-calls), and the registry (up to 24
|
|
54
|
+
ids and descriptions; input schemas stay out of the prompt). The model therefore knows
|
|
55
|
+
what exists without spending a discovery call; `langgraph_run` with no `graph` still
|
|
56
|
+
returns the full list and input schemas.
|
|
57
|
+
|
|
58
|
+
- The section sits just before the subagent guidance, after the `workflow` tool's
|
|
59
|
+
"only when the user asks" rule. An earlier placement at `TOOL_WORKFLOW` made the two
|
|
60
|
+
"workflow" instructions read as one.
|
|
61
|
+
- The section also says that `langgraph_run` only runs registered graphs and cannot
|
|
62
|
+
define one: one-off or still-unclear work stays on ordinary DSH tools (or `workflow`
|
|
63
|
+
for an ad-hoc fan-out), and a reusable shape belongs in a profile graph module. It
|
|
64
|
+
gives no concrete examples for that choice, so the model composes the shape instead
|
|
65
|
+
of copying one.
|
|
66
|
+
- Apart from the section and the two tool schemas, the plugin injects no runtime context;
|
|
67
|
+
per-session thread facts are read on demand with `langgraph_threads`. See
|
|
68
|
+
[CONTEXT.md](CONTEXT.md) for the mapping and the maintenance rules.
|
|
55
69
|
|
|
56
70
|
- The registry is scanned when the plugin activates, so graph modules should keep top-level
|
|
57
71
|
code side-effect free.
|
|
@@ -299,8 +313,8 @@ const ship = answers.find(answer => answer.id === 'ship')
|
|
|
299
313
|
## Writing a graph (TypeScript or JavaScript)
|
|
300
314
|
|
|
301
315
|
```ts
|
|
302
|
-
export const id = 'my-
|
|
303
|
-
export const description = 'One line the agent sees when it lists
|
|
316
|
+
export const id = 'my-graph'
|
|
317
|
+
export const description = 'One line the agent sees when it lists graphs.'
|
|
304
318
|
export const input = {
|
|
305
319
|
type: 'object',
|
|
306
320
|
properties: { pattern: { type: 'string', description: 'Glob to scan.' } },
|
package/graphs/approval-gate.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Example
|
|
2
|
+
* Example graph that pauses for a decision before doing any work.
|
|
3
3
|
*
|
|
4
4
|
* The gate node calls LangGraph's `interrupt(...)`: the run stops, the agent sees
|
|
5
5
|
* `status: "interrupted"` with the question, and `langgraph_run({ graph, thread,
|
package/graphs/ask-tools.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Example ReAct
|
|
2
|
+
* Example ReAct graph: LangGraph's prebuilt agent driving DSH tools with this
|
|
3
3
|
* deployment's model.
|
|
4
4
|
*
|
|
5
5
|
* This is the "LangGraph in DSH" case end to end: the graph is LangGraph's own
|
package/graphs/ask-workspace.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Example
|
|
2
|
+
* Example graph that mixes DSH tool calls with a model call inside one graph.
|
|
3
3
|
*
|
|
4
4
|
* `scan` reads the workspace through the DSH `glob` tool; `answer` asks the
|
|
5
5
|
* deployment's model to explain the result. The graph owns the control flow, DSH
|
package/graphs/scan-report.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Example LangGraph
|
|
2
|
+
* Example LangGraph graph shipped with the plugin.
|
|
3
3
|
*
|
|
4
4
|
* It demonstrates the two things this plugin adds to LangGraph inside DSH:
|
|
5
5
|
* - a graph is registered by id and run from the agent's `langgraph_run` tool;
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* LangGraph
|
|
2
|
+
* LangGraph graphs as DSH tools, with durable threads.
|
|
3
3
|
*
|
|
4
4
|
* A graph module exports `id`, an optional `description`, an optional `input` JSON
|
|
5
5
|
* Schema for its initial state, and `build(api)` where `api` carries the LangGraph API
|
|
@@ -134,15 +134,16 @@ function describeInput(entry) {
|
|
|
134
134
|
* @returns {string} section text.
|
|
135
135
|
*/
|
|
136
136
|
export function renderGraphPrompt(registry, ready) {
|
|
137
|
-
const intro = 'LangGraph
|
|
137
|
+
const intro = 'LangGraph graphs are profile-registered, named graphs run by `langgraph_run`. '
|
|
138
|
+
+ 'They are not the `workflow` tool (`workflow` runs an ad-hoc JavaScript fan-out script).'
|
|
138
139
|
if (!ready) {
|
|
139
|
-
return `${intro} Call it with no \`graph\` to list the registered
|
|
140
|
+
return `${intro} Call it with no \`graph\` to list the registered graphs and their input schemas.`
|
|
140
141
|
}
|
|
141
142
|
const available = [...registry.values()]
|
|
142
143
|
.filter(entry => entry.error === undefined)
|
|
143
144
|
.sort((left, right) => left.id.localeCompare(right.id))
|
|
144
145
|
if (available.length === 0) {
|
|
145
|
-
return `${intro}\n\nNo
|
|
146
|
+
return `${intro}\n\nNo graph is registered yet; call it with no \`graph\` to re-check.`
|
|
146
147
|
}
|
|
147
148
|
const limit = 24
|
|
148
149
|
const lines = available.slice(0, limit).map(entry => {
|
|
@@ -154,11 +155,22 @@ export function renderGraphPrompt(registry, ready) {
|
|
|
154
155
|
}
|
|
155
156
|
return [
|
|
156
157
|
intro,
|
|
157
|
-
'Use
|
|
158
|
-
+ '
|
|
159
|
-
+ '
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
'Use `langgraph_run` when:\n'
|
|
159
|
+
+ '- the user names one of the graph ids below;\n'
|
|
160
|
+
+ '- a registered graph\'s description matches the requested output; use that graph instead of '
|
|
161
|
+
+ 'hand-rolling its steps with bash, subagent, or ad-hoc calls;\n'
|
|
162
|
+
+ '- the task needs a durable LangGraph thread, a background run (a DSH job), checkpoint '
|
|
163
|
+
+ 'history or replay, a Trajectory sub-call record, or the graph description says it interrupts.',
|
|
164
|
+
'When no graph\'s output matches, use ordinary DSH tools; do not wrap a single tool call in a graph '
|
|
165
|
+
+ 'just for ceremony, and do not use the `workflow` tool as a substitute for a named graph.',
|
|
166
|
+
'`langgraph_run` only runs graphs already registered with this profile; it cannot define a new one, '
|
|
167
|
+
+ 'so do not invent an id. For one-off or still-unclear work, compose ordinary DSH tools (or use '
|
|
168
|
+
+ '`workflow` for an ad-hoc fan-out). A shape worth reusing belongs in a profile graph module, '
|
|
169
|
+
+ 'which then appears in this list.',
|
|
170
|
+
'A LangGraph thread is a durable checkpoint chain for one graph run, not a DSH Session. '
|
|
171
|
+
+ 'Use `langgraph_threads` to list, inspect, time-travel, or delete threads, or read a graph\'s topology.',
|
|
172
|
+
`Registered graphs:\n${lines.join('\n')}`,
|
|
173
|
+
'Omit `graph` to list input schemas.',
|
|
162
174
|
].join('\n\n')
|
|
163
175
|
}
|
|
164
176
|
|
|
@@ -677,7 +689,7 @@ export function apply(ctx, config) {
|
|
|
677
689
|
// --- tools --------------------------------------------------------------------
|
|
678
690
|
async function describeGraphs() {
|
|
679
691
|
await scan()
|
|
680
|
-
if (registry.size === 0) return 'No LangGraph
|
|
692
|
+
if (registry.size === 0) return 'No LangGraph graph is registered.'
|
|
681
693
|
const lines = [...registry.values()]
|
|
682
694
|
.sort((left, right) => left.id.localeCompare(right.id))
|
|
683
695
|
.map(entry => {
|
|
@@ -1165,39 +1177,43 @@ export function apply(ctx, config) {
|
|
|
1165
1177
|
void scan().then(() => { scannedReady = true }).catch(error => {
|
|
1166
1178
|
ctx.logger?.warn(`langgraph: graph scan failed: ${error?.message ?? error}`)
|
|
1167
1179
|
})
|
|
1168
|
-
|
|
1180
|
+
// Sit after the `workflow` tool's "only when the user asks" rule and just
|
|
1181
|
+
// before subagent guidance. The old TOOL_WORKFLOW slot put this section
|
|
1182
|
+
// next to a second "workflow" rule, which read as one instruction.
|
|
1183
|
+
let order = 2790
|
|
1169
1184
|
try {
|
|
1170
1185
|
if (typeof systemPrompt.getSectionOrder === 'function') {
|
|
1171
|
-
order = systemPrompt.getSectionOrder('
|
|
1186
|
+
order = systemPrompt.getSectionOrder('TOOL_SUBAGENT') - 10
|
|
1172
1187
|
}
|
|
1173
1188
|
} catch {
|
|
1174
|
-
// A future DSH may rename the order;
|
|
1189
|
+
// A future DSH may rename the order; 2790 is just before subagents.
|
|
1175
1190
|
}
|
|
1176
1191
|
ctx.effect(() => systemPrompt.section({
|
|
1177
1192
|
name: 'tool:langgraph',
|
|
1178
1193
|
order,
|
|
1179
1194
|
text: () => renderGraphPrompt(registry, scannedReady),
|
|
1180
|
-
retirement: 'The langgraph_run
|
|
1195
|
+
retirement: 'The langgraph_run graph guidance no longer applies.',
|
|
1181
1196
|
}), 'langgraph: prompt section')
|
|
1182
1197
|
}
|
|
1183
1198
|
}
|
|
1184
1199
|
|
|
1185
1200
|
ctx.effect(() => ctx.tools.register({
|
|
1186
1201
|
name: RUN_TOOL,
|
|
1187
|
-
description: 'Run
|
|
1188
|
-
+ '
|
|
1189
|
-
+ '
|
|
1190
|
-
+ '
|
|
1191
|
-
+ '
|
|
1202
|
+
description: 'Run one registered LangGraph graph by id. Use it when the user names a graph, a graph\'s '
|
|
1203
|
+
+ 'description matches the requested output, or the task needs a durable thread, background job, '
|
|
1204
|
+
+ 'checkpoint replay, or Trajectory record; it is not the `workflow` tool. Omit `graph` to list graphs '
|
|
1205
|
+
+ 'and input schemas. Threads are durable LangGraph checkpoint chains (not DSH Sessions): pass `thread` '
|
|
1206
|
+
+ 'to continue one, `resume` to answer an interrupt, and `checkpoint` to replay a snapshot from '
|
|
1207
|
+
+ '`langgraph_threads` history. `run_in_background` returns a DSH job id for `job_output`/`job_kill`.',
|
|
1192
1208
|
parameters: {
|
|
1193
1209
|
type: 'object',
|
|
1194
1210
|
properties: {
|
|
1195
|
-
graph: { type: 'string', description: '
|
|
1211
|
+
graph: { type: 'string', description: 'Registered graph id; omit to list graphs and input schemas.' },
|
|
1196
1212
|
input: { type: 'object', description: 'Initial graph state, as a JSON object.', additionalProperties: true },
|
|
1197
|
-
thread: { type: 'string', description: '
|
|
1213
|
+
thread: { type: 'string', description: 'LangGraph thread to continue; omit to start a new durable thread. Not a DSH Session id.' },
|
|
1198
1214
|
checkpoint: {
|
|
1199
1215
|
type: 'string',
|
|
1200
|
-
description: 'Checkpoint id to replay from
|
|
1216
|
+
description: 'Checkpoint id to replay from (langgraph_threads action "history"); requires `thread`.',
|
|
1201
1217
|
},
|
|
1202
1218
|
resume: { description: 'Value handed to an interrupted graph, resuming it where it stopped.' },
|
|
1203
1219
|
maxSteps: { type: 'integer', description: 'Upper bound on graph supersteps for this run.' },
|
|
@@ -1224,16 +1240,16 @@ export function apply(ctx, config) {
|
|
|
1224
1240
|
|
|
1225
1241
|
ctx.effect(() => ctx.tools.register({
|
|
1226
1242
|
name: THREADS_TOOL,
|
|
1227
|
-
description: '
|
|
1228
|
-
+ '
|
|
1229
|
-
+ '`
|
|
1230
|
-
+ 'langgraph_run({ checkpoint })
|
|
1243
|
+
description: 'Manage durable LangGraph threads and a graph\'s topology. `list` (this session by default), '
|
|
1244
|
+
+ '`state` (values, next, interrupts), `history` (checkpoint ids), `edit` (fork a checkpoint with new '
|
|
1245
|
+
+ 'values), `topology` (nodes/edges), or `delete`. A thread is a LangGraph checkpoint chain, not a '
|
|
1246
|
+
+ 'DSH Session. Replay an edit with `langgraph_run({ checkpoint })`.',
|
|
1231
1247
|
parameters: {
|
|
1232
1248
|
type: 'object',
|
|
1233
1249
|
properties: {
|
|
1234
1250
|
action: { type: 'string', enum: ['list', 'state', 'history', 'edit', 'topology', 'delete'], description: 'Defaults to list.' },
|
|
1235
|
-
graph: { type: 'string', description: 'Graph id; required by state, history, and
|
|
1236
|
-
thread: { type: 'string', description: '
|
|
1251
|
+
graph: { type: 'string', description: 'Graph id; required by state, history, edit, and topology.' },
|
|
1252
|
+
thread: { type: 'string', description: 'LangGraph thread id; required by state, history, edit, and delete. Not a DSH Session id.' },
|
|
1237
1253
|
checkpoint: { type: 'string', description: 'Checkpoint id for state, edit, or replay; defaults to the thread head.' },
|
|
1238
1254
|
values: { type: 'object', description: 'State fields to write in an edit, as a JSON object.', additionalProperties: true },
|
|
1239
1255
|
asNode: { type: 'string', description: 'Attribute an edit to this node, when the graph needs one.' },
|
package/lib/client.js
CHANGED
|
@@ -206,9 +206,9 @@ window.__ModuleLoader__.load({
|
|
|
206
206
|
return () => { live = false; };
|
|
207
207
|
}, [selected]);
|
|
208
208
|
const selectedGraph = ui?.graphs.find(graph => graph.id === selected);
|
|
209
|
-
return ((0, jsx_runtime_1.jsxs)("section", { className: "lg-panel", "aria-label": "LangGraph
|
|
210
|
-
? 'Loading
|
|
211
|
-
: `${ui.graphs.length}
|
|
209
|
+
return ((0, jsx_runtime_1.jsxs)("section", { className: "lg-panel", "aria-label": "LangGraph graphs", children: [(0, jsx_runtime_1.jsxs)("header", { className: "lg-header", children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h2", { className: "lg-title", children: "LangGraph" }), (0, jsx_runtime_1.jsx)("p", { className: "lg-muted", children: ui === undefined
|
|
210
|
+
? 'Loading graphs…'
|
|
211
|
+
: `${ui.graphs.length} graph${ui.graphs.length === 1 ? '' : 's'} · ${ui.threads.total} durable thread${ui.threads.total === 1 ? '' : 's'}` })] }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "lg-button", onClick: () => { void refresh(); }, children: "Refresh" })] }), uiError !== undefined && (0, jsx_runtime_1.jsx)("p", { className: "lg-error", children: uiError }), (0, jsx_runtime_1.jsxs)("div", { className: "lg-grid", children: [(0, jsx_runtime_1.jsxs)("nav", { className: "lg-list", "aria-label": "Registered graphs", children: [(ui?.graphs ?? []).map(graph => ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: graph.id === selected ? 'lg-item lg-item-active' : 'lg-item', onClick: () => setSelected(graph.id), children: [(0, jsx_runtime_1.jsx)("span", { className: "lg-item-id", children: graph.id }), (0, jsx_runtime_1.jsx)("span", { className: "lg-item-meta", children: graph.error ?? `${ui?.threads.byGraph[graph.id] ?? 0} thread${(ui?.threads.byGraph[graph.id] ?? 0) === 1 ? '' : 's'}` }), graph.error === undefined && graph.description !== undefined && ((0, jsx_runtime_1.jsx)("span", { className: "lg-item-desc", children: graph.description }))] }, graph.id))), ui !== undefined && ui.graphs.length === 0 && (0, jsx_runtime_1.jsx)("p", { className: "lg-muted", children: "No graphs registered." })] }), (0, jsx_runtime_1.jsxs)("div", { className: "lg-canvas", children: [topologyError !== undefined && (0, jsx_runtime_1.jsx)("p", { className: "lg-error", children: topologyError }), busy && (0, jsx_runtime_1.jsx)("p", { className: "lg-muted", children: "Loading topology\u2026" }), !busy && topology !== undefined && (0, jsx_runtime_1.jsx)(TopologyView, { topology: topology }), !busy && topology === undefined && topologyError === undefined && ((0, jsx_runtime_1.jsx)("p", { className: "lg-muted", children: "Select a graph to see its nodes and edges." }))] })] }), (0, jsx_runtime_1.jsx)("footer", { className: "lg-footer", children: selectedGraph?.description ?? 'Runs appear as langgraph_run rows in Trajectory.' })] }));
|
|
212
212
|
}
|
|
213
213
|
/** Sidebar launcher icon: one node feeding two others. */
|
|
214
214
|
function LangGraphIcon() {
|
package/locale/en.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
|
-
"title": "LangGraph
|
|
4
|
-
"description": "Registers LangGraph graphs as durable
|
|
3
|
+
"title": "LangGraph graphs",
|
|
4
|
+
"description": "Registers LangGraph graphs as durable DSH tools an agent runs with the langgraph_run tool. Registered graphs are listed in the system prompt, nodes call this session's own tools in its sandbox, can ask the user through the native question UI, run as background jobs or delegate to DSH subagents, every node/tool/model call is traced in Trajectory, threads and long-term memory survive restarts, an interrupted graph resumes where it stopped, and a Web sidebar panel lists the graphs and draws their topology.",
|
|
5
5
|
"detail": "docs/DETAIL.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
|
-
"title": "LangGraph
|
|
4
|
-
"description": "把 LangGraph
|
|
3
|
+
"title": "LangGraph 图",
|
|
4
|
+
"description": "把 LangGraph 图注册成可持久化的 DSH 工具,agent 通过 langgraph_run 工具运行。已注册的图会列在 system prompt 里,图里的节点调用本会话自己的工具、在同一个沙箱执行,可通过原生提问 UI 询问用户,可后台运行,也可派发 DSH 子 agent;节点/工具/模型动作在 Trajectory 里逐层可见;线程和长期记忆跨重启保留,被 interrupt 暂停的图可以从原处继续;Web 侧边栏面板会列出图并绘制拓扑。",
|
|
5
5
|
"detail": "docs/DETAIL.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lzn1998/dsh-langgraph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Durable LangGraph
|
|
5
|
+
"description": "Durable LangGraph graphs as DSH tools: register TS/JS graphs, advertise them in the system prompt, run, resume and time-travel them, give them durable long-term memory, ask the user in the native question UI, run them as background jobs, delegate to DSH subagents, trace every node/tool/model call in Trajectory, draw their topology in a Web panel, and let graph nodes call this session's own tools.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/lznnnnn1998/DSH-LangGraph.git"
|