@picoflow/ezgraph 0.0.5 → 0.0.7
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 +174 -68
- package/dist/framework/base-graph.js +1 -1
- package/dist/framework/conversation-node.js +1 -1
- package/dist/framework/conversation-runner.js +1 -1
- package/dist/framework/graph-engine.js +1 -1
- package/dist/framework/graph-node.js +1 -1
- package/dist/framework/graph-state.js +1 -1
- package/dist/framework/langchain-llm-gateway.js +1 -1
- package/dist/framework/langchain-provider.adapter.js +1 -1
- package/dist/framework/model-catalog.js +1 -1
- package/dist/framework/node-invocation.js +1 -0
- package/dist/framework/node-outcome.js +1 -1
- package/dist/framework/node-state.js +1 -1
- package/dist/framework/openai-auth-provider.js +4 -0
- package/dist/framework/persistence/session-manager.js +1 -1
- package/dist/framework/state-graph-ext.js +1 -1
- package/dist/framework/tool-response.js +1 -0
- package/dist/index.js +1 -1
- package/dist/types/npmlib/src/index.d.ts +5 -5
- package/dist/types/src/framework/base-graph.d.ts +8 -0
- package/dist/types/src/framework/conversation-node.d.ts +8 -14
- package/dist/types/src/framework/conversation-runner.d.ts +3 -3
- package/dist/types/src/framework/graph-llm.config.d.ts +1 -1
- package/dist/types/src/framework/graph-node.d.ts +24 -21
- package/dist/types/src/framework/graph-registry.d.ts +3 -0
- package/dist/types/src/framework/graph-state.d.ts +0 -2
- package/dist/types/src/framework/model-catalog.d.ts +20 -1
- package/dist/types/src/framework/node-invocation.d.ts +12 -0
- package/dist/types/src/framework/node-outcome.d.ts +1 -30
- package/dist/types/src/framework/node-state.d.ts +2 -1
- package/dist/types/src/framework/openai-auth-provider.d.ts +12 -0
- package/dist/types/src/framework/persistence/session-manager.d.ts +1 -0
- package/dist/types/src/framework/state-graph-ext.d.ts +2 -8
- package/dist/types/src/framework/tool-response.d.ts +25 -0
- package/package.json +1 -1
- package/dist/framework/conversation-tool-result.js +0 -1
- package/dist/types/src/framework/conversation-tool-result.d.ts +0 -19
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const GRAPH_LLM_PROVIDERS: readonly ["openai", "anthropic", "google", "azure_openai", "bedrock", "ollama", "cohere", "cerebras", "deepseek", "fireworks", "groq", "mistral", "mistralai", "perplexity", "together", "xai", "scripted"];
|
|
2
|
+
export declare const GRAPH_LLM_PROVIDERS: readonly ["openai", "openai-auth", "anthropic", "google", "azure_openai", "bedrock", "ollama", "cohere", "cerebras", "deepseek", "fireworks", "groq", "mistral", "mistralai", "perplexity", "together", "xai", "scripted"];
|
|
3
3
|
export type GraphLlmProvider = (typeof GRAPH_LLM_PROVIDERS)[number];
|
|
4
4
|
export declare const GRAPH_LLM_FAMILIES: readonly ["chat", "reasoning", "thinking"];
|
|
5
5
|
export type GraphLlmFamily = (typeof GRAPH_LLM_FAMILIES)[number];
|
|
@@ -22,6 +22,9 @@ export type OpenAIReasoningParameters = CommonModelParameters & Readonly<{
|
|
|
22
22
|
serviceTier?: "auto" | "default" | "flex" | "priority";
|
|
23
23
|
promptCacheKey?: string;
|
|
24
24
|
}>;
|
|
25
|
+
export type OpenAIAuthReasoningParameters = CommonModelParameters & Readonly<{
|
|
26
|
+
reasoningEffort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
27
|
+
}>;
|
|
25
28
|
export type AnthropicChatParameters = CommonModelParameters & Readonly<{
|
|
26
29
|
temperature?: number;
|
|
27
30
|
outputEffort?: "low" | "medium" | "high" | "xhigh" | "max";
|
|
@@ -54,6 +57,7 @@ export type BuiltInModelParameters = Readonly<{
|
|
|
54
57
|
"openai:gpt-4o-mini": OpenAIChatParameters;
|
|
55
58
|
"openai:gpt-5.1": OpenAIReasoningParameters;
|
|
56
59
|
"openai:gpt-5.4": OpenAIReasoningParameters;
|
|
60
|
+
"openai-auth:gpt-5.4": OpenAIAuthReasoningParameters;
|
|
57
61
|
"anthropic:claude-sonnet-4-5": AnthropicChatParameters;
|
|
58
62
|
"anthropic:claude-opus-4-1": AnthropicThinkingParameters;
|
|
59
63
|
"google:gemini-3.1-flash-lite": GoogleChatParameters;
|
|
@@ -150,6 +154,18 @@ export declare const BUILT_IN_MODEL_CATALOG: {
|
|
|
150
154
|
readonly requiredCapabilities: null;
|
|
151
155
|
};
|
|
152
156
|
};
|
|
157
|
+
readonly "openai-auth.reasoning": {
|
|
158
|
+
readonly provider: "openai-auth";
|
|
159
|
+
readonly family: "reasoning";
|
|
160
|
+
readonly paramsSchema: Record<string, unknown>;
|
|
161
|
+
readonly parameterMappings: {
|
|
162
|
+
readonly maxOutputTokens: "maxTokens";
|
|
163
|
+
readonly reasoningEffort: "reasoningEffort";
|
|
164
|
+
readonly retries: "maxRetries";
|
|
165
|
+
readonly forceToolCalls: null;
|
|
166
|
+
readonly requiredCapabilities: null;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
153
169
|
readonly "anthropic.chat": {
|
|
154
170
|
readonly provider: "anthropic";
|
|
155
171
|
readonly family: "chat";
|
|
@@ -217,6 +233,9 @@ export declare const BUILT_IN_MODEL_CATALOG: {
|
|
|
217
233
|
readonly "openai:gpt-5.4": {
|
|
218
234
|
readonly profile: "openai.reasoning";
|
|
219
235
|
};
|
|
236
|
+
readonly "openai-auth:gpt-5.4": {
|
|
237
|
+
readonly profile: "openai-auth.reasoning";
|
|
238
|
+
};
|
|
220
239
|
readonly "anthropic:claude-sonnet-4-5": {
|
|
221
240
|
readonly profile: "anthropic.chat";
|
|
222
241
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
2
|
+
import type { GraphState } from './graph-state.js';
|
|
3
|
+
export declare function hasNodeInvocation(owner: object): boolean;
|
|
4
|
+
export declare function withNodeInvocation<State extends GraphState, Result>(owner: object, nodeId: string, state: State, run: () => Promise<Result>): Promise<Result>;
|
|
5
|
+
export declare function invocationNodeId(owner: object): string;
|
|
6
|
+
export declare function invocationNodeState(owner: object, nodeId: string): Record<string, unknown>;
|
|
7
|
+
export declare function saveInvocationNodeState(owner: object, nodeId: string, patch: Record<string, unknown>): void;
|
|
8
|
+
export declare function replaceInvocationNodeState(owner: object, nodeId: string, value: Record<string, unknown>): void;
|
|
9
|
+
export declare function appendInvocationHistory(owner: object, space: string, messages: readonly BaseMessage[]): void;
|
|
10
|
+
export declare function invocationHistory(owner: object, space: string): BaseMessage[];
|
|
11
|
+
export declare function invocationGraphState<State extends GraphState>(owner: object): State;
|
|
12
|
+
export declare function invocationUpdate<State extends GraphState>(owner: object): Partial<State>;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { HumanMessage, type BaseMessage } from '@langchain/core/messages';
|
|
2
|
-
import { END } from '@langchain/langgraph';
|
|
3
1
|
import type { GraphState } from './graph-state.js';
|
|
4
2
|
export declare const GRAPH_NODE_LOCAL_STATE: unique symbol;
|
|
5
3
|
export type GraphNodeTarget<LocalState extends object = object> = {
|
|
@@ -11,31 +9,4 @@ export type GraphNodeTarget<LocalState extends object = object> = {
|
|
|
11
9
|
};
|
|
12
10
|
export type GraphNodeLocalState<NodeClass extends GraphNodeTarget> = NodeClass['prototype'][typeof GRAPH_NODE_LOCAL_STATE];
|
|
13
11
|
export type GraphNodeUpdate<State extends GraphState> = Partial<State>;
|
|
14
|
-
export
|
|
15
|
-
export declare const OUTCOME_ROUTE_TARGET: unique symbol;
|
|
16
|
-
type OutcomeState<State extends GraphState> = Pick<State, 'histories' | 'currentNode'>;
|
|
17
|
-
export type NodeOutcomeBuilder<State extends GraphState, LocalState extends object, CanForwardInput extends boolean = false> = Readonly<GraphNodeUpdate<State>> & {
|
|
18
|
-
withState(patch: Partial<LocalState>): NodeOutcomeBuilder<State, LocalState, CanForwardInput>;
|
|
19
|
-
withStateFor<NodeClass extends GraphNodeTarget>(NodeClass: NodeClass, patch: Partial<GraphNodeLocalState<NodeClass>>): NodeOutcomeBuilder<State, LocalState, CanForwardInput>;
|
|
20
|
-
withHistory(space: string, messages: BaseMessage | readonly BaseMessage[]): NodeOutcomeBuilder<State, LocalState, CanForwardInput>;
|
|
21
|
-
via<NodeClass extends GraphNodeTarget>(NodeClass: NodeClass): NodeOutcomeBuilder<State, LocalState, CanForwardInput>;
|
|
22
|
-
} & (CanForwardInput extends true ? {
|
|
23
|
-
forwardInput(state: OutcomeState<State>, fallbackMessage?: string): NodeOutcomeBuilder<State, LocalState>;
|
|
24
|
-
} : object);
|
|
25
|
-
type BuilderOptions<State extends GraphState, LocalState extends object, CanForwardInput extends boolean> = Readonly<{
|
|
26
|
-
update: GraphNodeUpdate<State>;
|
|
27
|
-
nodeName: string;
|
|
28
|
-
saveNode: (nodeName: string, patch: Record<string, unknown>) => GraphNodeUpdate<State>;
|
|
29
|
-
forwardInput?: (state: OutcomeState<State>, fallbackMessage?: string) => GraphNodeUpdate<State>;
|
|
30
|
-
routeTarget: OutcomeRouteTarget;
|
|
31
|
-
}>;
|
|
32
|
-
export declare function createNodeOutcomeBuilder<State extends GraphState, LocalState extends object, CanForwardInput extends boolean>(options: BuilderOptions<State, LocalState, CanForwardInput>): NodeOutcomeBuilder<State, LocalState, CanForwardInput>;
|
|
33
|
-
export declare function outcomeRouteTarget(update: GraphNodeUpdate<GraphState>): OutcomeRouteTarget | undefined;
|
|
34
|
-
export declare function preserveOutcomeRouteTarget<State extends GraphState, Update extends GraphNodeUpdate<State>>(source: GraphNodeUpdate<State>, update: Update): Update;
|
|
35
|
-
export declare function forwardedHistoryUpdate<State extends GraphState>(options: {
|
|
36
|
-
sourceSpace: string;
|
|
37
|
-
targetSpace: string;
|
|
38
|
-
latestInput?: HumanMessage;
|
|
39
|
-
fallbackMessage?: string;
|
|
40
|
-
}): GraphNodeUpdate<State>;
|
|
41
|
-
export {};
|
|
12
|
+
export declare function combineGraphNodeUpdates<State extends GraphState>(current: GraphNodeUpdate<State>, addition: GraphNodeUpdate<State>): GraphNodeUpdate<State>;
|
|
@@ -3,4 +3,5 @@ export type NodeStateValue<T extends object = Record<string, unknown>> = T & {
|
|
|
3
3
|
model?: GraphLlmModelMetadata | undefined;
|
|
4
4
|
};
|
|
5
5
|
export type GraphNodeStates = Record<string, NodeStateValue>;
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function replaceNodeStates<NodeStates extends object>(current: NodeStates, update: Partial<NodeStates>): NodeStates;
|
|
7
|
+
export declare const mergeNodeStates: typeof replaceNodeStates;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GraphLlmConfig, ModelProviderInitialization } from './graph-llm.config.js';
|
|
2
|
+
export declare const OPENAI_AUTH_PROVIDER = "openai-auth";
|
|
3
|
+
export type OpenAIAuthCredentials = Readonly<{
|
|
4
|
+
accessToken: string;
|
|
5
|
+
accountId?: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function initializeOpenAIAuthProvider(model: string, options: Readonly<Record<string, unknown>>): ModelProviderInitialization;
|
|
8
|
+
export declare function isOpenAIAuthConfig(config: GraphLlmConfig): boolean;
|
|
9
|
+
export declare function openAIAuthMessageText(content: unknown): string;
|
|
10
|
+
export declare function openAIAuthFile(): string;
|
|
11
|
+
export declare function readOpenAIAuthCredentials(authFile?: string): OpenAIAuthCredentials;
|
|
12
|
+
export declare function normalizeOpenAIAuthResponsesRequest(request: Request): Promise<Request>;
|
|
@@ -33,6 +33,7 @@ export type BeginTurnResult<State extends GraphState = GraphState> = Readonly<{
|
|
|
33
33
|
export type SessionWriteOptions = Readonly<{
|
|
34
34
|
owner?: string;
|
|
35
35
|
expectedRevision?: number;
|
|
36
|
+
keepTurn?: boolean;
|
|
36
37
|
}>;
|
|
37
38
|
export type SessionGraphStatus = 'in_progress' | 'completed' | 'error';
|
|
38
39
|
export type SessionGraphDocument<State extends GraphState = GraphState> = {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { END, type ExtractStateType, type ExtractUpdateType, START, type StateDefinitionInit } from '@langchain/langgraph';
|
|
1
|
+
import { type Command, END, type ExtractStateType, type ExtractUpdateType, START, type StateDefinitionInit } from '@langchain/langgraph';
|
|
2
2
|
import { GRAPH_NODE_CLASS } from './graph-node.js';
|
|
3
3
|
export type RegisteredNode<State, Update> = {
|
|
4
4
|
readonly id: string;
|
|
5
|
-
readonly invoke: (state: State) => Promise<Update
|
|
5
|
+
readonly invoke: (state: State) => Promise<Update | Command<unknown, Update & Record<string, unknown>, string>>;
|
|
6
6
|
route(state: State): string;
|
|
7
7
|
validateTools?(): void;
|
|
8
|
-
readonly supportsAutomaticOutcomeRouting?: boolean;
|
|
9
8
|
};
|
|
10
9
|
export type GraphNodeClass = {
|
|
11
10
|
readonly name: string;
|
|
@@ -33,10 +32,7 @@ export declare class StateGraphExt<StateDefinition extends StateDefinitionInit>
|
|
|
33
32
|
private readonly graph;
|
|
34
33
|
private readonly addedNodeIds;
|
|
35
34
|
private readonly nodeClasses;
|
|
36
|
-
private readonly explicitConditionalNodeIds;
|
|
37
35
|
private readonly nodeInstances;
|
|
38
|
-
private automaticOutcomeRoutingRequested;
|
|
39
|
-
private automaticOutcomeRoutesAdded;
|
|
40
36
|
constructor(state: StateDefinition, createGraphNode?: GraphNodeFactory<ExtractStateType<StateDefinition>, ExtractUpdateType<StateDefinition>> | undefined, endNode?: string);
|
|
41
37
|
addNode(NodeClass: GraphNodeClass): this;
|
|
42
38
|
nodes(...NodeClasses: readonly GraphNodeClass[]): this;
|
|
@@ -44,12 +40,10 @@ export declare class StateGraphExt<StateDefinition extends StateDefinitionInit>
|
|
|
44
40
|
addEdge(source: GraphEndpoint | readonly GraphEndpoint[], target: GraphEndpoint): this;
|
|
45
41
|
branch<NodeClass extends GraphNodeClass, Destinations extends Readonly<Record<RouteOf<NodeClass>, GraphEndpoint>>>(NodeClass: NodeClass, destinations: BranchDestinations<NodeClass, Destinations>): this;
|
|
46
42
|
branchBy(NodeClass: GraphNodeClass, options: CurrentNodeBranchOptions): this;
|
|
47
|
-
configAutoRoute(): this;
|
|
48
43
|
registerTurns(...NodeClasses: readonly GraphNodeClass[]): this;
|
|
49
44
|
compile(): import("@langchain/langgraph").CompiledStateGraph<ExtractStateType<StateDefinition, StateDefinition> extends infer T ? { [K in keyof T]: T[K]; } : never, ExtractUpdateType<StateDefinition, StateDefinition> extends infer T_1 ? { [K_1 in keyof T_1]: T_1[K_1]; } : never, string, StateDefinition extends import("@langchain/langgraph").AnyStateSchema ? StateDefinition : StateDefinition extends StateDefinitionInit ? import("@langchain/langgraph").ToStateDefinition<StateDefinition> : import("@langchain/langgraph").StateDefinition, StateDefinition extends import("@langchain/langgraph").AnyStateSchema ? StateDefinition : StateDefinition extends StateDefinitionInit ? import("@langchain/langgraph").ToStateDefinition<StateDefinition> : import("@langchain/langgraph").StateDefinition, import("@langchain/langgraph").StateDefinition, unknown, unknown, unknown, []>;
|
|
50
45
|
private addConditionalEdge;
|
|
51
46
|
private registerNode;
|
|
52
|
-
private addAutomaticOutcomeRoutes;
|
|
53
47
|
private assertSource;
|
|
54
48
|
private assertTarget;
|
|
55
49
|
private assertAddedNode;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
2
|
+
import type { GraphNodeLocalState, GraphNodeTarget } from './node-outcome.js';
|
|
3
|
+
export type ToolResponseKind = 'go' | 'stay' | 'direct' | 'finish';
|
|
4
|
+
export type ToolResponse = Readonly<{
|
|
5
|
+
kind: ToolResponseKind;
|
|
6
|
+
target?: GraphNodeTarget;
|
|
7
|
+
feedback?: string;
|
|
8
|
+
state?: Record<string, unknown>;
|
|
9
|
+
message?: BaseMessage;
|
|
10
|
+
messages?: readonly BaseMessage[];
|
|
11
|
+
cleanup?: () => Promise<void>;
|
|
12
|
+
response?: string;
|
|
13
|
+
}>;
|
|
14
|
+
export type ToolResponseBuilder<NodeClass extends GraphNodeTarget> = ToolResponse & {
|
|
15
|
+
withState(state: Partial<GraphNodeLocalState<NodeClass>>): ToolResponseBuilder<NodeClass>;
|
|
16
|
+
withMessage(message: BaseMessage): ToolResponseBuilder<NodeClass>;
|
|
17
|
+
withMessages(messages: readonly BaseMessage[]): ToolResponseBuilder<NodeClass>;
|
|
18
|
+
withCleanup(cleanup: () => Promise<void>): ToolResponseBuilder<NodeClass>;
|
|
19
|
+
withToolFeedback(feedback: string): ToolResponseBuilder<NodeClass>;
|
|
20
|
+
};
|
|
21
|
+
export declare function go<NodeClass extends GraphNodeTarget>(target: NodeClass): ToolResponseBuilder<NodeClass>;
|
|
22
|
+
export declare function stay(feedback?: string): ToolResponseBuilder<GraphNodeTarget>;
|
|
23
|
+
export declare function direct(content: string | object): ToolResponseBuilder<GraphNodeTarget>;
|
|
24
|
+
export declare function finish(content: string | object): ToolResponseBuilder<GraphNodeTarget>;
|
|
25
|
+
export declare function isToolResponse(value: unknown): value is ToolResponse;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var i=Object.defineProperty;var n=(o,t)=>i(o,"name",{value:t,configurable:!0});const u=Symbol("TOOL_RESULT_EFFECTS");function p(o){return l({output:o},{context:[],stops:[]})}n(p,"createConversationToolResult");function b(o,t){const s=o[u];if(!s)return o;for(const e of s.context){const r=typeof e=="function"?e(t):e;if(!r||typeof r!="object"||Array.isArray(r))throw new Error("withContext() must produce an object patch.");Object.assign(t,r)}const a=s.stops.some(e=>typeof e=="function"?e(t):e);return{...o,...a?{stopAfterBatch:!0}:{}}}n(b,"resolveConversationToolResult");function l(o,t){const s={...o},a=n((e,r=t)=>l({...o,...e},r),"derive");return Object.defineProperties(s,{[u]:{enumerable:!1,value:t},withContext:{enumerable:!1,value:n(e=>a({},{...t,context:[...t.context,e]}),"value")},withMessages:{enumerable:!1,value:n(e=>{const r=Array.isArray(e)?[...e]:[e];return a({messages:[...o.messages??[],...r]})},"value")},withCleanup:{enumerable:!1,value:n(e=>a({cleanup:e}),"value")},haltAfterBatch:{enumerable:!1,value:n(()=>a({},{...t,stops:[...t.stops,!0]}),"value")},stopAfterBatchWhen:{enumerable:!1,value:n(e=>a({},{...t,stops:[...t.stops,e]}),"value")}}),s}n(l,"createBuilder");export{p as createConversationToolResult,b as resolveConversationToolResult};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { BaseMessage } from '@langchain/core/messages';
|
|
2
|
-
export type ConversationToolResult = {
|
|
3
|
-
output: unknown;
|
|
4
|
-
messages?: BaseMessage[];
|
|
5
|
-
cleanup?: () => Promise<void>;
|
|
6
|
-
stopAfterBatch?: boolean;
|
|
7
|
-
};
|
|
8
|
-
type ContextEffect<Context extends object> = Partial<Context> | ((context: Readonly<Context>) => Partial<Context>);
|
|
9
|
-
type StopPredicate<Context extends object> = boolean | ((context: Readonly<Context>) => boolean);
|
|
10
|
-
export type ConversationToolResultBuilder<Context extends object> = ConversationToolResult & {
|
|
11
|
-
withContext(effect: ContextEffect<Context>): ConversationToolResultBuilder<Context>;
|
|
12
|
-
withMessages(messages: BaseMessage | readonly BaseMessage[]): ConversationToolResultBuilder<Context>;
|
|
13
|
-
withCleanup(cleanup: () => Promise<void>): ConversationToolResultBuilder<Context>;
|
|
14
|
-
haltAfterBatch(): ConversationToolResultBuilder<Context>;
|
|
15
|
-
stopAfterBatchWhen(predicate: StopPredicate<Context>): ConversationToolResultBuilder<Context>;
|
|
16
|
-
};
|
|
17
|
-
export declare function createConversationToolResult<Context extends object>(output: unknown): ConversationToolResultBuilder<Context>;
|
|
18
|
-
export declare function resolveConversationToolResult<Context extends object>(result: ConversationToolResult, context: Context): ConversationToolResult;
|
|
19
|
-
export {};
|