@picoflow/ezgraph 0.0.4
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.md +17 -0
- package/README.md +171 -0
- package/dist/framework/base-graph.js +1 -0
- package/dist/framework/config-manager.js +1 -0
- package/dist/framework/conversation-node.js +1 -0
- package/dist/framework/conversation-runner.js +1 -0
- package/dist/framework/conversation-tool-result.js +1 -0
- package/dist/framework/graph-engine.js +1 -0
- package/dist/framework/graph-llm.config.js +1 -0
- package/dist/framework/graph-node.js +1 -0
- package/dist/framework/graph-registry.js +1 -0
- package/dist/framework/graph-state-support.js +1 -0
- package/dist/framework/graph-state.js +1 -0
- package/dist/framework/json-response.js +1 -0
- package/dist/framework/langchain-llm-gateway.js +1 -0
- package/dist/framework/langchain-provider.adapter.js +1 -0
- package/dist/framework/llm-file.js +1 -0
- package/dist/framework/llm-gateway.js +1 -0
- package/dist/framework/model-catalog.js +1 -0
- package/dist/framework/model-provider.js +1 -0
- package/dist/framework/model-stop-reason.js +1 -0
- package/dist/framework/node-outcome.js +1 -0
- package/dist/framework/node-state.js +1 -0
- package/dist/framework/persistence/cosmos-session-document.container.js +1 -0
- package/dist/framework/persistence/mongodb-session-document.container.js +1 -0
- package/dist/framework/persistence/session-manager.js +1 -0
- package/dist/framework/persistence/sqlite-session-document.container.js +13 -0
- package/dist/framework/session-log.js +1 -0
- package/dist/framework/stable-id.js +1 -0
- package/dist/framework/state-graph-ext.js +1 -0
- package/dist/framework/terminate-session.node.js +1 -0
- package/dist/framework/token-usage.js +1 -0
- package/dist/framework/turn-context.js +1 -0
- package/dist/index.js +1 -0
- package/dist/testing/scripted-gateway.js +1 -0
- package/dist/testing/turn-harness.js +1 -0
- package/dist/testing.js +1 -0
- package/dist/types/npmlib/src/index.d.ts +27 -0
- package/dist/types/npmlib/src/testing.d.ts +2 -0
- package/dist/types/src/framework/base-graph.d.ts +66 -0
- package/dist/types/src/framework/config-manager.d.ts +13 -0
- package/dist/types/src/framework/conversation-node.d.ts +18 -0
- package/dist/types/src/framework/conversation-runner.d.ts +49 -0
- package/dist/types/src/framework/conversation-tool-result.d.ts +19 -0
- package/dist/types/src/framework/graph-engine.d.ts +82 -0
- package/dist/types/src/framework/graph-llm.config.d.ts +21 -0
- package/dist/types/src/framework/graph-node.d.ts +106 -0
- package/dist/types/src/framework/graph-registry.d.ts +26 -0
- package/dist/types/src/framework/graph-state-support.d.ts +24 -0
- package/dist/types/src/framework/graph-state.d.ts +26 -0
- package/dist/types/src/framework/json-response.d.ts +1 -0
- package/dist/types/src/framework/langchain-llm-gateway.d.ts +23 -0
- package/dist/types/src/framework/langchain-provider.adapter.d.ts +4 -0
- package/dist/types/src/framework/llm-file.d.ts +13 -0
- package/dist/types/src/framework/llm-gateway.d.ts +27 -0
- package/dist/types/src/framework/model-catalog.d.ts +252 -0
- package/dist/types/src/framework/model-provider.d.ts +19 -0
- package/dist/types/src/framework/model-stop-reason.d.ts +11 -0
- package/dist/types/src/framework/node-outcome.d.ts +41 -0
- package/dist/types/src/framework/node-state.d.ts +6 -0
- package/dist/types/src/framework/persistence/cosmos-session-document.container.d.ts +34 -0
- package/dist/types/src/framework/persistence/mongodb-session-document.container.d.ts +18 -0
- package/dist/types/src/framework/persistence/session-manager.d.ts +116 -0
- package/dist/types/src/framework/persistence/sqlite-session-document.container.d.ts +19 -0
- package/dist/types/src/framework/session-log.d.ts +11 -0
- package/dist/types/src/framework/stable-id.d.ts +7 -0
- package/dist/types/src/framework/state-graph-ext.d.ts +58 -0
- package/dist/types/src/framework/terminate-session.node.d.ts +9 -0
- package/dist/types/src/framework/token-usage.d.ts +24 -0
- package/dist/types/src/framework/turn-context.d.ts +7 -0
- package/dist/types/src/testing/scripted-gateway.d.ts +45 -0
- package/dist/types/src/testing/turn-harness.d.ts +35 -0
- package/model-catalog.schema.json +57 -0
- package/package.json +64 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AIMessage, type BaseMessage } from '@langchain/core/messages';
|
|
2
|
+
import type { ZodType } from 'zod';
|
|
3
|
+
import { type GraphLlmConfig } from '../framework/graph-llm.config.js';
|
|
4
|
+
import type { LlmCallOptions, LlmGateway, LlmGatewayTool, LlmGatewayToolCall } from '../framework/llm-gateway.js';
|
|
5
|
+
import { type ModelResult, type TokenUsage } from '../framework/token-usage.js';
|
|
6
|
+
export declare const SCRIPTED_MODEL: GraphLlmConfig;
|
|
7
|
+
export declare const SCRIPTED_TOKEN_USAGE: TokenUsage;
|
|
8
|
+
export type ScriptedCall = Readonly<{
|
|
9
|
+
method: 'structured' | 'generate' | 'respond' | 'agent' | 'toolCall';
|
|
10
|
+
systemPrompt: string;
|
|
11
|
+
history: readonly BaseMessage[];
|
|
12
|
+
tools: readonly string[];
|
|
13
|
+
llmConfig?: GraphLlmConfig | undefined;
|
|
14
|
+
callOptions?: LlmCallOptions | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
export declare class ScriptedGateway implements LlmGateway {
|
|
17
|
+
private readonly turns;
|
|
18
|
+
private consumed;
|
|
19
|
+
readonly calls: ScriptedCall[];
|
|
20
|
+
text(text: string): this;
|
|
21
|
+
callsTool(name: string, args?: Record<string, unknown>, id?: string): this;
|
|
22
|
+
callsTools(calls: readonly {
|
|
23
|
+
name: string;
|
|
24
|
+
args?: Record<string, unknown>;
|
|
25
|
+
id?: string;
|
|
26
|
+
}[]): this;
|
|
27
|
+
structuredResult(value: Record<string, unknown>): this;
|
|
28
|
+
toolDecision(call: LlmGatewayToolCall | undefined): this;
|
|
29
|
+
empty(finishReason?: string): this;
|
|
30
|
+
fail(error: Error | string): this;
|
|
31
|
+
repeat(times: number, declare: (gateway: this) => this): this;
|
|
32
|
+
get drained(): boolean;
|
|
33
|
+
get remaining(): number;
|
|
34
|
+
structured<T extends Record<string, unknown>>(_schema: ZodType<T>, systemPrompt: string, input: string, name: string, llmConfig?: GraphLlmConfig, history?: readonly BaseMessage[], callOptions?: LlmCallOptions): Promise<ModelResult<T>>;
|
|
35
|
+
generate(systemPrompt: string, userPrompt: string, llmConfig?: GraphLlmConfig, callOptions?: LlmCallOptions): Promise<ModelResult<string>>;
|
|
36
|
+
respond(systemPrompt: string, history: readonly BaseMessage[], llmConfig?: GraphLlmConfig, callOptions?: LlmCallOptions): Promise<ModelResult<string>>;
|
|
37
|
+
agent(systemPrompt: string, history: readonly BaseMessage[], tools: readonly LlmGatewayTool[], llmConfig?: GraphLlmConfig, callOptions?: LlmCallOptions): Promise<ModelResult<AIMessage>>;
|
|
38
|
+
toolCall(systemPrompt: string, userPrompt: string, tools: readonly LlmGatewayTool[], llmConfig?: GraphLlmConfig, history?: readonly BaseMessage[], callOptions?: LlmCallOptions): Promise<ModelResult<LlmGatewayToolCall | undefined>>;
|
|
39
|
+
private record;
|
|
40
|
+
private takeText;
|
|
41
|
+
private take;
|
|
42
|
+
private mismatch;
|
|
43
|
+
private result;
|
|
44
|
+
}
|
|
45
|
+
export declare function scriptedGateway(): ScriptedGateway;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { GraphEngine, type GraphConstructor, type RunResult } from '../framework/graph-engine.js';
|
|
2
|
+
import type { GraphState } from '../framework/graph-state.js';
|
|
3
|
+
import type { LlmGateway } from '../framework/llm-gateway.js';
|
|
4
|
+
import type { SessionLogs } from '../framework/session-log.js';
|
|
5
|
+
import { SessionManager, type SessionDocument } from '../framework/persistence/session-manager.js';
|
|
6
|
+
export type HarnessTurn<State extends GraphState> = Readonly<{
|
|
7
|
+
status: number;
|
|
8
|
+
session: string;
|
|
9
|
+
response: string;
|
|
10
|
+
completed: boolean;
|
|
11
|
+
code?: string;
|
|
12
|
+
body: RunResult['body'];
|
|
13
|
+
contentType?: 'application/json';
|
|
14
|
+
document?: SessionDocument<State>;
|
|
15
|
+
state?: State;
|
|
16
|
+
currentNode?: State['currentNode'];
|
|
17
|
+
warnings: SessionLogs['warnings'];
|
|
18
|
+
errors: SessionLogs['errors'];
|
|
19
|
+
}>;
|
|
20
|
+
export type TurnHarness<State extends GraphState> = Readonly<{
|
|
21
|
+
session: string;
|
|
22
|
+
engine: GraphEngine;
|
|
23
|
+
send: (userMessage?: string, options?: Readonly<{
|
|
24
|
+
config?: Record<string, unknown>;
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}>) => Promise<HarnessTurn<State>>;
|
|
27
|
+
document: () => Promise<SessionDocument<State> | undefined>;
|
|
28
|
+
close: () => Promise<void>;
|
|
29
|
+
}>;
|
|
30
|
+
export declare function createTurnHarness<State extends GraphState = GraphState>(options: Readonly<{
|
|
31
|
+
graph: GraphConstructor;
|
|
32
|
+
gateway?: LlmGateway;
|
|
33
|
+
sessionManager?: SessionManager;
|
|
34
|
+
sessionId?: string;
|
|
35
|
+
}>): TurnHarness<State>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://ezgraph.dev/schemas/model-catalog-v1.json",
|
|
4
|
+
"title": "EZGraph model catalog",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["version", "models"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"$schema": { "type": "string", "minLength": 1 },
|
|
10
|
+
"version": { "const": 1 },
|
|
11
|
+
"profiles": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"additionalProperties": { "$ref": "#/$defs/profile" }
|
|
14
|
+
},
|
|
15
|
+
"models": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"additionalProperties": { "$ref": "#/$defs/model" }
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"$defs": {
|
|
21
|
+
"profile": {
|
|
22
|
+
"type": "object",
|
|
23
|
+
"additionalProperties": false,
|
|
24
|
+
"required": ["provider", "family", "paramsSchema", "parameterMappings"],
|
|
25
|
+
"properties": {
|
|
26
|
+
"provider": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"pattern": "^[a-z][a-z0-9_-]*$"
|
|
29
|
+
},
|
|
30
|
+
"family": { "enum": ["chat", "reasoning", "thinking"] },
|
|
31
|
+
"paramsSchema": {
|
|
32
|
+
"type": "object",
|
|
33
|
+
"description": "JSON Schema for the complete params object."
|
|
34
|
+
},
|
|
35
|
+
"parameterMappings": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"description": "Parameter-to-LangChain paths; null denotes EZGraph policy.",
|
|
38
|
+
"additionalProperties": {
|
|
39
|
+
"oneOf": [
|
|
40
|
+
{ "type": "string", "minLength": 1 },
|
|
41
|
+
{ "type": "null" }
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"model": {
|
|
48
|
+
"type": "object",
|
|
49
|
+
"additionalProperties": false,
|
|
50
|
+
"required": ["profile"],
|
|
51
|
+
"properties": {
|
|
52
|
+
"profile": { "type": "string", "minLength": 1 },
|
|
53
|
+
"providerModel": { "type": "string", "minLength": 1 }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@picoflow/ezgraph",
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"description": "Provider-neutral graph primitives built on LangGraph and LangChain.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/types/npmlib/src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/types/npmlib/src/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./testing": {
|
|
15
|
+
"types": "./dist/types/npmlib/src/testing.d.ts",
|
|
16
|
+
"import": "./dist/testing.js",
|
|
17
|
+
"default": "./dist/testing.js"
|
|
18
|
+
},
|
|
19
|
+
"./model-catalog.schema.json": "./model-catalog.schema.json"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE.md",
|
|
25
|
+
"model-catalog.schema.json"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=22.5"
|
|
29
|
+
},
|
|
30
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@anthropic-ai/sdk": "0.115.0",
|
|
36
|
+
"@azure/cosmos": "4.10.0",
|
|
37
|
+
"@azure/identity": "4.13.1",
|
|
38
|
+
"@google/genai": "2.14.0",
|
|
39
|
+
"dotenv": "17.4.2",
|
|
40
|
+
"@langchain/core": "1.2.3",
|
|
41
|
+
"@langchain/langgraph": "1.4.8",
|
|
42
|
+
"langchain": "1.5.4",
|
|
43
|
+
"mongodb": "6.21.0",
|
|
44
|
+
"openai": "7.1.0",
|
|
45
|
+
"reflect-metadata": "0.2.2",
|
|
46
|
+
"zod": "4.4.3"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@langchain/anthropic": ">=1.5.2",
|
|
50
|
+
"@langchain/google": ">=0.2.1",
|
|
51
|
+
"@langchain/openai": ">=1.5.5"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"@langchain/anthropic": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"@langchain/google": {
|
|
58
|
+
"optional": true
|
|
59
|
+
},
|
|
60
|
+
"@langchain/openai": {
|
|
61
|
+
"optional": true
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|