@picoflow/ezgraph 0.0.6 → 0.0.8
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 +247 -86
- 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/decision/decision-node.js +1 -0
- package/dist/framework/decision/decision-provider.js +1 -0
- package/dist/framework/decision/decision-runner.js +1 -0
- package/dist/framework/decision/decision-types.js +1 -0
- package/dist/framework/decision/decision-validation.js +1 -0
- package/dist/framework/decision/typesafe-provider.js +1 -0
- 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/node-invocation.js +1 -0
- package/dist/framework/node-outcome.js +1 -1
- package/dist/framework/node-state.js +1 -1
- package/dist/framework/persistence/session-manager.js +1 -1
- package/dist/framework/session-log.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/testing/scripted-decisions.js +1 -0
- package/dist/testing/turn-harness.js +1 -1
- package/dist/testing.js +1 -1
- package/dist/types/npmlib/src/index.d.ts +11 -5
- package/dist/types/npmlib/src/testing.d.ts +1 -0
- package/dist/types/src/framework/base-graph.d.ts +28 -14
- package/dist/types/src/framework/conversation-node.d.ts +9 -15
- package/dist/types/src/framework/conversation-runner.d.ts +9 -9
- package/dist/types/src/framework/decision/decision-node.d.ts +17 -0
- package/dist/types/src/framework/decision/decision-provider.d.ts +14 -0
- package/dist/types/src/framework/decision/decision-runner.d.ts +18 -0
- package/dist/types/src/framework/decision/decision-types.d.ts +126 -0
- package/dist/types/src/framework/decision/decision-validation.d.ts +4 -0
- package/dist/types/src/framework/decision/typesafe-provider.d.ts +12 -0
- package/dist/types/src/framework/graph-engine.d.ts +4 -0
- package/dist/types/src/framework/graph-llm.config.d.ts +3 -3
- package/dist/types/src/framework/graph-node.d.ts +51 -36
- package/dist/types/src/framework/graph-registry.d.ts +10 -5
- package/dist/types/src/framework/graph-state-support.d.ts +1 -1
- package/dist/types/src/framework/graph-state.d.ts +6 -5
- package/dist/types/src/framework/langchain-provider.adapter.d.ts +2 -2
- package/dist/types/src/framework/llm-gateway.d.ts +4 -4
- package/dist/types/src/framework/model-stop-reason.d.ts +2 -2
- package/dist/types/src/framework/node-invocation.d.ts +12 -0
- package/dist/types/src/framework/node-outcome.d.ts +3 -32
- package/dist/types/src/framework/node-state.d.ts +3 -2
- package/dist/types/src/framework/openai-auth-provider.d.ts +1 -1
- package/dist/types/src/framework/persistence/session-manager.d.ts +4 -0
- package/dist/types/src/framework/session-log.d.ts +30 -0
- package/dist/types/src/framework/state-graph-ext.d.ts +4 -10
- package/dist/types/src/framework/token-usage.d.ts +2 -2
- package/dist/types/src/framework/tool-response.d.ts +29 -0
- package/dist/types/src/testing/scripted-decisions.d.ts +24 -0
- package/dist/types/src/testing/turn-harness.d.ts +2 -0
- package/package.json +11 -7
- package/dist/framework/conversation-tool-result.js +0 -1
- package/dist/types/src/framework/conversation-tool-result.d.ts +0 -19
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ZodType } from
|
|
2
|
-
import type { AIMessage, BaseMessage } from
|
|
3
|
-
import type { GraphLlmConfig } from
|
|
4
|
-
import type { ModelResult } from
|
|
1
|
+
import type { ZodType } from "zod";
|
|
2
|
+
import type { AIMessage, BaseMessage } from "@langchain/core/messages";
|
|
3
|
+
import type { GraphLlmConfig } from "./graph-llm.config.js";
|
|
4
|
+
import type { ModelResult } from "./token-usage.js";
|
|
5
5
|
export declare const LLM_GATEWAY_FACTORY: unique symbol;
|
|
6
6
|
export type LlmCallOptions = Readonly<{
|
|
7
7
|
signal?: AbortSignal;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AIMessage } from
|
|
2
|
-
export type ModelStopCategory =
|
|
1
|
+
import { AIMessage } from "@langchain/core/messages";
|
|
2
|
+
export type ModelStopCategory = "complete" | "blocked" | "truncated" | "malformed_tool_call" | "unspecified";
|
|
3
3
|
export type ModelStopReason = Readonly<{
|
|
4
4
|
category: ModelStopCategory;
|
|
5
5
|
provider?: string;
|
|
@@ -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,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { END } from '@langchain/langgraph';
|
|
3
|
-
import type { GraphState } from './graph-state.js';
|
|
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> = {
|
|
6
4
|
readonly name: string;
|
|
@@ -9,33 +7,6 @@ export type GraphNodeTarget<LocalState extends object = object> = {
|
|
|
9
7
|
readonly [GRAPH_NODE_LOCAL_STATE]: LocalState;
|
|
10
8
|
};
|
|
11
9
|
};
|
|
12
|
-
export type GraphNodeLocalState<NodeClass extends GraphNodeTarget> = NodeClass[
|
|
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>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { GraphLlmModelMetadata } from
|
|
1
|
+
import type { GraphLlmModelMetadata } from "./graph-llm.config.js";
|
|
2
2
|
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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GraphLlmConfig, ModelProviderInitialization } from
|
|
1
|
+
import type { GraphLlmConfig, ModelProviderInitialization } from "./graph-llm.config.js";
|
|
2
2
|
export declare const OPENAI_AUTH_PROVIDER = "openai-auth";
|
|
3
3
|
export type OpenAIAuthCredentials = Readonly<{
|
|
4
4
|
accessToken: string;
|
|
@@ -4,6 +4,7 @@ import { type GraphState } from '../graph-state.js';
|
|
|
4
4
|
import { type GraphLlmConfig, type GraphLlmModelMetadata } from '../graph-llm.config.js';
|
|
5
5
|
import { type SessionLogs } from '../session-log.js';
|
|
6
6
|
import { type TokenUsage } from '../token-usage.js';
|
|
7
|
+
import { type DecisionUsage } from '../decision/decision-types.js';
|
|
7
8
|
export declare const SESSION_DOCUMENT_VERSION = 16;
|
|
8
9
|
export declare const SESSION_BUSY = "SESSION_BUSY";
|
|
9
10
|
export declare const SESSION_CONFLICT = "SESSION_CONFLICT";
|
|
@@ -33,6 +34,7 @@ export type BeginTurnResult<State extends GraphState = GraphState> = Readonly<{
|
|
|
33
34
|
export type SessionWriteOptions = Readonly<{
|
|
34
35
|
owner?: string;
|
|
35
36
|
expectedRevision?: number;
|
|
37
|
+
keepTurn?: boolean;
|
|
36
38
|
}>;
|
|
37
39
|
export type SessionGraphStatus = 'in_progress' | 'completed' | 'error';
|
|
38
40
|
export type SessionGraphDocument<State extends GraphState = GraphState> = {
|
|
@@ -50,8 +52,10 @@ export type SessionDocument<State extends GraphState = GraphState> = {
|
|
|
50
52
|
revision: number;
|
|
51
53
|
status: SessionGraphStatus;
|
|
52
54
|
tokens: TokenUsage;
|
|
55
|
+
decisionUsage?: DecisionUsage;
|
|
53
56
|
errors: SessionLogs['errors'];
|
|
54
57
|
warnings: SessionLogs['warnings'];
|
|
58
|
+
decisions?: SessionLogs['decisions'];
|
|
55
59
|
graph: SessionGraphDocument<State>;
|
|
56
60
|
turn?: SessionTurnLease;
|
|
57
61
|
createdAt: string;
|
|
@@ -1,11 +1,41 @@
|
|
|
1
|
+
import type { DecisionFailure, DecisionUsage } from "./decision/decision-types.js";
|
|
1
2
|
export type SessionLogEntry = Record<string, unknown> & {
|
|
2
3
|
createdAt: string;
|
|
3
4
|
};
|
|
4
5
|
export type SessionLogs = {
|
|
5
6
|
errors: SessionLogEntry[];
|
|
6
7
|
warnings: SessionLogEntry[];
|
|
8
|
+
decisions: DecisionAuditEntry[];
|
|
9
|
+
};
|
|
10
|
+
export type DecisionAuditOutcome = "success" | "fallback" | "decision_handler_failed" | "fallback_handler_failed";
|
|
11
|
+
export type DecisionAuditEntry = SessionLogEntry & {
|
|
12
|
+
node: string;
|
|
13
|
+
provider: string;
|
|
14
|
+
configuredModel: string;
|
|
15
|
+
actualModel?: string;
|
|
16
|
+
outcome: DecisionAuditOutcome;
|
|
17
|
+
failure?: DecisionFailure;
|
|
18
|
+
attempts: number;
|
|
19
|
+
durationMs: number;
|
|
20
|
+
requestId?: string;
|
|
21
|
+
usage: DecisionUsage;
|
|
22
|
+
};
|
|
23
|
+
export type DecisionAuditInput = {
|
|
24
|
+
node: string;
|
|
25
|
+
provider: string;
|
|
26
|
+
configuredModel: string;
|
|
27
|
+
actualModel?: string;
|
|
28
|
+
outcome: DecisionAuditOutcome;
|
|
29
|
+
failure?: DecisionFailure;
|
|
30
|
+
attempts: number;
|
|
31
|
+
durationMs: number;
|
|
32
|
+
requestId?: string;
|
|
33
|
+
usage: DecisionUsage;
|
|
7
34
|
};
|
|
8
35
|
export declare function createSessionLogs(): SessionLogs;
|
|
36
|
+
export declare function drainSessionLogs(logs: SessionLogs): SessionLogs;
|
|
37
|
+
export declare function restoreSessionLogs(logs: SessionLogs, drained: SessionLogs): void;
|
|
9
38
|
export declare function withSessionLogs<T>(logs: SessionLogs, callback: () => Promise<T>): Promise<T>;
|
|
10
39
|
export declare function SessionLogError(tree: Record<string, unknown>, logs?: SessionLogs | undefined): void;
|
|
11
40
|
export declare function SessionLogWarning(tree: Record<string, unknown>, logs?: SessionLogs | undefined): void;
|
|
41
|
+
export declare function SessionLogDecision(entry: DecisionAuditInput, logs?: SessionLogs | undefined): DecisionAuditEntry | undefined;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { END, type ExtractStateType, type ExtractUpdateType, START, type StateDefinitionInit } from
|
|
2
|
-
import { GRAPH_NODE_CLASS } from
|
|
1
|
+
import { type Command, END, type ExtractStateType, type ExtractUpdateType, START, type StateDefinitionInit } from "@langchain/langgraph";
|
|
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;
|
|
@@ -22,7 +21,7 @@ export type CurrentNodeBranchOptions = Readonly<{
|
|
|
22
21
|
}[];
|
|
23
22
|
otherwise: GraphEndpoint;
|
|
24
23
|
}>;
|
|
25
|
-
type RouteOf<NodeClass extends GraphNodeClass> = NodeClass[
|
|
24
|
+
type RouteOf<NodeClass extends GraphNodeClass> = NodeClass["prototype"] extends {
|
|
26
25
|
route(...args: never[]): infer Route;
|
|
27
26
|
} ? Extract<Route, string> : never;
|
|
28
27
|
type BranchDestinations<NodeClass extends GraphNodeClass, Destinations extends Readonly<Record<RouteOf<NodeClass>, GraphEndpoint>>> = Destinations & Record<Exclude<keyof Destinations, RouteOf<NodeClass>>, never>;
|
|
@@ -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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModelCatalog, type GraphLlmConfig, type GraphLlmParameters } from
|
|
1
|
+
import { ModelCatalog, type GraphLlmConfig, type GraphLlmParameters } from "./graph-llm.config.js";
|
|
2
2
|
export type TokenUsage = {
|
|
3
3
|
input_tokens: number;
|
|
4
4
|
output_tokens: number;
|
|
@@ -14,7 +14,7 @@ export type ModelResult<T> = {
|
|
|
14
14
|
};
|
|
15
15
|
export type ModelExecution = {
|
|
16
16
|
model: string;
|
|
17
|
-
family: ReturnType<typeof ModelCatalog.resolveModelDescriptor>[
|
|
17
|
+
family: ReturnType<typeof ModelCatalog.resolveModelDescriptor>["family"];
|
|
18
18
|
parameters: GraphLlmParameters;
|
|
19
19
|
};
|
|
20
20
|
export declare function modelExecution(config: GraphLlmConfig): ModelExecution;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BaseMessage } from "@langchain/core/messages";
|
|
2
|
+
import type { GraphNodeLocalState, GraphNodeTarget } from "./node-outcome.js";
|
|
3
|
+
import type { TokenUsage } from "./token-usage.js";
|
|
4
|
+
export type ToolResponseKind = "go" | "stay" | "direct" | "directTo" | "finish";
|
|
5
|
+
export type ToolResponse = Readonly<{
|
|
6
|
+
kind: ToolResponseKind;
|
|
7
|
+
target?: GraphNodeTarget;
|
|
8
|
+
feedback?: string;
|
|
9
|
+
state?: Record<string, unknown>;
|
|
10
|
+
message?: BaseMessage;
|
|
11
|
+
messages?: readonly BaseMessage[];
|
|
12
|
+
cleanup?: () => Promise<void>;
|
|
13
|
+
response?: string;
|
|
14
|
+
usage?: TokenUsage;
|
|
15
|
+
}>;
|
|
16
|
+
export type ToolResponseBuilder<NodeClass extends GraphNodeTarget> = ToolResponse & {
|
|
17
|
+
withState(state: Partial<GraphNodeLocalState<NodeClass>>): ToolResponseBuilder<NodeClass>;
|
|
18
|
+
withMessage(message: BaseMessage): ToolResponseBuilder<NodeClass>;
|
|
19
|
+
withMessages(messages: readonly BaseMessage[]): ToolResponseBuilder<NodeClass>;
|
|
20
|
+
withCleanup(cleanup: () => Promise<void>): ToolResponseBuilder<NodeClass>;
|
|
21
|
+
withToolFeedback(feedback: string): ToolResponseBuilder<NodeClass>;
|
|
22
|
+
withUsage(usage: TokenUsage): ToolResponseBuilder<NodeClass>;
|
|
23
|
+
};
|
|
24
|
+
export declare function go<NodeClass extends GraphNodeTarget>(target: NodeClass): ToolResponseBuilder<NodeClass>;
|
|
25
|
+
export declare function stay(feedback?: string): ToolResponseBuilder<GraphNodeTarget>;
|
|
26
|
+
export declare function direct(content: string | object): ToolResponseBuilder<GraphNodeTarget>;
|
|
27
|
+
export declare function directTo<NodeClass extends GraphNodeTarget>(target: NodeClass, content: string | object): ToolResponseBuilder<NodeClass>;
|
|
28
|
+
export declare function finish(content: string | object): ToolResponseBuilder<GraphNodeTarget>;
|
|
29
|
+
export declare function isToolResponse(value: unknown): value is ToolResponse;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DecisionAnswer, DecisionCallOptions, DecisionProviderAdapter, DecisionRequest, DecisionResult, DecisionTokenUsage } from '../framework/decision/decision-types.js';
|
|
2
|
+
export type ScriptedDecisionCall = Readonly<{
|
|
3
|
+
request: DecisionRequest;
|
|
4
|
+
options: DecisionCallOptions;
|
|
5
|
+
}>;
|
|
6
|
+
export declare class ScriptedDecisions implements DecisionProviderAdapter {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
private readonly turns;
|
|
9
|
+
private consumed;
|
|
10
|
+
readonly calls: ScriptedDecisionCall[];
|
|
11
|
+
constructor(id?: string);
|
|
12
|
+
answers(answers: Record<string, DecisionAnswer>, options?: Readonly<{
|
|
13
|
+
model?: string;
|
|
14
|
+
usage?: DecisionTokenUsage;
|
|
15
|
+
requestId?: string;
|
|
16
|
+
}>): this;
|
|
17
|
+
result(result: DecisionResult): this;
|
|
18
|
+
fail(error: Error | string): this;
|
|
19
|
+
get drained(): boolean;
|
|
20
|
+
get remaining(): number;
|
|
21
|
+
decide(request: DecisionRequest, options: DecisionCallOptions): Promise<DecisionResult>;
|
|
22
|
+
shouldRetry(error: Error): boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function scriptedDecisions(id?: string): ScriptedDecisions;
|
|
@@ -2,6 +2,7 @@ import { GraphEngine, type GraphConstructor, type RunResult } from '../framework
|
|
|
2
2
|
import type { GraphState } from '../framework/graph-state.js';
|
|
3
3
|
import type { LlmGateway } from '../framework/llm-gateway.js';
|
|
4
4
|
import type { SessionLogs } from '../framework/session-log.js';
|
|
5
|
+
import type { DecisionProviderAdapter } from '../framework/decision/decision-types.js';
|
|
5
6
|
import { SessionManager, type SessionDocument } from '../framework/persistence/session-manager.js';
|
|
6
7
|
export type HarnessTurn<State extends GraphState> = Readonly<{
|
|
7
8
|
status: number;
|
|
@@ -30,6 +31,7 @@ export type TurnHarness<State extends GraphState> = Readonly<{
|
|
|
30
31
|
export declare function createTurnHarness<State extends GraphState = GraphState>(options: Readonly<{
|
|
31
32
|
graph: GraphConstructor;
|
|
32
33
|
gateway?: LlmGateway;
|
|
34
|
+
decisions?: DecisionProviderAdapter | readonly DecisionProviderAdapter[];
|
|
33
35
|
sessionManager?: SessionManager;
|
|
34
36
|
sessionId?: string;
|
|
35
37
|
}>): TurnHarness<State>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picoflow/ezgraph",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Provider-neutral graph primitives built on LangGraph and LangChain.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -37,18 +37,19 @@
|
|
|
37
37
|
"@azure/identity": "4.13.1",
|
|
38
38
|
"@google/genai": "2.14.0",
|
|
39
39
|
"dotenv": "17.4.2",
|
|
40
|
-
"@langchain/core": "1.2.
|
|
41
|
-
"@langchain/langgraph": "1.4.
|
|
42
|
-
"langchain": "1.5.
|
|
40
|
+
"@langchain/core": "1.2.12",
|
|
41
|
+
"@langchain/langgraph": "1.4.17",
|
|
42
|
+
"langchain": "1.5.12",
|
|
43
43
|
"mongodb": "6.21.0",
|
|
44
44
|
"openai": "7.1.0",
|
|
45
45
|
"reflect-metadata": "0.2.2",
|
|
46
46
|
"zod": "4.4.3"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@langchain/anthropic": ">=1.5.
|
|
50
|
-
"@langchain/google": ">=0.2.
|
|
51
|
-
"@langchain/openai": ">=1.5.
|
|
49
|
+
"@langchain/anthropic": ">=1.5.11",
|
|
50
|
+
"@langchain/google": ">=0.2.7",
|
|
51
|
+
"@langchain/openai": ">=1.5.13",
|
|
52
|
+
"@langchain/typesafe": ">=0.0.1"
|
|
52
53
|
},
|
|
53
54
|
"peerDependenciesMeta": {
|
|
54
55
|
"@langchain/anthropic": {
|
|
@@ -59,6 +60,9 @@
|
|
|
59
60
|
},
|
|
60
61
|
"@langchain/openai": {
|
|
61
62
|
"optional": true
|
|
63
|
+
},
|
|
64
|
+
"@langchain/typesafe": {
|
|
65
|
+
"optional": true
|
|
62
66
|
}
|
|
63
67
|
}
|
|
64
68
|
}
|
|
@@ -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 {};
|