@lzn1998/dsh-langgraph 0.0.0-stage → 0.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/LICENSE +21 -0
- package/README.md +30 -2
- package/cordis.patch.yml +11 -0
- package/docs/DETAIL.md +239 -0
- package/docs/architecture.svg +117 -0
- package/dsh-chat-model.js +157 -0
- package/dsh-checkpointer.js +520 -0
- package/dsh-tools.js +56 -0
- package/dsh-trace.js +313 -0
- package/graphs/approval-gate.js +52 -0
- package/graphs/ask-subagent.js +48 -0
- package/graphs/ask-tools.js +57 -0
- package/graphs/ask-workspace.js +48 -0
- package/graphs/scan-report.js +51 -0
- package/graphs/typed-report.ts +58 -0
- package/icon.svg +11 -0
- package/index.d.ts +119 -0
- package/index.js +889 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +56 -4
package/index.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for `dsh-langgraph` graph modules.
|
|
3
|
+
*
|
|
4
|
+
* A graph module can be written in TypeScript and type-checked without importing
|
|
5
|
+
* the plugin at runtime:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import type { GraphApi, GraphModule } from '@lzn1998/dsh-langgraph'
|
|
9
|
+
* export const id = 'report'
|
|
10
|
+
* export const input = { type: 'object' }
|
|
11
|
+
* export function build({ StateGraph, Annotation, START, END, helpers }: GraphApi) { ... }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
import { Annotation, END, START, StateGraph, interrupt } from '@langchain/langgraph'
|
|
15
|
+
import type { BaseCheckpointSaver } from '@langchain/langgraph-checkpoint'
|
|
16
|
+
import type { BaseChatModel } from '@langchain/core/language_models/chat_models'
|
|
17
|
+
|
|
18
|
+
/** Route options accepted by the model bridges. */
|
|
19
|
+
export interface ModelRouteOptions {
|
|
20
|
+
provider?: string
|
|
21
|
+
model?: string
|
|
22
|
+
reasoningEffort?: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Options for one text-only model call. */
|
|
26
|
+
export interface CallModelOptions extends ModelRouteOptions {
|
|
27
|
+
system?: string
|
|
28
|
+
temperature?: number
|
|
29
|
+
maxTokens?: number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Options for one DSH subagent delegation. */
|
|
33
|
+
export interface SubagentOptions {
|
|
34
|
+
/** Registered subagent provider; defaults to `spawn`. */
|
|
35
|
+
provider?: string
|
|
36
|
+
/** Display label for the child. */
|
|
37
|
+
label?: string
|
|
38
|
+
/** Unique child name; omitted assigns `agent-N`. */
|
|
39
|
+
name?: string
|
|
40
|
+
/** Initial child directory; relative paths resolve against the parent's cwd. */
|
|
41
|
+
cwd?: string
|
|
42
|
+
/** Independent agent preset; only local providers support this. */
|
|
43
|
+
agentPreset?: string
|
|
44
|
+
/** Child model/provider overrides. */
|
|
45
|
+
agentOptions?: Record<string, unknown>
|
|
46
|
+
/** Object-rooted JSON Schema for the child's structured result. */
|
|
47
|
+
schema?: Record<string, unknown>
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The result of one DSH subagent delegation. */
|
|
51
|
+
export interface SubagentResult {
|
|
52
|
+
/** Concatenated text blocks of the child's final output. */
|
|
53
|
+
text: string
|
|
54
|
+
/** The child's final content blocks, including any images. */
|
|
55
|
+
output: unknown[]
|
|
56
|
+
/** The validated structured result when `schema` was supplied. */
|
|
57
|
+
structured?: unknown
|
|
58
|
+
/** `completed` or the provider's failure stop reason. */
|
|
59
|
+
stopReason: string
|
|
60
|
+
/** The child's model-facing name. */
|
|
61
|
+
name: string
|
|
62
|
+
/** The child's Session id. */
|
|
63
|
+
childId: string
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The helpers bound to one run. */
|
|
67
|
+
export interface GraphHelpers {
|
|
68
|
+
/** The calling DSH agent, when the tool was invoked by an agent. */
|
|
69
|
+
readonly agent: unknown
|
|
70
|
+
/** The calling session id, when known. */
|
|
71
|
+
readonly sessionId: string | undefined
|
|
72
|
+
/** LangChain message classes, re-exported so a graph needs no LangChain dependency. */
|
|
73
|
+
readonly messages: {
|
|
74
|
+
AIMessage: unknown
|
|
75
|
+
HumanMessage: unknown
|
|
76
|
+
SystemMessage: unknown
|
|
77
|
+
ToolMessage: unknown
|
|
78
|
+
}
|
|
79
|
+
/** A LangChain chat model over this deployment's model route. */
|
|
80
|
+
chatModel(options?: ModelRouteOptions): BaseChatModel
|
|
81
|
+
/** Wrap visible DSH tools as LangChain tools. */
|
|
82
|
+
tools(names: string[]): unknown[]
|
|
83
|
+
/** LangGraph's prebuilt ReAct agent over DSH tools and the DSH model. */
|
|
84
|
+
createReactAgent(options?: Record<string, unknown>): Promise<unknown>
|
|
85
|
+
/** One text completion on this deployment's model route. */
|
|
86
|
+
callModel(prompt: string, options?: CallModelOptions): Promise<{ text: string; usage?: unknown }>
|
|
87
|
+
/** Run one DSH tool in the calling agent's scope and return its text content. */
|
|
88
|
+
callTool(name: string, args?: Record<string, unknown>): Promise<string>
|
|
89
|
+
/** Delegate one task to a DSH subagent and await its final output. */
|
|
90
|
+
subagent(prompt: string, options?: SubagentOptions): Promise<SubagentResult>
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** The API object passed to a graph module's `build(api)`. */
|
|
94
|
+
export interface GraphApi {
|
|
95
|
+
readonly StateGraph: typeof StateGraph
|
|
96
|
+
readonly Annotation: typeof Annotation
|
|
97
|
+
readonly START: typeof START
|
|
98
|
+
readonly END: typeof END
|
|
99
|
+
readonly interrupt: typeof interrupt
|
|
100
|
+
readonly helpers: GraphHelpers
|
|
101
|
+
/** The durable checkpointer the plugin compiles the graph with. */
|
|
102
|
+
readonly checkpointer: BaseCheckpointSaver
|
|
103
|
+
readonly [key: string]: unknown
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** The module shape the plugin discovers. */
|
|
107
|
+
export interface GraphModule {
|
|
108
|
+
/** Stable graph id used by the `langgraph_run` tool. */
|
|
109
|
+
readonly id: string
|
|
110
|
+
/** One-line description shown when the agent lists graphs. */
|
|
111
|
+
readonly description?: string
|
|
112
|
+
/** JSON Schema of the initial state, shown to the agent. */
|
|
113
|
+
readonly input?: Record<string, unknown>
|
|
114
|
+
/** Return an uncompiled StateGraph (preferred) or a compiled graph. */
|
|
115
|
+
build(api: GraphApi): unknown | Promise<unknown>
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Identity helper for a typed graph module. */
|
|
119
|
+
export function defineGraph<T extends GraphModule>(module: T): T
|