@picoflow/ezgraph 0.0.13 → 0.0.14
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 +40 -0
- package/dist/framework/base-graph.js +1 -1
- package/dist/framework/decision/decision-node.js +1 -1
- package/dist/framework/graph-engine.js +1 -1
- package/dist/framework/graph-node.js +1 -1
- package/dist/framework/langchain-provider.adapter.js +1 -1
- package/dist/framework/llm-lifecycle.js +1 -1
- package/dist/framework/llm-node.js +1 -1
- package/dist/framework/llm-runner.js +1 -0
- package/dist/framework/persistence/session-manager.js +1 -1
- package/dist/framework/state-graph-ext.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/npmlib/src/index.d.ts +2 -2
- package/dist/types/src/framework/base-graph.d.ts +2 -2
- package/dist/types/src/framework/decision/decision-node.d.ts +2 -2
- package/dist/types/src/framework/graph-node.d.ts +7 -7
- package/dist/types/src/framework/llm-lifecycle.d.ts +3 -3
- package/dist/types/src/framework/llm-node.d.ts +4 -4
- package/dist/types/src/framework/{conversation-runner.d.ts → llm-runner.d.ts} +7 -7
- package/package.json +1 -1
- package/dist/framework/conversation-runner.js +0 -1
package/README.md
CHANGED
|
@@ -224,6 +224,31 @@ alternate in the same recovery sequence is rejected. Completed tool effects
|
|
|
224
224
|
and their feedback remain in place; newly generated tool calls still execute
|
|
225
225
|
normally, so applications should keep side effects idempotent.
|
|
226
226
|
|
|
227
|
+
```ts
|
|
228
|
+
import {
|
|
229
|
+
LlmNode, ModelCatalog, retryWithModel,
|
|
230
|
+
type GraphState, type LlmErrorContext,
|
|
231
|
+
} from "@picoflow/ezgraph";
|
|
232
|
+
|
|
233
|
+
class AlternateSupportNode extends LlmNode<GraphState> {
|
|
234
|
+
getPrompt(): string { return "Help the customer with their request."; }
|
|
235
|
+
|
|
236
|
+
override async onLlmError(context: LlmErrorContext) {
|
|
237
|
+
if (context.model === "openai:gpt-4o-mini") {
|
|
238
|
+
return retryWithModel(
|
|
239
|
+
ModelCatalog.model("openai:gpt-4.1", { retries: 0, temperature: 0.2 }),
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
return "The service is unavailable. Please try again.";
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
`retryWithModel()` validates the selected model and parameters immediately.
|
|
248
|
+
The runner also validates manually constructed recovery results before calling
|
|
249
|
+
the gateway. Cancellation and the graph's per-call timeout apply to the alternate;
|
|
250
|
+
provider blocks continue through `onLlmBlocked()`.
|
|
251
|
+
|
|
227
252
|
For conversational nodes, `params.retries` remains an **additional** retry
|
|
228
253
|
count: `2` allows three attempts for invocation errors or rejected candidates.
|
|
229
254
|
The runner supplies `retries: 0` to each gateway call to prevent nested SDK
|
|
@@ -237,6 +262,21 @@ and direct gateway calls retain their existing behavior, including
|
|
|
237
262
|
`GraphNode.onEmptyModelResponse()`. Typed `DecisionNode` validation and
|
|
238
263
|
`onDecisionError()` remain separate.
|
|
239
264
|
|
|
265
|
+
The shared loop is exported as `LlmRunner` from `llm-runner.ts`. When migrating
|
|
266
|
+
from `ConversationRunner`, update imports and subclasses to the new names:
|
|
267
|
+
|
|
268
|
+
| Previous name | Current name |
|
|
269
|
+
| --- | --- |
|
|
270
|
+
| `ConversationRunner` | `LlmRunner` |
|
|
271
|
+
| `ConversationRunResult` | `LlmRunResult` |
|
|
272
|
+
| `ConversationPolicy` / `DEFAULT_CONVERSATION_POLICY` | `LlmPolicy` / `DEFAULT_LLM_POLICY` |
|
|
273
|
+
| `ConversationLlmLifecycle` | `LlmLifecycle` |
|
|
274
|
+
| `runConversation()` | `runLlm()` |
|
|
275
|
+
| `conversationLlmLifecycle()` | `llmLifecycle()` |
|
|
276
|
+
| `conversationPolicy` | `llmPolicy` |
|
|
277
|
+
|
|
278
|
+
These are API renames; the previous names are no longer exported.
|
|
279
|
+
|
|
240
280
|
## Add typed decisions with Jev
|
|
241
281
|
|
|
242
282
|
EZGraph supports [Jev](https://typesafe.ai/) through LangChain's optional
|
|
@@ -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
|
|
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 +1 @@
|
|
|
1
|
-
var D=Object.defineProperty;var r=(a,o)=>D(a,"name",{value:o,configurable:!0});import{GraphNode as m}from"../graph-node.js";import{currentTurnSignal as v}from"../turn-context.js";import{DecisionRunner as C}from"./decision-runner.js";import{assertJsonCompatible as w,validateDecisionQuestions as g}from"./decision-validation.js";class y extends m{static{r(this,"DecisionNode")}getPrompt(o){return""}getDecisionFacts(o){return{}}getDecisionConfig(){return{}}onDecisionError(o){return null}async run(o){this.assertNoChatConfiguration();const s=v();s?.throwIfAborted();const h=this.graph.resolveDecisionOptions(this.getDecisionConfig()),f=this.graph.resolveDecisionProvider(h.provider),l=structuredClone(this.defineQuestions(o));g(l);const u=this.getPrompt(o).trim(),p=Object.fromEntries(Object.entries(l).map(([e,t])=>[e,{...t,...u?{instructions:[u,...t.instructions===void 0?[]:[t.instructions]]}:{}}]));g(p);const n=this.graph.getConversation(this.historySpace()),c=structuredClone(this.getDecisionFacts(o));if("request"in c||"priorRequests"in c)throw new Error("getDecisionFacts() cannot replace framework-owned request or priorRequests.");const d={...c,request:n.request,priorRequests:[...n.priorRequests]};return w(d,"Decision input"),C.run({nodeId:this.id,state:o,conversation:n,providerState:d,questions:p,provider:f,options:h,callerSignal:s,onDecision:r(async(e,t,i)=>this.resolveNodeResponse(await this.onDecision(e,t,i)),"onDecision"),onError:r(async e=>{const i=await this.onDecisionError(e)??await this.graph.handleDecisionError(e);if(i===null)throw e.error;return this.resolveNodeResponse(i)},"onError")})}validateTools(){this.assertNoChatConfiguration();const o=this.graph.resolveDecisionOptions(this.getDecisionConfig());this.graph.resolveDecisionProvider(o.provider)}assertNoChatConfiguration(){const o=this.defineTool(),s=this.obtainTools();if(o.length>0||s.length>0)throw new Error("DecisionNode cannot configure chat tools.");if(Object.keys(this.getLlmConfig()).length>0)throw new Error("DecisionNode uses getDecisionConfig(), not a chat model configuration.")}usesChatModel(){return!1}async
|
|
1
|
+
var D=Object.defineProperty;var r=(a,o)=>D(a,"name",{value:o,configurable:!0});import{GraphNode as m}from"../graph-node.js";import{currentTurnSignal as v}from"../turn-context.js";import{DecisionRunner as C}from"./decision-runner.js";import{assertJsonCompatible as w,validateDecisionQuestions as g}from"./decision-validation.js";class y extends m{static{r(this,"DecisionNode")}getPrompt(o){return""}getDecisionFacts(o){return{}}getDecisionConfig(){return{}}onDecisionError(o){return null}async run(o){this.assertNoChatConfiguration();const s=v();s?.throwIfAborted();const h=this.graph.resolveDecisionOptions(this.getDecisionConfig()),f=this.graph.resolveDecisionProvider(h.provider),l=structuredClone(this.defineQuestions(o));g(l);const u=this.getPrompt(o).trim(),p=Object.fromEntries(Object.entries(l).map(([e,t])=>[e,{...t,...u?{instructions:[u,...t.instructions===void 0?[]:[t.instructions]]}:{}}]));g(p);const n=this.graph.getConversation(this.historySpace()),c=structuredClone(this.getDecisionFacts(o));if("request"in c||"priorRequests"in c)throw new Error("getDecisionFacts() cannot replace framework-owned request or priorRequests.");const d={...c,request:n.request,priorRequests:[...n.priorRequests]};return w(d,"Decision input"),C.run({nodeId:this.id,state:o,conversation:n,providerState:d,questions:p,provider:f,options:h,callerSignal:s,onDecision:r(async(e,t,i)=>this.resolveNodeResponse(await this.onDecision(e,t,i)),"onDecision"),onError:r(async e=>{const i=await this.onDecisionError(e)??await this.graph.handleDecisionError(e);if(i===null)throw e.error;return this.resolveNodeResponse(i)},"onError")})}validateTools(){this.assertNoChatConfiguration();const o=this.graph.resolveDecisionOptions(this.getDecisionConfig());this.graph.resolveDecisionProvider(o.provider)}assertNoChatConfiguration(){const o=this.defineTool(),s=this.obtainTools();if(o.length>0||s.length>0)throw new Error("DecisionNode cannot configure chat tools.");if(Object.keys(this.getLlmConfig()).length>0)throw new Error("DecisionNode uses getDecisionConfig(), not a chat model configuration.")}usesChatModel(){return!1}async runLlm(o,s){throw new Error("DecisionNode does not run the conversational model loop.")}}export{y as DecisionNode};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const uI=f;(function(o,S){const ui={o:0xe0,S:0xdb,d:0xc1,T:0xb4},uq=f,d=o();while(!![]){try{const T=parseInt(uq(0xa0))/0x1+parseInt(uq(ui.o))/0x2+parseInt(uq(ui.S))/0x3+parseInt(uq(ui.d))/0x4+-parseInt(uq(0xce))/0x5+parseInt(uq(0xd6))/0x6+parseInt(uq(ui.T))/0x7*(-parseInt(uq(0xa3))/0x8);if(T===S)break;else d['push'](d['shift']());}catch(n){d['push'](d['shift']());}}}(u,0x8258d));var P=Object['defineProperty'],y=(o,S)=>P(o,uI(0xc5),{'value':S,'configurable':!0x0});import{HumanMessage as Q}from'@langchain/core/messages';function u(){const ur=['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'];u=function(){return ur;};return u();}function f(w,k){w=w-0x9d;const Q=u();let O=Q[w];if(f['pjzpNm']===undefined){var Y=function(I){const W='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let J='',v='';for(let s=0x0,P,p,t=0x0;p=I['charAt'](t++);~p&&(P=s%0x4?P*0x40+p:p,s++%0x4)?J+=String['fromCharCode'](0xff&P>>(-0x2*s&0x6)):0x0){p=W['indexOf'](p);}for(let C=0x0,a=J['length'];C<a;C++){v+='%'+('00'+J['charCodeAt'](C)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(v);};f['bOrkSb']=Y,f['wJSDQu']={},f['pjzpNm']=!![];}const M=Q[0x0],m=w+M,q=f['wJSDQu'][m];return!q?(O=f['bOrkSb'](O),f['wJSDQu'][m]=O):O=q,O;}import{randomUUID as Y}from'node:crypto';import{GraphRegistry as m,registeredGraphId as I,registeredGraphSchemaVersion as W}from'./graph-registry.js';import{LangChainLlmGateway as J}from'./langchain-llm-gateway.js';import{SessionLogError as v,createSessionLogs as s,drainSessionLogs as p,restoreSessionLogs as t,withSessionLogs as a}from'./session-log.js';import{withTurnContext as K}from'./turn-context.js';import{SessionManager as i,SessionTurnError as L,SESSION_BUSY as l,SESSION_COMPLETED as g}from'./persistence/session-manager.js';import{parseJsonObjectResponse as Z}from'./json-response.js';import{DecisionProviderRegistry as X}from'./decision/decision-provider.js';class M{static{y(this,'GraphEngine');}[uI(0xe1)]=new m();[uI(0x9f)];[uI(0xa4)];['decisionProviders'];[uI(0xe2)]=new Set();constructor(o={}){const uL={o:0xc8,S:0xcf,d:0xcf,T:0xa4,n:0xde},uW=uI;this[uW(0x9f)]=o[uW(uL.o)]??new i(),this[uW(uL.S)]=new X(o[uW(uL.d)]??[]),this['llmGatewayFactory']=o[uW(uL.T)]??(S=>new J(S,o[uW(0xd5)]?{'providers':o[uW(0xd5)]}:{})),this[uW(uL.n)](o['graphs']??[]);}static async[uI(0xca)](o={}){const ul={o:0xc0,S:0xc0,d:0xd5,T:0xcf},uJ=uI,S=await i[uJ(0xa2)](o['configManager']);return new M({'sessionManager':S,...o['llmGatewayFactory']?{'llmGatewayFactory':o[uJ(0xa4)]}:{},...o[uJ(ul.o)]?{'graphs':o[uJ(ul.S)]}:{},...o[uJ(ul.d)]?{'providers':o[uJ(0xd5)]}:{},...o[uJ(ul.T)]?{'decisionProviders':o['decisionProviders']}:{}});}[uI(0xde)](o){const uR={o:0xbe},uj={o:0x9e,S:0xd0},uv=uI,S=o[uv(uR.o)](d=>{const us=uv,T=new d(this[us(0xa4)](d[us(uj.o)]()[us(0xe3)]));return T[us(uj.S)]?.(n=>this['decisionProviders'][us(0xe7)](n)),T[us(0xba)],T;});return this[uv(0xe1)]['register'](S),this;}[uI(0xaa)](){return this['registry']['names']();}[uI(0xe5)](o){const uZ={o:0x9f},uP=uI;return this[uP(uZ.o)]['getSession'](w(o));}async[uI(0xb9)](o){const uX={o:0xcc,S:0xdd,d:0xab,T:0xa5,n:0xa6,c:0xe2,G:0xb5},ux={o:0x9f,S:0xac,d:0xb7,T:0xba,n:0xa9,c:0xa9,G:0xa8,r:0xeb,h:0xa8,b:0xea,D:0x9f,e:0xc4,u0:0xc2,u1:0xba,u2:0xba,u3:0xd7,u4:0xb1,u5:0xbc,u6:0xa1,u7:0xda,u8:0x9d,u9:0xe9,uu:0xdf},up=uI,S=this[up(0xe1)][up(0xb0)](o[up(0xe4)]);if(!S)return{'status':0x190,'body':{'success':!0x1,'completed':!0x0,'message':'Graph\x20\x27'+(o['graphName']??'')+up(uX.o)}};const T=typeof o[up(uX.S)]==up(0xc3)?o['userMessage'][up(uX.d)]():void 0x0;if(S[up(0xd8)]!==!0x1&&!T)return{'status':0x190,'body':{'success':!0x1,'completed':!0x1,'message':up(0xc7)}};let n;try{n=o[up(0xd2)]?w(o['sessionId']):Y();}catch(u0){return{'status':0x190,'body':{'success':!0x1,'completed':!0x1,'message':u0 instanceof Error?u0[up(0xaf)]:String(u0)}};}const c=I(S),G=W(S),h={'graphId':c,'graphSchemaVersion':G,'llmConfig':S['llmConfig']},b=s();if(this['inflightSessions']['has'](n))return this[up(0xd4)](n,l,up(uX.T)+n+up(uX.n));this[up(uX.c)]['add'](n);const D={'session':n,...o[up(0xb5)]===void 0x0?{}:{'signal':o[up(uX.G)]}};return this['withTurnScope'](D,b,async()=>{const ut=up;let u1=!0x0,u2,u3;try{const u4=Y(),u5=await this[ut(ux.o)][ut(ux.S)](n,u4,h);u2=u4,u3=u5[ut(0xd9)];const u6=u5[ut(ux.d)][ut(ux.T)][ut(0xc9)]?u5[ut(0xb7)]:void 0x0;u6&&u6[ut(0xba)][ut(0xa8)]!==G&&(u1=!0x1);const u7=u6?S[ut(ux.n)]?await S[ut(ux.c)](u6):u6:void 0x0;if(u7&&u7[ut(0xba)][ut(ux.G)]!==G)throw new Error(ut(ux.r)+c+ut(0xbd)+u7[ut(0xba)][ut(ux.h)]+ut(ux.b)+G+'.');u6&&u7&&u7['graph'][ut(0xa8)]!==u6[ut(0xba)][ut(ux.G)]&&await this[ut(ux.o)]['persistMigratedSession'](u7,{'owner':u4,'expectedRevision':u3}),u1=!0x0;const u8=u7?this[ut(ux.o)][ut(0xbf)](u7,c):void 0x0;if(u8?.[ut(0xa1)])return await this[ut(ux.D)][ut(0xc6)](n,u4,u3),this[ut(0xae)](S[ut(ux.e)],n);const u9={...T?S[ut(0xcd)](u8,new Q(T)):u8??{},'config':{...u8?.[ut(ux.u0)]??{},...o[ut(0xc2)]??{}},'inputConsumed':!0x1,'response':''};let uu;if(S['graph'][ut(0xd3)]){const uw=await S[ut(ux.u1)][ut(0xd3)](u9,{'streamMode':'values'});for await(const uf of uw){if(uu=uf,uu[ut(0xe6)]!==!0x0)continue;const uk=p(b);let uQ;try{uQ=await this['sessions']['saveState'](n,uu,h,uk,{'owner':u4,...u3===void 0x0?{}:{'expectedRevision':u3},'keepTurn':!0x0});}catch(uO){throw t(b,uk),uO;}u3=uQ['revision'];}}else uu=await S[ut(ux.u2)][ut(ux.u3)](u9);if(!uu)throw new Error('Graph\x20\x27'+c+ut(ux.u4));return await this[ut(ux.o)][ut(0xb2)](n,uu,h,b,{'owner':u4,...u3===void 0x0?{}:{'expectedRevision':u3}}),S[ut(0xc4)]===ut(ux.u5)?this[ut(0xdc)](n,uu[ut(0xcb)]):this['chatResult'](n,uu[ut(0xcb)],uu[ut(ux.u6)]);}catch(uY){if(uY instanceof L)return this['conflictResult'](n,uY[ut(ux.u7)],uY['message']);const uM=uY instanceof Error?uY['message']:String(uY);if(v({'chat_service':uM}),u2)try{await this[ut(0x9f)]['endFailedTurn'](n,u2,h,u1?b:void 0x0,u3);}catch(um){console[ut(ux.u8)](ut(ux.u9),um);}return{'status':0x190,'session':n,'body':{'success':!0x1,'completed':!0x1,'message':uM,'session':n}};}finally{this['inflightSessions'][ut(ux.uu)](n);}});}[uI(0xe8)](o,S,d){return K(o,()=>a(S,d));}async[uI(0xb3)](o){const uS={o:0xbb},uC=uI;if(!o)return{'status':0x190,'body':{'success':!0x1,'message':uC(uS.o)}};try{const S=w(o);return await this['sessions'][uC(0xb3)](S),{'status':0xc8,'body':{'success':!0x0,'session':S}};}catch(d){return{'status':0x190,'body':{'success':!0x1,'session':o,'message':d instanceof Error?d[uC(0xaf)]:String(d)}};}}async[uI(0xad)](){const ua=uI;await this[ua(0x9f)][ua(0xad)]();}['conflictResult'](o,S,d){return{'status':0x199,'session':o,'body':{'success':!0x1,'completed':!0x1,'message':d,'code':S,'session':o}};}[uI(0xae)](o,S){const un={o:0xd4},uB=uI,d='This\x20conversation\x20is\x20already\x20complete.';return o===uB(0xbc)?this[uB(un.o)](S,g,d):this['chatResult'](S,d,!0x0);}[uI(0xdc)](o,S){const uy=uI;return{'status':0xc8,'session':o,'contentType':uy(0xb6),'body':Z(S)};}[uI(0xb8)](o,S,d){return{'status':0xc8,'session':o,'body':{'success':!0x0,'completed':d,'message':S,'bot':S,'session':o}};}}function w(o){const uV={o:0xd1},uK=uI,S=o[uK(0xab)]();if(!/^[A-Za-z0-9_-]{1,128}$/[uK(uV.o)](S))throw new Error('SESSION_ID\x20must\x20be\x201-128\x20letters,\x20numbers,\x20underscores,\x20or\x20hyphens.');return S;}y(w,uI(0xa7));export{M as GraphEngine};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var E=Object.defineProperty;var i=(r,e)=>E(r,"name",{value:e,configurable:!0});import"reflect-metadata";import{AIMessage as p,HumanMessage as R}from"@langchain/core/messages";import{Command as c,END as f,isCommand as w}from"@langchain/langgraph";import{GraphLlm as u}from"./graph-llm.config.js";import{GraphStateSupport as T}from"./graph-state-support.js";import{ConversationRunner as O,DEFAULT_CONVERSATION_POLICY as H,DEFAULT_MAX_AGENT_ROUNDS as L,EmptyModelResponseError as $}from"./conversation-runner.js";import{currentTurnSignal as x}from"./turn-context.js";import{combineGraphNodeUpdates as A}from"./node-outcome.js";import{parseJsonObjectResponse as C}from"./json-response.js";import{stableClassId as g}from"./stable-id.js";import{SessionLogWarning as b}from"./session-log.js";import{isToolResponse as S,stay as G}from"./tool-response.js";import{invocationGraphState as I,hasNodeInvocation as k,invocationHistory as M,invocationNodeState as P,invocationUpdate as _,appendInvocationHistory as D,replaceInvocationNodeState as U,invocationContext as j,saveInvocationContext as J,replaceInvocationContext as q,saveInvocationNodeState as F,withNodeInvocation as z}from"./node-invocation.js";import{DecisionConfigurationError as V,resolveDecisionOptions as W}from"./decision/decision-types.js";import{GRAPH_NODE_LOCAL_STATE as ve}from"./node-outcome.js";const X=Symbol("GRAPH_NODE_CLASS"),y=Symbol("graph-node-tool-handlers");function ue(r){if(!r.trim())throw new Error("A tool handler requires a tool name.");return(e,t)=>{const o=Reflect.getOwnMetadata(y,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(y,o,e)}}i(ue,"Tool");class N{static{i(this,"GraphNode")}llmGateway;runtime;static[X]=!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=g(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 d=this.runtime.requireTool(n.toolName),s=K(t.args);if(!s.ok)return this.rejectToolCall(n.toolName,s.error);const a=d.schema.safeParse(s.value);if(!a.success)return this.rejectToolCall(n.toolName,Q(a.error));const h=a.data,l=this[n.methodName];if(!l)throw new Error(`Tool '${n.toolName}' is decorated on missing method '${String(n.methodName)}'.`);const m=await l.call(this,h,o,e);if(S(m))return m;throw new Error(`Tool '${n.toolName}' on '${this.id}' must return a ToolResponse.`)}rejectToolCall(e,t){return b({tool_call:t,node:this.id,tool:e}),G(JSON.stringify({accepted:!1,error:t}))}usesChatModel(){return!0}onInvalidJsonResponse(e){throw e.error}onEmptyModelResponse(e){throw new $(e.reason)}invoke=i(e=>this.runtime.withInvocation(this.id,e,async()=>{const t=this.resolveNodeResponse(await this.run(e)),o=B(t),n=await this.resolveJsonResponse(e,o);if(this.runtime.stageNodeEntries(n.nodes),n.context!==void 0&&this.runtime.stageContext(n.context),this.usesChatModel()){const s=this.runtime.resolveLlmConfig(this.getLlmConfig()),a=Y(s,this.runtime.resolveLlmConfig()),h=(e.nodes??{})[this.id];(!a||h?.model!==void 0)&&this.runtime.saveNode(this.id,{model:a?void 0:u.modelMetadata(s)})}const d=A(n,this.runtime.stagedUpdate());return w(t)?new c({update:d,...t.goto===void 0?{}:{goto:t.goto},...t.graph===void 0?{}:{graph:t.graph},...t.resume===void 0?{}:{resume:t.resume}}):d}),"invoke");obtainTools(){return this.toolHandlers().map(({toolName:e})=>this.runtime.requireTool(e)).sort((e,t)=>e.name==="terminate_session"?1:t.name==="terminate_session"?-1:0)}validateTools(){this.obtainTools()}llmConfig(){return this.runtime.resolveLlmConfig(this.getLlmConfig())}llmCallOptions(){return this.runtime.llmCallOptions()}async runConversation(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}}conversationLlmLifecycle(){}runAgentLoop(e,t){const o=this.conversationLlmLifecycle();return new O(this.llmGateway).run({...o===void 0?{}:{lifecycle:o},systemPrompt:this.getPrompt(e),history:this.history(e),tools:this.obtainTools(),llmConfig:this.llmConfig(),executeTool:i(n=>this.handleTool(e,n,t),"executeTool"),maxAgentRounds:this.runtime.maxAgentRounds,emptyHistorySeed:this.runtime.conversationPolicy.emptyHistorySeed,emptyResponseRecovery:this.runtime.conversationPolicy.emptyResponseRecovery,callOptions:this.llmCallOptions()})}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 p(e)])}}complete(e){return{...this.runtime.complete(e),...this.historyUpdate([new p(e)])}}resolveNodeResponse(e){if(!S(e))return e;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"){if(!e.target)throw new Error(`Graph node '${this.id}' selected ${e.kind}() without a target.`);const t=g(e.target,"graph node"),o=this.graph.historySpace(t);if(e.state&&this.graph.saveNodeState(e.target,e.state),e.message&&this.graph.appendHistory(o,[e.message]),e.kind==="directTo"){const n=v(this.id,e);return this.graph.appendHistory(o,[new p(n)]),new c({update:{currentNode:t,response:n,inputConsumed:!0,completed:!1,...e.usage===void 0?{}:{tokens:e.usage}},goto:f})}return new c({update:{currentNode:t,response:"",inputConsumed:!0,completed:!1,...e.usage===void 0?{}:{tokens:e.usage}},goto:t})}if(e.message)throw new Error(`Graph node '${this.id}' can only use withMessage() with go() or directTo().`);if(e.kind==="direct"){const t=v(this.id,e);return this.graph.appendHistory(this.historySpace(),[new p(t)]),new c({update:{currentNode:this.id,response:t,inputConsumed:!0,completed:!1,...e.usage===void 0?{}:{tokens:e.usage}},goto:f})}if(e.kind==="finish"){const t=v(this.id,e);return this.graph.appendHistory(this.historySpace(),[new p(t)]),new c({update:{...this.graph.complete(t),...e.usage===void 0?{}:{tokens:e.usage}},goto:f})}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 C(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)&&C(n.response??""),n}}toolHandlers(){let e=Object.getPrototypeOf(this);const t=[];for(;e&&e!==N.prototype;){const n=Reflect.getOwnMetadata(y,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 Y(r,e){return r.model===e.model&&JSON.stringify(u.parameters(r))===JSON.stringify(u.parameters(e))}i(Y,"sameLlmConfig");class fe extends T{static{i(this,"GraphNodeRuntime")}defaultLlmConfig;historySpaces;responseMode;maxAgentRounds;conversationPolicy;decisionOptions;decisionErrorHandler;llmLifecycle;assertContextChannel;tools=new Map;constructor(e,t,o={},n="chat",d=L,s=H,a={},h,l,m){super(e),this.defaultLlmConfig=t,this.historySpaces=o,this.responseMode=n,this.maxAgentRounds=d,this.conversationPolicy=s,this.decisionOptions=a,this.decisionErrorHandler=h,this.llmLifecycle=l,this.assertContextChannel=m}llmCallOptions(){const{llmTimeoutMs:e}=this.conversationPolicy,t=x();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 u.resolveConfig(this.defaultLlmConfig,e)}resolveDecisionOptions(e={}){return W(this.decisionOptions,e)}decisionProviderResolver;attachDecisionProviderResolver(e){this.decisionProviderResolver=e}resolveDecisionProvider(e){if(!this.decisionProviderResolver)throw new V(`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=>R.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.responseUpdate(e)}complete(e){return this.endUpdate(e)}withInvocation(e,t,o){return z(this,e,t,o)}nodeState(e){return P(this,e)}hasInvocation(){return k(this)}graphState(){return I(this)}getContext(){return j(this)}saveContext(e){this.assertContextChannel?.(),J(this,e)}stageContext(e){this.assertContextChannel?.(),q(this,e)}appendHistory(e,t){D(this,e,t)}invocationHistory(e){return M(this,e)}stagedUpdate(){return _(this)}stageNodeEntries(e){for(const[t,o]of Object.entries(e??{}))!o||typeof o!="object"||Array.isArray(o)||U(this,t,o)}saveNode(e,t){return F(this,e,t),{nodes:{[e]:this.nodeState(e)}}}saveNodeState(e,t){this.saveNode(g(e,"graph node"),t)}removeNode(e,...t){return this.saveNode(e,Object.fromEntries(t.map(o=>[o,void 0])))}}function B(r){if(!w(r))return r;if(Array.isArray(r.update))throw new Error("GraphNode Command updates must be state objects.");return r.update??{}}i(B,"commandUpdate");function v(r,e){if(!e.response?.trim())throw new Error(`Graph node '${r}' selected ${e.kind}() without a response.`);return e.response}i(v,"requireNodeResponse");function K(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)}`}}}i(K,"coerceToolArgs");function Q(r){return r.issues.map(e=>e.path.length>0?`${e.path.join(".")}: ${e.message}`:e.message).join("; ")}i(Q,"formatToolArgumentError");export{X as GRAPH_NODE_CLASS,ve as GRAPH_NODE_LOCAL_STATE,N as GraphNode,fe as GraphNodeRuntime,ue as Tool};
|
|
1
|
+
var E=Object.defineProperty;var i=(r,e)=>E(r,"name",{value:e,configurable:!0});import"reflect-metadata";import{AIMessage as l,HumanMessage as R}from"@langchain/core/messages";import{Command as p,END as f,isCommand as v}from"@langchain/langgraph";import{GraphLlm as u}from"./graph-llm.config.js";import{GraphStateSupport as T}from"./graph-state-support.js";import{LlmRunner as O,DEFAULT_LLM_POLICY as L,DEFAULT_MAX_AGENT_ROUNDS as H,EmptyModelResponseError as $}from"./llm-runner.js";import{currentTurnSignal as x}from"./turn-context.js";import{combineGraphNodeUpdates as A}from"./node-outcome.js";import{parseJsonObjectResponse as C}from"./json-response.js";import{stableClassId as g}from"./stable-id.js";import{SessionLogWarning as b}from"./session-log.js";import{isToolResponse as S,stay as G}from"./tool-response.js";import{invocationGraphState as k,hasNodeInvocation as I,invocationHistory as M,invocationNodeState as P,invocationUpdate as _,appendInvocationHistory as D,replaceInvocationNodeState as U,invocationContext as j,saveInvocationContext as J,replaceInvocationContext as q,saveInvocationNodeState as F,withNodeInvocation as z}from"./node-invocation.js";import{DecisionConfigurationError as W,resolveDecisionOptions as X}from"./decision/decision-types.js";import{GRAPH_NODE_LOCAL_STATE as we}from"./node-outcome.js";const Y=Symbol("GRAPH_NODE_CLASS"),y=Symbol("graph-node-tool-handlers");function ue(r){if(!r.trim())throw new Error("A tool handler requires a tool name.");return(e,t)=>{const o=Reflect.getOwnMetadata(y,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(y,o,e)}}i(ue,"Tool");class N{static{i(this,"GraphNode")}llmGateway;runtime;static[Y]=!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=g(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 d=this.runtime.requireTool(n.toolName),s=Q(t.args);if(!s.ok)return this.rejectToolCall(n.toolName,s.error);const a=d.schema.safeParse(s.value);if(!a.success)return this.rejectToolCall(n.toolName,V(a.error));const h=a.data,c=this[n.methodName];if(!c)throw new Error(`Tool '${n.toolName}' is decorated on missing method '${String(n.methodName)}'.`);const m=await c.call(this,h,o,e);if(S(m))return m;throw new Error(`Tool '${n.toolName}' on '${this.id}' must return a ToolResponse.`)}rejectToolCall(e,t){return b({tool_call:t,node:this.id,tool:e}),G(JSON.stringify({accepted:!1,error:t}))}usesChatModel(){return!0}onInvalidJsonResponse(e){throw e.error}onEmptyModelResponse(e){throw new $(e.reason)}invoke=i(e=>this.runtime.withInvocation(this.id,e,async()=>{const t=this.resolveNodeResponse(await this.run(e)),o=K(t),n=await this.resolveJsonResponse(e,o);if(this.runtime.stageNodeEntries(n.nodes),n.context!==void 0&&this.runtime.stageContext(n.context),this.usesChatModel()){const s=this.runtime.resolveLlmConfig(this.getLlmConfig()),a=B(s,this.runtime.resolveLlmConfig()),h=(e.nodes??{})[this.id];(!a||h?.model!==void 0)&&this.runtime.saveNode(this.id,{model:a?void 0:u.modelMetadata(s)})}const d=A(n,this.runtime.stagedUpdate());return v(t)?new p({update:d,...t.goto===void 0?{}:{goto:t.goto},...t.graph===void 0?{}:{graph:t.graph},...t.resume===void 0?{}:{resume:t.resume}}):d}),"invoke");obtainTools(){return this.toolHandlers().map(({toolName:e})=>this.runtime.requireTool(e)).sort((e,t)=>e.name==="terminate_session"?1:t.name==="terminate_session"?-1:0)}validateTools(){this.obtainTools()}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 O(this.llmGateway).run({...o===void 0?{}:{lifecycle:o},systemPrompt:this.getPrompt(e),history:this.history(e),tools:this.obtainTools(),llmConfig:this.llmConfig(),executeTool:i(n=>this.handleTool(e,n,t),"executeTool"),maxAgentRounds:this.runtime.maxAgentRounds,emptyHistorySeed:this.runtime.llmPolicy.emptyHistorySeed,emptyResponseRecovery:this.runtime.llmPolicy.emptyResponseRecovery,callOptions:this.llmCallOptions()})}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 l(e)])}}complete(e){return{...this.runtime.complete(e),...this.historyUpdate([new l(e)])}}resolveNodeResponse(e){if(!S(e))return e;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"){if(!e.target)throw new Error(`Graph node '${this.id}' selected ${e.kind}() without a target.`);const t=g(e.target,"graph node"),o=this.graph.historySpace(t);if(e.state&&this.graph.saveNodeState(e.target,e.state),e.message&&this.graph.appendHistory(o,[e.message]),e.kind==="directTo"){const n=w(this.id,e);return this.graph.appendHistory(o,[new l(n)]),new p({update:{currentNode:t,response:n,inputConsumed:!0,completed:!1,...e.usage===void 0?{}:{tokens:e.usage}},goto:f})}return new p({update:{currentNode:t,response:"",inputConsumed:!0,completed:!1,...e.usage===void 0?{}:{tokens:e.usage}},goto:t})}if(e.message)throw new Error(`Graph node '${this.id}' can only use withMessage() with go() or directTo().`);if(e.kind==="direct"){const t=w(this.id,e);return this.graph.appendHistory(this.historySpace(),[new l(t)]),new p({update:{currentNode:this.id,response:t,inputConsumed:!0,completed:!1,...e.usage===void 0?{}:{tokens:e.usage}},goto:f})}if(e.kind==="finish"){const t=w(this.id,e);return this.graph.appendHistory(this.historySpace(),[new l(t)]),new p({update:{...this.graph.complete(t),...e.usage===void 0?{}:{tokens:e.usage}},goto:f})}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 C(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)&&C(n.response??""),n}}toolHandlers(){let e=Object.getPrototypeOf(this);const t=[];for(;e&&e!==N.prototype;){const n=Reflect.getOwnMetadata(y,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 B(r,e){return r.model===e.model&&JSON.stringify(u.parameters(r))===JSON.stringify(u.parameters(e))}i(B,"sameLlmConfig");class fe extends T{static{i(this,"GraphNodeRuntime")}defaultLlmConfig;historySpaces;responseMode;maxAgentRounds;llmPolicy;decisionOptions;decisionErrorHandler;llmLifecycle;assertContextChannel;tools=new Map;constructor(e,t,o={},n="chat",d=H,s=L,a={},h,c,m){super(e),this.defaultLlmConfig=t,this.historySpaces=o,this.responseMode=n,this.maxAgentRounds=d,this.llmPolicy=s,this.decisionOptions=a,this.decisionErrorHandler=h,this.llmLifecycle=c,this.assertContextChannel=m}llmCallOptions(){const{llmTimeoutMs:e}=this.llmPolicy,t=x();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 u.resolveConfig(this.defaultLlmConfig,e)}resolveDecisionOptions(e={}){return X(this.decisionOptions,e)}decisionProviderResolver;attachDecisionProviderResolver(e){this.decisionProviderResolver=e}resolveDecisionProvider(e){if(!this.decisionProviderResolver)throw new W(`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=>R.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.responseUpdate(e)}complete(e){return this.endUpdate(e)}withInvocation(e,t,o){return z(this,e,t,o)}nodeState(e){return P(this,e)}hasInvocation(){return I(this)}graphState(){return k(this)}getContext(){return j(this)}saveContext(e){this.assertContextChannel?.(),J(this,e)}stageContext(e){this.assertContextChannel?.(),q(this,e)}appendHistory(e,t){D(this,e,t)}invocationHistory(e){return M(this,e)}stagedUpdate(){return _(this)}stageNodeEntries(e){for(const[t,o]of Object.entries(e??{}))!o||typeof o!="object"||Array.isArray(o)||U(this,t,o)}saveNode(e,t){return F(this,e,t),{nodes:{[e]:this.nodeState(e)}}}saveNodeState(e,t){this.saveNode(g(e,"graph node"),t)}removeNode(e,...t){return this.saveNode(e,Object.fromEntries(t.map(o=>[o,void 0])))}}function K(r){if(!v(r))return r;if(Array.isArray(r.update))throw new Error("GraphNode Command updates must be state objects.");return r.update??{}}i(K,"commandUpdate");function w(r,e){if(!e.response?.trim())throw new Error(`Graph node '${r}' selected ${e.kind}() without a response.`);return e.response}i(w,"requireNodeResponse");function Q(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)}`}}}i(Q,"coerceToolArgs");function V(r){return r.issues.map(e=>e.path.length>0?`${e.path.join(".")}: ${e.message}`:e.message).join("; ")}i(V,"formatToolArgumentError");export{Y as GRAPH_NODE_CLASS,we as GRAPH_NODE_LOCAL_STATE,N as GraphNode,fe as GraphNodeRuntime,ue as Tool};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function w(){const T=['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'];w=function(){return T;};return w();}const Z=k;(function(I,W){const o={I:0x17a,W:0x16b,J:0x178,P:0x166},R=k,J=I();while(!![]){try{const P=parseInt(R(0x173))/0x1+-parseInt(R(0x17c))/0x2+-parseInt(R(o.I))/0x3+-parseInt(R(o.W))/0x4+parseInt(R(o.J))/0x5+parseInt(R(o.P))/0x6*(parseInt(R(0x174))/0x7)+parseInt(R(0x16c))/0x8*(parseInt(R(0x175))/0x9);if(P===W)break;else J['push'](J['shift']());}catch(p){J['push'](J['shift']());}}}(w,0xb9e87));var s=Object['defineProperty'],l=(I,W)=>s(I,Z(0x171),{'value':W,'configurable':!0x0});import{GraphLlm as Q,ModelCatalog as O}from'./graph-llm.config.js';function k(u,f){u=u-0x165;const Q=w();let O=Q[u];if(k['uapbbH']===undefined){var Y=function(I){const W='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let J='',v='';for(let s=0x0,P,p,t=0x0;p=I['charAt'](t++);~p&&(P=s%0x4?P*0x40+p:p,s++%0x4)?J+=String['fromCharCode'](0xff&P>>(-0x2*s&0x6)):0x0){p=W['indexOf'](p);}for(let C=0x0,a=J['length'];C<a;C++){v+='%'+('00'+J['charCodeAt'](C)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(v);};k['ujitrk']=Y,k['tGlJwF']={},k['uapbbH']=!![];}const M=Q[0x0],m=u+M,q=k['tGlJwF'][m];return!q?(O=k['ujitrk'](O),k['tGlJwF'][m]=O):O=q,O;}import{modelProviderAdapter as Y}from'./model-provider.js';import{OPENAI_AUTH_PROVIDER as M,initializeOpenAIAuthProvider as q}from'./openai-auth-provider.js';function C(I,W=[]){const S={I:0x17e,W:0x17d,J:0x165,P:0x167,p:0x16d,t:0x16e,a:0x170,B:0x16a,y:0x16e},x=Z,J=Q[x(S.I)](I),P=O[x(S.W)](J),B={};for(const [K,L]of Object[x(0x17f)](J[x(S.J)])){const j=P[x(S.P)][K];j!==null&&u(B,j??K,L);}if(P[x(0x16e)]===M)return q(P[x(S.p)],B);const y=Y(P[x(S.t)],W)??P[x(S.a)];return y?y[x(S.B)]({'provider':P[x(S.y)],'model':P[x(S.p)],'options':B}):{'model':P[x(S.p)],'options':{'modelProvider':P[x(0x16e)],...B}};}l(C,Z(0x169));function u(I,W,J){const d={I:0x16f,W:0x17b,J:0x176,P:0x179},X=Z,P=W[X(0x177)]('.');let B=I;for(const K of P[X(0x172)](0x0,-0x1)){const L=B[K];if(L===void 0x0){const j={};B[K]=j,B=j;}else{if(typeof L==X(d.I)&&L!==null&&!Array[X(d.W)](L))B=L;else throw new Error(X(d.J)+W+'\x27\x20has\x20a\x20conflicting\x20path.');}}const y=P['at'](-0x1);if(!y)throw new Error(X(d.P));B[y]=J;}l(u,Z(0x168));export{C as langChainModelInitialization};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var s=Object.defineProperty;var o=(e,r)=>s(e,"name",{value:r,configurable:!0});function
|
|
1
|
+
var s=Object.defineProperty;var o=(e,r)=>s(e,"name",{value:r,configurable:!0});import{GraphLlm as n}from"./graph-llm.config.js";function m(e){return{kind:"retry_with_model",model:n.validateConfig(e)}}o(m,"retryWithModel");class p extends Error{static{o(this,"LlmResponseBlockedError")}context;constructor(r,t){super(`LLM response blocked. Reason:${r.rawReason}`,{cause:t}),this.context=r,this.name="LlmResponseBlockedError"}}class d extends Error{static{o(this,"LlmSetupError")}constructor(r){super(r instanceof Error?r.message:String(r),{cause:r}),this.name="LlmSetupError"}}export{p as LlmResponseBlockedError,d as LlmSetupError,m as retryWithModel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var m=Object.defineProperty;var a=(
|
|
1
|
+
var m=Object.defineProperty;var a=(s,t)=>m(s,"name",{value:t,configurable:!0});var g=function(s,t,e,r){var n=arguments.length,o=n<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(s,t,e,r);else for(var d=s.length-1;d>=0;d--)(i=s[d])&&(o=(n<3?i(o):n>3?i(t,e,o):i(t,e))||o);return n>3&&o&&Object.defineProperty(t,e,o),o},l=function(s,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,t)};import{AIMessage as u,HumanMessage as w}from"@langchain/core/messages";import{Command as h,END as p}from"@langchain/langgraph";import{GraphNode as y,Tool as L}from"./graph-node.js";import{stableClassId as f}from"./stable-id.js";import{TerminateSessionNode as R}from"./terminate-session.node.js";import{go as k}from"./tool-response.js";import{addTokenUsage as b}from"./token-usage.js";class I extends y{static{a(this,"LlmNode")}checkResponse(t){return!1}async onLlmBlocked(t){return null}shouldRetryLlmError(t){}async onLlmError(t){return null}llmLifecycle(){return{nodeId:this.id,checkResponse:a(t=>this.checkResponse(t),"checkResponse"),shouldRetryLlmError:a(t=>{t.signal?.throwIfAborted();const e=this.shouldRetryLlmError(t);t.signal?.throwIfAborted();const r=e===void 0?this.graph.llmLifecycle?.shouldRetryLlmError(t):e;return t.signal?.throwIfAborted(),r},"shouldRetryLlmError"),onLlmBlocked:a(async t=>{t.signal?.throwIfAborted();let e=await this.onLlmBlocked(t);return t.signal?.throwIfAborted(),e===null&&(e=await this.graph.llmLifecycle?.onLlmBlocked(t)??null,t.signal?.throwIfAborted()),e},"onLlmBlocked"),onLlmError:a(async t=>{t.signal?.throwIfAborted();let e=await this.onLlmError(t);return t.signal?.throwIfAborted(),e===null&&(e=await this.graph.llmLifecycle?.onLlmError(t)??null,t.signal?.throwIfAborted()),e},"onLlmError")}}async endChat(t){return k(R).withMessage(new w({content:t.message?.trim()||"The user asked to end the conversation.",additional_kwargs:{ezgraphInternal:!0}}))}async run(t){const e=await this.runLlm(t,{});if(e.toolResponse)return this.resolveToolResponse(e,e.toolResponse);const r=e.response;if(!r?.trim())throw new Error(`LLM node '${this.id}' stopped without a response or tool transition.`);return new h({update:{currentNode:this.id,response:r,inputConsumed:!0,completed:!1,...this.historyUpdate(e.messages),tokens:e.usage},goto:p})}resolveToolResponse(t,e){const r=this.historyUpdate(t.messages),n=b(t.usage,e.usage);if(e.kind==="go"){if(!e.target)throw new Error(`LLM node '${this.id}' selected go() without a target.`);const o=f(e.target,"graph node");return e.state&&this.graph.saveNodeState(e.target,e.state),e.message&&this.graph.appendHistory(this.graph.historySpace(o),[e.message]),new h({update:{currentNode:o,inputConsumed:!0,response:"",completed:!1,...r,tokens:n},goto:o})}if(e.kind==="directTo"){if(!e.target)throw new Error(`LLM node '${this.id}' selected directTo() without a target.`);const o=f(e.target,"graph node"),i=this.graph.historySpace(o);e.state&&this.graph.saveNodeState(e.target,e.state),e.message&&this.graph.appendHistory(i,[e.message]);const d=c(this.id,e);return i!==this.historySpace()&&this.graph.appendHistory(i,[new u(d)]),new h({update:{currentNode:o,response:d,inputConsumed:!0,completed:!1,...r,tokens:n},goto:p})}if(e.kind==="direct")return new h({update:{currentNode:this.id,response:c(this.id,e),inputConsumed:!0,completed:!1,...r,tokens:n},goto:p});if(e.kind==="finish")return new h({update:{...this.graph.complete(c(this.id,e)),...r,tokens:n},goto:p});throw new Error(`LLM node '${this.id}' returned stay() after the agent loop stopped.`)}}g([L("terminate_session"),l("design:type",Function),l("design:paramtypes",[Object]),l("design:returntype",Promise)],I.prototype,"endChat",null);function c(s,t){if(!t.response?.trim())throw new Error(`LLM node '${s}' selected ${t.kind}() without a response.`);return t.response}a(c,"requireResponse");export{I as LlmNode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const ug=w;(function(l,R){const uE={l:0x146,R:0x147,g:0x188,x:0x13f,o:0x156},uR=w,g=l();while(!![]){try{const x=parseInt(uR(uE.l))/0x1*(parseInt(uR(0x18e))/0x2)+parseInt(uR(0x19f))/0x3*(-parseInt(uR(uE.R))/0x4)+-parseInt(uR(0x142))/0x5*(parseInt(uR(0x166))/0x6)+parseInt(uR(uE.g))/0x7*(-parseInt(uR(uE.x))/0x8)+-parseInt(uR(uE.o))/0x9+-parseInt(uR(0x14f))/0xa*(parseInt(uR(0x19a))/0xb)+parseInt(uR(0x17d))/0xc;if(x===R)break;else g['push'](g['shift']());}catch(o){g['push'](g['shift']());}}}(u,0xd4210));var J=Object[ug(0x195)],s=(l,R)=>J(l,ug(0x161),{'value':R,'configurable':!0x0});import{setTimeout as f}from'node:timers/promises';import{GraphLlm as k,ModelCatalog as O}from'./graph-llm.config.js';import{LlmResponseBlockedError as M,LlmSetupError as m}from'./llm-lifecycle.js';import{AIMessage as q,HumanMessage as I,ToolMessage as W}from'@langchain/core/messages';import{addTokenUsage as v,emptyTokenUsage as p}from'./token-usage.js';import{isToolResponse as t}from'./tool-response.js';import{describeStopReason as C,isRetryableStopReason as a,modelStopReason as B}from'./model-stop-reason.js';import{SessionLogWarning as y}from'./session-log.js';import{isOpenAIAuthConfig as i,openAIAuthMessageText as L}from'./openai-auth-provider.js';class le extends Error{static{s(this,ug(0x16a));}[ug(0x180)];constructor(l){const uz={l:0x180},uZ=ug;super('The\x20model\x20returned\x20an\x20empty\x20response\x20('+C(l)+').'),this[uZ(uz.l)]=l,this[uZ(0x161)]=uZ(0x16a);}}function w(f,k){f=f-0x13d;const Q=u();let O=Q[f];if(w['xkvChd']===undefined){var Y=function(I){const W='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let J='',v='';for(let s=0x0,P,p,t=0x0;p=I['charAt'](t++);~p&&(P=s%0x4?P*0x40+p:p,s++%0x4)?J+=String['fromCharCode'](0xff&P>>(-0x2*s&0x6)):0x0){p=W['indexOf'](p);}for(let C=0x0,a=J['length'];C<a;C++){v+='%'+('00'+J['charCodeAt'](C)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(v);};w['QBeQbQ']=Y,w['OWyAWJ']={},w['xkvChd']=!![];}const M=Q[0x0],m=f+M,q=w['OWyAWJ'][m];return!q?(O=w['QBeQbQ'](O),w['OWyAWJ'][m]=O):O=q,O;}const de=0x8;function ce(l){const ub={l:0x15d},ux=ug;if(!Number[ux(0x19c)](l)||l<0x1)throw new Error(ux(ub.l)+String(l)+'.');return l;}s(ce,'assertMaxAgentRounds');const H='Start',P={'retries':0x2,'nudge':'Follow\x20the\x20system\x20prompt\x20and\x20respond\x20properly.\x20Use\x20the\x20required\x20tool\x20when\x20instructed.'};function ue(l){const uX=ug;if(!Number['isInteger'](l)||l<0x0)throw new Error(uX(0x171)+String(l)+'.');return l;}s(ue,'assertEmptyResponseRetries');const ke={'emptyHistorySeed':H,'emptyResponseRecovery':P};class Me{static{s(this,ug(0x155));}['llmGateway'];constructor(l){const uU={l:0x1a4},uo=ug;this[uo(uU.l)]=l;}async[ug(0x17e)](z){const w3={l:0x177,R:0x165,g:0x18a,x:0x17b,o:0x16e,d:0x148,T:0x17a,n:0x17a,c:0x159,r:0x1a3,h:0x159,E:0x167,z:0x17a,b:0x185,D:0x16f,e:0x189,A:0x157,u0:0x161,u1:0x1a3,u2:0x19e,u3:0x1a3,u4:0x16b,u5:0x154,u6:0x18b,u7:0x145},w1={l:0x18c,R:0x13d,g:0x19b,x:0x16f,o:0x17a,d:0x150,T:0x14a,n:0x194,c:0x168,r:0x179,h:0x17a,E:0x16f,z:0x15a},uA={l:0x186,R:0x197,g:0x189,x:0x16b,o:0x15b,d:0x19e,T:0x1a3},uS=ug,D=z[uS(w3.l)]===void 0x0?H:z['emptyHistorySeed'],e=z[uS(0x165)][uS(0x16d)]===0x0&&D!==null,u0=e?[$(D)]:[...z[uS(w3.R)]],u1=e?[...u0]:[];let u2=[],u3=p();const u4=ce(z['maxAgentRounds']??de),u5=z[uS(w3.g)]===void 0x0?P:z[uS(w3.g)],u6=u5?ue(u5['retries']):0x0;let u7=0x0,u8=z[uS(w3.x)],u9=!0x1;const uu=z[uS(w3.o)],uw=z[uS(0x19b)]?.[uS(w3.d)],uf=s(()=>uu?k[uS(0x149)](u8,{'params':{'retries':0x0}}):u8,'invocationConfig'),uk=s(()=>({'nodeId':uu['nodeId'],'provider':O[uS(0x178)](u8)[uS(0x15e)],'model':u8[uS(0x144)],...uw===void 0x0?{}:{'signal':uw}}),'commonContext'),uQ=s(async(um,uq)=>{const ud=uS;if(uw?.['throwIfAborted'](),um===null)throw uq;if(typeof um==ud(uA.l)&&um[ud(0x189)]==='retry_with_model'){if(u9)throw new Error(ud(0x18f),{'cause':uq});u8=k[ud(uA.R)](um[ud(0x144)]),u9=!0x0,u7=0x0;return;}const uI=typeof um==ud(0x158)?void 0x0:um;if(uI&&(uI[ud(uA.g)]===ud(uA.x)||uI['cleanup']||uI[ud(0x157)]!==void 0x0))throw new Error(ud(uA.o));const uW=typeof um=='string'?um:uI?.['response'];return uI?.[ud(uA.d)]&&u1[ud(0x1a3)](...uI[ud(0x19e)]),uW!==void 0x0&&u1[ud(uA.T)](new q(uW)),{'messages':u1,'usage':u3,'stoppedAfterTool':!0x1,...uW===void 0x0?{}:{'response':uW},...uI===void 0x0?{}:{'toolResponse':uI}};},uS(0x183)),uO=s(async(um,uq)=>{const uT=uS;uw?.['throwIfAborted']();const uI=await uu[uT(0x160)](um);if(uw?.[uT(0x16f)](),typeof uI=='object'&&uI!==null&&uI[uT(0x189)]===uT(0x169))throw new Error(uT(0x181));return await uQ(uI,new M(um,uq));},uS(0x18d)),uY=s(async()=>{const un=uS;let um=0x0;for(;;){uw?.[un(0x16f)]();const uq=u9?0x1:Number(u8[un(w1.l)][un(0x191)])+0x1;um+=0x1;let uI;const uW=uf();try{uI=await this[un(0x1a4)][un(0x170)](z[un(w1.R)],u0,z[un(0x182)],uW,z[un(w1.g)]);}catch(up){if(uw?.[un(0x16f)](),!uu||up instanceof m)throw up;const ut=ye(up,uk());if(ut)return uO(ut,up);const uC=up instanceof Error?up:new Error(String(up)),ua=uu['shouldRetryLlmError']({...uk(),'error':uC,'attempt':um,'maxAttempts':uq});if(uw?.['throwIfAborted'](),ua!==!0x1&&um<uq){await Y(uw);continue;}const uB={...uk(),'kind':un(0x17c),'error':uC,'attemptsMade':um,'maxAttempts':uq,'stoppedBecause':ua===!0x1?'retry_declined':un(0x167)},uy=await uQ(await uu['onLlmError'](uB),uC);if(uy)return uy;um=0x0;continue;}if(uw?.[un(w1.x)](),u3=v(u3,uI[un(0x16c)]),!uu)return uI;const uJ=B(uI[un(w1.o)]);if(uJ['category']===un(0x1a1)||[un(w1.d),un(w1.T)]['includes'](S(uJ['provider']??'')))return uO({...uk(),'phase':'candidate','rawReason':uJ[un(0x15e)]??un(w1.n),'reason':S(uJ[un(0x15e)]??'refusal'),...Array[un(0x175)](uJ['ratings'])?{'safetyRatings':uJ[un(0x17f)]}:{},...(uI[un(0x17a)][un(0x179)][un(0x1a2)]??uI[un(0x17a)][un(0x143)][un(0x1a2)]??uJ[un(w1.c)])===void 0x0?{}:{'providerDetails':uI['value'][un(w1.r)][un(0x1a2)]??uI['value'][un(0x143)][un(0x1a2)]??uJ[un(0x168)]}});if(!G(uI[un(0x17a)]))return uI;const uv=uu['checkResponse'](uI[un(w1.h)]);if(uw?.[un(w1.E)](),!uv)return uI;if(um<uq){await Y(uw);continue;}const us=new Error(un(0x187)),uP=await uQ(await uu[un(0x152)]({...uk(),'kind':un(w1.z),'error':us,'attemptsMade':um,'maxAttempts':uq,'stoppedBecause':un(0x167),'lastResponse':uI[un(0x17a)]}),us);if(uP)return uP;um=0x0;}},uS(0x172));try{for(let um=0x0;um<u4;um+=0x1){const uq=await uY();if(!(uS(0x17a)in uq))return uq;u1['push'](uq[uS(w3.T)]),u0[uS(0x1a3)](uq['value']);const uI=uq[uS(w3.n)]['tool_calls']??[];if(uI[uS(0x16d)]===0x0){const uv=me(uq['value'],u8);if(uv['trim']()&&(!uu||G(uq[uS(w3.T)])))return await uM(),{'messages':u1,'usage':u3,'response':uv,'stoppedAfterTool':!0x1};const us=B(uq['value']),uP=a(us)&&u5!==null&&u7<u6&&!u9&&(!uu||um+0x1<u4);if(y({'empty_model_response':C(us),'retried':uP}),uP&&u5){u7+=0x1,u1[uS(w3.c)](),u0[uS(0x159)](),u0[uS(w3.r)]($(u5[uS(0x196)]));continue;}if(uu){u1[uS(w3.h)](),u0[uS(w3.h)]();const up=new le(us),ut=await uQ(await uu['onLlmError']({...uk(),'kind':uS(0x151),'error':up,'attemptsMade':u7+0x1,'maxAttempts':u9?0x1:Math[uS(0x173)](u6+0x1,u7+u4-um),'stoppedBecause':uS(w3.E),'lastResponse':uq[uS(w3.z)]}),up);if(ut)return ut;um-=0x1;continue;}return await uM(),{'messages':u1,'usage':u3,'response':uv,'stoppedAfterTool':!0x1,'stopReason':us};}await uM();let uW=!0x1,uJ;try{for(const [uC,ua]of uI[uS(w3.b)]()){uw?.[uS(w3.D)]();const uB=await z['executeTool'](ua);if(t(uB)){if(uB[uS(w3.e)]!==uS(0x16b)){if(uJ&&uJ[uS(w3.e)]!=='stay'&&!pe(uJ,uB))throw new Error(uS(0x141));uJ=uB;}else uJ||(uJ=uB);const uy=new W({'content':uB[uS(w3.A)]??'OK','tool_call_id':ua['id']??uS(0x14d)+um+'-'+uC,'name':ua[uS(w3.u0)]});u1[uS(w3.u1)](uy),u0[uS(w3.u1)](uy),uB['messages']&&(u1['push'](...uB[uS(w3.u2)]),u0['push'](...uB[uS(0x19e)])),uB[uS(0x193)]&&u2[uS(w3.u3)](uB['cleanup']),uw?.[uS(0x16f)](),uW||=uB[uS(w3.e)]!==uS(w3.u4);continue;}}}catch(uK){throw await uM(),uK;}if(uW){const ui=uJ?.[uS(w3.u5)];if(ui){const uL=new q(ui);u1[uS(w3.r)](uL),u0['push'](uL);}return await uM(),{'messages':u1,'usage':u3,'stoppedAfterTool':!0x0,...ui?{'response':ui}:{},...uJ?{'toolResponse':uJ}:{}};}}throw await uM(),new Error(uS(w3.u6)+u4+'\x20agent\x20rounds.');}finally{await uM();}async function uM(){const uc=uS,ul=u2;u2=[],await Promise[uc(0x19d)](ul[uc(0x15f)](uj=>uj()));}s(uM,uS(w3.u7));}}function pe(l,R){const w4={l:0x189,R:0x198,g:0x19e,x:0x16c},uG=ug;return l['kind']==='go'&&R[uG(w4.l)]==='go'&&l[uG(0x198)]===R[uG(w4.R)]&&l['state']===void 0x0&&R['state']===void 0x0&&l['message']===void 0x0&&R['message']===void 0x0&&l[uG(w4.g)]===void 0x0&&R[uG(0x19e)]===void 0x0&&l['cleanup']===void 0x0&&R[uG(0x193)]===void 0x0&&l[uG(0x154)]===void 0x0&&R[uG(0x154)]===void 0x0&&l[uG(w4.x)]===void 0x0&&R[uG(0x16c)]===void 0x0;}s(pe,ug(0x1a0));function $(l){return new I({'content':l,'additional_kwargs':{'ezgraphInternal':!0x0}});}s($,ug(0x163));function fe(l){const w6={l:0x192},uV=ug;return typeof l[uV(0x192)]==uV(0x158)?l[uV(0x192)]:JSON[uV(0x14c)](l[uV(w6.l)]);}s(fe,'messageText');function me(l,R){const w7={l:0x192},ur=ug;return i(R)?L(l[ur(w7.l)]):fe(l);}s(me,ug(0x199));function S(l){const w8={l:0x15c},uH=ug;return l[uH(0x140)]()[uH(0x162)]()[uH(w8.l)]('-','_');}s(S,'normalizeReason');function u(){const wf=['Dgv4Da','CMvZCg9UC2u','tgXTuNvUBMvY','mta4mZiWmJjvy25kDxm','zMvLzgjHy2S','C3rYAw5N','Cg9W','CMvZCg9UC2vFCMvQzwn0zwq','teXnihjLy292zxj5ignHBM5VDcbYzxr1CM4GDg9VBc1VBMX5ihn0yxKOksWGy2XLyw51CcWGB3iGzMvLzgjHy2SU','CMvWBgfJzufSBa','Bwf4qwDLBNrsB3vUzhmGBxvZDcbIzsbHihbVC2L0AxzLigLUDgvNzxi7ihjLy2vPDMvKia','ChjVDMLKzxi','BwfW','B25mBg1cBg9JA2vK','BMfTzq','Dg9mB3DLCKnHC2u','Aw50zxjUywXiDw1HBK1LC3nHz2u','ChjVBxb0qMXVy2TLzenVBNrLEhq','AgLZDg9YEq','nM9QsvHRCq','yxr0zw1WDhnFzxHOyxvZDgvK','zgv0ywLS','CMv0CNLFD2L0Af9TB2rLBa','rw1WDhLnB2rLBfjLC3bVBNnLrxjYB3i','C3rHEq','DxnHz2u','BgvUz3rO','BgLMzwn5y2XL','DgHYB3DjzKfIB3j0zwq','ywDLBNq','zw1WDhLszxnWB25ZzvjLy292zxj5lNjLDhjPzxmGBxvZDcbIzsbHig5VBI1UzwDHDgL2zsbPBNrLz2vYoYbYzwnLAxzLzca','ywnXDwLYzunHBMrPzgf0zq','BwLU','ChjVBxb0','AxnbCNjHEq','C2fMzxr5x3jHDgLUz3m','zw1WDhLiAxn0B3j5u2vLza','CMvZB2X2zu1VzgvSrgvZy3jPChrVCG','CMvZCg9UC2vFBwv0ywrHDge','DMfSDwu','BgXTq29UzMLN','Aw52B2nHDgLVBL9LCNjVCG','ndKWoduZodHcDw14ww8','CNvU','CMf0Aw5NCW','CMvHC29U','CMv0CNLxAxrOtw9KzwWOksbPCYbZDxbWB3j0zwqGB25SEsbIEsbVBKXSBuvYCM9YkcKU','Dg9VBhm','yxbWBhLszwnVDMvYEq','AgfZq2fUzgLKyxrLq29UDgvUDa','zw50CMLLCW','B2jQzwn0','vgHLig1VzgvSihjLC3bVBNnLihDHCYbYzwPLy3rLzcbIEsbJAgvJA1jLC3bVBNnLkcKU','mJf2se9Jvgu','A2LUza','zw1WDhLszxnWB25ZzvjLy292zxj5','q29UDMvYC2f0Aw9Uigv4y2vLzgvKia','CgfYyw1Z','AgfUzgXLqMXVy2TLza','nM9nAvPbra','CMv0CNLxAxrOtw9KzwWOksbTyxKGyMuGCMv0DxjUzwqGB25SEsbVBMnLigLUigeGCMvJB3zLCNKGC2vXDwvUy2uU','Dg9VBf9JywXSCW','CMv0CMLLCW','y29UDgvUDa','y2XLyw51Ca','CMvMDxnHBa','zgvMAw5LuhjVCgvYDhK','BNvKz2u','DMfSAwrHDgvdB25MAwC','DgfYz2v0','CMvZCg9UC2vuzxH0','mJmXntaZognjExn4BW','y2fSBe9WDgLVBNm','AxnjBNrLz2vY','ywXSu2v0DgXLza','BwvZC2fNzxm','mtG2mdq4uwj1qvn0','Axntyw1LqMfYzvrYyw5ZAxrPB24','yMXVy2TLza','C3rVCf9KzxrHAwXZ','ChvZAa','BgXTr2f0zxDHEq','C3LZDgvTuhjVBxb0','C29Tzq','mJa2otC3nKDWvMrzvq','DhjPBq','qsb0B29SigjHDgnOihnLBgvJDgvKig1VCMuGDgHHBIbVBMuGDgvYBwLUywWGCMvZCg9UC2uGB3iGDhjHBNnPDgLVBI4','mZqYnZe0nurez3HoEq','ywrKAxrPB25HBf9RD2fYz3m','Bw9KzwW','y2XLyw51Cef0DgfJAg1LBNrZ','ntaWndqYwKjJz25w','otjPCKzlswS','C2LNBMfS','CMvZB2X2zunVBMzPzW','Aw1Hz2vFB3rOzxi','yMXVy2TFCMvHC29U','C3rYAw5NAwz5','Dg9VBc1JywXSlq','yMXVy2TszwfZB24','mZbvsNv3tfa','B3rOzxi','zw1WDhLFCMvZCg9UC2u','B25mBg1fCNjVCG'];u=function(){return wf;};return u();}function ye(l,R){const w9={l:0x14e,R:0x176,g:0x174,x:0x175},uN=ug;if(!l||typeof l!=uN(0x186))return null;const x=l,o=x[uN(w9.l)]??x[uN(0x14b)];if(typeof o!=uN(0x158)||!o[uN(0x140)]())return null;const d=x['safetyRatings']??x[uN(w9.R)];return{...R,'phase':uN(w9.g),'rawReason':o,'reason':S(o),...Array[uN(w9.x)](d)?{'safetyRatings':d}:{}};}s(ye,ug(0x164));function G(l){const wu={l:0x190,R:0x192,g:0x158},uh=ug;return l[uh(wu.l)]?.[uh(0x16d)]?!0x0:typeof l[uh(wu.R)]==uh(wu.g)?!!l['content'][uh(0x140)]():l[uh(wu.R)][uh(0x13e)](R=>typeof R[uh(0x153)]==uh(0x158)&&!!R[uh(0x153)][uh(0x140)]());}s(G,ug(0x184));async function Y(l){const ww={l:0x16f},uF=ug;try{await f(0x1f4,void 0x0,l?{'signal':l}:void 0x0);}catch(R){throw l?.[uF(ww.l)](),R;}}s(Y,'waitForRetry');export{H as DEFAULT_EMPTY_HISTORY_SEED,P as DEFAULT_EMPTY_RESPONSE_RECOVERY,ke as DEFAULT_LLM_POLICY,de as DEFAULT_MAX_AGENT_ROUNDS,le as EmptyModelResponseError,Me as LlmRunner,ue as assertEmptyResponseRetries,ce as assertMaxAgentRounds};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const qN=d;(function(t,A){const k5={t:0xad,A:0xfd,r:0x125,i:0xa6,Z:0xce,Y:0xe8},qa=d,r=t();while(!![]){try{const i=-parseInt(qa(k5.t))/0x1*(-parseInt(qa(0x10b))/0x2)+-parseInt(qa(k5.A))/0x3+-parseInt(qa(k5.r))/0x4*(parseInt(qa(0xdc))/0x5)+-parseInt(qa(k5.i))/0x6*(parseInt(qa(0xd6))/0x7)+-parseInt(qa(0x122))/0x8+parseInt(qa(k5.Z))/0x9*(parseInt(qa(k5.Y))/0xa)+parseInt(qa(0x99))/0xb*(parseInt(qa(0xa8))/0xc);if(i===A)break;else r['push'](r['shift']());}catch(Z){r['push'](r['shift']());}}}(k,0x27bd1));var J=Object[qN(0xc6)],c=(t,A)=>J(t,qN(0xc9),{'value':A,'configurable':!0x0});import{mapChatMessagesToStoredMessages as l,mapStoredMessagesToChatMessages as e}from'@langchain/core/messages';import{BaseGraph as B}from'../base-graph.js';function k(){const kf=['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'];k=function(){return kf;};return k();}import{ConfigManager as w}from'../config-manager.js';import{GRAPH_END_NODE as D}from'../graph-state.js';import{cloneJsonObject as o}from'../graph-context.js';import{GraphLlm as a}from'../graph-llm.config.js';import{replaceNodeStates as u}from'../node-state.js';import{createSessionLogs as n}from'../session-log.js';import{emptyTokenUsage as m,normalizeTokenUsage as E}from'../token-usage.js';import{assertGraphSchemaVersion as s}from'../stable-id.js';import{addDecisionUsage as L,emptyDecisionUsage as z,normalizeDecisionUsage as R}from'../decision/decision-types.js';const h=0x10,g=qN(0xed),q=qN(0xc2),Ce='SESSION_COMPLETED';class f extends Error{static{c(this,qN(0xfa));}[qN(0xb4)];constructor(A,r){const qu=qN;super(r),this[qu(0xc9)]=qu(0xfa),this[qu(0xb4)]=A;}}class N{static{c(this,'SessionManager');}['container'];[qN(0x103)];constructor(A=new V(),r=F()){const qP=qN;this['container']=A,this[qP(0x103)]=r;}static async[qN(0xf8)](r=new w()){const k8={t:0x119,A:0x9d,r:0x12c,i:0x119,Z:0xdb,Y:0xa2,H:0x110,M:0x106,O:0x12a,q0:0x112,q1:0x136,q2:0xa7,q3:0xec,q4:0xd7,q5:0xd8,q6:0xdd,q7:0xe4,q8:0x119,q9:0x11a,qq:0xbd},qn=qN,q0=r[qn(k8.t)]('SESSION_STORE','memory')[qn(k8.A)]()['toLowerCase'](),q1=F(r['get'](qn(k8.r)));if(q0==='memory')return new N(new V(),q1);if(q0===qn(0xbe)){const {SqliteSessionDocumentContainer:qX}=await import('./sqlite-session-document.container.js');return new N(new qX(r[qn(k8.i)](qn(0xb0),qn(0xe1))),q1);}if(q0===qn(0xa2)||q0==='mongo'){const qv=p(r,qn(k8.Z)),qB=p(r,'MONGODB_NAME'),qw=p(r,qn(0x134));if(!qv||!qB||!qw)throw new Error('MongoDB\x20session\x20persistence\x20requires\x20MONGODB_URL,\x20MONGODB_NAME,\x20and\x20MONGODB_COLLECTION.');const [{MongoClient:qK},{MongoDbSessionDocumentContainer:qj}]=await Promise[qn(0xe9)]([import(qn(k8.Y)),import('./mongodb-session-document.container.js')]),qD=new qK(qv);await qD[qn(0x115)]();const qo=qD['db'](qB)['collection'](qw);return await qo['createIndex']({'id':0x1},{'unique':!0x0}),new N(new qj(qo,qD),q1);}if(q0!==qn(0x10a)&&q0!==qn(k8.H))throw new Error('Unsupported\x20SESSION_STORE\x20\x27'+q0+qn(0x127));const q2=p(r,'COSMO_ENDPOINT','COSMOS_ENDPOINT','COSMODB_URL'),q3=p(r,qn(k8.M),'COSMOS_KEY'),q4=p(r,qn(k8.O)),q5=p(r,qn(k8.q0)),q6=p(r,qn(0xaf)),q7=p(r,qn(k8.q1),'COSMOS_DATABASE',qn(k8.q2))??qn(k8.q3),q8=p(r,'COSMO_DB_SESSION_CONTAINER_ID',qn(0xc5),qn(k8.q4))??qn(0x116);if(!q2||!q3&&(!q4||!q5||!q6))throw new Error(qn(0xb3));const [{CosmosClient:q9},{ClientSecretCredential:qq}]=await Promise['all']([import(qn(k8.q5)),import(qn(k8.q6))]),qk=q3?new q9({'endpoint':q2,'key':q3}):new q9({'endpoint':q2,'aadCredentials':new qq(q4,q5,q6)}),{database:qd}=await qk[qn(k8.q7)][qn(0x109)]({'id':q7}),qG=Number(r[qn(k8.q8)](qn(0xd5),qn(0xa0))),{container:qT}=await qd['containers'][qn(0x109)]({'id':q8,'partitionKey':{'paths':['/id']},...Number[qn(0x98)](qG)&&qG>0x0?{'throughput':qG}:{}}),{resource:qy}=await qT[qn(0xac)](),ql=qy?.[qn(0x13c)]?.[qn(k8.q9)]??[];if(!ql[qn(0xda)](qn(0xf5)))throw new Error('Cosmos\x20container\x20\x27'+q8+'\x27\x20must\x20use\x20partition\x20key\x20/id;\x20found\x20'+(ql[qn(0x145)](',\x20')||'none')+'.');const {CosmosSessionDocumentContainer:qe}=await import(qn(k8.qq));return new N(new qe(qT,()=>qk[qn(0x126)]()),q1);}async[qN(0x128)](A){const k9={t:0x117,A:0x101},qm=qN,r=await this[qm(k9.t)](A);return r?.[qm(k9.A)]===h?r:void 0x0;}async[qN(0x117)](A){const kq={t:0xe7},qV=qN;try{const {resource:r}=await this[qV(kq.t)][qV(0x13e)](A,A)[qV(0xac)]();return r;}catch(i){if(G(i))return;throw i;}}async[qN(0x108)](A,r,Z){const kk={t:0xca,A:0x117,r:0x123,i:0x103,Z:0xa1,Y:0x13d,H:0xcb,M:0xe7,O:0xd4,q0:0xff,q1:0xdf,q2:0xbb,q3:0xcb},qE=qN,Y=B[qE(kk.t)](Z[qE(0x11d)]),H=s(Z[qE(0xe2)]),M=await this[qE(kk.A)](A);M&&M[qE(0x101)]===h&&T(M,Y);const O=new Date(),q0={'owner':r,'expiresAt':new Date(O[qE(kk.r)]()+this[qE(kk.i)])[qE(0xa1)]()};if(!M){const q2=this['placeholderDocument'](A,Z,Y,H,q0,O[qE(kk.Z)]());if(await this['container'][qE(kk.Y)]({'expectedRevision':null},q2)==='conflict')throw new f(g,qE(0xbb)+A+qE(kk.H));return{'kind':qE(0xff),'document':q2,'expectedRevision':q2['revision']};}if(M[qE(0x101)]!==h){const q3=this['placeholderDocument'](A,Z,Y,H,q0,O['toISOString']());if(await this[qE(kk.M)][qE(0x13d)]({'expectedRevision':S(M),'replaceIncompatible':!0x0},q3)===qE(kk.O))throw new f(g,qE(0xbb)+A+'\x27\x20is\x20already\x20processing\x20a\x20turn.');return{'kind':qE(kk.q0),'document':q3,'expectedRevision':q3[qE(0xb2)]};}if(K(M[qE(0xdf)])&&M[qE(kk.q1)]?.[qE(0x135)]!==r)throw new f(g,'Session\x20\x27'+A+qE(kk.H));const q1={...M,'revision':S(M)+0x1,'turn':q0};if(await this['container']['compareAndSwap']({'expectedRevision':S(M),'requireFreeLease':!0x0,'allowOwner':r},q1)==='conflict')throw new f(g,qE(kk.q2)+A+qE(kk.q3));return{'kind':'leased','document':q1,'expectedRevision':S(q1)};}async[qN(0x12b)](A,r){const qC=qN,i=await this['getSession'](A);if(i)return this[qC(0x102)](i,r);}[qN(0x102)](A,r){const kG={t:0x129,A:0x129,r:0xa5,i:0x13a,Z:0x114,Y:0x11f,H:0xfc},qp=qN,i=B[qp(0xca)](r);T(A,i);const {graph:Z}=A;if(!Z[qp(kG.t)])return;const Y=u({},Z[qp(kG.A)]),H=ae(Z[qp(kG.r)]);return{'currentNode':Z[qp(0x9f)],'config':Z[qp(kG.i)]??{},'context':o(Z[qp(kG.Z)]===void 0x0?{}:Z['context']),'completed':A[qp(kG.Y)]===qp(kG.H)||Z[qp(0x9f)]===D,'nodes':Y,'tokens':E(A[qp(0xab)]),'decisionUsage':R(A['decisionUsage']),'histories':H,'inputConsumed':!0x0,'response':''};}async[qN(0xd9)](A,r,Z,Y=n(),H={}){const kT={t:0xe2,A:0xa1,r:0x129,i:0xfc,Z:0x140,Y:0xe0,H:0x11c,M:0x9f,O:0x114,q0:0x10f,q1:0x135,q2:0x13d,q3:0xd4,q4:0xbb,q5:0xcb},qJ=qN,M=B[qJ(0xca)](Z[qJ(0x11d)]),q0=s(Z[qJ(kT.t)]),q1=await this[qJ(0x117)](A),q2=q1?.[qJ(0x101)]===h?q1:void 0x0;q2&&(T(q2,M),j(q2,q0));const q3=new Date()[qJ(kT.A)](),q4=oe(u({},r[qJ(kT.r)])),{tokens:q5,histories:q6}=r,q7=this[qJ(0xc4)](q1,H),q8={'version':h,'id':A,'revision':q7===null?0x0:q7+0x1,'status':r[qJ(kT.i)]?'completed':'in_progress','tokens':E(q5),'decisionUsage':R(r[qJ(kT.Z)]),'errors':[...q2?.[qJ(0xe0)]??[],...Y[qJ(kT.Y)]],'warnings':[...q2?.[qJ(0xcd)]??[],...Y[qJ(0xcd)]],'decisions':[...q2?.['decisions']??[],...Y[qJ(kT.H)]],'graph':{'id':M,'schemaVersion':q0,'currentNode':r[qJ(kT.M)],'config':r[qJ(0x13a)],'context':o(r[qJ(kT.O)]===void 0x0?{}:r[qJ(kT.O)]),'histories':se(q6),'model':a[qJ(kT.q0)](Z[qJ(0xf3)]),'nodes':q4},...H['keepTurn']&&q2?.[qJ(0xdf)]?{'turn':{'owner':q2[qJ(0xdf)][qJ(kT.q1)],'expiresAt':new Date(Date[qJ(0x130)]()+this[qJ(0x103)])[qJ(0xa1)]()}}:{},'createdAt':q2?.['createdAt']??q3,'modifiedAt':q3};if(await this['container'][qJ(kT.q2)](this[qJ(0x12e)](q1,H,q7),q8)===qJ(kT.q3))throw new f(H['owner']?q:g,H[qJ(0x135)]?qJ(kT.q4)+A+qJ(0xa3):qJ(0xbb)+A+qJ(kT.q5));return q8;}async['appendLogs'](A,r,Z,Y={}){const ky={t:0xe2,A:0x128,r:0x140,i:0xe0,Z:0x11c,Y:0x9f,H:0x13a,M:0xa5,O:0x114,q0:0xf3,q1:0x131,q2:0x131,q3:0x141,q4:0x13d,q5:0x12e,q6:0x135,q7:0xbb,q8:0x12d},qs=qN,H=B[qs(0xca)](Z[qs(0x11d)]),M=s(Z[qs(ky.t)]),O=await this[qs(ky.A)](A);O&&(T(O,H),j(O,M));const q0=new Date()['toISOString'](),q1=this[qs(0xc4)](O,Y),q2={'version':h,'id':A,'revision':q1===null?0x0:q1+0x1,'status':r[qs(0xe0)]['length']>0x0?qs(0xaa):O?.['status']??'in_progress','tokens':O?.[qs(0xab)]??m(),'decisionUsage':r[qs(0x11c)][qs(0xc8)]((q3,q4)=>L(q3,q4['usage']),R(O?.[qs(ky.r)])),'errors':[...O?.[qs(ky.i)]??[],...r[qs(0xe0)]],'warnings':[...O?.[qs(0xcd)]??[],...r[qs(0xcd)]],'decisions':[...O?.[qs(ky.Z)]??[],...r[qs(0x11c)]],'graph':{'id':H,'schemaVersion':M,...O?{'currentNode':O['graph'][qs(ky.Y)],'config':O['graph'][qs(ky.H)]}:{},'histories':O?.[qs(0x131)][qs(ky.M)]??{},'context':o(O?.['graph'][qs(ky.O)]===void 0x0?{}:O[qs(0x131)]['context']),'model':a['modelMetadata'](Z[qs(ky.q0)]),...O?.[qs(ky.q1)][qs(0x129)]?{'nodes':O[qs(ky.q2)][qs(0x129)]}:{}},'createdAt':O?.[qs(ky.q3)]??q0,'modifiedAt':q0};if(await this['container'][qs(ky.q4)](this[qs(ky.q5)](O,Y,q1),q2)==='conflict'){if(Y[qs(ky.q6)]){console['warn'](qs(ky.q7)+A+qs(0xf0)+r[qs(ky.i)]['length']+'\x20error(s)\x20and\x20'+r['warnings'][qs(ky.q8)]+qs(0xe3));return;}throw new f(g,'Session\x20\x27'+A+qs(0xcb));}return q2;}async['endFailedTurn'](A,r,i,Z,Y){const kl={t:0xe0,A:0xcd,r:0x9c},qL=qN;if(Z&&(Z[qL(kl.t)][qL(0x12d)]>0x0||Z[qL(kl.A)][qL(0x12d)]>0x0||Z[qL(0x11c)][qL(0x12d)]>0x0)){await this[qL(0xee)](A,Z,i,{'owner':r,...Y!==void 0x0?{'expectedRevision':Y}:{}});return;}await this[qL(kl.r)](A,r,Y);}async[qN(0x9c)](A,r,Z){const ke={t:0x135,A:0x13d},qz=qN,Y=await this['getSession'](A);if(!Y||Y['turn']?.[qz(ke.t)]!==r)return;const H=Z??S(Y),{turn:M,...O}=Y,q0={...O,'modifiedAt':new Date()['toISOString']()};await this[qz(0xe7)][qz(ke.A)]({'expectedRevision':H,'requireOwner':r},q0);}async[qN(0x120)](A){const kX={t:0xe7},qR=qN;try{await this[qR(kX.t)][qR(0x13e)](A,A)[qR(0x138)]();}catch(r){if(!G(r))throw r;}}async['persistMigratedSession'](A,r={}){const kv={t:0x100,A:0xc3,r:0x131,i:0xeb,Z:0x128,Y:0xdf,H:0x114,M:0x141,O:0x141,q0:0xbb,q1:0xb8},qc=qN;if(A['version']!==h)throw new Error(qc(kv.t)+A[qc(0x101)]+qc(kv.A)+h+'.');B[qc(0xca)](A[qc(0x131)]['id']),s(A[qc(kv.r)][qc(kv.i)]);const i=await this[qc(kv.Z)](A['id']),Z=r[qc(0x113)]??S(i||A),Y=i?.[qc(0xdf)]??A[qc(kv.Y)],H={...A,'graph':{...A['graph'],'context':o(A[qc(kv.r)][qc(kv.H)]===void 0x0?{}:A['graph']['context'])},'revision':Z,'createdAt':i?.[qc(kv.M)]??A[qc(kv.O)],'modifiedAt':i?.[qc(0xf6)]??A[qc(0xf6)],...Y?{'turn':Y}:{}};if(await this['container'][qc(0x13d)]({'expectedRevision':Z,...r[qc(0x135)]?{'requireOwner':r[qc(0x135)]}:{'requireFreeLease':!0x0}},H)===qc(0xd4))throw new f(r[qc(0x135)]?q:g,qc(kv.q0)+A['id']+qc(kv.q1));}async[qN(0x13f)](){const qg=qN;await this['container'][qg(0x13f)]?.();}[qN(0xd3)](A,r,i,Z,Y,H){const kw={t:0x144},qt=qN;return{'version':h,'id':A,'revision':0x0,'status':qt(kw.t),'tokens':m(),'decisionUsage':z(),'errors':[],'warnings':[],'decisions':[],'graph':{'id':i,'schemaVersion':Z,'histories':{},'context':{},'model':a[qt(0x10f)](r[qt(0xf3)])},'turn':Y,'createdAt':H,'modifiedAt':H};}['commitExpectedRevision'](A,r){const kK={t:0x113},qA=qN;return r[qA(kK.t)]!==void 0x0?r[qA(kK.t)]:A?S(A):null;}[qN(0x12e)](A,r,i){const kj={t:0x135,A:0x101},qr=qN;return r[qr(kj.t)]?{'expectedRevision':i,'requireOwner':r['owner']}:A&&A[qr(kj.A)]!==h?{'expectedRevision':i,'replaceIncompatible':!0x0}:{'expectedRevision':i,'requireFreeLease':!0x0};}}function p(A,...i){const qf=qN;for(const Z of i){const Y=A[qf(0x119)](Z);if(Y)return Y;}}c(p,qN(0x107));function T(t,A){const ko={t:0x131,A:0xbb,r:0xfe,i:0x13b},qi=qN;if(t[qi(ko.t)]['id']!==A)throw new Error(qi(ko.A)+t['id']+qi(ko.r)+t['graph']['id']+'\x27,\x20not\x20\x27'+A+qi(ko.i));}c(T,qN(0xf4));function j(t,A){const ka={t:0x131,A:0xeb,r:0xfb,i:0xb6,Z:0x131,Y:0xeb,H:0xea,M:0xae},qh=qN;if(t[qh(ka.t)][qh(ka.A)]!==A)throw new Error('Session\x20\x27'+t['id']+qh(ka.r)+t['graph']['id']+qh(ka.i)+t[qh(ka.Z)][qh(ka.Y)]+qh(ka.H)+A+qh(ka.M));}c(j,qN(0xde));function oe(t){const ku={t:0x11e},kN={t:0x121},qQ=qN;return Object[qQ(0xc0)](Object[qQ(0xd2)](t)[qQ(ku.t)](([A,i])=>{const qZ=qQ;if(!i||typeof i!=qZ(kN.t))return[A,i];const {toolTrace:Z,...Y}=i;return[A,Y];}));}c(oe,qN(0x132));function ie(t){const kP={t:0xef,A:0x12d,r:0xe5,i:0xd1,Z:0xcf,Y:0xf7,H:0x111,M:0x12d,O:0xf9,q0:0x12d,q1:0xf9};return t['map'](A=>{const qY=d,i={...A[qY(0xb1)]},Z=A['type']==='ai'&&Array[qY(kP.t)](i[qY(0x111)])&&i[qY(0x111)][qY(kP.A)]>0x0?ce(i[qY(0xe5)]):void 0x0,Y=b(i[qY(kP.r)])&&i[qY(0xe5)][qY(kP.i)]===!0x0;return delete i[qY(0xe5)],(Z||Y)&&(i['additional_kwargs']={...Z?{'originalTextContentBlock':Z}:{},...Y?{'ezgraphInternal':!0x0}:{}}),delete i[qY(kP.Z)],delete i[qY(kP.Y)],A[qY(0xbc)]==='ai'&&(Array[qY(0xef)](i[qY(kP.H)])&&i[qY(0x111)][qY(kP.M)]===0x0&&delete i[qY(kP.H)],Array['isArray'](i[qY(kP.O)])&&i[qY(0xf9)][qY(kP.q0)]===0x0&&delete i[qY(kP.q1)]),{...A,'data':i};});}c(ie,qN(0x9a));function se(t){const km={t:0xd2,A:0x11e},qH=qN;return Object[qH(0xc0)](Object[qH(km.t)](t)[qH(km.A)](([A,i])=>[A,ie(l(i))]));}c(se,qN(0xa4));function ae(t={}){const kV={t:0xc0},qW=qN;return Object[qW(kV.t)](Object[qW(0xd2)](t)[qW(0x11e)](([A,i])=>[A,e(i)]));}c(ae,qN(0xa9));function ce(t){const kE={t:0x9e,A:0x133,r:0x9e},qM=qN;if(!b(t))return;const A=t[qM(0x10d)];if(!(!b(A)||typeof A[qM(kE.t)]!=qM(0xc7)))return{...typeof A[qM(kE.A)]==qM(0xc7)?{'text':A['text']}:{},'thoughtSignature':A[qM(kE.r)],...A[qM(0xba)]===!0x0?{'thought':!0x0}:{}};}c(ce,qN(0xf1));function b(t){const qx=qN;return t!==null&&typeof t==qx(0x121)&&!Array['isArray'](t);}c(b,qN(0x104));class V{static{c(this,qN(0xb9));}[qN(0x105)]=new Map();get[qN(0x9b)](){const qU=qN;return this[qU(0x105)][qU(0x9b)];}[qN(0xbf)]={'upsert':c(async e=>{const kJ={t:0x105},qO=qN,t=e;return this[qO(kJ.t)]['set'](t['id'],structuredClone(t)),{};},qN(0x124))};async[qN(0x13d)](A,r){const ks={t:0x105},qF=qN,i=this[qF(ks.t)][qF(0x119)](r['id']);return de(i,A)?(this['documents'][qF(0x10e)](r['id'],structuredClone(r)),'ok'):'conflict';}[qN(0x13e)](A,r){const kz={t:0x119,A:0xc1,r:0x11b},kL={t:0x105},qI=qN;return{'read':c(async()=>{const qS=d,i=this[qS(kL.t)][qS(0x119)](A);if(!i||i['id']!==r)throw Object[qS(0xc1)](new Error('Not\x20found'),{'code':0x194});return{'resource':structuredClone(i)};},'read'),'delete':c(async()=>{const qb=d,i=this[qb(0x105)][qb(kz.t)](A);if(!i||i['id']!==r)throw Object[qb(kz.A)](new Error(qb(kz.r)),{'code':0x194});return this[qb(0x105)]['delete'](A),{};},qI(0x138))};}}function G(t){const k0=qN;if(!t||typeof t!=k0(0x121))return!0x1;const A=t;return A[k0(0xb4)]===0x194||A[k0(0x12f)]===0x194;}c(G,qN(0x139));function F(t=process.env.SESSION_TURN_LEASE_MS){const kg={t:0x118},k1=qN,A=Number(t??k1(kg.t));return Number[k1(0x98)](A)&&A>0x0?A:0xea60;}function d(q,G){q=q-0x98;const T=k();let y=T[q];if(d['zZPXch']===undefined){var l=function(B){const w='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let K='',j='';for(let D=0x0,o,a,N=0x0;a=B['charAt'](N++);~a&&(o=D%0x4?o*0x40+a:a,D++%0x4)?K+=String['fromCharCode'](0xff&o>>(-0x2*D&0x6)):0x0){a=w['indexOf'](a);}for(let k=0x0,u=K['length'];k<u;k++){j+='%'+('00'+K['charCodeAt'](k)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(j);};d['quHhSI']=l,d['AkYZlF']={},d['zZPXch']=!![];}const e=T[0x0],X=q+e,v=d['AkYZlF'][X];return!v?(y=d['quHhSI'](y),d['AkYZlF'][X]=y):y=v,y;}c(F,qN(0xe6));function S(t){const kt={t:0xb2},k2=qN;return t?.[k2(kt.t)]??0x0;}c(S,qN(0x142));function K(A,i=Date['now']()){const kA={t:0x135,A:0xcc,r:0xb7},k3=qN;if(!A?.[k3(kA.t)]||!A[k3(0xb7)])return!0x1;const Z=Date[k3(kA.A)](A[k3(kA.r)]);return Number['isFinite'](Z)&&Z>i;}c(K,qN(0xb5));function de(A,i,Z=Date[qN(0x130)]()){const kr={t:0x113,A:0xdf,r:0xf2,i:0xd0},k4=qN;return i[k4(0x10c)]?A!==void 0x0&&A['version']!==h:i[k4(kr.t)]===null?A===void 0x0:!(!A||S(A)!==i[k4(0x113)]||i['requireOwner']&&A[k4(kr.A)]?.[k4(0x135)]!==i[k4(kr.r)]||i[k4(kr.i)]&&K(A[k4(0xdf)],Z)&&A['turn']?.[k4(0x135)]!==i[k4(0x143)]);}c(de,qN(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 ut=w;(function(d,n){const w5={d:0xad,n:0xfd,r:0x125,H:0xa6,E:0xce,z:0xe8},up=w,r=d();while(!![]){try{const H=-parseInt(up(w5.d))/0x1*(-parseInt(up(0x10b))/0x2)+-parseInt(up(w5.n))/0x3+-parseInt(up(w5.r))/0x4*(parseInt(up(0xdc))/0x5)+-parseInt(up(w5.H))/0x6*(parseInt(up(0xd6))/0x7)+-parseInt(up(0x122))/0x8+parseInt(up(w5.E))/0x9*(parseInt(up(w5.z))/0xa)+parseInt(up(0x99))/0xb*(parseInt(up(0xa8))/0xc);if(H===n)break;else r['push'](r['shift']());}catch(E){r['push'](r['shift']());}}}(u,0x27bd1));var J=Object[ut(0xc6)],c=(d,n)=>J(d,ut(0xc9),{'value':n,'configurable':!0x0});import{mapChatMessagesToStoredMessages as k,mapStoredMessagesToChatMessages as O}from'@langchain/core/messages';import{BaseGraph as Y}from'../base-graph.js';function u(){const wn=['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'];u=function(){return wn;};return u();}import{ConfigManager as M}from'../config-manager.js';import{GRAPH_END_NODE as m}from'../graph-state.js';import{cloneJsonObject as s}from'../graph-context.js';import{GraphLlm as t}from'../graph-llm.config.js';import{replaceNodeStates as a}from'../node-state.js';import{createSessionLogs as B}from'../session-log.js';import{emptyTokenUsage as i,normalizeTokenUsage as L}from'../token-usage.js';import{assertGraphSchemaVersion as l}from'../stable-id.js';import{addDecisionUsage as R,emptyDecisionUsage as Z,normalizeDecisionUsage as o}from'../decision/decision-types.js';const h=0x10,g=ut(0xed),q=ut(0xc2),Ce='SESSION_COMPLETED';class f extends Error{static{c(this,ut(0xfa));}[ut(0xb4)];constructor(d,n){const uC=ut;super(n),this[uC(0xc9)]=uC(0xfa),this[uC(0xb4)]=d;}}class N{static{c(this,'SessionManager');}['container'];[ut(0x103)];constructor(d=new V(),n=F()){const ua=ut;this['container']=d,this[ua(0x103)]=n;}static async[ut(0xf8)](r=new M()){const w8={d:0x119,n:0x9d,r:0x12c,H:0x119,E:0xdb,z:0xa2,D:0x110,e:0x106,A:0x12a,u0:0x112,u1:0x136,u2:0xa7,u3:0xec,u4:0xd7,u5:0xd8,u6:0xdd,u7:0xe4,u8:0x119,u9:0x11a,uu:0xbd},uB=ut,u0=r[uB(w8.d)]('SESSION_STORE','memory')[uB(w8.n)]()['toLowerCase'](),u1=F(r['get'](uB(w8.r)));if(u0==='memory')return new N(new V(),u1);if(u0===uB(0xbe)){const {SqliteSessionDocumentContainer:um}=await import('./sqlite-session-document.container.js');return new N(new um(r[uB(w8.H)](uB(0xb0),uB(0xe1))),u1);}if(u0===uB(0xa2)||u0==='mongo'){const uq=p(r,uB(w8.E)),uI=p(r,'MONGODB_NAME'),uW=p(r,uB(0x134));if(!uq||!uI||!uW)throw new Error('MongoDB\x20session\x20persistence\x20requires\x20MONGODB_URL,\x20MONGODB_NAME,\x20and\x20MONGODB_COLLECTION.');const [{MongoClient:uJ},{MongoDbSessionDocumentContainer:uv}]=await Promise[uB(0xe9)]([import(uB(w8.z)),import('./mongodb-session-document.container.js')]),us=new uJ(uq);await us[uB(0x115)]();const uP=us['db'](uI)['collection'](uW);return await uP['createIndex']({'id':0x1},{'unique':!0x0}),new N(new uv(uP,us),u1);}if(u0!==uB(0x10a)&&u0!==uB(w8.D))throw new Error('Unsupported\x20SESSION_STORE\x20\x27'+u0+uB(0x127));const u2=p(r,'COSMO_ENDPOINT','COSMOS_ENDPOINT','COSMODB_URL'),u3=p(r,uB(w8.e),'COSMOS_KEY'),u4=p(r,uB(w8.A)),u5=p(r,uB(w8.u0)),u6=p(r,uB(0xaf)),u7=p(r,uB(w8.u1),'COSMOS_DATABASE',uB(w8.u2))??uB(w8.u3),u8=p(r,'COSMO_DB_SESSION_CONTAINER_ID',uB(0xc5),uB(w8.u4))??uB(0x116);if(!u2||!u3&&(!u4||!u5||!u6))throw new Error(uB(0xb3));const [{CosmosClient:u9},{ClientSecretCredential:uu}]=await Promise['all']([import(uB(w8.u5)),import(uB(w8.u6))]),uw=u3?new u9({'endpoint':u2,'key':u3}):new u9({'endpoint':u2,'aadCredentials':new uu(u4,u5,u6)}),{database:uf}=await uw[uB(w8.u7)][uB(0x109)]({'id':u7}),uk=Number(r[uB(w8.u8)](uB(0xd5),uB(0xa0))),{container:uQ}=await uf['containers'][uB(0x109)]({'id':u8,'partitionKey':{'paths':['/id']},...Number[uB(0x98)](uk)&&uk>0x0?{'throughput':uk}:{}}),{resource:uO}=await uQ[uB(0xac)](),uY=uO?.[uB(0x13c)]?.[uB(w8.u9)]??[];if(!uY[uB(0xda)](uB(0xf5)))throw new Error('Cosmos\x20container\x20\x27'+u8+'\x27\x20must\x20use\x20partition\x20key\x20/id;\x20found\x20'+(uY[uB(0x145)](',\x20')||'none')+'.');const {CosmosSessionDocumentContainer:uM}=await import(uB(w8.uu));return new N(new uM(uQ,()=>uw[uB(0x126)]()),u1);}async[ut(0x128)](d){const w9={d:0x117,n:0x101},uy=ut,n=await this[uy(w9.d)](d);return n?.[uy(w9.n)]===h?n:void 0x0;}async[ut(0x117)](d){const wu={d:0xe7},uK=ut;try{const {resource:n}=await this[uK(wu.d)][uK(0x13e)](d,d)[uK(0xac)]();return n;}catch(r){if(G(r))return;throw r;}}async[ut(0x108)](r,H,E){const ww={d:0xca,n:0x117,r:0x123,H:0x103,E:0xa1,z:0x13d,D:0xcb,e:0xe7,A:0xd4,u0:0xff,u1:0xdf,u2:0xbb,u3:0xcb},ui=ut,z=Y[ui(ww.d)](E[ui(0x11d)]),D=l(E[ui(0xe2)]),A=await this[ui(ww.n)](r);A&&A[ui(0x101)]===h&&T(A,z);const u0=new Date(),u1={'owner':H,'expiresAt':new Date(u0[ui(ww.r)]()+this[ui(ww.H)])[ui(0xa1)]()};if(!A){const u3=this['placeholderDocument'](r,E,z,D,u1,u0[ui(ww.E)]());if(await this['container'][ui(ww.z)]({'expectedRevision':null},u3)==='conflict')throw new f(g,ui(0xbb)+r+ui(ww.D));return{'kind':ui(0xff),'document':u3,'expectedRevision':u3['revision']};}if(A[ui(0x101)]!==h){const u4=this['placeholderDocument'](r,E,z,D,u1,u0['toISOString']());if(await this[ui(ww.e)][ui(0x13d)]({'expectedRevision':S(A),'replaceIncompatible':!0x0},u4)===ui(ww.A))throw new f(g,ui(0xbb)+r+'\x27\x20is\x20already\x20processing\x20a\x20turn.');return{'kind':ui(ww.u0),'document':u4,'expectedRevision':u4[ui(0xb2)]};}if(K(A[ui(0xdf)])&&A[ui(ww.u1)]?.[ui(0x135)]!==H)throw new f(g,'Session\x20\x27'+r+ui(ww.D));const u2={...A,'revision':S(A)+0x1,'turn':u1};if(await this['container']['compareAndSwap']({'expectedRevision':S(A),'requireFreeLease':!0x0,'allowOwner':H},u2)==='conflict')throw new f(g,ui(ww.u2)+r+ui(ww.u3));return{'kind':'leased','document':u2,'expectedRevision':S(u2)};}async[ut(0x12b)](d,r){const uL=ut,H=await this['getSession'](d);if(H)return this[uL(0x102)](H,r);}[ut(0x102)](d,r){const wk={d:0x129,n:0x129,r:0xa5,H:0x13a,E:0x114,z:0x11f,D:0xfc},ul=ut,H=Y[ul(0xca)](r);T(d,H);const {graph:E}=d;if(!E[ul(wk.d)])return;const z=a({},E[ul(wk.n)]),D=ae(E[ul(wk.r)]);return{'currentNode':E[ul(0x9f)],'config':E[ul(wk.H)]??{},'context':s(E[ul(wk.E)]===void 0x0?{}:E['context']),'completed':d[ul(wk.z)]===ul(wk.D)||E[ul(0x9f)]===m,'nodes':z,'tokens':L(d[ul(0xab)]),'decisionUsage':o(d['decisionUsage']),'histories':D,'inputConsumed':!0x0,'response':''};}async[ut(0xd9)](r,H,z,D=B(),A={}){const wQ={d:0xe2,n:0xa1,r:0x129,H:0xfc,E:0x140,z:0xe0,D:0x11c,e:0x9f,A:0x114,u0:0x10f,u1:0x135,u2:0x13d,u3:0xd4,u4:0xbb,u5:0xcb},uj=ut,u0=Y[uj(0xca)](z[uj(0x11d)]),u1=l(z[uj(wQ.d)]),u2=await this[uj(0x117)](r),u3=u2?.[uj(0x101)]===h?u2:void 0x0;u3&&(T(u3,u0),j(u3,u1));const u4=new Date()[uj(wQ.n)](),u5=oe(a({},H[uj(wQ.r)])),{tokens:u6,histories:u7}=H,u8=this[uj(0xc4)](u2,A),u9={'version':h,'id':r,'revision':u8===null?0x0:u8+0x1,'status':H[uj(wQ.H)]?'completed':'in_progress','tokens':L(u6),'decisionUsage':o(H[uj(wQ.E)]),'errors':[...u3?.[uj(0xe0)]??[],...D[uj(wQ.z)]],'warnings':[...u3?.[uj(0xcd)]??[],...D[uj(0xcd)]],'decisions':[...u3?.['decisions']??[],...D[uj(wQ.D)]],'graph':{'id':u0,'schemaVersion':u1,'currentNode':H[uj(wQ.e)],'config':H[uj(0x13a)],'context':s(H[uj(wQ.A)]===void 0x0?{}:H[uj(wQ.A)]),'histories':se(u7),'model':t[uj(wQ.u0)](z[uj(0xf3)]),'nodes':u5},...A['keepTurn']&&u3?.[uj(0xdf)]?{'turn':{'owner':u3[uj(0xdf)][uj(wQ.u1)],'expiresAt':new Date(Date[uj(0x130)]()+this[uj(0x103)])[uj(0xa1)]()}}:{},'createdAt':u3?.['createdAt']??u4,'modifiedAt':u4};if(await this['container'][uj(wQ.u2)](this[uj(0x12e)](u2,A,u8),u9)===uj(wQ.u3))throw new f(A['owner']?q:g,A[uj(0x135)]?uj(wQ.u4)+r+uj(0xa3):uj(0xbb)+r+uj(wQ.u5));return u9;}async['appendLogs'](r,H,E,z={}){const wO={d:0xe2,n:0x128,r:0x140,H:0xe0,E:0x11c,z:0x9f,D:0x13a,e:0xa5,A:0x114,u0:0xf3,u1:0x131,u2:0x131,u3:0x141,u4:0x13d,u5:0x12e,u6:0x135,u7:0xbb,u8:0x12d},uR=ut,D=Y[uR(0xca)](E[uR(0x11d)]),A=l(E[uR(wO.d)]),u0=await this[uR(wO.n)](r);u0&&(T(u0,D),j(u0,A));const u1=new Date()['toISOString'](),u2=this[uR(0xc4)](u0,z),u3={'version':h,'id':r,'revision':u2===null?0x0:u2+0x1,'status':H[uR(0xe0)]['length']>0x0?uR(0xaa):u0?.['status']??'in_progress','tokens':u0?.[uR(0xab)]??i(),'decisionUsage':H[uR(0x11c)][uR(0xc8)]((u4,u5)=>R(u4,u5['usage']),o(u0?.[uR(wO.r)])),'errors':[...u0?.[uR(wO.H)]??[],...H[uR(0xe0)]],'warnings':[...u0?.[uR(0xcd)]??[],...H[uR(0xcd)]],'decisions':[...u0?.[uR(wO.E)]??[],...H[uR(0x11c)]],'graph':{'id':D,'schemaVersion':A,...u0?{'currentNode':u0['graph'][uR(wO.z)],'config':u0['graph'][uR(wO.D)]}:{},'histories':u0?.[uR(0x131)][uR(wO.e)]??{},'context':s(u0?.['graph'][uR(wO.A)]===void 0x0?{}:u0[uR(0x131)]['context']),'model':t['modelMetadata'](E[uR(wO.u0)]),...u0?.[uR(wO.u1)][uR(0x129)]?{'nodes':u0[uR(wO.u2)][uR(0x129)]}:{}},'createdAt':u0?.[uR(wO.u3)]??u1,'modifiedAt':u1};if(await this['container'][uR(wO.u4)](this[uR(wO.u5)](u0,z,u2),u3)==='conflict'){if(z[uR(wO.u6)]){console['warn'](uR(wO.u7)+r+uR(0xf0)+H[uR(wO.H)]['length']+'\x20error(s)\x20and\x20'+H['warnings'][uR(wO.u8)]+uR(0xe3));return;}throw new f(g,'Session\x20\x27'+r+uR(0xcb));}return u3;}async['endFailedTurn'](d,r,H,E,z){const wY={d:0xe0,n:0xcd,r:0x9c},ug=ut;if(E&&(E[ug(wY.d)][ug(0x12d)]>0x0||E[ug(wY.n)][ug(0x12d)]>0x0||E[ug(0x11c)][ug(0x12d)]>0x0)){await this[ug(0xee)](d,E,H,{'owner':r,...z!==void 0x0?{'expectedRevision':z}:{}});return;}await this[ug(wY.r)](d,r,z);}async[ut(0x9c)](d,r,H){const wM={d:0x135,n:0x13d},uZ=ut,E=await this['getSession'](d);if(!E||E['turn']?.[uZ(wM.d)]!==r)return;const z=H??S(E),{turn:D,...A}=E,u0={...A,'modifiedAt':new Date()['toISOString']()};await this[uZ(0xe7)][uZ(wM.n)]({'expectedRevision':z,'requireOwner':r},u0);}async[ut(0x120)](d){const wm={d:0xe7},ux=ut;try{await this[ux(wm.d)][ux(0x13e)](d,d)[ux(0x138)]();}catch(n){if(!G(n))throw n;}}async['persistMigratedSession'](d,r={}){const wq={d:0x100,n:0xc3,r:0x131,H:0xeb,E:0x128,z:0xdf,D:0x114,e:0x141,A:0x141,u0:0xbb,u1:0xb8},uX=ut;if(d['version']!==h)throw new Error(uX(wq.d)+d[uX(0x101)]+uX(wq.n)+h+'.');Y[uX(0xca)](d[uX(0x131)]['id']),l(d[uX(wq.r)][uX(wq.H)]);const H=await this[uX(wq.E)](d['id']),E=r[uX(0x113)]??S(H||d),z=H?.[uX(0xdf)]??d[uX(wq.z)],D={...d,'graph':{...d['graph'],'context':s(d[uX(wq.r)][uX(wq.D)]===void 0x0?{}:d['graph']['context'])},'revision':E,'createdAt':H?.[uX(wq.e)]??d[uX(wq.A)],'modifiedAt':H?.[uX(0xf6)]??d[uX(0xf6)],...z?{'turn':z}:{}};if(await this['container'][uX(0x13d)]({'expectedRevision':E,...r[uX(0x135)]?{'requireOwner':r[uX(0x135)]}:{'requireFreeLease':!0x0}},D)===uX(0xd4))throw new f(r[uX(0x135)]?q:g,uX(wq.u0)+d['id']+uX(wq.u1));}async[ut(0x13f)](){const uo=ut;await this['container'][uo(0x13f)]?.();}[ut(0xd3)](d,r,H,E,z,D){const wW={d:0x144},uS=ut;return{'version':h,'id':d,'revision':0x0,'status':uS(wW.d),'tokens':i(),'decisionUsage':Z(),'errors':[],'warnings':[],'decisions':[],'graph':{'id':H,'schemaVersion':E,'histories':{},'context':{},'model':t[uS(0x10f)](r[uS(0xf3)])},'turn':z,'createdAt':D,'modifiedAt':D};}['commitExpectedRevision'](d,n){const wJ={d:0x113},ud=ut;return n[ud(wJ.d)]!==void 0x0?n[ud(wJ.d)]:d?S(d):null;}[ut(0x12e)](d,r,H){const wv={d:0x135,n:0x101},uT=ut;return r[uT(wv.d)]?{'expectedRevision':H,'requireOwner':r['owner']}:d&&d[uT(wv.n)]!==h?{'expectedRevision':H,'replaceIncompatible':!0x0}:{'expectedRevision':H,'requireFreeLease':!0x0};}}function p(d,...H){const un=ut;for(const E of H){const z=d[un(0x119)](E);if(z)return z;}}c(p,ut(0x107));function T(d,n){const wP={d:0x131,n:0xbb,r:0xfe,H:0x13b},uc=ut;if(d[uc(wP.d)]['id']!==n)throw new Error(uc(wP.n)+d['id']+uc(wP.r)+d['graph']['id']+'\x27,\x20not\x20\x27'+n+uc(wP.H));}c(T,ut(0xf4));function j(d,n){const wp={d:0x131,n:0xeb,r:0xfb,H:0xb6,E:0x131,z:0xeb,D:0xea,e:0xae},uG=ut;if(d[uG(wp.d)][uG(wp.n)]!==n)throw new Error('Session\x20\x27'+d['id']+uG(wp.r)+d['graph']['id']+uG(wp.H)+d[uG(wp.E)][uG(wp.z)]+uG(wp.D)+n+uG(wp.e));}c(j,ut(0xde));function oe(d){const wC={d:0x11e},wt={d:0x121},uV=ut;return Object[uV(0xc0)](Object[uV(0xd2)](d)[uV(wC.d)](([H,E])=>{const ur=uV;if(!E||typeof E!=ur(wt.d))return[H,E];const {toolTrace:z,...D}=E;return[H,D];}));}c(oe,ut(0x132));function ie(d){const wa={d:0xef,n:0x12d,r:0xe5,H:0xd1,E:0xcf,z:0xf7,D:0x111,e:0x12d,A:0xf9,u0:0x12d,u1:0xf9};return d['map'](n=>{const uH=w,H={...n[uH(0xb1)]},E=n['type']==='ai'&&Array[uH(wa.d)](H[uH(0x111)])&&H[uH(0x111)][uH(wa.n)]>0x0?ce(H[uH(0xe5)]):void 0x0,z=b(H[uH(wa.r)])&&H[uH(0xe5)][uH(wa.H)]===!0x0;return delete H[uH(0xe5)],(E||z)&&(H['additional_kwargs']={...E?{'originalTextContentBlock':E}:{},...z?{'ezgraphInternal':!0x0}:{}}),delete H[uH(wa.E)],delete H[uH(wa.z)],n[uH(0xbc)]==='ai'&&(Array[uH(0xef)](H[uH(wa.D)])&&H[uH(0x111)][uH(wa.e)]===0x0&&delete H[uH(wa.D)],Array['isArray'](H[uH(wa.A)])&&H[uH(0xf9)][uH(wa.u0)]===0x0&&delete H[uH(wa.u1)]),{...n,'data':H};});}c(ie,ut(0x9a));function se(d){const wy={d:0xd2,n:0x11e},uN=ut;return Object[uN(0xc0)](Object[uN(wy.d)](d)[uN(wy.n)](([n,H])=>[n,ie(k(H))]));}c(se,ut(0xa4));function ae(d={}){const wK={d:0xc0},uh=ut;return Object[uh(wK.d)](Object[uh(0xd2)](d)[uh(0x11e)](([n,H])=>[n,O(H)]));}c(ae,ut(0xa9));function ce(d){const wi={d:0x9e,n:0x133,r:0x9e},uF=ut;if(!b(d))return;const n=d[uF(0x10d)];if(!(!b(n)||typeof n[uF(wi.d)]!=uF(0xc7)))return{...typeof n[uF(wi.n)]==uF(0xc7)?{'text':n['text']}:{},'thoughtSignature':n[uF(wi.r)],...n[uF(0xba)]===!0x0?{'thought':!0x0}:{}};}c(ce,ut(0xf1));function b(d){const uE=ut;return d!==null&&typeof d==uE(0x121)&&!Array['isArray'](d);}c(b,ut(0x104));class V{static{c(this,ut(0xb9));}[ut(0x105)]=new Map();get[ut(0x9b)](){const uz=ut;return this[uz(0x105)][uz(0x9b)];}[ut(0xbf)]={'upsert':c(async e=>{const wj={d:0x105},ub=ut,t=e;return this[ub(wj.d)]['set'](t['id'],structuredClone(t)),{};},ut(0x124))};async[ut(0x13d)](d,r){const wR={d:0x105},uD=ut,H=this[uD(wR.d)][uD(0x119)](r['id']);return de(H,d)?(this['documents'][uD(0x10e)](r['id'],structuredClone(r)),'ok'):'conflict';}[ut(0x13e)](d,n){const wZ={d:0x119,n:0xc1,r:0x11b},wg={d:0x105},uA=ut;return{'read':c(async()=>{const uU=w,r=this[uU(wg.d)][uU(0x119)](d);if(!r||r['id']!==n)throw Object[uU(0xc1)](new Error('Not\x20found'),{'code':0x194});return{'resource':structuredClone(r)};},'read'),'delete':c(async()=>{const ue=w,r=this[ue(0x105)][ue(wZ.d)](d);if(!r||r['id']!==n)throw Object[ue(wZ.n)](new Error(ue(wZ.r)),{'code':0x194});return this[ue(0x105)]['delete'](d),{};},uA(0x138))};}}function G(d){const w0=ut;if(!d||typeof d!=w0(0x121))return!0x1;const n=d;return n[w0(0xb4)]===0x194||n[w0(0x12f)]===0x194;}c(G,ut(0x139));function F(d=process.env.SESSION_TURN_LEASE_MS){const wo={d:0x118},w1=ut,n=Number(d??w1(wo.d));return Number[w1(0x98)](n)&&n>0x0?n:0xea60;}function w(f,k){f=f-0x98;const Q=u();let O=Q[f];if(w['zZPXch']===undefined){var Y=function(I){const W='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let J='',v='';for(let s=0x0,P,p,t=0x0;p=I['charAt'](t++);~p&&(P=s%0x4?P*0x40+p:p,s++%0x4)?J+=String['fromCharCode'](0xff&P>>(-0x2*s&0x6)):0x0){p=W['indexOf'](p);}for(let C=0x0,a=J['length'];C<a;C++){v+='%'+('00'+J['charCodeAt'](C)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(v);};w['quHhSI']=Y,w['AkYZlF']={},w['zZPXch']=!![];}const M=Q[0x0],m=f+M,q=w['AkYZlF'][m];return!q?(O=w['quHhSI'](O),w['AkYZlF'][m]=O):O=q,O;}c(F,ut(0xe6));function S(d){const wS={d:0xb2},w2=ut;return d?.[w2(wS.d)]??0x0;}c(S,ut(0x142));function K(d,n=Date['now']()){const wd={d:0x135,n:0xcc,r:0xb7},w3=ut;if(!d?.[w3(wd.d)]||!d[w3(0xb7)])return!0x1;const H=Date[w3(wd.n)](d[w3(wd.r)]);return Number['isFinite'](H)&&H>n;}c(K,ut(0xb5));function de(d,n,H=Date[ut(0x130)]()){const wT={d:0x113,n:0xdf,r:0xf2,H:0xd0},w4=ut;return n[w4(0x10c)]?d!==void 0x0&&d['version']!==h:n[w4(wT.d)]===null?d===void 0x0:!(!d||S(d)!==n[w4(0x113)]||n['requireOwner']&&d[w4(wT.n)]?.[w4(0x135)]!==n[w4(wT.r)]||n[w4(wT.H)]&&K(d[w4(0xdf)],H)&&d['turn']?.[w4(0x135)]!==n[w4(0x143)]);}c(de,ut(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 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const X=k;(function(v,s){const u5={v:0xe8,s:0xc4,P:0xde,t:0x10f,C:0xc5,a:0x10d},Z=k,P=v();while(!![]){try{const t=parseInt(Z(u5.v))/0x1+parseInt(Z(0x108))/0x2*(-parseInt(Z(u5.s))/0x3)+parseInt(Z(u5.P))/0x4*(-parseInt(Z(0xd7))/0x5)+parseInt(Z(u5.t))/0x6*(-parseInt(Z(0xfa))/0x7)+parseInt(Z(0xe2))/0x8*(-parseInt(Z(0xcd))/0x9)+-parseInt(Z(0xf3))/0xa*(-parseInt(Z(u5.C))/0xb)+parseInt(Z(u5.a))/0xc;if(t===s)break;else P['push'](P['shift']());}catch(C){P['push'](P['shift']());}}}(f,0x39347));var m=Object[X(0xc9)],p=(v,s)=>m(v,X(0xd8),{'value':s,'configurable':!0x0});import{END as Q,isCommand as O,START as Y,StateGraph as M}from'@langchain/langgraph';import{GRAPH_NODE_CLASS as q,GraphNode as I}from'./graph-node.js';function k(u,w){u=u-0xc3;const Q=f();let O=Q[u];if(k['uhJOwZ']===undefined){var Y=function(I){const W='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let J='',v='';for(let s=0x0,P,p,t=0x0;p=I['charAt'](t++);~p&&(P=s%0x4?P*0x40+p:p,s++%0x4)?J+=String['fromCharCode'](0xff&P>>(-0x2*s&0x6)):0x0){p=W['indexOf'](p);}for(let C=0x0,a=J['length'];C<a;C++){v+='%'+('00'+J['charCodeAt'](C)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(v);};k['CPtMFs']=Y,k['PUoJpy']={},k['uhJOwZ']=!![];}const M=Q[0x0],m=u+M,q=k['PUoJpy'][m];return!q?(O=k['CPtMFs'](O),k['PUoJpy'][m]=O):O=q,O;}import{GRAPH_END_NODE as W}from'./graph-state.js';import{stableClassId as J}from'./stable-id.js';class x{static{p(this,'StateGraphExt');}[X(0xca)];[X(0xdd)];[X(0xdc)];[X(0xe7)]=new Set();[X(0xfd)]=new Map();[X(0x107)]=new Map();constructor(v,s,P=W){const o=X;this['createGraphNode']=s,this[o(0xdd)]=P,this[o(0xdc)]=new M(v);}[X(0xe3)](v){const u7={v:0xca,s:0xca,P:0x10e,t:0xd3},S=X;if(!g(v))throw new Error(S(0xcc));if(!this[S(u7.v)])throw new Error('This\x20graph\x20has\x20no\x20GraphNode\x20factory.');const s=this[S(u7.s)](v),P=J(v,'graph\x20node');if(s['id']!==P)throw new Error(S(u7.P)+P+S(u7.t)+s['id']+'\x27.');return this[S(0xfd)][S(0xd5)](P,v),this['registerNode'](s,[...this['addedNodeIds'],P,Q]);}[X(0xea)](...v){const u9={v:0xca,s:0xec,P:0xf5,t:0xd3},u8={v:0xe6,s:0x101},d=X;if(!this[d(u9.v)])throw new Error('This\x20graph\x20has\x20no\x20GraphNode\x20factory.');const P=v['map'](K=>{const T=d;if(!g(K))throw new Error(T(u8.v));return J(K,T(u8.s));}),C=P['find']((K,i)=>P['indexOf'](K)!==i||this[d(0xe7)][d(0xd6)](K));if(C)throw new Error(d(u9.s)+C+d(u9.P));const B=[...this[d(0xe7)],...P,Q];for(const [K,i]of v['entries']()){const L=this[d(0xca)](i),j=P[K];if(L['id']!==j)throw new Error(d(0x10e)+j+d(u9.t)+L['id']+'\x27.');this['nodeClasses'][d(0xd5)](j,i),this[d(0xd4)](L,B);}return this;}[X(0xee)](...v){const n=X;return this['nodes'](...v),this[n(0xdf)](...v),this;}[X(0xcf)](v,s){const uw={v:0x100,s:0x103,P:0xcf},V=X,P=Array[V(uw.v)](v)?v:[v];for(const a of P)this[V(0x10a)](a);this[V(0xf1)](s);const C=P[V(uw.s)](c);return this['graph'][V(uw.P)](C['length']===0x1?C[0x0]:C,c(s)),this;}[X(0xf0)](v,s){const uf={v:0xf4},r=X,P=J(v,'graph\x20node'),C=this[r(0x107)][r(0x10c)](P);if(!C)throw new Error('Graph\x20node\x20\x27'+P+'\x27\x20must\x20be\x20added\x20before\x20it\x20is\x20connected.');return this[r(uf.v)](v,C[r(0xf8)]['bind'](C),s),this;}[X(0xd9)](v,s){const uQ={v:0xfc,s:0xf4,P:0x106,t:0x103},uk={v:0xef},H=X,P=J(v,H(0x101));if(!this['nodeInstances'][H(0xd6)](P))throw new Error(H(0xec)+P+H(0xc7));if(s[H(uQ.v)][H(0xd0)]===0x0)throw new Error('branchBy()\x20requires\x20at\x20least\x20one\x20case.');const C=s[H(uQ.v)]['map'](({when:L})=>this['currentNodeSelectorName'](L)),B=C[H(0xd1)]((L,j)=>C[H(0xe0)](L)!==j);if(B)throw new Error(H(0xe5)+B+'\x27.');const K=C['map']((L,j)=>H(0x10b)+j),i='otherwise';return this[H(uQ.s)](v,L=>{const N=H,j=L[N(0xfe)];if(typeof j!=N(uk.v))throw new Error(N(0xec)+P+N(0xf7));const R=C[N(0xe0)](j);return R===-0x1?i:K[R];},{...Object[H(uQ.P)](s['cases'][H(uQ.t)](({routeTo:L},j)=>[K[j],L])),[i]:s[H(0xdb)]}),this;}['registerTurns'](...v){const uO={v:0xf9,s:0x102,P:0x103},F=X;if(v[F(uO.v)](s=>J(s,'graph\x20node')===this[F(0xdd)]))throw new Error(F(uO.s)+this[F(0xdd)]+'\x27\x20is\x20reserved\x20by\x20StateGraphExt.registerTurns().');return this['addConditionalEdge'](Y,s=>s[F(0xfe)],{...Object[F(0x106)](v[F(uO.P)](s=>[J(s,F(0x101)),s])),[this[F(0xdd)]]:Q}),this;}[X(0xda)](){const uY={v:0x107,s:0xcb,P:0xda},z=X;for(const v of this[z(uY.v)][z(uY.s)]())v['validateTools']?.();return this['graph'][z(uY.P)]();}['addConditionalEdge'](v,s,P){const uM={v:0xf1,s:0xce},D=X;this['assertSource'](v);for(const C of Object[D(0xcb)](P))this[D(uM.v)](C);this['graph'][D(0xe9)](c(v),s,Object['fromEntries'](Object[D(uM.s)](P)['map'](([a,B])=>[a,c(B)])));}[X(0xd4)](v,s){const uq={v:0xec},um={v:0xc3,s:0xc3,P:0xc3},U=X;if(this[U(0xe7)]['has'](v['id']))throw new Error(U(uq.v)+v['id']+'\x27\x20is\x20already\x20registered.');return this[U(0xdc)]['addNode'](v['id'],async P=>{const e=U,C=await v['invoke'](P);if(O(C)){const B=Array['isArray'](C['goto'])?C[e(um.v)]:C[e(um.s)]===void 0x0?[]:[C[e(um.P)]];for(const K of B)typeof K=='string'&&this['assertTarget'](K);}return C;},{'ends':[...new Set(s)]}),this['addedNodeIds'][U(0xd2)](v['id']),this['nodeInstances']['set'](v['id'],v),this;}[X(0x10a)](v){const uI={v:0x104},A=X;c(v)!==Y&&this[A(uI.v)](v,A(0xe1));}['assertTarget'](v){const u0=X;c(v)!==Q&&this['assertAddedNode'](v,u0(0xeb));}[X(0x104)](v,s){const uJ={v:0xd6,s:0xfb},u1=X,P=c(v);if(!this['addedNodeIds'][u1(uJ.v)](P))throw new Error(u1(uJ.s)+s+'\x20\x27'+P+u1(0xc7));}[X(0xf2)](v){const uv={v:0xef,s:0x101,P:0xf6,t:0xd6,C:0xe4},u2=X;if(typeof v!=u2(uv.v)){if(!g(v))throw new Error(u2(0xff));const s=J(v,u2(uv.s));if(!this['addedNodeIds'][u2(0xd6)](s))throw new Error(u2(uv.P)+s+u2(0xc6));return s;}if(v!==this[u2(0xdd)]&&!this[u2(0xe7)][u2(uv.t)](v))throw new Error(u2(0xf6)+v+u2(uv.C)+this[u2(0xdd)]+'\x27.');return v;}}function g(v){const u3=X,s=v;return typeof v==u3(0x105)&&v!==null&&s[q]===!0x0&&s[u3(0xed)]instanceof I;}p(g,X(0x109));function c(v){const uP={v:0xef},u4=X;return typeof v==u4(uP.v)?v:J(v,'graph\x20node');}p(c,X(0xc8));export{x as StateGraphExt};function f(){const up=['BMfTzq','yNjHBMnOqNK','y29TCgLSzq','B3rOzxj3AxnL','z3jHCgG','zw5KtM9Kzq','mZmXmLntELbvvW','CMvNAxn0zxjuDxjUCW','Aw5KzxHpzG','C291CMnL','mtzqzxrltfa','ywrKtM9Kzq','jYbTDxn0igjLigfUigfKzgvKieDYyxbOtM9KzsbVCIb0AguGy29UzMLNDxjLzcb0zxjTAw5HBcbZDgf0zsaN','yNjHBMnOqNKOksbOyxmGBw9Yzsb0AgfUig9UzsbJyxnLigzVCIaN','u3rHDgvhCMfWAev4DcbUB2rLCYbTDxn0igjLigfKzgvKigfZieDYyxbOtM9KzsbJBgfZC2vZoIbNCMfWAc5UB2rLCYHnEu5VzguPlG','ywrKzwroB2rLswrZ','mJu5mJuWwNLwt0fb','ywrKq29UzgL0Aw9UywXfzgDLCW','BM9Kzxm','DgfYz2v0','r3jHCgGGBM9KzsaN','ChjVDg90ExbL','CMvNAxn0zxjuDxjUtM9Kzxm','C3rYAw5N','yNjHBMnO','yxnZzxj0vgfYz2v0','y3vYCMvUDe5VzgvtzwXLy3rVCK5HBwu','mtuXmeXbEhL1uq','ywrKq29UzgL0Aw9UywXfzgDL','jYbPCYbHBhjLywr5ihjLz2LZDgvYzwqU','q3vYCMvUDc1UB2rLihnLBgvJDg9YicC','jYbJyw5UB3qGyNjHBMnOihDPDgHVDxqGysbZDhjPBMCGy3vYCMvUDe5VzguU','CM91Dgu','C29Tzq','ntzhCKzws2K','q29UzgL0Aw9UywWGB3iGzgLYzwn0igvKz2uG','y2fZzxm','BM9KzunSyxnZzxm','y3vYCMvUDe5Vzgu','yNjHBMnOqNKOksbZzwXLy3rVCNmGBxvZDcbIzsbhCMfWAe5VzguGy2XHC3nLCYbVCIb0AguGy29UzMLNDxjLzcb0zxjTAw5HBcbZDgf0zs4','AxnbCNjHEq','z3jHCgGGBM9Kzq','vgHLihrLCM1PBMfSihn0yxrLicC','BwfW','yxnZzxj0qwrKzwroB2rL','zNvUy3rPB24','zNjVBuvUDhjPzxm','BM9KzuLUC3rHBMnLCW','mtmWofrzD3DYCW','AxnhCMfWAe5VzgvdBgfZCW','yxnZzxj0u291CMnL','y2fZztO','z2v0','nteXmZmYmg1dDKPdtW','r3jHCgGGBM9KzsbMywn0B3j5igzVCIaN','mJu4ndHMuu95ww8','z290BW','nJi3DNHeyNnq','mJeWndnKyLHfr0W','jYbTDxn0igjLigfKzgvKigjLzM9YzsbPDcbPCYb1C2vKlG','jYbTDxn0igjLigfKzgvKigjLzM9YzsbPDcbPCYbJB25Uzwn0zwqU','zw5KCg9PBNrjza','zgvMAw5LuhjVCgvYDhK','y3jLyxrLr3jHCgHoB2rL','DMfSDwvZ','u3rHDgvhCMfWAev4DcbUB2rLCYbTDxn0igjLigfKzgvKigfZieDYyxbOtM9KzsbJBgfZC2vZoIbNCMfWAc5HzgroB2rLke15tM9KzsKU','mtG2mJy2n2ritNruCq','zw50CMLLCW','ywrKrwrNzq','BgvUz3rO','zMLUza','ywrK','jYbYzxr1CM5LzcaN','CMvNAxn0zxjoB2rL','C2v0','AgfZ','otm1vgPyBfb0'];f=function(){return up;};return f();}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{GraphContextChannel as r}from"./framework/graph-context.js";import{BaseGraph as t}from"./framework/base-graph.js";import{GRAPH_NODE_CLASS as n,GraphNode as a,GraphNodeRuntime as
|
|
1
|
+
import{GraphContextChannel as r}from"./framework/graph-context.js";import{BaseGraph as t}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 L,assertLlmTimeoutMs as f}from"./framework/llm-gateway.js";import{LlmRunner as l,DEFAULT_LLM_POLICY as g,DEFAULT_EMPTY_HISTORY_SEED as D,DEFAULT_EMPTY_RESPONSE_RECOVERY as T,DEFAULT_MAX_AGENT_ROUNDS as _,EmptyModelResponseError as R,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,go as F,isToolResponse as Y,stay as H}from"./framework/tool-response.js";import{GraphStateSupport as B}from"./framework/graph-state-support.js";import{GRAPH_END_NODE as V,createGraphStateAnnotation as W}from"./framework/graph-state.js";import{GraphRegistry as z}from"./framework/graph-registry.js";import{GraphEngine as J}from"./framework/graph-engine.js";import{ConfigManager as X}from"./framework/config-manager.js";import{StateGraphExt as K}from"./framework/state-graph-ext.js";import{TerminateSessionNode as $}from"./framework/terminate-session.node.js";import{SessionLogError as oe,SessionLogDecision as re,SessionLogWarning as se,createSessionLogs as te,drainSessionLogs as ie,restoreSessionLogs as ne,withSessionLogs as ae}from"./framework/session-log.js";import{ProviderFileManager as pe}from"./framework/llm-file.js";import{SessionManager as Ee,SessionTurnError as xe,SESSION_BUSY as Le,SESSION_CONFLICT as fe,SESSION_COMPLETED as de,SESSION_DOCUMENT_VERSION as le,MemorySessionDocumentContainer as ge,sessionTurnLeaseMs as De,sessionRevision as Te,isLiveSessionTurn as _e,matchesSessionWritePredicate as Re}from"./framework/persistence/session-manager.js";import{MongoDbSessionDocumentContainer as Ce}from"./framework/persistence/mongodb-session-document.container.js";import{SqliteSessionDocumentContainer as ue}from"./framework/persistence/sqlite-session-document.container.js";import{CosmosSessionDocumentContainer as Ne}from"./framework/persistence/cosmos-session-document.container.js";import{mergeNodeStates as Ie,replaceNodeStates as Ge}from"./framework/node-state.js";import{LangChainLlmGateway as he}from"./framework/langchain-llm-gateway.js";import{ModelProvider as ye}from"./framework/model-provider.js";import{langChainModelInitialization as Fe}from"./framework/langchain-provider.adapter.js";import{GRAPH_LLM_PROVIDERS as He,GRAPH_LLM_FAMILIES as ke,GRAPH_LLM_CAPABILITIES as Be,BUILT_IN_MODEL_CATALOG as be,GraphLlm as Ve,ModelCatalog as We,ModelProviderRegistry as we}from"./framework/graph-llm.config.js";import{addTokenUsage as qe,emptyTokenUsage as Je,modelExecution as Qe,normalizeTokenUsage as Xe,tokenUsageFromMessage as je}from"./framework/token-usage.js";import{DecisionNode as Ze}from"./framework/decision/decision-node.js";import{DecisionRunner as eo}from"./framework/decision/decision-runner.js";import{DecisionProvider as ro,DecisionProviderRegistry as so}from"./framework/decision/decision-provider.js";import{TypeSafeClassifierAdapter as io}from"./framework/decision/typesafe-provider.js";import{DecisionConfigurationError as ao,DecisionTimeoutError as mo,DecisionValidationError as po,DEFAULT_DECISION_OPTIONS as So,addDecisionUsage as Eo,decisionUsage as xo,emptyDecisionUsage as Lo,normalizeDecisionUsage as fo,resolveDecisionOptions as lo}from"./framework/decision/decision-types.js";import{assertJsonCompatible as Do,validateDecisionQuestions as To,validateDecisionResult as _o}from"./framework/decision/decision-validation.js";import{retryWithModel as co,LlmResponseBlockedError as Co,LlmSetupError as Mo}from"./framework/llm-lifecycle.js";export{be as BUILT_IN_MODEL_CATALOG,t as BaseGraph,X as ConfigManager,Ne as CosmosSessionDocumentContainer,So as DEFAULT_DECISION_OPTIONS,D as DEFAULT_EMPTY_HISTORY_SEED,T as DEFAULT_EMPTY_RESPONSE_RECOVERY,g as DEFAULT_LLM_POLICY,_ as DEFAULT_MAX_AGENT_ROUNDS,ao as DecisionConfigurationError,Ze as DecisionNode,ro as DecisionProvider,so as DecisionProviderRegistry,eo as DecisionRunner,mo as DecisionTimeoutError,po as DecisionValidationError,R as EmptyModelResponseError,V as GRAPH_END_NODE,Be as GRAPH_LLM_CAPABILITIES,ke as GRAPH_LLM_FAMILIES,He as GRAPH_LLM_PROVIDERS,n as GRAPH_NODE_CLASS,r as GraphContextChannel,J as GraphEngine,Ve as GraphLlm,a as GraphNode,m as GraphNodeRuntime,z as GraphRegistry,B as GraphStateSupport,L as LLM_GATEWAY_FACTORY,he as LangChainLlmGateway,E as LlmNode,Co as LlmResponseBlockedError,l as LlmRunner,Mo as LlmSetupError,ge as MemorySessionDocumentContainer,We as ModelCatalog,ye as ModelProvider,we as ModelProviderRegistry,Ce as MongoDbSessionDocumentContainer,pe as ProviderFileManager,Le as SESSION_BUSY,de as SESSION_COMPLETED,fe as SESSION_CONFLICT,le as SESSION_DOCUMENT_VERSION,re as SessionLogDecision,oe as SessionLogError,se as SessionLogWarning,Ee as SessionManager,xe as SessionTurnError,ue as SqliteSessionDocumentContainer,K as StateGraphExt,$ as TerminateSessionNode,p as Tool,io as TypeSafeClassifierAdapter,Eo as addDecisionUsage,qe as addTokenUsage,c as assertEmptyResponseRetries,Do as assertJsonCompatible,f as assertLlmTimeoutMs,C as assertMaxAgentRounds,W as createGraphStateAnnotation,te as createSessionLogs,I as currentTurnContext,G as currentTurnSignal,xo as decisionUsage,u as describeStopReason,U as direct,y as directTo,ie as drainSessionLogs,Lo as emptyDecisionUsage,Je as emptyTokenUsage,v as finish,F as go,_e as isLiveSessionTurn,A as isRetryableStopReason,Y as isToolResponse,Fe as langChainModelInitialization,Re as matchesSessionWritePredicate,Ie as mergeNodeStates,Qe as modelExecution,N as modelStopReason,fo as normalizeDecisionUsage,Xe as normalizeTokenUsage,Ge as replaceNodeStates,lo as resolveDecisionOptions,ne as restoreSessionLogs,co as retryWithModel,Te as sessionRevision,De as sessionTurnLeaseMs,H as stay,je as tokenUsageFromMessage,To as validateDecisionQuestions,_o as validateDecisionResult,ae as withSessionLogs,P as withTurnContext};
|
|
@@ -3,7 +3,7 @@ export { BaseGraph, type GraphDefinition, type GraphNodeConstructor, type GraphS
|
|
|
3
3
|
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, } from "../../src/framework/graph-node.js";
|
|
4
4
|
export { LlmNode, type LlmNodeRunResult, } from "../../src/framework/llm-node.js";
|
|
5
5
|
export { LLM_GATEWAY_FACTORY, assertLlmTimeoutMs, type LlmCallOptions, type LlmGateway, type LlmGatewayFactory, type LlmGatewayTool, type LlmGatewayToolCall, } from "../../src/framework/llm-gateway.js";
|
|
6
|
-
export {
|
|
6
|
+
export { LlmRunner, DEFAULT_LLM_POLICY, DEFAULT_EMPTY_HISTORY_SEED, DEFAULT_EMPTY_RESPONSE_RECOVERY, DEFAULT_MAX_AGENT_ROUNDS, EmptyModelResponseError, assertEmptyResponseRetries, assertMaxAgentRounds, type LlmPolicy, type LlmRunResult, type EmptyResponseRecovery, } from "../../src/framework/llm-runner.js";
|
|
7
7
|
export { describeStopReason, isRetryableStopReason, modelStopReason, type ModelStopCategory, type ModelStopReason, } from "../../src/framework/model-stop-reason.js";
|
|
8
8
|
export { currentTurnContext, currentTurnSignal, withTurnContext, type TurnContext, } from "../../src/framework/turn-context.js";
|
|
9
9
|
export { direct, directTo, finish, go, isToolResponse, stay, type ToolResponse, type ToolResponseBuilder, type ToolResponseKind, } from "../../src/framework/tool-response.js";
|
|
@@ -32,4 +32,4 @@ export { DecisionProvider, DecisionProviderRegistry, type BuiltinDecisionProvide
|
|
|
32
32
|
export { TypeSafeClassifierAdapter, type TypeSafeProviderOptions, } from "../../src/framework/decision/typesafe-provider.js";
|
|
33
33
|
export { DecisionConfigurationError, DecisionTimeoutError, DecisionValidationError, DEFAULT_DECISION_OPTIONS, addDecisionUsage, decisionUsage, emptyDecisionUsage, normalizeDecisionUsage, resolveDecisionOptions, type Choice, type ChoiceAnswer, type DecisionAnswer, type DecisionAnswers, type DecisionCallOptions, type DecisionContext, type DecisionConversation, type DecisionEvidence, type DecisionErrorContext, type DecisionFailure, type DecisionMetadata, type DecisionOptions, type DecisionProviderAdapter, type DecisionQuestion, type DecisionQuestionMap, type DecisionRequest, type DecisionResult, type DecisionState, type DecisionTokenUsage, type DecisionUsage, type JsonObject, type JsonPrimitive, type JsonValue, type Noul, type NoulAnswer, type ResolvedDecisionOptions, type Score, type ScoreAnswer, } from "../../src/framework/decision/decision-types.js";
|
|
34
34
|
export { assertJsonCompatible, validateDecisionQuestions, validateDecisionResult, } from "../../src/framework/decision/decision-validation.js";
|
|
35
|
-
export { retryWithModel, LlmResponseBlockedError, LlmSetupError, type LlmAttemptErrorContext, type LlmBlockedContext, type LlmBlockedResponse, type LlmErrorContext, type LlmErrorResponse, type RetryWithModelResponse, type
|
|
35
|
+
export { retryWithModel, LlmResponseBlockedError, LlmSetupError, type LlmAttemptErrorContext, type LlmBlockedContext, type LlmBlockedResponse, type LlmErrorContext, type LlmErrorResponse, type RetryWithModelResponse, type LlmLifecycle, type GraphLlmLifecycle, } from "../../src/framework/llm-lifecycle.js";
|
|
@@ -8,7 +8,7 @@ import { StateGraphExt, type GraphNodeClass } from "./state-graph-ext.js";
|
|
|
8
8
|
import type { StateDefinitionInit } from "@langchain/langgraph";
|
|
9
9
|
import type { SessionDocument } from "./persistence/session-manager.js";
|
|
10
10
|
import type { DeepReadonly, JsonObject } from "./graph-context.js";
|
|
11
|
-
import { type
|
|
11
|
+
import { type LlmPolicy } from "./llm-runner.js";
|
|
12
12
|
import type { GraphNodeLocalState, GraphNodeTarget } from "./node-outcome.js";
|
|
13
13
|
import type { DecisionOptions, DecisionErrorContext, DecisionProviderAdapter } from "./decision/decision-types.js";
|
|
14
14
|
export type HistorySpace = readonly [GraphNodeClass, string];
|
|
@@ -51,7 +51,7 @@ export declare abstract class BaseGraph<State extends GraphState> {
|
|
|
51
51
|
readonly requiresUserMessage: boolean;
|
|
52
52
|
readonly responseMode: "chat" | "json";
|
|
53
53
|
readonly maxAgentRounds: number;
|
|
54
|
-
readonly
|
|
54
|
+
readonly llmPolicy: LlmPolicy;
|
|
55
55
|
private compiledGraph?;
|
|
56
56
|
protected readonly runtime: GraphNodeRuntime<State>;
|
|
57
57
|
private readonly nodeMap;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LlmRunResult } from "../llm-runner.js";
|
|
2
2
|
import { GraphNode, type GraphNodeResponse, type GraphNodeResult } from "../graph-node.js";
|
|
3
3
|
import type { GraphState } from "../graph-state.js";
|
|
4
4
|
import { type DecisionAnswers, type DecisionContext, type DecisionEvidence, type DecisionErrorContext, type DecisionOptions, type DecisionQuestionMap } from "./decision-types.js";
|
|
@@ -13,5 +13,5 @@ export declare abstract class DecisionNode<State extends GraphState, Questions e
|
|
|
13
13
|
validateTools(): void;
|
|
14
14
|
private assertNoChatConfiguration;
|
|
15
15
|
protected usesChatModel(): boolean;
|
|
16
|
-
protected
|
|
16
|
+
protected runLlm(_state: State, _context: Record<string, unknown>): Promise<LlmRunResult>;
|
|
17
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LlmLifecycle, GraphLlmLifecycle } from "./llm-lifecycle.js";
|
|
2
2
|
import type { GraphState } from "./graph-state.js";
|
|
3
3
|
import type { DeepReadonly, JsonObject } from "./graph-context.js";
|
|
4
4
|
import type { LlmCallOptions, LlmGateway, LlmGatewayTool } from "./llm-gateway.js";
|
|
@@ -9,7 +9,7 @@ import { Command } from "@langchain/langgraph";
|
|
|
9
9
|
import { type GraphLlmConfig, type GraphLlmConfigOverride } from "./graph-llm.config.js";
|
|
10
10
|
import type { NodeStateValue } from "./node-state.js";
|
|
11
11
|
import { GraphStateSupport } from "./graph-state-support.js";
|
|
12
|
-
import { type
|
|
12
|
+
import { type LlmPolicy, type LlmRunResult } from "./llm-runner.js";
|
|
13
13
|
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";
|
|
@@ -27,7 +27,7 @@ export type InvalidJsonResponseContext<State extends GraphState> = Readonly<{
|
|
|
27
27
|
}>;
|
|
28
28
|
export type EmptyModelResponseContext<State extends GraphState> = Readonly<{
|
|
29
29
|
state: Readonly<State>;
|
|
30
|
-
conversation: Readonly<
|
|
30
|
+
conversation: Readonly<LlmRunResult>;
|
|
31
31
|
reason: ModelStopReason;
|
|
32
32
|
}>;
|
|
33
33
|
export declare const GRAPH_NODE_CLASS: unique symbol;
|
|
@@ -58,8 +58,8 @@ export declare abstract class GraphNode<State extends GraphState, LocalState ext
|
|
|
58
58
|
validateTools(): void;
|
|
59
59
|
protected llmConfig(): GraphLlmConfig;
|
|
60
60
|
protected llmCallOptions(): LlmCallOptions;
|
|
61
|
-
protected
|
|
62
|
-
protected
|
|
61
|
+
protected runLlm(state: State, context: ToolContext): Promise<LlmRunResult>;
|
|
62
|
+
protected llmLifecycle(): LlmLifecycle | undefined;
|
|
63
63
|
private runAgentLoop;
|
|
64
64
|
protected historySpace(): string;
|
|
65
65
|
protected history(state: Pick<State, "histories">): BaseMessage[];
|
|
@@ -81,13 +81,13 @@ export declare class GraphNodeRuntime<State extends GraphState> extends GraphSta
|
|
|
81
81
|
private readonly historySpaces;
|
|
82
82
|
private readonly responseMode;
|
|
83
83
|
readonly maxAgentRounds: number;
|
|
84
|
-
readonly
|
|
84
|
+
readonly llmPolicy: LlmPolicy;
|
|
85
85
|
private readonly decisionOptions;
|
|
86
86
|
private readonly decisionErrorHandler?;
|
|
87
87
|
readonly llmLifecycle?: GraphLlmLifecycle | undefined;
|
|
88
88
|
private readonly assertContextChannel?;
|
|
89
89
|
private readonly tools;
|
|
90
|
-
constructor(endNode: State["currentNode"], defaultLlmConfig: GraphLlmConfig, historySpaces?: Readonly<Record<string, string>>, responseMode?: "chat" | "json", maxAgentRounds?: number,
|
|
90
|
+
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);
|
|
91
91
|
llmCallOptions(): LlmCallOptions;
|
|
92
92
|
expectsJsonResponse(): boolean;
|
|
93
93
|
historySpace(currentNode?: string): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AIMessage } from "@langchain/core/messages";
|
|
2
|
-
import type
|
|
2
|
+
import { type GraphLlmConfig } from "./graph-llm.config.js";
|
|
3
3
|
import type { ToolResponse } from "./tool-response.js";
|
|
4
4
|
export type LlmAttemptErrorContext = Readonly<{
|
|
5
5
|
nodeId: string;
|
|
@@ -51,11 +51,11 @@ export declare class LlmResponseBlockedError extends Error {
|
|
|
51
51
|
export declare class LlmSetupError extends Error {
|
|
52
52
|
constructor(cause: unknown);
|
|
53
53
|
}
|
|
54
|
-
export type
|
|
54
|
+
export type LlmLifecycle = Readonly<{
|
|
55
55
|
nodeId: string;
|
|
56
56
|
checkResponse(response: string | object): boolean;
|
|
57
57
|
onLlmBlocked(context: LlmBlockedContext): Promise<LlmBlockedResponse | null>;
|
|
58
58
|
shouldRetryLlmError(context: LlmAttemptErrorContext): boolean | undefined;
|
|
59
59
|
onLlmError(context: LlmErrorContext): Promise<LlmErrorResponse | null>;
|
|
60
60
|
}>;
|
|
61
|
-
export type GraphLlmLifecycle = Pick<
|
|
61
|
+
export type GraphLlmLifecycle = Pick<LlmLifecycle, "onLlmBlocked" | "shouldRetryLlmError" | "onLlmError">;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { LlmLifecycle, LlmAttemptErrorContext, LlmBlockedContext, LlmBlockedResponse, LlmErrorContext, LlmErrorResponse } from "./llm-lifecycle.js";
|
|
2
|
+
import type { LlmRunResult } from "./llm-runner.js";
|
|
3
3
|
import { GraphNode, type GraphNodeResult } from "./graph-node.js";
|
|
4
4
|
import type { GraphState } from "./graph-state.js";
|
|
5
5
|
import { type ToolResponse } from "./tool-response.js";
|
|
6
|
-
export type LlmNodeRunResult =
|
|
6
|
+
export type LlmNodeRunResult = LlmRunResult;
|
|
7
7
|
export declare abstract class LlmNode<State extends GraphState> extends GraphNode<State> {
|
|
8
8
|
checkResponse(_llmResult: string | object): boolean;
|
|
9
9
|
onLlmBlocked(_context: LlmBlockedContext): Promise<LlmBlockedResponse | null>;
|
|
10
10
|
shouldRetryLlmError(_context: LlmAttemptErrorContext): boolean | undefined;
|
|
11
11
|
onLlmError(_context: LlmErrorContext): Promise<LlmErrorResponse | null>;
|
|
12
|
-
protected
|
|
12
|
+
protected llmLifecycle(): LlmLifecycle;
|
|
13
13
|
protected endChat(input: {
|
|
14
14
|
message?: string;
|
|
15
15
|
}): Promise<ToolResponse>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type LlmLifecycle } from "./llm-lifecycle.js";
|
|
2
2
|
import { type BaseMessage } from "@langchain/core/messages";
|
|
3
3
|
import type { ToolCall } from "@langchain/core/messages/tool";
|
|
4
4
|
import type { GraphLlmConfig } from "./graph-llm.config.js";
|
|
@@ -6,7 +6,7 @@ import type { LlmCallOptions, LlmGateway, LlmGatewayTool } from "./llm-gateway.j
|
|
|
6
6
|
import { type TokenUsage } from "./token-usage.js";
|
|
7
7
|
import { type ToolResponse } from "./tool-response.js";
|
|
8
8
|
import { type ModelStopReason } from "./model-stop-reason.js";
|
|
9
|
-
export type
|
|
9
|
+
export type LlmRunResult = {
|
|
10
10
|
messages: BaseMessage[];
|
|
11
11
|
usage: TokenUsage;
|
|
12
12
|
response?: string;
|
|
@@ -27,17 +27,17 @@ export type EmptyResponseRecovery = Readonly<{
|
|
|
27
27
|
}>;
|
|
28
28
|
export declare const DEFAULT_EMPTY_RESPONSE_RECOVERY: EmptyResponseRecovery;
|
|
29
29
|
export declare function assertEmptyResponseRetries(value: number): number;
|
|
30
|
-
export type
|
|
30
|
+
export type LlmPolicy = Readonly<{
|
|
31
31
|
llmTimeoutMs?: number;
|
|
32
32
|
emptyHistorySeed: string | null;
|
|
33
33
|
emptyResponseRecovery: EmptyResponseRecovery | null;
|
|
34
34
|
}>;
|
|
35
|
-
export declare const
|
|
36
|
-
export declare class
|
|
35
|
+
export declare const DEFAULT_LLM_POLICY: LlmPolicy;
|
|
36
|
+
export declare class LlmRunner {
|
|
37
37
|
private readonly llmGateway;
|
|
38
38
|
constructor(llmGateway: LlmGateway);
|
|
39
39
|
run(options: {
|
|
40
|
-
lifecycle?:
|
|
40
|
+
lifecycle?: LlmLifecycle;
|
|
41
41
|
systemPrompt: string;
|
|
42
42
|
history: readonly BaseMessage[];
|
|
43
43
|
tools: readonly LlmGatewayTool[];
|
|
@@ -47,5 +47,5 @@ export declare class ConversationRunner {
|
|
|
47
47
|
emptyHistorySeed?: string | null;
|
|
48
48
|
emptyResponseRecovery?: EmptyResponseRecovery | null;
|
|
49
49
|
callOptions?: LlmCallOptions;
|
|
50
|
-
}): Promise<
|
|
50
|
+
}): Promise<LlmRunResult>;
|
|
51
51
|
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const qR=k;(function(L,z){const qU={L:0x1a7,z:0x19f,R:0x1b5,c:0x170,g:0x16f,t:0x185},qz=k,R=L();while(!![]){try{const c=parseInt(qz(qU.L))/0x1*(-parseInt(qz(0x1b7))/0x2)+-parseInt(qz(qU.z))/0x3*(-parseInt(qz(0x169))/0x4)+parseInt(qz(0x1cd))/0x5*(-parseInt(qz(0x1bd))/0x6)+parseInt(qz(qU.R))/0x7*(-parseInt(qz(qU.c))/0x8)+parseInt(qz(0x196))/0x9*(-parseInt(qz(0x1d2))/0xa)+parseInt(qz(qU.g))/0xb+parseInt(qz(qU.t))/0xc;if(c===z)break;else R['push'](R['shift']());}catch(g){R['push'](R['shift']());}}}(q,0x506a6));var V=Object[qR(0x168)],s=(L,z)=>V(L,'name',{'value':z,'configurable':!0x0});import{setTimeout as d}from'node:timers/promises';import{GraphLlm as T,ModelCatalog as y}from'./graph-llm.config.js';import{LlmResponseBlockedError as l,LlmSetupError as e}from'./llm-lifecycle.js';import{AIMessage as v,HumanMessage as B,ToolMessage as w}from'@langchain/core/messages';import{addTokenUsage as D,emptyTokenUsage as o}from'./token-usage.js';import{isToolResponse as a}from'./tool-response.js';import{describeStopReason as u,isRetryableStopReason as n,modelStopReason as m}from'./model-stop-reason.js';import{SessionLogWarning as E}from'./session-log.js';import{isOpenAIAuthConfig as C,openAIAuthMessageText as p}from'./openai-auth-provider.js';function q(){const kd=['Aw1Hz2vFB3rOzxi','DhjPBq','CMvZCg9UC2vFCMvQzwn0zwq','A2LUza','mZC0nda0ogfzv3fmEa','mtuXmtiWz1jsC2ni','CMvZB2X2zunVBMzPzW','zw50CMLLCW','y29UDgvUDa','B2jQzwn0','CMvZB2X2zu1VzgvSrgvZy3jPChrVCG','DgHYB3DjzKfIB3j0zwq','rw1WDhLnB2rLBfjLC3bVBNnLrxjYB3i','y2XLyw51Cef0DgfJAg1LBNrZ','BM9KzuLK','AxnjBNrLz2vY','BgXTr2f0zxDHEq','CMf0Aw5NCW','ywDLBNq','ChjVBxb0qMXVy2TLzenVBNrLEhq','B25mBg1fCNjVCG','D2fPDezVCLjLDhj5','Bwf4qwDLBNrsB3vUzhm','yxbWBhLszwnVDMvYEq','vgHLig1VzgvSihjLC3bVBNnLihDHCYbYzwPLy3rLzcbIEsbJAgvJA1jLC3bVBNnLkcKU','zMvLzgjHy2S','mteWnta0odHxALjHzu8','BwvZC2fNzxm','CMvWBgfJzufSBa','Bw9KzwW','yMXVy2TFCMvHC29U','BNvKz2u','C3rYAw5NAwz5','ywnXDwLYzunHBMrPzgf0zq','y2HLy2TszxnWB25Zzq','Aw5JBhvKzxm','Aw52B2nHDgLVBKnVBMzPzW','AxnbCNjHEq','C2HVDwXKuMv0CNLmBg1fCNjVCG','rM9SBg93ihrOzsbZExn0zw0GChjVBxb0igfUzcbYzxnWB25KihbYB3bLCMX5lIbvC2uGDgHLihjLCxvPCMvKihrVB2WGD2HLBIbPBNn0CNvJDgvKlG','yxnZzxj0twf4qwDLBNrsB3vUzhm','zw1WDhLszxnWB25ZzvjLy292zxj5lNjLDhjPzxmGBxvZDcbIzsbHig5VBI1UzwDHDgL2zsbPBNrLz2vYoYbYzwnLAxzLzca','ywrKAxrPB25HBf9RD2fYz3m','nJnWDezQruy','B3rOzxi','yxnZzxj0rw1WDhLszxnWB25ZzvjLDhjPzxm','y2XLyw51Ca','CMv0CNLxAxrOtw9KzwWOksbTyxKGyMuGCMv0DxjUzwqGB25SEsbVBMnLigLUigeGCMvJB3zLCNKGC2vXDwvUy2uU','CMv0CNLxAxrOtw9KzwWOksbPCYbZDxbWB3j0zwqGB25SEsbIEsbVBKXSBuvYCM9YkcKU','zw1WDhLszxnWB25ZzvjLy292zxj5','BM9YBwfSAxPLuMvHC29U','Cg9W','mZu0m1ngCLbsuG','BgvUz3rO','ChjVBxb0','CgfYyw1Z','C3rVCf9KzxrHAwXZ','CMvZCg9UC2u','CMv0CNLFD2L0Af9TB2rLBa','ChvZAa','nKnrD0rMzW','u3rHCNq','BwvZC2fNzq','CMvHC29U','yMXVy2TLza','AgfZq2fUzgLKyxrLq29UDgvUDa','CMv0CNLFzgvJBgLUzwq','y2fUzgLKyxrL','Axntyw1LqMfYzvrYyw5ZAxrPB24','zw1WDhLiAxn0B3j5u2vLza','zxHLy3v0zvrVB2W','DgfYz2v0','Aw50zxjUywXiDw1HBK1LC3nHz2u','AgLZDg9YEq','mZvlCNL6AgC','igfNzw50ihjVDw5KCY4','mty1nZm0uwD6z2Lv','yxr0zw1WDhnFzxHOyxvZDgvK','BwfW','CMvMDxnHBa','ChjVDMLKzxi','Dgv4Da','mty2mLvlAKDZvG','Dg9VBc1JywXSlq','zgv0ywLS','y2fSBe9WDgLVBNm','q29UDMvYC2f0Aw9Uigv4y2vLzgvKia','C3rYAw5N','Bwf4qwDLBNrsB3vUzhmGBxvZDcbIzsbHihbVC2L0AxzLigLUDgvNzxi7ihjLy2vPDMvKia','B25mBg1cBg9JA2vK','CMvZCg9UC2vuzxH0','BMfTzq','yMXVy2TszwfZB24','DMfSAwrHDgvdB25MAwC','BgLMzwn5y2XL','C3rHDgu','CMv0CMLLCW','BgXTq29UzMLN','ntG0nu1ct2jsAW','DxnHz2u','ywXSu2v0DgXLza','C3rHEq','Dg9VBhm','mJG5otKWvKnvAeP6','y29TBw9Uq29UDgv4Da','Aw52B2nHDgLVBL9LCNjVCG','vgHLig1VzgvSihjLDhvYBMvKigfUigvTChr5ihjLC3bVBNnLicG','zw1WDhLFCMvZCg9UC2u','Dg9VBf9JywXSCW','teXnihjLy292zxj5ignHBM5VDcbYzxr1CM4GDg9VBc1VBMX5ihn0yxKOksWGy2XLyw51CcWGB3iGzMvLzgjHy2SU','DMfSDwu','zgvMAw5LuhjVCgvYDhK','nJmYquvQzxbW','C2fMzxr5uMf0Aw5NCW'];q=function(){return kd;};return q();}class le extends Error{static{s(this,qR(0x177));}[qR(0x1aa)];constructor(L){const qO={L:0x177},qc=qR;super(qc(0x163)+u(L)+').'),this[qc(0x1aa)]=L,this[qc(0x1c6)]=qc(qO.L);}}const de=0x8;function ce(L){const qF={L:0x17a},qg=qR;if(!Number[qg(qF.L)](L)||L<0x1)throw new Error(qg(0x1c3)+String(L)+'.');return L;}s(ce,qR(0x193));const H=qR(0x1a8),P={'retries':0x2,'nudge':qR(0x192)};function ue(L){const qS={L:0x17a},qt=qR;if(!Number[qt(qS.L)](L)||L<0x0)throw new Error(qt(0x194)+String(L)+'.');return L;}s(ue,qR(0x198));function k(d,G){d=d-0x161;const T=q();let y=T[d];if(k['dhKmNQ']===undefined){var l=function(B){const w='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let K='',j='';for(let D=0x0,o,a,N=0x0;a=B['charAt'](N++);~a&&(o=D%0x4?o*0x40+a:a,D++%0x4)?K+=String['fromCharCode'](0xff&o>>(-0x2*D&0x6)):0x0){a=w['indexOf'](a);}for(let u=0x0,P=K['length'];u<P;u++){j+='%'+('00'+K['charCodeAt'](u)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(j);};k['epnwKt']=l,k['xWcWkK']={},k['dhKmNQ']=!![];}const e=T[0x0],X=d+e,v=k['xWcWkK'][X];return!v?(y=k['epnwKt'](y),k['xWcWkK'][X]=y):y=v,y;}const ke={'emptyHistorySeed':H,'emptyResponseRecovery':P};class Te{static{s(this,'ConversationRunner');}[qR(0x17b)];constructor(L){const qA=qR;this[qA(0x17b)]=L;}async['run'](z){const k3={L:0x1b0,z:0x1b4,R:0x1a0,c:0x19c,g:0x1cb,t:0x1cc,A:0x1c9,r:0x161,f:0x167,i:0x1a6,h:0x16c,W:0x167,M:0x19e,x:0x1a6,O:0x18a,b:0x16e,I:0x1be,q0:0x186,q1:0x1a6,q2:0x1a6,q3:0x176,q4:0x16e,q5:0x1d0,q6:0x1a6,q7:0x1c1,q8:0x1b6},k2={L:0x1cf,z:0x1b9},k1={L:0x176,z:0x1a2,R:0x17b,c:0x17d,g:0x1d1,t:0x191,A:0x162,r:0x17f,f:0x1ab,i:0x16b,h:0x1bb,W:0x1ae,M:0x190,x:0x195,O:0x1a3,b:0x167,I:0x167,q0:0x1bf,q1:0x167,q2:0x16d},k0={L:0x176,z:0x1c4},qI={L:0x16e,z:0x19a,R:0x184,c:0x166,g:0x1c2,t:0x186,A:0x1a6},qr=qR,q0=z[qr(k3.L)]===void 0x0?H:z[qr(0x1b0)],q1=z[qr(k3.z)][qr(k3.R)]===0x0&&q0!==null,q2=q1?[$(q0)]:[...z[qr(k3.z)]],q3=q1?[...q2]:[];let q4=[],q5=o();const q6=ce(z[qr(0x181)]??de),q7=z[qr(k3.c)]===void 0x0?P:z[qr(0x19c)],q8=q7?ue(q7[qr(k3.g)]):0x0;let q9=0x0,qq=z[qr(k3.t)],qk=!0x1;const qd=z[qr(k3.A)],qG=z[qr(0x1c0)]?.['signal'],qT=s(()=>qd?T[qr(0x171)](qq,{'params':{'retries':0x0}}):qq,qr(0x18f)),qy=s(()=>({'nodeId':qd[qr(0x179)],'provider':y[qr(0x175)](qq)['provider'],'model':qq[qr(0x188)],...qG===void 0x0?{}:{'signal':qG}}),qr(k3.r)),ql=s(async(qB,qw)=>{const qf=qr;if(qG?.['throwIfAborted'](),qB===null)throw qw;if(typeof qB=='object'&&qB[qf(qI.L)]===qf(0x1a5)){if(qk)throw new Error(qf(qI.z),{'cause':qw});qq=T[qf(0x1c8)](qB[qf(0x188)]),qk=!0x0,q9=0x0;return;}const qK=typeof qB==qf(0x1c2)?void 0x0:qB;if(qK&&(qK[qf(0x16e)]===qf(0x1d0)||qK[qf(0x199)]||qK[qf(qI.R)]!==void 0x0))throw new Error(qf(qI.c));const qj=typeof qB==qf(qI.g)?qB:qK?.[qf(0x1a4)];return qK?.[qf(0x186)]&&q3[qf(0x1a6)](...qK[qf(qI.t)]),qj!==void 0x0&&q3[qf(qI.A)](new v(qj)),{'messages':q3,'usage':q5,'stoppedAfterTool':!0x1,...qj===void 0x0?{}:{'response':qj},...qK===void 0x0?{}:{'toolResponse':qK}};},qr(0x182)),qe=s(async(qB,qw)=>{const qi=qr;qG?.[qi(k0.L)]();const qK=await qd[qi(k0.z)](qB);if(qG?.[qi(0x176)](),typeof qK==qi(0x174)&&qK!==null&&qK['kind']==='retry_with_model')throw new Error(qi(0x19b));return await ql(qK,new l(qB,qw));},'handleBlocked'),qX=s(async()=>{const qh=qr;let qB=0x0;for(;;){qG?.[qh(k1.L)]();const qw=qk?0x1:Number(qq[qh(k1.z)]['retries'])+0x1;qB+=0x1;let qK;const qj=qT();try{qK=await this[qh(k1.R)][qh(k1.c)](z['systemPrompt'],q2,z[qh(k1.g)],qj,z['callOptions']);}catch(qu){if(qG?.[qh(0x176)](),!qd||qu instanceof e)throw qu;const qP=ye(qu,qy());if(qP)return qe(qP,qu);const qn=qu instanceof Error?qu:new Error(String(qu)),qm=qd[qh(k1.t)]({...qy(),'error':qn,'attempt':qB,'maxAttempts':qw});if(qG?.[qh(0x176)](),qm!==!0x1&&qB<qw){await Y(qG);continue;}const qV={...qy(),'kind':qh(k1.A),'error':qn,'attemptsMade':qB,'maxAttempts':qw,'stoppedBecause':qm===!0x1?qh(0x1ad):qh(0x1b8)},qE=await ql(await qd[qh(k1.r)](qV),qn);if(qE)return qE;qB=0x0;continue;}if(qG?.['throwIfAborted'](),q5=D(q5,qK[qh(0x1ce)]),!qd)return qK;const qD=m(qK[qh(0x167)]);if(qD['category']===qh(k1.f)||[qh(0x197),qh(k1.i)][qh(0x18e)](S(qD[qh(k1.h)]??'')))return qe({...qy(),'phase':qh(k1.W),'rawReason':qD[qh(k1.h)]??'refusal','reason':S(qD['provider']??qh(0x1ba)),...Array[qh(k1.M)](qD[qh(0x17c)])?{'safetyRatings':qD['ratings']}:{},...(qK['value']['response_metadata'][qh(0x1a3)]??qK[qh(0x167)][qh(k1.x)][qh(k1.O)]??qD[qh(0x1bf)])===void 0x0?{}:{'providerDetails':qK[qh(k1.b)]['response_metadata']['stop_details']??qK[qh(k1.I)][qh(0x195)][qh(0x1a3)]??qD[qh(k1.q0)]}});if(!G(qK[qh(k1.I)]))return qK;const qo=qd[qh(0x18d)](qK[qh(k1.q1)]);if(qG?.['throwIfAborted'](),!qo)return qK;if(qB<qw){await Y(qG);continue;}const qa=new Error(qh(0x183)),qN=await ql(await qd[qh(0x17f)]({...qy(),'kind':qh(k1.q2),'error':qa,'attemptsMade':qB,'maxAttempts':qw,'stoppedBecause':qh(0x1b8),'lastResponse':qK['value']}),qa);if(qN)return qN;qB=0x0;}},qr(0x18c));try{for(let qB=0x0;qB<q6;qB+=0x1){const qw=await qX();if(!(qr(k3.f)in qw))return qw;q3[qr(k3.i)](qw[qr(0x167)]),q2['push'](qw[qr(k3.f)]);const qK=qw[qr(0x167)]['tool_calls']??[];if(qK['length']===0x0){const qo=me(qw[qr(k3.f)],qq);if(qo[qr(k3.h)]()&&(!qd||G(qw[qr(0x167)])))return await qv(),{'messages':q3,'usage':q5,'response':qo,'stoppedAfterTool':!0x1};const qa=m(qw[qr(k3.W)]),qN=n(qa)&&q7!==null&&q9<q8&&!qk&&(!qd||qB+0x1<q6);if(E({'empty_model_response':u(qa),'retried':qN}),qN&&q7){q9+=0x1,q3[qr(k3.M)](),q2[qr(0x19e)](),q2[qr(k3.x)]($(q7[qr(k3.O)]));continue;}if(qd){q3[qr(0x19e)](),q2[qr(0x19e)]();const qu=new le(qa),qP=await ql(await qd['onLlmError']({...qy(),'kind':qr(0x164),'error':qu,'attemptsMade':q9+0x1,'maxAttempts':qk?0x1:Math['min'](q8+0x1,q9+q6-qB),'stoppedBecause':'attempts_exhausted','lastResponse':qw[qr(0x167)]}),qu);if(qP)return qP;qB-=0x1;continue;}return await qv(),{'messages':q3,'usage':q5,'response':qo,'stoppedAfterTool':!0x1,'stopReason':qa};}await qv();let qj=!0x1,qD;try{for(const [qn,qm]of qK[qr(0x172)]()){qG?.[qr(0x176)]();const qV=await z[qr(0x1b1)](qm);if(a(qV)){if(qV[qr(0x16e)]!==qr(0x1d0)){if(qD&&qD[qr(k3.b)]!==qr(0x1d0)&&!pe(qD,qV))throw new Error('A\x20tool\x20batch\x20selected\x20more\x20than\x20one\x20terminal\x20response\x20or\x20transition.');qD=qV;}else qD||(qD=qV);const qE=new w({'content':qV['feedback']??'OK','tool_call_id':qm['id']??qr(k3.I)+qB+'-'+qn,'name':qm['name']});q3['push'](qE),q2[qr(k3.x)](qE),qV[qr(k3.q0)]&&(q3[qr(k3.q1)](...qV[qr(k3.q0)]),q2[qr(k3.q2)](...qV['messages'])),qV[qr(0x199)]&&q4['push'](qV[qr(0x199)]),qG?.[qr(k3.q3)](),qj||=qV[qr(k3.q4)]!==qr(k3.q5);continue;}}}catch(qC){throw await qv(),qC;}if(qj){const qp=qD?.['response'];if(qp){const qJ=new v(qp);q3[qr(k3.q6)](qJ),q2[qr(0x1a6)](qJ);}return await qv(),{'messages':q3,'usage':q5,'stoppedAfterTool':!0x0,...qp?{'response':qp}:{},...qD?{'toolResponse':qD}:{}};}}throw await qv(),new Error(qr(k3.q7)+q6+qr(k3.q8));}finally{await qv();}async function qv(){const qQ=qr,qs=q4;q4=[],await Promise[qQ(k2.L)](qs[qQ(k2.z)](qL=>qL()));}s(qv,qr(0x178));}}function pe(L,z){const k4={L:0x16e,z:0x16e,R:0x199,c:0x1ce},qZ=qR;return L[qZ(k4.L)]==='go'&&z[qZ(k4.z)]==='go'&&L['target']===z[qZ(0x1b2)]&&L['state']===void 0x0&&z[qZ(0x1ca)]===void 0x0&&L[qZ(0x1a9)]===void 0x0&&z[qZ(0x1a9)]===void 0x0&&L[qZ(0x186)]===void 0x0&&z[qZ(0x186)]===void 0x0&&L[qZ(k4.R)]===void 0x0&&z[qZ(k4.R)]===void 0x0&&L[qZ(0x1a4)]===void 0x0&&z[qZ(0x1a4)]===void 0x0&&L[qZ(0x1ce)]===void 0x0&&z[qZ(k4.c)]===void 0x0;}s(pe,qR(0x1af));function $(L){return new B({'content':L,'additional_kwargs':{'ezgraphInternal':!0x0}});}s($,qR(0x1b3));function fe(L){const k6={L:0x173,z:0x1c2,R:0x18b},qY=qR;return typeof L[qY(k6.L)]==qY(k6.z)?L[qY(0x173)]:JSON[qY(k6.R)](L['content']);}s(fe,'messageText');function me(L,z){const qH=qR;return C(z)?p(L[qH(0x173)]):fe(L);}s(me,qR(0x1c5));function S(L){const k8={L:0x16c},qW=qR;return L[qW(k8.L)]()['toLowerCase']()[qW(0x187)]('-','_');}s(S,qR(0x19d));function ye(L,z){const k9={L:0x1c7,z:0x189,R:0x16a,c:0x190},qM=qR;if(!L||typeof L!=qM(0x174))return null;const R=L,c=R[qM(k9.L)]??R[qM(k9.z)];if(typeof c!=qM(0x1c2)||!c[qM(0x16c)]())return null;const A=R[qM(k9.R)]??R['safety_ratings'];return{...z,'phase':qM(0x1a1),'rawReason':c,'reason':S(c),...Array[qM(k9.c)](A)?{'safetyRatings':A}:{}};}s(ye,qR(0x17e));function G(L){const kq={L:0x173},qx=qR;return L[qx(0x165)]?.[qx(0x1a0)]?!0x0:typeof L[qx(kq.L)]==qx(0x1c2)?!!L[qx(0x173)][qx(0x16c)]():L[qx(kq.L)]['some'](z=>typeof z[qx(0x1bc)]==qx(0x1c2)&&!!z[qx(0x1bc)][qx(0x16c)]());}s(G,qR(0x1ac));async function Y(L){try{await d(0x1f4,void 0x0,L?{'signal':L}:void 0x0);}catch(z){throw L?.['throwIfAborted'](),z;}}s(Y,qR(0x180));export{Te as ConversationRunner,ke as DEFAULT_CONVERSATION_POLICY,H as DEFAULT_EMPTY_HISTORY_SEED,P as DEFAULT_EMPTY_RESPONSE_RECOVERY,de as DEFAULT_MAX_AGENT_ROUNDS,le as EmptyModelResponseError,ue as assertEmptyResponseRetries,ce as assertMaxAgentRounds};
|