@picoflow/ezgraph 0.0.8 → 0.0.9

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.
@@ -1 +1 @@
1
- var D=Object.defineProperty;var n=(a,o)=>D(a,"name",{value:o,configurable:!0});import{GraphNode as v}from"../graph-node.js";import{currentTurnSignal as m}from"../turn-context.js";import{DecisionRunner as C}from"./decision-runner.js";import{assertJsonCompatible as w,validateDecisionQuestions as g}from"./decision-validation.js";class y extends v{static{n(this,"DecisionNode")}getPrompt(o){return""}getDecisionEvidence(o){return{}}getDecisionConfig(){return{}}onDecisionError(o){return null}async run(o){this.assertNoChatConfiguration();const t=m();t?.throwIfAborted();const h=this.graph.resolveDecisionOptions(this.getDecisionConfig()),f=this.graph.resolveDecisionProvider(h.provider),l=structuredClone(this.defineQuestions(o));g(l);const u=this.getPrompt(o).trim(),d=Object.fromEntries(Object.entries(l).map(([e,i])=>[e,{...i,...u?{instructions:[u,...i.instructions===void 0?[]:[i.instructions]]}:{}}]));g(d);const s=this.graph.getConversation(this.historySpace()),c=structuredClone(this.getDecisionEvidence(o));if("request"in c||"priorRequests"in c)throw new Error("getDecisionEvidence() cannot replace framework-owned request or priorRequests.");const p={...c,request:s.request,priorRequests:[...s.priorRequests]};return w(p,"Decision input"),C.run({nodeId:this.id,state:o,conversation:s,providerState:p,questions:d,provider:f,options:h,callerSignal:t,onDecision:n(async(e,i,r)=>this.resolveNodeResponse(await this.onDecision(e,i,r)),"onDecision"),onError:n(async e=>{const r=await this.onDecisionError(e)??await this.graph.handleDecisionError(e);if(r===null)throw e.error;return this.resolveNodeResponse(r)},"onError")})}validateTools(){this.assertNoChatConfiguration();const o=this.graph.resolveDecisionOptions(this.getDecisionConfig());this.graph.resolveDecisionProvider(o.provider)}assertNoChatConfiguration(){const o=this.defineTool(),t=this.obtainTools();if(o.length>0||t.length>0)throw new Error("DecisionNode cannot configure chat tools.");if(Object.keys(this.getLlmConfig()).length>0)throw new Error("DecisionNode uses getDecisionConfig(), not a chat model configuration.")}usesChatModel(){return!1}async runConversation(o,t){throw new Error("DecisionNode does not run the conversational model loop.")}}export{y as DecisionNode};
1
+ var D=Object.defineProperty;var r=(a,o)=>D(a,"name",{value:o,configurable:!0});import{GraphNode as m}from"../graph-node.js";import{currentTurnSignal as v}from"../turn-context.js";import{DecisionRunner as C}from"./decision-runner.js";import{assertJsonCompatible as w,validateDecisionQuestions as g}from"./decision-validation.js";class y extends m{static{r(this,"DecisionNode")}getPrompt(o){return""}getDecisionFacts(o){return{}}getDecisionConfig(){return{}}onDecisionError(o){return null}async run(o){this.assertNoChatConfiguration();const s=v();s?.throwIfAborted();const h=this.graph.resolveDecisionOptions(this.getDecisionConfig()),f=this.graph.resolveDecisionProvider(h.provider),l=structuredClone(this.defineQuestions(o));g(l);const u=this.getPrompt(o).trim(),p=Object.fromEntries(Object.entries(l).map(([e,t])=>[e,{...t,...u?{instructions:[u,...t.instructions===void 0?[]:[t.instructions]]}:{}}]));g(p);const n=this.graph.getConversation(this.historySpace()),c=structuredClone(this.getDecisionFacts(o));if("request"in c||"priorRequests"in c)throw new Error("getDecisionFacts() cannot replace framework-owned request or priorRequests.");const d={...c,request:n.request,priorRequests:[...n.priorRequests]};return w(d,"Decision input"),C.run({nodeId:this.id,state:o,conversation:n,providerState:d,questions:p,provider:f,options:h,callerSignal:s,onDecision:r(async(e,t,i)=>this.resolveNodeResponse(await this.onDecision(e,t,i)),"onDecision"),onError:r(async e=>{const i=await this.onDecisionError(e)??await this.graph.handleDecisionError(e);if(i===null)throw e.error;return this.resolveNodeResponse(i)},"onError")})}validateTools(){this.assertNoChatConfiguration();const o=this.graph.resolveDecisionOptions(this.getDecisionConfig());this.graph.resolveDecisionProvider(o.provider)}assertNoChatConfiguration(){const o=this.defineTool(),s=this.obtainTools();if(o.length>0||s.length>0)throw new Error("DecisionNode cannot configure chat tools.");if(Object.keys(this.getLlmConfig()).length>0)throw new Error("DecisionNode uses getDecisionConfig(), not a chat model configuration.")}usesChatModel(){return!1}async runConversation(o,s){throw new Error("DecisionNode does not run the conversational model loop.")}}export{y as DecisionNode};
@@ -5,7 +5,7 @@ import { type DecisionAnswers, type DecisionContext, type DecisionEvidence, type
5
5
  export declare abstract class DecisionNode<State extends GraphState, Questions extends DecisionQuestionMap = DecisionQuestionMap, LocalState extends object = Record<string, unknown>> extends GraphNode<State, LocalState> {
6
6
  abstract defineQuestions(state: State): Questions;
7
7
  getPrompt(_state: State): string;
8
- protected getDecisionEvidence(_state: State): DecisionEvidence;
8
+ protected getDecisionFacts(_state: State): DecisionEvidence;
9
9
  getDecisionConfig(): DecisionOptions;
10
10
  abstract onDecision(answers: DecisionAnswers<Questions>, context: DecisionContext, state: State): GraphNodeResponse<State> | Promise<GraphNodeResponse<State>>;
11
11
  protected onDecisionError(_context: DecisionErrorContext<State>): GraphNodeResponse<State> | null | Promise<GraphNodeResponse<State> | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picoflow/ezgraph",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "Provider-neutral graph primitives built on LangGraph and LangChain.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",