@picoflow/ezgraph 0.0.18 → 0.0.20

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 CHANGED
@@ -50,6 +50,32 @@ returns exactly one response:
50
50
  There is no per-turn context object, post-tool transition hook, synthetic tool
51
51
  result, or automatic outcome router to maintain.
52
52
 
53
+ ## Await child work inside a parent
54
+
55
+ Use `runNode()` with one or more registered targets when the parent needs their
56
+ results before choosing its next action:
57
+
58
+ ```ts
59
+ const [judge] = await this.runNode({ node: JudgeNode, input: { candidate } });
60
+ const [first, second] = await this.runNode(Child1Node, Child2Node);
61
+ ```
62
+
63
+ The parent resumes after the await with ordered readonly results. Each result
64
+ contains final child state, a discriminated `outcome`, and usage. Narrow
65
+ `outcome.kind === "taskResult"` to consume a typed judge verdict; text replies
66
+ use `kind: "reply"`. The child reads explicit JSON facts with
67
+ `this.getRunNodeInput<Input>()` and validates them before use.
68
+
69
+ Children execute through EZGraph's invocation lifecycle inside LangGraph tasks.
70
+ They own local state; the parent owns conversation history and routing. On full
71
+ success, child state and usage join the parent's staged update automatically.
72
+ Ordinary failures throw `RunNodeBatchError` after all children settle and join
73
+ no child business state from that batch. Known usage remains accounted for.
74
+
75
+ An active compiled LangGraph execution is required. The current default engine
76
+ does not configure a checkpointer, so scheduling alone supplies no restart
77
+ recovery. Nested child batches are not supported in this initial version.
78
+
53
79
  ## Define durable state
54
80
 
55
81
  Keep the node registry next to the graph. It is converted into the annotated
@@ -1 +1 @@
1
- var d=Object.defineProperty;var i=(o,e)=>d(o,"name",{value:e,configurable:!0});import{GraphLlm as p}from"./graph-llm.config.js";import{GraphNodeRuntime as l}from"./graph-node.js";import{StateGraphExt as u}from"./state-graph-ext.js";import{assertEmptyResponseRetries as g,assertMaxAgentRounds as f,DEFAULT_LLM_POLICY as h,DEFAULT_MAX_AGENT_ROUNDS as y}from"./llm-runner.js";import{assertLlmTimeoutMs as w}from"./llm-gateway.js";import{assertGraphSchemaVersion as m,assertStableId as E,stableClassId as a}from"./stable-id.js";class c{static{i(this,"BaseGraph")}llmGateway;static id(){return this.name}static assertName(e){return c.assertId(e)}static assertId(e){return E(e,"graph")}name;id;schemaVersion;llmConfig;requiresUserMessage;responseMode;maxAgentRounds;llmPolicy;compiledGraph;runtime;nodeMap=new Map;endNode;migrations;constructor(e,r){this.llmGateway=e;const t=new.target;this.name=t.name,this.id=a(t,"graph"),this.schemaVersion=m(r.schemaVersion??1),this.migrations=$(r.migrations,this.schemaVersion),this.llmConfig=p.resolveConfig(r.llmConfig),this.requiresUserMessage=r.requiresUserMessage??!0,this.responseMode=r.responseMode??"chat",this.maxAgentRounds=f(r.maxAgentRounds??y),this.llmPolicy=v(r),this.endNode=r.endNode,this.runtime=new l(r.endNode,this.llmConfig,R(r.historySpaces),this.responseMode,this.maxAgentRounds,this.llmPolicy,r.decisionConfig,s=>this.onDecisionError(s),{onLlmBlocked:i(s=>this.onLlmBlocked(s),"onLlmBlocked"),shouldRetryLlmError:i(s=>this.shouldRetryLlmError(s),"shouldRetryLlmError"),onLlmError:i(s=>this.onLlmError(s),"onLlmError")},()=>{if(!this.graph.channels?.context)throw new Error(`Graph '${this.id}' must declare a context channel to save context. Use createGraphStateAnnotation().`)})}async onLlmBlocked(e){return null}shouldRetryLlmError(e){}async onLlmError(e){return null}onDecisionError(e){return null}attachDecisionProviderResolver(e){this.runtime.attachDecisionProviderResolver(e)}get graph(){return this.compiledGraph??=this.buildGraph()}prepareInput(e,r){const t=e?.currentNode??this.initialNodeId(),s=this.runtime.historySpace(t);return{...e??{},currentNode:t,histories:{...e?.histories??{},[s]:[...e?.histories[s]??[],r]}}}initialNodeId(){const e=this.graph.channels?.currentNode;if(!e||typeof e.fromCheckpoint!="function")throw new Error(`Graph '${this.id}' must declare a currentNode default before preparing its first message.`);let r;try{r=e.fromCheckpoint().get()}catch(t){throw new Error(`Graph '${this.id}' must declare a currentNode default before preparing its first message.`,{cause:t})}if(typeof r!="string"||!r.trim())throw new Error(`Graph '${this.id}' must declare a non-empty currentNode default.`);return r}getContext(){return this.runtime.getContext()}saveContext(e){this.runtime.saveContext(e)}saveNodeState(e,r){this.runtime.saveNode(a(e,"graph node"),r)}async restoreSessionDoc(e){if(e.graph.id!==this.id)throw new Error(`Session '${e.id}' belongs to graph '${e.graph.id}', not '${this.id}'. Start a new session to run a different graph.`);if(e.graph.schemaVersion>this.schemaVersion)throw new Error(`Session '${e.id}' uses graph '${this.id}' schema version ${e.graph.schemaVersion}, but this runtime supports version ${this.schemaVersion}.`);let r=e;for(;r.graph.schemaVersion<this.schemaVersion;){const t=r.graph.schemaVersion,s=this.migrations.get(t);if(!s)throw new Error(`Graph '${this.id}' has no migration from schema version ${t} to ${t+1}.`);const n=await s.migrate(r);if(n.graph.id!==this.id)throw new Error(`Graph '${this.id}' migration from schema version ${t} changed the persisted graph ID.`);r={...n,graph:{...n.graph,schemaVersion:t+1}}}return await this.onRestoreSessionDoc(r)}async onRestoreSessionDoc(e){return e}idleMs(e){const r=Date.parse(e.modifiedAt);return Number.isFinite(r)?Date.now()-r:0}createStateGraph(e){return new u(e,(r=>this.createNode(r)),this.endNode)}createNode(e){const r=new e(this.llmGateway,this.runtime),t=a(e,"graph node");if(r.id!==t)throw new Error(`Graph node factory for '${t}' constructs '${r.id}'.`);if(this.nodeMap.has(r.id))throw new Error(`Graph node '${r.id}' is already registered.`);return this.nodeMap.set(r.id,r),this.runtime.registerTools(r.id,r.defineTool()),Object.freeze(r),r}}function v(o){const e=o.emptyResponseRecovery===void 0?h.emptyResponseRecovery:o.emptyResponseRecovery;return e&&g(e.retries),{...o.llmTimeoutMs===void 0?{}:{llmTimeoutMs:w(o.llmTimeoutMs)},emptyHistorySeed:o.emptyHistorySeed===void 0?h.emptyHistorySeed:o.emptyHistorySeed,emptyResponseRecovery:e}}i(v,"resolveLlmPolicy");function R(o){return Object.fromEntries((o??[]).map(([e,r])=>[a(e,"graph node"),r]))}i(R,"historySpaceMap");function $(o,e){const r=new Map;let t;for(const s of o??[]){const n=m(s.from);if(n>=e)throw new Error(`A graph migration from version ${n} cannot target schema version ${e}.`);if(r.has(n))throw new Error(`More than one graph migration starts at version ${n}.`);if(t!==void 0&&n!==t+1)throw new Error(`Graph migrations must be ordered and contiguous; version ${t} must be followed by ${t+1}.`);r.set(n,s),t=n}return r}i($,"migrationMap");export{c as BaseGraph};
1
+ var p=Object.defineProperty;var i=(n,e)=>p(n,"name",{value:e,configurable:!0});import{GraphLlm as u}from"./graph-llm.config.js";import{GraphNodeRuntime as l}from"./graph-node.js";import{StateGraphExt as g}from"./state-graph-ext.js";import{assertEmptyResponseRetries as f,assertMaxAgentRounds as w,DEFAULT_LLM_POLICY as m,DEFAULT_MAX_AGENT_ROUNDS as y}from"./llm-runner.js";import{assertLlmTimeoutMs as E}from"./llm-gateway.js";import{assertGraphSchemaVersion as c,assertStableId as v,stableClassId as a}from"./stable-id.js";class d{static{i(this,"BaseGraph")}llmGateway;static id(){return this.name}static assertName(e){return d.assertId(e)}static assertId(e){return v(e,"graph")}name;id;schemaVersion;llmConfig;requiresUserMessage;responseMode;maxAgentRounds;llmPolicy;compiledGraph;runtime;nodeMap=new Map;endNode;migrations;constructor(e,r){this.llmGateway=e;const t=new.target;this.name=t.name,this.id=a(t,"graph"),this.schemaVersion=c(r.schemaVersion??1),this.migrations=M(r.migrations,this.schemaVersion),this.llmConfig=u.resolveConfig(r.llmConfig),this.requiresUserMessage=r.requiresUserMessage??!0,this.responseMode=r.responseMode??"chat",this.maxAgentRounds=w(r.maxAgentRounds??y),this.llmPolicy=R(r),this.endNode=r.endNode,this.runtime=new l(r.endNode,this.llmConfig,$(r.historySpaces),this.responseMode,this.maxAgentRounds,this.llmPolicy,r.decisionConfig,s=>this.onDecisionError(s),{onLlmBlocked:i(s=>this.onLlmBlocked(s),"onLlmBlocked"),shouldRetryLlmError:i(s=>this.shouldRetryLlmError(s),"shouldRetryLlmError"),onLlmError:i(s=>this.onLlmError(s),"onLlmError")},()=>{if(!this.graph.channels?.context)throw new Error(`Graph '${this.id}' must declare a context channel to save context. Use createGraphStateAnnotation().`)}),this.runtime.attachRunNodeResolver(s=>{const o=a(s,"graph node"),h=this.nodeMap.get(o);if(!h||h.constructor!==s)throw new Error(`runNode() target '${o}' must be registered in this graph.`);return h})}async onLlmBlocked(e){return null}shouldRetryLlmError(e){}async onLlmError(e){return null}onDecisionError(e){return null}attachDecisionProviderResolver(e){this.runtime.attachDecisionProviderResolver(e)}get graph(){return this.compiledGraph??=this.buildGraph()}prepareInput(e,r){const t=e?.currentNode??this.initialNodeId(),s=this.runtime.historySpace(t);return{...e??{},currentNode:t,histories:{...e?.histories??{},[s]:[...e?.histories[s]??[],r]}}}initialNodeId(){const e=this.graph.channels?.currentNode;if(!e||typeof e.fromCheckpoint!="function")throw new Error(`Graph '${this.id}' must declare a currentNode default before preparing its first message.`);let r;try{r=e.fromCheckpoint().get()}catch(t){throw new Error(`Graph '${this.id}' must declare a currentNode default before preparing its first message.`,{cause:t})}if(typeof r!="string"||!r.trim())throw new Error(`Graph '${this.id}' must declare a non-empty currentNode default.`);return r}getContext(){return this.runtime.getContext()}saveContext(e){this.runtime.saveContext(e)}saveNodeState(e,r){this.runtime.saveNode(a(e,"graph node"),r)}async restoreSessionDoc(e){if(e.graph.id!==this.id)throw new Error(`Session '${e.id}' belongs to graph '${e.graph.id}', not '${this.id}'. Start a new session to run a different graph.`);if(e.graph.schemaVersion>this.schemaVersion)throw new Error(`Session '${e.id}' uses graph '${this.id}' schema version ${e.graph.schemaVersion}, but this runtime supports version ${this.schemaVersion}.`);let r=e;for(;r.graph.schemaVersion<this.schemaVersion;){const t=r.graph.schemaVersion,s=this.migrations.get(t);if(!s)throw new Error(`Graph '${this.id}' has no migration from schema version ${t} to ${t+1}.`);const o=await s.migrate(r);if(o.graph.id!==this.id)throw new Error(`Graph '${this.id}' migration from schema version ${t} changed the persisted graph ID.`);r={...o,graph:{...o.graph,schemaVersion:t+1}}}return await this.onRestoreSessionDoc(r)}async onRestoreSessionDoc(e){return e}idleMs(e){const r=Date.parse(e.modifiedAt);return Number.isFinite(r)?Date.now()-r:0}createStateGraph(e){return new g(e,(r=>this.createNode(r)),this.endNode)}createNode(e){const r=new e(this.llmGateway,this.runtime),t=a(e,"graph node");if(r.id!==t)throw new Error(`Graph node factory for '${t}' constructs '${r.id}'.`);if(this.nodeMap.has(r.id))throw new Error(`Graph node '${r.id}' is already registered.`);return this.nodeMap.set(r.id,r),this.runtime.registerTools(r.id,r.defineTool()),Object.freeze(r),r}}function R(n){const e=n.emptyResponseRecovery===void 0?m.emptyResponseRecovery:n.emptyResponseRecovery;return e&&f(e.retries),{...n.llmTimeoutMs===void 0?{}:{llmTimeoutMs:E(n.llmTimeoutMs)},emptyHistorySeed:n.emptyHistorySeed===void 0?m.emptyHistorySeed:n.emptyHistorySeed,emptyResponseRecovery:e}}i(R,"resolveLlmPolicy");function $(n){return Object.fromEntries((n??[]).map(([e,r])=>[a(e,"graph node"),r]))}i($,"historySpaceMap");function M(n,e){const r=new Map;let t;for(const s of n??[]){const o=c(s.from);if(o>=e)throw new Error(`A graph migration from version ${o} cannot target schema version ${e}.`);if(r.has(o))throw new Error(`More than one graph migration starts at version ${o}.`);if(t!==void 0&&o!==t+1)throw new Error(`Graph migrations must be ordered and contiguous; version ${t} must be followed by ${t+1}.`);r.set(o,s),t=o}return r}i(M,"migrationMap");export{d as BaseGraph};
@@ -1 +1 @@
1
- var k=Object.defineProperty;var n=(o,e)=>k(o,"name",{value:e,configurable:!0});import{Command as M,isCommand as v}from"@langchain/langgraph";import{SessionLogDecision as _,SessionLogWarning as m}from"../session-log.js";import{DecisionConfigurationError as L,DecisionTimeoutError as P,DecisionValidationError as h,addDecisionUsage as I,decisionUsage as U,emptyDecisionUsage as C}from"./decision-types.js";import{validateDecisionResult as R}from"./decision-validation.js";class G{static{n(this,"DecisionRunner")}static async run(e){e.callerSignal?.throwIfAborted();const i=performance.now();let t=0,a=C(),r,d,c;try{for(;;){t+=1;try{r=await x(e),d=r.model,c=r.requestId,a=I(a,U(N(r))),R(r,e.questions);break}catch(l){const s=D(l);if(e.callerSignal?.throwIfAborted(),A(s)||!(!(s instanceof h)&&(s.name==="TimeoutError"||e.provider.shouldRetry?.(s)===!0))||t>e.options.maxRetries)throw s;m({decision_retry:!0,node:e.nodeId,provider:e.provider.id,attempt:t+1}),await F(250,e.callerSignal)}}}catch(l){const s=D(l);if(e.callerSignal?.throwIfAborted(),A(s))throw s;const u=j(s);m({decision_fallback:u,node:e.nodeId,provider:e.provider.id});const w=y(e,{outcome:"fallback",failure:u,attempts:t,durationMs:performance.now()-i,usage:a,...d?{actualModel:d}:{},...c?{requestId:c}:{}});let g;try{g=await q(e.onError({nodeId:e.nodeId,provider:e.provider.id,model:e.options.model,failure:u,attempts:t,error:s,state:e.state}),e.callerSignal,"Decision fallback handler aborted.")}catch(T){throw w&&(w.outcome="fallback_handler_failed"),S(e,"fallback",t,a),T}return e.callerSignal?.throwIfAborted(),E(g,a)}e.callerSignal?.throwIfAborted();const f={provider:e.provider.id,model:r.model,durationMs:performance.now()-i,attempts:t,usage:r.usage??{},...r.requestId?{requestId:r.requestId}:{},request:e.conversation.request,priorRequests:[...e.conversation.priorRequests]},p=y(e,{outcome:"success",attempts:t,durationMs:f.durationMs,usage:a,actualModel:r.model,...r.requestId?{requestId:r.requestId}:{}});let b;try{b=await q(e.onDecision(r.answers,f,e.state),e.callerSignal,"Decision handler aborted.")}catch(l){throw p&&(p.outcome="decision_handler_failed"),S(e,"decision",t,a),l}return e.callerSignal?.throwIfAborted(),E(b,a)}}function y(o,e){return _({node:o.nodeId,provider:o.provider.id,configuredModel:o.options.model,...e})}n(y,"recordDecision");async function x(o){const e=new AbortController,i=setTimeout(()=>e.abort(new P),o.options.timeoutMs),t=o.callerSignal?AbortSignal.any([o.callerSignal,e.signal]):e.signal;let a=n(()=>{},"onAbort");try{t.throwIfAborted();const r=new Promise((c,f)=>{a=n(()=>f(t.reason??new Error("Decision call aborted.")),"onAbort"),t.addEventListener("abort",a,{once:!0})}),d=await Promise.race([o.provider.decide({model:o.options.model,state:o.providerState,questions:o.questions},{signal:t,timeoutMs:o.options.timeoutMs}),r]);return t.throwIfAborted(),d}finally{clearTimeout(i),t.removeEventListener("abort",a)}}n(x,"callProvider");function E(o,e){const i=v(o)?o.update??{}:o,t={...i,decisionUsage:I(i.decisionUsage,e)};return v(o)?new M({update:t,...o.goto===void 0?{}:{goto:o.goto},...o.graph===void 0?{}:{graph:o.graph},...o.resume===void 0?{}:{resume:o.resume}}):t}n(E,"withUsage");function F(o,e){return e?(e.throwIfAborted(),new Promise((i,t)=>{const a=setTimeout(()=>{e.removeEventListener("abort",r),i()},o),r=n(()=>{clearTimeout(a),t(e.reason??new Error("Decision retry aborted."))},"onAbort");e.addEventListener("abort",r,{once:!0})})):new Promise(i=>setTimeout(i,o))}n(F,"retryDelay");async function q(o,e,i){if(!e)return o;e.throwIfAborted();let t=n(()=>{},"onAbort");try{const a=new Promise((d,c)=>{t=n(()=>c(e.reason??new Error(i)),"onAbort"),e.addEventListener("abort",t,{once:!0})}),r=await Promise.race([Promise.resolve(o),a]);return e.throwIfAborted(),r}finally{e.removeEventListener("abort",t)}}n(q,"withCallerCancellation");function j(o){return o instanceof h?"validation":o.name==="TimeoutError"?"timeout":"provider"}n(j,"classifyFailure");function A(o){if(o instanceof L)return!0;const e=o.status;return e===401||e===403}n(A,"isConfigurationFailure");function D(o){return o instanceof Error?o:new Error(String(o))}n(D,"asError");function N(o){if(!o||typeof o!="object")return{};const e=o.usage;if(!e||typeof e!="object")return{};const i=e.inputTokens,t=e.outputTokens;return{...Number.isInteger(i)&&i>=0?{inputTokens:i}:{},...Number.isInteger(t)&&t>=0?{outputTokens:t}:{}}}n(N,"observedUsage");function S(o,e,i,t){m({decision_handler_failed:e,node:o.nodeId,provider:o.provider.id,model:o.options.model,attempts:i,observedDecisionUsage:t})}n(S,"logHandlerFailure");export{G as DecisionRunner};
1
+ var k=Object.defineProperty;var a=(o,e)=>k(o,"name",{value:e,configurable:!0});import{Command as M,isCommand as v}from"@langchain/langgraph";import{SessionLogDecision as _,SessionLogWarning as m}from"../session-log.js";import{DecisionConfigurationError as U,DecisionTimeoutError as L,DecisionValidationError as h,addDecisionUsage as I,decisionUsage as P,emptyDecisionUsage as R}from"./decision-types.js";import{validateDecisionResult as C}from"./decision-validation.js";import{observeRunNodeDecisionUsage as x}from"../node-invocation.js";class K{static{a(this,"DecisionRunner")}static async run(e){e.callerSignal?.throwIfAborted();const i=performance.now();let t=0,n=R(),r,d,c;try{for(;;){t+=1;try{r=await F(e),d=r.model,c=r.requestId,n=I(n,P(H(r))),x(n),C(r,e.questions);break}catch(l){const s=A(l);if(e.callerSignal?.throwIfAborted(),q(s)||!(!(s instanceof h)&&(s.name==="TimeoutError"||e.provider.shouldRetry?.(s)===!0))||t>e.options.maxRetries)throw s;m({decision_retry:!0,node:e.nodeId,provider:e.provider.id,attempt:t+1}),await N(250,e.callerSignal)}}}catch(l){const s=A(l);if(e.callerSignal?.throwIfAborted(),q(s))throw s;const u=j(s);m({decision_fallback:u,node:e.nodeId,provider:e.provider.id});const w=y(e,{outcome:"fallback",failure:u,attempts:t,durationMs:performance.now()-i,usage:n,...d?{actualModel:d}:{},...c?{requestId:c}:{}});let g;try{g=await D(e.onError({nodeId:e.nodeId,provider:e.provider.id,model:e.options.model,failure:u,attempts:t,error:s,state:e.state}),e.callerSignal,"Decision fallback handler aborted.")}catch(T){throw w&&(w.outcome="fallback_handler_failed"),S(e,"fallback",t,n),T}return e.callerSignal?.throwIfAborted(),E(g,n)}e.callerSignal?.throwIfAborted();const f={provider:e.provider.id,model:r.model,durationMs:performance.now()-i,attempts:t,usage:r.usage??{},...r.requestId?{requestId:r.requestId}:{},request:e.conversation.request,priorRequests:[...e.conversation.priorRequests]},p=y(e,{outcome:"success",attempts:t,durationMs:f.durationMs,usage:n,actualModel:r.model,...r.requestId?{requestId:r.requestId}:{}});let b;try{b=await D(e.onDecision(r.answers,f,e.state),e.callerSignal,"Decision handler aborted.")}catch(l){throw p&&(p.outcome="decision_handler_failed"),S(e,"decision",t,n),l}return e.callerSignal?.throwIfAborted(),E(b,n)}}function y(o,e){return _({node:o.nodeId,provider:o.provider.id,configuredModel:o.options.model,...e})}a(y,"recordDecision");async function F(o){const e=new AbortController,i=setTimeout(()=>e.abort(new L),o.options.timeoutMs),t=o.callerSignal?AbortSignal.any([o.callerSignal,e.signal]):e.signal;let n=a(()=>{},"onAbort");try{t.throwIfAborted();const r=new Promise((c,f)=>{n=a(()=>f(t.reason??new Error("Decision call aborted.")),"onAbort"),t.addEventListener("abort",n,{once:!0})}),d=await Promise.race([o.provider.decide({model:o.options.model,state:o.providerState,questions:o.questions},{signal:t,timeoutMs:o.options.timeoutMs}),r]);return t.throwIfAborted(),d}finally{clearTimeout(i),t.removeEventListener("abort",n)}}a(F,"callProvider");function E(o,e){const i=v(o)?o.update??{}:o,t={...i,decisionUsage:I(i.decisionUsage,e)};return v(o)?new M({update:t,...o.goto===void 0?{}:{goto:o.goto},...o.graph===void 0?{}:{graph:o.graph},...o.resume===void 0?{}:{resume:o.resume}}):t}a(E,"withUsage");function N(o,e){return e?(e.throwIfAborted(),new Promise((i,t)=>{const n=setTimeout(()=>{e.removeEventListener("abort",r),i()},o),r=a(()=>{clearTimeout(n),t(e.reason??new Error("Decision retry aborted."))},"onAbort");e.addEventListener("abort",r,{once:!0})})):new Promise(i=>setTimeout(i,o))}a(N,"retryDelay");async function D(o,e,i){if(!e)return o;e.throwIfAborted();let t=a(()=>{},"onAbort");try{const n=new Promise((d,c)=>{t=a(()=>c(e.reason??new Error(i)),"onAbort"),e.addEventListener("abort",t,{once:!0})}),r=await Promise.race([Promise.resolve(o),n]);return e.throwIfAborted(),r}finally{e.removeEventListener("abort",t)}}a(D,"withCallerCancellation");function j(o){return o instanceof h?"validation":o.name==="TimeoutError"?"timeout":"provider"}a(j,"classifyFailure");function q(o){if(o instanceof U)return!0;const e=o.status;return e===401||e===403}a(q,"isConfigurationFailure");function A(o){return o instanceof Error?o:new Error(String(o))}a(A,"asError");function H(o){if(!o||typeof o!="object")return{};const e=o.usage;if(!e||typeof e!="object")return{};const i=e.inputTokens,t=e.outputTokens;return{...Number.isInteger(i)&&i>=0?{inputTokens:i}:{},...Number.isInteger(t)&&t>=0?{outputTokens:t}:{}}}a(H,"observedUsage");function S(o,e,i,t){m({decision_handler_failed:e,node:o.nodeId,provider:o.provider.id,model:o.options.model,attempts:i,observedDecisionUsage:t})}a(S,"logHandlerFailure");export{K as DecisionRunner};
@@ -1 +1 @@
1
- const PK=e;(function(i,c){const PM={i:0xe0,c:0xdb,l:0xc1,I:0xb4},PC=e,l=i();while(!![]){try{const I=parseInt(PC(0xa0))/0x1+parseInt(PC(PM.i))/0x2+parseInt(PC(PM.c))/0x3+parseInt(PC(PM.l))/0x4+-parseInt(PC(0xce))/0x5+parseInt(PC(0xd6))/0x6+parseInt(PC(PM.I))/0x7*(-parseInt(PC(0xa3))/0x8);if(I===c)break;else l['push'](l['shift']());}catch(a){l['push'](l['shift']());}}}(b,0x8258d));var P=Object['defineProperty'],y=(i,c)=>P(i,PK(0xc5),{'value':c,'configurable':!0x0});import{HumanMessage as X}from'@langchain/core/messages';function b(){const PI=['z2v0','jYbJB21WBgv0zwqGD2L0Ag91DcbWCM9KDwnPBMCGC3rHDguU','C2f2zvn0yxrL','zgvSzxrLu2vZC2LVBG','mtmZyKPmquzc','C2LNBMfS','yxbWBgLJyxrPB24VANnVBG','zg9JDw1LBNq','y2HHDfjLC3vSDa','CNvU','z3jHCgG','u0vtu0LptL9jrcbPCYbYzxf1AxjLzc4','ANnVBG','jYbYzxn0B3jLihjLDhvYBMvKihnJAgvTysb2zxjZAw9Uia','BwfW','CMvZDg9YzvnLC3nPB25eB2n1BwvUDa','z3jHCgHZ','mti2mZCWmhbWs2TtCq','y29UzMLN','C3rYAw5N','CMvZCg9UC2vnB2rL','BMfTzq','CMvSzwfZzvr1CM4','DxnLCK1LC3nHz2uGBxvZDcbIzsbHig5VBI1LBxb0EsbZDhjPBMCU','C2vZC2LVBK1HBMfNzxi','BM9Kzxm','y3jLyxrL','CMvZCg9UC2u','jYbPCYbUB3qGCMvNAxn0zxjLzc4','ChjLCgfYzuLUChv0','ntG5nda1y0DYtxje','zgvJAxnPB25qCM92AwrLCNm','yxr0ywnOrgvJAxnPB25qCM92AwrLCLjLC29SDMvY','DgvZDa','C2vZC2LVBKLK','C3rYzwfT','y29UzMXPy3rszxn1Bhq','ChjVDMLKzxjZ','mJK0odeYnhbwwMLgBq','Aw52B2TL','CMvXDwLYzxnvC2vYtwvZC2fNzq','zxHWzwn0zwrszxzPC2LVBG','y29Kzq','mtu3otGZmgfArvHPzG','ANnVBLjLC3vSDa','DxnLCK1LC3nHz2u','CMvNAxn0zxjhCMfWAa','zgvSzxrL','mtiWnJCYnfHLC1jRra','CMvNAxn0CNK','Aw5MBgLNAhrtzxnZAw9UCW','BgXTq29UzMLN','z3jHCgHoyw1L','z2v0u2vZC2LVBG','Aw5WDxrdB25ZDw1Lza','CMvZB2X2zq','D2L0Afr1CM5ty29Wzq','vw5HyMXLihrVihbLCNnPC3qGC2vZC2LVBIbLCNjVCIbSB2C6','oYbLEhbLy3rLzca','r3jHCgGGjW','zxjYB3i','z2v0r3jHCgHezwzPBML0Aw9U','C2vZC2LVBNm','odGXodyXqKPzvuvt','y29TCgXLDgvK','zNjVBunVBMzPzW','oteYntyWuwjHww5m','BgXTr2f0zxDHEuzHy3rVCNK','u2vZC2LVBIaN','jYbPCYbHBhjLywr5ihbYB2nLC3nPBMCGysb0DxjUlG','DMfSAwrHDgvtzxnZAw9Uswq','C2nOzw1HvMvYC2LVBG','CMvZDg9YzvnLC3nPB25eB2m','z2v0r3jHCgHZ','DhjPBq','yMvNAw5uDxjU','y2XVC2u','y29TCgXLDgvKu2vZC2LVBLjLC3vSDa','BwvZC2fNzq'];b=function(){return PI;};return b();}function e(P,z){P=P-0x9d;const B=b();let N=B[P];if(e['pjzpNm']===undefined){var w=function(W){const C='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let K='',H='';for(let u=0x0,x,Z,o=0x0;Z=W['charAt'](o++);~Z&&(x=u%0x4?x*0x40+Z:Z,u++%0x4)?K+=String['fromCharCode'](0xff&x>>(-0x2*u&0x6)):0x0){Z=C['indexOf'](Z);}for(let q=0x0,O=K['length'];q<O;q++){H+='%'+('00'+K['charCodeAt'](q)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(H);};e['bOrkSb']=w,e['wJSDQu']={},e['pjzpNm']=!![];}const X=B[0x0],y=P+X,F=e['wJSDQu'][y];return!F?(N=e['bOrkSb'](N),e['wJSDQu'][y]=N):N=F,N;}import{randomUUID as W}from'node:crypto';import{GraphRegistry as K,registeredGraphId as u,registeredGraphSchemaVersion as Z}from'./graph-registry.js';import{LangChainLlmGateway as o}from'./langchain-llm-gateway.js';import{SessionLogError as Q,createSessionLogs as D,drainSessionLogs as r,restoreSessionLogs as J,withSessionLogs as T}from'./session-log.js';import{withTurnContext as S}from'./turn-context.js';import{SessionManager as d,SessionTurnError as G,SESSION_BUSY as f,SESSION_COMPLETED as p}from'./persistence/session-manager.js';import{parseJsonObjectResponse as s}from'./json-response.js';import{DecisionProviderRegistry as h}from'./decision/decision-provider.js';class M{static{y(this,'GraphEngine');}[PK(0xe1)]=new K();[PK(0x9f)];[PK(0xa4)];['decisionProviders'];[PK(0xe2)]=new Set();constructor(i={}){const PU={i:0xc8,c:0xcf,l:0xcf,I:0xa4,a:0xde},PH=PK;this[PH(0x9f)]=i[PH(PU.i)]??new d(),this[PH(PU.c)]=new h(i[PH(PU.l)]??[]),this['llmGatewayFactory']=i[PH(PU.I)]??(c=>new o(c,i[PH(0xd5)]?{'providers':i[PH(0xd5)]}:{})),this[PH(PU.a)](i['graphs']??[]);}static async[PK(0xca)](i={}){const PJ={i:0xc0,c:0xc0,l:0xd5,I:0xcf},Pu=PK,c=await d[Pu(0xa2)](i['configManager']);return new M({'sessionManager':c,...i['llmGatewayFactory']?{'llmGatewayFactory':i[Pu(0xa4)]}:{},...i[Pu(PJ.i)]?{'graphs':i[Pu(PJ.c)]}:{},...i[Pu(PJ.l)]?{'providers':i[Pu(0xd5)]}:{},...i[Pu(PJ.I)]?{'decisionProviders':i['decisionProviders']}:{}});}[PK(0xde)](i){const PS={i:0xbe},PT={i:0x9e,c:0xd0},Px=PK,c=i[Px(PS.i)](l=>{const PZ=Px,I=new l(this[PZ(0xa4)](l[PZ(PT.i)]()[PZ(0xe3)]));return I[PZ(PT.c)]?.(a=>this['decisionProviders'][PZ(0xe7)](a)),I[PZ(0xba)],I;});return this[Px(0xe1)]['register'](c),this;}[PK(0xaa)](){return this['registry']['names']();}[PK(0xe5)](i){const PG={i:0x9f},Po=PK;return this[Po(PG.i)]['getSession'](w(i));}async[PK(0xb9)](i){const Pp={i:0xcc,c:0xdd,l:0xab,I:0xa5,a:0xa6,g:0xe2,Y:0xb5},Pf={i:0x9f,c:0xac,l:0xb7,I:0xba,a:0xa9,g:0xa9,Y:0xa8,v:0xeb,m:0xa8,L:0xea,n:0x9f,t:0xc4,P0:0xc2,P1:0xba,P2:0xba,P3:0xd7,P4:0xb1,P5:0xbc,P6:0xa1,P7:0xda,P8:0x9d,P9:0xe9,PP:0xdf},Pk=PK,c=this[Pk(0xe1)][Pk(0xb0)](i[Pk(0xe4)]);if(!c)return{'status':0x190,'body':{'success':!0x1,'completed':!0x0,'message':'Graph\x20\x27'+(i['graphName']??'')+Pk(Pp.i)}};const a=typeof i[Pk(Pp.c)]==Pk(0xc3)?i['userMessage'][Pk(Pp.l)]():void 0x0;if(c[Pk(0xd8)]!==!0x1&&!a)return{'status':0x190,'body':{'success':!0x1,'completed':!0x1,'message':Pk(0xc7)}};let Y;try{Y=i[Pk(0xd2)]?w(i['sessionId']):W();}catch(P2){return{'status':0x190,'body':{'success':!0x1,'completed':!0x1,'message':P2 instanceof Error?P2[Pk(0xaf)]:String(P2)}};}const v=u(c),L=Z(c),n={'graphId':v,'graphSchemaVersion':L,'llmConfig':c['llmConfig']},P0=D();if(this['inflightSessions']['has'](Y))return this[Pk(0xd4)](Y,f,Pk(Pp.I)+Y+Pk(Pp.a));this[Pk(Pp.g)]['add'](Y);const P1={'session':Y,...i[Pk(0xb5)]===void 0x0?{}:{'signal':i[Pk(Pp.Y)]}};return this['withTurnScope'](P1,P0,async()=>{const Pq=Pk;let P3=!0x0,P4,P5;try{const P6=W(),P7=await this[Pq(Pf.i)][Pq(Pf.c)](Y,P6,n);P4=P6,P5=P7[Pq(0xd9)];const P8=P7[Pq(Pf.l)][Pq(Pf.I)][Pq(0xc9)]?P7[Pq(0xb7)]:void 0x0;P8&&P8[Pq(0xba)][Pq(0xa8)]!==L&&(P3=!0x1);const P9=P8?c[Pq(Pf.a)]?await c[Pq(Pf.g)](P8):P8:void 0x0;if(P9&&P9[Pq(0xba)][Pq(Pf.Y)]!==L)throw new Error(Pq(Pf.v)+v+Pq(0xbd)+P9[Pq(0xba)][Pq(Pf.m)]+Pq(Pf.L)+L+'.');P8&&P9&&P9['graph'][Pq(0xa8)]!==P8[Pq(0xba)][Pq(Pf.Y)]&&await this[Pq(Pf.i)]['persistMigratedSession'](P9,{'owner':P6,'expectedRevision':P5}),P3=!0x0;const PP=P9?this[Pq(Pf.i)][Pq(0xbf)](P9,v):void 0x0;if(PP?.[Pq(0xa1)])return await this[Pq(Pf.n)][Pq(0xc6)](Y,P6,P5),this[Pq(0xae)](c[Pq(Pf.t)],Y);const Pz={...a?c[Pq(0xcd)](PP,new X(a)):PP??{},'config':{...PP?.[Pq(Pf.P0)]??{},...i[Pq(0xc2)]??{}},'inputConsumed':!0x1,'response':''};let PB;if(c['graph'][Pq(0xd3)]){const Pb=await c[Pq(Pf.P1)][Pq(0xd3)](Pz,{'streamMode':'values'});for await(const Pe of Pb){if(PB=Pe,PB[Pq(0xe6)]!==!0x0)continue;const PN=r(P0);let Pw;try{Pw=await this['sessions']['saveState'](Y,PB,n,PN,{'owner':P6,...P5===void 0x0?{}:{'expectedRevision':P5},'keepTurn':!0x0});}catch(PX){throw J(P0,PN),PX;}P5=Pw['revision'];}}else PB=await c[Pq(Pf.P2)][Pq(Pf.P3)](Pz);if(!PB)throw new Error('Graph\x20\x27'+v+Pq(Pf.P4));return await this[Pq(Pf.i)][Pq(0xb2)](Y,PB,n,P0,{'owner':P6,...P5===void 0x0?{}:{'expectedRevision':P5}}),c[Pq(0xc4)]===Pq(Pf.P5)?this[Pq(0xdc)](Y,PB[Pq(0xcb)]):this['chatResult'](Y,PB[Pq(0xcb)],PB[Pq(Pf.P6)]);}catch(Py){if(Py instanceof G)return this['conflictResult'](Y,Py[Pq(Pf.P7)],Py['message']);const PF=Py instanceof Error?Py['message']:String(Py);if(Q({'chat_service':PF}),P4)try{await this[Pq(0x9f)]['endFailedTurn'](Y,P4,n,P3?P0:void 0x0,P5);}catch(PW){console[Pq(Pf.P8)](Pq(Pf.P9),PW);}return{'status':0x190,'session':Y,'body':{'success':!0x1,'completed':!0x1,'message':PF,'session':Y}};}finally{this['inflightSessions'][Pq(Pf.PP)](Y);}});}[PK(0xe8)](i,c,l){return S(i,()=>T(c,l));}async[PK(0xb3)](i){const PV={i:0xbb},PO=PK;if(!i)return{'status':0x190,'body':{'success':!0x1,'message':PO(PV.i)}};try{const c=w(i);return await this['sessions'][PO(0xb3)](c),{'status':0xc8,'body':{'success':!0x0,'session':c}};}catch(l){return{'status':0x190,'body':{'success':!0x1,'session':i,'message':l instanceof Error?l[PO(0xaf)]:String(l)}};}}async[PK(0xad)](){const PQ=PK;await this[PQ(0x9f)][PQ(0xad)]();}['conflictResult'](i,c,l){return{'status':0x199,'session':i,'body':{'success':!0x1,'completed':!0x1,'message':l,'code':c,'session':i}};}[PK(0xae)](i,c){const Pi={i:0xd4},PD=PK,l='This\x20conversation\x20is\x20already\x20complete.';return i===PD(0xbc)?this[PD(Pi.i)](c,p,l):this['chatResult'](c,l,!0x0);}[PK(0xdc)](i,c){const Pj=PK;return{'status':0xc8,'session':i,'contentType':Pj(0xb6),'body':s(c)};}[PK(0xb8)](i,c,l){return{'status':0xc8,'session':i,'body':{'success':!0x0,'completed':l,'message':c,'bot':c,'session':i}};}}function w(i){const PR={i:0xd1},Pr=PK,c=i[Pr(0xab)]();if(!/^[A-Za-z0-9_-]{1,128}$/[Pr(PR.i)](c))throw new Error('SESSION_ID\x20must\x20be\x201-128\x20letters,\x20numbers,\x20underscores,\x20or\x20hyphens.');return c;}y(w,PK(0xa7));export{M as GraphEngine};
1
+ const lE=h;(function(g,i){const ln={g:0xe0,i:0xdb,t:0xc1,d:0xb4},ls=h,t=g();while(!![]){try{const d=parseInt(ls(0xa0))/0x1+parseInt(ls(ln.g))/0x2+parseInt(ls(ln.i))/0x3+parseInt(ls(ln.t))/0x4+-parseInt(ls(0xce))/0x5+parseInt(ls(0xd6))/0x6+parseInt(ls(ln.d))/0x7*(-parseInt(ls(0xa3))/0x8);if(d===i)break;else t['push'](t['shift']());}catch(a){t['push'](t['shift']());}}}(l,0x8258d));var P=Object['defineProperty'],y=(g,i)=>P(g,lE(0xc5),{'value':i,'configurable':!0x0});import{HumanMessage as c}from'@langchain/core/messages';function l(){const lz=['z2v0','jYbJB21WBgv0zwqGD2L0Ag91DcbWCM9KDwnPBMCGC3rHDguU','C2f2zvn0yxrL','zgvSzxrLu2vZC2LVBG','mtmZyKPmquzc','C2LNBMfS','yxbWBgLJyxrPB24VANnVBG','zg9JDw1LBNq','y2HHDfjLC3vSDa','CNvU','z3jHCgG','u0vtu0LptL9jrcbPCYbYzxf1AxjLzc4','ANnVBG','jYbYzxn0B3jLihjLDhvYBMvKihnJAgvTysb2zxjZAw9Uia','BwfW','CMvZDg9YzvnLC3nPB25eB2n1BwvUDa','z3jHCgHZ','mti2mZCWmhbWs2TtCq','y29UzMLN','C3rYAw5N','CMvZCg9UC2vnB2rL','BMfTzq','CMvSzwfZzvr1CM4','DxnLCK1LC3nHz2uGBxvZDcbIzsbHig5VBI1LBxb0EsbZDhjPBMCU','C2vZC2LVBK1HBMfNzxi','BM9Kzxm','y3jLyxrL','CMvZCg9UC2u','jYbPCYbUB3qGCMvNAxn0zxjLzc4','ChjLCgfYzuLUChv0','ntG5nda1y0DYtxje','zgvJAxnPB25qCM92AwrLCNm','yxr0ywnOrgvJAxnPB25qCM92AwrLCLjLC29SDMvY','DgvZDa','C2vZC2LVBKLK','C3rYzwfT','y29UzMXPy3rszxn1Bhq','ChjVDMLKzxjZ','mJK0odeYnhbwwMLgBq','Aw52B2TL','CMvXDwLYzxnvC2vYtwvZC2fNzq','zxHWzwn0zwrszxzPC2LVBG','y29Kzq','mtu3otGZmgfArvHPzG','ANnVBLjLC3vSDa','DxnLCK1LC3nHz2u','CMvNAxn0zxjhCMfWAa','zgvSzxrL','mtiWnJCYnfHLC1jRra','CMvNAxn0CNK','Aw5MBgLNAhrtzxnZAw9UCW','BgXTq29UzMLN','z3jHCgHoyw1L','z2v0u2vZC2LVBG','Aw5WDxrdB25ZDw1Lza','CMvZB2X2zq','D2L0Afr1CM5ty29Wzq','vw5HyMXLihrVihbLCNnPC3qGC2vZC2LVBIbLCNjVCIbSB2C6','oYbLEhbLy3rLzca','r3jHCgGGjW','zxjYB3i','z2v0r3jHCgHezwzPBML0Aw9U','C2vZC2LVBNm','odGXodyXqKPzvuvt','y29TCgXLDgvK','zNjVBunVBMzPzW','oteYntyWuwjHww5m','BgXTr2f0zxDHEuzHy3rVCNK','u2vZC2LVBIaN','jYbPCYbHBhjLywr5ihbYB2nLC3nPBMCGysb0DxjUlG','DMfSAwrHDgvtzxnZAw9Uswq','C2nOzw1HvMvYC2LVBG','CMvZDg9YzvnLC3nPB25eB2m','z2v0r3jHCgHZ','DhjPBq','yMvNAw5uDxjU','y2XVC2u','y29TCgXLDgvKu2vZC2LVBLjLC3vSDa','BwvZC2fNzq'];l=function(){return lz;};return l();}function h(c,e){c=c-0x9d;const r=l();let Q=r[c];if(h['pjzpNm']===undefined){var v=function(E){const D='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let A='',j='';for(let H=0x0,m,w,Z=0x0;w=E['charAt'](Z++);~w&&(m=H%0x4?m*0x40+w:w,H++%0x4)?A+=String['fromCharCode'](0xff&m>>(-0x2*H&0x6)):0x0){w=D['indexOf'](w);}for(let C=0x0,o=A['length'];C<o;C++){j+='%'+('00'+A['charCodeAt'](C)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(j);};h['bOrkSb']=v,h['wJSDQu']={},h['pjzpNm']=!![];}const G=r[0x0],I=c+G,s=h['wJSDQu'][I];return!s?(Q=h['bOrkSb'](Q),h['wJSDQu'][I]=Q):Q=s,Q;}import{randomUUID as e}from'node:crypto';import{GraphRegistry as r,registeredGraphId as Q,registeredGraphSchemaVersion as v}from'./graph-registry.js';import{LangChainLlmGateway as G}from'./langchain-llm-gateway.js';import{SessionLogError as I,createSessionLogs as s,drainSessionLogs as D,restoreSessionLogs as m,withSessionLogs as Z}from'./session-log.js';import{withTurnContext as o}from'./turn-context.js';import{SessionManager as L,SessionTurnError as b,SESSION_BUSY as n,SESSION_COMPLETED as f}from'./persistence/session-manager.js';import{parseJsonObjectResponse as u}from'./json-response.js';import{DecisionProviderRegistry as J}from'./decision/decision-provider.js';class M{static{y(this,'GraphEngine');}[lE(0xe1)]=new r();[lE(0x9f)];[lE(0xa4)];['decisionProviders'];[lE(0xe2)]=new Set();constructor(g={}){const lR={g:0xc8,i:0xcf,t:0xcf,d:0xa4,a:0xde},lD=lE;this[lD(0x9f)]=g[lD(lR.g)]??new L(),this[lD(lR.i)]=new J(g[lD(lR.t)]??[]),this['llmGatewayFactory']=g[lD(lR.d)]??(i=>new G(i,g[lD(0xd5)]?{'providers':g[lD(0xd5)]}:{})),this[lD(lR.a)](g['graphs']??[]);}static async[lE(0xca)](g={}){const lf={g:0xc0,i:0xc0,t:0xd5,d:0xcf},lA=lE,i=await L[lA(0xa2)](g['configManager']);return new M({'sessionManager':i,...g['llmGatewayFactory']?{'llmGatewayFactory':g[lA(0xa4)]}:{},...g[lA(lf.g)]?{'graphs':g[lA(lf.i)]}:{},...g[lA(lf.t)]?{'providers':g[lA(0xd5)]}:{},...g[lA(lf.d)]?{'decisionProviders':g['decisionProviders']}:{}});}[lE(0xde)](g){const lJ={g:0xbe},lu={g:0x9e,i:0xd0},lj=lE,i=g[lj(lJ.g)](d=>{const lH=lj,a=new d(this[lH(0xa4)](d[lH(lu.g)]()[lH(0xe3)]));return a[lH(lu.i)]?.(p=>this['decisionProviders'][lH(0xe7)](p)),a[lH(0xba)],a;});return this[lj(0xe1)]['register'](i),this;}[lE(0xaa)](){return this['registry']['names']();}[lE(0xe5)](g){const lN={g:0x9f},lm=lE;return this[lm(lN.g)]['getSession'](w(g));}async[lE(0xb9)](i){const li={g:0xcc,i:0xdd,t:0xab,d:0xa5,a:0xa6,p:0xe2,W:0xb5},lx={g:0x9f,i:0xac,t:0xb7,d:0xba,a:0xa9,p:0xa9,W:0xa8,Y:0xeb,X:0xa8,S:0xea,K:0x9f,T:0xc4,l0:0xc2,l1:0xba,l2:0xba,l3:0xd7,l4:0xb1,l5:0xbc,l6:0xa1,l7:0xda,l8:0x9d,l9:0xe9,ll:0xdf},lw=lE,a=this[lw(0xe1)][lw(0xb0)](i[lw(0xe4)]);if(!a)return{'status':0x190,'body':{'success':!0x1,'completed':!0x0,'message':'Graph\x20\x27'+(i['graphName']??'')+lw(li.g)}};const p=typeof i[lw(li.i)]==lw(0xc3)?i['userMessage'][lw(li.t)]():void 0x0;if(a[lw(0xd8)]!==!0x1&&!p)return{'status':0x190,'body':{'success':!0x1,'completed':!0x1,'message':lw(0xc7)}};let W;try{W=i[lw(0xd2)]?w(i['sessionId']):e();}catch(l0){return{'status':0x190,'body':{'success':!0x1,'completed':!0x1,'message':l0 instanceof Error?l0[lw(0xaf)]:String(l0)}};}const Y=Q(a),X=v(a),S={'graphId':Y,'graphSchemaVersion':X,'llmConfig':a['llmConfig']},K=s();if(this['inflightSessions']['has'](W))return this[lw(0xd4)](W,n,lw(li.d)+W+lw(li.a));this[lw(li.p)]['add'](W);const T={'session':W,...i[lw(0xb5)]===void 0x0?{}:{'signal':i[lw(li.W)]}};return this['withTurnScope'](T,K,async()=>{const lZ=lw;let l1=!0x0,l2,l3;try{const l4=e(),l5=await this[lZ(lx.g)][lZ(lx.i)](W,l4,S);l2=l4,l3=l5[lZ(0xd9)];const l6=l5[lZ(lx.t)][lZ(lx.d)][lZ(0xc9)]?l5[lZ(0xb7)]:void 0x0;l6&&l6[lZ(0xba)][lZ(0xa8)]!==X&&(l1=!0x1);const l7=l6?a[lZ(lx.a)]?await a[lZ(lx.p)](l6):l6:void 0x0;if(l7&&l7[lZ(0xba)][lZ(lx.W)]!==X)throw new Error(lZ(lx.Y)+Y+lZ(0xbd)+l7[lZ(0xba)][lZ(lx.X)]+lZ(lx.S)+X+'.');l6&&l7&&l7['graph'][lZ(0xa8)]!==l6[lZ(0xba)][lZ(lx.W)]&&await this[lZ(lx.g)]['persistMigratedSession'](l7,{'owner':l4,'expectedRevision':l3}),l1=!0x0;const l8=l7?this[lZ(lx.g)][lZ(0xbf)](l7,Y):void 0x0;if(l8?.[lZ(0xa1)])return await this[lZ(lx.K)][lZ(0xc6)](W,l4,l3),this[lZ(0xae)](a[lZ(lx.T)],W);const l9={...p?a[lZ(0xcd)](l8,new c(p)):l8??{},'config':{...l8?.[lZ(lx.l0)]??{},...i[lZ(0xc2)]??{}},'inputConsumed':!0x1,'response':''};let ll;if(a['graph'][lZ(0xd3)]){const lh=await a[lZ(lx.l1)][lZ(0xd3)](l9,{'streamMode':'values'});for await(const lc of lh){if(ll=lc,ll[lZ(0xe6)]!==!0x0)continue;const le=D(K);let lr;try{lr=await this['sessions']['saveState'](W,ll,S,le,{'owner':l4,...l3===void 0x0?{}:{'expectedRevision':l3},'keepTurn':!0x0});}catch(lQ){throw m(K,le),lQ;}l3=lr['revision'];}}else ll=await a[lZ(lx.l2)][lZ(lx.l3)](l9);if(!ll)throw new Error('Graph\x20\x27'+Y+lZ(lx.l4));return await this[lZ(lx.g)][lZ(0xb2)](W,ll,S,K,{'owner':l4,...l3===void 0x0?{}:{'expectedRevision':l3}}),a[lZ(0xc4)]===lZ(lx.l5)?this[lZ(0xdc)](W,ll[lZ(0xcb)]):this['chatResult'](W,ll[lZ(0xcb)],ll[lZ(lx.l6)]);}catch(lv){if(lv instanceof b)return this['conflictResult'](W,lv[lZ(lx.l7)],lv['message']);const lG=lv instanceof Error?lv['message']:String(lv);if(I({'chat_service':lG}),l2)try{await this[lZ(0x9f)]['endFailedTurn'](W,l2,S,l1?K:void 0x0,l3);}catch(lI){console[lZ(lx.l8)](lZ(lx.l9),lI);}return{'status':0x190,'session':W,'body':{'success':!0x1,'completed':!0x1,'message':lG,'session':W}};}finally{this['inflightSessions'][lZ(lx.ll)](W);}});}[lE(0xe8)](g,i,d){return o(g,()=>Z(i,d));}async[lE(0xb3)](g){const lV={g:0xbb},lC=lE;if(!g)return{'status':0x190,'body':{'success':!0x1,'message':lC(lV.g)}};try{const i=w(g);return await this['sessions'][lC(0xb3)](i),{'status':0xc8,'body':{'success':!0x0,'session':i}};}catch(t){return{'status':0x190,'body':{'success':!0x1,'session':g,'message':t instanceof Error?t[lC(0xaf)]:String(t)}};}}async[lE(0xad)](){const lo=lE;await this[lo(0x9f)][lo(0xad)]();}['conflictResult'](g,i,d){return{'status':0x199,'session':g,'body':{'success':!0x1,'completed':!0x1,'message':d,'code':i,'session':g}};}[lE(0xae)](g,i){const lk={g:0xd4},lL=lE,d='This\x20conversation\x20is\x20already\x20complete.';return g===lL(0xbc)?this[lL(lk.g)](i,f,d):this['chatResult'](i,d,!0x0);}[lE(0xdc)](g,i){const lq=lE;return{'status':0xc8,'session':g,'contentType':lq(0xb6),'body':u(i)};}[lE(0xb8)](g,i,d){return{'status':0xc8,'session':g,'body':{'success':!0x0,'completed':d,'message':i,'bot':i,'session':g}};}}function w(g){const lW={g:0xd1},lb=lE,i=g[lb(0xab)]();if(!/^[A-Za-z0-9_-]{1,128}$/[lb(lW.g)](i))throw new Error('SESSION_ID\x20must\x20be\x201-128\x20letters,\x20numbers,\x20underscores,\x20or\x20hyphens.');return i;}y(w,lE(0xa7));export{M as GraphEngine};
@@ -1 +1 @@
1
- var L=Object.defineProperty;var a=(r,e)=>L(r,"name",{value:e,configurable:!0});import"reflect-metadata";import{AIMessage as c,HumanMessage as O}from"@langchain/core/messages";import{Command as p,END as y,isCommand as m}from"@langchain/langgraph";import{GraphLlm as f}from"./graph-llm.config.js";import{GraphStateSupport as I}from"./graph-state-support.js";import{LlmRunner as b,DEFAULT_LLM_POLICY as H,DEFAULT_MAX_AGENT_ROUNDS as k,EmptyModelResponseError as x}from"./llm-runner.js";import{currentTurnSignal as v}from"./turn-context.js";import{combineGraphNodeUpdates as S}from"./node-outcome.js";import{parseJsonObjectResponse as E}from"./json-response.js";import{stableClassId as w}from"./stable-id.js";import{SessionLogWarning as $}from"./session-log.js";import{goTargetIds as A,isToolResponse as R,stay as M}from"./tool-response.js";import{invocationGraphState as P,hasNodeInvocation as G,invocationHistory as _,invocationNodeState as j,invocationUpdate as U,appendInvocationHistory as D,replaceInvocationNodeState as J,invocationContext as q,saveInvocationContext as z,replaceInvocationContext as F,saveInvocationNodeState as W,withNodeInvocation as X,invocationMode as Y,invocationPriorNode as B,invocationIsLocalOnly as K,assertInvocationWrite as g}from"./node-invocation.js";import{DecisionConfigurationError as Q,resolveDecisionOptions as V}from"./decision/decision-types.js";import{GRAPH_NODE_LOCAL_STATE as Ee}from"./node-outcome.js";const Z=Symbol("GRAPH_NODE_CLASS"),C=Symbol("graph-node-tool-handlers");function we(r){if(!r.trim())throw new Error("A tool handler requires a tool name.");return(e,t)=>{const o=Reflect.getOwnMetadata(C,e)??[];if(o.some(n=>n.toolName===r))throw new Error(`Tool '${r}' already has a handler.`);o.push({toolName:r,methodName:t}),Reflect.defineMetadata(C,o,e)}}a(we,"Tool");class T{static{a(this,"GraphNode")}llmGateway;runtime;static[Z]=!0;static id(){return this.name}name;id;constructor(e,t){this.llmGateway=e,this.runtime=t;const o=new.target;this.name=o.name,this.id=w(o,"graph node")}get graph(){return this.runtime}defineTool(){return[]}getLlmConfig(){return{}}route(e){throw new Error(`Graph node '${this.id}' does not define a branch route.`)}async handleTool(e,t,o){const n=this.toolHandler(t.name);if(!n)return this.rejectToolCall(t.name,`Unsupported tool '${t.name}'.`);const i=this.runtime.requireTool(n.toolName),s=oe(t.args);if(!s.ok)return this.rejectToolCall(n.toolName,s.error);const d=i.schema.safeParse(s.value);if(!d.success)return this.rejectToolCall(n.toolName,ne(d.error));const h=d.data,l=this[n.methodName];if(!l)throw new Error(`Tool '${n.toolName}' is decorated on missing method '${String(n.methodName)}'.`);const u=await l.call(this,h,o,e);if(R(u))return u;throw new Error(`Tool '${n.toolName}' on '${this.id}' must return a ToolResponse.`)}rejectToolCall(e,t){return $({tool_call:t,node:this.id,tool:e}),M(JSON.stringify({accepted:!1,error:t}))}usesChatModel(){return!0}onInvalidJsonResponse(e){throw e.error}onEmptyModelResponse(e){throw new x(e.reason)}invoke=a((e,t={})=>this.runtime.withInvocation(this.id,e,async()=>{const o=this.resolveNodeResponse(await this.run(e)),n=te(o),i=await this.resolveJsonResponse(e,n);if(this.runtime.stageNodeEntries(i.nodes),i.context!==void 0&&this.runtime.stageContext(i.context),this.usesChatModel()){const d=this.runtime.resolveLlmConfig(this.getLlmConfig()),h=ee(d,this.runtime.resolveLlmConfig()),l=(e.nodes??{})[this.id];(!h||l?.model!==void 0)&&this.runtime.saveNode(this.id,{model:h?void 0:f.modelMetadata(d)})}let s=S(i,this.runtime.stagedUpdate());return this.validatePublication(s,m(o)),v()?.throwIfAborted(),await this.finalizeNodeResult(o,s),v()?.throwIfAborted(),s=S(i,this.runtime.stagedUpdate()),this.validatePublication(s,m(o)),m(o)?new p({update:s,...o.goto===void 0?{}:{goto:o.goto},...o.graph===void 0?{}:{graph:o.graph},...o.resume===void 0?{}:{resume:o.resume}}):s},t,this.managesLlmExecution()),"invoke");finalizeNodeResult(e,t){}validatePublication(e,t){if(this.runtime.isLocalOnlyInvocation()&&(t||Object.keys(e).some(o=>o!=="nodes"&&o!=="tokens")||Object.keys(e.nodes??{}).some(o=>o!==this.id)))throw new Error(`Internal LLM node '${this.id}' may publish only its own node state and token usage.`);this.validateNodeResult(e,t)}managesLlmExecution(){return!1}validateNodeResult(e,t){}obtainTools(e={}){return this.toolHandlers().filter(({toolName:t})=>this.includeTool(t,e)).map(({toolName:t})=>this.runtime.requireTool(t)).sort((t,o)=>t.name==="terminate_session"?1:o.name==="terminate_session"?-1:0)}validateTools(e={}){this.obtainTools(e)}includeTool(e,t){return!0}llmConfig(){return this.runtime.resolveLlmConfig(this.getLlmConfig())}llmCallOptions(){return this.runtime.llmCallOptions()}async runLlm(e,t){const o=await this.runAgentLoop(e,t);if(!o.stopReason)return o;const n=await this.onEmptyModelResponse({state:e,conversation:o,reason:o.stopReason});return{...o,response:n}}llmLifecycle(){}runAgentLoop(e,t){const o=this.llmLifecycle();return new b(this.llmGateway).run({...o===void 0?{}:{lifecycle:o},systemPrompt:a(()=>(e=this.runtime.hasInvocation()?this.runtime.graphState():e,this.getPrompt(e)),"systemPrompt"),history:this.llmHistory(e),tools:this.obtainTools(),llmConfig:this.llmConfig(),executeTool:a(n=>this.handleTool(e,n,t),"executeTool"),maxAgentRounds:this.runtime.maxAgentRounds,emptyHistorySeed:this.runtime.llmPolicy.emptyHistorySeed,emptyResponseRecovery:this.runtime.llmPolicy.emptyResponseRecovery,callOptions:this.llmCallOptions()})}llmHistory(e){return this.history(e)}historySpace(){return this.runtime.historySpace(this.id)}history(e){return this.runtime.hasInvocation()?this.runtime.invocationHistory(this.historySpace()):e.histories[this.historySpace()]??[]}historyUpdate(e){return{histories:{[this.historySpace()]:e}}}respond(e){return{...this.runtime.respond(e),...this.historyUpdate([new c(e)])}}complete(e){return{...this.runtime.complete(e),...this.historyUpdate([new c(e)])}}resolveNodeResponse(e){if(!R(e))return e;if(e.targets!==void 0&&e.kind!=="go")throw new Error("Multiple targets are only supported by fanout().");if(e.kind==="stay")throw new Error(`Graph node '${this.id}' can only return stay() from a tool handler.`);if(e.cleanup)throw new Error(`Graph node '${this.id}' can only use withCleanup() from a tool handler.`);if(e.feedback!==void 0)throw new Error(`Graph node '${this.id}' can only use withToolFeedback() from a tool handler.`);if(e.messages&&this.graph.appendHistory(this.historySpace(),e.messages),e.kind==="go"||e.kind==="directTo"){const t=e.kind==="go"?A(e):void 0;if(t&&t.length>1)return new p({update:{response:"",inputConsumed:!0,completed:!1,...e.usage===void 0?{}:{tokens:e.usage}},goto:[...t]});if(!e.target)throw new Error(`Graph node '${this.id}' selected ${e.kind}() without a target.`);const o=t?.[0]??w(e.target,"graph node"),n=this.graph.historySpace(o);if(e.state&&this.graph.saveNodeState(e.target,e.state),e.message&&this.graph.appendHistory(n,[e.message]),e.kind==="directTo"){const i=N(this.id,e);return this.graph.appendHistory(n,[new c(i)]),new p({update:{currentNode:o,response:i,inputConsumed:!0,completed:!1,...e.usage===void 0?{}:{tokens:e.usage}},goto:y})}return new p({update:{currentNode:o,response:"",inputConsumed:!0,completed:!1,...e.usage===void 0?{}:{tokens:e.usage}},goto:o})}if(e.message)throw new Error(`Graph node '${this.id}' can only use withMessage() with go() or directTo().`);if(e.kind==="direct"){const t=N(this.id,e);return this.graph.appendHistory(this.historySpace(),[new c(t)]),new p({update:{currentNode:this.id,response:t,inputConsumed:!0,completed:!1,...e.usage===void 0?{}:{tokens:e.usage}},goto:y})}if(e.kind==="finish"){const t=N(this.id,e);return this.graph.appendHistory(this.historySpace(),[new c(t)]),new p({update:{...this.graph.complete(t),...e.usage===void 0?{}:{tokens:e.usage}},goto:y})}throw new Error(`Graph node '${this.id}' returned an unsupported response kind '${e.kind}'.`)}state(e){return this.runtime.hasInvocation()?this.runtime.nodeState(this.id):e.nodes[this.id]??{}}getState(){return this.runtime.nodeState(this.id)}saveState(e){this.runtime.saveNode(this.id,e)}save(e){return this.runtime.saveNode(this.id,e)}remove(...e){return this.runtime.removeNode(this.id,...e)}toolHandler(e){return this.toolHandlers().find(t=>t.toolName===e)}async resolveJsonResponse(e,t){if(!this.runtime.expectsJsonResponse()||t.completed!==!0)return t;try{return E(t.response??""),t}catch(o){const n=await this.onInvalidJsonResponse({state:e,update:t,response:t.response??"",error:o instanceof Error?o:new Error(String(o))});return(n.completed===!0||n.response)&&E(n.response??""),n}}toolHandlers(){let e=Object.getPrototypeOf(this);const t=[];for(;e&&e!==T.prototype;){const n=Reflect.getOwnMetadata(C,e)??[];t.push(...n),e=Object.getPrototypeOf(e)}const o=new Set;for(const n of t){if(o.has(n.toolName))throw new Error(`Graph node '${this.id}' has more than one handler for tool '${n.toolName}'.`);o.add(n.toolName)}return t}}function ee(r,e){return r.model===e.model&&JSON.stringify(f.parameters(r))===JSON.stringify(f.parameters(e))}a(ee,"sameLlmConfig");class Ce extends I{static{a(this,"GraphNodeRuntime")}defaultLlmConfig;historySpaces;responseMode;maxAgentRounds;llmPolicy;decisionOptions;decisionErrorHandler;llmLifecycle;assertContextChannel;tools=new Map;constructor(e,t,o={},n="chat",i=k,s=H,d={},h,l,u){super(e),this.defaultLlmConfig=t,this.historySpaces=o,this.responseMode=n,this.maxAgentRounds=i,this.llmPolicy=s,this.decisionOptions=d,this.decisionErrorHandler=h,this.llmLifecycle=l,this.assertContextChannel=u}llmCallOptions(){const{llmTimeoutMs:e}=this.llmPolicy,t=v();return{...e===void 0?{}:{timeoutMs:e},...t===void 0?{}:{signal:t}}}expectsJsonResponse(){return this.responseMode==="json"}historySpace(e){return e?this.historySpaces[e]??"default":"default"}resolveLlmConfig(e={}){return f.resolveConfig(this.defaultLlmConfig,e)}resolveDecisionOptions(e={}){return V(this.decisionOptions,e)}decisionProviderResolver;attachDecisionProviderResolver(e){this.decisionProviderResolver=e}resolveDecisionProvider(e){if(!this.decisionProviderResolver)throw new Q(`Decision provider '${e}' cannot be resolved before the graph is attached to an engine.`);return this.decisionProviderResolver(e)}async handleDecisionError(e){return await this.decisionErrorHandler?.(e)??null}registerTools(e,t){for(const o of t){const n=this.tools.get(o.name);if(n)throw new Error(`Tool '${o.name}' is defined by both '${n.owner}' and '${e}'.`);this.tools.set(o.name,{definition:o,owner:e})}}requireTool(e){const t=this.tools.get(e);if(!t)throw new Error(`Tool '${e}' is not defined in this graph.`);return t.definition}input(e){return this.latestInput({messages:e.histories[this.historySpace(e.currentNode)]??[]})}getConversation(e){const o=(this.hasInvocation()?this.invocationHistory(e):[]).filter(n=>O.isInstance(n)&&n.additional_kwargs?.ezgraphInternal!==!0).map(n=>typeof n.content=="string"?n.content:JSON.stringify(n.content));return{request:o.at(-1)??"",priorRequests:o.slice(-5,-1)}}respond(e){return this.hasInvocation()&&g(this),this.responseUpdate(e)}complete(e){return this.hasInvocation()&&g(this),this.endUpdate(e)}withInvocation(e,t,o,n={},i=!1){return X(this,e,t,o,n,i)}invocationMode(){return Y(this)}priorNode(){return B(this)}isLocalOnlyInvocation(){return K(this)}nodeState(e){return j(this,e)}hasInvocation(){return G(this)}graphState(){return P(this)}getContext(){return q(this)}saveContext(e){g(this),this.assertContextChannel?.(),z(this,e)}stageContext(e){g(this),this.assertContextChannel?.(),F(this,e)}appendHistory(e,t){D(this,e,t)}invocationHistory(e){return _(this,e)}stagedUpdate(){return U(this)}stageNodeEntries(e){for(const[t,o]of Object.entries(e??{}))!o||typeof o!="object"||Array.isArray(o)||J(this,t,o)}saveNode(e,t){return W(this,e,t),{nodes:{[e]:this.nodeState(e)}}}saveNodeState(e,t){this.saveNode(w(e,"graph node"),t)}removeNode(e,...t){return this.saveNode(e,Object.fromEntries(t.map(o=>[o,void 0])))}}function te(r){if(!m(r))return r;if(Array.isArray(r.update))throw new Error("GraphNode Command updates must be state objects.");return r.update??{}}a(te,"commandUpdate");function N(r,e){if(!e.response?.trim())throw new Error(`Graph node '${r}' selected ${e.kind}() without a response.`);return e.response}a(N,"requireNodeResponse");function oe(r){if(typeof r!="string")return{ok:!0,value:r};try{return{ok:!0,value:JSON.parse(r)}}catch(e){return{ok:!1,error:`Tool arguments were not valid JSON: ${e instanceof Error?e.message:String(e)}`}}}a(oe,"coerceToolArgs");function ne(r){return r.issues.map(e=>e.path.length>0?`${e.path.join(".")}: ${e.message}`:e.message).join("; ")}a(ne,"formatToolArgumentError");export{Z as GRAPH_NODE_CLASS,Ee as GRAPH_NODE_LOCAL_STATE,T as GraphNode,Ce as GraphNodeRuntime,we as Tool};
1
+ var O=Object.defineProperty;var a=(r,e)=>O(r,"name",{value:e,configurable:!0});import"reflect-metadata";import{AIMessage as u,HumanMessage as I}from"@langchain/core/messages";import{Command as c,END as y,isCommand as m}from"@langchain/langgraph";import{GraphLlm as f}from"./graph-llm.config.js";import{GraphStateSupport as L}from"./graph-state-support.js";import{LlmRunner as k,DEFAULT_LLM_POLICY as A,DEFAULT_MAX_AGENT_ROUNDS as H,EmptyModelResponseError as $}from"./llm-runner.js";import{currentTurnSignal as v}from"./turn-context.js";import{combineGraphNodeUpdates as w}from"./node-outcome.js";import{parseJsonObjectResponse as S}from"./json-response.js";import{stableClassId as N}from"./stable-id.js";import{SessionLogWarning as x}from"./session-log.js";import{goTargetIds as P,isToolResponse as E,stay as M}from"./tool-response.js";import{invocationGraphState as U,hasNodeInvocation as G,invocationHistory as _,invocationNodeState as j,invocationUpdate as D,appendInvocationHistory as J,replaceInvocationNodeState as q,invocationContext as z,saveInvocationContext as F,replaceInvocationContext as W,saveInvocationNodeState as B,withNodeInvocation as X,invocationMode as Y,invocationPriorNode as K,invocationIsLocalOnly as Q,assertInvocationWrite as g,invocationChildUpdate as V,invocationIsBatchChild as Z,recordRunNodeOutcome as ee,recordRunNodeUsage as T,runNodeInput as te}from"./node-invocation.js";import{runNodeTasks as oe}from"./run-node.js";import{addTokenUsage as ne}from"./token-usage.js";import{addDecisionUsage as re}from"./decision/decision-types.js";import{DecisionConfigurationError as ie,resolveDecisionOptions as se}from"./decision/decision-types.js";import{GRAPH_NODE_LOCAL_STATE as xe}from"./node-outcome.js";const ae=Symbol("GRAPH_NODE_CLASS"),C=Symbol("graph-node-tool-handlers");function ke(r){if(!r.trim())throw new Error("A tool handler requires a tool name.");return(e,t)=>{const o=Reflect.getOwnMetadata(C,e)??[];if(o.some(n=>n.toolName===r))throw new Error(`Tool '${r}' already has a handler.`);o.push({toolName:r,methodName:t}),Reflect.defineMetadata(C,o,e)}}a(ke,"Tool");class b{static{a(this,"GraphNode")}llmGateway;runtime;static[ae]=!0;static id(){return this.name}name;id;constructor(e,t){this.llmGateway=e,this.runtime=t;const o=new.target;this.name=o.name,this.id=N(o,"graph node")}get graph(){return this.runtime}runNode(...e){return this.runtime.runNode(e)}getRunNodeInput(){return te(this.runtime)}defineTool(){return[]}getLlmConfig(){return{}}route(e){throw new Error(`Graph node '${this.id}' does not define a branch route.`)}async handleTool(e,t,o){const n=this.toolHandler(t.name);if(!n)return this.rejectToolCall(t.name,`Unsupported tool '${t.name}'.`);const s=this.runtime.requireTool(n.toolName),i=le(t.args);if(!i.ok)return this.rejectToolCall(n.toolName,i.error);const d=s.schema.safeParse(i.value);if(!d.success)return this.rejectToolCall(n.toolName,ce(d.error));const h=d.data,l=this[n.methodName];if(!l)throw new Error(`Tool '${n.toolName}' is decorated on missing method '${String(n.methodName)}'.`);const p=await l.call(this,h,o,e);if(E(p))return p;throw new Error(`Tool '${n.toolName}' on '${this.id}' must return a ToolResponse.`)}rejectToolCall(e,t){return x({tool_call:t,node:this.id,tool:e}),M(JSON.stringify({accepted:!1,error:t}))}usesChatModel(){return!0}onInvalidJsonResponse(e){throw e.error}onEmptyModelResponse(e){throw new $(e.reason)}invoke=a((e,t={})=>this.runtime.withInvocation(this.id,e,async()=>{const o=this.resolveNodeResponse(await this.run(e)),n=he(o);T(this.runtime,n);const s=await this.resolveJsonResponse(e,n);if(this.runtime.stageNodeEntries(s.nodes),s.context!==void 0&&this.runtime.stageContext(s.context),this.usesChatModel()){const d=this.runtime.resolveLlmConfig(this.getLlmConfig()),h=de(d,this.runtime.resolveLlmConfig()),l=(e.nodes??{})[this.id];(!h||l?.model!==void 0)&&this.runtime.saveNode(this.id,{model:h?void 0:f.modelMetadata(d)})}let i=w(s,this.runtime.stagedUpdate());return this.validatePublication(i,m(o)),i=this.withChildPublication(i),v()?.throwIfAborted(),await this.finalizeNodeResult(o,i),v()?.throwIfAborted(),i=w(s,this.runtime.stagedUpdate()),this.validatePublication(i,m(o)),i=this.withChildPublication(i),T(this.runtime,i),m(o)?new c({update:i,...o.goto===void 0?{}:{goto:o.goto},...o.graph===void 0?{}:{graph:o.graph},...o.resume===void 0?{}:{resume:o.resume}}):i},t,this.managesLlmExecution()),"invoke");withChildPublication(e){const t=V(this.runtime),o=w(t,e);return t.tokens&&(o.tokens=ne(e.tokens,t.tokens)),t.decisionUsage&&(o.decisionUsage=re(e.decisionUsage,t.decisionUsage)),o}finalizeNodeResult(e,t){}validatePublication(e,t){const o=Z(this.runtime);if(o&&e.nodes!==void 0&&(!e.nodes||typeof e.nodes!="object"||Array.isArray(e.nodes)||Object.values(e.nodes).some(n=>!n||typeof n!="object"||Array.isArray(n))))throw new Error(`runNode() child '${this.id}' must publish object-valued node state.`);if(this.runtime.isLocalOnlyInvocation()&&(t||Object.keys(e).some(n=>n!=="nodes"&&n!=="tokens"&&!(o&&n==="decisionUsage"))||Object.keys(e.nodes??{}).some(n=>n!==this.id)))throw new Error(`Internal LLM node '${this.id}' may publish only its own node state and token usage.`);this.validateNodeResult(e,t)}managesLlmExecution(){return!1}validateNodeResult(e,t){}obtainTools(e={}){return this.toolHandlers().filter(({toolName:t})=>this.includeTool(t,e)).map(({toolName:t})=>this.runtime.requireTool(t)).sort((t,o)=>t.name==="terminate_session"?1:o.name==="terminate_session"?-1:0)}validateTools(e={}){this.obtainTools(e)}includeTool(e,t){return!0}llmConfig(){return this.runtime.resolveLlmConfig(this.getLlmConfig())}llmCallOptions(){return this.runtime.llmCallOptions()}async runLlm(e,t){const o=await this.runAgentLoop(e,t);if(!o.stopReason)return o;const n=await this.onEmptyModelResponse({state:e,conversation:o,reason:o.stopReason});return{...o,response:n}}llmLifecycle(){}runAgentLoop(e,t){const o=this.llmLifecycle();return new k(this.llmGateway).run({...o===void 0?{}:{lifecycle:o},systemPrompt:a(()=>(e=this.runtime.hasInvocation()?this.runtime.graphState():e,this.getPrompt(e)),"systemPrompt"),history:this.llmHistory(e),tools:this.obtainTools(),llmConfig:this.llmConfig(),executeTool:a(n=>this.handleTool(e,n,t),"executeTool"),maxAgentRounds:this.runtime.maxAgentRounds,emptyHistorySeed:this.runtime.llmPolicy.emptyHistorySeed,emptyResponseRecovery:this.runtime.llmPolicy.emptyResponseRecovery,callOptions:this.llmCallOptions()})}llmHistory(e){return this.history(e)}historySpace(){return this.runtime.historySpace(this.id)}history(e){return this.runtime.hasInvocation()?this.runtime.invocationHistory(this.historySpace()):e.histories[this.historySpace()]??[]}historyUpdate(e){return{histories:{[this.historySpace()]:e}}}respond(e){return{...this.runtime.respond(e),...this.historyUpdate([new u(e)])}}complete(e){return{...this.runtime.complete(e),...this.historyUpdate([new u(e)])}}resolveNodeResponse(e){if(!E(e))return e;if(e.targets!==void 0&&e.kind!=="go")throw new Error("Multiple targets are only supported by fanout().");if(e.kind==="stay")throw new Error(`Graph node '${this.id}' can only return stay() from a tool handler.`);if(e.cleanup)throw new Error(`Graph node '${this.id}' can only use withCleanup() from a tool handler.`);if(e.feedback!==void 0)throw new Error(`Graph node '${this.id}' can only use withToolFeedback() from a tool handler.`);if(e.messages&&this.graph.appendHistory(this.historySpace(),e.messages),e.kind==="go"||e.kind==="directTo"){const t=e.kind==="go"?P(e):void 0;if(t&&t.length>1)return new c({update:{response:"",inputConsumed:!0,completed:!1,...e.usage===void 0?{}:{tokens:e.usage}},goto:[...t]});if(!e.target)throw new Error(`Graph node '${this.id}' selected ${e.kind}() without a target.`);const o=t?.[0]??N(e.target,"graph node"),n=this.graph.historySpace(o);if(e.state&&this.graph.saveNodeState(e.target,e.state),e.message&&this.graph.appendHistory(n,[e.message]),e.kind==="directTo"){const s=R(this.id,e);return this.graph.appendHistory(n,[new u(s)]),new c({update:{currentNode:o,response:s,inputConsumed:!0,completed:!1,...e.usage===void 0?{}:{tokens:e.usage}},goto:y})}return new c({update:{currentNode:o,response:"",inputConsumed:!0,completed:!1,...e.usage===void 0?{}:{tokens:e.usage}},goto:o})}if(e.message)throw new Error(`Graph node '${this.id}' can only use withMessage() with go() or directTo().`);if(e.kind==="direct"){const t=R(this.id,e);return this.graph.appendHistory(this.historySpace(),[new u(t)]),new c({update:{currentNode:this.id,response:t,inputConsumed:!0,completed:!1,...e.usage===void 0?{}:{tokens:e.usage}},goto:y})}if(e.kind==="finish"){const t=R(this.id,e);return this.graph.appendHistory(this.historySpace(),[new u(t)]),new c({update:{...this.graph.complete(t),...e.usage===void 0?{}:{tokens:e.usage}},goto:y})}throw new Error(`Graph node '${this.id}' returned an unsupported response kind '${e.kind}'.`)}state(e){return this.runtime.hasInvocation()?this.runtime.nodeState(this.id):e.nodes[this.id]??{}}getState(){return this.runtime.nodeState(this.id)}saveState(e){this.runtime.saveNode(this.id,e)}save(e){return this.runtime.saveNode(this.id,e)}remove(...e){return this.runtime.removeNode(this.id,...e)}toolHandler(e){return this.toolHandlers().find(t=>t.toolName===e)}async resolveJsonResponse(e,t){if(!this.runtime.expectsJsonResponse()||t.completed!==!0)return t;try{return S(t.response??""),t}catch(o){const n=await this.onInvalidJsonResponse({state:e,update:t,response:t.response??"",error:o instanceof Error?o:new Error(String(o))});return(n.completed===!0||n.response)&&S(n.response??""),n}}toolHandlers(){let e=Object.getPrototypeOf(this);const t=[];for(;e&&e!==b.prototype;){const n=Reflect.getOwnMetadata(C,e)??[];t.push(...n),e=Object.getPrototypeOf(e)}const o=new Set;for(const n of t){if(o.has(n.toolName))throw new Error(`Graph node '${this.id}' has more than one handler for tool '${n.toolName}'.`);o.add(n.toolName)}return t}}function de(r,e){return r.model===e.model&&JSON.stringify(f.parameters(r))===JSON.stringify(f.parameters(e))}a(de,"sameLlmConfig");class Ae extends L{static{a(this,"GraphNodeRuntime")}defaultLlmConfig;historySpaces;responseMode;maxAgentRounds;llmPolicy;decisionOptions;decisionErrorHandler;llmLifecycle;assertContextChannel;runNodeResolver;attachRunNodeResolver(e){this.runNodeResolver=e}runNode(e){return oe({owner:this,graphState:a(()=>this.graphState(),"graphState"),resolve:a(t=>{if(!this.runNodeResolver)throw new Error("runNode() requires a graph's registered-node resolver.");return this.runNodeResolver(t)},"resolve")},e)}recordRunNodeOutcome(e){ee(this,e)}tools=new Map;constructor(e,t,o={},n="chat",s=H,i=A,d={},h,l,p){super(e),this.defaultLlmConfig=t,this.historySpaces=o,this.responseMode=n,this.maxAgentRounds=s,this.llmPolicy=i,this.decisionOptions=d,this.decisionErrorHandler=h,this.llmLifecycle=l,this.assertContextChannel=p}llmCallOptions(){const{llmTimeoutMs:e}=this.llmPolicy,t=v();return{...e===void 0?{}:{timeoutMs:e},...t===void 0?{}:{signal:t}}}expectsJsonResponse(){return this.responseMode==="json"}historySpace(e){return e?this.historySpaces[e]??"default":"default"}resolveLlmConfig(e={}){return f.resolveConfig(this.defaultLlmConfig,e)}resolveDecisionOptions(e={}){return se(this.decisionOptions,e)}decisionProviderResolver;attachDecisionProviderResolver(e){this.decisionProviderResolver=e}resolveDecisionProvider(e){if(!this.decisionProviderResolver)throw new ie(`Decision provider '${e}' cannot be resolved before the graph is attached to an engine.`);return this.decisionProviderResolver(e)}async handleDecisionError(e){return await this.decisionErrorHandler?.(e)??null}registerTools(e,t){for(const o of t){const n=this.tools.get(o.name);if(n)throw new Error(`Tool '${o.name}' is defined by both '${n.owner}' and '${e}'.`);this.tools.set(o.name,{definition:o,owner:e})}}requireTool(e){const t=this.tools.get(e);if(!t)throw new Error(`Tool '${e}' is not defined in this graph.`);return t.definition}input(e){return this.latestInput({messages:e.histories[this.historySpace(e.currentNode)]??[]})}getConversation(e){const o=(this.hasInvocation()?this.invocationHistory(e):[]).filter(n=>I.isInstance(n)&&n.additional_kwargs?.ezgraphInternal!==!0).map(n=>typeof n.content=="string"?n.content:JSON.stringify(n.content));return{request:o.at(-1)??"",priorRequests:o.slice(-5,-1)}}respond(e){return this.hasInvocation()&&g(this),this.responseUpdate(e)}complete(e){return this.hasInvocation()&&g(this),this.endUpdate(e)}withInvocation(e,t,o,n={},s=!1){return X(this,e,t,o,n,s)}invocationMode(){return Y(this)}priorNode(){return K(this)}isLocalOnlyInvocation(){return Q(this)}nodeState(e){return j(this,e)}hasInvocation(){return G(this)}graphState(){return U(this)}getContext(){return z(this)}saveContext(e){g(this),this.assertContextChannel?.(),F(this,e)}stageContext(e){g(this),this.assertContextChannel?.(),W(this,e)}appendHistory(e,t){J(this,e,t)}invocationHistory(e){return _(this,e)}stagedUpdate(){return D(this)}stageNodeEntries(e){for(const[t,o]of Object.entries(e??{}))!o||typeof o!="object"||Array.isArray(o)||q(this,t,o)}saveNode(e,t){return B(this,e,t),{nodes:{[e]:this.nodeState(e)}}}saveNodeState(e,t){this.saveNode(N(e,"graph node"),t)}removeNode(e,...t){return this.saveNode(e,Object.fromEntries(t.map(o=>[o,void 0])))}}function he(r){if(!m(r))return r;if(Array.isArray(r.update))throw new Error("GraphNode Command updates must be state objects.");return r.update??{}}a(he,"commandUpdate");function R(r,e){if(!e.response?.trim())throw new Error(`Graph node '${r}' selected ${e.kind}() without a response.`);return e.response}a(R,"requireNodeResponse");function le(r){if(typeof r!="string")return{ok:!0,value:r};try{return{ok:!0,value:JSON.parse(r)}}catch(e){return{ok:!1,error:`Tool arguments were not valid JSON: ${e instanceof Error?e.message:String(e)}`}}}a(le,"coerceToolArgs");function ce(r){return r.issues.map(e=>e.path.length>0?`${e.path.join(".")}: ${e.message}`:e.message).join("; ")}a(ce,"formatToolArgumentError");export{ae as GRAPH_NODE_CLASS,xe as GRAPH_NODE_LOCAL_STATE,b as GraphNode,Ae as GraphNodeRuntime,ke as Tool};
@@ -1 +1 @@
1
- function P(){const U=['CMvZB2X2zu1VzgvSrgvZy3jPChrVCG','DMfSAwrHDgvdB25MAwC','zw50CMLLCW','CgfYyw1Z','ntuYndy4DNHqAfjm','CgfYyw1LDgvYtwfWCgLUz3m','C2v0ugf0Aa','BgfUz0nOywLUtw9KzwXjBML0AwfSAxPHDgLVBG','Aw5PDgLHBgL6zq','ntCXmZCYohLHBhDsra','ndbUuejIqM8','ChjVDMLKzxjnB2rLBa','ChjVDMLKzxi','B2jQzwn0','ChjVDMLKzxjbzgfWDgvY','BMfTzq','C2XPy2u','ntKXnJCXELjNrNDU','nZDVtujpzhK','mZeYotq1m1vtC294qG','q2f0ywXVzYbWyxjHBwv0zxiGBwfWCgLUzYaN','C3bSAxq','nde1nZq5nxn1CKL2Aq','q2f0ywXVzYbWyxjHBwv0zxiGBwfWCgLUzYbWyxrOCYbJyw5UB3qGyMuGzw1WDhKU','mJqWndK2nwzoDNfWqq','AxnbCNjHEq','mJm2nJa5nePzAg10ta'];P=function(){return U;};return P();}const O=z;(function(X,y){const j={X:0x17a,y:0x16b,F:0x178,W:0x166},q=z,F=X();while(!![]){try{const W=parseInt(q(0x173))/0x1+-parseInt(q(0x17c))/0x2+-parseInt(q(j.X))/0x3+-parseInt(q(j.y))/0x4+parseInt(q(j.F))/0x5+parseInt(q(j.W))/0x6*(parseInt(q(0x174))/0x7)+parseInt(q(0x16c))/0x8*(parseInt(q(0x175))/0x9);if(W===y)break;else F['push'](F['shift']());}catch(K){F['push'](F['shift']());}}}(P,0xb9e87));var s=Object['defineProperty'],l=(X,y)=>s(X,O(0x171),{'value':y,'configurable':!0x0});import{GraphLlm as B,ModelCatalog as b}from'./graph-llm.config.js';function z(B,b){B=B-0x165;const e=P();let N=e[B];if(z['uapbbH']===undefined){var w=function(W){const C='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let K='',H='';for(let u=0x0,x,Z,o=0x0;Z=W['charAt'](o++);~Z&&(x=u%0x4?x*0x40+Z:Z,u++%0x4)?K+=String['fromCharCode'](0xff&x>>(-0x2*u&0x6)):0x0){Z=C['indexOf'](Z);}for(let q=0x0,O=K['length'];q<O;q++){H+='%'+('00'+K['charCodeAt'](q)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(H);};z['ujitrk']=w,z['tGlJwF']={},z['uapbbH']=!![];}const X=e[0x0],y=B+X,F=z['tGlJwF'][y];return!F?(N=z['ujitrk'](N),z['tGlJwF'][y]=N):N=F,N;}import{modelProviderAdapter as e}from'./model-provider.js';import{OPENAI_AUTH_PROVIDER as N,initializeOpenAIAuthProvider as w}from'./openai-auth-provider.js';function C(X,y=[]){const r={X:0x17e,y:0x17d,F:0x165,W:0x167,K:0x16d,H:0x16e,x:0x170,Z:0x16a,o:0x16e},Q=O,F=B[Q(r.X)](X),W=b[Q(r.y)](F),K={};for(const [x,Z]of Object[Q(0x17f)](F[Q(r.F)])){const k=W[Q(r.W)][x];k!==null&&u(K,k??x,Z);}if(W[Q(0x16e)]===N)return w(W[Q(r.K)],K);const H=e(W[Q(r.H)],y)??W[Q(r.x)];return H?H[Q(r.Z)]({'provider':W[Q(r.o)],'model':W[Q(r.K)],'options':K}):{'model':W[Q(r.K)],'options':{'modelProvider':W[Q(0x16e)],...K}};}l(C,O(0x169));function u(X,y,F){const M={X:0x16f,y:0x17b,F:0x176,W:0x179},D=O,W=y[D(0x177)]('.');let K=X;for(const x of W[D(0x172)](0x0,-0x1)){const Z=K[x];if(Z===void 0x0){const k={};K[x]=k,K=k;}else{if(typeof Z==D(M.X)&&Z!==null&&!Array[D(M.y)](Z))K=Z;else throw new Error(D(M.F)+y+'\x27\x20has\x20a\x20conflicting\x20path.');}}const H=W['at'](-0x1);if(!H)throw new Error(D(M.W));K[H]=F;}l(u,O(0x168));export{C as langChainModelInitialization};
1
+ function h(){const V=['CMvZB2X2zu1VzgvSrgvZy3jPChrVCG','DMfSAwrHDgvdB25MAwC','zw50CMLLCW','CgfYyw1Z','ntuYndy4DNHqAfjm','CgfYyw1LDgvYtwfWCgLUz3m','C2v0ugf0Aa','BgfUz0nOywLUtw9KzwXjBML0AwfSAxPHDgLVBG','Aw5PDgLHBgL6zq','ntCXmZCYohLHBhDsra','ndbUuejIqM8','ChjVDMLKzxjnB2rLBa','ChjVDMLKzxi','B2jQzwn0','ChjVDMLKzxjbzgfWDgvY','BMfTzq','C2XPy2u','ntKXnJCXELjNrNDU','nZDVtujpzhK','mZeYotq1m1vtC294qG','q2f0ywXVzYbWyxjHBwv0zxiGBwfWCgLUzYaN','C3bSAxq','nde1nZq5nxn1CKL2Aq','q2f0ywXVzYbWyxjHBwv0zxiGBwfWCgLUzYbWyxrOCYbJyw5UB3qGyMuGzw1WDhKU','mJqWndK2nwzoDNfWqq','AxnbCNjHEq','mJm2nJa5nePzAg10ta'];h=function(){return V;};return h();}const R=e;(function(D,A){const x={D:0x17a,A:0x16b,j:0x178,H:0x166},n=e,j=D();while(!![]){try{const H=parseInt(n(0x173))/0x1+-parseInt(n(0x17c))/0x2+-parseInt(n(x.D))/0x3+-parseInt(n(x.A))/0x4+parseInt(n(x.j))/0x5+parseInt(n(x.H))/0x6*(parseInt(n(0x174))/0x7)+parseInt(n(0x16c))/0x8*(parseInt(n(0x175))/0x9);if(H===A)break;else j['push'](j['shift']());}catch(w){j['push'](j['shift']());}}}(h,0xb9e87));var s=Object['defineProperty'],l=(D,A)=>s(D,R(0x171),{'value':A,'configurable':!0x0});import{GraphLlm as r,ModelCatalog as Q}from'./graph-llm.config.js';function e(l,c){l=l-0x165;const r=h();let Q=r[l];if(e['uapbbH']===undefined){var v=function(E){const D='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let A='',j='';for(let H=0x0,m,w,Z=0x0;w=E['charAt'](Z++);~w&&(m=H%0x4?m*0x40+w:w,H++%0x4)?A+=String['fromCharCode'](0xff&m>>(-0x2*H&0x6)):0x0){w=D['indexOf'](w);}for(let C=0x0,o=A['length'];C<o;C++){j+='%'+('00'+A['charCodeAt'](C)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(j);};e['ujitrk']=v,e['tGlJwF']={},e['uapbbH']=!![];}const G=r[0x0],I=l+G,s=e['tGlJwF'][I];return!s?(Q=e['ujitrk'](Q),e['tGlJwF'][I]=Q):Q=s,Q;}import{modelProviderAdapter as G}from'./model-provider.js';import{OPENAI_AUTH_PROVIDER as I,initializeOpenAIAuthProvider as E}from'./openai-auth-provider.js';function C(D,A=[]){const i={D:0x17e,A:0x17d,j:0x165,H:0x167,w:0x16d,Z:0x16e,o:0x170,L:0x16a,q:0x16e},J=R,j=r[J(i.D)](D),H=Q[J(i.A)](j),w={};for(const [L,q]of Object[J(0x17f)](j[J(i.j)])){const b=H[J(i.H)][L];b!==null&&u(w,b??L,q);}if(H[J(0x16e)]===I)return E(H[J(i.w)],w);const Z=G(H[J(i.Z)],A)??H[J(i.o)];return Z?Z[J(i.L)]({'provider':H[J(i.q)],'model':H[J(i.w)],'options':w}):{'model':H[J(i.w)],'options':{'modelProvider':H[J(0x16e)],...w}};}l(C,R(0x169));function u(D,A,j){const O={D:0x16f,A:0x17b,j:0x176,H:0x179},N=R,H=A[N(0x177)]('.');let w=D;for(const L of H[N(0x172)](0x0,-0x1)){const q=w[L];if(q===void 0x0){const b={};w[L]=b,w=b;}else{if(typeof q==N(O.D)&&q!==null&&!Array[N(O.A)](q))w=q;else throw new Error(N(O.j)+A+'\x27\x20has\x20a\x20conflicting\x20path.');}}const Z=H['at'](-0x1);if(!Z)throw new Error(N(O.H));w[Z]=j;}l(u,R(0x168));export{C as langChainModelInitialization};
@@ -1 +1 @@
1
- var v=Object.defineProperty;var h=(a,e)=>v(a,"name",{value:e,configurable:!0});var L=function(a,e,t,o){var s=arguments.length,n=s<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(a,e,t,o);else for(var r=a.length-1;r>=0;r--)(i=a[r])&&(n=(s<3?i(n):s>3?i(e,t,n):i(e,t))||n);return s>3&&n&&Object.defineProperty(e,t,n),n},u=function(a,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(a,e)};import{AIMessage as p,HumanMessage as R}from"@langchain/core/messages";import{Command as d,END as m}from"@langchain/langgraph";import{Tool as E}from"./graph-node.js";import{LlmNodeBase as O}from"./llm-node-base.js";import{stableClassId as M}from"./stable-id.js";import{TerminateSessionNode as I}from"./terminate-session.node.js";import{go as T,goTargetIds as g,isToolResponse as w}from"./tool-response.js";import{addTokenUsage as f,emptyTokenUsage as _}from"./token-usage.js";import{currentTurnSignal as k}from"./turn-context.js";class x extends O{static{h(this,"LlmNode")}exitOutcomes=new WeakMap;onEnter(e,t){return e}llmLifecycle(){return{...super.llmLifecycle(),onEnter:h(e=>this.onEnter(e,this.graph.hasInvocation()?this.graph.priorNode():void 0),"onEnter")}}onResponse(e,t){}onExit(e){}async finalizeNodeResult(e,t){const o=this.exitOutcomes.get(e);if(this.exitOutcomes.delete(e),!o)return;const s=o.kind==="finish"?t.completed===!0?{kind:"finish",response:t.response??o.response}:{kind:"reply",response:t.response??""}:o;await this.onExit({nodeId:this.id,mode:this.graph.invocationMode(),state:this.graph.graphState(),outcome:s,usage:{...t.tokens??_()}})}withExitOutcome(e,t){return this.exitOutcomes.set(e,t),e}managesLlmExecution(){return!0}isInternal(){return this.graph.hasInvocation()&&this.graph.invocationMode()==="internal"}includeTool(e,t){return!((t.mode==="internal"||t.mode===void 0&&this.isInternal())&&e==="terminate_session")}llmHistory(e){return this.isInternal()?[]:super.llmHistory(e)}async handleTool(e,t,o){if(this.isInternal()&&t.name==="terminate_session")throw this.invalidInternalOutcome(t.name);const s=await super.handleTool(e,t,o);return this.validateOutcome(s),s}validateLlmRecovery(e){e&&typeof e=="object"&&e.kind!=="retry_with_model"&&this.validateOutcome(e)}validateOutcome(e){const t=["target","targets","state","message","messages"].some(o=>o in e);if(e.kind==="taskResult"&&(!("value"in e)||e.value===void 0||t||["response","feedback","cleanup"].some(o=>o in e)))throw new Error(`LLM node '${this.id}' requires a taskResult value without conversation effects.`);if(e.targets!==void 0&&e.kind!=="go")throw new Error("Multiple targets are only supported by fanout().");if(e.kind==="go"&&g(e),this.isInternal()&&(e.kind!=="stay"&&e.kind!=="taskResult"&&e.kind!=="direct"||t))throw this.invalidInternalOutcome(e.kind)}invalidInternalOutcome(e){return new Error(`Internal LLM node '${this.id}' cannot use '${e}'; its caller owns conversation routing and completion.`)}async endChat(e){return T(I).withMessage(new R({content:e.message?.trim()||"The user asked to end the conversation.",additional_kwargs:{ezgraphInternal:!0}}))}async run(e){const t=await this.runLlm(e,{}),o=t.toolResponse;if(o&&(this.validateOutcome(o),o.kind!=="taskResult"&&o.kind!=="direct"))return this.resolveToolResponse(t,o);const s=o?.kind==="taskResult"?o.value:t.response;if(o?.kind!=="taskResult"&&(typeof s!="string"||!s.trim()))throw new Error(`LLM node '${this.id}' stopped without a response or tool transition.`);k()?.throwIfAborted();const n=await this.onResponse(s,e);k()?.throwIfAborted();let i=n===void 0?s:n,r=f(t.usage,o?.usage);if(w(n)){if(this.validateOutcome(n),n.cleanup)throw new Error(`LLM node '${this.id}' may use cleanup only from a tool handler.`);if(n.feedback!==void 0||n.messages)throw new Error(`LLM node '${this.id}' may use tool feedback/messages only from a tool handler.`);if(n.message&&n.kind!=="go"&&n.kind!=="directTo")throw new Error(`LLM node '${this.id}' may use withMessage() only with go() or directTo().`);if(n.kind==="stay")throw new Error(`LLM node '${this.id}' may return stay() only from a tool handler.`);if(n.kind!=="taskResult"&&n.kind!=="direct")return this.resolveToolResponse({...t,usage:r,messages:n.response?this.responseMessages(t,n.response):t.messages},n);i=n.kind==="taskResult"?n.value:n.response,r=f(r,n.usage)}if(typeof i=="string"&&!i.trim())throw new Error(`LLM node '${this.id}' onResponse() produced no response.`);const l=(w(n)?n.kind==="taskResult":n===void 0&&o?.kind==="taskResult")?{kind:"taskResult",value:i}:{kind:"reply",response:typeof i=="string"?i:JSON.stringify(i)};if(this.isInternal())return this.withExitOutcome({tokens:r},l);const c=typeof i=="string"?i:JSON.stringify(i);if(!c?.trim())throw new Error(`LLM node '${this.id}' onResponse() produced no response.`);return this.withExitOutcome(new d({update:{currentNode:this.id,response:c,inputConsumed:!0,completed:!1,...this.historyUpdate(this.responseMessages(t,c)),tokens:r},goto:m}),l)}responseMessages(e,t){const o=[...e.messages],s=o.at(-1);return s&&p.isInstance(s)&&e.response!==void 0?t!==e.response&&(o[o.length-1]=new p({content:t,...s.id===void 0?{}:{id:s.id}})):o.push(new p(t)),o}resolveToolResponse(e,t){const o=this.historyUpdate(e.messages),s=f(e.usage,t.usage);if(t.kind==="go"){const n=g(t);if(n.length>1)return this.withExitOutcome(new d({update:{inputConsumed:!0,response:"",completed:!1,...o,tokens:s},goto:[...n]}),{kind:"fanout",targets:n});if(!t.target)throw new Error(`LLM node '${this.id}' selected go() without a target.`);const i=n[0];return t.state&&this.graph.saveNodeState(t.target,t.state),t.message&&this.graph.appendHistory(this.graph.historySpace(i),[t.message]),this.withExitOutcome(new d({update:{currentNode:i,inputConsumed:!0,response:"",completed:!1,...o,tokens:s},goto:i}),{kind:"go",targets:[i]})}if(t.kind==="directTo"){if(!t.target)throw new Error(`LLM node '${this.id}' selected directTo() without a target.`);const n=M(t.target,"graph node"),i=this.graph.historySpace(n);t.state&&this.graph.saveNodeState(t.target,t.state),t.message&&this.graph.appendHistory(i,[t.message]);const r=y(this.id,t);return i!==this.historySpace()&&this.graph.appendHistory(i,[new p(r)]),this.withExitOutcome(new d({update:{currentNode:n,response:r,inputConsumed:!0,completed:!1,...o,tokens:s},goto:m}),{kind:"directTo",targets:[n],response:r})}if(t.kind==="finish"){const n=y(this.id,t);return this.withExitOutcome(new d({update:{...this.graph.complete(n),...o,tokens:s},goto:m}),{kind:"finish",response:n})}throw new Error(`LLM node '${this.id}' cannot publish '${t.kind}' as a conversation result.`)}}L([E("terminate_session"),u("design:type",Function),u("design:paramtypes",[Object]),u("design:returntype",Promise)],x.prototype,"endChat",null);function y(a,e){if(!e.response?.trim())throw new Error(`LLM node '${a}' selected ${e.kind}() without a response.`);return e.response}h(y,"requireResponse");export{x as LlmNode};
1
+ var R=Object.defineProperty;var h=(a,e)=>R(a,"name",{value:e,configurable:!0});var v=function(a,e,t,o){var s=arguments.length,n=s<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(a,e,t,o);else for(var r=a.length-1;r>=0;r--)(i=a[r])&&(n=(s<3?i(n):s>3?i(e,t,n):i(e,t))||n);return s>3&&n&&Object.defineProperty(e,t,n),n},u=function(a,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(a,e)};import{AIMessage as p,HumanMessage as L}from"@langchain/core/messages";import{Command as d,END as m}from"@langchain/langgraph";import{Tool as E}from"./graph-node.js";import{LlmNodeBase as O}from"./llm-node-base.js";import{stableClassId as M}from"./stable-id.js";import{TerminateSessionNode as I}from"./terminate-session.node.js";import{go as T,goTargetIds as g,isToolResponse as w}from"./tool-response.js";import{addTokenUsage as f,emptyTokenUsage as _}from"./token-usage.js";import{currentTurnSignal as k}from"./turn-context.js";class x extends O{static{h(this,"LlmNode")}exitOutcomes=new WeakMap;onEnter(e,t){return e}llmLifecycle(){return{...super.llmLifecycle(),onEnter:h(e=>this.onEnter(e,this.graph.hasInvocation()?this.graph.priorNode():void 0),"onEnter")}}onResponse(e,t){}onExit(e){}async finalizeNodeResult(e,t){const o=this.exitOutcomes.get(e);if(this.exitOutcomes.delete(e),!o)return;const s=o.kind==="finish"?t.completed===!0?{kind:"finish",response:t.response??o.response}:{kind:"reply",response:t.response??""}:o;await this.onExit({nodeId:this.id,mode:this.graph.invocationMode(),state:this.graph.graphState(),outcome:s,usage:{...t.tokens??_()}}),(s.kind==="reply"||s.kind==="taskResult")&&this.graph.recordRunNodeOutcome(s)}withExitOutcome(e,t){return this.exitOutcomes.set(e,t),e}managesLlmExecution(){return!0}isInternal(){return this.graph.hasInvocation()&&this.graph.invocationMode()==="internal"}includeTool(e,t){return!((t.mode==="internal"||t.mode===void 0&&this.isInternal())&&e==="terminate_session")}llmHistory(e){return this.isInternal()?[]:super.llmHistory(e)}async handleTool(e,t,o){if(this.isInternal()&&t.name==="terminate_session")throw this.invalidInternalOutcome(t.name);const s=await super.handleTool(e,t,o);return this.validateOutcome(s),s}validateLlmRecovery(e){e&&typeof e=="object"&&e.kind!=="retry_with_model"&&this.validateOutcome(e)}validateOutcome(e){const t=["target","targets","state","message","messages"].some(o=>o in e);if(e.kind==="taskResult"&&(!("value"in e)||e.value===void 0||t||["response","feedback","cleanup"].some(o=>o in e)))throw new Error(`LLM node '${this.id}' requires a taskResult value without conversation effects.`);if(e.targets!==void 0&&e.kind!=="go")throw new Error("Multiple targets are only supported by fanout().");if(e.kind==="go"&&g(e),this.isInternal()&&(e.kind!=="stay"&&e.kind!=="taskResult"&&e.kind!=="direct"||t))throw this.invalidInternalOutcome(e.kind)}invalidInternalOutcome(e){return new Error(`Internal LLM node '${this.id}' cannot use '${e}'; its caller owns conversation routing and completion.`)}async endChat(e){return T(I).withMessage(new L({content:e.message?.trim()||"The user asked to end the conversation.",additional_kwargs:{ezgraphInternal:!0}}))}async run(e){const t=await this.runLlm(e,{}),o=t.toolResponse;if(o&&(this.validateOutcome(o),o.kind!=="taskResult"&&o.kind!=="direct"))return this.resolveToolResponse(t,o);const s=o?.kind==="taskResult"?o.value:t.response;if(o?.kind!=="taskResult"&&(typeof s!="string"||!s.trim()))throw new Error(`LLM node '${this.id}' stopped without a response or tool transition.`);k()?.throwIfAborted();const n=await this.onResponse(s,e);k()?.throwIfAborted();let i=n===void 0?s:n,r=f(t.usage,o?.usage);if(w(n)){if(this.validateOutcome(n),n.cleanup)throw new Error(`LLM node '${this.id}' may use cleanup only from a tool handler.`);if(n.feedback!==void 0||n.messages)throw new Error(`LLM node '${this.id}' may use tool feedback/messages only from a tool handler.`);if(n.message&&n.kind!=="go"&&n.kind!=="directTo")throw new Error(`LLM node '${this.id}' may use withMessage() only with go() or directTo().`);if(n.kind==="stay")throw new Error(`LLM node '${this.id}' may return stay() only from a tool handler.`);if(n.kind!=="taskResult"&&n.kind!=="direct")return this.resolveToolResponse({...t,usage:r,messages:n.response?this.responseMessages(t,n.response):t.messages},n);i=n.kind==="taskResult"?n.value:n.response,r=f(r,n.usage)}if(typeof i=="string"&&!i.trim())throw new Error(`LLM node '${this.id}' onResponse() produced no response.`);const l=(w(n)?n.kind==="taskResult":n===void 0&&o?.kind==="taskResult")?{kind:"taskResult",value:i}:{kind:"reply",response:typeof i=="string"?i:JSON.stringify(i)};if(this.isInternal())return this.withExitOutcome({tokens:r},l);const c=typeof i=="string"?i:JSON.stringify(i);if(!c?.trim())throw new Error(`LLM node '${this.id}' onResponse() produced no response.`);return this.withExitOutcome(new d({update:{currentNode:this.id,response:c,inputConsumed:!0,completed:!1,...this.historyUpdate(this.responseMessages(t,c)),tokens:r},goto:m}),l)}responseMessages(e,t){const o=[...e.messages],s=o.at(-1);return s&&p.isInstance(s)&&e.response!==void 0?t!==e.response&&(o[o.length-1]=new p({content:t,...s.id===void 0?{}:{id:s.id}})):o.push(new p(t)),o}resolveToolResponse(e,t){const o=this.historyUpdate(e.messages),s=f(e.usage,t.usage);if(t.kind==="go"){const n=g(t);if(n.length>1)return this.withExitOutcome(new d({update:{inputConsumed:!0,response:"",completed:!1,...o,tokens:s},goto:[...n]}),{kind:"fanout",targets:n});if(!t.target)throw new Error(`LLM node '${this.id}' selected go() without a target.`);const i=n[0];return t.state&&this.graph.saveNodeState(t.target,t.state),t.message&&this.graph.appendHistory(this.graph.historySpace(i),[t.message]),this.withExitOutcome(new d({update:{currentNode:i,inputConsumed:!0,response:"",completed:!1,...o,tokens:s},goto:i}),{kind:"go",targets:[i]})}if(t.kind==="directTo"){if(!t.target)throw new Error(`LLM node '${this.id}' selected directTo() without a target.`);const n=M(t.target,"graph node"),i=this.graph.historySpace(n);t.state&&this.graph.saveNodeState(t.target,t.state),t.message&&this.graph.appendHistory(i,[t.message]);const r=y(this.id,t);return i!==this.historySpace()&&this.graph.appendHistory(i,[new p(r)]),this.withExitOutcome(new d({update:{currentNode:n,response:r,inputConsumed:!0,completed:!1,...o,tokens:s},goto:m}),{kind:"directTo",targets:[n],response:r})}if(t.kind==="finish"){const n=y(this.id,t);return this.withExitOutcome(new d({update:{...this.graph.complete(n),...o,tokens:s},goto:m}),{kind:"finish",response:n})}throw new Error(`LLM node '${this.id}' cannot publish '${t.kind}' as a conversation result.`)}}v([E("terminate_session"),u("design:type",Function),u("design:paramtypes",[Object]),u("design:returntype",Promise)],x.prototype,"endChat",null);function y(a,e){if(!e.response?.trim())throw new Error(`LLM node '${a}' selected ${e.kind}() without a response.`);return e.response}h(y,"requireResponse");export{x as LlmNode};
@@ -1 +1 @@
1
- const Ps=B;(function(s,E){const Pt={s:0x252,E:0x22b,h:0x243,i:0x247,c:0x21f,l:0x227},Pp=B,h=s();while(!![]){try{const i=-parseInt(Pp(Pt.s))/0x1*(-parseInt(Pp(0x1f4))/0x2)+parseInt(Pp(0x22e))/0x3*(parseInt(Pp(Pt.E))/0x4)+parseInt(Pp(0x204))/0x5+parseInt(Pp(Pt.h))/0x6+-parseInt(Pp(0x24a))/0x7+parseInt(Pp(Pt.i))/0x8*(-parseInt(Pp(0x237))/0x9)+-parseInt(Pp(Pt.c))/0xa*(-parseInt(Pp(Pt.l))/0xb);if(i===E)break;else h['push'](h['shift']());}catch(c){h['push'](h['shift']());}}}(z,0xae67e));function z(){const zX=['zw1WDhLiAxn0B3j5u2vLza','C3rVCf9KzxrHAwXZ','vgHLig1VzgvSihjLDhvYBMvKigfUigvTChr5ihjLC3bVBNnLicG','CMvHC29U','Dg9VBc1JywXSlq','y2fSBe9WDgLVBNm','mZu5mdy2ze9As3DR','yxr0zw1WDhnFzxHOyxvZDgvK','zgv0ywLS','BgXTr2f0zxDHEq','ywDLBNq','rM9SBg93ihrOzsbZExn0zw0GChjVBxb0igfUzcbYzxnWB25KihbYB3bLCMX5lIbvC2uGDgHLihjLCxvPCMvKihrVB2WGD2HLBIbPBNn0CNvJDgvKlG','Cg9W','CMvZB2X2zu1VzgvSrgvZy3jPChrVCG','DgHYB3DjzKfIB3j0zwq','zxHLy3v0zvrVB2W','B3rOzxi','vgHLig1VzgvSihjLC3bVBNnLihDHCYbYzwPLy3rLzcbIEsbJAgvJA1jLC3bVBNnLkcKU','C3rYAw5N','AxnjBNn0yw5Jzq','ChjVDMLKzxi','CMf0Aw5NCW','nJiYnJuWAxPUDKDt','ChvZAa','BMfTzq','Bw9KzwW','y2XLyw51Ca','BwvZC2fNzvrLEhq','igfNzw50ihjVDw5KCY4','AgfUzgXLqMXVy2TLza','C3rYAw5NAwz5','Dg9VBf9JywXSCW','yxnZzxj0twf4qwDLBNrsB3vUzhm','y2HLy2TszxnWB25Zzq','BM9YBwfSAxPLuMvHC29U','CMv0CNLFD2L0Af9TB2rLBa','CNvU','yMXVy2TLza','CMvZB2X2zunVBMzPzW','CMv0CMLLCW','C2fMzxr5x3jHDgLUz3m','Aw5JBhvKzxm','Dg9VBhm','BwvZC2fNzxm','C3rHEq','CMv0CNLFzgvJBgLUzwq','DMfSDwu','CMvZCg9UC2vFCMvQzwn0zwq','B2jQzwn0','otuXnZCWz0XQruLN','Aw52B2nHDgLVBL9LCNjVCG','zw1WDhLFCMvZCg9UC2u','CMvZCg9UC2vuzxH0','BwLU','CMvZCg9UC2u','ywXSu2v0DgXLza','C2HVDwXKuMv0CNLmBg1fCNjVCG','mtf0sMXuywq','zgvMAw5LuhjVCgvYDhK','Aw52B2nHDgLVBKnVBMzPzW','Dg9mB3DLCKnHC2u','mJC2mtmXnKv5teHWBq','A2LUza','DxnHz2u','m3ftv2HyBq','Bwf4qwDLBNrsB3vUzhmGBxvZDcbIzsbHihbVC2L0AxzLigLUDgvNzxi7ihjLy2vPDMvKia','BgXTq29UzMLN','BwfW','DhjPBq','C3LZDgvTuhjVBxb0','AxnbCNjHEq','y29TBw9Uq29UDgv4Da','CMv0CNLxAxrOtw9KzwWOksbTyxKGyMuGCMv0DxjUzwqGB25SEsbVBMnLigLUigeGCMvJB3zLCNKGC2vXDwvUy2uU','oty4ody4owPtyvLjtG','zxzLCNK','C3rHDgu','yxbWBhLszwnVDMvYEq','AxnjBNrLz2vY','CMvZCg9UC2vFBwv0ywrHDge','q29UDMvYC2f0Aw9Uigv4y2vLzgvKia','DMfSAwrHDgvdB25MAwC','ywrKAxrPB25HBf9RD2fYz3m','AgfZq2fUzgLKyxrLq29UDgvUDa','B25mBg1fCNjVCG','yMXVy2TszwfZB24','mZy2mtq5nhzRCxfzzq','CMvWBgfJzufSBa','zMvLzgjHy2S','ywnXDwLYzunHBMrPzgf0zq','ofDVq2nPuW','CgfYyw1Z','Axntyw1LqMfYzvrYyw5ZAxrPB24','nty0nJe3mKzss2rzra','C29Tzq','BgvUz3rO','teXnihjLy292zxj5ignHBM5VDcbYzxr1CM4GDg9VBc1VBMX5ihn0yxKOksWGy2XLyw51CcWGB3iGzMvLzgjHy2SU','tgXTuNvUBMvY','Aw1Hz2vFB3rOzxi','Aw50zxjUywXiDw1HBK1LC3nHz2u','CMvMDxnHBa','nNLHrfzosq','BwvZC2fNzq','BNvKz2u','B25fBNrLCG','yxnZzxj0rw1WDhLszxnWB25ZzvjLDhjPzxm','y2XLyw51Cef0DgfJAg1LBNrZ','qsb0B29SigjHDgnOihnLBgvJDgvKig1VCMuGDgHHBIbVBMuGDgvYBwLUywWGCMvZCg9UC2uGB3iGDhjHBNnPDgLVBI4','y29UDgvUDa','CMv0CNLxAxrOtw9KzwWOksbPCYbZDxbWB3j0zwqGB25SEsbIEsbVBKXSBuvYCM9YkcKU','yMXVy2TFCMvHC29U'];z=function(){return zX;};return z();}var V=Object[Ps(0x228)],d=(s,E)=>V(s,'name',{'value':E,'configurable':!0x0});import{setTimeout as b}from'node:timers/promises';import{GraphLlm as e,ModelCatalog as w}from'./graph-llm.config.js';import{LlmResponseBlockedError as y,LlmSetupError as W}from'./llm-lifecycle.js';import{AIMessage as C,HumanMessage as K,RemoveMessage as u,ToolMessage as x}from'@langchain/core/messages';import{addTokenUsage as o,emptyTokenUsage as k}from'./token-usage.js';import{goTargetIds as O,isToolResponse as D}from'./tool-response.js';import{describeStopReason as r,isRetryableStopReason as J,modelStopReason as T}from'./model-stop-reason.js';import{SessionLogWarning as S}from'./session-log.js';import{isOpenAIAuthConfig as f,openAIAuthMessageText as p}from'./openai-auth-provider.js';class ce extends Error{static{d(this,'EmptyModelResponseError');}[Ps(0x1f1)];constructor(s){const z0={s:0x1f0,E:0x1f1,h:0x206},PV=Ps;super(PV(z0.s)+r(s)+').'),this[PV(z0.E)]=s,this[PV(z0.h)]='EmptyModelResponseError';}}const pe=0x8;function ue(s){const z1={s:0x23b,E:0x22f},PE=Ps;if(!Number[PE(z1.s)](s)||s<0x1)throw new Error(PE(z1.E)+String(s)+'.');return s;}d(ue,Ps(0x20e));const H='Start',$={'retries':0x2,'nudge':Ps(0x1f9)};function fe(s){const Ph=Ps;if(!Number[Ph(0x23b)](s)||s<0x0)throw new Error('emptyResponseRecovery.retries\x20must\x20be\x20a\x20non-negative\x20integer;\x20received\x20'+String(s)+'.');return s;}d(fe,Ps(0x256));const Ie={'emptyHistorySeed':H,'emptyResponseRecovery':$};class Me{static{d(this,Ps(0x24e));}[Ps(0x1f7)];constructor(s){const Pi=Ps;this[Pi(0x1f7)]=s;}async[Ps(0x212)](I){const z8={s:0x255,E:0x201,h:0x255,i:0x1fa,c:0x205,l:0x24c,R:0x205,I:0x230,a:0x229,g:0x235,v:0x246,m:0x21c,A:0x254,n:0x241,t:0x1fc,P0:0x1fd,P1:0x245,P2:0x1f2,P3:0x219,P4:0x208,P5:0x224,P6:0x20a},z7={s:0x225},z6={s:0x248,E:0x218,h:0x1fc,i:0x226,c:0x1fc,l:0x220,R:0x21b,I:0x22d,a:0x213,g:0x202,v:0x251,m:0x202,A:0x234,n:0x21c,t:0x23c,P0:0x1ef,P1:0x21c,P2:0x23f,P3:0x21c,P4:0x1f5,P5:0x21c},z5={s:0x21e,E:0x22c,h:0x25a},z4={s:0x22c,E:0x211,h:0x23e,i:0x207,c:0x22c,l:0x200,R:0x219,I:0x205},Pc=Ps,P0=I[Pc(0x1f3)]?.['signal'];P0?.[Pc(0x1fc)]();const P1=[...I['history']],P2=[],P3=I['lifecycle'];if(P3?.[Pc(z8.s)]){const PW=P1['at'](-0x1),PC=PW&&K[Pc(z8.E)](PW)?PW:void 0x0,PK=await P3[Pc(z8.h)](PC);P0?.['throwIfAborted'](),PK!==PC&&(PC&&(P1[Pc(z8.i)](),PC['id']&&PC['id']!==PK?.['id']&&P2['push'](new u({'id':PC['id']}))),PK&&(P1['push'](PK),P2[Pc(z8.c)](PK)));}const P4=typeof I['systemPrompt']=='function'?I[Pc(0x233)]():I[Pc(0x233)];P0?.['throwIfAborted']();const P5=I[Pc(0x1ee)]===void 0x0?H:I['emptyHistorySeed'];if(P1[Pc(z8.l)]===0x0&&P5!==null){const PH=G(P5);P1[Pc(z8.R)](PH),P2[Pc(0x205)](PH);}let P6=[],P7=k();const P8=ue(I['maxAgentRounds']??pe),P9=I['emptyResponseRecovery']===void 0x0?$:I['emptyResponseRecovery'],PP=P9?fe(P9[Pc(0x215)]):0x0;let Pz=0x0,PB=I[Pc(z8.I)],Pb=!0x1;const Pe=d(()=>P3?e[Pc(0x214)](PB,{'params':{'retries':0x0}}):PB,Pc(z8.a)),PN=d(()=>({'nodeId':P3['nodeId'],'provider':w[Pc(0x1fb)](PB)['provider'],'model':PB[Pc(0x207)],...P0===void 0x0?{}:{'signal':P0}}),Pc(z8.g)),Pw=d(async(Pu,Px)=>{const Pl=Pc;if(P0?.['throwIfAborted'](),Pu===null)throw Px;if(typeof Pu=='object'&&Pu[Pl(z4.s)]===Pl(z4.E)){if(Pb)throw new Error(Pl(0x236),{'cause':Px});PB=e[Pl(z4.h)](Pu[Pl(z4.i)]),Pb=!0x0,Pz=0x0;return;}const PZ=typeof Pu==Pl(0x200)?void 0x0:Pu;if(PZ&&(PZ[Pl(z4.c)]===Pl(0x21a)||PZ[Pl(0x208)]||PZ[Pl(0x245)]!==void 0x0))throw new Error(Pl(0x24d));const Po=typeof Pu==Pl(z4.l)?Pu:PZ?.[Pl(0x224)];return PZ?.[Pl(z4.R)]&&P2[Pl(0x205)](...PZ['messages']),Po!==void 0x0&&P2[Pl(z4.I)](new C(Po)),{'messages':P2,'usage':P7,'stoppedAfterTool':!0x1,...Po===void 0x0?{}:{'response':Po},...PZ===void 0x0?{}:{'toolResponse':PZ}};},Pc(0x23a)),PX=d(async(Pu,Px)=>{const PR=Pc;P0?.['throwIfAborted']();const PZ=await P3['onLlmBlocked'](Pu);if(P0?.[PR(0x1fc)](),typeof PZ==PR(z5.s)&&PZ!==null&&PZ[PR(z5.E)]==='retry_with_model')throw new Error(PR(z5.h));return await Pw(PZ,new y(Pu,Px));},Pc(0x20b)),Py=d(async()=>{const PI=Pc;let Pu=0x0;for(;;){P0?.['throwIfAborted']();const Px=Pb?0x1:Number(PB[PI(z6.s)]['retries'])+0x1;Pu+=0x1;let PZ;const Po=Pe();try{PZ=await this[PI(0x1f7)][PI(0x1f8)](P4,P1,I[PI(z6.E)],Po,I['callOptions']);}catch(PD){if(P0?.[PI(z6.h)](),!P3||PD instanceof W)throw PD;const Pj=we(PD,PN());if(Pj)return PX(Pj,PD);const Pr=PD instanceof Error?PD:new Error(String(PD)),PM=P3[PI(z6.i)]({...PN(),'error':Pr,'attempt':Pu,'maxAttempts':Px});if(P0?.[PI(z6.c)](),PM!==!0x1&&Pu<Px){await q(P0);continue;}const PU={...PN(),'kind':PI(z6.l),'error':Pr,'attemptsMade':Pu,'maxAttempts':Px,'stoppedBecause':PM===!0x1?PI(z6.R):PI(0x1f5)},PJ=await Pw(await P3['onLlmError'](PU),Pr);if(PJ)return PJ;Pu=0x0;continue;}if(P0?.[PI(0x1fc)](),P7=o(P7,PZ[PI(z6.I)]),!P3)return PZ;const Pk=T(PZ['value']);if(Pk['category']===PI(z6.a)||[PI(0x1fe),PI(0x24f)][PI(0x217)](L(Pk[PI(0x202)]??'')))return PX({...PN(),'phase':'candidate','rawReason':Pk[PI(z6.g)]??PI(z6.v),'reason':L(Pk[PI(z6.m)]??PI(0x251)),...Array[PI(z6.A)](Pk[PI(0x203)])?{'safetyRatings':Pk['ratings']}:{},...(PZ[PI(z6.n)][PI(z6.t)]['stop_details']??PZ[PI(0x21c)][PI(0x23f)][PI(0x1ef)]??Pk[PI(0x1f6)])===void 0x0?{}:{'providerDetails':PZ[PI(0x21c)][PI(z6.t)][PI(z6.P0)]??PZ[PI(z6.P1)][PI(z6.P2)][PI(z6.P0)]??Pk['detail']}});if(!Y(PZ[PI(z6.P3)]))return PZ;const Pq=P3[PI(0x20f)](PZ[PI(0x21c)]);if(P0?.[PI(0x1fc)](),!Pq)return PZ;if(Pu<Px){await q(P0);continue;}const PO=new Error(PI(0x1ff)),PQ=await Pw(await P3[PI(0x241)]({...PN(),'kind':PI(0x21d),'error':PO,'attemptsMade':Pu,'maxAttempts':Px,'stoppedBecause':PI(z6.P4),'lastResponse':PZ[PI(z6.P5)]}),PO);if(PQ)return PQ;Pu=0x0;}},Pc(z8.v));try{for(let Pu=0x0;Pu<P8;Pu+=0x1){const Px=await Py();if(!(Pc(z8.m)in Px))return Px;P2[Pc(z8.c)](Px[Pc(z8.m)]),P1[Pc(0x205)](Px[Pc(0x21c)]);const PZ=Px[Pc(0x21c)][Pc(0x20d)]??[];if(PZ[Pc(0x24c)]===0x0){const Pq=he(Px['value'],PB);if(Pq['trim']()&&(!P3||Y(Px[Pc(z8.m)])))return await PF(),{'messages':P2,'usage':P7,'response':Pq,'stoppedAfterTool':!0x1};const PO=T(Px[Pc(0x21c)]),PQ=J(PO)&&P9!==null&&Pz<PP&&!Pb&&(!P3||Pu+0x1<P8);if(S({'empty_model_response':r(PO),'retried':PQ}),PQ&&P9){Pz+=0x1,P2[Pc(0x1fa)](),P1[Pc(z8.i)](),P1['push'](G(P9[Pc(z8.A)]));continue;}if(P3){P2[Pc(0x1fa)](),P1['pop']();const PD=new ce(PO),Pj=await Pw(await P3[Pc(z8.n)]({...PN(),'kind':Pc(0x221),'error':PD,'attemptsMade':Pz+0x1,'maxAttempts':Pb?0x1:Math[Pc(0x223)](PP+0x1,Pz+P8-Pu),'stoppedBecause':Pc(0x1f5),'lastResponse':Px['value']}),PD);if(Pj)return Pj;Pu-=0x1;continue;}return await PF(),{'messages':P2,'usage':P7,'response':Pq,'stoppedAfterTool':!0x1,'stopReason':PO};}await PF();let Po=!0x1,Pk;try{for(const [Pr,PM]of PZ['entries']()){P0?.[Pc(z8.t)]();const PU=await I[Pc(z8.P0)](PM);if(D(PU)){if(PU['kind']==='go'&&O(PU),PU['kind']!==Pc(0x21a)){if(Pk&&Pk['kind']!=='stay'&&!me(Pk,PU))throw new Error(Pc(0x258));Pk=PU;}else Pk||(Pk=PU);const PJ=new x({'content':PU[Pc(z8.P1)]??'OK','tool_call_id':PM['id']??Pc(z8.P2)+Pu+'-'+Pr,'name':PM[Pc(0x206)]});P2['push'](PJ),P1[Pc(0x205)](PJ),PU[Pc(0x219)]&&(P2[Pc(0x205)](...PU['messages']),P1['push'](...PU[Pc(z8.P3)])),PU[Pc(z8.P4)]&&P6[Pc(0x205)](PU[Pc(0x208)]),P0?.[Pc(0x1fc)](),Po||=PU[Pc(0x22c)]!=='stay';continue;}}}catch(PT){throw await PF(),PT;}if(Po){const PS=Pk?.[Pc(z8.P5)];if(PS){const Pd=new C(PS);P2['push'](Pd),P1[Pc(0x205)](Pd);}return await PF(),{'messages':P2,'usage':P7,'stoppedAfterTool':!0x0,...PS?{'response':PS}:{},...Pk?{'toolResponse':Pk}:{}};}}throw await PF(),new Error(Pc(0x23d)+P8+Pc(z8.P6));}finally{await PF();}async function PF(){const Pa=Pc,PG=P6;P6=[],await Promise[Pa(z7.s)](PG[Pa(0x231)](Pf=>Pf()));}d(PF,Pc(0x257));}}function me(E,h){const z9={s:0x238,E:0x239,h:0x253},Pg=Ps;if(E['kind']!=='go'||h[Pg(0x22c)]!=='go')return!0x1;const i=O(E),c=new Set(O(h));return i[Pg(0x24c)]===c['size']&&i[Pg(z9.s)](l=>c['has'](l))&&E[Pg(0x239)]===void 0x0&&h[Pg(z9.E)]===void 0x0&&E[Pg(z9.h)]===void 0x0&&h[Pg(z9.h)]===void 0x0&&E[Pg(0x219)]===void 0x0&&h['messages']===void 0x0&&E['cleanup']===void 0x0&&h[Pg(0x208)]===void 0x0&&E[Pg(0x224)]===void 0x0&&h[Pg(0x224)]===void 0x0&&E['usage']===void 0x0&&h[Pg(0x22d)]===void 0x0;}d(me,Ps(0x249));function G(s){return new K({'content':s,'additional_kwargs':{'ezgraphInternal':!0x0}});}d(G,Ps(0x250));function ye(s){const zz={s:0x259},PY=Ps;return typeof s['content']=='string'?s[PY(zz.s)]:JSON[PY(0x20c)](s['content']);}d(ye,Ps(0x209));function he(s,E){const zB={s:0x259},Pv=Ps;return f(E)?p(s[Pv(zB.s)]):ye(s);}d(he,Ps(0x222));function L(s){const zb={s:0x232,E:0x244},Pm=Ps;return s[Pm(zb.s)]()[Pm(0x22a)]()[Pm(zb.E)]('-','_');}d(L,Ps(0x210));function we(E,h){const ze={s:0x21e,E:0x1ed,h:0x234},PL=Ps;if(!E||typeof E!=PL(ze.s))return null;const c=E,l=c[PL(0x242)]??c[PL(ze.E)];if(typeof l!='string'||!l[PL(0x232)]())return null;const R=c['safetyRatings']??c[PL(0x216)];return{...h,'phase':'prompt','rawReason':l,'reason':L(l),...Array[PL(ze.h)](R)?{'safetyRatings':R}:{}};}function B(P,b){P=P-0x1ed;const e=z();let N=e[P];if(B['YuevmR']===undefined){var w=function(W){const C='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let K='',H='';for(let u=0x0,x,Z,o=0x0;Z=W['charAt'](o++);~Z&&(x=u%0x4?x*0x40+Z:Z,u++%0x4)?K+=String['fromCharCode'](0xff&x>>(-0x2*u&0x6)):0x0){Z=C['indexOf'](Z);}for(let q=0x0,O=K['length'];q<O;q++){H+='%'+('00'+K['charCodeAt'](q)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(H);};B['jcKpvx']=w,B['ArHGMx']={},B['YuevmR']=!![];}const X=e[0x0],y=P+X,F=B['ArHGMx'][y];return!F?(N=B['jcKpvx'](N),B['ArHGMx'][y]=N):N=F,N;}d(we,'promptBlockedContext');function Y(s){const zN={s:0x259,E:0x232},PA=Ps;return s['tool_calls']?.['length']?!0x0:typeof s[PA(zN.s)]==PA(0x200)?!!s['content'][PA(zN.E)]():s[PA(zN.s)][PA(0x24b)](E=>typeof E['text']==PA(0x200)&&!!E['text'][PA(0x232)]());}d(Y,Ps(0x240));async function q(s){const zw={s:0x1fc},Pn=Ps;try{await b(0x1f4,void 0x0,s?{'signal':s}:void 0x0);}catch(E){throw s?.[Pn(zw.s)](),E;}}d(q,'waitForRetry');export{H as DEFAULT_EMPTY_HISTORY_SEED,$ as DEFAULT_EMPTY_RESPONSE_RECOVERY,Ie as DEFAULT_LLM_POLICY,pe as DEFAULT_MAX_AGENT_ROUNDS,ce as EmptyModelResponseError,Me as LlmRunner,fe as assertEmptyResponseRetries,ue as assertMaxAgentRounds};
1
+ const lt=h;(function(x,i){const lT={x:0x1d9,i:0x217,O:0x1c9},lV=h,O=x();while(!![]){try{const t=-parseInt(lV(0x1de))/0x1+parseInt(lV(lT.x))/0x2+-parseInt(lV(0x1e8))/0x3+parseInt(lV(lT.i))/0x4+-parseInt(lV(0x1d6))/0x5+parseInt(lV(lT.O))/0x6*(parseInt(lV(0x1c6))/0x7)+parseInt(lV(0x22e))/0x8;if(t===i)break;else O['push'](O['shift']());}catch(k){O['push'](O['shift']());}}}(l,0x83962));var V=Object[lt(0x225)],d=(x,i)=>V(x,lt(0x1ef),{'value':i,'configurable':!0x0});import{setTimeout as c}from'node:timers/promises';import{GraphLlm as e,ModelCatalog as r}from'./graph-llm.config.js';import{LlmResponseBlockedError as v,LlmSetupError as I}from'./llm-lifecycle.js';import{AIMessage as s,HumanMessage as E,RemoveMessage as D,ToolMessage as A}from'@langchain/core/messages';import{addTokenUsage as m,emptyTokenUsage as w}from'./token-usage.js';import{goTargetIds as C,isToolResponse as o}from'./tool-response.js';import{describeStopReason as b,isRetryableStopReason as n,modelStopReason as R}from'./model-stop-reason.js';import{SessionLogWarning as f}from'./session-log.js';import{observeRunNodeUsage as u}from'./node-invocation.js';import{isOpenAIAuthConfig as J,openAIAuthMessageText as g}from'./openai-auth-provider.js';class ue extends Error{static{d(this,lt(0x20d));}[lt(0x1c3)];constructor(x){const lF={x:0x218,i:0x1c3},ld=lt;super(ld(lF.x)+b(x)+').'),this[ld(lF.i)]=x,this['name']=ld(0x20d);}}const pe=0x8;function fe(x){const h0={x:0x1e5,i:0x229},lk=lt;if(!Number[lk(h0.x)](x)||x<0x1)throw new Error(lk(h0.i)+String(x)+'.');return x;}d(fe,lt(0x1fc));const H=lt(0x22c),$={'retries':0x2,'nudge':lt(0x1eb)};function me(x){const la=lt;if(!Number[la(0x1e5)](x)||x<0x0)throw new Error(la(0x1c5)+String(x)+'.');return x;}d(me,'assertEmptyResponseRetries');const Le={'emptyHistorySeed':H,'emptyResponseRecovery':$};class Se{static{d(this,'LlmRunner');}[lt(0x20a)];constructor(x){const lp=lt;this[lp(0x20a)]=x;}async[lt(0x1d2)](B){const h7={x:0x1dd,i:0x21c,O:0x220,t:0x1f1,k:0x1ff,a:0x1d1,p:0x206,W:0x1db,z:0x214,B:0x1cf,y:0x226,S:0x228,K:0x1d0,T:0x208,l0:0x20e,l1:0x1d0,l2:0x1fd,l3:0x221,l4:0x224,l5:0x1e9,l6:0x1e9,l7:0x1f4,l8:0x1d1,l9:0x1f4,ll:0x1f4,lh:0x21a,lc:0x1e9,lr:0x201,lQ:0x1c8},h6={x:0x216},h5={x:0x220,i:0x1fb,O:0x1df,t:0x1cb,k:0x227,a:0x1e6,p:0x213,W:0x222,z:0x1fa,B:0x1d0,y:0x21b,S:0x1d0,K:0x21f,T:0x21b,l0:0x1fe,l1:0x1d0,l2:0x1da,l3:0x21b,l4:0x1fe,l5:0x1d5,l6:0x20c},h4={x:0x220,i:0x220,O:0x200,t:0x1dc},h3={x:0x20f,i:0x1e4,O:0x21a,t:0x1f4,k:0x1f4},lW=lt,K=B[lW(h7.x)]?.[lW(h7.i)];K?.[lW(h7.O)]();const l0=[...B[lW(0x204)]],l1=[],l2=B['lifecycle'];if(l2?.[lW(h7.t)]){const lE=l0['at'](-0x1),lD=lE&&E[lW(h7.k)](lE)?lE:void 0x0,lA=await l2['onEnter'](lD);K?.[lW(0x220)](),lA!==lD&&(lD&&(l0[lW(0x1cc)](),lD['id']&&lD['id']!==lA?.['id']&&l1['push'](new D({'id':lD['id']}))),lA&&(l0[lW(h7.a)](lA),l1[lW(0x1d1)](lA)));}const l3=typeof B[lW(h7.p)]==lW(h7.W)?B[lW(0x206)]():B['systemPrompt'];K?.[lW(h7.O)]();const l4=B['emptyHistorySeed']===void 0x0?H:B[lW(h7.z)];if(l0[lW(0x1e7)]===0x0&&l4!==null){const lj=G(l4);l0['push'](lj),l1['push'](lj);}let l5=[],l6=w();const l7=fe(B[lW(0x1f3)]??pe),l8=B['emptyResponseRecovery']===void 0x0?$:B[lW(h7.B)],l9=l8?me(l8[lW(h7.y)]):0x0;let ll=0x0,lh=B[lW(0x1cd)],lc=!0x1;const lr=d(()=>l2?e[lW(0x22f)](lh,{'params':{'retries':0x0}}):lh,'invocationConfig'),lQ=d(()=>({'nodeId':l2[lW(0x1c0)],'provider':r[lW(0x1c4)](lh)['provider'],'model':lh[lW(0x1ea)],...K===void 0x0?{}:{'signal':K}}),lW(h7.S)),lv=d(async(lH,lm)=>{const lz=lW;if(K?.[lz(0x220)](),lH===null)throw lm;if(typeof lH=='object'&&lH[lz(0x200)]===lz(0x1ec)){if(lc)throw new Error(lz(h3.x),{'cause':lm});lh=e[lz(0x1f5)](lH[lz(0x1ea)]),lc=!0x0,ll=0x0;return;}const lw=typeof lH==lz(h3.i)?void 0x0:lH;if(lw&&(lw['kind']==='stay'||lw[lz(h3.O)]||lw[lz(0x1d7)]!==void 0x0))throw new Error(lz(0x1d3));const lZ=typeof lH=='string'?lH:lw?.[lz(0x1c1)];return lw?.[lz(h3.t)]&&l1[lz(0x1d1)](...lw[lz(h3.k)]),lZ!==void 0x0&&l1['push'](new s(lZ)),{'messages':l1,'usage':l6,'stoppedAfterTool':!0x1,...lZ===void 0x0?{}:{'response':lZ},...lw===void 0x0?{}:{'toolResponse':lw}};},'applyRecovery'),lG=d(async(lH,lm)=>{const lP=lW;K?.[lP(h4.x)]();const lw=await l2[lP(0x22b)](lH);if(K?.[lP(h4.i)](),typeof lw==lP(0x21d)&&lw!==null&&lw[lP(h4.O)]===lP(0x1ec))throw new Error(lP(h4.t));return await lv(lw,new v(lH,lm));},lW(0x1f7)),lI=d(async()=>{const lY=lW;let lH=0x0;for(;;){K?.[lY(h5.x)]();const lm=lc?0x1:Number(lh[lY(h5.i)][lY(0x226)])+0x1;lH+=0x1;let lw;const lZ=lr();try{lw=await this['llmGateway'][lY(h5.O)](l3,l0,B['tools'],lZ,B[lY(0x1dd)]);}catch(lb){if(K?.[lY(0x220)](),!l2||lb instanceof I)throw lb;const ln=ge(lb,lQ());if(ln)return lG(ln,lb);const lR=lb instanceof Error?lb:new Error(String(lb)),lf=l2['shouldRetryLlmError']({...lQ(),'error':lR,'attempt':lH,'maxAttempts':lm});if(K?.[lY(0x220)](),lf!==!0x1&&lH<lm){await q(K);continue;}const lu={...lQ(),'kind':lY(h5.t),'error':lR,'attemptsMade':lH,'maxAttempts':lm,'stoppedBecause':lf===!0x1?lY(0x209):lY(0x210)},lJ=await lv(await l2[lY(0x221)](lu),lR);if(lJ)return lJ;lH=0x0;continue;}if(K?.[lY(0x220)](),l6=m(l6,lw['usage']),u(lw[lY(0x1ca)]),!l2)return lw;const lC=R(lw[lY(0x1d0)]);if(lC[lY(0x1ce)]==='blocked'||[lY(h5.k),lY(h5.a)]['includes'](L(lC['provider']??'')))return lG({...lQ(),'phase':'candidate','rawReason':lC[lY(h5.p)]??lY(0x222),'reason':L(lC['provider']??lY(h5.W)),...Array[lY(h5.z)](lC['ratings'])?{'safetyRatings':lC['ratings']}:{},...(lw[lY(h5.B)]['response_metadata'][lY(h5.y)]??lw[lY(h5.S)][lY(h5.K)][lY(h5.T)]??lC[lY(h5.l0)])===void 0x0?{}:{'providerDetails':lw[lY(h5.l1)][lY(h5.l2)][lY(h5.l3)]??lw[lY(h5.l1)][lY(h5.K)][lY(0x21b)]??lC[lY(h5.l4)]}});if(!Y(lw[lY(h5.l1)]))return lw;const lo=l2[lY(h5.l5)](lw['value']);if(K?.[lY(h5.x)](),!lo)return lw;if(lH<lm){await q(K);continue;}const lL=new Error(lY(0x1f9)),lq=await lv(await l2[lY(0x221)]({...lQ(),'kind':lY(h5.l6),'error':lL,'attemptsMade':lH,'maxAttempts':lm,'stoppedBecause':lY(0x210),'lastResponse':lw[lY(0x1d0)]}),lL);if(lq)return lq;lH=0x0;}},lW(0x22a));try{for(let lH=0x0;lH<l7;lH+=0x1){const lm=await lI();if(!(lW(h7.K)in lm))return lm;l1['push'](lm['value']),l0[lW(0x1d1)](lm[lW(h7.K)]);const lw=lm[lW(h7.K)][lW(h7.T)]??[];if(lw[lW(0x1e7)]===0x0){const lo=we(lm[lW(h7.K)],lh);if(lo[lW(h7.l0)]()&&(!l2||Y(lm['value'])))return await ls(),{'messages':l1,'usage':l6,'response':lo,'stoppedAfterTool':!0x1};const lL=R(lm[lW(h7.l1)]),lq=n(lL)&&l8!==null&&ll<l9&&!lc&&(!l2||lH+0x1<l7);if(f({'empty_model_response':b(lL),'retried':lq}),lq&&l8){ll+=0x1,l1['pop'](),l0['pop'](),l0[lW(h7.a)](G(l8[lW(h7.l2)]));continue;}if(l2){l1['pop'](),l0[lW(0x1cc)]();const lb=new ue(lL),ln=await lv(await l2[lW(h7.l3)]({...lQ(),'kind':lW(0x1ed),'error':lb,'attemptsMade':ll+0x1,'maxAttempts':lc?0x1:Math[lW(0x1f8)](l9+0x1,ll+l7-lH),'stoppedBecause':'attempts_exhausted','lastResponse':lm[lW(0x1d0)]}),lb);if(ln)return ln;lH-=0x1;continue;}return await ls(),{'messages':l1,'usage':l6,'response':lo,'stoppedAfterTool':!0x1,'stopReason':lL};}await ls();let lZ=!0x1,lC;try{for(const [lR,lf]of lw[lW(0x21e)]()){K?.[lW(0x220)]();const lu=await B[lW(h7.l4)](lf);if(o(lu)){if(lu[lW(0x200)]==='go'&&C(lu),lu['kind']!==lW(h7.l5)){if(lC&&lC[lW(0x200)]!==lW(h7.l6)&&!ye(lC,lu))throw new Error(lW(0x207));lC=lu;}else lC||(lC=lu);const lJ=new A({'content':lu[lW(0x1d7)]??'OK','tool_call_id':lf['id']??lW(0x1d4)+lH+'-'+lR,'name':lf[lW(0x1ef)]});l1['push'](lJ),l0['push'](lJ),lu[lW(h7.l7)]&&(l1[lW(h7.l8)](...lu[lW(h7.l9)]),l0['push'](...lu[lW(h7.ll)])),lu[lW(h7.lh)]&&l5[lW(0x1d1)](lu['cleanup']),K?.['throwIfAborted'](),lZ||=lu['kind']!==lW(h7.lc);continue;}}}catch(lg){throw await ls(),lg;}if(lZ){const lN=lC?.[lW(0x1c1)];if(lN){const lx=new s(lN);l1['push'](lx),l0[lW(h7.a)](lx);}return await ls(),{'messages':l1,'usage':l6,'stoppedAfterTool':!0x0,...lN?{'response':lN}:{},...lC?{'toolResponse':lC}:{}};}}throw await ls(),new Error(lW(h7.lr)+l7+lW(h7.lQ));}finally{await ls();}async function ls(){const lB=lW,li=l5;l5=[],await Promise[lB(h6.x)](li[lB(0x1ee)](lO=>lO()));}d(ls,'cleanupAttachments');}}function ye(x,i){const h8={x:0x200,i:0x1f2,O:0x219,t:0x1f4,k:0x21a,a:0x1c1,p:0x1ca},ly=lt;if(x[ly(h8.x)]!=='go'||i[ly(h8.x)]!=='go')return!0x1;const O=C(x),k=new Set(C(i));return O[ly(0x1e7)]===k[ly(h8.i)]&&O[ly(0x22d)](p=>k[ly(0x1e3)](p))&&x[ly(0x219)]===void 0x0&&i[ly(h8.O)]===void 0x0&&x['message']===void 0x0&&i['message']===void 0x0&&x[ly(0x1f4)]===void 0x0&&i[ly(h8.t)]===void 0x0&&x['cleanup']===void 0x0&&i[ly(h8.k)]===void 0x0&&x[ly(0x1c1)]===void 0x0&&i[ly(h8.a)]===void 0x0&&x['usage']===void 0x0&&i[ly(h8.p)]===void 0x0;}d(ye,lt(0x1d8));function G(x){return new E({'content':x,'additional_kwargs':{'ezgraphInternal':!0x0}});}d(G,lt(0x215));function he(x){const hl={x:0x1c7,i:0x1e4},lU=lt;return typeof x[lU(hl.x)]==lU(hl.i)?x[lU(0x1c7)]:JSON[lU(0x1f6)](x[lU(0x1c7)]);}d(he,lt(0x1e0));function we(x,i){return J(i)?g(x['content']):he(x);}d(we,lt(0x1e2));function L(x){const hc={x:0x212},lX=lt;return x['trim']()['toLowerCase']()[lX(hc.x)]('-','_');}function h(c,e){c=c-0x1c0;const r=l();let Q=r[c];if(h['lAqOKE']===undefined){var v=function(E){const D='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let A='',j='';for(let H=0x0,m,w,Z=0x0;w=E['charAt'](Z++);~w&&(m=H%0x4?m*0x40+w:w,H++%0x4)?A+=String['fromCharCode'](0xff&m>>(-0x2*H&0x6)):0x0){w=D['indexOf'](w);}for(let C=0x0,o=A['length'];C<o;C++){j+='%'+('00'+A['charCodeAt'](C)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(j);};h['ChChuV']=v,h['kDTAzo']={},h['lAqOKE']=!![];}const G=r[0x0],I=c+G,s=h['kDTAzo'][I];return!s?(Q=h['ChChuV'](Q),h['kDTAzo'][I]=Q):Q=s,Q;}function l(){const hG=['C2LNBMfS','B2jQzwn0','zw50CMLLCW','ywrKAxrPB25HBf9RD2fYz3m','DgHYB3DjzKfIB3j0zwq','B25mBg1fCNjVCG','CMvMDxnHBa','yMXVy2TFCMvHC29U','zxHLy3v0zvrVB2W','zgvMAw5LuhjVCgvYDhK','CMv0CMLLCW','B3rOzxi','y29TBw9Uq29UDgv4Da','Bwf4qwDLBNrsB3vUzhmGBxvZDcbIzsbHihbVC2L0AxzLigLUDgvNzxi7ihjLy2vPDMvKia','ywnXDwLYzunHBMrPzgf0zq','B25mBg1cBg9JA2vK','u3rHCNq','zxzLCNK','mtm3otKWngHRBKzxwq','CMvZB2X2zunVBMzPzW','BM9KzuLK','CMvZCg9UC2u','C2fMzxr5uMf0Aw5NCW','CMvHC29U','CMvZB2X2zu1VzgvSrgvZy3jPChrVCG','zw1WDhLszxnWB25ZzvjLy292zxj5lNjLDhjPzxmGBxvZDcbIzsbHig5VBI1UzwDHDgL2zsbPBNrLz2vYoYbYzwnLAxzLzca','mZm2n0vyz2fZyq','y29UDgvUDa','igfNzw50ihjVDw5KCY4','mte0mfrwCvHuzq','DxnHz2u','Aw52B2nHDgLVBL9LCNjVCG','Cg9W','BgXTq29UzMLN','y2f0zwDVCNK','zw1WDhLszxnWB25ZzvjLy292zxj5','DMfSDwu','ChvZAa','CNvU','teXnihjLy292zxj5ignHBM5VDcbYzxr1CM4GDg9VBc1VBMX5ihn0yxKOksWGy2XLyw51CcWGB3iGzMvLzgjHy2SU','Dg9VBc1JywXSlq','y2HLy2TszxnWB25Zzq','mJu5oti1A2HNtLzI','zMvLzgjHy2S','Axntyw1LqMfYzvrYyw5ZAxrPB24','otm2odi0CLr6uM1A','CMvZCg9UC2vFBwv0ywrHDge','zNvUy3rPB24','CMv0CNLxAxrOtw9KzwWOksbPCYbZDxbWB3j0zwqGB25SEsbIEsbVBKXSBuvYCM9YkcKU','y2fSBe9WDgLVBNm','nJu4mJqZBenoyLnO','ywDLBNq','BwvZC2fNzvrLEhq','yMXVy2TszwfZB24','CMvZCg9UC2vuzxH0','AgfZ','C3rYAw5N','AxnjBNrLz2vY','Aw1Hz2vFB3rOzxi','BgvUz3rO','nty1nZe5sKHuAevt','C3rHEq','Bw9KzwW','rM9SBg93ihrOzsbZExn0zw0GChjVBxb0igfUzcbYzxnWB25KihbYB3bLCMX5lIbvC2uGDgHLihjLCxvPCMvKihrVB2WGD2HLBIbPBNn0CNvJDgvKlG','CMv0CNLFD2L0Af9TB2rLBa','zw1WDhLFCMvZCg9UC2u','BwfW','BMfTzq','C2fMzxr5x3jHDgLUz3m','B25fBNrLCG','C2L6zq','Bwf4qwDLBNrsB3vUzhm','BwvZC2fNzxm','DMfSAwrHDgvdB25MAwC','C3rYAw5NAwz5','AgfUzgXLqMXVy2TLza','BwLU','vgHLig1VzgvSihjLC3bVBNnLihDHCYbYzwPLy3rLzcbIEsbJAgvJA1jLC3bVBNnLkcKU','AxnbCNjHEq','CgfYyw1Z','yxnZzxj0twf4qwDLBNrsB3vUzhm','BNvKz2u','zgv0ywLS','AxnjBNn0yw5Jzq','A2LUza','q29UDMvYC2f0Aw9Uigv4y2vLzgvKia','BM9YBwfSAxPLuMvHC29U','ChjVBxb0','AgLZDg9YEq','AgfZq2fUzgLKyxrLq29UDgvUDa','C3LZDgvTuhjVBxb0','qsb0B29SigjHDgnOihnLBgvJDgvKig1VCMuGDgHHBIbVBMuGDgvYBwLUywWGCMvZCg9UC2uGB3iGDhjHBNnPDgLVBI4','Dg9VBf9JywXSCW','CMv0CNLFzgvJBgLUzwq','BgXTr2f0zxDHEq','ChjVBxb0qMXVy2TLzenVBNrLEhq','CMvZCg9UC2vFCMvQzwn0zwq','rw1WDhLnB2rLBfjLC3bVBNnLrxjYB3i','DhjPBq','CMv0CNLxAxrOtw9KzwWOksbTyxKGyMuGCMv0DxjUzwqGB25SEsbVBMnLigLUigeGCMvJB3zLCNKGC2vXDwvUy2uU','yxr0zw1WDhnFzxHOyxvZDgvK','C29Tzq','CMvWBgfJzufSBa','ChjVDMLKzxi','zw1WDhLiAxn0B3j5u2vLza','Aw50zxjUywXiDw1HBK1LC3nHz2u','ywXSu2v0DgXLza','mJGYmtK1nNr5q211wG','vgHLig1VzgvSihjLDhvYBMvKigfUigvTChr5ihjLC3bVBNnLicG','C3rHDgu','y2XLyw51Ca','C3rVCf9KzxrHAwXZ'];l=function(){return hG;};return l();}d(L,lt(0x202));function ge(x,O){const hr={x:0x21d,i:0x1e1,O:0x223,t:0x20e,k:0x1c2,a:0x1fa},lM=lt;if(!x||typeof x!=lM(hr.x))return null;const k=x,p=k[lM(hr.i)]??k[lM(hr.O)];if(typeof p!='string'||!p[lM(hr.t)]())return null;const W=k[lM(hr.k)]??k[lM(0x1f0)];return{...O,'phase':lM(0x203),'rawReason':p,'reason':L(p),...Array[lM(hr.a)](W)?{'safetyRatings':W}:{}};}d(ge,lt(0x20b));function Y(x){const hQ={x:0x1c7,i:0x1c7},lS=lt;return x[lS(0x208)]?.[lS(0x1e7)]?!0x0:typeof x['content']==lS(0x1e4)?!!x[lS(hQ.x)][lS(0x20e)]():x[lS(hQ.i)][lS(0x211)](i=>typeof i['text']=='string'&&!!i['text'][lS(0x20e)]());}d(Y,lt(0x205));async function q(x){const hv={x:0x220},lK=lt;try{await c(0x1f4,void 0x0,x?{'signal':x}:void 0x0);}catch(i){throw x?.[lK(hv.x)](),i;}}d(q,'waitForRetry');export{H as DEFAULT_EMPTY_HISTORY_SEED,$ as DEFAULT_EMPTY_RESPONSE_RECOVERY,Le as DEFAULT_LLM_POLICY,pe as DEFAULT_MAX_AGENT_ROUNDS,ue as EmptyModelResponseError,Se as LlmRunner,me as assertEmptyResponseRetries,fe as assertMaxAgentRounds};
@@ -1 +1 @@
1
- var v=Object.defineProperty;var n=(o,t)=>v(o,"name",{value:t,configurable:!0});import{AsyncLocalStorage as p}from"node:async_hooks";import{messagesStateReducer as h}from"@langchain/langgraph";import{cloneJsonObject as a,readonlyContext as y}from"./graph-context.js";const u=new p;function N(o){return u.getStore()?.owner===o}n(N,"hasNodeInvocation");async function b(o,t,e,r,i={},f=!1){const s=u.getStore();if(i.mode!==void 0&&i.mode!=="conversation"&&i.mode!=="internal")throw new Error(`Invalid node invocation mode '${String(i.mode)}'.`);if(s&&i.mode==="conversation")throw new Error("A nested node cannot take ownership of the conversation.");const x=s?"internal":i.mode??"conversation";return u.run({owner:o,nodeId:t,state:e,nodes:{},histories:{},mode:x,...s?.owner===o?{priorNode:s.nodeId}:{},localStateOnly:x==="internal"&&(f||s?.localStateOnly===!0)},r)}n(b,"withNodeInvocation");function k(o){return c(o).mode}n(k,"invocationMode");function j(o){return c(o).localStateOnly}n(j,"invocationIsLocalOnly");function d(o,t){const e=c(o);if(e.localStateOnly&&t!==e.nodeId)throw new Error(`Internal LLM node '${e.nodeId}' may publish only its own node state and token usage.`)}n(d,"assertInvocationWrite");function w(o){return c(o).nodeId}n(w,"invocationNodeId");function C(o){return c(o).priorNode}n(C,"invocationPriorNode");function E(o){const t=c(o);return y(t.context??t.state.context??{})}n(E,"invocationContext");function L(o,t){d(o);const e=c(o),r=a(t,"Context patch");e.context={...a(e.context??e.state.context??{}),...r}}n(L,"saveInvocationContext");function A(o,t){d(o),c(o).context=a(t)}n(A,"replaceInvocationContext");function l(o,t){const e=c(o),r=e.nodes[t];return r?{...r}:{...(e.state.nodes??{})[t]??{}}}n(l,"invocationNodeState");function H(o,t,e){d(o,t);const r=l(o,t);for(const[i,f]of Object.entries(e))f===void 0?delete r[i]:r[i]=f;c(o).nodes[t]=r}n(H,"saveInvocationNodeState");function M(o,t,e){d(o,t),c(o).nodes[t]={...e}}n(M,"replaceInvocationNodeState");function $(o,t,e){d(o);const r=c(o);r.histories[t]=[...r.histories[t]??[],...e]}n($,"appendInvocationHistory");function m(o,t){const e=c(o);return h(e.state.histories?.[t]??[],e.histories[t]??[])}n(m,"invocationHistory");function q(o){const t=c(o),e={...t.state.nodes??{}};for(const i of Object.keys(t.nodes))e[i]=l(o,i);const r={...t.state.histories??{}};for(const i of Object.keys(t.histories))r[i]=m(o,i);return{...t.state,nodes:e,histories:r,context:a(t.context??t.state.context??{})}}n(q,"invocationGraphState");function G(o){const t=c(o);return{...t.context!==void 0?{context:a(t.context)}:{},...Object.keys(t.nodes).length>0?{nodes:t.nodes}:{},...Object.keys(t.histories).length>0?{histories:t.histories}:{}}}n(G,"invocationUpdate");function c(o){const t=u.getStore();if(!t||t.owner!==o)throw new Error("Node state can only be accessed during an active graph-node invocation.");return t}n(c,"requireInvocation");export{$ as appendInvocationHistory,d as assertInvocationWrite,N as hasNodeInvocation,E as invocationContext,q as invocationGraphState,m as invocationHistory,j as invocationIsLocalOnly,k as invocationMode,w as invocationNodeId,l as invocationNodeState,C as invocationPriorNode,G as invocationUpdate,A as replaceInvocationContext,M as replaceInvocationNodeState,L as saveInvocationContext,H as saveInvocationNodeState,b as withNodeInvocation};
1
+ var m=Object.defineProperty;var r=(t,e)=>m(t,"name",{value:e,configurable:!0});import{AsyncLocalStorage as x}from"node:async_hooks";import{messagesStateReducer as S}from"@langchain/langgraph";import{cloneJsonObject as h,readonlyContext as b}from"./graph-context.js";import{addTokenUsage as p}from"./token-usage.js";import{addDecisionUsage as N}from"./decision/decision-types.js";import{SessionLogWarning as y}from"./session-log.js";const g=new x,u=new x;function A(t,e){return u.run(t,e)}r(A,"withRunNodeExecution");function L(t,e){const o=u.getStore();o?.owner===t&&(o.outcome=e)}r(L,"recordRunNodeOutcome");function $(t){const e=u.getStore();e&&(e.usage=p(e.usage,t))}r($,"observeRunNodeUsage");function H(t){const e=u.getStore();e&&(e.decisionUsage={...t})}r(H,"observeRunNodeDecisionUsage");function M(t,e){const o=u.getStore();o?.owner===t&&(e.tokens&&(o.usage=p(void 0,e.tokens)),e.decisionUsage&&(o.decisionUsage=N(void 0,e.decisionUsage)))}r(M,"recordRunNodeUsage");function T(t){i(t);const e=u.getStore();return e?.owner===t?e.input:void 0}r(T,"runNodeInput");function W(t,e){const o=i(t);if(o.batchChild)throw new Error("A runNode() child cannot start a nested runNode() batch.");const s=new Set;for(const n of e){if(n===o.nodeId||o.ancestors.has(n)||s.has(n)||o.reservations.has(n))throw new Error(`runNode() target '${n}' is duplicated, active, or is the caller.`);s.add(n)}for(const n of e)o.reservations.add(n);return()=>{for(const n of e)o.reservations.delete(n)}}r(W,"reserveRunNodeTargets");function _(t){return i(t).nodeId}r(_,"currentInvocationNode");function q(t,e,o,s){const n=i(t);if(n.batchChild)throw new Error("A runNode() child cannot publish a child join.");for(const[a,c]of Object.entries(e)){if(!n.reservations.has(a))throw new Error(`Unreserved runNode() publication '${a}'.`);n.childNodes[a]=c,delete n.nodes[a]}n.childUsage=p(n.childUsage,o),n.childDecisionUsage=N(n.childDecisionUsage,s)}r(q,"joinRunNodeResults");function B(t){const e=i(t);return{...Object.keys(e.childNodes).length?{nodes:e.childNodes}:{},...e.childUsage?{tokens:e.childUsage}:{},...e.childDecisionUsage&&Object.values(e.childDecisionUsage).some(o=>o!==0)?{decisionUsage:e.childDecisionUsage}:{}}}r(B,"invocationChildUpdate");function G(t){return g.getStore()?.owner===t}r(G,"hasNodeInvocation");async function J(t,e,o,s,n={},a=!1){const c=g.getStore(),d=u.getStore();if(c?.batchChild)throw new Error("A runNode() child cannot invoke nested nodes.");if(d&&(d.owner!==t||d.nodeId!==e))throw new Error("runNode() task invoked an unexpected node.");if(n.mode!==void 0&&n.mode!=="conversation"&&n.mode!=="internal")throw new Error(`Invalid node invocation mode '${String(n.mode)}'.`);if(c&&n.mode==="conversation")throw new Error("A nested node cannot take ownership of the conversation.");const v=c?"internal":n.mode??"conversation";return g.run({owner:t,nodeId:e,state:o,nodes:{},histories:{},mode:v,...d?{priorNode:d.caller}:c?.owner===t?{priorNode:c.nodeId}:{},batchChild:d!==void 0,ancestors:c?.owner===t?new Set([...c.ancestors,c.nodeId]):new Set,reservations:new Set,childNodes:{},localStateOnly:d!==void 0||v==="internal"&&(a||c?.localStateOnly===!0)},async()=>{try{return await s()}catch(w){const f=i(t);throw(f.childUsage||f.childDecisionUsage)&&y({runNode_parent_failed:!0,node:e,...f.childUsage?{usage:f.childUsage}:{},...f.childDecisionUsage?{decisionUsage:f.childDecisionUsage}:{}}),w}})}r(J,"withNodeInvocation");function P(t){return i(t).mode}r(P,"invocationMode");function z(t){return i(t).localStateOnly}r(z,"invocationIsLocalOnly");function F(t){return i(t).batchChild}r(F,"invocationIsBatchChild");function l(t,e){const o=i(t);if(o.localStateOnly&&e!==o.nodeId)throw new Error(`Internal LLM node '${o.nodeId}' may publish only its own node state and token usage.`)}r(l,"assertInvocationWrite");function K(t){return i(t).nodeId}r(K,"invocationNodeId");function Q(t){return i(t).priorNode}r(Q,"invocationPriorNode");function V(t){const e=i(t);return b(e.context??e.state.context??{})}r(V,"invocationContext");function X(t,e){l(t);const o=i(t),s=h(e,"Context patch");o.context={...h(o.context??o.state.context??{}),...s}}r(X,"saveInvocationContext");function Y(t,e){l(t),i(t).context=h(e)}r(Y,"replaceInvocationContext");function U(t,e){const o=i(t),s=o.nodes[e];return s?{...s}:{...o.childNodes[e]??(o.state.nodes??{})[e]??{}}}r(U,"invocationNodeState");function Z(t,e,o){l(t,e);const s=U(t,e);for(const[n,a]of Object.entries(o))a===void 0?delete s[n]:s[n]=a;i(t).nodes[e]=s}r(Z,"saveInvocationNodeState");function ee(t,e,o){l(t,e),i(t).nodes[e]={...o}}r(ee,"replaceInvocationNodeState");function te(t,e,o){l(t);const s=i(t);s.histories[e]=[...s.histories[e]??[],...o]}r(te,"appendInvocationHistory");function I(t,e){const o=i(t);return S(o.state.histories?.[e]??[],o.histories[e]??[])}r(I,"invocationHistory");function oe(t){const e=i(t),o={...e.state.nodes??{}};Object.assign(o,e.childNodes);for(const n of Object.keys(e.nodes))o[n]=U(t,n);const s={...e.state.histories??{}};for(const n of Object.keys(e.histories))s[n]=I(t,n);return{...e.state,nodes:o,histories:s,context:h(e.context??e.state.context??{})}}r(oe,"invocationGraphState");function ne(t){const e=i(t);return{...e.context!==void 0?{context:h(e.context)}:{},...Object.keys(e.nodes).length>0?{nodes:e.nodes}:{},...Object.keys(e.histories).length>0?{histories:e.histories}:{}}}r(ne,"invocationUpdate");function i(t){const e=g.getStore();if(!e||e.owner!==t)throw new Error("Node state can only be accessed during an active graph-node invocation.");return e}r(i,"requireInvocation");export{te as appendInvocationHistory,l as assertInvocationWrite,_ as currentInvocationNode,G as hasNodeInvocation,B as invocationChildUpdate,V as invocationContext,oe as invocationGraphState,I as invocationHistory,F as invocationIsBatchChild,z as invocationIsLocalOnly,P as invocationMode,K as invocationNodeId,U as invocationNodeState,Q as invocationPriorNode,ne as invocationUpdate,q as joinRunNodeResults,H as observeRunNodeDecisionUsage,$ as observeRunNodeUsage,L as recordRunNodeOutcome,M as recordRunNodeUsage,Y as replaceInvocationContext,ee as replaceInvocationNodeState,W as reserveRunNodeTargets,T as runNodeInput,X as saveInvocationContext,Z as saveInvocationNodeState,J as withNodeInvocation,A as withRunNodeExecution};
@@ -1 +1 @@
1
- const Pk=B;(function(l,R){const z6={l:0xad,R:0xfd,a:0x125,Y:0xa6,m:0xce,L:0xe8},Po=B,a=l();while(!![]){try{const Y=-parseInt(Po(z6.l))/0x1*(-parseInt(Po(0x10b))/0x2)+-parseInt(Po(z6.R))/0x3+-parseInt(Po(z6.a))/0x4*(parseInt(Po(0xdc))/0x5)+-parseInt(Po(z6.Y))/0x6*(parseInt(Po(0xd6))/0x7)+-parseInt(Po(0x122))/0x8+parseInt(Po(z6.m))/0x9*(parseInt(Po(z6.L))/0xa)+parseInt(Po(0x99))/0xb*(parseInt(Po(0xa8))/0xc);if(Y===R)break;else a['push'](a['shift']());}catch(m){a['push'](a['shift']());}}}(z,0x27bd1));var J=Object[Pk(0xc6)],c=(l,R)=>J(l,Pk(0xc9),{'value':R,'configurable':!0x0});import{mapChatMessagesToStoredMessages as e,mapStoredMessagesToChatMessages as w}from'@langchain/core/messages';import{BaseGraph as H}from'../base-graph.js';function z(){const zh=['CMvSzwfZzvr1CM4','DhjPBq','DgHVDwDODfnPz25HDhvYzq','y3vYCMvUDe5Vzgu','ndaW','Dg9ju09tDhjPBMC','Bw9Uz29KyG','jYbJAgfUz2vKigjLzM9Yzsb0AgLZihr1CM4Gy291BgqGyMuGC2f2zwqU','C3rVCMviAxn0B3jPzxm','AgLZDg9YAwvZ','mtyXmtq0nhLWs1DLEq','q09ttu9eqL9jra','mZm2mJG5mMTtveTHDq','CMvZDg9YzuHPC3rVCMLLCW','zxjYB3i','Dg9Rzw5Z','CMvHza','ntK0nJHzwhrsu2u','lIbszxn0B3jLig9Yig1Pz3jHDguGAxqGyMvMB3jLihnHDMLUzY4','q09ttu9FrejFq0Xjru5ux1nfq1jfva','u1fmsvrfx0rcx1bbveG','zgf0yq','CMv2AxnPB24','q29ZBw9ZihnLC3nPB24GCgvYC2LZDgvUy2uGCMvXDwLYzxmGq09ttu9eqL9vuKWGyw5Kienpu01prejFs0vzlcbVCIbdt1nnt19ftKrqt0LovcWGqvPvuKvFvevoqu5ux0Lelcbdt1nnt19eqL9dteLftLrFsuqSigfUzcbdt1nnt19eqL9dteLftLrFu0vduKvulG','y29Kzq','AxnmAxzLu2vZC2LVBLr1CM4','jYbZy2HLBweGDMvYC2LVBIa','zxHWAxjLC0f0','jYbJAgfUz2vKigjLzM9YzsbPDhmGBwLNCMf0Aw9UignVDwXKigjLihnHDMvKlG','twvTB3j5u2vZC2LVBKrVy3vTzw50q29UDgfPBMvY','DgHVDwDODa','u2vZC2LVBIaN','DhLWzq','lI9JB3nTB3mTC2vZC2LVBI1KB2n1BwvUDc5JB250ywLUzxiUANm','C3fSAxrL','AxrLBxm','zNjVBuvUDhjPzxm','yxnZAwDU','u0vtu0LptL9dt05gteLdva','oYbLEhbLy3rLzca','y29TBwL0rxHWzwn0zwrszxzPC2LVBG','q09ttu9tx0nptLrbsu5fuG','zgvMAw5LuhjVCgvYDhK','C3rYAw5N','CMvKDwnL','BMfTzq','yxnZzxj0swq','jYbPCYbHBhjLywr5ihbYB2nLC3nPBMCGysb0DxjUlG','CgfYC2u','D2fYBMLUz3m','nte4nerotgHcBq','CMvZCg9UC2vFBwv0ywrHDge','CMvXDwLYzuzYzwvmzwfZzq','zxPNCMfWAeLUDgvYBMfS','zw50CMLLCW','CgXHy2vOB2XKzxjeB2n1BwvUDa','y29UzMXPy3q','q09ttu9tx1riuK9vr0Hqvvq','n29TvvLjwG','q09ttu9eqL9trvntsu9ox0Le','qgf6DxjLl2nVC21VCW','C2f2zvn0yxrL','Aw5JBhvKzxm','tu9or09eqL9vuKW','nw92sfz6uW','qgf6DxjLl2LKzw50Axr5','yxnZzxj0u2vZC2LVBKDYyxbOu2nOzw1H','DhvYBG','zxjYB3jZ','lI9KyxrHl3nLC3nPB25ZlNnXBgL0zq','z3jHCgHty2HLBwfwzxjZAw9U','ihDHCM5PBMCOCYKGD2vYzsbKCM9WCgvKlG','zgf0ywjHC2vZ','ywrKAxrPB25HBf9RD2fYz3m','C2vZC2LVBLr1CM5mzwfZzu1Z','y29UDgfPBMvY','nti5meD6twLVAa','ywXS','lcbUB3qG','C2nOzw1HvMvYC2LVBG','BgfUz2DYyxbO','u0vtu0LptL9cvvnz','yxbWzw5Ktg9NCW','AxnbCNjHEq','jYbSB3n0igL0CYbSzwfZzsbIzwzVCMuGBg9NCYb3zxjLigfWCgvUzgvKoYa','C2LNBMf0DxjLqMvHCMLUz0nVBNrLBNrcBg9JAW','CMvXDwLYzu93BMvY','BgXTq29UzMLN','yxnZzxj0u2vZC2LVBKDYyxbO','l2LK','Bw9KAwzPzwrbDa','DxnHz2vFBwv0ywrHDge','zNjVBunVBMzPzW','Aw52ywXPzf90B29Sx2nHBgXZ','u2vZC2LVBLr1CM5fCNjVCG','jYb1C2vZigDYyxbOicC','y29TCgXLDgvK','mtC4otKYA3HSq3bk','jYbIzwXVBMDZihrVigDYyxbOicC','BgvHC2vK','q2fUBM90ihbLCNnPC3qGC2vZC2LVBIbKB2n1BwvUDcb2zxjZAw9Uia','DMvYC2LVBG','CMvZDg9YzvnLC3nPB25eB2n1BwvUDa','DhvYBKXLyxnLtxm','AxnszwnVCMq','zg9JDw1LBNrZ','q09ttu9eqL9lrvK','zMLYC3q','yMvNAw5uDxjU','y3jLyxrLswzoB3rfEgLZDhm','y29ZBw9Z','nNPfDeHQwa','CMvWBgfJzuLUy29TCgf0AwjSzq','B3jPz2LUywXuzxH0q29UDgvUDejSB2nR','C2v0','Bw9KzwXnzxrHzgf0yq','y29ZBw9Zzgi','Dg9VBf9JywXSCW','q09ttu9FrejFq0Xjru5ux0Le','zxHWzwn0zwrszxzPC2LVBG','y29UDgv4Da','y29UBMvJDa','C2vZC2LVBNm','CMvHzerVy3vTzw50','nJaWmda','z2v0','Cgf0Ahm','tM90igzVDw5K','zgvJAxnPB25Z','z3jHCgHjza','BwfW','C3rHDhvZ','zgvSzxrLu2vZC2LVBG','B2jQzwn0','mZu4mtuYsvfetg9P','z2v0vgLTzq','DxbZzxj0','oteWmJKYBNjPz0fp','zgLZCg9Zzq','jY4GvxnLicDTzw1VCNKNlcaNC3fSAxrLjYWGj21VBMDVzgiNlcbVCIaNy29ZBw9ZjY4','z2v0u2vZC2LVBG','BM9Kzxm','qvPvuKvFvevoqu5ux0Le','CMvZDg9Yzvn0yxrL','u0vtu0LptL9uvvjox0Xfqvnfx01t','BgvUz3rO','y29TBwL0uhjLzgLJyxrL','C3rHDhvZq29Kzq','BM93','z3jHCgG','CMvTB3zLtgvNywn5vg9VBfrYywnLCW','Dgv4Da','tu9or09eqL9dt0Xmrunusu9o','B3DUzxi','q09ttu9FrejFsuq','Bwf0y2HLC1nLC3nPB25xCML0zvbYzwrPy2f0zq','zgvSzxrL','AxnoB3rgB3vUza','y29UzMLN','jY4Gu3rHCNqGysbUzxCGC2vZC2LVBIb0BYbYDw4GysbKAwzMzxjLBNqGz3jHCgGU','CgfYDgL0Aw9Us2v5','y29TCgfYzufUzfn3yxa','AxrLBq','y2XVC2u','zgvJAxnPB25vC2fNzq','y3jLyxrLzef0','C2vZC2LVBLjLDMLZAw9U','ywXSB3DpD25LCG','Aw5FChjVz3jLC3m','AM9PBG','AxngAw5PDgu','mtfnAKDzEgO','y29TCgfJDfn0B3jLze1LC3nHz2vZ','C2L6zq'];z=function(){return zh;};return z();}import{ConfigManager as u}from'../config-manager.js';import{GRAPH_END_NODE as Z}from'../graph-state.js';import{cloneJsonObject as o}from'../graph-context.js';import{GraphLlm as k}from'../graph-llm.config.js';import{replaceNodeStates as O}from'../node-state.js';import{createSessionLogs as D}from'../session-log.js';import{emptyTokenUsage as r,normalizeTokenUsage as M}from'../token-usage.js';import{assertGraphSchemaVersion as d}from'../stable-id.js';import{addDecisionUsage as s,emptyDecisionUsage as E,normalizeDecisionUsage as i}from'../decision/decision-types.js';const h=0x10,g=Pk(0xed),q=Pk(0xc2),Ce='SESSION_COMPLETED';class f extends Error{static{c(this,Pk(0xfa));}[Pk(0xb4)];constructor(l,R){const Pq=Pk;super(R),this[Pq(0xc9)]=Pq(0xfa),this[Pq(0xb4)]=l;}}class N{static{c(this,'SessionManager');}['container'];[Pk(0x103)];constructor(l=new V(),R=F()){const PO=Pk;this['container']=l,this[PO(0x103)]=R;}static async[Pk(0xf8)](P0=new u()){const z9={l:0x119,R:0x9d,a:0x12c,Y:0x119,m:0xdb,L:0xa2,A:0x110,n:0x106,t:0x12a,P0:0x112,P1:0x136,P2:0xa7,P3:0xec,P4:0xd7,P5:0xd8,P6:0xdd,P7:0xe4,P8:0x119,P9:0x11a,PP:0xbd},PQ=Pk,P1=P0[PQ(z9.l)]('SESSION_STORE','memory')[PQ(z9.R)]()['toLowerCase'](),P2=F(P0['get'](PQ(z9.a)));if(P1==='memory')return new N(new V(),P2);if(P1===PQ(0xbe)){const {SqliteSessionDocumentContainer:PF}=await import('./sqlite-session-document.container.js');return new N(new PF(P0[PQ(z9.Y)](PQ(0xb0),PQ(0xe1))),P2);}if(P1===PQ(0xa2)||P1==='mongo'){const PW=p(P0,PQ(z9.m)),PC=p(P0,'MONGODB_NAME'),PK=p(P0,PQ(0x134));if(!PW||!PC||!PK)throw new Error('MongoDB\x20session\x20persistence\x20requires\x20MONGODB_URL,\x20MONGODB_NAME,\x20and\x20MONGODB_COLLECTION.');const [{MongoClient:PH},{MongoDbSessionDocumentContainer:Pu}]=await Promise[PQ(0xe9)]([import(PQ(z9.L)),import('./mongodb-session-document.container.js')]),Px=new PH(PW);await Px[PQ(0x115)]();const PZ=Px['db'](PC)['collection'](PK);return await PZ['createIndex']({'id':0x1},{'unique':!0x0}),new N(new Pu(PZ,Px),P2);}if(P1!==PQ(0x10a)&&P1!==PQ(z9.A))throw new Error('Unsupported\x20SESSION_STORE\x20\x27'+P1+PQ(0x127));const P3=p(P0,'COSMO_ENDPOINT','COSMOS_ENDPOINT','COSMODB_URL'),P4=p(P0,PQ(z9.n),'COSMOS_KEY'),P5=p(P0,PQ(z9.t)),P6=p(P0,PQ(z9.P0)),P7=p(P0,PQ(0xaf)),P8=p(P0,PQ(z9.P1),'COSMOS_DATABASE',PQ(z9.P2))??PQ(z9.P3),P9=p(P0,'COSMO_DB_SESSION_CONTAINER_ID',PQ(0xc5),PQ(z9.P4))??PQ(0x116);if(!P3||!P4&&(!P5||!P6||!P7))throw new Error(PQ(0xb3));const [{CosmosClient:PP},{ClientSecretCredential:Pz}]=await Promise['all']([import(PQ(z9.P5)),import(PQ(z9.P6))]),PB=P4?new PP({'endpoint':P3,'key':P4}):new PP({'endpoint':P3,'aadCredentials':new Pz(P5,P6,P7)}),{database:Pb}=await PB[PQ(z9.P7)][PQ(0x109)]({'id':P8}),Pe=Number(P0[PQ(z9.P8)](PQ(0xd5),PQ(0xa0))),{container:PN}=await Pb['containers'][PQ(0x109)]({'id':P9,'partitionKey':{'paths':['/id']},...Number[PQ(0x98)](Pe)&&Pe>0x0?{'throughput':Pe}:{}}),{resource:Pw}=await PN[PQ(0xac)](),PX=Pw?.[PQ(0x13c)]?.[PQ(z9.P9)]??[];if(!PX[PQ(0xda)](PQ(0xf5)))throw new Error('Cosmos\x20container\x20\x27'+P9+'\x27\x20must\x20use\x20partition\x20key\x20/id;\x20found\x20'+(PX[PQ(0x145)](',\x20')||'none')+'.');const {CosmosSessionDocumentContainer:Py}=await import(PQ(z9.PP));return new N(new Py(PN,()=>PB[PQ(0x126)]()),P2);}async[Pk(0x128)](l){const zP={l:0x117,R:0x101},PD=Pk,R=await this[PD(zP.l)](l);return R?.[PD(zP.R)]===h?R:void 0x0;}async[Pk(0x117)](l){const zz={l:0xe7},Pj=Pk;try{const {resource:R}=await this[Pj(zz.l)][Pj(0x13e)](l,l)[Pj(0xac)]();return R;}catch(a){if(G(a))return;throw a;}}async[Pk(0x108)](R,Y,m){const zB={l:0xca,R:0x117,a:0x123,Y:0x103,m:0xa1,L:0x13d,A:0xcb,n:0xe7,t:0xd4,P0:0xff,P1:0xdf,P2:0xbb,P3:0xcb},Pr=Pk,L=H[Pr(zB.l)](m[Pr(0x11d)]),A=d(m[Pr(0xe2)]),P0=await this[Pr(zB.R)](R);P0&&P0[Pr(0x101)]===h&&T(P0,L);const P1=new Date(),P2={'owner':Y,'expiresAt':new Date(P1[Pr(zB.a)]()+this[Pr(zB.Y)])[Pr(0xa1)]()};if(!P0){const P4=this['placeholderDocument'](R,m,L,A,P2,P1[Pr(zB.m)]());if(await this['container'][Pr(zB.L)]({'expectedRevision':null},P4)==='conflict')throw new f(g,Pr(0xbb)+R+Pr(zB.A));return{'kind':Pr(0xff),'document':P4,'expectedRevision':P4['revision']};}if(P0[Pr(0x101)]!==h){const P5=this['placeholderDocument'](R,m,L,A,P2,P1['toISOString']());if(await this[Pr(zB.n)][Pr(0x13d)]({'expectedRevision':S(P0),'replaceIncompatible':!0x0},P5)===Pr(zB.t))throw new f(g,Pr(0xbb)+R+'\x27\x20is\x20already\x20processing\x20a\x20turn.');return{'kind':Pr(zB.P0),'document':P5,'expectedRevision':P5[Pr(0xb2)]};}if(K(P0[Pr(0xdf)])&&P0[Pr(zB.P1)]?.[Pr(0x135)]!==Y)throw new f(g,'Session\x20\x27'+R+Pr(zB.A));const P3={...P0,'revision':S(P0)+0x1,'turn':P2};if(await this['container']['compareAndSwap']({'expectedRevision':S(P0),'requireFreeLease':!0x0,'allowOwner':Y},P3)==='conflict')throw new f(g,Pr(zB.P2)+R+Pr(zB.P3));return{'kind':'leased','document':P3,'expectedRevision':S(P3)};}async[Pk(0x12b)](l,R){const PM=Pk,a=await this['getSession'](l);if(a)return this[PM(0x102)](a,R);}[Pk(0x102)](l,R){const ze={l:0x129,R:0x129,a:0xa5,Y:0x13a,m:0x114,L:0x11f,A:0xfc},PU=Pk,Y=H[PU(0xca)](R);T(l,Y);const {graph:m}=l;if(!m[PU(ze.l)])return;const L=O({},m[PU(ze.R)]),A=ae(m[PU(ze.a)]);return{'currentNode':m[PU(0x9f)],'config':m[PU(ze.Y)]??{},'context':o(m[PU(ze.m)]===void 0x0?{}:m['context']),'completed':l[PU(ze.L)]===PU(ze.A)||m[PU(0x9f)]===Z,'nodes':L,'tokens':M(l[PU(0xab)]),'decisionUsage':i(l['decisionUsage']),'histories':A,'inputConsumed':!0x0,'response':''};}async[Pk(0xd9)](R,Y,L,A=D(),P0={}){const zN={l:0xe2,R:0xa1,a:0x129,Y:0xfc,m:0x140,L:0xe0,A:0x11c,n:0x9f,t:0x114,P0:0x10f,P1:0x135,P2:0x13d,P3:0xd4,P4:0xbb,P5:0xcb},PJ=Pk,P1=H[PJ(0xca)](L[PJ(0x11d)]),P2=d(L[PJ(zN.l)]),P3=await this[PJ(0x117)](R),P4=P3?.[PJ(0x101)]===h?P3:void 0x0;P4&&(T(P4,P1),j(P4,P2));const P5=new Date()[PJ(zN.R)](),P6=oe(O({},Y[PJ(zN.a)])),{tokens:P7,histories:P8}=Y,P9=this[PJ(0xc4)](P3,P0),PP={'version':h,'id':R,'revision':P9===null?0x0:P9+0x1,'status':Y[PJ(zN.Y)]?'completed':'in_progress','tokens':M(P7),'decisionUsage':i(Y[PJ(zN.m)]),'errors':[...P4?.[PJ(0xe0)]??[],...A[PJ(zN.L)]],'warnings':[...P4?.[PJ(0xcd)]??[],...A[PJ(0xcd)]],'decisions':[...P4?.['decisions']??[],...A[PJ(zN.A)]],'graph':{'id':P1,'schemaVersion':P2,'currentNode':Y[PJ(zN.n)],'config':Y[PJ(0x13a)],'context':o(Y[PJ(zN.t)]===void 0x0?{}:Y[PJ(zN.t)]),'histories':se(P8),'model':k[PJ(zN.P0)](L[PJ(0xf3)]),'nodes':P6},...P0['keepTurn']&&P4?.[PJ(0xdf)]?{'turn':{'owner':P4[PJ(0xdf)][PJ(zN.P1)],'expiresAt':new Date(Date[PJ(0x130)]()+this[PJ(0x103)])[PJ(0xa1)]()}}:{},'createdAt':P4?.['createdAt']??P5,'modifiedAt':P5};if(await this['container'][PJ(zN.P2)](this[PJ(0x12e)](P3,P0,P9),PP)===PJ(zN.P3))throw new f(P0['owner']?q:g,P0[PJ(0x135)]?PJ(zN.P4)+R+PJ(0xa3):PJ(0xbb)+R+PJ(zN.P5));return PP;}async['appendLogs'](l,R,Y,L={}){const zw={l:0xe2,R:0x128,a:0x140,Y:0xe0,m:0x11c,L:0x9f,A:0x13a,n:0xa5,t:0x114,P0:0xf3,P1:0x131,P2:0x131,P3:0x141,P4:0x13d,P5:0x12e,P6:0x135,P7:0xbb,P8:0x12d},PT=Pk,A=H[PT(0xca)](Y[PT(0x11d)]),P0=d(Y[PT(zw.l)]),P1=await this[PT(zw.R)](l);P1&&(T(P1,A),j(P1,P0));const P2=new Date()['toISOString'](),P3=this[PT(0xc4)](P1,L),P4={'version':h,'id':l,'revision':P3===null?0x0:P3+0x1,'status':R[PT(0xe0)]['length']>0x0?PT(0xaa):P1?.['status']??'in_progress','tokens':P1?.[PT(0xab)]??r(),'decisionUsage':R[PT(0x11c)][PT(0xc8)]((P5,P6)=>s(P5,P6['usage']),i(P1?.[PT(zw.a)])),'errors':[...P1?.[PT(zw.Y)]??[],...R[PT(0xe0)]],'warnings':[...P1?.[PT(0xcd)]??[],...R[PT(0xcd)]],'decisions':[...P1?.[PT(zw.m)]??[],...R[PT(0x11c)]],'graph':{'id':A,'schemaVersion':P0,...P1?{'currentNode':P1['graph'][PT(zw.L)],'config':P1['graph'][PT(zw.A)]}:{},'histories':P1?.[PT(0x131)][PT(zw.n)]??{},'context':o(P1?.['graph'][PT(zw.t)]===void 0x0?{}:P1[PT(0x131)]['context']),'model':k['modelMetadata'](Y[PT(zw.P0)]),...P1?.[PT(zw.P1)][PT(0x129)]?{'nodes':P1[PT(zw.P2)][PT(0x129)]}:{}},'createdAt':P1?.[PT(zw.P3)]??P2,'modifiedAt':P2};if(await this['container'][PT(zw.P4)](this[PT(zw.P5)](P1,L,P3),P4)==='conflict'){if(L[PT(zw.P6)]){console['warn'](PT(zw.P7)+l+PT(0xf0)+R[PT(zw.Y)]['length']+'\x20error(s)\x20and\x20'+R['warnings'][PT(zw.P8)]+PT(0xe3));return;}throw new f(g,'Session\x20\x27'+l+PT(0xcb));}return P4;}async['endFailedTurn'](l,R,a,Y,m){const zX={l:0xe0,R:0xcd,a:0x9c},PS=Pk;if(Y&&(Y[PS(zX.l)][PS(0x12d)]>0x0||Y[PS(zX.R)][PS(0x12d)]>0x0||Y[PS(0x11c)][PS(0x12d)]>0x0)){await this[PS(0xee)](l,Y,a,{'owner':R,...m!==void 0x0?{'expectedRevision':m}:{}});return;}await this[PS(zX.a)](l,R,m);}async[Pk(0x9c)](l,R,Y){const zy={l:0x135,R:0x13d},Pd=Pk,m=await this['getSession'](l);if(!m||m['turn']?.[Pd(zy.l)]!==R)return;const L=Y??S(m),{turn:A,...P0}=m,P1={...P0,'modifiedAt':new Date()['toISOString']()};await this[Pd(0xe7)][Pd(zy.R)]({'expectedRevision':L,'requireOwner':R},P1);}async[Pk(0x120)](l){const zF={l:0xe7},PG=Pk;try{await this[PG(zF.l)][PG(0x13e)](l,l)[PG(0x138)]();}catch(R){if(!G(R))throw R;}}async['persistMigratedSession'](l,R={}){const zW={l:0x100,R:0xc3,a:0x131,Y:0xeb,m:0x128,L:0xdf,A:0x114,n:0x141,t:0x141,P0:0xbb,P1:0xb8},Pf=Pk;if(l['version']!==h)throw new Error(Pf(zW.l)+l[Pf(0x101)]+Pf(zW.R)+h+'.');H[Pf(0xca)](l[Pf(0x131)]['id']),d(l[Pf(zW.a)][Pf(zW.Y)]);const Y=await this[Pf(zW.m)](l['id']),m=R[Pf(0x113)]??S(Y||l),L=Y?.[Pf(0xdf)]??l[Pf(zW.L)],A={...l,'graph':{...l['graph'],'context':o(l[Pf(zW.a)][Pf(zW.A)]===void 0x0?{}:l['graph']['context'])},'revision':m,'createdAt':Y?.[Pf(zW.n)]??l[Pf(zW.t)],'modifiedAt':Y?.[Pf(0xf6)]??l[Pf(0xf6)],...L?{'turn':L}:{}};if(await this['container'][Pf(0x13d)]({'expectedRevision':m,...R[Pf(0x135)]?{'requireOwner':R[Pf(0x135)]}:{'requireFreeLease':!0x0}},A)===Pf(0xd4))throw new f(R[Pf(0x135)]?q:g,Pf(zW.P0)+l['id']+Pf(zW.P1));}async[Pk(0x13f)](){const Pp=Pk;await this['container'][Pp(0x13f)]?.();}[Pk(0xd3)](l,R,Y,m,L,A){const zK={l:0x144},Ps=Pk;return{'version':h,'id':l,'revision':0x0,'status':Ps(zK.l),'tokens':r(),'decisionUsage':E(),'errors':[],'warnings':[],'decisions':[],'graph':{'id':Y,'schemaVersion':m,'histories':{},'context':{},'model':k[Ps(0x10f)](R[Ps(0xf3)])},'turn':L,'createdAt':A,'modifiedAt':A};}['commitExpectedRevision'](l,R){const zH={l:0x113},PV=Pk;return R[PV(zH.l)]!==void 0x0?R[PV(zH.l)]:l?S(l):null;}[Pk(0x12e)](l,R,a){const zu={l:0x135,R:0x101},PE=Pk;return R[PE(zu.l)]?{'expectedRevision':a,'requireOwner':R['owner']}:l&&l[PE(zu.R)]!==h?{'expectedRevision':a,'replaceIncompatible':!0x0}:{'expectedRevision':a,'requireFreeLease':!0x0};}}function p(l,...R){const Ph=Pk;for(const a of R){const Y=l[Ph(0x119)](a);if(Y)return Y;}}c(p,Pk(0x107));function T(l,R){const zZ={l:0x131,R:0xbb,a:0xfe,Y:0x13b},Pi=Pk;if(l[Pi(zZ.l)]['id']!==R)throw new Error(Pi(zZ.R)+l['id']+Pi(zZ.a)+l['graph']['id']+'\x27,\x20not\x20\x27'+R+Pi(zZ.Y));}c(T,Pk(0xf4));function j(l,R){const zo={l:0x131,R:0xeb,a:0xfb,Y:0xb6,m:0x131,L:0xeb,A:0xea,n:0xae},Pc=Pk;if(l[Pc(zo.l)][Pc(zo.R)]!==R)throw new Error('Session\x20\x27'+l['id']+Pc(zo.a)+l['graph']['id']+Pc(zo.Y)+l[Pc(zo.m)][Pc(zo.L)]+Pc(zo.A)+R+Pc(zo.n));}c(j,Pk(0xde));function oe(l){const zq={l:0x11e},zk={l:0x121},Pl=Pk;return Object[Pl(0xc0)](Object[Pl(0xd2)](l)[Pl(zq.l)](([R,a])=>{const PR=Pl;if(!a||typeof a!=PR(zk.l))return[R,a];const {toolTrace:Y,...m}=a;return[R,m];}));}c(oe,Pk(0x132));function ie(l){const zO={l:0xef,R:0x12d,a:0xe5,Y:0xd1,m:0xcf,L:0xf7,A:0x111,n:0x12d,t:0xf9,P0:0x12d,P1:0xf9};return l['map'](R=>{const PI=B,a={...R[PI(0xb1)]},Y=R['type']==='ai'&&Array[PI(zO.l)](a[PI(0x111)])&&a[PI(0x111)][PI(zO.R)]>0x0?ce(a[PI(0xe5)]):void 0x0,m=b(a[PI(zO.a)])&&a[PI(0xe5)][PI(zO.Y)]===!0x0;return delete a[PI(0xe5)],(Y||m)&&(a['additional_kwargs']={...Y?{'originalTextContentBlock':Y}:{},...m?{'ezgraphInternal':!0x0}:{}}),delete a[PI(zO.m)],delete a[PI(zO.L)],R[PI(0xbc)]==='ai'&&(Array[PI(0xef)](a[PI(zO.A)])&&a[PI(0x111)][PI(zO.n)]===0x0&&delete a[PI(zO.A)],Array['isArray'](a[PI(zO.t)])&&a[PI(0xf9)][PI(zO.P0)]===0x0&&delete a[PI(zO.P1)]),{...R,'data':a};});}c(ie,Pk(0x9a));function se(l){const zD={l:0xd2,R:0x11e},Pa=Pk;return Object[Pa(0xc0)](Object[Pa(zD.l)](l)[Pa(zD.R)](([R,a])=>[R,ie(e(a))]));}c(se,Pk(0xa4));function ae(l={}){const zj={l:0xc0},Pg=Pk;return Object[Pg(zj.l)](Object[Pg(0xd2)](l)[Pg(0x11e)](([R,a])=>[R,w(a)]));}c(ae,Pk(0xa9));function ce(l){const zr={l:0x9e,R:0x133,a:0x9e},PY=Pk;if(!b(l))return;const R=l[PY(0x10d)];if(!(!b(R)||typeof R[PY(zr.l)]!=PY(0xc7)))return{...typeof R[PY(zr.R)]==PY(0xc7)?{'text':R['text']}:{},'thoughtSignature':R[PY(zr.a)],...R[PY(0xba)]===!0x0?{'thought':!0x0}:{}};}c(ce,Pk(0xf1));function b(l){const Pv=Pk;return l!==null&&typeof l==Pv(0x121)&&!Array['isArray'](l);}c(b,Pk(0x104));class V{static{c(this,Pk(0xb9));}[Pk(0x105)]=new Map();get[Pk(0x9b)](){const Pm=Pk;return this[Pm(0x105)][Pm(0x9b)];}[Pk(0xbf)]={'upsert':c(async e=>{const zJ={l:0x105},PL=Pk,t=e;return this[PL(zJ.l)]['set'](t['id'],structuredClone(t)),{};},Pk(0x124))};async[Pk(0x13d)](l,R){const zT={l:0x105},PA=Pk,a=this[PA(zT.l)][PA(0x119)](R['id']);return de(a,l)?(this['documents'][PA(0x10e)](R['id'],structuredClone(R)),'ok'):'conflict';}[Pk(0x13e)](l,R){const zd={l:0x119,R:0xc1,a:0x11b},zS={l:0x105},z0=Pk;return{'read':c(async()=>{const Pn=B,a=this[Pn(zS.l)][Pn(0x119)](l);if(!a||a['id']!==R)throw Object[Pn(0xc1)](new Error('Not\x20found'),{'code':0x194});return{'resource':structuredClone(a)};},'read'),'delete':c(async()=>{const Pt=B,a=this[Pt(0x105)][Pt(zd.l)](l);if(!a||a['id']!==R)throw Object[Pt(zd.R)](new Error(Pt(zd.a)),{'code':0x194});return this[Pt(0x105)]['delete'](l),{};},z0(0x138))};}}function G(l){const z1=Pk;if(!l||typeof l!=z1(0x121))return!0x1;const R=l;return R[z1(0xb4)]===0x194||R[z1(0x12f)]===0x194;}c(G,Pk(0x139));function F(l=process.env.SESSION_TURN_LEASE_MS){const zp={l:0x118},z2=Pk,R=Number(l??z2(zp.l));return Number[z2(0x98)](R)&&R>0x0?R:0xea60;}function B(P,b){P=P-0x98;const e=z();let N=e[P];if(B['zZPXch']===undefined){var w=function(W){const C='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let K='',H='';for(let u=0x0,x,Z,o=0x0;Z=W['charAt'](o++);~Z&&(x=u%0x4?x*0x40+Z:Z,u++%0x4)?K+=String['fromCharCode'](0xff&x>>(-0x2*u&0x6)):0x0){Z=C['indexOf'](Z);}for(let q=0x0,O=K['length'];q<O;q++){H+='%'+('00'+K['charCodeAt'](q)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(H);};B['quHhSI']=w,B['AkYZlF']={},B['zZPXch']=!![];}const X=e[0x0],y=P+X,F=B['AkYZlF'][y];return!F?(N=B['quHhSI'](N),B['AkYZlF'][y]=N):N=F,N;}c(F,Pk(0xe6));function S(l){const zs={l:0xb2},z3=Pk;return l?.[z3(zs.l)]??0x0;}c(S,Pk(0x142));function K(l,R=Date['now']()){const zV={l:0x135,R:0xcc,a:0xb7},z4=Pk;if(!l?.[z4(zV.l)]||!l[z4(0xb7)])return!0x1;const a=Date[z4(zV.R)](l[z4(zV.a)]);return Number['isFinite'](a)&&a>R;}c(K,Pk(0xb5));function de(l,R,a=Date[Pk(0x130)]()){const zE={l:0x113,R:0xdf,a:0xf2,Y:0xd0},z5=Pk;return R[z5(0x10c)]?l!==void 0x0&&l['version']!==h:R[z5(zE.l)]===null?l===void 0x0:!(!l||S(l)!==R[z5(0x113)]||R['requireOwner']&&l[z5(zE.R)]?.[z5(0x135)]!==R[z5(zE.a)]||R[z5(zE.Y)]&&K(l[z5(0xdf)],a)&&l['turn']?.[z5(0x135)]!==R[z5(0x143)]);}c(de,Pk(0x137));export{V as MemorySessionDocumentContainer,g as SESSION_BUSY,Ce as SESSION_COMPLETED,q as SESSION_CONFLICT,h as SESSION_DOCUMENT_VERSION,N as SessionManager,f as SessionTurnError,K as isLiveSessionTurn,de as matchesSessionWritePredicate,S as sessionRevision,F as sessionTurnLeaseMs};
1
+ const lC=e;(function(O,t){const h6={O:0xad,t:0xfd,d:0x125,k:0xa6,a:0xce,z:0xe8},lZ=e,d=O();while(!![]){try{const k=-parseInt(lZ(h6.O))/0x1*(-parseInt(lZ(0x10b))/0x2)+-parseInt(lZ(h6.t))/0x3+-parseInt(lZ(h6.d))/0x4*(parseInt(lZ(0xdc))/0x5)+-parseInt(lZ(h6.k))/0x6*(parseInt(lZ(0xd6))/0x7)+-parseInt(lZ(0x122))/0x8+parseInt(lZ(h6.a))/0x9*(parseInt(lZ(h6.z))/0xa)+parseInt(lZ(0x99))/0xb*(parseInt(lZ(0xa8))/0xc);if(k===t)break;else d['push'](d['shift']());}catch(a){d['push'](d['shift']());}}}(l,0x27bd1));var J=Object[lC(0xc6)],c=(O,t)=>J(O,lC(0xc9),{'value':t,'configurable':!0x0});import{mapChatMessagesToStoredMessages as r,mapStoredMessagesToChatMessages as s}from'@langchain/core/messages';import{BaseGraph as E}from'../base-graph.js';function l(){const ha=['CMvSzwfZzvr1CM4','DhjPBq','DgHVDwDODfnPz25HDhvYzq','y3vYCMvUDe5Vzgu','ndaW','Dg9ju09tDhjPBMC','Bw9Uz29KyG','jYbJAgfUz2vKigjLzM9Yzsb0AgLZihr1CM4Gy291BgqGyMuGC2f2zwqU','C3rVCMviAxn0B3jPzxm','AgLZDg9YAwvZ','mtyXmtq0nhLWs1DLEq','q09ttu9eqL9jra','mZm2mJG5mMTtveTHDq','CMvZDg9YzuHPC3rVCMLLCW','zxjYB3i','Dg9Rzw5Z','CMvHza','ntK0nJHzwhrsu2u','lIbszxn0B3jLig9Yig1Pz3jHDguGAxqGyMvMB3jLihnHDMLUzY4','q09ttu9FrejFq0Xjru5ux1nfq1jfva','u1fmsvrfx0rcx1bbveG','zgf0yq','CMv2AxnPB24','q29ZBw9ZihnLC3nPB24GCgvYC2LZDgvUy2uGCMvXDwLYzxmGq09ttu9eqL9vuKWGyw5Kienpu01prejFs0vzlcbVCIbdt1nnt19ftKrqt0LovcWGqvPvuKvFvevoqu5ux0Lelcbdt1nnt19eqL9dteLftLrFsuqSigfUzcbdt1nnt19eqL9dteLftLrFu0vduKvulG','y29Kzq','AxnmAxzLu2vZC2LVBLr1CM4','jYbZy2HLBweGDMvYC2LVBIa','zxHWAxjLC0f0','jYbJAgfUz2vKigjLzM9YzsbPDhmGBwLNCMf0Aw9UignVDwXKigjLihnHDMvKlG','twvTB3j5u2vZC2LVBKrVy3vTzw50q29UDgfPBMvY','DgHVDwDODa','u2vZC2LVBIaN','DhLWzq','lI9JB3nTB3mTC2vZC2LVBI1KB2n1BwvUDc5JB250ywLUzxiUANm','C3fSAxrL','AxrLBxm','zNjVBuvUDhjPzxm','yxnZAwDU','u0vtu0LptL9dt05gteLdva','oYbLEhbLy3rLzca','y29TBwL0rxHWzwn0zwrszxzPC2LVBG','q09ttu9tx0nptLrbsu5fuG','zgvMAw5LuhjVCgvYDhK','C3rYAw5N','CMvKDwnL','BMfTzq','yxnZzxj0swq','jYbPCYbHBhjLywr5ihbYB2nLC3nPBMCGysb0DxjUlG','CgfYC2u','D2fYBMLUz3m','nte4nerotgHcBq','CMvZCg9UC2vFBwv0ywrHDge','CMvXDwLYzuzYzwvmzwfZzq','zxPNCMfWAeLUDgvYBMfS','zw50CMLLCW','CgXHy2vOB2XKzxjeB2n1BwvUDa','y29UzMXPy3q','q09ttu9tx1riuK9vr0Hqvvq','n29TvvLjwG','q09ttu9eqL9trvntsu9ox0Le','qgf6DxjLl2nVC21VCW','C2f2zvn0yxrL','Aw5JBhvKzxm','tu9or09eqL9vuKW','nw92sfz6uW','qgf6DxjLl2LKzw50Axr5','yxnZzxj0u2vZC2LVBKDYyxbOu2nOzw1H','DhvYBG','zxjYB3jZ','lI9KyxrHl3nLC3nPB25ZlNnXBgL0zq','z3jHCgHty2HLBwfwzxjZAw9U','ihDHCM5PBMCOCYKGD2vYzsbKCM9WCgvKlG','zgf0ywjHC2vZ','ywrKAxrPB25HBf9RD2fYz3m','C2vZC2LVBLr1CM5mzwfZzu1Z','y29UDgfPBMvY','nti5meD6twLVAa','ywXS','lcbUB3qG','C2nOzw1HvMvYC2LVBG','BgfUz2DYyxbO','u0vtu0LptL9cvvnz','yxbWzw5Ktg9NCW','AxnbCNjHEq','jYbSB3n0igL0CYbSzwfZzsbIzwzVCMuGBg9NCYb3zxjLigfWCgvUzgvKoYa','C2LNBMf0DxjLqMvHCMLUz0nVBNrLBNrcBg9JAW','CMvXDwLYzu93BMvY','BgXTq29UzMLN','yxnZzxj0u2vZC2LVBKDYyxbO','l2LK','Bw9KAwzPzwrbDa','DxnHz2vFBwv0ywrHDge','zNjVBunVBMzPzW','Aw52ywXPzf90B29Sx2nHBgXZ','u2vZC2LVBLr1CM5fCNjVCG','jYb1C2vZigDYyxbOicC','y29TCgXLDgvK','mtC4otKYA3HSq3bk','jYbIzwXVBMDZihrVigDYyxbOicC','BgvHC2vK','q2fUBM90ihbLCNnPC3qGC2vZC2LVBIbKB2n1BwvUDcb2zxjZAw9Uia','DMvYC2LVBG','CMvZDg9YzvnLC3nPB25eB2n1BwvUDa','DhvYBKXLyxnLtxm','AxnszwnVCMq','zg9JDw1LBNrZ','q09ttu9eqL9lrvK','zMLYC3q','yMvNAw5uDxjU','y3jLyxrLswzoB3rfEgLZDhm','y29ZBw9Z','nNPfDeHQwa','CMvWBgfJzuLUy29TCgf0AwjSzq','B3jPz2LUywXuzxH0q29UDgvUDejSB2nR','C2v0','Bw9KzwXnzxrHzgf0yq','y29ZBw9Zzgi','Dg9VBf9JywXSCW','q09ttu9FrejFq0Xjru5ux0Le','zxHWzwn0zwrszxzPC2LVBG','y29UDgv4Da','y29UBMvJDa','C2vZC2LVBNm','CMvHzerVy3vTzw50','nJaWmda','z2v0','Cgf0Ahm','tM90igzVDw5K','zgvJAxnPB25Z','z3jHCgHjza','BwfW','C3rHDhvZ','zgvSzxrLu2vZC2LVBG','B2jQzwn0','mZu4mtuYsvfetg9P','z2v0vgLTzq','DxbZzxj0','oteWmJKYBNjPz0fp','zgLZCg9Zzq','jY4GvxnLicDTzw1VCNKNlcaNC3fSAxrLjYWGj21VBMDVzgiNlcbVCIaNy29ZBw9ZjY4','z2v0u2vZC2LVBG','BM9Kzxm','qvPvuKvFvevoqu5ux0Le','CMvZDg9Yzvn0yxrL','u0vtu0LptL9uvvjox0Xfqvnfx01t','BgvUz3rO','y29TBwL0uhjLzgLJyxrL','C3rHDhvZq29Kzq','BM93','z3jHCgG','CMvTB3zLtgvNywn5vg9VBfrYywnLCW','Dgv4Da','tu9or09eqL9dt0Xmrunusu9o','B3DUzxi','q09ttu9FrejFsuq','Bwf0y2HLC1nLC3nPB25xCML0zvbYzwrPy2f0zq','zgvSzxrL','AxnoB3rgB3vUza','y29UzMLN','jY4Gu3rHCNqGysbUzxCGC2vZC2LVBIb0BYbYDw4GysbKAwzMzxjLBNqGz3jHCgGU','CgfYDgL0Aw9Us2v5','y29TCgfYzufUzfn3yxa','AxrLBq','y2XVC2u','zgvJAxnPB25vC2fNzq','y3jLyxrLzef0','C2vZC2LVBLjLDMLZAw9U','ywXSB3DpD25LCG','Aw5FChjVz3jLC3m','AM9PBG','AxngAw5PDgu','mtfnAKDzEgO','y29TCgfJDfn0B3jLze1LC3nHz2vZ','C2L6zq'];l=function(){return ha;};return l();}import{ConfigManager as D}from'../config-manager.js';import{GRAPH_END_NODE as A}from'../graph-state.js';import{cloneJsonObject as H}from'../graph-context.js';import{GraphLlm as m}from'../graph-llm.config.js';import{replaceNodeStates as w}from'../node-state.js';import{createSessionLogs as Z}from'../session-log.js';import{emptyTokenUsage as o,normalizeTokenUsage as L}from'../token-usage.js';import{assertGraphSchemaVersion as n}from'../stable-id.js';import{addDecisionUsage as R,emptyDecisionUsage as u,normalizeDecisionUsage as i}from'../decision/decision-types.js';const h=0x10,g=lC(0xed),q=lC(0xc2),Ce='SESSION_COMPLETED';class f extends Error{static{c(this,lC(0xfa));}[lC(0xb4)];constructor(O,d){const lo=lC;super(d),this[lo(0xc9)]=lo(0xfa),this[lo(0xb4)]=O;}}class N{static{c(this,'SessionManager');}['container'];[lC(0x103)];constructor(O=new V(),d=F()){const lL=lC;this['container']=O,this[lL(0x103)]=d;}static async[lC(0xf8)](l0=new D()){const h9={O:0x119,t:0x9d,d:0x12c,k:0x119,a:0xdb,z:0xa2,Y:0x110,B:0x106,M:0x12a,l0:0x112,l1:0x136,l2:0xa7,l3:0xec,l4:0xd7,l5:0xd8,l6:0xdd,l7:0xe4,l8:0x119,l9:0x11a,ll:0xbd},lq=lC,l1=l0[lq(h9.O)]('SESSION_STORE','memory')[lq(h9.t)]()['toLowerCase'](),l2=F(l0['get'](lq(h9.d)));if(l1==='memory')return new N(new V(),l2);if(l1===lq(0xbe)){const {SqliteSessionDocumentContainer:ls}=await import('./sqlite-session-document.container.js');return new N(new ls(l0[lq(h9.k)](lq(0xb0),lq(0xe1))),l2);}if(l1===lq(0xa2)||l1==='mongo'){const lE=p(l0,lq(h9.a)),lD=p(l0,'MONGODB_NAME'),lA=p(l0,lq(0x134));if(!lE||!lD||!lA)throw new Error('MongoDB\x20session\x20persistence\x20requires\x20MONGODB_URL,\x20MONGODB_NAME,\x20and\x20MONGODB_COLLECTION.');const [{MongoClient:lj},{MongoDbSessionDocumentContainer:lH}]=await Promise[lq(0xe9)]([import(lq(h9.z)),import('./mongodb-session-document.container.js')]),lm=new lj(lE);await lm[lq(0x115)]();const lw=lm['db'](lD)['collection'](lA);return await lw['createIndex']({'id':0x1},{'unique':!0x0}),new N(new lH(lw,lm),l2);}if(l1!==lq(0x10a)&&l1!==lq(h9.Y))throw new Error('Unsupported\x20SESSION_STORE\x20\x27'+l1+lq(0x127));const l3=p(l0,'COSMO_ENDPOINT','COSMOS_ENDPOINT','COSMODB_URL'),l4=p(l0,lq(h9.B),'COSMOS_KEY'),l5=p(l0,lq(h9.M)),l6=p(l0,lq(h9.l0)),l7=p(l0,lq(0xaf)),l8=p(l0,lq(h9.l1),'COSMOS_DATABASE',lq(h9.l2))??lq(h9.l3),l9=p(l0,'COSMO_DB_SESSION_CONTAINER_ID',lq(0xc5),lq(h9.l4))??lq(0x116);if(!l3||!l4&&(!l5||!l6||!l7))throw new Error(lq(0xb3));const [{CosmosClient:ll},{ClientSecretCredential:lh}]=await Promise['all']([import(lq(h9.l5)),import(lq(h9.l6))]),lc=l4?new ll({'endpoint':l3,'key':l4}):new ll({'endpoint':l3,'aadCredentials':new lh(l5,l6,l7)}),{database:le}=await lc[lq(h9.l7)][lq(0x109)]({'id':l8}),lr=Number(l0[lq(h9.l8)](lq(0xd5),lq(0xa0))),{container:lQ}=await le['containers'][lq(0x109)]({'id':l9,'partitionKey':{'paths':['/id']},...Number[lq(0x98)](lr)&&lr>0x0?{'throughput':lr}:{}}),{resource:lv}=await lQ[lq(0xac)](),lG=lv?.[lq(0x13c)]?.[lq(h9.l9)]??[];if(!lG[lq(0xda)](lq(0xf5)))throw new Error('Cosmos\x20container\x20\x27'+l9+'\x27\x20must\x20use\x20partition\x20key\x20/id;\x20found\x20'+(lG[lq(0x145)](',\x20')||'none')+'.');const {CosmosSessionDocumentContainer:lI}=await import(lq(h9.ll));return new N(new lI(lQ,()=>lc[lq(0x126)]()),l2);}async[lC(0x128)](O){const hl={O:0x117,t:0x101},lb=lC,d=await this[lb(hl.O)](O);return d?.[lb(hl.t)]===h?d:void 0x0;}async[lC(0x117)](O){const hh={O:0xe7},ln=lC;try{const {resource:d}=await this[ln(hh.O)][ln(0x13e)](O,O)[ln(0xac)]();return d;}catch(k){if(G(k))return;throw k;}}async[lC(0x108)](O,k,z){const hc={O:0xca,t:0x117,d:0x123,k:0x103,a:0xa1,z:0x13d,Y:0xcb,B:0xe7,M:0xd4,l0:0xff,l1:0xdf,l2:0xbb,l3:0xcb},lR=lC,Y=E[lR(hc.O)](z[lR(0x11d)]),B=n(z[lR(0xe2)]),M=await this[lR(hc.t)](O);M&&M[lR(0x101)]===h&&T(M,Y);const l0=new Date(),l1={'owner':k,'expiresAt':new Date(l0[lR(hc.d)]()+this[lR(hc.k)])[lR(0xa1)]()};if(!M){const l3=this['placeholderDocument'](O,z,Y,B,l1,l0[lR(hc.a)]());if(await this['container'][lR(hc.z)]({'expectedRevision':null},l3)==='conflict')throw new f(g,lR(0xbb)+O+lR(hc.Y));return{'kind':lR(0xff),'document':l3,'expectedRevision':l3['revision']};}if(M[lR(0x101)]!==h){const l4=this['placeholderDocument'](O,z,Y,B,l1,l0['toISOString']());if(await this[lR(hc.B)][lR(0x13d)]({'expectedRevision':S(M),'replaceIncompatible':!0x0},l4)===lR(hc.M))throw new f(g,lR(0xbb)+O+'\x27\x20is\x20already\x20processing\x20a\x20turn.');return{'kind':lR(hc.l0),'document':l4,'expectedRevision':l4[lR(0xb2)]};}if(K(M[lR(0xdf)])&&M[lR(hc.l1)]?.[lR(0x135)]!==k)throw new f(g,'Session\x20\x27'+O+lR(hc.Y));const l2={...M,'revision':S(M)+0x1,'turn':l1};if(await this['container']['compareAndSwap']({'expectedRevision':S(M),'requireFreeLease':!0x0,'allowOwner':k},l2)==='conflict')throw new f(g,lR(hc.l2)+O+lR(hc.l3));return{'kind':'leased','document':l2,'expectedRevision':S(l2)};}async[lC(0x12b)](O,d){const lf=lC,k=await this['getSession'](O);if(k)return this[lf(0x102)](k,d);}[lC(0x102)](O,d){const hr={O:0x129,t:0x129,d:0xa5,k:0x13a,a:0x114,z:0x11f,Y:0xfc},lu=lC,k=E[lu(0xca)](d);T(O,k);const {graph:z}=O;if(!z[lu(hr.O)])return;const Y=w({},z[lu(hr.t)]),B=ae(z[lu(hr.d)]);return{'currentNode':z[lu(0x9f)],'config':z[lu(hr.k)]??{},'context':H(z[lu(hr.a)]===void 0x0?{}:z['context']),'completed':O[lu(hr.z)]===lu(hr.Y)||z[lu(0x9f)]===A,'nodes':Y,'tokens':L(O[lu(0xab)]),'decisionUsage':i(O['decisionUsage']),'histories':B,'inputConsumed':!0x0,'response':''};}async[lC(0xd9)](k,z,Y,B=Z(),M={}){const hQ={O:0xe2,t:0xa1,d:0x129,k:0xfc,a:0x140,z:0xe0,Y:0x11c,B:0x9f,M:0x114,l0:0x10f,l1:0x135,l2:0x13d,l3:0xd4,l4:0xbb,l5:0xcb},lJ=lC,l0=E[lJ(0xca)](Y[lJ(0x11d)]),l1=n(Y[lJ(hQ.O)]),l2=await this[lJ(0x117)](k),l3=l2?.[lJ(0x101)]===h?l2:void 0x0;l3&&(T(l3,l0),j(l3,l1));const l4=new Date()[lJ(hQ.t)](),l5=oe(w({},z[lJ(hQ.d)])),{tokens:l6,histories:l7}=z,l8=this[lJ(0xc4)](l2,M),l9={'version':h,'id':k,'revision':l8===null?0x0:l8+0x1,'status':z[lJ(hQ.k)]?'completed':'in_progress','tokens':L(l6),'decisionUsage':i(z[lJ(hQ.a)]),'errors':[...l3?.[lJ(0xe0)]??[],...B[lJ(hQ.z)]],'warnings':[...l3?.[lJ(0xcd)]??[],...B[lJ(0xcd)]],'decisions':[...l3?.['decisions']??[],...B[lJ(hQ.Y)]],'graph':{'id':l0,'schemaVersion':l1,'currentNode':z[lJ(hQ.B)],'config':z[lJ(0x13a)],'context':H(z[lJ(hQ.M)]===void 0x0?{}:z[lJ(hQ.M)]),'histories':se(l7),'model':m[lJ(hQ.l0)](Y[lJ(0xf3)]),'nodes':l5},...M['keepTurn']&&l3?.[lJ(0xdf)]?{'turn':{'owner':l3[lJ(0xdf)][lJ(hQ.l1)],'expiresAt':new Date(Date[lJ(0x130)]()+this[lJ(0x103)])[lJ(0xa1)]()}}:{},'createdAt':l3?.['createdAt']??l4,'modifiedAt':l4};if(await this['container'][lJ(hQ.l2)](this[lJ(0x12e)](l2,M,l8),l9)===lJ(hQ.l3))throw new f(M['owner']?q:g,M[lJ(0x135)]?lJ(hQ.l4)+k+lJ(0xa3):lJ(0xbb)+k+lJ(hQ.l5));return l9;}async['appendLogs'](O,k,z,Y={}){const hv={O:0xe2,t:0x128,d:0x140,k:0xe0,a:0x11c,z:0x9f,Y:0x13a,B:0xa5,M:0x114,l0:0xf3,l1:0x131,l2:0x131,l3:0x141,l4:0x13d,l5:0x12e,l6:0x135,l7:0xbb,l8:0x12d},lg=lC,B=E[lg(0xca)](z[lg(0x11d)]),M=n(z[lg(hv.O)]),l0=await this[lg(hv.t)](O);l0&&(T(l0,B),j(l0,M));const l1=new Date()['toISOString'](),l2=this[lg(0xc4)](l0,Y),l3={'version':h,'id':O,'revision':l2===null?0x0:l2+0x1,'status':k[lg(0xe0)]['length']>0x0?lg(0xaa):l0?.['status']??'in_progress','tokens':l0?.[lg(0xab)]??o(),'decisionUsage':k[lg(0x11c)][lg(0xc8)]((l4,l5)=>R(l4,l5['usage']),i(l0?.[lg(hv.d)])),'errors':[...l0?.[lg(hv.k)]??[],...k[lg(0xe0)]],'warnings':[...l0?.[lg(0xcd)]??[],...k[lg(0xcd)]],'decisions':[...l0?.[lg(hv.a)]??[],...k[lg(0x11c)]],'graph':{'id':B,'schemaVersion':M,...l0?{'currentNode':l0['graph'][lg(hv.z)],'config':l0['graph'][lg(hv.Y)]}:{},'histories':l0?.[lg(0x131)][lg(hv.B)]??{},'context':H(l0?.['graph'][lg(hv.M)]===void 0x0?{}:l0[lg(0x131)]['context']),'model':m['modelMetadata'](z[lg(hv.l0)]),...l0?.[lg(hv.l1)][lg(0x129)]?{'nodes':l0[lg(hv.l2)][lg(0x129)]}:{}},'createdAt':l0?.[lg(hv.l3)]??l1,'modifiedAt':l1};if(await this['container'][lg(hv.l4)](this[lg(hv.l5)](l0,Y,l2),l3)==='conflict'){if(Y[lg(hv.l6)]){console['warn'](lg(hv.l7)+O+lg(0xf0)+k[lg(hv.k)]['length']+'\x20error(s)\x20and\x20'+k['warnings'][lg(hv.l8)]+lg(0xe3));return;}throw new f(g,'Session\x20\x27'+O+lg(0xcb));}return l3;}async['endFailedTurn'](O,d,k,a,z){const hG={O:0xe0,t:0xcd,d:0x9c},lN=lC;if(a&&(a[lN(hG.O)][lN(0x12d)]>0x0||a[lN(hG.t)][lN(0x12d)]>0x0||a[lN(0x11c)][lN(0x12d)]>0x0)){await this[lN(0xee)](O,a,k,{'owner':d,...z!==void 0x0?{'expectedRevision':z}:{}});return;}await this[lN(hG.d)](O,d,z);}async[lC(0x9c)](O,d,k){const hI={O:0x135,t:0x13d},lx=lC,z=await this['getSession'](O);if(!z||z['turn']?.[lx(hI.O)]!==d)return;const Y=k??S(z),{turn:B,...M}=z,l0={...M,'modifiedAt':new Date()['toISOString']()};await this[lx(0xe7)][lx(hI.t)]({'expectedRevision':Y,'requireOwner':d},l0);}async[lC(0x120)](O){const hs={O:0xe7},li=lC;try{await this[li(hs.O)][li(0x13e)](O,O)[li(0x138)]();}catch(d){if(!G(d))throw d;}}async['persistMigratedSession'](O,d={}){const hE={O:0x100,t:0xc3,d:0x131,k:0xeb,a:0x128,z:0xdf,Y:0x114,B:0x141,M:0x141,l0:0xbb,l1:0xb8},lO=lC;if(O['version']!==h)throw new Error(lO(hE.O)+O[lO(0x101)]+lO(hE.t)+h+'.');E[lO(0xca)](O[lO(0x131)]['id']),n(O[lO(hE.d)][lO(hE.k)]);const k=await this[lO(hE.a)](O['id']),z=d[lO(0x113)]??S(k||O),Y=k?.[lO(0xdf)]??O[lO(hE.z)],B={...O,'graph':{...O['graph'],'context':H(O[lO(hE.d)][lO(hE.Y)]===void 0x0?{}:O['graph']['context'])},'revision':z,'createdAt':k?.[lO(hE.B)]??O[lO(hE.M)],'modifiedAt':k?.[lO(0xf6)]??O[lO(0xf6)],...Y?{'turn':Y}:{}};if(await this['container'][lO(0x13d)]({'expectedRevision':z,...d[lO(0x135)]?{'requireOwner':d[lO(0x135)]}:{'requireFreeLease':!0x0}},B)===lO(0xd4))throw new f(d[lO(0x135)]?q:g,lO(hE.l0)+O['id']+lO(hE.l1));}async[lC(0x13f)](){const lV=lC;await this['container'][lV(0x13f)]?.();}[lC(0xd3)](O,d,k,z,Y,B){const hA={O:0x144},lt=lC;return{'version':h,'id':O,'revision':0x0,'status':lt(hA.O),'tokens':o(),'decisionUsage':u(),'errors':[],'warnings':[],'decisions':[],'graph':{'id':k,'schemaVersion':z,'histories':{},'context':{},'model':m[lt(0x10f)](d[lt(0xf3)])},'turn':Y,'createdAt':B,'modifiedAt':B};}['commitExpectedRevision'](O,d){const hj={O:0x113},ld=lC;return d[ld(hj.O)]!==void 0x0?d[ld(hj.O)]:O?S(O):null;}[lC(0x12e)](O,d,k){const hH={O:0x135,t:0x101},lk=lC;return d[lk(hH.O)]?{'expectedRevision':k,'requireOwner':d['owner']}:O&&O[lk(hH.t)]!==h?{'expectedRevision':k,'replaceIncompatible':!0x0}:{'expectedRevision':k,'requireFreeLease':!0x0};}}function p(O,...d){const la=lC;for(const k of d){const a=O[la(0x119)](k);if(a)return a;}}c(p,lC(0x107));function T(O,t){const hw={O:0x131,t:0xbb,d:0xfe,k:0x13b},lp=lC;if(O[lp(hw.O)]['id']!==t)throw new Error(lp(hw.t)+O['id']+lp(hw.d)+O['graph']['id']+'\x27,\x20not\x20\x27'+t+lp(hw.k));}c(T,lC(0xf4));function j(O,t){const hZ={O:0x131,t:0xeb,d:0xfb,k:0xb6,a:0x131,z:0xeb,Y:0xea,B:0xae},lW=lC;if(O[lW(hZ.O)][lW(hZ.t)]!==t)throw new Error('Session\x20\x27'+O['id']+lW(hZ.d)+O['graph']['id']+lW(hZ.k)+O[lW(hZ.a)][lW(hZ.z)]+lW(hZ.Y)+t+lW(hZ.B));}c(j,lC(0xde));function oe(O){const ho={O:0x11e},hC={O:0x121},lz=lC;return Object[lz(0xc0)](Object[lz(0xd2)](O)[lz(ho.O)](([d,k])=>{const lP=lz;if(!k||typeof k!=lP(hC.O))return[d,k];const {toolTrace:a,...z}=k;return[d,z];}));}c(oe,lC(0x132));function ie(O){const hL={O:0xef,t:0x12d,d:0xe5,k:0xd1,a:0xcf,z:0xf7,Y:0x111,B:0x12d,M:0xf9,l0:0x12d,l1:0xf9};return O['map'](d=>{const lY=e,k={...d[lY(0xb1)]},a=d['type']==='ai'&&Array[lY(hL.O)](k[lY(0x111)])&&k[lY(0x111)][lY(hL.t)]>0x0?ce(k[lY(0xe5)]):void 0x0,z=b(k[lY(hL.d)])&&k[lY(0xe5)][lY(hL.k)]===!0x0;return delete k[lY(0xe5)],(a||z)&&(k['additional_kwargs']={...a?{'originalTextContentBlock':a}:{},...z?{'ezgraphInternal':!0x0}:{}}),delete k[lY(hL.a)],delete k[lY(hL.z)],d[lY(0xbc)]==='ai'&&(Array[lY(0xef)](k[lY(hL.Y)])&&k[lY(0x111)][lY(hL.B)]===0x0&&delete k[lY(hL.Y)],Array['isArray'](k[lY(hL.M)])&&k[lY(0xf9)][lY(hL.l0)]===0x0&&delete k[lY(hL.l1)]),{...d,'data':k};});}c(ie,lC(0x9a));function se(O){const hb={O:0xd2,t:0x11e},lB=lC;return Object[lB(0xc0)](Object[lB(hb.O)](O)[lB(hb.t)](([d,k])=>[d,ie(r(k))]));}c(se,lC(0xa4));function ae(O={}){const hn={O:0xc0},ly=lC;return Object[ly(hn.O)](Object[ly(0xd2)](O)[ly(0x11e)](([d,k])=>[d,s(k)]));}c(ae,lC(0xa9));function ce(O){const hR={O:0x9e,t:0x133,d:0x9e},lU=lC;if(!b(O))return;const t=O[lU(0x10d)];if(!(!b(t)||typeof t[lU(hR.O)]!=lU(0xc7)))return{...typeof t[lU(hR.t)]==lU(0xc7)?{'text':t['text']}:{},'thoughtSignature':t[lU(hR.d)],...t[lU(0xba)]===!0x0?{'thought':!0x0}:{}};}c(ce,lC(0xf1));function b(O){const lX=lC;return O!==null&&typeof O==lX(0x121)&&!Array['isArray'](O);}c(b,lC(0x104));class V{static{c(this,lC(0xb9));}[lC(0x105)]=new Map();get[lC(0x9b)](){const lM=lC;return this[lM(0x105)][lM(0x9b)];}[lC(0xbf)]={'upsert':c(async e=>{const hJ={O:0x105},lS=lC,t=e;return this[lS(hJ.O)]['set'](t['id'],structuredClone(t)),{};},lC(0x124))};async[lC(0x13d)](O,d){const hg={O:0x105},lK=lC,k=this[lK(hg.O)][lK(0x119)](d['id']);return de(k,O)?(this['documents'][lK(0x10e)](d['id'],structuredClone(d)),'ok'):'conflict';}[lC(0x13e)](O,d){const hx={O:0x119,t:0xc1,d:0x11b},hN={O:0x105},h0=lC;return{'read':c(async()=>{const lT=e,k=this[lT(hN.O)][lT(0x119)](O);if(!k||k['id']!==d)throw Object[lT(0xc1)](new Error('Not\x20found'),{'code':0x194});return{'resource':structuredClone(k)};},'read'),'delete':c(async()=>{const lF=e,k=this[lF(0x105)][lF(hx.O)](O);if(!k||k['id']!==d)throw Object[lF(hx.t)](new Error(lF(hx.d)),{'code':0x194});return this[lF(0x105)]['delete'](O),{};},h0(0x138))};}}function G(O){const h1=lC;if(!O||typeof O!=h1(0x121))return!0x1;const t=O;return t[h1(0xb4)]===0x194||t[h1(0x12f)]===0x194;}c(G,lC(0x139));function F(O=process.env.SESSION_TURN_LEASE_MS){const hV={O:0x118},h2=lC,t=Number(O??h2(hV.O));return Number[h2(0x98)](t)&&t>0x0?t:0xea60;}function e(h,c){h=h-0x98;const r=l();let Q=r[h];if(e['zZPXch']===undefined){var v=function(E){const D='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let A='',j='';for(let H=0x0,m,w,Z=0x0;w=E['charAt'](Z++);~w&&(m=H%0x4?m*0x40+w:w,H++%0x4)?A+=String['fromCharCode'](0xff&m>>(-0x2*H&0x6)):0x0){w=D['indexOf'](w);}for(let C=0x0,o=A['length'];C<o;C++){j+='%'+('00'+A['charCodeAt'](C)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(j);};e['quHhSI']=v,e['AkYZlF']={},e['zZPXch']=!![];}const G=r[0x0],I=h+G,s=e['AkYZlF'][I];return!s?(Q=e['quHhSI'](Q),e['AkYZlF'][I]=Q):Q=s,Q;}c(F,lC(0xe6));function S(O){const ht={O:0xb2},h3=lC;return O?.[h3(ht.O)]??0x0;}c(S,lC(0x142));function K(O,d=Date['now']()){const hd={O:0x135,t:0xcc,d:0xb7},h4=lC;if(!O?.[h4(hd.O)]||!O[h4(0xb7)])return!0x1;const k=Date[h4(hd.t)](O[h4(hd.d)]);return Number['isFinite'](k)&&k>d;}c(K,lC(0xb5));function de(O,d,k=Date[lC(0x130)]()){const hk={O:0x113,t:0xdf,d:0xf2,k:0xd0},h5=lC;return d[h5(0x10c)]?O!==void 0x0&&O['version']!==h:d[h5(hk.O)]===null?O===void 0x0:!(!O||S(O)!==d[h5(0x113)]||d['requireOwner']&&O[h5(hk.t)]?.[h5(0x135)]!==d[h5(hk.d)]||d[h5(hk.k)]&&K(O[h5(0xdf)],k)&&O['turn']?.[h5(0x135)]!==d[h5(0x143)]);}c(de,lC(0x137));export{V as MemorySessionDocumentContainer,g as SESSION_BUSY,Ce as SESSION_COMPLETED,q as SESSION_CONFLICT,h as SESSION_DOCUMENT_VERSION,N as SessionManager,f as SessionTurnError,K as isLiveSessionTurn,de as matchesSessionWritePredicate,S as sessionRevision,F as sessionTurnLeaseMs};
@@ -0,0 +1 @@
1
+ var l=Object.defineProperty;var s=(i,e)=>l(i,"name",{value:e,configurable:!0});import{fileURLToPath as p}from"url";import{readFileSync as h}from"fs";import n from"path";class d{static{s(this,"Prompt")}static cache=new Map;static file(e){const a=this.getCallerDir(),r=n.resolve(a,e);if(this.cache.has(r))return this.cache.get(r);const t=h(r,"utf-8");return this.cache.set(r,t),t}static getCallerDir(){const e=Error.prepareStackTrace;Error.prepareStackTrace=(c,o)=>o;const r=new Error().stack;Error.prepareStackTrace=e;const t=r?.[2]?.getFileName();if(!t)throw new Error("Unable to determine caller file path");return n.dirname(t.startsWith("file:")?p(t):t)}static set(e,a,r){return e.replace(`{{${a}}}`,r)}static replace(e,a){return e.replace(/{{(.*?)}}/g,(r,t)=>a[t]||r)}static replace2(e,a){return e.replace(/{{(.*?)}}/g,(r,t)=>{const c=a[t.trim()];return c===void 0?r:typeof c=="string"?c:JSON.stringify(c)})}}export{d as Prompt};
@@ -0,0 +1 @@
1
+ var $=Object.defineProperty;var a=(n,e)=>$(n,"name",{value:e,configurable:!0});import{mapChatMessagesToStoredMessages as D,mapStoredMessagesToChatMessages as F}from"@langchain/core/messages";import{getConfig as J,getCurrentTaskInput as M,isCommand as B,isGraphBubbleUp as G,task as P}from"@langchain/langgraph";import{cloneJsonObject as f}from"./graph-context.js";import{addTokenUsage as x,emptyTokenUsage as I}from"./token-usage.js";import{addDecisionUsage as A,emptyDecisionUsage as y}from"./decision/decision-types.js";import{currentInvocationNode as V,joinRunNodeResults as R,reserveRunNodeTargets as W,withRunNodeExecution as H}from"./node-invocation.js";import{currentTurnContext as K,withTurnContext as Q}from"./turn-context.js";import{currentSessionLogs as X,SessionLogWarning as Y,withSessionLogs as Z}from"./session-log.js";import{stableClassId as q}from"./stable-id.js";const me=Symbol("RUN_NODE_OUTPUT");class ee extends Error{static{a(this,"RunNodeBatchError")}results;usage;decisionUsage;constructor(e){super(`runNode() failed: ${e.filter(t=>t.status==="rejected").map(t=>`${t.nodeId}: ${t.error.message}`).join("; ")}`),this.name="RunNodeBatchError",this.results=b(e),this.usage=Object.freeze(e.reduce((t,r)=>x(t,r.usage),I())),this.decisionUsage=Object.freeze(e.reduce((t,r)=>A(t,r.decisionUsage),y()))}}async function he(n,e){if(!e.length)throw new Error("runNode() requires at least one target.");const t=V(n.owner);try{M()}catch{throw new Error("runNode() requires an active LangGraph node or task; standalone invoke() is unsupported.")}const r=e.map(s=>{const i=typeof s=="object"&&s!==null&&"node"in s,u=i?s.node:s;if(!u||typeof u.id!="function")throw new Error("runNode() requires registered GraphNode classes.");const j=n.resolve(u),E=q(u,"graph node"),N=i&&s.input!==void 0?f({input:s.input},"runNode() input").input:void 0;return{node:j,nodeId:E,input:N}}),p=W(n.owner,r.map(s=>s.nodeId));try{const s=oe(n.graphState()),i=ne();i?.signal?.throwIfAborted();const u=X(),j=r.map(o=>({version:1,nodeId:o.nodeId,caller:t,state:f(s,"runNode() snapshot"),...o.input===void 0?{}:{input:o.input}})),E=r.map((o,d)=>P({name:`runNode:${o.nodeId}`,retry:{maxAttempts:1}},async h=>{const l={owner:n.owner,nodeId:h.nodeId,caller:h.caller,...h.input===void 0?{}:{input:b(h.input)},outcome:{kind:"state"},usage:I(),decisionUsage:y()},S=a(()=>H(l,async()=>{try{i?.signal?.throwIfAborted();const c=te(h.state),w=await o.node.invoke(c,{mode:"internal"});if(i?.signal?.throwIfAborted(),B(w))throw new Error(`runNode() child '${o.nodeId}' cannot route.`);const C=w.nodes?.[o.nodeId]??c.nodes[o.nodeId]??{},_=Object.fromEntries(Object.entries(C).filter(([,L])=>L!==void 0)),z={version:1,status:"fulfilled",nodeId:o.nodeId,state:_,outcome:l.outcome,usage:l.usage,decisionUsage:l.decisionUsage};return f(z,"runNode() task result")}catch(c){if(i?.signal?.throwIfAborted(),G(c)||c instanceof Error&&c.name==="AbortError")throw c;const w=c instanceof Error?c:new Error(String(c));return{version:1,status:"rejected",nodeId:o.nodeId,error:{name:w.name,message:w.message},usage:l.usage,decisionUsage:l.decisionUsage}}}),"invoke"),T=a(()=>u?Z(u,S):S(),"withLogs");return i?Q(i,T):T()})(j[d])),N=await Promise.allSettled(E);i?.signal?.throwIfAborted();const U=N.find(o=>o.status==="rejected");if(U)throw U.reason;const m=N.map((o,d)=>{const g=o.value;if(g.version!==1||g.nodeId!==r[d].nodeId)throw new Error("Incompatible runNode() task result.");return re(g)}),k=m.reduce((o,d)=>x(o,d.usage),I()),O=m.reduce((o,d)=>A(o,d.decisionUsage),y());if(m.some(o=>o.status==="rejected"))throw R(n.owner,{},k,O),Y({runNode_failed:!0,caller:t,usage:k,decisionUsage:O}),new ee(m.map(({version:o,...d})=>d));const v=m;return R(n.owner,Object.fromEntries(v.map(o=>[o.nodeId,f(o.state)])),k,O),b(v.map(({version:o,status:d,...g})=>g))}finally{p()}}a(he,"runNodeTasks");function ne(){const n=K(),e=J()?.signal,t=n?.signal&&e&&n.signal!==e?AbortSignal.any([n.signal,e]):n?.signal??e;return n||t?{session:n?.session??"runNode",...t?{signal:t}:{}}:void 0}a(ne,"taskTurnContext");function oe(n){const e=Object.fromEntries(Object.entries(n.histories??{}).map(([t,r])=>[t,JSON.parse(JSON.stringify(D(r),(p,s)=>{if(["function","symbol","bigint"].includes(typeof s)||typeof s=="number"&&!Number.isFinite(s))throw new TypeError("runNode() message snapshot contains a non-JSON value.");return s}))]));return f(Object.fromEntries(Object.entries({...n,histories:e}).filter(([,t])=>t!==void 0)),"runNode() graph snapshot")}a(oe,"serializeState");function te(n){const e=f(n,"runNode() graph snapshot"),t=Object.fromEntries(Object.entries(e.histories).map(([r,p])=>[r,F(p)]));return b({...e,histories:t})}a(te,"deserializeState");function b(n){if(n&&typeof n=="object"&&!Object.isFrozen(n)){for(const e of Object.values(n))b(e);Object.freeze(n)}return n}a(b,"freezeRunNodeValue");function re(n){const e=f(n,"runNode() restored task result"),t=a((r,p)=>p.every(s=>{const i=r[s];return typeof i=="number"&&Number.isFinite(i)&&i>=0}),"validUsage");if(!e.usage||!e.decisionUsage||!t(e.usage,Object.keys(I()))||!t(e.decisionUsage,Object.keys(y())))throw new Error("Invalid runNode() task usage.");if(e.status==="rejected"){if(!e.error||typeof e.error.name!="string"||typeof e.error.message!="string")throw new Error("Invalid runNode() task failure.")}else if(e.status==="fulfilled"){const r=e.outcome;if(!e.state||typeof e.state!="object"||Array.isArray(e.state)||!r||!(r.kind==="state"||r.kind==="taskResult"&&"value"in r||r.kind==="reply"&&typeof r.response=="string"))throw new Error("Invalid runNode() task success.")}else throw new Error("Invalid runNode() task status.");return e}a(re,"validateEnvelope");export{me as RUN_NODE_OUTPUT,ee as RunNodeBatchError,b as freezeRunNodeValue,he as runNodeTasks};
@@ -1 +1 @@
1
- var t=Object.defineProperty;var e=(n,r)=>t(n,"name",{value:r,configurable:!0});import{AsyncLocalStorage as c}from"node:async_hooks";const s=new c;function g(){return{errors:[],warnings:[],decisions:[]}}e(g,"createSessionLogs");function S(n){return{errors:n.errors.splice(0),warnings:n.warnings.splice(0),decisions:n.decisions.splice(0)}}e(S,"drainSessionLogs");function f(n,r){n.errors.unshift(...r.errors),n.warnings.unshift(...r.warnings),n.decisions.unshift(...r.decisions)}e(f,"restoreSessionLogs");function p(n,r){return s.run(n,r)}e(p,"withSessionLogs");function d(n,r=s.getStore()){i("errors",n,r)}e(d,"SessionLogError");function w(n,r=s.getStore()){i("warnings",n,r)}e(w,"SessionLogWarning");function L(n,r=s.getStore()){if(!r)return;const o={...n,createdAt:new Date().toISOString()};return r.decisions.push(o),o}e(L,"SessionLogDecision");function i(n,r,o){o&&o[n].push({...r,createdAt:new Date().toISOString()})}e(i,"appendLog");export{L as SessionLogDecision,d as SessionLogError,w as SessionLogWarning,g as createSessionLogs,S as drainSessionLogs,f as restoreSessionLogs,p as withSessionLogs};
1
+ var i=Object.defineProperty;var e=(n,r)=>i(n,"name",{value:r,configurable:!0});import{AsyncLocalStorage as c}from"node:async_hooks";const s=new c;function S(){return s.getStore()}e(S,"currentSessionLogs");function a(){return{errors:[],warnings:[],decisions:[]}}e(a,"createSessionLogs");function f(n){return{errors:n.errors.splice(0),warnings:n.warnings.splice(0),decisions:n.decisions.splice(0)}}e(f,"drainSessionLogs");function p(n,r){n.errors.unshift(...r.errors),n.warnings.unshift(...r.warnings),n.decisions.unshift(...r.decisions)}e(p,"restoreSessionLogs");function d(n,r){return s.run(n,r)}e(d,"withSessionLogs");function L(n,r=s.getStore()){t("errors",n,r)}e(L,"SessionLogError");function w(n,r=s.getStore()){t("warnings",n,r)}e(w,"SessionLogWarning");function x(n,r=s.getStore()){if(!r)return;const o={...n,createdAt:new Date().toISOString()};return r.decisions.push(o),o}e(x,"SessionLogDecision");function t(n,r,o){o&&o[n].push({...r,createdAt:new Date().toISOString()})}e(t,"appendLog");export{x as SessionLogDecision,L as SessionLogError,w as SessionLogWarning,a as createSessionLogs,S as currentSessionLogs,f as drainSessionLogs,p as restoreSessionLogs,d as withSessionLogs};
@@ -1 +1 @@
1
- const J=z;(function(K,H){const P6={K:0x1de,H:0x1ff,Z:0x215,o:0x200,k:0x1e6,q:0x1d7,O:0x21d,Q:0x20a},U=z,Z=K();while(!![]){try{const o=parseInt(U(P6.K))/0x1*(-parseInt(U(P6.H))/0x2)+parseInt(U(P6.Z))/0x3+parseInt(U(P6.o))/0x4*(parseInt(U(0x1f2))/0x5)+parseInt(U(P6.k))/0x6+parseInt(U(P6.q))/0x7+-parseInt(U(P6.O))/0x8*(-parseInt(U(P6.Q))/0x9)+-parseInt(U(0x20c))/0xa;if(o===H)break;else Z['push'](Z['shift']());}catch(k){Z['push'](Z['shift']());}}}(P,0x339cf));var m=Object[J(0x1ed)],p=(K,H)=>m(K,'name',{'value':H,'configurable':!0x0});import{END as B,isCommand as e,START as N,StateGraph as X}from'@langchain/langgraph';import{GRAPH_NODE_CLASS as y,GraphNode as F}from'./graph-node.js';import{GRAPH_END_NODE as W}from'./graph-state.js';import{stableClassId as C}from'./stable-id.js';class x{static{p(this,'StateGraphExt');}['createGraphNode'];[J(0x1e5)];[J(0x1fa)];[J(0x1f0)]=new Set();[J(0x21f)]=new Map();['turnNodeIds'];[J(0x1ec)]=new Set();[J(0x1e2)]=new Map();constructor(K,H,Z=W){const P7={K:0x1e5},T=J;this[T(0x21c)]=H,this[T(P7.K)]=Z,this['graph']=new X(K);}['addNode'](K){const P8={K:0x21c,H:0x21c,Z:0x21f,o:0x1f0},S=J;if(!w(K))throw new Error('StateGraphExt\x20nodes\x20must\x20be\x20added\x20as\x20GraphNode\x20classes:\x20graph.addNode(MyNode).');if(!this[S(P8.K)])throw new Error('This\x20graph\x20has\x20no\x20GraphNode\x20factory.');const H=this[S(P8.H)](K),Z=C(K,S(0x1dd));if(H['id']!==Z)throw new Error(S(0x1db)+Z+'\x27\x20returned\x20\x27'+H['id']+'\x27.');return this[S(P8.Z)]['set'](Z,K),this[S(0x21a)](H,[...this[S(P8.o)],Z,B]);}['nodes'](...K){const PP={K:0x1fc,H:0x21b,Z:0x220,o:0x217,k:0x21a},P9={K:0x21e},d=J;if(!this[d(0x21c)])throw new Error(d(0x201));const H=K[d(0x209)](q=>{const f=d;if(!w(q))throw new Error(f(P9.K));return C(q,f(0x1dd));}),Z=H[d(PP.K)]((q,O)=>H[d(0x204)](q)!==O||this['addedNodeIds']['has'](q));if(Z)throw new Error(d(PP.H)+Z+d(0x1ef));const k=[...this[d(0x1f0)],...H,B];for(const [q,O]of K[d(PP.Z)]()){const Q=this[d(0x21c)](O),D=H[q];if(Q['id']!==D)throw new Error(d(0x1db)+D+'\x27\x20returned\x20\x27'+Q['id']+'\x27.');this[d(0x21f)][d(PP.o)](D,O),this[d(PP.k)](Q,k);}return this;}[J(0x1d8)](...K){const s=J;return this[s(0x1f6)](...K),this['registerTurns'](...K),this;}[J(0x211)](...K){const PB={K:0x1ee,H:0x21b,Z:0x1f0},V=J;for(const H of K){if(!w(H))throw new Error(V(0x203));const Z=C(H,V(0x1dd));if(this[V(0x1fe)]?.[V(PB.K)](Z))throw new Error(V(PB.H)+Z+'\x27\x20is\x20already\x20a\x20user-turn\x20entry.');this[V(PB.Z)]['has'](Z)||this[V(0x1f6)](H),this['workerNodeIds'][V(0x206)](Z);}return this;}['addEdge'](K,H){const Pb={K:0x1fa,H:0x1d6},h=J,Z=Array[h(0x1e3)](K)?K:[K];for(const q of Z)this[h(0x1eb)](q);this[h(0x1d9)](H);const k=Z[h(0x209)](c);return this[h(Pb.K)][h(0x208)](k[h(Pb.H)]===0x1?k[0x0]:k,c(H)),this;}['branch'](K,H){const Pe={K:0x1da},R=J,Z=C(K,R(0x1dd)),k=this[R(0x1e2)]['get'](Z);if(!k)throw new Error(R(0x21b)+Z+R(0x1fb));return this[R(0x20f)](K,k[R(0x20b)][R(Pe.K)](k),H),this;}['branchBy'](K,H){const Pw={K:0x1dd,H:0x1ee,Z:0x1fc,o:0x20f,k:0x209,q:0x1f8},PN={K:0x210,H:0x1f1,Z:0x1f3},a=J,Z=C(K,a(Pw.K));if(!this[a(0x1e2)][a(Pw.H)](Z))throw new Error('Graph\x20node\x20\x27'+Z+a(0x1fb));if(H['cases'][a(0x1d6)]===0x0)throw new Error(a(0x218));const k=H['cases']['map'](({when:D})=>this[a(0x214)](D)),q=k[a(Pw.Z)]((D,j)=>k['indexOf'](D)!==j);if(q)throw new Error(a(0x1e4)+q+'\x27.');const O=k['map']((D,j)=>a(0x216)+j),Q=a(0x1f8);return this[a(Pw.o)](K,D=>{const Y=a,j=D[Y(PN.K)];if(typeof j!=Y(PN.H))throw new Error(Y(0x21b)+Z+Y(PN.Z));const M=k[Y(0x204)](j);return M===-0x1?Q:O[M];},{...Object['fromEntries'](H[a(0x202)][a(Pw.k)](({routeTo:D},j)=>[O[j],D])),[Q]:H[a(Pw.q)]}),this;}[J(0x1e7)](...K){const PX={K:0x20e,H:0x1f5,Z:0x1e8,o:0x209,k:0x1fe},v=J,H=K['map'](Z=>C(Z,v(0x1dd)));for(const Z of H)if(this[v(0x1ec)][v(0x1ee)](Z))throw new Error(v(0x21b)+Z+'\x27\x20is\x20already\x20registered\x20as\x20internal\x20work.');if(K[v(PX.K)](o=>C(o,'graph\x20node')===this[v(0x1e5)]))throw new Error(v(PX.H)+this[v(0x1e5)]+v(PX.Z));return this[v(0x20f)](N,o=>o[v(0x210)],{...Object['fromEntries'](K[v(PX.o)](o=>[C(o,'graph\x20node'),o])),[this['endNode']]:B}),this[v(PX.k)]=new Set(H),this;}[J(0x212)](){const Py={K:0x1e2,H:0x1df,Z:0x1fa},L=J;for(const K of this[L(Py.K)]['values']())K[L(Py.H)]?.(this[L(0x1f7)](K['id']));return this[L(Py.Z)]['compile']();}[J(0x1f7)](K){const PF={K:0x1ec,H:0x1e0,Z:0x219},A=J;return{'mode':this[A(PF.K)][A(0x1ee)](K)||this[A(0x1fe)]!==void 0x0&&!this[A(0x1fe)]['has'](K)?A(PF.H):A(PF.Z)};}[J(0x20f)](K,H,Z){const PW={K:0x1fa,H:0x1f4,Z:0x220},n=J;this[n(0x1eb)](K);for(const k of Object['values'](Z))this['assertTarget'](k);this[n(PW.K)][n(PW.H)](c(K),H,Object[n(0x1f9)](Object[n(PW.Z)](Z)['map'](([q,O])=>[q,c(O)])));}[J(0x21a)](K,H){const PK={K:0x1f0,H:0x21b,Z:0x1ef,o:0x217},PC={K:0x1f7,H:0x1d9},t=J;if(this[t(PK.K)][t(0x1ee)](K['id']))throw new Error(t(PK.H)+K['id']+t(PK.Z));return this[t(0x1fa)][t(0x205)](K['id'],async Z=>{const P0=t,k=await K['invoke'](Z,this[P0(PC.K)](K['id']));if(e(k)){const q=Array[P0(0x1e3)](k[P0(0x20d)])?k[P0(0x20d)]:k[P0(0x20d)]===void 0x0?[]:[k[P0(0x20d)]];for(const O of q)typeof O=='string'&&this[P0(PC.H)](O);}return k;},{'ends':[...new Set(H)]}),this[t(0x1f0)][t(0x206)](K['id']),this[t(0x1e2)][t(PK.o)](K['id'],K),this;}[J(0x1eb)](K){const PH={K:0x1e1},P1=J;c(K)!==N&&this[P1(0x207)](K,P1(PH.K));}['assertTarget'](K){const Pu={K:0x207,H:0x1fd},P2=J;c(K)!==B&&this[P2(Pu.K)](K,P2(Pu.H));}[J(0x207)](K,H){const Px={K:0x1f0},P3=J,Z=c(K);if(!this[P3(Px.K)][P3(0x1ee)](Z))throw new Error(P3(0x213)+H+'\x20\x27'+Z+P3(0x1fb));}[J(0x214)](K){const PZ={K:0x1f1,H:0x1ee,Z:0x1dc,o:0x1e9,k:0x1e5,q:0x1ea,O:0x1e5},P4=J;if(typeof K!=P4(PZ.K)){if(!w(K))throw new Error('branchBy()\x20selectors\x20must\x20be\x20GraphNode\x20classes\x20or\x20the\x20configured\x20terminal\x20state.');const H=C(K,'graph\x20node');if(!this[P4(0x1f0)][P4(PZ.H)](H))throw new Error(P4(PZ.Z)+H+P4(PZ.o));return H;}if(K!==this[P4(PZ.k)]&&!this['addedNodeIds'][P4(0x1ee)](K))throw new Error(P4(PZ.Z)+K+P4(PZ.q)+this[P4(PZ.O)]+'\x27.');return K;}}function z(B,b){B=B-0x1d6;const e=P();let N=e[B];if(z['eVpIkl']===undefined){var w=function(W){const C='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let K='',H='';for(let u=0x0,x,Z,o=0x0;Z=W['charAt'](o++);~Z&&(x=u%0x4?x*0x40+Z:Z,u++%0x4)?K+=String['fromCharCode'](0xff&x>>(-0x2*u&0x6)):0x0){Z=C['indexOf'](Z);}for(let q=0x0,O=K['length'];q<O;q++){H+='%'+('00'+K['charCodeAt'](q)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(H);};z['aoVAHY']=w,z['txctJP']={},z['eVpIkl']=!![];}const X=e[0x0],y=B+X,F=z['txctJP'][y];return!F?(N=z['aoVAHY'](N),z['txctJP'][y]=N):N=F,N;}function w(K){const H=K;return typeof K=='function'&&K!==null&&H[y]===!0x0&&H['prototype']instanceof F;}function P(){const Pq=['yMLUza','r3jHCgGGBM9KzsbMywn0B3j5igzVCIaN','q3vYCMvUDc1UB2rLihnLBgvJDg9YicC','z3jHCgGGBM9Kzq','otG4ndzWwNP1r0q','DMfSAwrHDgvuB29SCW','Aw50zxjUywW','C291CMnL','BM9KzuLUC3rHBMnLCW','AxnbCNjHEq','yNjHBMnOqNKOksbOyxmGBw9Yzsb0AgfUig9UzsbJyxnLigzVCIaN','zw5KtM9Kzq','otG0odeWvM1ZqKHX','CMvNAxn0zxjuDxjUCW','jYbPCYbYzxnLCNzLzcbIEsbtDgf0zuDYyxbOrxH0lNjLz2LZDgvYvhvYBNmOks4','jYbTDxn0igjLigfKzgvKigjLzM9YzsbPDcbPCYb1C2vKlG','jYbTDxn0igjLigfUigfKzgvKieDYyxbOtM9KzsbVCIb0AguGy29UzMLNDxjLzcb0zxjTAw5HBcbZDgf0zsaN','yxnZzxj0u291CMnL','D29YA2vYtM9KzuLKCW','zgvMAw5LuhjVCgvYDhK','AgfZ','jYbPCYbHBhjLywr5ihjLz2LZDgvYzwqU','ywrKzwroB2rLswrZ','C3rYAw5N','nwnMs3bqtW','jYbJyw5UB3qGyNjHBMnOihDPDgHVDxqGysbZDhjPBMCGy3vYCMvUDe5VzguU','ywrKq29UzgL0Aw9UywXfzgDLCW','vgHLihrLCM1PBMfSihn0yxrLicC','BM9Kzxm','Aw52B2nHDgLVBK9WDgLVBNm','B3rOzxj3AxnL','zNjVBuvUDhjPzxm','z3jHCgG','jYbTDxn0igjLigfKzgvKigjLzM9YzsbPDcbPCYbJB25Uzwn0zwqU','zMLUza','DgfYz2v0','DhvYBK5Vzgvjzhm','oe14wLD4qq','ode1mZa0swPuvxf3','vgHPCYbNCMfWAcbOyxmGBM8Gr3jHCgHoB2rLigzHy3rVCNKU','y2fZzxm','u3rHDgvhCMfWAev4Dcb3B3jRzxjZig11C3qGyMuGywrKzwqGyxmGr3jHCgHoB2rLignSyxnZzxmU','Aw5KzxHpzG','ywrKtM9Kzq','ywrK','yxnZzxj0qwrKzwroB2rL','ywrKrwrNzq','BwfW','ntrRtKffrvm','CM91Dgu','nJa2mtK1mhHOz3rcsW','z290BW','C29Tzq','ywrKq29UzgL0Aw9UywXfzgDL','y3vYCMvUDe5Vzgu','D29YA2vYCW','y29TCgLSzq','q29UzgL0Aw9UywWGB3iGzgLYzwn0igvKz2uG','y3vYCMvUDe5VzgvtzwXLy3rVCK5HBwu','nJmYnJe5s1Ptu3Px','y2fZztO','C2v0','yNjHBMnOqNKOksbYzxf1AxjLCYbHDcbSzwfZDcbVBMuGy2fZzs4','y29UDMvYC2f0Aw9U','CMvNAxn0zxjoB2rL','r3jHCgGGBM9KzsaN','y3jLyxrLr3jHCgHoB2rL','ntu5ndmYzu55CMzp','u3rHDgvhCMfWAev4DcbUB2rLCYbTDxn0igjLigfKzgvKigfZieDYyxbOtM9KzsbJBgfZC2vZoIbNCMfWAc5UB2rLCYHnEu5VzguPlG','BM9KzunSyxnZzxm','zw50CMLLCW','BgvUz3rO','mtuWmJa0nMnnywT6yq','CMvNAxn0zxjuDxjUtM9Kzxm','yxnZzxj0vgfYz2v0'];P=function(){return Pq;};return P();}p(w,'isGraphNodeClass');function c(K){const Pk={K:0x1f1},P5=J;return typeof K==P5(Pk.K)?K:C(K,P5(0x1dd));}p(c,'endpointId');export{x as StateGraphExt};
1
+ const W=e;(function(Z,C){const l9={Z:0x1de,C:0x1ff,o:0x215,L:0x200,q:0x1e6,n:0x1d7,R:0x21d,f:0x20a},a=e,o=Z();while(!![]){try{const L=parseInt(a(l9.Z))/0x1*(-parseInt(a(l9.C))/0x2)+parseInt(a(l9.o))/0x3+parseInt(a(l9.L))/0x4*(parseInt(a(0x1f2))/0x5)+parseInt(a(l9.q))/0x6+parseInt(a(l9.n))/0x7+-parseInt(a(l9.R))/0x8*(-parseInt(a(l9.f))/0x9)+-parseInt(a(0x20c))/0xa;if(L===C)break;else o['push'](o['shift']());}catch(q){o['push'](o['shift']());}}}(h,0x339cf));var m=Object[W(0x1ed)],p=(Z,C)=>m(Z,'name',{'value':C,'configurable':!0x0});import{END as r,isCommand as Q,START as v,StateGraph as s}from'@langchain/langgraph';import{GRAPH_NODE_CLASS as D,GraphNode as A}from'./graph-node.js';import{GRAPH_END_NODE as j}from'./graph-state.js';import{stableClassId as H}from'./stable-id.js';class x{static{p(this,'StateGraphExt');}['createGraphNode'];[W(0x1e5)];[W(0x1fa)];[W(0x1f0)]=new Set();[W(0x21f)]=new Map();['turnNodeIds'];[W(0x1ec)]=new Set();[W(0x1e2)]=new Map();constructor(Z,C,o=j){const ll={Z:0x1e5},z=W;this[z(0x21c)]=C,this[z(ll.Z)]=o,this['graph']=new s(Z);}['addNode'](Z){const lh={Z:0x21c,C:0x21c,o:0x21f,L:0x1f0},P=W;if(!w(Z))throw new Error('StateGraphExt\x20nodes\x20must\x20be\x20added\x20as\x20GraphNode\x20classes:\x20graph.addNode(MyNode).');if(!this[P(lh.Z)])throw new Error('This\x20graph\x20has\x20no\x20GraphNode\x20factory.');const C=this[P(lh.C)](Z),o=H(Z,P(0x1dd));if(C['id']!==o)throw new Error(P(0x1db)+o+'\x27\x20returned\x20\x27'+C['id']+'\x27.');return this[P(lh.o)]['set'](o,Z),this[P(0x21a)](C,[...this[P(lh.L)],o,r]);}['nodes'](...Z){const le={Z:0x1fc,C:0x21b,o:0x220,L:0x217,q:0x21a},lc={Z:0x21e},Y=W;if(!this[Y(0x21c)])throw new Error(Y(0x201));const C=Z[Y(0x209)](n=>{const B=Y;if(!w(n))throw new Error(B(lc.Z));return H(n,B(0x1dd));}),L=C[Y(le.Z)]((n,R)=>C[Y(0x204)](n)!==R||this['addedNodeIds']['has'](n));if(L)throw new Error(Y(le.C)+L+Y(0x1ef));const q=[...this[Y(0x1f0)],...C,r];for(const [n,R]of Z[Y(le.o)]()){const J=this[Y(0x21c)](R),N=C[n];if(J['id']!==N)throw new Error(Y(0x1db)+N+'\x27\x20returned\x20\x27'+J['id']+'\x27.');this[Y(0x21f)][Y(le.L)](N,R),this[Y(le.q)](J,q);}return this;}[W(0x1d8)](...Z){const y=W;return this[y(0x1f6)](...Z),this['registerTurns'](...Z),this;}[W(0x211)](...Z){const lQ={Z:0x1ee,C:0x21b,o:0x1f0},U=W;for(const C of Z){if(!w(C))throw new Error(U(0x203));const o=H(C,U(0x1dd));if(this[U(0x1fe)]?.[U(lQ.Z)](o))throw new Error(U(lQ.C)+o+'\x27\x20is\x20already\x20a\x20user-turn\x20entry.');this[U(lQ.o)]['has'](o)||this[U(0x1f6)](C),this['workerNodeIds'][U(0x206)](o);}return this;}['addEdge'](Z,C){const lv={Z:0x1fa,C:0x1d6},X=W,L=Array[X(0x1e3)](Z)?Z:[Z];for(const n of L)this[X(0x1eb)](n);this[X(0x1d9)](C);const q=L[X(0x209)](c);return this[X(lv.Z)][X(0x208)](q[X(lv.C)]===0x1?q[0x0]:q,c(C)),this;}['branch'](Z,C){const lG={Z:0x1da},M=W,L=H(Z,M(0x1dd)),q=this[M(0x1e2)]['get'](L);if(!q)throw new Error(M(0x21b)+L+M(0x1fb));return this[M(0x20f)](Z,q[M(0x20b)][M(lG.Z)](q),C),this;}['branchBy'](Z,C){const ls={Z:0x1dd,C:0x1ee,o:0x1fc,L:0x20f,q:0x209,n:0x1f8},lI={Z:0x210,C:0x1f1,o:0x1f3},S=W,L=H(Z,S(ls.Z));if(!this[S(0x1e2)][S(ls.C)](L))throw new Error('Graph\x20node\x20\x27'+L+S(0x1fb));if(C['cases'][S(0x1d6)]===0x0)throw new Error(S(0x218));const q=C['cases']['map'](({when:N})=>this[S(0x214)](N)),n=q[S(ls.o)]((N,O)=>q['indexOf'](N)!==O);if(n)throw new Error(S(0x1e4)+n+'\x27.');const R=q['map']((N,O)=>S(0x216)+O),J=S(0x1f8);return this[S(ls.L)](Z,O=>{const K=S,V=O[K(lI.Z)];if(typeof V!=K(lI.C))throw new Error(K(0x21b)+L+K(lI.o));const k=q[K(0x204)](V);return k===-0x1?J:R[k];},{...Object['fromEntries'](C[S(0x202)][S(ls.q)](({routeTo:N},O)=>[R[O],N])),[J]:C[S(ls.n)]}),this;}[W(0x1e7)](...Z){const lE={Z:0x20e,C:0x1f5,o:0x1e8,L:0x209,q:0x1fe},T=W,C=Z['map'](o=>H(o,T(0x1dd)));for(const o of C)if(this[T(0x1ec)][T(0x1ee)](o))throw new Error(T(0x21b)+o+'\x27\x20is\x20already\x20registered\x20as\x20internal\x20work.');if(Z[T(lE.Z)](L=>H(L,'graph\x20node')===this[T(0x1e5)]))throw new Error(T(lE.C)+this[T(0x1e5)]+T(lE.o));return this[T(0x20f)](v,L=>L[T(0x210)],{...Object['fromEntries'](Z[T(lE.L)](L=>[H(L,'graph\x20node'),L])),[this['endNode']]:r}),this[T(lE.q)]=new Set(C),this;}[W(0x212)](){const lD={Z:0x1e2,C:0x1df,o:0x1fa},F=W;for(const Z of this[F(lD.Z)]['values']())Z[F(lD.C)]?.(this[F(0x1f7)](Z['id']));return this[F(lD.o)]['compile']();}[W(0x1f7)](Z){const lA={Z:0x1ec,C:0x1e0,o:0x219},l0=W;return{'mode':this[l0(lA.Z)][l0(0x1ee)](Z)||this[l0(0x1fe)]!==void 0x0&&!this[l0(0x1fe)]['has'](Z)?l0(lA.C):l0(lA.o)};}[W(0x20f)](Z,C,L){const lj={Z:0x1fa,C:0x1f4,o:0x220},l1=W;this[l1(0x1eb)](Z);for(const q of Object['values'](L))this['assertTarget'](q);this[l1(lj.Z)][l1(lj.C)](c(Z),C,Object[l1(0x1f9)](Object[l1(lj.o)](L)['map'](([n,R])=>[n,c(R)])));}[W(0x21a)](Z,C){const lm={Z:0x1f0,C:0x21b,o:0x1ef,L:0x217},lH={Z:0x1f7,C:0x1d9},l2=W;if(this[l2(lm.Z)][l2(0x1ee)](Z['id']))throw new Error(l2(lm.C)+Z['id']+l2(lm.o));return this[l2(0x1fa)][l2(0x205)](Z['id'],async L=>{const l3=l2,q=await Z['invoke'](L,this[l3(lH.Z)](Z['id']));if(Q(q)){const n=Array[l3(0x1e3)](q[l3(0x20d)])?q[l3(0x20d)]:q[l3(0x20d)]===void 0x0?[]:[q[l3(0x20d)]];for(const R of n)typeof R=='string'&&this[l3(lH.C)](R);}return q;},{'ends':[...new Set(C)]}),this[l2(0x1f0)][l2(0x206)](Z['id']),this[l2(0x1e2)][l2(lm.L)](Z['id'],Z),this;}[W(0x1eb)](Z){const lw={Z:0x1e1},l4=W;c(Z)!==v&&this[l4(0x207)](Z,l4(lw.Z));}['assertTarget'](Z){const lZ={Z:0x207,C:0x1fd},l5=W;c(Z)!==r&&this[l5(lZ.Z)](Z,l5(lZ.C));}[W(0x207)](Z,C){const lC={Z:0x1f0},l6=W,o=c(Z);if(!this[l6(lC.Z)][l6(0x1ee)](o))throw new Error(l6(0x213)+C+'\x20\x27'+o+l6(0x1fb));}[W(0x214)](Z){const lo={Z:0x1f1,C:0x1ee,o:0x1dc,L:0x1e9,q:0x1e5,n:0x1ea,R:0x1e5},l7=W;if(typeof Z!=l7(lo.Z)){if(!w(Z))throw new Error('branchBy()\x20selectors\x20must\x20be\x20GraphNode\x20classes\x20or\x20the\x20configured\x20terminal\x20state.');const C=H(Z,'graph\x20node');if(!this[l7(0x1f0)][l7(lo.C)](C))throw new Error(l7(lo.o)+C+l7(lo.L));return C;}if(Z!==this[l7(lo.q)]&&!this['addedNodeIds'][l7(0x1ee)](Z))throw new Error(l7(lo.o)+Z+l7(lo.n)+this[l7(lo.R)]+'\x27.');return Z;}}function e(l,c){l=l-0x1d6;const r=h();let Q=r[l];if(e['eVpIkl']===undefined){var v=function(E){const D='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let A='',j='';for(let H=0x0,m,w,Z=0x0;w=E['charAt'](Z++);~w&&(m=H%0x4?m*0x40+w:w,H++%0x4)?A+=String['fromCharCode'](0xff&m>>(-0x2*H&0x6)):0x0){w=D['indexOf'](w);}for(let C=0x0,o=A['length'];C<o;C++){j+='%'+('00'+A['charCodeAt'](C)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(j);};e['aoVAHY']=v,e['txctJP']={},e['eVpIkl']=!![];}const G=r[0x0],I=l+G,s=e['txctJP'][I];return!s?(Q=e['aoVAHY'](Q),e['txctJP'][I]=Q):Q=s,Q;}function w(Z){const C=Z;return typeof Z=='function'&&Z!==null&&C[D]===!0x0&&C['prototype']instanceof A;}function h(){const lb=['yMLUza','r3jHCgGGBM9KzsbMywn0B3j5igzVCIaN','q3vYCMvUDc1UB2rLihnLBgvJDg9YicC','z3jHCgGGBM9Kzq','otG4ndzWwNP1r0q','DMfSAwrHDgvuB29SCW','Aw50zxjUywW','C291CMnL','BM9KzuLUC3rHBMnLCW','AxnbCNjHEq','yNjHBMnOqNKOksbOyxmGBw9Yzsb0AgfUig9UzsbJyxnLigzVCIaN','zw5KtM9Kzq','otG0odeWvM1ZqKHX','CMvNAxn0zxjuDxjUCW','jYbPCYbYzxnLCNzLzcbIEsbtDgf0zuDYyxbOrxH0lNjLz2LZDgvYvhvYBNmOks4','jYbTDxn0igjLigfKzgvKigjLzM9YzsbPDcbPCYb1C2vKlG','jYbTDxn0igjLigfUigfKzgvKieDYyxbOtM9KzsbVCIb0AguGy29UzMLNDxjLzcb0zxjTAw5HBcbZDgf0zsaN','yxnZzxj0u291CMnL','D29YA2vYtM9KzuLKCW','zgvMAw5LuhjVCgvYDhK','AgfZ','jYbPCYbHBhjLywr5ihjLz2LZDgvYzwqU','ywrKzwroB2rLswrZ','C3rYAw5N','nwnMs3bqtW','jYbJyw5UB3qGyNjHBMnOihDPDgHVDxqGysbZDhjPBMCGy3vYCMvUDe5VzguU','ywrKq29UzgL0Aw9UywXfzgDLCW','vgHLihrLCM1PBMfSihn0yxrLicC','BM9Kzxm','Aw52B2nHDgLVBK9WDgLVBNm','B3rOzxj3AxnL','zNjVBuvUDhjPzxm','z3jHCgG','jYbTDxn0igjLigfKzgvKigjLzM9YzsbPDcbPCYbJB25Uzwn0zwqU','zMLUza','DgfYz2v0','DhvYBK5Vzgvjzhm','oe14wLD4qq','ode1mZa0swPuvxf3','vgHPCYbNCMfWAcbOyxmGBM8Gr3jHCgHoB2rLigzHy3rVCNKU','y2fZzxm','u3rHDgvhCMfWAev4Dcb3B3jRzxjZig11C3qGyMuGywrKzwqGyxmGr3jHCgHoB2rLignSyxnZzxmU','Aw5KzxHpzG','ywrKtM9Kzq','ywrK','yxnZzxj0qwrKzwroB2rL','ywrKrwrNzq','BwfW','ntrRtKffrvm','CM91Dgu','nJa2mtK1mhHOz3rcsW','z290BW','C29Tzq','ywrKq29UzgL0Aw9UywXfzgDL','y3vYCMvUDe5Vzgu','D29YA2vYCW','y29TCgLSzq','q29UzgL0Aw9UywWGB3iGzgLYzwn0igvKz2uG','y3vYCMvUDe5VzgvtzwXLy3rVCK5HBwu','nJmYnJe5s1Ptu3Px','y2fZztO','C2v0','yNjHBMnOqNKOksbYzxf1AxjLCYbHDcbSzwfZDcbVBMuGy2fZzs4','y29UDMvYC2f0Aw9U','CMvNAxn0zxjoB2rL','r3jHCgGGBM9KzsaN','y3jLyxrLr3jHCgHoB2rL','ntu5ndmYzu55CMzp','u3rHDgvhCMfWAev4DcbUB2rLCYbTDxn0igjLigfKzgvKigfZieDYyxbOtM9KzsbJBgfZC2vZoIbNCMfWAc5UB2rLCYHnEu5VzguPlG','BM9KzunSyxnZzxm','zw50CMLLCW','BgvUz3rO','mtuWmJa0nMnnywT6yq','CMvNAxn0zxjuDxjUtM9Kzxm','yxnZzxj0vgfYz2v0'];h=function(){return lb;};return h();}p(w,'isGraphNodeClass');function c(Z){const lq={Z:0x1f1},l8=W;return typeof Z==l8(lq.Z)?Z:H(Z,l8(0x1dd));}p(c,'endpointId');export{x as StateGraphExt};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{GraphContextChannel as r}from"./framework/graph-context.js";import{BaseGraph as s}from"./framework/base-graph.js";import{GRAPH_NODE_CLASS as n,GraphNode as a,GraphNodeRuntime as m,Tool as p}from"./framework/graph-node.js";import{LlmNode as E}from"./framework/llm-node.js";import{LLM_GATEWAY_FACTORY as x,assertLlmTimeoutMs as L}from"./framework/llm-gateway.js";import{LlmRunner as d,DEFAULT_LLM_POLICY as g,DEFAULT_EMPTY_HISTORY_SEED as D,DEFAULT_EMPTY_RESPONSE_RECOVERY as T,DEFAULT_MAX_AGENT_ROUNDS as R,EmptyModelResponseError as _,assertEmptyResponseRetries as c,assertMaxAgentRounds as C}from"./framework/llm-runner.js";import{describeStopReason as u,isRetryableStopReason as A,modelStopReason as N}from"./framework/model-stop-reason.js";import{currentTurnContext as I,currentTurnSignal as G,withTurnContext as P}from"./framework/turn-context.js";import{direct as U,directTo as y,finish as v,fanout as F,go as Y,isToolResponse as k,stay as H,taskResult as B}from"./framework/tool-response.js";import{GraphStateSupport as V}from"./framework/graph-state-support.js";import{GRAPH_END_NODE as w,createGraphStateAnnotation as z}from"./framework/graph-state.js";import{GraphRegistry as J}from"./framework/graph-registry.js";import{GraphEngine as X}from"./framework/graph-engine.js";import{ConfigManager as K}from"./framework/config-manager.js";import{StateGraphExt as $}from"./framework/state-graph-ext.js";import{TerminateSessionNode as oe}from"./framework/terminate-session.node.js";import{SessionLogError as te,SessionLogDecision as se,SessionLogWarning as ie,createSessionLogs as ne,drainSessionLogs as ae,restoreSessionLogs as me,withSessionLogs as pe}from"./framework/session-log.js";import{ProviderFileManager as Ee}from"./framework/llm-file.js";import{SessionManager as xe,SessionTurnError as Le,SESSION_BUSY as le,SESSION_CONFLICT as de,SESSION_COMPLETED as ge,SESSION_DOCUMENT_VERSION as De,MemorySessionDocumentContainer as Te,sessionTurnLeaseMs as Re,sessionRevision as _e,isLiveSessionTurn as ce,matchesSessionWritePredicate as Ce}from"./framework/persistence/session-manager.js";import{MongoDbSessionDocumentContainer as ue}from"./framework/persistence/mongodb-session-document.container.js";import{SqliteSessionDocumentContainer as Ne}from"./framework/persistence/sqlite-session-document.container.js";import{CosmosSessionDocumentContainer as Ie}from"./framework/persistence/cosmos-session-document.container.js";import{mergeNodeStates as Pe,replaceNodeStates as he}from"./framework/node-state.js";import{LangChainLlmGateway as ye}from"./framework/langchain-llm-gateway.js";import{ModelProvider as Fe}from"./framework/model-provider.js";import{langChainModelInitialization as ke}from"./framework/langchain-provider.adapter.js";import{GRAPH_LLM_PROVIDERS as Be,GRAPH_LLM_FAMILIES as be,GRAPH_LLM_CAPABILITIES as Ve,BUILT_IN_MODEL_CATALOG as We,GraphLlm as we,ModelCatalog as ze,ModelProviderRegistry as qe}from"./framework/graph-llm.config.js";import{addTokenUsage as Qe,emptyTokenUsage as Xe,modelExecution as je,normalizeTokenUsage as Ke,tokenUsageFromMessage as Ze}from"./framework/token-usage.js";import{DecisionNode as eo}from"./framework/decision/decision-node.js";import{DecisionRunner as ro}from"./framework/decision/decision-runner.js";import{DecisionProvider as so,DecisionProviderRegistry as io}from"./framework/decision/decision-provider.js";import{TypeSafeClassifierAdapter as ao}from"./framework/decision/typesafe-provider.js";import{DecisionConfigurationError as po,DecisionTimeoutError as So,DecisionValidationError as Eo,DEFAULT_DECISION_OPTIONS as fo,addDecisionUsage as xo,decisionUsage as Lo,emptyDecisionUsage as lo,normalizeDecisionUsage as go,resolveDecisionOptions as Do}from"./framework/decision/decision-types.js";import{assertJsonCompatible as Ro,validateDecisionQuestions as _o,validateDecisionResult as co}from"./framework/decision/decision-validation.js";import{retryWithModel as Mo,LlmResponseBlockedError as uo,LlmSetupError as Ao}from"./framework/llm-lifecycle.js";export{We as BUILT_IN_MODEL_CATALOG,s as BaseGraph,K as ConfigManager,Ie as CosmosSessionDocumentContainer,fo as DEFAULT_DECISION_OPTIONS,D as DEFAULT_EMPTY_HISTORY_SEED,T as DEFAULT_EMPTY_RESPONSE_RECOVERY,g as DEFAULT_LLM_POLICY,R as DEFAULT_MAX_AGENT_ROUNDS,po as DecisionConfigurationError,eo as DecisionNode,so as DecisionProvider,io as DecisionProviderRegistry,ro as DecisionRunner,So as DecisionTimeoutError,Eo as DecisionValidationError,_ as EmptyModelResponseError,w as GRAPH_END_NODE,Ve as GRAPH_LLM_CAPABILITIES,be as GRAPH_LLM_FAMILIES,Be as GRAPH_LLM_PROVIDERS,n as GRAPH_NODE_CLASS,r as GraphContextChannel,X as GraphEngine,we as GraphLlm,a as GraphNode,m as GraphNodeRuntime,J as GraphRegistry,V as GraphStateSupport,x as LLM_GATEWAY_FACTORY,ye as LangChainLlmGateway,E as LlmNode,uo as LlmResponseBlockedError,d as LlmRunner,Ao as LlmSetupError,Te as MemorySessionDocumentContainer,ze as ModelCatalog,Fe as ModelProvider,qe as ModelProviderRegistry,ue as MongoDbSessionDocumentContainer,Ee as ProviderFileManager,le as SESSION_BUSY,ge as SESSION_COMPLETED,de as SESSION_CONFLICT,De as SESSION_DOCUMENT_VERSION,se as SessionLogDecision,te as SessionLogError,ie as SessionLogWarning,xe as SessionManager,Le as SessionTurnError,Ne as SqliteSessionDocumentContainer,$ as StateGraphExt,oe as TerminateSessionNode,p as Tool,ao as TypeSafeClassifierAdapter,xo as addDecisionUsage,Qe as addTokenUsage,c as assertEmptyResponseRetries,Ro as assertJsonCompatible,L as assertLlmTimeoutMs,C as assertMaxAgentRounds,z as createGraphStateAnnotation,ne as createSessionLogs,I as currentTurnContext,G as currentTurnSignal,Lo as decisionUsage,u as describeStopReason,U as direct,y as directTo,ae as drainSessionLogs,lo as emptyDecisionUsage,Xe as emptyTokenUsage,F as fanout,v as finish,Y as go,ce as isLiveSessionTurn,A as isRetryableStopReason,k as isToolResponse,ke as langChainModelInitialization,Ce as matchesSessionWritePredicate,Pe as mergeNodeStates,je as modelExecution,N as modelStopReason,go as normalizeDecisionUsage,Ke as normalizeTokenUsage,he as replaceNodeStates,Do as resolveDecisionOptions,me as restoreSessionLogs,Mo as retryWithModel,_e as sessionRevision,Re as sessionTurnLeaseMs,H as stay,B as taskResult,Ze as tokenUsageFromMessage,_o as validateDecisionQuestions,co as validateDecisionResult,pe as withSessionLogs,P as withTurnContext};
1
+ import{Prompt as r}from"./framework/prompt.js";import{GraphContextChannel as s}from"./framework/graph-context.js";import{RunNodeBatchError as i}from"./framework/run-node.js";import{BaseGraph as m}from"./framework/base-graph.js";import{GRAPH_NODE_CLASS as S,GraphNode as E,GraphNodeRuntime as f,Tool as x}from"./framework/graph-node.js";import{LlmNode as d}from"./framework/llm-node.js";import{LLM_GATEWAY_FACTORY as g,assertLlmTimeoutMs as D}from"./framework/llm-gateway.js";import{LlmRunner as T,DEFAULT_LLM_POLICY as _,DEFAULT_EMPTY_HISTORY_SEED as c,DEFAULT_EMPTY_RESPONSE_RECOVERY as u,DEFAULT_MAX_AGENT_ROUNDS as C,EmptyModelResponseError as M,assertEmptyResponseRetries as A,assertMaxAgentRounds as N}from"./framework/llm-runner.js";import{describeStopReason as I,isRetryableStopReason as P,modelStopReason as h}from"./framework/model-stop-reason.js";import{currentTurnContext as U,currentTurnSignal as y,withTurnContext as v}from"./framework/turn-context.js";import{direct as Y,directTo as k,finish as B,fanout as H,go as b,isToolResponse as V,stay as W,taskResult as w}from"./framework/tool-response.js";import{GraphStateSupport as q}from"./framework/graph-state-support.js";import{GRAPH_END_NODE as Q,createGraphStateAnnotation as X}from"./framework/graph-state.js";import{GraphRegistry as K}from"./framework/graph-registry.js";import{GraphEngine as $}from"./framework/graph-engine.js";import{ConfigManager as eo}from"./framework/config-manager.js";import{StateGraphExt as to}from"./framework/state-graph-ext.js";import{TerminateSessionNode as no}from"./framework/terminate-session.node.js";import{SessionLogError as ao,SessionLogDecision as mo,SessionLogWarning as po,createSessionLogs as So,drainSessionLogs as Eo,restoreSessionLogs as fo,withSessionLogs as xo}from"./framework/session-log.js";import{ProviderFileManager as lo}from"./framework/llm-file.js";import{SessionManager as Do,SessionTurnError as Ro,SESSION_BUSY as To,SESSION_CONFLICT as _o,SESSION_COMPLETED as co,SESSION_DOCUMENT_VERSION as uo,MemorySessionDocumentContainer as Co,sessionTurnLeaseMs as Mo,sessionRevision as Ao,isLiveSessionTurn as No,matchesSessionWritePredicate as Oo}from"./framework/persistence/session-manager.js";import{MongoDbSessionDocumentContainer as Po}from"./framework/persistence/mongodb-session-document.container.js";import{SqliteSessionDocumentContainer as Go}from"./framework/persistence/sqlite-session-document.container.js";import{CosmosSessionDocumentContainer as yo}from"./framework/persistence/cosmos-session-document.container.js";import{mergeNodeStates as Fo,replaceNodeStates as Yo}from"./framework/node-state.js";import{LangChainLlmGateway as Bo}from"./framework/langchain-llm-gateway.js";import{ModelProvider as bo}from"./framework/model-provider.js";import{langChainModelInitialization as Wo}from"./framework/langchain-provider.adapter.js";import{GRAPH_LLM_PROVIDERS as zo,GRAPH_LLM_FAMILIES as qo,GRAPH_LLM_CAPABILITIES as Jo,BUILT_IN_MODEL_CATALOG as Qo,GraphLlm as Xo,ModelCatalog as jo,ModelProviderRegistry as Ko}from"./framework/graph-llm.config.js";import{addTokenUsage as $o,emptyTokenUsage as oe,modelExecution as ee,normalizeTokenUsage as re,tokenUsageFromMessage as te}from"./framework/token-usage.js";import{DecisionNode as ne}from"./framework/decision/decision-node.js";import{DecisionRunner as ae}from"./framework/decision/decision-runner.js";import{DecisionProvider as pe,DecisionProviderRegistry as Se}from"./framework/decision/decision-provider.js";import{TypeSafeClassifierAdapter as fe}from"./framework/decision/typesafe-provider.js";import{DecisionConfigurationError as Le,DecisionTimeoutError as de,DecisionValidationError as le,DEFAULT_DECISION_OPTIONS as ge,addDecisionUsage as De,decisionUsage as Re,emptyDecisionUsage as Te,normalizeDecisionUsage as _e,resolveDecisionOptions as ce}from"./framework/decision/decision-types.js";import{assertJsonCompatible as Ce,validateDecisionQuestions as Me,validateDecisionResult as Ae}from"./framework/decision/decision-validation.js";import{retryWithModel as Oe,LlmResponseBlockedError as Ie,LlmSetupError as Pe}from"./framework/llm-lifecycle.js";export{Qo as BUILT_IN_MODEL_CATALOG,m as BaseGraph,eo as ConfigManager,yo as CosmosSessionDocumentContainer,ge as DEFAULT_DECISION_OPTIONS,c as DEFAULT_EMPTY_HISTORY_SEED,u as DEFAULT_EMPTY_RESPONSE_RECOVERY,_ as DEFAULT_LLM_POLICY,C as DEFAULT_MAX_AGENT_ROUNDS,Le as DecisionConfigurationError,ne as DecisionNode,pe as DecisionProvider,Se as DecisionProviderRegistry,ae as DecisionRunner,de as DecisionTimeoutError,le as DecisionValidationError,M as EmptyModelResponseError,Q as GRAPH_END_NODE,Jo as GRAPH_LLM_CAPABILITIES,qo as GRAPH_LLM_FAMILIES,zo as GRAPH_LLM_PROVIDERS,S as GRAPH_NODE_CLASS,s as GraphContextChannel,$ as GraphEngine,Xo as GraphLlm,E as GraphNode,f as GraphNodeRuntime,K as GraphRegistry,q as GraphStateSupport,g as LLM_GATEWAY_FACTORY,Bo as LangChainLlmGateway,d as LlmNode,Ie as LlmResponseBlockedError,T as LlmRunner,Pe as LlmSetupError,Co as MemorySessionDocumentContainer,jo as ModelCatalog,bo as ModelProvider,Ko as ModelProviderRegistry,Po as MongoDbSessionDocumentContainer,r as Prompt,lo as ProviderFileManager,i as RunNodeBatchError,To as SESSION_BUSY,co as SESSION_COMPLETED,_o as SESSION_CONFLICT,uo as SESSION_DOCUMENT_VERSION,mo as SessionLogDecision,ao as SessionLogError,po as SessionLogWarning,Do as SessionManager,Ro as SessionTurnError,Go as SqliteSessionDocumentContainer,to as StateGraphExt,no as TerminateSessionNode,x as Tool,fe as TypeSafeClassifierAdapter,De as addDecisionUsage,$o as addTokenUsage,A as assertEmptyResponseRetries,Ce as assertJsonCompatible,D as assertLlmTimeoutMs,N as assertMaxAgentRounds,X as createGraphStateAnnotation,So as createSessionLogs,U as currentTurnContext,y as currentTurnSignal,Re as decisionUsage,I as describeStopReason,Y as direct,k as directTo,Eo as drainSessionLogs,Te as emptyDecisionUsage,oe as emptyTokenUsage,H as fanout,B as finish,b as go,No as isLiveSessionTurn,P as isRetryableStopReason,V as isToolResponse,Wo as langChainModelInitialization,Oo as matchesSessionWritePredicate,Fo as mergeNodeStates,ee as modelExecution,h as modelStopReason,_e as normalizeDecisionUsage,re as normalizeTokenUsage,Yo as replaceNodeStates,ce as resolveDecisionOptions,fo as restoreSessionLogs,Oe as retryWithModel,Ao as sessionRevision,Mo as sessionTurnLeaseMs,W as stay,w as taskResult,te as tokenUsageFromMessage,Me as validateDecisionQuestions,Ae as validateDecisionResult,xo as withSessionLogs,v as withTurnContext};
@@ -1,4 +1,6 @@
1
+ export { Prompt } from "../../src/framework/prompt.js";
1
2
  export { GraphContextChannel, type DeepReadonly } from "../../src/framework/graph-context.js";
3
+ export { RunNodeBatchError, type RunNodeTarget, type RunNodeArgument, type RunNodeRequest, type RunNodeResult, type RunNodeResults, type RunNodeOutcome, type RunNodeFailure, type RunNodeSettlement, } from "../../src/framework/run-node.js";
2
4
  export { BaseGraph, type GraphDefinition, type GraphNodeConstructor, type GraphSchemaMigration, type HistorySpace, } from "../../src/framework/base-graph.js";
3
5
  export { GRAPH_NODE_CLASS, GraphNode, GraphNodeRuntime, Tool, type EmptyModelResponseContext, type GraphNodeUpdate, type GraphNodeResponse, type GraphNodeResult, type InvalidJsonResponseContext, type ToolDefinition, type ToolInput, type GraphNodeLocalState, type GraphNodeTarget, type NodeInvocationOptions, } from "../../src/framework/graph-node.js";
4
6
  export { LlmNode, type LlmNodeRunResult, type LlmNodeResponse, type LlmNodeExitContext, type LlmNodeExitOutcome, type MessageTypes, } from "../../src/framework/llm-node.js";
@@ -14,6 +14,7 @@ import type { ModelStopReason } from "./model-stop-reason.js";
14
14
  import { GRAPH_NODE_LOCAL_STATE, type GraphNodeLocalState, type GraphNodeTarget, type GraphNodeUpdate } from "./node-outcome.js";
15
15
  import { type ToolResponse } from "./tool-response.js";
16
16
  import { type NodeInvocationOptions } from "./node-invocation.js";
17
+ import { type RunNodeArgument, type RunNodeResults, type RunNodeTarget, type RunNodeOutcome } from "./run-node.js";
17
18
  export type { NodeInvocationOptions } from "./node-invocation.js";
18
19
  import { type DecisionConversation, type DecisionErrorContext, type DecisionOptions, type DecisionProviderAdapter, type ResolvedDecisionOptions } from "./decision/decision-types.js";
19
20
  export { GRAPH_NODE_LOCAL_STATE, type GraphNodeLocalState, type GraphNodeTarget, type GraphNodeUpdate, } from "./node-outcome.js";
@@ -45,6 +46,8 @@ export declare abstract class GraphNode<State extends GraphState, LocalState ext
45
46
  readonly id: string;
46
47
  constructor(llmGateway: LlmGateway, runtime: GraphNodeRuntime<State>);
47
48
  protected get graph(): GraphNodeRuntime<State>;
49
+ protected runNode<const Arguments extends readonly [RunNodeArgument, ...RunNodeArgument[]]>(...targets: Arguments): Promise<RunNodeResults<Arguments>>;
50
+ protected getRunNodeInput<Input>(): DeepReadonly<Input> | undefined;
48
51
  abstract getPrompt(state: State): string;
49
52
  defineTool(): readonly ToolDefinition[];
50
53
  getLlmConfig(): GraphLlmConfigOverride;
@@ -56,6 +59,7 @@ export declare abstract class GraphNode<State extends GraphState, LocalState ext
56
59
  protected onInvalidJsonResponse(context: InvalidJsonResponseContext<State>): GraphNodeUpdate<State> | Promise<GraphNodeUpdate<State>>;
57
60
  protected onEmptyModelResponse(context: EmptyModelResponseContext<State>): string | Promise<string>;
58
61
  readonly invoke: (state: State, options?: NodeInvocationOptions) => Promise<GraphNodeResult<State>>;
62
+ private withChildPublication;
59
63
  protected finalizeNodeResult(_result: GraphNodeResult<State>, _update: GraphNodeUpdate<State>): void | Promise<void>;
60
64
  private validatePublication;
61
65
  protected managesLlmExecution(): boolean;
@@ -94,6 +98,16 @@ export declare class GraphNodeRuntime<State extends GraphState> extends GraphSta
94
98
  private readonly decisionErrorHandler?;
95
99
  readonly llmLifecycle?: GraphLlmLifecycle | undefined;
96
100
  private readonly assertContextChannel?;
101
+ private runNodeResolver?;
102
+ attachRunNodeResolver(resolve: (Node: RunNodeTarget) => GraphNode<State>): void;
103
+ runNode(targets: readonly RunNodeArgument[]): Promise<readonly Readonly<{
104
+ nodeId: string;
105
+ state: Record<string, unknown>;
106
+ outcome: RunNodeOutcome;
107
+ usage: import("./token-usage.js").TokenUsage;
108
+ decisionUsage: import("./decision/decision-types.js").DecisionUsage;
109
+ }>[]>;
110
+ recordRunNodeOutcome(outcome: RunNodeOutcome): void;
97
111
  private readonly tools;
98
112
  constructor(endNode: State["currentNode"], defaultLlmConfig: GraphLlmConfig, historySpaces?: Readonly<Record<string, string>>, responseMode?: "chat" | "json", maxAgentRounds?: number, llmPolicy?: LlmPolicy, decisionOptions?: DecisionOptions, decisionErrorHandler?: ((context: DecisionErrorContext<State>) => GraphNodeResponse<State> | null | Promise<GraphNodeResponse<State> | null>) | undefined, llmLifecycle?: GraphLlmLifecycle | undefined, assertContextChannel?: (() => void) | undefined);
99
113
  llmCallOptions(): LlmCallOptions;
@@ -8,6 +8,7 @@ import { type ToolResponse } from "./tool-response.js";
8
8
  import { type TokenUsage } from "./token-usage.js";
9
9
  import type { LlmErrorResponse, LlmLifecycle } from "./llm-lifecycle.js";
10
10
  import type { MessageTypes } from "./message-types.js";
11
+ import { RUN_NODE_OUTPUT } from "./run-node.js";
11
12
  export type { MessageTypes } from "./message-types.js";
12
13
  export type LlmNodeRunResult = LlmRunResult;
13
14
  export type LlmNodeResponse = void | string | ToolResponse;
@@ -39,6 +40,7 @@ export type LlmNodeExitContext<State extends GraphState, Output = string> = Read
39
40
  usage: TokenUsage;
40
41
  }>;
41
42
  export declare abstract class LlmNode<State extends GraphState, LocalState extends object = Record<string, unknown>, Output = string> extends LlmNodeBase<State, LocalState> {
43
+ readonly [RUN_NODE_OUTPUT]: Output;
42
44
  private readonly exitOutcomes;
43
45
  protected onEnter(langMessage: MessageTypes | null | undefined, _priorNode?: string): MessageTypes | null | undefined | Promise<MessageTypes | null | undefined>;
44
46
  protected llmLifecycle(): LlmLifecycle;
@@ -1,13 +1,36 @@
1
1
  import type { BaseMessage } from "@langchain/core/messages";
2
2
  import type { GraphState } from "./graph-state.js";
3
3
  import { type DeepReadonly, type JsonObject } from "./graph-context.js";
4
+ import { type TokenUsage } from "./token-usage.js";
5
+ import { type DecisionUsage } from "./decision/decision-types.js";
6
+ import type { RunNodeOutcome } from "./run-node.js";
4
7
  export type NodeInvocationOptions = Readonly<{
5
8
  mode?: "conversation" | "internal";
6
9
  }>;
10
+ export type RunNodeExecution = {
11
+ owner: object;
12
+ nodeId: string;
13
+ caller: string;
14
+ input?: unknown;
15
+ outcome: RunNodeOutcome;
16
+ usage: TokenUsage;
17
+ decisionUsage: DecisionUsage;
18
+ };
19
+ export declare function withRunNodeExecution<T>(scope: RunNodeExecution, run: () => Promise<T>): Promise<T>;
20
+ export declare function recordRunNodeOutcome(owner: object, outcome: RunNodeOutcome): void;
21
+ export declare function observeRunNodeUsage(usage: TokenUsage): void;
22
+ export declare function observeRunNodeDecisionUsage(usage: DecisionUsage): void;
23
+ export declare function recordRunNodeUsage(owner: object, update: Partial<GraphState>): void;
24
+ export declare function runNodeInput<Input>(owner: object): DeepReadonly<Input> | undefined;
25
+ export declare function reserveRunNodeTargets(owner: object, ids: readonly string[]): () => void;
26
+ export declare function currentInvocationNode(owner: object): string;
27
+ export declare function joinRunNodeResults(owner: object, nodes: Record<string, Record<string, unknown>>, usage: TokenUsage, decisionUsage: DecisionUsage): void;
28
+ export declare function invocationChildUpdate<State extends GraphState>(owner: object): Partial<State>;
7
29
  export declare function hasNodeInvocation(owner: object): boolean;
8
30
  export declare function withNodeInvocation<State extends GraphState, Result>(owner: object, nodeId: string, state: State, run: () => Promise<Result>, options?: NodeInvocationOptions, managedLlm?: boolean): Promise<Result>;
9
31
  export declare function invocationMode(owner: object): "conversation" | "internal";
10
32
  export declare function invocationIsLocalOnly(owner: object): boolean;
33
+ export declare function invocationIsBatchChild(owner: object): boolean;
11
34
  export declare function assertInvocationWrite(owner: object, nodeId?: string): void;
12
35
  export declare function invocationNodeId(owner: object): string;
13
36
  export declare function invocationPriorNode(owner: object): string | undefined;
@@ -0,0 +1,8 @@
1
+ export declare class Prompt {
2
+ private static cache;
3
+ static file(filePath: string): string;
4
+ private static getCallerDir;
5
+ static set(prompt: string, key: string, value: string): string;
6
+ static replace(template: string, values: Record<string, string>): string;
7
+ static replace2(template: string, values: Record<string, any>): string;
8
+ }
@@ -0,0 +1,76 @@
1
+ import type { GraphNode } from "./graph-node.js";
2
+ import type { GraphNodeClass } from "./state-graph-ext.js";
3
+ import type { GraphNodeLocalState, GraphNodeTarget } from "./node-outcome.js";
4
+ import type { NodeStateValue } from "./node-state.js";
5
+ import type { GraphState } from "./graph-state.js";
6
+ import { type DeepReadonly, type JsonValue } from "./graph-context.js";
7
+ import { type TokenUsage } from "./token-usage.js";
8
+ import { type DecisionUsage } from "./decision/decision-types.js";
9
+ export declare const RUN_NODE_OUTPUT: unique symbol;
10
+ export type RunNodeTarget = GraphNodeClass & GraphNodeTarget;
11
+ export type RunNodeRequest<Node extends RunNodeTarget = RunNodeTarget> = Readonly<{
12
+ node: Node;
13
+ input?: JsonValue;
14
+ }>;
15
+ export type RunNodeArgument = RunNodeTarget | RunNodeRequest;
16
+ export type RunNodeOutcome<Output = unknown> = Readonly<{
17
+ kind: "state";
18
+ }> | Readonly<{
19
+ kind: "reply";
20
+ response: string;
21
+ }> | Readonly<{
22
+ kind: "taskResult";
23
+ value: Output;
24
+ }>;
25
+ type TargetOf<Argument extends RunNodeArgument> = Argument extends RunNodeRequest<infer Node> ? Node : Argument;
26
+ type OutcomeOf<Node extends RunNodeTarget> = Node["prototype"] extends {
27
+ readonly [RUN_NODE_OUTPUT]: infer Output;
28
+ } ? Exclude<RunNodeOutcome<Output>, {
29
+ kind: "state";
30
+ }> : Readonly<{
31
+ kind: "state";
32
+ }>;
33
+ export type RunNodeResult<Node extends RunNodeTarget = RunNodeTarget> = Readonly<{
34
+ nodeId: string;
35
+ state: DeepReadonly<NodeStateValue<GraphNodeLocalState<Node>>>;
36
+ outcome: DeepReadonly<OutcomeOf<Node>>;
37
+ usage: Readonly<TokenUsage>;
38
+ decisionUsage: Readonly<DecisionUsage>;
39
+ }>;
40
+ export type RunNodeResults<Arguments extends readonly RunNodeArgument[]> = {
41
+ readonly [Index in keyof Arguments]: RunNodeResult<Extract<TargetOf<Arguments[Index]>, RunNodeTarget>>;
42
+ };
43
+ export type RunNodeFailure = Readonly<{
44
+ nodeId: string;
45
+ status: "rejected";
46
+ error: Readonly<{
47
+ name: string;
48
+ message: string;
49
+ }>;
50
+ usage: Readonly<TokenUsage>;
51
+ decisionUsage: Readonly<DecisionUsage>;
52
+ }>;
53
+ type Success = Readonly<{
54
+ nodeId: string;
55
+ state: Record<string, unknown>;
56
+ outcome: RunNodeOutcome;
57
+ usage: TokenUsage;
58
+ decisionUsage: DecisionUsage;
59
+ }>;
60
+ export type RunNodeSettlement = RunNodeFailure | DeepReadonly<Success & {
61
+ status: "fulfilled";
62
+ }>;
63
+ export declare class RunNodeBatchError extends Error {
64
+ readonly results: readonly RunNodeSettlement[];
65
+ readonly usage: Readonly<TokenUsage>;
66
+ readonly decisionUsage: Readonly<DecisionUsage>;
67
+ constructor(results: readonly RunNodeSettlement[]);
68
+ }
69
+ export type RunNodeHost<State extends GraphState> = Readonly<{
70
+ owner: object;
71
+ graphState(): State;
72
+ resolve(Node: RunNodeTarget): GraphNode<State>;
73
+ }>;
74
+ export declare function runNodeTasks<State extends GraphState>(host: RunNodeHost<State>, requests: readonly RunNodeArgument[]): Promise<readonly Success[]>;
75
+ export declare function freezeRunNodeValue<Value>(value: Value): Value;
76
+ export {};
@@ -32,6 +32,7 @@ export type DecisionAuditInput = {
32
32
  requestId?: string;
33
33
  usage: DecisionUsage;
34
34
  };
35
+ export declare function currentSessionLogs(): SessionLogs | undefined;
35
36
  export declare function createSessionLogs(): SessionLogs;
36
37
  export declare function drainSessionLogs(logs: SessionLogs): SessionLogs;
37
38
  export declare function restoreSessionLogs(logs: SessionLogs, drained: SessionLogs): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picoflow/ezgraph",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "Provider-neutral graph primitives built on LangGraph and LangChain.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",