@lzn1998/dsh-langgraph 1.0.0 → 1.5.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/index.d.ts CHANGED
@@ -153,3 +153,139 @@ export interface GraphModule {
153
153
 
154
154
  /** Identity helper for a typed graph module. */
155
155
  export function defineGraph<T extends GraphModule>(module: T): T
156
+
157
+ // --- composed graphs (`langgraph_compose`) -----------------------------------
158
+
159
+ /** One declared state field. */
160
+ export interface StateField {
161
+ type: 'string' | 'number' | 'boolean' | 'json' | 'string[]' | 'number[]'
162
+ /** Required; must match `type`. */
163
+ default: unknown
164
+ /** Defaults to `replace`; parallel writers need append/add/max/min/merge. */
165
+ reducer?: 'replace' | 'append' | 'add' | 'max' | 'min' | 'merge'
166
+ }
167
+
168
+ /** A state reference; `field` or `field.path` into a json field. */
169
+ export interface StateRef {
170
+ $state: string
171
+ }
172
+
173
+ /** One prompt part: literal text or a state reference. */
174
+ export type PromptPart = string | StateRef
175
+
176
+ /** A node argument or set value: a JSON literal or a state reference. */
177
+ export type SpecValue = unknown | StateRef
178
+
179
+ /** How a node result is written to state. */
180
+ export type Transform = 'text' | 'lines' | 'json' | 'bool' | 'number' | 'first' | 'count'
181
+
182
+ /** A guard operator. */
183
+ export type GuardOp = 'eq' | 'ne' | 'in' | 'gt' | 'gte' | 'lt' | 'lte' | 'exists' | 'and' | 'or' | 'not'
184
+
185
+ /** A guard operand: a JSON literal or a state reference. */
186
+ export type GuardOperand = unknown | StateRef
187
+
188
+ /** A structured edge guard; `and`, `or`, and `not` nest guards. */
189
+ export type Guard = true | false | { op: GuardOp; args: Array<Guard | GuardOperand> }
190
+
191
+ /** One known atomic DSH tool action. */
192
+ export interface ComposeToolNode {
193
+ id: string
194
+ do: 'tool'
195
+ tool: string
196
+ args: Record<string, SpecValue>
197
+ out: Record<string, Transform>
198
+ }
199
+
200
+ /** One model judgment. */
201
+ export interface ComposeModelNode {
202
+ id: string
203
+ do: 'model'
204
+ prompt: PromptPart[]
205
+ system?: string
206
+ schema?: Record<string, unknown>
207
+ out: Record<string, Transform>
208
+ }
209
+
210
+ /** Open work: a prose brief plus tools, run by LangGraph's prebuilt ReAct agent. */
211
+ export interface ComposeAgentNode {
212
+ id: string
213
+ do: 'agent'
214
+ prompt: PromptPart[]
215
+ tools: string[]
216
+ out: Record<string, Transform>
217
+ }
218
+
219
+ /** A human decision through LangGraph `interrupt()`. */
220
+ export interface ComposeGateNode {
221
+ id: string
222
+ do: 'gate'
223
+ question: string
224
+ options?: string[]
225
+ out: Record<string, Transform>
226
+ }
227
+
228
+ /** A DSH child session. */
229
+ export interface ComposeSubagentNode {
230
+ id: string
231
+ do: 'subagent'
232
+ prompt: PromptPart[]
233
+ schema?: Record<string, unknown>
234
+ out: Record<string, Transform>
235
+ }
236
+
237
+ /** A map body; its `id` is optional and ignored. */
238
+ export type ComposeMapBody =
239
+ | (Omit<ComposeToolNode, 'id'> & { id?: string })
240
+ | (Omit<ComposeModelNode, 'id'> & { id?: string })
241
+ | (Omit<ComposeAgentNode, 'id'> & { id?: string })
242
+ | (Omit<ComposeSubagentNode, 'id'> & { id?: string })
243
+
244
+ /** Dynamic fan-out over a string[] or number[] field. */
245
+ export interface ComposeMapNode {
246
+ id: string
247
+ do: 'map'
248
+ over: string
249
+ body: ComposeMapBody
250
+ maxItems?: number
251
+ maxConcurrency?: number
252
+ }
253
+
254
+ /** A literal state update. */
255
+ export interface ComposeSetNode {
256
+ id: string
257
+ do: 'set'
258
+ values: Record<string, SpecValue>
259
+ }
260
+
261
+ /** Any node the compiler accepts. */
262
+ export type ComposeNode =
263
+ | ComposeToolNode
264
+ | ComposeModelNode
265
+ | ComposeAgentNode
266
+ | ComposeGateNode
267
+ | ComposeMapNode
268
+ | ComposeSetNode
269
+ | ComposeSubagentNode
270
+
271
+ /** One edge. `from` is a node id or `START`; `to` is a node id or `END`. */
272
+ export interface ComposeEdge {
273
+ from: string
274
+ to: string
275
+ when?: Guard
276
+ }
277
+
278
+ /** The strict JSON IR accepted by `langgraph_compose`. */
279
+ export interface GraphSpec {
280
+ ir: 1
281
+ name?: string
282
+ description?: string
283
+ state: Record<string, StateField>
284
+ nodes: ComposeNode[]
285
+ edges: ComposeEdge[]
286
+ output?: string[]
287
+ maxSteps?: number
288
+ }
289
+
290
+ /** Actions accepted by `langgraph_compose`. */
291
+ export type ComposeAction = 'describe' | 'validate' | 'compose' | 'list' | 'get' | 'delete' | 'fork'