@lzn1998/dsh-langgraph 1.5.0 → 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.
@@ -0,0 +1,516 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>dsh-langgraph — Graphs with seams</title>
7
+ <meta name="description" content="Six small, durable graphs for DSH. JSON specs, DSH tools, human gates, and threads that survive a restart — no arbitrary JavaScript.">
8
+ <link rel="icon" href="../icon.svg">
9
+ <style>
10
+ :root {
11
+ --bg: #080b12;
12
+ --panel: #0e1420;
13
+ --panel-2: #111a2a;
14
+ --ink: #e8edf7;
15
+ --muted: #8695ad;
16
+ --faint: #55647c;
17
+ --line: rgba(150, 175, 220, .14);
18
+ --line-strong: rgba(150, 175, 220, .28);
19
+ --blue: #7c9cff;
20
+ --mint: #5eead4;
21
+ --pink: #f0abfc;
22
+ --amber: #f6c177;
23
+ --green: #86efac;
24
+ --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
25
+ --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
26
+ }
27
+ * { box-sizing: border-box; }
28
+ html { scroll-behavior: smooth; }
29
+ body {
30
+ margin: 0;
31
+ color: var(--ink);
32
+ background:
33
+ radial-gradient(1100px 600px at 78% -8%, rgba(124, 156, 255, .18), transparent 60%),
34
+ radial-gradient(900px 500px at 8% 12%, rgba(94, 234, 212, .08), transparent 55%),
35
+ var(--bg);
36
+ font-family: var(--sans);
37
+ -webkit-font-smoothing: antialiased;
38
+ line-height: 1.55;
39
+ }
40
+ a { color: inherit; text-decoration: none; }
41
+ a:hover { color: var(--blue); }
42
+ .page { max-width: 1180px; margin: 0 auto; padding: 0 28px 80px; }
43
+ .grid-bg {
44
+ position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .5;
45
+ background-image:
46
+ linear-gradient(rgba(124, 156, 255, .045) 1px, transparent 1px),
47
+ linear-gradient(90deg, rgba(124, 156, 255, .045) 1px, transparent 1px);
48
+ background-size: 42px 42px;
49
+ mask-image: radial-gradient(85% 60% at 50% 0%, black 20%, transparent 100%);
50
+ }
51
+ nav {
52
+ display: flex; align-items: center; justify-content: space-between; gap: 20px;
53
+ padding: 22px 0; border-bottom: 1px solid var(--line);
54
+ position: sticky; top: 0; z-index: 20;
55
+ background: rgba(8, 11, 18, .78); backdrop-filter: blur(18px);
56
+ }
57
+ .brand { display: flex; align-items: center; gap: 11px; font-weight: 650; letter-spacing: -.01em; }
58
+ .brand img { width: 28px; height: 28px; border-radius: 8px; }
59
+ .brand small { color: var(--muted); font-weight: 500; margin-left: 2px; }
60
+ .nav-links { display: flex; align-items: center; gap: 24px; color: var(--muted); font-size: 13px; }
61
+ .nav-links a:hover { color: var(--ink); }
62
+ .pill {
63
+ display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-strong);
64
+ border-radius: 999px; padding: 7px 13px; font-size: 12px; color: var(--muted);
65
+ background: rgba(255, 255, 255, .02);
66
+ }
67
+ .pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 12px var(--mint); }
68
+ .hero { display: grid; grid-template-columns: 1.02fr 1.12fr; gap: 46px; align-items: center; padding: 74px 0 56px; }
69
+ .kicker { color: var(--mint); font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 18px; }
70
+ h1 { font-size: clamp(44px, 5.6vw, 76px); line-height: .98; letter-spacing: -.045em; margin: 0 0 22px; font-weight: 730; }
71
+ .grad { background: linear-gradient(110deg, #dfe8ff 4%, var(--blue) 42%, var(--mint) 92%); -webkit-background-clip: text; background-clip: text; color: transparent; }
72
+ .lede { color: var(--muted); font-size: 17px; max-width: 560px; margin: 0 0 28px; }
73
+ .actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
74
+ .btn { display: inline-flex; align-items: center; gap: 9px; border-radius: 10px; padding: 11px 17px; font-size: 13px; font-weight: 600; border: 1px solid transparent; cursor: pointer; }
75
+ .btn-primary { background: linear-gradient(135deg, var(--blue), #a78bfa); color: #08101f; box-shadow: 0 10px 34px rgba(124, 156, 255, .23); }
76
+ .btn-primary:hover { color: #08101f; filter: brightness(1.08); }
77
+ .btn-ghost { border-color: var(--line-strong); color: var(--ink); background: rgba(255, 255, 255, .02); }
78
+ .btn-ghost:hover { border-color: var(--blue); }
79
+ .meta-strip { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 28px; color: var(--faint); font-family: var(--mono); font-size: 11px; }
80
+ .meta-strip strong { color: var(--ink); font-weight: 600; }
81
+ .hero-visual { position: relative; min-height: 430px; }
82
+ .hero-card {
83
+ border: 1px solid var(--line-strong); border-radius: 18px; overflow: hidden;
84
+ background: linear-gradient(180deg, rgba(17, 26, 42, .92), rgba(10, 15, 24, .96));
85
+ box-shadow: 0 30px 90px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .05);
86
+ transform: perspective(1200px) rotateY(-4deg) rotateX(2deg); transform-origin: 70% 40%;
87
+ }
88
+ .window-bar { display: flex; align-items: center; gap: 7px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .015); }
89
+ .window-bar i { width: 8px; height: 8px; border-radius: 50%; background: #334155; display: block; }
90
+ .window-bar i:nth-child(1) { background: #f87171aa; } .window-bar i:nth-child(2) { background: #f6c177aa; } .window-bar i:nth-child(3) { background: #86efacaa; }
91
+ .window-bar span { margin-left: 8px; color: var(--faint); font-family: var(--mono); font-size: 10px; }
92
+ .hero-card .graph-wrap { padding: 18px 14px 4px; }
93
+ .hero-card .thread { margin: 0 16px 16px; border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; background: rgba(5, 9, 15, .55); }
94
+ .thread-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; }
95
+ .thread-head b { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
96
+ .live { display: inline-flex; align-items: center; gap: 6px; color: var(--mint); font-family: var(--mono); font-size: 10px; }
97
+ .live::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 10px var(--mint); animation: pulse 2.2s infinite; }
98
+ .thread code { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
99
+ .thread .row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px dashed rgba(150, 175, 220, .08); }
100
+ .thread .row:last-child { border-bottom: 0; }
101
+ .thread .row span:last-child { color: var(--ink); }
102
+ .thread .decision { color: var(--amber); }
103
+ .glow { position: absolute; width: 220px; height: 220px; border-radius: 50%; filter: blur(60px); opacity: .28; pointer-events: none; }
104
+ .glow-a { background: var(--blue); right: -60px; top: 30px; } .glow-b { background: var(--mint); left: -50px; bottom: 0; opacity: .14; }
105
+ section { padding: 62px 0; border-top: 1px solid var(--line); }
106
+ .section-head { display: flex; align-items: end; justify-content: space-between; gap: 22px; margin-bottom: 30px; }
107
+ .section-head h2 { font-size: 30px; letter-spacing: -.03em; margin: 0; font-weight: 680; }
108
+ .section-head p { margin: 0; color: var(--muted); font-size: 13px; max-width: 500px; }
109
+ .section-head .eyebrow { color: var(--faint); font-family: var(--mono); font-size: 10px; letter-spacing: .13em; text-transform: uppercase; margin-bottom: 7px; }
110
+ .demo-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 18px; align-items: stretch; }
111
+ .demo-video { position: relative; border: 1px solid var(--line-strong); border-radius: 15px; overflow: hidden; background: #05080d; box-shadow: 0 24px 70px rgba(0,0,0,.38); }
112
+ .demo-video video { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: #05080d; }
113
+ .demo-caption { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: 9px; background: rgba(6,10,16,.82); backdrop-filter: blur(12px); color: var(--muted); font-family: var(--mono); font-size: 9.5px; pointer-events: none; }
114
+ .demo-video .live { font-size: 9.5px; }
115
+ .demo-copy { border: 1px solid var(--line); border-radius: 15px; padding: 20px; background: linear-gradient(180deg, rgba(17,26,42,.72), rgba(10,15,24,.82)); }
116
+ .demo-copy h3 { font-size: 21px; letter-spacing: -.02em; margin: 0 0 10px; }
117
+ .demo-copy p { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; }
118
+ .demo-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
119
+ .demo-stats div { border: 1px solid var(--line); border-radius: 9px; padding: 10px; background: rgba(255,255,255,.015); }
120
+ .demo-stats b { display: block; font-size: 19px; letter-spacing: -.03em; color: var(--ink); }
121
+ .demo-stats span { display: block; color: var(--faint); font-family: var(--mono); font-size: 9px; margin-top: 2px; }
122
+ .demo-copy .btn { width: 100%; justify-content: center; margin-top: 8px; }
123
+ .cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
124
+ .card {
125
+ position: relative; border: 1px solid var(--line); border-radius: 15px; overflow: hidden;
126
+ background: linear-gradient(180deg, rgba(17, 26, 42, .82), rgba(11, 16, 25, .9));
127
+ transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
128
+ }
129
+ .card:hover { transform: translateY(-4px); border-color: var(--line-strong); box-shadow: 0 25px 50px rgba(0, 0, 0, .3); }
130
+ .card .stripe { height: 2px; background: linear-gradient(90deg, var(--accent), transparent); opacity: .9; }
131
+ .card .topo { padding: 14px 12px 0; }
132
+ .card .body { padding: 12px 16px 16px; }
133
+ .card h3 { font-size: 15px; margin: 0 0 4px; letter-spacing: -.01em; }
134
+ .card .tagline { color: var(--muted); font-size: 11.5px; min-height: 34px; margin: 0 0 11px; }
135
+ .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
136
+ .tag { font-family: var(--mono); font-size: 9.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 7px; }
137
+ .tag.gate { color: var(--amber); border-color: rgba(246, 193, 119, .25); background: rgba(246, 193, 119, .05); }
138
+ .prompt { position: relative; border: 1px solid var(--line); border-radius: 9px; background: rgba(4, 8, 13, .6); padding: 10px 11px; font-family: var(--mono); font-size: 9.6px; color: #aebbd0; line-height: 1.5; min-height: 66px; }
139
+ .prompt button { position: absolute; right: 7px; top: 7px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); border-radius: 5px; font-size: 9px; padding: 3px 6px; cursor: pointer; font-family: var(--sans); }
140
+ .prompt button:hover { color: var(--ink); border-color: var(--blue); }
141
+ .card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 11px; font-size: 10.5px; color: var(--faint); }
142
+ .card .foot a:hover { color: var(--accent); }
143
+ .how { display: grid; grid-template-columns: .9fr 1.1fr; gap: 38px; align-items: start; }
144
+ .how-list { display: grid; gap: 12px; }
145
+ .how-item { display: grid; grid-template-columns: 34px 1fr; gap: 13px; padding: 13px 0; border-bottom: 1px dashed var(--line); }
146
+ .how-item:last-child { border-bottom: 0; }
147
+ .how-item .n { width: 28px; height: 28px; border: 1px solid var(--line-strong); border-radius: 8px; display: grid; place-items: center; font-family: var(--mono); font-size: 10px; color: var(--blue); background: rgba(124, 156, 255, .06); }
148
+ .how-item b { display: block; font-size: 13px; margin-bottom: 2px; }
149
+ .how-item p { margin: 0; color: var(--muted); font-size: 11.5px; }
150
+ .code { border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; background: rgba(4, 8, 14, .78); }
151
+ .code .bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 13px; border-bottom: 1px solid var(--line); color: var(--faint); font-family: var(--mono); font-size: 10px; }
152
+ .code pre { margin: 0; padding: 16px 16px 18px; overflow: auto; font-family: var(--mono); font-size: 10.5px; line-height: 1.7; color: #b9c6da; }
153
+ .code .k { color: var(--mint); } .code .s { color: var(--blue); } .code .c { color: var(--faint); } .code .a { color: var(--amber); }
154
+ .honest { display: grid; grid-template-columns: 1.1fr .9fr; gap: 38px; align-items: center; }
155
+ .bench { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: rgba(10, 15, 24, .7); }
156
+ .bench-row { display: grid; grid-template-columns: 1.3fr .8fr .8fr; gap: 10px; padding: 11px 15px; border-bottom: 1px solid var(--line); align-items: center; font-size: 11px; }
157
+ .bench-row:last-child { border-bottom: 0; }
158
+ .bench-row.head { color: var(--faint); font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
159
+ .bench-row b { font-weight: 600; }
160
+ .bench-row .muted { color: var(--muted); font-family: var(--mono); font-size: 10px; }
161
+ .bar-mini { height: 4px; border-radius: 4px; background: rgba(124, 156, 255, .12); overflow: hidden; margin-top: 6px; }
162
+ .bar-mini i { display: block; height: 100%; border-radius: 4px; background: var(--blue); }
163
+ .honest .quote { color: var(--muted); font-size: 13px; }
164
+ .honest .quote strong { color: var(--ink); }
165
+ .safety { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
166
+ .safety div { border: 1px solid var(--line); border-radius: 12px; padding: 15px; background: rgba(255, 255, 255, .015); }
167
+ .safety b { display: block; font-size: 12px; margin-bottom: 3px; }
168
+ .safety p { margin: 0; color: var(--muted); font-size: 10.5px; }
169
+ footer { display: flex; justify-content: space-between; gap: 20px; align-items: center; padding-top: 30px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11px; }
170
+ footer .links { display: flex; gap: 18px; }
171
+ @keyframes pulse { 0%, 100% { opacity: .45; transform: scale(.9); } 50% { opacity: 1; transform: scale(1.15); } }
172
+ @media (max-width: 980px) {
173
+ .hero { grid-template-columns: 1fr; padding-top: 48px; }
174
+ .hero-visual { min-height: 360px; }
175
+ .hero-card { transform: none; }
176
+ .cards { grid-template-columns: repeat(2, 1fr); }
177
+ .demo-grid, .how, .honest { grid-template-columns: 1fr; }
178
+ .safety { grid-template-columns: repeat(2, 1fr); }
179
+ .nav-links a:not(.pill) { display: none; }
180
+ }
181
+ @media (max-width: 620px) {
182
+ .page { padding: 0 16px 60px; }
183
+ .cards { grid-template-columns: 1fr; }
184
+ .safety { grid-template-columns: 1fr; }
185
+ .section-head { display: block; }
186
+ footer { display: block; }
187
+ footer .links { margin-top: 10px; }
188
+ }
189
+ @media (prefers-reduced-motion: reduce) {
190
+ * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
191
+ }
192
+ </style>
193
+ </head>
194
+ <body>
195
+ <div class="grid-bg"></div>
196
+ <div class="page">
197
+ <nav>
198
+ <a class="brand" href="../README.md"><img src="../icon.svg" alt=""><span>dsh-langgraph</span><small>gallery</small></a>
199
+ <div class="nav-links">
200
+ <a href="#demo">Demo</a>
201
+ <a href="#graphs">Graphs</a>
202
+ <a href="#how">How it works</a>
203
+ <a href="#honest">Benchmark</a>
204
+ <a href="../docs/COMPOSE.md">Contract</a>
205
+ <a class="pill" href="../README.md">v1.5.0 <span class="dot"></span> DSH</a>
206
+ </div>
207
+ </nav>
208
+
209
+ <header class="hero">
210
+ <div>
211
+ <div class="kicker">Durable workflows · DSH-native</div>
212
+ <h1>Graphs<br><span class="grad">with seams.</span></h1>
213
+ <p class="lede">Six small graphs that earn their keep at a real seam: fan-out over unknown files, one extraction per item, a human signature, a pause that survives a restart. JSON specs, DSH tools, and a ledger — no arbitrary JavaScript.</p>
214
+ <div class="actions">
215
+ <a class="btn btn-primary" href="#graphs">Open the gallery <span>↓</span></a>
216
+ <a class="btn btn-ghost" href="../docs/COMPOSE.md">Read the contract</a>
217
+ <a class="btn btn-ghost" href="https://github.com/lznnnnn1998/DSH-LangGraph">GitHub ↗</a>
218
+ </div>
219
+ <div class="meta-strip">
220
+ <span><strong>6</strong> graphs</span>
221
+ <span><strong>3</strong> human gates</span>
222
+ <span><strong>0</strong> arbitrary JS</span>
223
+ <span><strong>166</strong> tests</span>
224
+ </div>
225
+ </div>
226
+ <div class="hero-visual">
227
+ <div class="glow glow-a"></div><div class="glow glow-b"></div>
228
+ <div class="hero-card">
229
+ <div class="window-bar"><i></i><i></i><i></i><span>langgraph · thread</span></div>
230
+ <div class="graph-wrap"><div id="hero-graph"></div></div>
231
+ <div class="thread">
232
+ <div class="thread-head"><b>ledger</b><span class="live">durable</span></div>
233
+ <div class="row"><span>files</span><code>12</code></div>
234
+ <div class="row"><span>extracts</span><code>12 objects</code></div>
235
+ <div class="row"><span>outline</span><code>ready</code></div>
236
+ <div class="row"><span>gate</span><span class="decision">approve →</span></div>
237
+ <div class="row"><span>checkpoint</span><code>lg_…_w0xw</code></div>
238
+ </div>
239
+ </div>
240
+ </div>
241
+ </header>
242
+
243
+ <section id="demo">
244
+ <div class="section-head">
245
+ <div><div class="eyebrow">Real session · 57s</div><h2>Not a mock.</h2></div>
246
+ <p>Recorded from the actual DSH Web app: a 12-topic brief, two 12-item maps, a human gate, and a 12-row output. The video is the transcript and the panel, not an illustration.</p>
247
+ </div>
248
+ <div class="demo-grid">
249
+ <div class="demo-video">
250
+ <video controls muted playsinline preload="metadata" poster="assets/session.png">
251
+ <source src="../media/dsh-langgraph-demo.webm" type="video/webm">
252
+ Your browser does not support the video tag.
253
+ </video>
254
+ <div class="demo-caption"><span class="live">real DSH session</span><span>55s · 226K tokens · 12 rows</span></div>
255
+ </div>
256
+ <div class="demo-copy">
257
+ <div class="eyebrow">The shape</div>
258
+ <h3>Two maps, one signature.</h3>
259
+ <p>The graph reads 12 files, extracts one JSON object per file, drafts the outline, and pauses. The human approves the outline; the same thread resumes and writes the brief.</p>
260
+ <div class="demo-stats">
261
+ <div><b>12</b><span>files</span></div>
262
+ <div><b>2 × 12</b><span>maps</span></div>
263
+ <div><b>1</b><span>gate</span></div>
264
+ <div><b>55s</b><span>wall time</span></div>
265
+ </div>
266
+ <a class="btn btn-ghost" href="specs/research-brief.lg.json">Open the spec <span>↗</span></a>
267
+ <a class="btn btn-ghost" href="../docs/BENCHMARK.md">See the benchmark</a>
268
+ </div>
269
+ </div>
270
+ </section>
271
+
272
+ <section id="graphs">
273
+ <div class="section-head">
274
+ <div><div class="eyebrow">The gallery</div><h2>Pick a seam, not a shape.</h2></div>
275
+ <p>Each card is a real GraphSpec. Copy the prompt, open the JSON, or compose it from the file. The graph is the contract; the model fills the roles.</p>
276
+ </div>
277
+ <div class="cards" id="cards"></div>
278
+ </section>
279
+
280
+ <section id="how">
281
+ <div class="section-head">
282
+ <div><div class="eyebrow">Under the hood</div><h2>Prose, law, a clerk.</h2></div>
283
+ <p>The model reads a guide for method and a law for rules. The compiler is deterministic: JSON in, StateGraph out. No model translates the IR.</p>
284
+ </div>
285
+ <div class="how">
286
+ <div class="how-list">
287
+ <div class="how-item"><div class="n">01</div><div><b>State is the ledger.</b><p>What must still be true after a seam: files, extracts, outline, decision. Typed fields and reducers decide how many writers may settle them.</p></div></div>
288
+ <div class="how-item"><div class="n">02</div><div><b>A node is a role.</b><p>One tool call, one judgment, or an open agent brief. Open-ended work stays in prose, not in a constellation of tiny nodes.</p></div></div>
289
+ <div class="how-item"><div class="n">03</div><div><b>A gate is a signature.</b><p>The run returns <code>interrupted</code> with a thread. The human answer is raw; the graph resumes from the same checkpoint.</p></div></div>
290
+ <div class="how-item"><div class="n">04</div><div><b>A map is one role repeated.</b><p>Fan out over a list you did not know until runtime; the join settles the ledger. Append follows input order, not completion order.</p></div></div>
291
+ </div>
292
+ <div class="code">
293
+ <div class="bar"><span>gallery/specs/research-brief.lg.json</span><span>JSON · IR 1</span></div>
294
+ <pre><span class="c">// the seam, not the ceremony</span>
295
+ <span class="k">"nodes"</span>: [
296
+ { <span class="k">"do"</span>: <span class="s">"tool"</span>, <span class="k">"tool"</span>: <span class="s">"glob"</span>, <span class="k">"out"</span>: { <span class="k">"files"</span>: <span class="s">"lines"</span> } },
297
+ { <span class="k">"do"</span>: <span class="s">"map"</span>, <span class="k">"over"</span>: <span class="s">"files"</span>,
298
+ <span class="k">"body"</span>: { <span class="k">"do"</span>: <span class="s">"tool"</span>, <span class="k">"tool"</span>: <span class="s">"read"</span>,
299
+ <span class="k">"args"</span>: { <span class="k">"file_path"</span>: { <span class="k">"$state"</span>: <span class="s">"item"</span> } } } },
300
+ { <span class="k">"do"</span>: <span class="s">"map"</span>, <span class="k">"over"</span>: <span class="s">"contents"</span>, <span class="c">// extract per item</span>
301
+ <span class="k">"body"</span>: { <span class="k">"do"</span>: <span class="s">"model"</span>, <span class="k">"schema"</span>: { <span class="k">"type"</span>: <span class="s">"object"</span> } } },
302
+ { <span class="k">"do"</span>: <span class="s">"gate"</span>, <span class="k">"question"</span>: <span class="s">"Approve this outline?"</span>,
303
+ <span class="k">"out"</span>: { <span class="k">"decision"</span>: <span class="s">"text"</span> } }
304
+ <span class="c">// … compose, write</span>
305
+ ]</pre>
306
+ </div>
307
+ </div>
308
+ </section>
309
+
310
+ <section id="honest">
311
+ <div class="section-head">
312
+ <div><div class="eyebrow">The honest part</div><h2>A graph is a seam tax.</h2></div>
313
+ <p>From a real 12-topic brief on the same DSH host. The ordinary loop is still the cheapest; a graph is for the seams that justify it.</p>
314
+ </div>
315
+ <div class="honest">
316
+ <div class="bench">
317
+ <div class="bench-row head"><span>approach</span><span>time</span><span>tokens</span></div>
318
+ <div class="bench-row"><div><b>Ordinary loop</b><div class="muted">no graph</div><div class="bar-mini"><i style="width:7%"></i></div></div><span class="muted">53s</span><span class="muted">124K</span></div>
319
+ <div class="bench-row"><div><b>Fine map graph</b><div class="muted">2 × 12-item maps + gate</div><div class="bar-mini"><i style="width:24%;background:var(--mint)"></i></div></div><span class="muted">55s</span><span class="muted">226K</span></div>
320
+ <div class="bench-row"><div><b>Coarse agent graph</b><div class="muted">4 agent/phase nodes</div><div class="bar-mini"><i style="width:100%;background:var(--amber)"></i></div></div><span class="muted">1m38s</span><span class="muted">462K</span></div>
321
+ </div>
322
+ <p class="quote"><strong>Don't graph a two-step task.</strong> Use the loop for open-ended work; reach for a graph when the work has a real fan-out you cannot enumerate, a human signature, or a pause that must survive a restart. The gallery's research-brief is the honest middle: the ordinary loop still wins on tokens, but the graph makes the seam explicit and resumable.</p>
323
+ </div>
324
+ </section>
325
+
326
+ <section id="run">
327
+ <div class="section-head">
328
+ <div><div class="eyebrow">Try one</div><h2>Compose from a file.</h2></div>
329
+ <p>No JS, no restart: the spec is data. Validate, compose, run; resume an interrupted thread with the raw answer.</p>
330
+ </div>
331
+ <div class="code">
332
+ <div class="bar"><span>in a DSH session</span><span>langgraph_compose · langgraph_run</span></div>
333
+ <pre><span class="a">langgraph_compose</span>({ action: <span class="s">"validate"</span>, path: <span class="s">"gallery/specs/research-brief.lg.json"</span> })
334
+ <span class="a">langgraph_compose</span>({ action: <span class="s">"compose"</span>, path: <span class="s">"gallery/specs/research-brief.lg.json"</span> })
335
+ <span class="a">langgraph_run</span>({ graph: <span class="s">"lg_adhoc_…"</span>, input: { pattern: <span class="s">"topics/*.txt"</span> } })
336
+
337
+ <span class="c">// the gate returns status: "interrupted"; ask, then resume the same thread</span>
338
+ <span class="a">langgraph_run</span>({ graph: <span class="s">"lg_adhoc_…"</span>, thread: <span class="s">"lg_lg_adhoc_…"</span>, resume: <span class="s">"Approve"</span> })</pre>
339
+ </div>
340
+ </section>
341
+
342
+ <section>
343
+ <div class="section-head">
344
+ <div><div class="eyebrow">Trust boundary</div><h2>Data, not code.</h2></div>
345
+ <p>The model may compose a graph, but it cannot ship JavaScript. The spec is session-owned; the tools are the ones you already gave the agent.</p>
346
+ </div>
347
+ <div class="safety">
348
+ <div><b>JSON IR only</b><p>No arbitrary model-written JS. The compiler is deterministic; the same spec makes the same graph.</p></div>
349
+ <div><b>Session-owned</b><p>Specs are immutable and owned by the session that composed them; another session cannot run or delete them.</p></div>
350
+ <div><b>Tool visibility</b><p>A node must name a tool visible to the calling agent; args are checked against the tool's own schema at compose time.</p></div>
351
+ <div><b>Human gates</b><p>Irreversible steps pause with a thread. The answer is raw; the resume is explicit, never a hidden side effect.</p></div>
352
+ </div>
353
+ </section>
354
+
355
+ <footer>
356
+ <span>dsh-langgraph · the graph is a contract, the compiler is a clerk.</span>
357
+ <div class="links">
358
+ <a href="https://github.com/lznnnnn1998/DSH-LangGraph">GitHub</a>
359
+ <a href="https://www.npmjs.com/package/@lzn1998/dsh-langgraph">npm</a>
360
+ <a href="../docs/COMPOSE.md">Docs</a>
361
+ <a href="../README.md">README</a>
362
+ </div>
363
+ </footer>
364
+ </div>
365
+
366
+ <script>
367
+ const graphs = [
368
+ {
369
+ id: "research-brief", title: "Research brief", accent: "var(--blue)",
370
+ tagline: "Fan out over files, extract one row per file, approve an outline, write.",
371
+ seam: "map ×2 + gate", gate: true, tools: ["glob", "read", "write"],
372
+ prompt: "Read topics/*.txt, extract topic/claim/risk per file, show me the outline, then write brief.md.",
373
+ flow: [
374
+ { label: "glob", kind: "tool" }, { label: "read", kind: "map", n: "×12" },
375
+ { label: "extract", kind: "map", n: "×12" }, { label: "outline", kind: "model" },
376
+ { label: "approve", kind: "gate" }, { label: "write", kind: "write" }
377
+ ]
378
+ },
379
+ {
380
+ id: "repo-scan", title: "Repo scan", accent: "var(--mint)",
381
+ tagline: "Read a set of source files in parallel and synthesize one review.",
382
+ seam: "map + join", gate: false, tools: ["glob", "read", "write"],
383
+ prompt: "Scan src/**/*.js in parallel and write scan-report.md with the main risks and the smallest next action.",
384
+ flow: [
385
+ { label: "glob", kind: "tool" }, { label: "read", kind: "map", n: "×N" },
386
+ { label: "review", kind: "model" }, { label: "write", kind: "write" }
387
+ ]
388
+ },
389
+ {
390
+ id: "pr-review", title: "PR review", accent: "var(--pink)",
391
+ tagline: "Read the current diff, draft a review, ask before posting.",
392
+ seam: "human gate", gate: true, tools: ["bash", "write"],
393
+ prompt: "Read the current git diff, draft a review, ask me before posting, then write review.md.",
394
+ flow: [
395
+ { label: "git diff", kind: "tool" }, { label: "review", kind: "model" },
396
+ { label: "approve", kind: "gate" }, { label: "write", kind: "write" }
397
+ ]
398
+ },
399
+ {
400
+ id: "incident-triage", title: "Incident triage", accent: "var(--amber)",
401
+ tagline: "Read many logs, classify the incident, ask whether to page.",
402
+ seam: "map + page gate", gate: true, tools: ["glob", "read", "write"],
403
+ prompt: "Read logs/*.log, triage the likely cause, ask whether to page on-call, then write triage.md.",
404
+ flow: [
405
+ { label: "glob", kind: "tool" }, { label: "read", kind: "map", n: "×N" },
406
+ { label: "classify", kind: "model" }, { label: "page?", kind: "gate" }, { label: "write", kind: "write" }
407
+ ]
408
+ },
409
+ {
410
+ id: "data-extract", title: "Data extract", accent: "var(--blue)",
411
+ tagline: "One JSON record per file, then one valid JSON array.",
412
+ seam: "map + join", gate: false, tools: ["glob", "read", "write"],
413
+ prompt: "Extract one {id, value} object from each data/*.txt and write records.json as one valid array.",
414
+ flow: [
415
+ { label: "glob", kind: "tool" }, { label: "read", kind: "map", n: "×N" },
416
+ { label: "extract", kind: "map", n: "×N" }, { label: "join", kind: "model" }, { label: "write", kind: "write" }
417
+ ]
418
+ },
419
+ {
420
+ id: "approval-plan", title: "Approval plan", accent: "var(--green)",
421
+ tagline: "Plan with tools, human approval, execute the plan, write the result.",
422
+ seam: "agent + gate", gate: true, tools: ["glob", "read", "write", "bash"],
423
+ prompt: "Plan the release notes with read-only tools, ask me to approve the plan, then execute and write release.md.",
424
+ flow: [
425
+ { label: "planner", kind: "agent" }, { label: "approve", kind: "gate" },
426
+ { label: "execute", kind: "agent" }, { label: "write", kind: "write" }
427
+ ]
428
+ }
429
+ ];
430
+
431
+ const colors = {
432
+ tool: "#7c9cff", map: "#5eead4", model: "#f0abfc", gate: "#f6c177",
433
+ write: "#86efac", agent: "#c4b5fd"
434
+ };
435
+
436
+ function svgGraph(flow, width, height, accent) {
437
+ const pad = 18, n = flow.length;
438
+ const y = Math.round(height * .56);
439
+ const step = (width - pad * 2) / Math.max(n - 1, 1);
440
+ const positions = flow.map((_, i) => ({ x: pad + i * step, y }));
441
+ const nodeW = Math.min(66, Math.max(43, step - 8));
442
+ const nodeH = 23;
443
+ const pieces = [];
444
+ const id = "a" + Math.random().toString(36).slice(2, 8);
445
+ pieces.push(`<defs><marker id="${id}" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="5" markerHeight="5" orient="auto"><path d="M0,0 L8,4 L0,8 z" fill="rgba(160,180,220,.45)"/></marker></defs>`);
446
+ pieces.push(`<circle cx="${pad - 7}" cy="${y}" r="2.4" fill="rgba(94,234,212,.7)"/>`);
447
+ for (let i = 1; i < n; i++) {
448
+ const a = positions[i - 1], b = positions[i];
449
+ pieces.push(`<line x1="${a.x + nodeW / 2}" y1="${y}" x2="${b.x - nodeW / 2 - 2}" y2="${y}" stroke="rgba(160,180,220,.22)" stroke-width="1" marker-end="url(#${id})"/>`);
450
+ }
451
+ flow.forEach((item, i) => {
452
+ const p = positions[i];
453
+ const color = item.kind === "gate" ? colors.gate : item.kind === "write" ? colors.write : item.kind === "map" ? colors.map : item.kind === "model" ? colors.model : item.kind === "agent" ? colors.agent : colors.tool;
454
+ if (item.kind === "map") {
455
+ pieces.push(`<rect x="${p.x - nodeW / 2 + 3}" y="${y - nodeH / 2 - 3}" width="${nodeW}" height="${nodeH}" rx="5" fill="none" stroke="${color}" stroke-opacity=".18"/>`);
456
+ pieces.push(`<rect x="${p.x - nodeW / 2 + 1}" y="${y - nodeH / 2 - 1}" width="${nodeW}" height="${nodeH}" rx="5" fill="none" stroke="${color}" stroke-opacity=".3"/>`);
457
+ }
458
+ if (item.kind === "gate") {
459
+ pieces.push(`<rect x="${p.x - nodeW / 2}" y="${y - nodeH / 2}" width="${nodeW}" height="${nodeH}" rx="4" transform="rotate(-6 ${p.x} ${y})" fill="rgba(246,193,119,.07)" stroke="${color}" stroke-opacity=".75"/>`);
460
+ } else {
461
+ pieces.push(`<rect x="${p.x - nodeW / 2}" y="${y - nodeH / 2}" width="${nodeW}" height="${nodeH}" rx="5" fill="rgba(12,18,30,.9)" stroke="${color}" stroke-opacity=".5"/>`);
462
+ }
463
+ if (item.n) pieces.push(`<text x="${p.x}" y="${y + 2.8}" text-anchor="middle" fill="${color}" font-family="ui-monospace,monospace" font-size="7.5">${item.label} ${item.n}</text>`);
464
+ else pieces.push(`<text x="${p.x}" y="${y + 2.8}" text-anchor="middle" fill="${color}" font-family="ui-monospace,monospace" font-size="7.5">${item.label}</text>`);
465
+ if (item.kind === "gate") pieces.push(`<text x="${p.x}" y="${y + nodeH / 2 + 10}" text-anchor="middle" fill="rgba(246,193,119,.7)" font-family="ui-monospace,monospace" font-size="6">HUMAN</text>`);
466
+ });
467
+ if (n > 0) {
468
+ const last = positions[n - 1];
469
+ pieces.push(`<circle cx="${Math.min(width - 6, last.x + nodeW / 2 + 5)}" cy="${y}" r="2.2" fill="rgba(134,239,172,.8)"/>`);
470
+ }
471
+ return `<svg viewBox="0 0 ${width} ${height}" width="100%" height="${height}" role="img" aria-label="graph topology">${pieces.join("")}</svg>`;
472
+ }
473
+
474
+ function renderCards() {
475
+ const root = document.getElementById("cards");
476
+ root.innerHTML = graphs.map(g => `
477
+ <article class="card" style="--accent:${g.accent}">
478
+ <div class="stripe"></div>
479
+ <div class="topo">${svgGraph(g.flow, 320, 96, g.accent)}</div>
480
+ <div class="body">
481
+ <h3>${g.title}</h3>
482
+ <p class="tagline">${g.tagline}</p>
483
+ <div class="tags">
484
+ ${g.gate ? '<span class="tag gate">human gate</span>' : '<span class="tag">no gate</span>'}
485
+ <span class="tag">${g.seam}</span>
486
+ ${g.tools.map(t => `<span class="tag">${t}</span>`).join("")}
487
+ </div>
488
+ <div class="prompt">${g.prompt}<button data-copy="${encodeURIComponent(g.prompt)}">copy</button></div>
489
+ <div class="foot"><span>${g.flow.length} nodes</span><a href="specs/${g.id}.lg.json">view spec →</a></div>
490
+ </div>
491
+ </article>
492
+ `).join("");
493
+ root.querySelectorAll("[data-copy]").forEach(button => {
494
+ button.addEventListener("click", async () => {
495
+ const text = decodeURIComponent(button.dataset.copy);
496
+ try { await navigator.clipboard.writeText(text); button.textContent = "copied"; }
497
+ catch { button.textContent = "select"; }
498
+ setTimeout(() => { button.textContent = "copy"; }, 1400);
499
+ });
500
+ });
501
+ }
502
+
503
+ function renderHero() {
504
+ const flow = [
505
+ { label: "glob", kind: "tool" }, { label: "read", kind: "map", n: "×12" },
506
+ { label: "extract", kind: "map", n: "×12" }, { label: "outline", kind: "model" },
507
+ { label: "approve", kind: "gate" }, { label: "write", kind: "write" }
508
+ ];
509
+ document.getElementById("hero-graph").innerHTML = svgGraph(flow, 560, 160);
510
+ }
511
+
512
+ renderCards();
513
+ renderHero();
514
+ </script>
515
+ </body>
516
+ </html>
@@ -0,0 +1,51 @@
1
+ {
2
+ "ir": 1,
3
+ "name": "approval-plan",
4
+ "description": "Plan with tools, ask for approval, execute the plan, and write the result.",
5
+ "state": {
6
+ "request": { "type": "string", "default": "Prepare the release notes for the next version." },
7
+ "plan": { "type": "string", "default": "" },
8
+ "decision": { "type": "string", "default": "" },
9
+ "result": { "type": "string", "default": "" }
10
+ },
11
+ "nodes": [
12
+ {
13
+ "id": "planner",
14
+ "do": "agent",
15
+ "prompt": ["Plan this request before doing it. Read only what you need; return a short numbered plan.\nRequest:\n", { "$state": "request" }],
16
+ "tools": ["glob", "read"],
17
+ "out": { "plan": "text" }
18
+ },
19
+ {
20
+ "id": "approve",
21
+ "do": "gate",
22
+ "question": "Approve this plan before execution?",
23
+ "options": ["Approve", "Revise"],
24
+ "out": { "decision": "text" }
25
+ },
26
+ {
27
+ "id": "execute",
28
+ "do": "agent",
29
+ "prompt": ["Execute the approved plan and return the result.\nPlan:\n", { "$state": "plan" }],
30
+ "tools": ["bash", "read", "write"],
31
+ "out": { "result": "text" }
32
+ },
33
+ {
34
+ "id": "write",
35
+ "do": "tool",
36
+ "tool": "write",
37
+ "args": { "file_path": "release.md", "content": { "$state": "result" } },
38
+ "out": {}
39
+ }
40
+ ],
41
+ "edges": [
42
+ { "from": "START", "to": "planner" },
43
+ { "from": "planner", "to": "approve" },
44
+ { "from": "approve", "to": "execute", "when": { "op": "eq", "args": [{ "$state": "decision" }, "Approve"] } },
45
+ { "from": "approve", "to": "END", "when": true },
46
+ { "from": "execute", "to": "write" },
47
+ { "from": "write", "to": "END" }
48
+ ],
49
+ "output": ["plan", "result", "decision"],
50
+ "maxSteps": 25
51
+ }