@picoflow/ezgraph 0.0.4 → 0.0.5
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 +106 -155
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,171 +1,122 @@
|
|
|
1
|
-
#
|
|
1
|
+
# EZGraph
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
EZGraph is a pre-release TypeScript application layer for durable,
|
|
4
|
+
multi-turn conversational workflows. It is built on LangGraph and LangChain,
|
|
5
|
+
but gives each conversation an explicit graph, typed node state, durable session
|
|
6
|
+
handling, and code-owned outcomes for validation, confirmation, and routing.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
It is provider-neutral and framework-neutral: use it with the model provider
|
|
9
|
+
and Node.js HTTP framework you already run.
|
|
9
10
|
|
|
10
|
-
##
|
|
11
|
+
## What it provides
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
- Graph and node primitives for staged conversations, rather than one large
|
|
14
|
+
prompt or an implicit agent loop.
|
|
15
|
+
- Per-node state, named history spaces, and typed outcomes such as `stay()`,
|
|
16
|
+
`advance()`, `finish()`, and `quit()`.
|
|
17
|
+
- One versioned session document per conversation, backed by memory, SQLite,
|
|
18
|
+
MongoDB, or Azure Cosmos DB.
|
|
19
|
+
- A model and tool loop that is bounded and owned by the graph, while business
|
|
20
|
+
validation and routing remain ordinary application code.
|
|
21
|
+
- Provider adapters and a typed model catalog, with support for OpenAI,
|
|
22
|
+
Anthropic, Google, Azure OpenAI, and custom compatible endpoints.
|
|
15
23
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
For the product overview, tutorial, and full developer guide, visit
|
|
25
|
+
[picoflow.io/ezgraph](https://www.picoflow.io/ezgraph/).
|
|
26
|
+
|
|
27
|
+
## Requirements
|
|
28
|
+
|
|
29
|
+
- Node.js 22.5 or later
|
|
30
|
+
- TypeScript 5.x
|
|
31
|
+
- A model-provider package and credentials for the provider you choose
|
|
32
|
+
|
|
33
|
+
Tool handlers use method decorators. Enable `experimentalDecorators` and
|
|
34
|
+
`emitDecoratorMetadata` in `tsconfig.json`, and import `reflect-metadata` once
|
|
35
|
+
at the very top of your application entry point.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install @picoflow/ezgraph
|
|
41
|
+
|
|
42
|
+
# Install only the provider adapter you use.
|
|
43
|
+
npm install @langchain/openai
|
|
44
|
+
# or: npm install @langchain/anthropic
|
|
45
|
+
# or: npm install @langchain/google
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The provider adapters are optional peer dependencies. The published package is
|
|
49
|
+
ESM; TypeScript applications should use `module` and `moduleResolution` set to
|
|
50
|
+
`NodeNext`.
|
|
51
|
+
|
|
52
|
+
## Start an application graph
|
|
53
|
+
|
|
54
|
+
Define your graph and nodes in application code, then register the graph with a
|
|
55
|
+
`GraphEngine`. The engine creates or resumes a session using the supplied
|
|
56
|
+
`sessionId`.
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import "reflect-metadata";
|
|
60
|
+
import { GraphEngine } from "@picoflow/ezgraph";
|
|
61
|
+
import { WeatherGraph } from "./weather-graph.js";
|
|
62
|
+
|
|
63
|
+
const engine = await GraphEngine.create({ graphs: [WeatherGraph] });
|
|
21
64
|
|
|
22
65
|
const result = await engine.run({
|
|
23
|
-
graphName: "
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
~~~
|
|
27
|
-
|
|
28
|
-
Graph and node IDs default to their class names, so existing declarations need
|
|
29
|
-
no identity boilerplate. If a class is renamed, preserve its persisted identity
|
|
30
|
-
with an override:
|
|
31
|
-
|
|
32
|
-
~~~ts
|
|
33
|
-
export class MyWeatherNode extends GraphNode<DemoGraphState> {
|
|
34
|
-
static override id() {
|
|
35
|
-
return "WeatherNode";
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
~~~
|
|
39
|
-
|
|
40
|
-
References that intentionally select a node identity should likewise use
|
|
41
|
-
`WeatherNode.id()` rather than `WeatherNode.name`, including the initial node
|
|
42
|
-
passed to `createGraphStateAnnotation`. Existing `nodes(...)`, `registerTurns(...)`,
|
|
43
|
-
`addEdge(...)`, and `advance(...)` calls remain unchanged. `branchBy(...)`
|
|
44
|
-
cases use `{ when: selector, routeTo: destination }` objects.
|
|
45
|
-
|
|
46
|
-
Every graph has an independent persisted schema version. Version 1 is the
|
|
47
|
-
default; set `schemaVersion` and provide ordered migrations in the graph
|
|
48
|
-
definition only when its persisted state shape changes.
|
|
49
|
-
|
|
50
|
-
Conversational stages extend `ConversationNode` and return semantic outcomes
|
|
51
|
-
instead of manually coordinating graph protocol fields:
|
|
52
|
-
|
|
53
|
-
~~~ts
|
|
54
|
-
protected nextStep(state, context, conversation) {
|
|
55
|
-
if (conversation.quitRequested) return this.quit(conversation);
|
|
56
|
-
if (context.complete) {
|
|
57
|
-
return this.advance(NextNode, conversation)
|
|
58
|
-
.withState({ value: context.value });
|
|
59
|
-
}
|
|
60
|
-
return this.stay(conversation).withState({ value: context.value });
|
|
61
|
-
}
|
|
62
|
-
~~~
|
|
63
|
-
|
|
64
|
-
Use `finish(response, conversation)` for terminal responses. Outcome builders
|
|
65
|
-
automatically coordinate history, tokens, response, input consumption, and the
|
|
66
|
-
persisted resume node. `toolResult(output).withContext(...)` provides typed
|
|
67
|
-
per-turn tool effects, and `branchBy(...)` keeps conditional
|
|
68
|
-
topology in the graph without a repetitive `route()` method. See
|
|
69
|
-
`docs/conversation-node-outcomes.md` in the source repository for the complete
|
|
70
|
-
contract.
|
|
71
|
-
|
|
72
|
-
For conversation graphs, call `graph.configAutoRoute()` to route semantic
|
|
73
|
-
outcomes automatically: `stay()` ends the current invocation, `advance()`
|
|
74
|
-
continues at its target, `quit()` continues at `TerminateSessionNode`, and
|
|
75
|
-
`finish()` ends it. Use `.via(WorkerNode)` to run a registered worker first
|
|
76
|
-
without changing the outcome's durable `currentNode`. `branchBy(SourceNode,
|
|
77
|
-
...)` remains available when a source needs explicit topology and takes
|
|
78
|
-
precedence over automatic routing for that source.
|
|
79
|
-
|
|
80
|
-
`GraphEngine` uses in-memory session persistence by default, so the shorter
|
|
81
|
-
`new GraphEngine().registerGraph([DemoGraph])` form works without configuration.
|
|
82
|
-
Set `SESSION_STORE` to `sqlite`, `mongodb`, or `cosmos` when durable persistence
|
|
83
|
-
is needed.
|
|
84
|
-
|
|
85
|
-
## Model catalog
|
|
86
|
-
|
|
87
|
-
Built-in models use `ModelCatalog.model`, which correlates each model ID with its legal
|
|
88
|
-
parameters at compile time and validates the same contract at runtime:
|
|
89
|
-
|
|
90
|
-
~~~ts
|
|
91
|
-
import { ModelCatalog } from "ezgraph";
|
|
92
|
-
|
|
93
|
-
const llmConfig = ModelCatalog.model("openai:gpt-5.4", {
|
|
94
|
-
retries: 3,
|
|
95
|
-
reasoningEffort: "medium",
|
|
96
|
-
forceToolCalls: true,
|
|
97
|
-
});
|
|
98
|
-
~~~
|
|
99
|
-
|
|
100
|
-
For a model released after the installed EZGraph version, load an application
|
|
101
|
-
JSON catalog at startup and use its resolver. Catalog construction validates
|
|
102
|
-
the profile, JSON Schema, parameter mappings, provider/model relationship, and
|
|
103
|
-
references. `catalog.model(...)` then validates parameters and returns a
|
|
104
|
-
branded runtime configuration; an arbitrary object cannot bypass the catalog.
|
|
105
|
-
|
|
106
|
-
~~~ts
|
|
107
|
-
import modelCatalogJson from "./model-catalog.json" with { type: "json" };
|
|
108
|
-
import { ModelCatalog } from "ezgraph";
|
|
109
|
-
|
|
110
|
-
const catalog = ModelCatalog.create(modelCatalogJson);
|
|
111
|
-
const llmConfig = catalog.model("openai:future-model", {
|
|
112
|
-
retries: 3,
|
|
113
|
-
reasoningEffort: "medium",
|
|
114
|
-
});
|
|
115
|
-
~~~
|
|
116
|
-
|
|
117
|
-
The complete JSON format is published as
|
|
118
|
-
`ezgraph/model-catalog.schema.json`. Built-in entries cannot be replaced by an
|
|
119
|
-
application catalog. A full node model configuration replaces the graph model;
|
|
120
|
-
`{ params: { temperature: 0.5 } }` patches the current model and `null` removes
|
|
121
|
-
an inherited optional parameter.
|
|
122
|
-
|
|
123
|
-
Providers absent from EZGraph and LangChain require application code because
|
|
124
|
-
JSON cannot safely contain constructors or credentials. Register an initializer
|
|
125
|
-
and pass the registry when creating the catalog:
|
|
126
|
-
|
|
127
|
-
~~~ts
|
|
128
|
-
import { ModelCatalog, ModelProviderRegistry } from "ezgraph";
|
|
129
|
-
|
|
130
|
-
const providers = ModelProviderRegistry.create().register("glm", {
|
|
131
|
-
initialize({ model, options }) {
|
|
132
|
-
return {
|
|
133
|
-
model,
|
|
134
|
-
options: {
|
|
135
|
-
modelProvider: "openai",
|
|
136
|
-
...options,
|
|
137
|
-
apiKey: process.env.GLM_API_KEY,
|
|
138
|
-
configuration: { baseURL: "https://api.z.ai/api/paas/v4" },
|
|
139
|
-
},
|
|
140
|
-
cacheKey: JSON.stringify({ provider: "glm", model, options }),
|
|
141
|
-
};
|
|
142
|
-
},
|
|
66
|
+
graphName: "WeatherGraph",
|
|
67
|
+
sessionId: "customer-123",
|
|
68
|
+
userMessage: "I need the weather in Seattle",
|
|
143
69
|
});
|
|
144
70
|
|
|
145
|
-
|
|
146
|
-
|
|
71
|
+
// { status, body, session }
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`GraphEngine.create()` reads `.env` and process environment values. Model
|
|
75
|
+
credentials stay with the provider you configure; EZGraph does not require an
|
|
76
|
+
EZGraph account or runtime key.
|
|
77
|
+
|
|
78
|
+
For a complete two-stage graph, including state, a tool handler, explicit
|
|
79
|
+
outcomes, and graph registration, follow the
|
|
80
|
+
[Get started tutorial](https://www.picoflow.io/ezgraph/tutorial/).
|
|
81
|
+
|
|
82
|
+
## Persistence and configuration
|
|
83
|
+
|
|
84
|
+
The default `SESSION_STORE=memory` is useful for local development. Select a
|
|
85
|
+
durable store when conversations must resume across process restarts or
|
|
86
|
+
instances:
|
|
87
|
+
|
|
88
|
+
```dotenv
|
|
89
|
+
# memory (default), sqlite, mongodb, or cosmos
|
|
90
|
+
SESSION_STORE=sqlite
|
|
91
|
+
SQLITE_DB_PATH=./data/sessions.sqlite
|
|
92
|
+
|
|
93
|
+
# Set the credential for the model provider you use.
|
|
94
|
+
OPENAI_API_KEY=...
|
|
95
|
+
```
|
|
147
96
|
|
|
148
|
-
|
|
149
|
-
|
|
97
|
+
For MongoDB, configure `MONGODB_URL`, `MONGODB_NAME`, and
|
|
98
|
+
`MONGODB_COLLECTION`. For Cosmos DB, use the Cosmos settings described in the
|
|
99
|
+
[developer guide](https://www.picoflow.io/ezgraph/docs/developer-guide/).
|
|
150
100
|
|
|
151
|
-
|
|
101
|
+
The [EZGraph demo application](https://github.com/picoflowio/ezgraph-demo)
|
|
102
|
+
shows a NestJS + Fastify service with QuoteGraph, a LangGraph comparison, and a
|
|
103
|
+
copyable [`.env.example`](https://github.com/picoflowio/ezgraph-demo/blob/main/.env.example).
|
|
152
104
|
|
|
153
|
-
|
|
105
|
+
## Learn more
|
|
154
106
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
~~~
|
|
107
|
+
- [Get started tutorial](https://www.picoflow.io/ezgraph/tutorial/)
|
|
108
|
+
- [Developer guide](https://www.picoflow.io/ezgraph/docs/developer-guide/)
|
|
109
|
+
- [QuoteGraph walkthrough](https://www.picoflow.io/ezgraph/quote-graph/)
|
|
110
|
+
- [EZGraph compared with direct LangGraph](https://www.picoflow.io/ezgraph/compare/langgraph/)
|
|
160
111
|
|
|
161
|
-
|
|
162
|
-
is minified, keeps public runtime names, and deliberately contains no source
|
|
163
|
-
map or source files. `build:locallib` creates `staging/lib`, a local-only package
|
|
164
|
-
that retains the framework TypeScript source and an unbundled, source-mapped
|
|
165
|
-
runtime for debugging through the sibling demo. Re-run `build:locallib` after
|
|
166
|
-
framework changes.
|
|
112
|
+
## License
|
|
167
113
|
|
|
168
|
-
|
|
114
|
+
EZGraph is proprietary software distributed under the
|
|
115
|
+
[EZGraph Commercial Runtime License](https://www.picoflow.io/ezgraph/license/).
|
|
116
|
+
Personal use, commercial SaaS, internal enterprise production, client work,
|
|
117
|
+
and closed-source applications are permitted with no EZGraph runtime fee or
|
|
118
|
+
license key. Optional support is separate; an active support subscription
|
|
119
|
+
includes the private source and debug package.
|
|
169
120
|
|
|
170
|
-
|
|
171
|
-
|
|
121
|
+
See the [license page](https://www.picoflow.io/ezgraph/license/) for the
|
|
122
|
+
applicable production-use terms.
|