@lzn1998/dsh-langgraph 1.0.1 → 1.6.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/README.md +172 -51
- package/bench/README.md +54 -0
- package/bench/demo-video.mjs +208 -0
- package/bench/results-harness.json +125 -0
- package/bench/run.mjs +139 -0
- package/compose/analysis.js +359 -0
- package/compose/build.js +274 -0
- package/compose/constants.js +83 -0
- package/compose/guard.js +72 -0
- package/compose/nodes.js +214 -0
- package/compose/resolve.js +97 -0
- package/compose/schema.js +975 -0
- package/compose/specs.js +218 -0
- package/compose/template.js +260 -0
- package/compose/tool.js +713 -0
- package/docs/BENCHMARK.md +116 -0
- package/docs/COMPOSE.md +376 -0
- package/docs/CONTEXT.md +34 -18
- package/docs/DETAIL.md +48 -1
- package/docs/ECOSYSTEM.md +30 -5
- package/gallery/README.md +69 -0
- package/gallery/assets/gallery.png +0 -0
- package/gallery/assets/session.png +0 -0
- package/gallery/index.html +516 -0
- package/gallery/specs/approval-plan.lg.json +51 -0
- package/gallery/specs/data-extract.lg.json +75 -0
- package/gallery/specs/incident-triage.lg.json +64 -0
- package/gallery/specs/pr-review.lg.json +49 -0
- package/gallery/specs/repo-scan.lg.json +54 -0
- package/gallery/specs/research-brief.lg.json +94 -0
- package/index.d.ts +136 -0
- package/index.js +423 -46
- package/media/dsh-langgraph-demo.webm +0 -0
- package/media/raw/page@0d0adc4d6eb7b946d722093988db7e67.webm +0 -0
- package/media/raw/page@0fceaacbda6d8f2da8485736c565ed87.webm +0 -0
- package/media/raw/page@49c6bb9135c0c35ed8cf9054a8e05711.webm +0 -0
- package/media/raw/page@86f5e37e1c1218697f8724a6bafda8d2.webm +0 -0
- package/media/raw/page@9b5b70b442c0ace7d4b135fc80edba73.webm +0 -0
- package/media/raw/page@beb9164240f13ad017c3fa7e8f20a772.webm +0 -0
- package/media/raw/page@db4ee1834adcc9e8d5b4708eabe4eb5c.webm +0 -0
- package/media/raw/page@e9c63a0029d3181e41506fc4bf8da05a.webm +0 -0
- package/media/raw/page@eaf729b06925fe86e9e9e4bf48e2cdcc.webm +0 -0
- package/media/raw/page@f0d6fd1a2534e69bc2f228b30ae19a9c.webm +0 -0
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -1,55 +1,176 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="icon.svg" alt="dsh-langgraph" width="96">
|
|
3
|
+
|
|
1
4
|
# dsh-langgraph
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
**Durable, inspectable workflows for DSH.**
|
|
7
|
+
|
|
8
|
+
Pause for approval. Survive a restart. Fan out over unknown files. See the graph.
|
|
9
|
+
No arbitrary model-written JavaScript.
|
|
10
|
+
|
|
11
|
+
[](https://www.npmjs.com/package/@lzn1998/dsh-langgraph)
|
|
12
|
+
[](LICENSE)
|
|
13
|
+
[](#reference)
|
|
14
|
+
[](docs/DETAIL.md)
|
|
15
|
+
[](docs/ECOSYSTEM.md)
|
|
16
|
+
|
|
17
|
+
[Gallery](gallery/index.html) · [57s real-session demo](media/dsh-langgraph-demo.webm) · [Benchmark](docs/BENCHMARK.md) · [Contract](docs/COMPOSE.md) · [npm](https://www.npmjs.com/package/@lzn1998/dsh-langgraph)
|
|
18
|
+
|
|
19
|
+
<a href="https://github.com/lznnnnn1998/DSH-LangGraph/blob/main/media/dsh-langgraph-demo.webm"><img src="gallery/assets/session.png" alt="A real DSH session: a 12-topic brief, a human gate, and a 12-row output" width="860"></a>
|
|
20
|
+
|
|
21
|
+
<sub>A real DSH Web session, not a mock: 12 files → two 12-item maps → outline → human gate → write. 55s, 12 rows, 226K reported tokens.</sub>
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## The shape
|
|
27
|
+
|
|
28
|
+
A composed graph is a contract about seams. The **state** is the ledger that survives a
|
|
29
|
+
seam; a **node** is a role that files one result; an **edge** is a handoff; a **map** is one
|
|
30
|
+
role repeated over a list; a **gate** is a human signature; a **transform** is the form a
|
|
31
|
+
result takes when filed. The compiler is a clerk: JSON in, a LangGraph out, with no model
|
|
32
|
+
in the translation.
|
|
33
|
+
|
|
34
|
+
The ordinary loop remains the default. Reach for a graph only when the work has a real
|
|
35
|
+
seam: a fan-out you cannot enumerate, a human decision, or a pause that must survive a
|
|
36
|
+
restart. The [benchmark](docs/BENCHMARK.md) is deliberately honest about the tax.
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
dsh plugin --profile <name> add @lzn1998/dsh-langgraph
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Restart that profile's host. From a local checkout, use
|
|
45
|
+
`dsh plugin --profile <name> add /path/to/dsh-langgraph`. Composed graphs need no restart;
|
|
46
|
+
the JSON spec is data.
|
|
47
|
+
|
|
48
|
+
## 60-second quickstart
|
|
49
|
+
|
|
50
|
+
In a DSH session:
|
|
51
|
+
|
|
52
|
+
> Read the 12 files under `topics/`, extract one Topic/Claim/Risk row per file, show me the
|
|
53
|
+
> outline, and wait for my approval before writing `brief.md`.
|
|
54
|
+
|
|
55
|
+
The model can register a graph from the profile, or compose one on demand with
|
|
56
|
+
`langgraph_compose`. Either way the run is a **durable thread**: the gate returns
|
|
57
|
+
`status: "interrupted"`, the human approves, and the same thread resumes. See the
|
|
58
|
+
[gallery](gallery/index.html) for six copyable specs and the [video](media/dsh-langgraph-demo.webm).
|
|
59
|
+
|
|
60
|
+
## What you get
|
|
61
|
+
|
|
62
|
+
- **A durable thread.** Threads are checkpointed in a DSH storage domain; a run survives a
|
|
63
|
+
turn and a Host restart. Resume with `thread`, replay from a checkpoint, edit a state and
|
|
64
|
+
replay, or run in a DSH background job.
|
|
65
|
+
- **A human signature.** `gate` pauses with a question and options; `ask_user_question` is
|
|
66
|
+
available inside graph nodes. The answer goes through `out`; `options` are labels, not
|
|
67
|
+
values.
|
|
68
|
+
- **Real fan-out.** `map` sends one body per item, reads `item`/`index`, appends in input
|
|
69
|
+
order, handles the empty list with a sentinel, and caps items/concurrency. The 12-topic
|
|
70
|
+
demo is two maps and a gate.
|
|
71
|
+
- **A graph you can see.** Every run is one `langgraph_run` row in **Trajectory**, with
|
|
72
|
+
graph nodes, DSH tool calls, model calls and subagents nested underneath. A Web profile
|
|
73
|
+
gets a **LangGraph** sidebar panel for registered graphs, thread counts and topology.
|
|
74
|
+
- **A model-authored contract.** `langgraph_compose` stores an immutable, session-owned
|
|
75
|
+
JSON `GraphSpec` (`lg_adhoc_…`) and runs it with the same threads, interrupts, jobs,
|
|
76
|
+
traces and time travel. The model writes data, never arbitrary JS.
|
|
77
|
+
- **Failure is data.** A failed run returns `failedNode`, `failedScc`, `upstream`,
|
|
78
|
+
`downstream`, `pending`, bounded `lastSupersteps`, `error.itemIndex`, `state` and a
|
|
79
|
+
hint. Resume a transient, edit/replay a state error, or `fork` the downstream and
|
|
80
|
+
compose a new graph.
|
|
81
|
+
- **DSH-native, not a parallel world.** Graph nodes call the session's own tools through
|
|
82
|
+
`helpers.callTool`; helpers cover `askUser`, `callModel`, `subagent`, `chatModel`,
|
|
83
|
+
`tools([...])` and `createReactAgent`. LangGraph's `BaseStore` runs over a DSH storage
|
|
84
|
+
domain. No DSH or LangGraph source changes.
|
|
85
|
+
|
|
86
|
+
## Gallery
|
|
87
|
+
|
|
88
|
+
Six small graphs, each earning its keep at a seam — no node catalogue:
|
|
89
|
+
|
|
90
|
+
| Graph | The seam | Gate |
|
|
91
|
+
|---|---|:---:|
|
|
92
|
+
| [Research brief](gallery/specs/research-brief.lg.json) | two maps, extract per file, approve an outline, write | yes |
|
|
93
|
+
| [Repo scan](gallery/specs/repo-scan.lg.json) | read source files in parallel, synthesize one review | no |
|
|
94
|
+
| [PR review](gallery/specs/pr-review.lg.json) | read the diff, draft, ask before posting | yes |
|
|
95
|
+
| [Incident triage](gallery/specs/incident-triage.lg.json) | read logs, classify, ask whether to page | yes |
|
|
96
|
+
| [Data extract](gallery/specs/data-extract.lg.json) | one JSON record per file, one JSON array | no |
|
|
97
|
+
| [Approval plan](gallery/specs/approval-plan.lg.json) | plan with tools, approve, execute, write | yes |
|
|
98
|
+
|
|
99
|
+
Open [`gallery/index.html`](gallery/index.html) for the visual gallery, copy a prompt, or
|
|
100
|
+
load a spec with `langgraph_compose({ action: "compose", path: "gallery/specs/…" })`.
|
|
101
|
+
The gallery is JSON-only; a pull request with a new spec and a validated output is welcome.
|
|
102
|
+
|
|
103
|
+
## When not to use a graph
|
|
104
|
+
|
|
105
|
+
Do not start with a graph for a one- or two-step task, a single tool call, or a task a
|
|
106
|
+
registered graph already matches. On the 12-topic brief the ordinary loop was
|
|
107
|
+
**53s / 124K**; the fine map graph was **55s / 226K**; the coarse agent graph was
|
|
108
|
+
**1m38s / 462K**. The graph is a seam tax, not a token discount. The
|
|
109
|
+
[benchmark report](docs/BENCHMARK.md) has the full method, numbers and caveats.
|
|
110
|
+
|
|
111
|
+
## How the model is taught
|
|
112
|
+
|
|
113
|
+
`langgraph_compose({ action: "describe" })` returns four things, on demand:
|
|
114
|
+
|
|
115
|
+
1. a prose **guide** — the contract, ledger, seams, roles and forms (built to be read as a
|
|
116
|
+
mentor);
|
|
117
|
+
2. a numbered **law** — MUST/MUST NOT rules for state, nodes, edges, maps, gates, failures
|
|
118
|
+
and limits;
|
|
119
|
+
3. a vocabulary **reference**;
|
|
120
|
+
4. **archetype examples** — `map-gate-write`, `map-extract`, and more.
|
|
121
|
+
|
|
122
|
+
The compiler is deterministic; no model translates the IR. `validate`/`compose` check tool
|
|
123
|
+
visibility and the visible tool's own argument schema, so a wrong `read` argument is caught
|
|
124
|
+
before a run, not inside a map. The model can reason from the contract instead of reading
|
|
125
|
+
the plugin source.
|
|
126
|
+
|
|
127
|
+
## Reference
|
|
8
128
|
|
|
9
129
|
- `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
|
-
|
|
12
|
-
- `langgraph_threads` (`action`: `list` | `state` | `history` | `edit` | `topology` |
|
|
13
|
-
`history` lists checkpoints
|
|
14
|
-
|
|
15
|
-
`
|
|
16
|
-
- Registry: `graphs/*.js` (and `graphs/*.ts` on Node 24.22+)
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
`
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
130
|
+
omit `graph` to list). A background run returns a DSH job id; read it with `job_output`,
|
|
131
|
+
stop it with `job_kill`.
|
|
132
|
+
- `langgraph_threads` (`action`: `list` | `state` | `history` | `edit` | `topology` |
|
|
133
|
+
`delete`). `history` lists checkpoints; `edit` forks a checkpoint with new values.
|
|
134
|
+
- `langgraph_compose` (`action`: `describe` | `validate` | `compose` | `list` | `get` |
|
|
135
|
+
`delete` | `fork`). Specs are content-addressed, session-owned, immutable and capped.
|
|
136
|
+
- Registry: `graphs/*.js` (and `graphs/*.ts` on Node 24.22+) plus `config.graphs`.
|
|
137
|
+
- Helpers: `callTool`, `askUser`, `subagent`, `callModel`, `chatModel`, `tools`, `createReactAgent`, `store`.
|
|
138
|
+
- Long-term memory: a real LangGraph `BaseStore` over `langgraph_store`; get/put/delete,
|
|
139
|
+
filtered pagination, namespace listing; vector `query` is rejected rather than faked.
|
|
140
|
+
- Trace: `langgraph:node`, `langgraph:tool`, `langgraph:model`, `langgraph:subagent` under
|
|
141
|
+
one `langgraph_run` row; log-only events, never model context.
|
|
142
|
+
- Web panel: registered graphs, thread counts, topology; owner-only routes;
|
|
143
|
+
`config.ui: false` disables it.
|
|
144
|
+
- Threads are owned by the session and graph that created them; retention defaults to 200
|
|
145
|
+
checkpoints (`0` keeps all) and writes are pruned alongside.
|
|
146
|
+
- Limits: 64 nodes, 128 edges, 64 state fields, 256 KiB spec, `maxSteps` 1–200 (default
|
|
147
|
+
25), map items 1–100 (default 50), map concurrency 1–16 (default 8), 64 specs/session.
|
|
148
|
+
|
|
149
|
+
Read the [compose contract](docs/COMPOSE.md), the [runtime detail](docs/DETAIL.md), the
|
|
150
|
+
[context boundary](docs/CONTEXT.md), and the [LangChain ecosystem bridges](docs/ECOSYSTEM.md).
|
|
151
|
+
|
|
152
|
+
## Trust boundary
|
|
153
|
+
|
|
154
|
+
The model may compose a graph, but it cannot ship JavaScript. A spec is JSON data:
|
|
155
|
+
session-owned, immutable, tool-visible, path-confined and argument-checked. Irreversible
|
|
156
|
+
steps belong behind a gate. This is the same DSH sandbox, approval scope and storage; the
|
|
157
|
+
plugin adds no privileged execution path.
|
|
158
|
+
|
|
159
|
+
## Compatibility and tests
|
|
160
|
+
|
|
161
|
+
DSH 0.2.x, LangGraph 1.7.x, Node 24.9+. The local suite has **166 tests** (`npm test`)
|
|
162
|
+
and a `tsc --noEmit --skipLibCheck` check; the benchmark harness is in
|
|
163
|
+
[`bench/run.mjs`](bench/run.mjs). The **1.6.0** release is on npm, and the gallery,
|
|
164
|
+
benchmark report and 57s demo ship with it. The runtime is unchanged from 1.5.0; 1.6.0
|
|
165
|
+
adds the examples, benchmark and documentation.
|
|
166
|
+
|
|
167
|
+
## Community
|
|
168
|
+
|
|
169
|
+
This is a small, open plugin built in the open. If it saves you a restart or an approval
|
|
170
|
+
mistake, a star helps other DSH users find it. Share a graph on the gallery with a JSON
|
|
171
|
+
spec and a validated output; open an issue with a trace or a failing spec. The goal is a
|
|
172
|
+
useful default for durable DSH workflows, not a node catalogue.
|
|
173
|
+
|
|
174
|
+
## License
|
|
175
|
+
|
|
176
|
+
MIT. See [LICENSE](LICENSE).
|
package/bench/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# benchmark harness
|
|
2
|
+
|
|
3
|
+
A small, one-run-per-cell harness for the report in [`../docs/BENCHMARK.md`](../docs/BENCHMARK.md).
|
|
4
|
+
It compares the stock DSH ordinary loop with the plugin's ordinary loop and forced graphs on
|
|
5
|
+
two deterministic tasks.
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
- A DSH checkout at `DSH_ROOT` (default `/Users/zhinan/deepseek-harness`).
|
|
10
|
+
- The stock `headless` profile (no plugin) and the `lgh` profile with this plugin linked.
|
|
11
|
+
- A configured DeepSeek route; the same model for every arm.
|
|
12
|
+
- The tasks write under `$DSH_ROOT/.lg-bench/work` so DSH's workspace-write policy allows them.
|
|
13
|
+
|
|
14
|
+
## Run
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
# all six comparable headless cells (official / plain / default × two tasks)
|
|
18
|
+
DSH_ROOT=/Users/zhinan/deepseek-harness node bench/run.mjs
|
|
19
|
+
|
|
20
|
+
# one cell
|
|
21
|
+
DSH_ROOT=/Users/zhinan/deepseek-harness node bench/run.mjs fanout official
|
|
22
|
+
DSH_ROOT=/Users/zhinan/deepseek-harness node bench/run.mjs report plain
|
|
23
|
+
|
|
24
|
+
# forced graph cells (the task text asks for a graph)
|
|
25
|
+
DSH_ROOT=/Users/zhinan/deepseek-harness node bench/run.mjs fanout coarse
|
|
26
|
+
DSH_ROOT=/Users/zhinan/deepseek-harness node bench/run.mjs fanout fine
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Conditions:
|
|
30
|
+
|
|
31
|
+
| Condition | Profile | What it does |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| `official` | `headless` | stock DSH, ordinary tools, no plugin |
|
|
34
|
+
| `plain` | `lgh` | plugin installed, but the task says ordinary tools / no graph |
|
|
35
|
+
| `default` | `lgh` | plugin prompt decides; no forced graph |
|
|
36
|
+
| `coarse` | `lgh` | task text asks for a coarse graph (agent nodes) |
|
|
37
|
+
| `fine` | `lgh` | task text asks for a fine graph (tool/model + map) |
|
|
38
|
+
|
|
39
|
+
## Metrics
|
|
40
|
+
|
|
41
|
+
`success` is a deterministic output check (`36` for the fan-out sum; `Beta: Chen` for the
|
|
42
|
+
report). `tokens` is the sum of `step_end` usage reported by DSH; it includes input, output
|
|
43
|
+
and cache reads, so it is comparable between cells but is not a bill. Graph-internal model
|
|
44
|
+
calls may not all appear as DSH `step_end` events; treat the graph arms' token counts as a
|
|
45
|
+
lower bound. `seconds` is wall time including model calls.
|
|
46
|
+
|
|
47
|
+
The 12-topic gate case in the report is Web-only (a headless profile has no answerer); its
|
|
48
|
+
numbers come from the real `lgtest` sessions, not this harness.
|
|
49
|
+
|
|
50
|
+
## Caveats
|
|
51
|
+
|
|
52
|
+
One run per cell; one model; one host; the forced graph arms were recorded before the
|
|
53
|
+
current guide/law and tool-schema validation, and include their failure/recovery costs. The
|
|
54
|
+
report is a directional comparison, not a leaderboard.
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Record a real DSH Web session as a short demo.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* DEMO_URL='http://localhost:3085/?token=…' \
|
|
6
|
+
* node bench/demo-video.mjs
|
|
7
|
+
*
|
|
8
|
+
* The session must already exist and be completed. This script is a recorder,
|
|
9
|
+
* not a model run: it opens the real app, scrolls the transcript, opens the
|
|
10
|
+
* trajectory and the LangGraph panel, and saves a .webm plus two screenshots.
|
|
11
|
+
*/
|
|
12
|
+
import { createRequire } from 'node:module'
|
|
13
|
+
import { mkdir } from 'node:fs/promises'
|
|
14
|
+
import { dirname, resolve } from 'node:path'
|
|
15
|
+
import { fileURLToPath } from 'node:url'
|
|
16
|
+
|
|
17
|
+
const here = dirname(fileURLToPath(import.meta.url))
|
|
18
|
+
const repo = resolve(here, '..')
|
|
19
|
+
const harness = process.env.DSH_HARNESS ?? '/Users/zhinan/deepseek-harness'
|
|
20
|
+
const require = createRequire(`${harness}/apps/web/package.json`)
|
|
21
|
+
const { chromium } = require('playwright')
|
|
22
|
+
|
|
23
|
+
const url = process.env.DEMO_URL
|
|
24
|
+
const sessionTitle = process.env.DEMO_SESSION ?? 'Build 12-topic brief with LangGraph'
|
|
25
|
+
const out = process.env.DEMO_OUT ?? resolve(repo, 'media/dsh-langgraph-demo.webm')
|
|
26
|
+
const sessionShot = process.env.DEMO_SHOT ?? resolve(repo, 'gallery/assets/session.png')
|
|
27
|
+
const galleryShot = resolve(repo, 'gallery/assets/gallery.png')
|
|
28
|
+
const videoDir = resolve(repo, 'media/raw')
|
|
29
|
+
|
|
30
|
+
if (!url) {
|
|
31
|
+
console.error('DEMO_URL is required (the DSH Web token URL)')
|
|
32
|
+
process.exit(2)
|
|
33
|
+
}
|
|
34
|
+
await mkdir(dirname(out), { recursive: true })
|
|
35
|
+
await mkdir(dirname(sessionShot), { recursive: true })
|
|
36
|
+
await mkdir(videoDir, { recursive: true })
|
|
37
|
+
|
|
38
|
+
const browser = await chromium.launch({ channel: 'chrome', headless: true })
|
|
39
|
+
const context = await browser.newContext({
|
|
40
|
+
viewport: { width: 1440, height: 900 },
|
|
41
|
+
recordVideo: { dir: videoDir, size: { width: 1440, height: 900 } },
|
|
42
|
+
})
|
|
43
|
+
const page = await context.newPage()
|
|
44
|
+
page.setDefaultTimeout(5000)
|
|
45
|
+
const video = page.video()
|
|
46
|
+
let scroller = null
|
|
47
|
+
|
|
48
|
+
const wait = ms => page.waitForTimeout(ms)
|
|
49
|
+
const caption = async text => {
|
|
50
|
+
await page.evaluate(value => {
|
|
51
|
+
let node = document.getElementById('__demo_caption')
|
|
52
|
+
if (!node) {
|
|
53
|
+
node = document.createElement('div')
|
|
54
|
+
node.id = '__demo_caption'
|
|
55
|
+
node.style.cssText = [
|
|
56
|
+
'position:fixed', 'left:50%', 'bottom:24px', 'transform:translateX(-50%)',
|
|
57
|
+
'z-index:2147483647', 'pointer-events:none', 'padding:9px 16px',
|
|
58
|
+
'border-radius:999px', 'background:rgba(8,12,20,.86)',
|
|
59
|
+
'border:1px solid rgba(150,175,220,.28)', 'color:#e8edf7',
|
|
60
|
+
'font:12px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace',
|
|
61
|
+
'box-shadow:0 12px 40px rgba(0,0,0,.45)', 'backdrop-filter:blur(12px)',
|
|
62
|
+
'white-space:nowrap', 'letter-spacing:.01em',
|
|
63
|
+
].join(';')
|
|
64
|
+
document.body.append(node)
|
|
65
|
+
}
|
|
66
|
+
node.textContent = value
|
|
67
|
+
}, text)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function scrollTo(fraction) {
|
|
71
|
+
await page.evaluate(value => {
|
|
72
|
+
const el = window.__demoScroller
|
|
73
|
+
if (!el) return
|
|
74
|
+
el.scrollTo({ top: Math.max(0, el.scrollHeight * value - el.clientHeight * 0.5), behavior: 'smooth' })
|
|
75
|
+
}, fraction)
|
|
76
|
+
await wait(1300)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function findScroller() {
|
|
80
|
+
return page.evaluate(() => {
|
|
81
|
+
const candidates = [...document.querySelectorAll('*')]
|
|
82
|
+
.filter(el => el.scrollHeight - el.clientHeight > 200 && el.clientHeight > 300)
|
|
83
|
+
.sort((a, b) => b.scrollHeight - a.scrollHeight)
|
|
84
|
+
if (candidates.length === 0) return null
|
|
85
|
+
const el = candidates[0]
|
|
86
|
+
window.__demoScroller = el
|
|
87
|
+
el.scrollTo({ top: 0 })
|
|
88
|
+
return { tag: el.tagName, cls: String(el.className).slice(0, 80), scrollHeight: el.scrollHeight, clientHeight: el.clientHeight }
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30000 })
|
|
94
|
+
await wait(2600)
|
|
95
|
+
|
|
96
|
+
// The app may open a fresh New Session after a restart. Decide from the
|
|
97
|
+
// session header, not from the whole body: the sidebar can contain the title
|
|
98
|
+
// while the open transcript is still empty.
|
|
99
|
+
const header = page.locator('nav[aria-label="Session hierarchy"], [aria-label="Session hierarchy"]').first()
|
|
100
|
+
const headerText = await header.innerText().catch(() => '')
|
|
101
|
+
if (!headerText.includes(sessionTitle)) {
|
|
102
|
+
// A restart may open a New Session. Open the session tree/search, then
|
|
103
|
+
// click the tree item by title. The search button can be hidden inside the
|
|
104
|
+
// sidebar scroll, so invoke its DOM click rather than a coordinate click.
|
|
105
|
+
await page.evaluate(() => document.querySelector('button[aria-label="Search sessions"]')?.click())
|
|
106
|
+
await wait(900)
|
|
107
|
+
let row = page.getByRole('treeitem').filter({ hasText: sessionTitle }).first()
|
|
108
|
+
if (!(await row.count())) {
|
|
109
|
+
const group = page.getByRole('treeitem', { name: 'Ungrouped', exact: true }).first()
|
|
110
|
+
if (await group.count()) {
|
|
111
|
+
await group.click()
|
|
112
|
+
await wait(900)
|
|
113
|
+
}
|
|
114
|
+
row = page.getByRole('treeitem').filter({ hasText: sessionTitle }).first()
|
|
115
|
+
}
|
|
116
|
+
if (!(await row.count())) row = page.getByText(sessionTitle, { exact: false }).first()
|
|
117
|
+
if (await row.count()) {
|
|
118
|
+
await row.click()
|
|
119
|
+
await wait(1800)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
scroller = await findScroller()
|
|
124
|
+
await caption('A real DSH session · 12 files · a fine map graph · 166 tests')
|
|
125
|
+
await wait(2800)
|
|
126
|
+
|
|
127
|
+
// The prompt and the graph composition.
|
|
128
|
+
await scrollTo(0.08)
|
|
129
|
+
await caption('Read 12 topics, extract one row per file — a map of roles')
|
|
130
|
+
await wait(2600)
|
|
131
|
+
await scrollTo(0.28)
|
|
132
|
+
await caption('Two 12-item maps, then a single outline model')
|
|
133
|
+
await wait(2600)
|
|
134
|
+
|
|
135
|
+
// The outline and the human gate.
|
|
136
|
+
await scrollTo(0.45)
|
|
137
|
+
await caption('The outline arrives; the graph pauses at a human gate')
|
|
138
|
+
await page.screenshot({ path: sessionShot, fullPage: false }).catch(() => {})
|
|
139
|
+
await wait(3000)
|
|
140
|
+
await scrollTo(0.62)
|
|
141
|
+
await caption('The thread is the ledger: approve, and the same run resumes')
|
|
142
|
+
await wait(2600)
|
|
143
|
+
|
|
144
|
+
// The answer and the final brief.
|
|
145
|
+
await scrollTo(0.82)
|
|
146
|
+
await caption('Resume with the raw answer · write_brief settles the file')
|
|
147
|
+
await wait(2600)
|
|
148
|
+
await scrollTo(1)
|
|
149
|
+
await caption('12 correct rows · output on disk')
|
|
150
|
+
await wait(2600)
|
|
151
|
+
|
|
152
|
+
// The trace.
|
|
153
|
+
const trajectory = page.getByRole('tab', { name: 'Trajectory' })
|
|
154
|
+
if (await trajectory.count()) {
|
|
155
|
+
await trajectory.first().click()
|
|
156
|
+
await wait(1200)
|
|
157
|
+
const traceScroller = await findScroller()
|
|
158
|
+
await caption('Trajectory: every node, tool call and model call is visible')
|
|
159
|
+
await wait(2600)
|
|
160
|
+
if (traceScroller) await scrollTo(0.55)
|
|
161
|
+
await wait(1800)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Back to the chat and the final file.
|
|
165
|
+
const chat = page.getByRole('tab', { name: 'Chat' })
|
|
166
|
+
if (await chat.count()) {
|
|
167
|
+
await chat.first().click()
|
|
168
|
+
await wait(900)
|
|
169
|
+
await scrollTo(1)
|
|
170
|
+
}
|
|
171
|
+
const fileButton = page.getByRole('button', { name: 'brief-fine.md' })
|
|
172
|
+
if (await fileButton.count()) {
|
|
173
|
+
await fileButton.first().click()
|
|
174
|
+
await wait(1800)
|
|
175
|
+
await caption('The output is a normal file; the graph was only the seam')
|
|
176
|
+
await wait(2200)
|
|
177
|
+
await page.keyboard.press('Escape').catch(() => {})
|
|
178
|
+
await wait(700)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// The LangGraph panel.
|
|
182
|
+
const panel = page.getByRole('button', { name: 'Open right sidebar' })
|
|
183
|
+
if (await panel.count()) {
|
|
184
|
+
await panel.first().click()
|
|
185
|
+
await wait(1600)
|
|
186
|
+
await caption('The LangGraph panel: registered graphs, threads, topology')
|
|
187
|
+
await wait(2400)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// End card.
|
|
191
|
+
await caption('dsh-langgraph · the graph is a contract, the compiler is a clerk')
|
|
192
|
+
await wait(2200)
|
|
193
|
+
|
|
194
|
+
// Gallery screenshot from the static page (no server needed).
|
|
195
|
+
const gallery = await context.newPage()
|
|
196
|
+
await gallery.goto(`file://${resolve(repo, 'gallery/index.html')}`, { waitUntil: 'load' })
|
|
197
|
+
await gallery.waitForTimeout(1800)
|
|
198
|
+
await gallery.screenshot({ path: galleryShot, fullPage: false }).catch(() => {})
|
|
199
|
+
await gallery.close()
|
|
200
|
+
|
|
201
|
+
await wait(800)
|
|
202
|
+
} finally {
|
|
203
|
+
await page.close().catch(() => {})
|
|
204
|
+
await video.saveAs(out).catch(error => console.error('video save failed:', error.message))
|
|
205
|
+
await context.close().catch(() => {})
|
|
206
|
+
await browser.close().catch(() => {})
|
|
207
|
+
console.log(JSON.stringify({ video: out, sessionShot, galleryShot, scroller }, null, 2))
|
|
208
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"task": "fanout",
|
|
4
|
+
"condition": "official",
|
|
5
|
+
"profile": "headless",
|
|
6
|
+
"success": true,
|
|
7
|
+
"seconds": 16,
|
|
8
|
+
"steps": 5,
|
|
9
|
+
"tokens": {
|
|
10
|
+
"input": 1464,
|
|
11
|
+
"output": 799,
|
|
12
|
+
"total": 72535
|
|
13
|
+
},
|
|
14
|
+
"tools": {
|
|
15
|
+
"read": 8,
|
|
16
|
+
"bash": 2,
|
|
17
|
+
"write": 1
|
|
18
|
+
},
|
|
19
|
+
"result": "36",
|
|
20
|
+
"exit": 0,
|
|
21
|
+
"stderr": "[llm-deepseek-api-key] model listing from https://api.deepseek.com/models loaded 2 model(s), skipped 0 row(s)\n"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"task": "fanout",
|
|
25
|
+
"condition": "plain",
|
|
26
|
+
"profile": "lgh",
|
|
27
|
+
"success": true,
|
|
28
|
+
"seconds": 9,
|
|
29
|
+
"steps": 4,
|
|
30
|
+
"tokens": {
|
|
31
|
+
"input": 1059,
|
|
32
|
+
"output": 785,
|
|
33
|
+
"total": 65204
|
|
34
|
+
},
|
|
35
|
+
"tools": {
|
|
36
|
+
"read": 9,
|
|
37
|
+
"write": 1
|
|
38
|
+
},
|
|
39
|
+
"result": "36",
|
|
40
|
+
"exit": 0,
|
|
41
|
+
"stderr": "[llm-deepseek-api-key] model listing from https://api.deepseek.com/models loaded 2 model(s), skipped 0 row(s)\n"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"task": "fanout",
|
|
45
|
+
"condition": "default",
|
|
46
|
+
"profile": "lgh",
|
|
47
|
+
"success": true,
|
|
48
|
+
"seconds": 9,
|
|
49
|
+
"steps": 4,
|
|
50
|
+
"tokens": {
|
|
51
|
+
"input": 1265,
|
|
52
|
+
"output": 643,
|
|
53
|
+
"total": 63988
|
|
54
|
+
},
|
|
55
|
+
"tools": {
|
|
56
|
+
"bash": 1,
|
|
57
|
+
"read": 8,
|
|
58
|
+
"write": 1
|
|
59
|
+
},
|
|
60
|
+
"result": "36",
|
|
61
|
+
"exit": 0,
|
|
62
|
+
"stderr": "[llm-deepseek-api-key] model listing from https://api.deepseek.com/models loaded 2 model(s), skipped 0 row(s)\n"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"task": "report",
|
|
66
|
+
"condition": "official",
|
|
67
|
+
"profile": "headless",
|
|
68
|
+
"success": true,
|
|
69
|
+
"seconds": 7,
|
|
70
|
+
"steps": 3,
|
|
71
|
+
"tokens": {
|
|
72
|
+
"input": 617,
|
|
73
|
+
"output": 315,
|
|
74
|
+
"total": 41124
|
|
75
|
+
},
|
|
76
|
+
"tools": {
|
|
77
|
+
"read": 3,
|
|
78
|
+
"write": 1
|
|
79
|
+
},
|
|
80
|
+
"result": "Beta: Chen",
|
|
81
|
+
"exit": 0,
|
|
82
|
+
"stderr": "[llm-deepseek-api-key] model listing from https://api.deepseek.com/models loaded 2 model(s), skipped 0 row(s)\n"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"task": "report",
|
|
86
|
+
"condition": "plain",
|
|
87
|
+
"profile": "lgh",
|
|
88
|
+
"success": true,
|
|
89
|
+
"seconds": 9,
|
|
90
|
+
"steps": 4,
|
|
91
|
+
"tokens": {
|
|
92
|
+
"input": 1045,
|
|
93
|
+
"output": 405,
|
|
94
|
+
"total": 63274
|
|
95
|
+
},
|
|
96
|
+
"tools": {
|
|
97
|
+
"read": 4,
|
|
98
|
+
"write": 1
|
|
99
|
+
},
|
|
100
|
+
"result": "Beta: Chen",
|
|
101
|
+
"exit": 0,
|
|
102
|
+
"stderr": "[llm-deepseek-api-key] model listing from https://api.deepseek.com/models loaded 2 model(s), skipped 0 row(s)\n"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"task": "report",
|
|
106
|
+
"condition": "default",
|
|
107
|
+
"profile": "lgh",
|
|
108
|
+
"success": true,
|
|
109
|
+
"seconds": 10,
|
|
110
|
+
"steps": 5,
|
|
111
|
+
"tokens": {
|
|
112
|
+
"input": 1096,
|
|
113
|
+
"output": 491,
|
|
114
|
+
"total": 79667
|
|
115
|
+
},
|
|
116
|
+
"tools": {
|
|
117
|
+
"read": 4,
|
|
118
|
+
"bash": 1,
|
|
119
|
+
"write": 1
|
|
120
|
+
},
|
|
121
|
+
"result": "Beta: Chen",
|
|
122
|
+
"exit": 0,
|
|
123
|
+
"stderr": "[llm-deepseek-api-key] model listing from https://api.deepseek.com/models loaded 2 model(s), skipped 0 row(s)\n"
|
|
124
|
+
}
|
|
125
|
+
]
|