@picoflow/ezgraph 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -88
- package/dist/framework/base-graph.js +1 -1
- package/dist/framework/conversation-node.js +1 -1
- package/dist/framework/conversation-runner.js +1 -1
- package/dist/framework/graph-engine.js +1 -1
- package/dist/framework/graph-node.js +1 -1
- package/dist/framework/graph-state.js +1 -1
- package/dist/framework/langchain-llm-gateway.js +1 -1
- package/dist/framework/langchain-provider.adapter.js +1 -1
- package/dist/framework/node-invocation.js +1 -0
- package/dist/framework/node-outcome.js +1 -1
- package/dist/framework/node-state.js +1 -1
- package/dist/framework/persistence/session-manager.js +1 -1
- package/dist/framework/state-graph-ext.js +1 -1
- package/dist/framework/tool-response.js +1 -0
- package/dist/index.js +1 -1
- package/dist/types/npmlib/src/index.d.ts +4 -4
- package/dist/types/src/framework/base-graph.d.ts +8 -0
- package/dist/types/src/framework/conversation-node.d.ts +8 -14
- package/dist/types/src/framework/conversation-runner.d.ts +3 -3
- package/dist/types/src/framework/graph-node.d.ts +24 -21
- package/dist/types/src/framework/graph-registry.d.ts +3 -0
- package/dist/types/src/framework/graph-state.d.ts +0 -2
- package/dist/types/src/framework/node-invocation.d.ts +12 -0
- package/dist/types/src/framework/node-outcome.d.ts +1 -30
- package/dist/types/src/framework/node-state.d.ts +2 -1
- package/dist/types/src/framework/persistence/session-manager.d.ts +1 -0
- package/dist/types/src/framework/state-graph-ext.d.ts +2 -8
- package/dist/types/src/framework/tool-response.d.ts +25 -0
- package/package.json +1 -1
- package/dist/framework/conversation-tool-result.js +0 -1
- package/dist/types/src/framework/conversation-tool-result.d.ts +0 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function h(){const V=['CMvZB2X2zu1VzgvSrgvZy3jPChrVCG','DMfSAwrHDgvdB25MAwC','zw50CMLLCW','CgfYyw1Z','ntuYndy4DNHqAfjm','CgfYyw1LDgvYtwfWCgLUz3m','C2v0ugf0Aa','BgfUz0nOywLUtw9KzwXjBML0AwfSAxPHDgLVBG','Aw5PDgLHBgL6zq','ntCXmZCYohLHBhDsra','ndbUuejIqM8','ChjVDMLKzxjnB2rLBa','ChjVDMLKzxi','B2jQzwn0','ChjVDMLKzxjbzgfWDgvY','BMfTzq','C2XPy2u','ntKXnJCXELjNrNDU','nZDVtujpzhK','mZeYotq1m1vtC294qG','q2f0ywXVzYbWyxjHBwv0zxiGBwfWCgLUzYaN','C3bSAxq','nde1nZq5nxn1CKL2Aq','q2f0ywXVzYbWyxjHBwv0zxiGBwfWCgLUzYbWyxrOCYbJyw5UB3qGyMuGzw1WDhKU','mJqWndK2nwzoDNfWqq','AxnbCNjHEq','mJm2nJa5nePzAg10ta'];h=function(){return V;};return h();}const r=T;(function(E,Q){const F={E:0x17a,Q:0x16b,n:0x178,w:0x166},z=T,n=E();while(!![]){try{const w=parseInt(z(0x173))/0x1+-parseInt(z(0x17c))/0x2+-parseInt(z(F.E))/0x3+-parseInt(z(F.Q))/0x4+parseInt(z(F.n))/0x5+parseInt(z(F.w))/0x6*(parseInt(z(0x174))/0x7)+parseInt(z(0x16c))/0x8*(parseInt(z(0x175))/0x9);if(w===Q)break;else n['push'](n['shift']());}catch(Y){n['push'](n['shift']());}}}(h,0xb9e87));var s=Object['defineProperty'],l=(E,Q)=>s(E,r(0x171),{'value':Q,'configurable':!0x0});import{GraphLlm as N,ModelCatalog as U}from'./graph-llm.config.js';function T(m,N){m=m-0x165;const U=h();let Z=U[m];if(T['uapbbH']===undefined){var d=function(C){const Q='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let n='',w='';for(let Y=0x0,x,e,J=0x0;e=C['charAt'](J++);~e&&(x=Y%0x4?x*0x40+e:e,Y++%0x4)?n+=String['fromCharCode'](0xff&x>>(-0x2*Y&0x6)):0x0){e=Q['indexOf'](e);}for(let u=0x0,D=n['length'];u<D;u++){w+='%'+('00'+n['charCodeAt'](u)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(w);};T['ujitrk']=d,T['tGlJwF']={},T['uapbbH']=!![];}const B=U[0x0],E=m+B,f=T['tGlJwF'][E];return!f?(Z=T['ujitrk'](Z),T['tGlJwF'][E]=Z):Z=f,Z;}import{modelProviderAdapter as Z}from'./model-provider.js';import{OPENAI_AUTH_PROVIDER as d,initializeOpenAIAuthProvider as B}from'./openai-auth-provider.js';function C(E,Q=[]){const A={E:0x17e,Q:0x17d,n:0x165,w:0x167,Y:0x16d,x:0x16e,e:0x170,J:0x16a,D:0x16e},b=r,w=N[b(A.E)](E),Y=U[b(A.Q)](w),x={};for(const [D,W]of Object[b(0x17f)](w[b(A.n)])){const k=Y[b(A.w)][D];k!==null&&u(x,k??D,W);}if(Y[b(0x16e)]===d)return B(Y[b(A.Y)],x);const J=Z(Y[b(A.x)],Q)??Y[b(A.e)];return J?J[b(A.J)]({'provider':Y[b(A.D)],'model':Y[b(A.Y)],'options':x}):{'model':Y[b(A.Y)],'options':{'modelProvider':Y[b(0x16e)],...x}};}l(C,r(0x169));function u(E,Q,w){const a={E:0x16f,Q:0x17b,n:0x176,w:0x179},p=r,Y=Q[p(0x177)]('.');let x=E;for(const D of Y[p(0x172)](0x0,-0x1)){const W=x[D];if(W===void 0x0){const k={};x[D]=k,x=k;}else{if(typeof W==p(a.E)&&W!==null&&!Array[p(a.Q)](W))x=W;else throw new Error(p(a.n)+Q+'\x27\x20has\x20a\x20conflicting\x20path.');}}const J=Y['at'](-0x1);if(!J)throw new Error(p(a.w));x[J]=w;}l(u,r(0x168));export{C as langChainModelInitialization};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f=Object.defineProperty;var s=(o,t)=>f(o,"name",{value:t,configurable:!0});import{AsyncLocalStorage as u}from"node:async_hooks";import{messagesStateReducer as p}from"@langchain/langgraph";const c=new u;function y(o){return c.getStore()?.owner===o}s(y,"hasNodeInvocation");function l(o,t,e,n){return c.run({owner:o,nodeId:t,state:e,nodes:{},histories:{}},n)}s(l,"withNodeInvocation");function I(o){return i(o).nodeId}s(I,"invocationNodeId");function d(o,t){const e=i(o),n=e.nodes[t];return n?{...n}:{...(e.state.nodes??{})[t]??{}}}s(d,"invocationNodeState");function S(o,t,e){const n=d(o,t);for(const[r,a]of Object.entries(e))a===void 0?delete n[r]:n[r]=a;i(o).nodes[t]=n}s(S,"saveInvocationNodeState");function N(o,t,e){i(o).nodes[t]={...e}}s(N,"replaceInvocationNodeState");function b(o,t,e){const n=i(o);n.histories[t]=[...n.histories[t]??[],...e]}s(b,"appendInvocationHistory");function h(o,t){const e=i(o);return p(e.state.histories?.[t]??[],e.histories[t]??[])}s(h,"invocationHistory");function j(o){const t=i(o),e={...t.state.nodes??{}};for(const r of Object.keys(t.nodes))e[r]=d(o,r);const n={...t.state.histories??{}};for(const r of Object.keys(t.histories))n[r]=h(o,r);return{...t.state,nodes:e,histories:n}}s(j,"invocationGraphState");function k(o){const t=i(o);return{...Object.keys(t.nodes).length>0?{nodes:t.nodes}:{},...Object.keys(t.histories).length>0?{histories:t.histories}:{}}}s(k,"invocationUpdate");function i(o){const t=c.getStore();if(!t||t.owner!==o)throw new Error("Node state can only be accessed during an active graph-node invocation.");return t}s(i,"requireInvocation");export{b as appendInvocationHistory,y as hasNodeInvocation,j as invocationGraphState,h as invocationHistory,I as invocationNodeId,d as invocationNodeState,k as invocationUpdate,N as replaceInvocationNodeState,S as saveInvocationNodeState,l as withNodeInvocation};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var d=Object.defineProperty;var n=(e,s)=>d(e,"name",{value:s,configurable:!0});const h=Symbol("GRAPH_NODE_LOCAL_STATE");function m(e,s){const o={...e,...s};return(e.nodes!==void 0||s.nodes!==void 0)&&(o.nodes=r(e.nodes,s.nodes)),(e.histories!==void 0||s.histories!==void 0)&&(o.histories=f(e.histories,s.histories)),o}n(m,"combineGraphNodeUpdates");function r(e,s){return{...e??{},...s??{}}}n(r,"mergeNodeUpdatePatches");function f(e,s){const o={...e??{}};for(const[t,i]of Object.entries(s??{}))o[t]=[...o[t]??[],...i];return o}n(f,"mergeHistoryUpdates");export{h as GRAPH_NODE_LOCAL_STATE,m as combineGraphNodeUpdates};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var r=Object.defineProperty;var o=(e,t)=>r(e,"name",{value:t,configurable:!0});function n(e,t){return{...e,...t}}o(n,"replaceNodeStates");const c=n;export{c as mergeNodeStates,n as replaceNodeStates};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const GY=S;(function(u,x){const e5={u:0x1dd,x:0x216,v:0x1f2,t:0x23d,b:0x22c,L:0x245},Go=S,v=u();while(!![]){try{const t=parseInt(Go(0x1ff))/0x1+parseInt(Go(0x25a))/0x2*(-parseInt(Go(e5.u))/0x3)+parseInt(Go(e5.x))/0x4*(-parseInt(Go(e5.v))/0x5)+-parseInt(Go(e5.t))/0x6*(-parseInt(Go(0x209))/0x7)+parseInt(Go(e5.b))/0x8+parseInt(Go(e5.L))/0x9*(-parseInt(Go(0x240))/0xa)+parseInt(Go(0x1f0))/0xb;if(t===x)break;else v['push'](v['shift']());}catch(b){v['push'](v['shift']());}}}(e,0xb27a4));var z=Object[GY(0x204)],c=(u,x)=>z(u,GY(0x1fc),{'value':x,'configurable':!0x0});import{mapChatMessagesToStoredMessages as g,mapStoredMessagesToChatMessages as a}from'@langchain/core/messages';import{BaseGraph as N}from'../base-graph.js';import{ConfigManager as F}from'../config-manager.js';import{GRAPH_END_NODE as i}from'../graph-state.js';import{GraphLlm as o}from'../graph-llm.config.js';import{mergeNodeStates as Y}from'../node-state.js';import{createSessionLogs as s}from'../session-log.js';import{emptyTokenUsage as K,normalizeTokenUsage as n}from'../token-usage.js';import{assertGraphSchemaVersion as H}from'../stable-id.js';const h=0x10,w=GY(0x25f),$=GY(0x20b),we=GY(0x23f);class f extends Error{static{c(this,'SessionTurnError');}[GY(0x1f3)];constructor(u,x){const e6={u:0x1f3},GR=GY;super(x),this['name']='SessionTurnError',this[GR(e6.u)]=u;}}class C{static{c(this,GY(0x257));}['container'];['turnLeaseMs'];constructor(u=new q(),x=j()){const e7={u:0x235},GZ=GY;this[GZ(0x1fa)]=u,this[GZ(e7.u)]=x;}static async[GY(0x254)](G0=new F()){const e8={u:0x247,x:0x214,v:0x1d5,t:0x238,b:0x201,L:0x1cf,r:0x1f1,d:0x21a,l:0x205,M:0x248,D:0x20d,A:0x268,O:0x1eb,G0:0x225,G1:0x1d6,G2:0x214,G3:0x233,G4:0x21d,G5:0x1de,G6:0x25c,G7:0x21d,G8:0x264,G9:0x24f,GG:0x1d4},Gm=GY,G1=G0['get'](Gm(0x1e4),Gm(0x265))[Gm(e8.u)]()[Gm(0x1d9)](),G2=j(G0[Gm(e8.x)](Gm(e8.v)));if(G1==='memory')return new C(new q(),G2);if(G1===Gm(e8.t)){const {SqliteSessionDocumentContainer:GN}=await import('./sqlite-session-document.container.js');return new C(new GN(G0[Gm(0x214)](Gm(0x22d),Gm(0x252))),G2);}if(G1===Gm(0x24b)||G1===Gm(e8.b)){const GF=p(G0,Gm(0x1d3)),GU=p(G0,'MONGODB_NAME'),Gw=p(G0,Gm(e8.L));if(!GF||!GU||!Gw)throw new Error(Gm(0x20a));const [{MongoClient:Gi},{MongoDbSessionDocumentContainer:Gc}]=await Promise[Gm(e8.r)]([import('mongodb'),import('./mongodb-session-document.container.js')]),Gq=new Gi(GF);await Gq[Gm(0x221)]();const Gf=Gq['db'](GU)['collection'](Gw);return await Gf[Gm(0x255)]({'id':0x1},{'unique':!0x0}),new C(new Gc(Gf,Gq),G2);}if(G1!==Gm(0x249)&&G1!==Gm(e8.d))throw new Error('Unsupported\x20SESSION_STORE\x20\x27'+G1+Gm(e8.l));const G3=p(G0,'COSMO_ENDPOINT','COSMOS_ENDPOINT','COSMODB_URL'),G4=p(G0,'COSMODB_KEY','COSMOS_KEY'),G5=p(G0,Gm(e8.M)),G6=p(G0,Gm(e8.D)),G7=p(G0,'COSMO_DB_CLIENT_SECRET'),G8=p(G0,'COSMO_DB_ID',Gm(0x1e9),'COSMODB_ID')??Gm(0x212),G9=p(G0,Gm(0x229),Gm(e8.A),Gm(e8.O))??'sessions';if(!G3||!G4&&(!G5||!G6||!G7))throw new Error(Gm(e8.G0));const [{CosmosClient:GG},{ClientSecretCredential:Ge}]=await Promise[Gm(0x1f1)]([import(Gm(0x211)),import(Gm(e8.G1))]),Gj=G4?new GG({'endpoint':G3,'key':G4}):new GG({'endpoint':G3,'aadCredentials':new Ge(G5,G6,G7)}),{database:GS}=await Gj[Gm(0x239)][Gm(0x233)]({'id':G8}),GC=Number(G0[Gm(e8.G2)](Gm(0x1ef),'400')),{container:Gg}=await GS[Gm(0x262)][Gm(e8.G3)]({'id':G9,'partitionKey':{'paths':[Gm(e8.G4)]},...Number[Gm(0x26a)](GC)&&GC>0x0?{'throughput':GC}:{}}),{resource:GE}=await Gg[Gm(e8.G5)](),GX=GE?.[Gm(0x1e3)]?.[Gm(e8.G6)]??[];if(!GX[Gm(0x1f9)](Gm(e8.G7)))throw new Error('Cosmos\x20container\x20\x27'+G9+Gm(e8.G8)+(GX['join'](',\x20')||Gm(e8.G9))+'.');const {CosmosSessionDocumentContainer:Ga}=await import(Gm(e8.GG));return new C(new Ga(Gg,()=>Gj[Gm(0x259)]()),G2);}async['getSession'](u){const e9={u:0x1d2},GI=GY,x=await this[GI(e9.u)](u);return x?.[GI(0x203)]===h?x:void 0x0;}async[GY(0x1d2)](u){const GJ=GY;try{const {resource:x}=await this[GJ(0x1fa)]['item'](u,u)[GJ(0x1de)]();return x;}catch(v){if(V(v))return;throw v;}}async[GY(0x1dc)](x,v,b){const ej={u:0x206,x:0x1d8,v:0x203,t:0x1f4,b:0x219,L:0x250,r:0x244,d:0x219,l:0x223,M:0x1d0,D:0x242,A:0x1db},GQ=GY,L=N['assertId'](b[GQ(ej.u)]),M=H(b[GQ(ej.x)]),D=await this[GQ(0x1d2)](x);D&&D[GQ(ej.v)]===h&&T(D,L);const A=new Date(),O={'owner':v,'expiresAt':new Date(A[GQ(0x200)]()+this['turnLeaseMs'])[GQ(ej.t)]()};if(!D){const G1=this[GQ(ej.b)](x,b,L,M,O,A['toISOString']());if(await this[GQ(0x1fa)][GQ(ej.L)]({'expectedRevision':null},G1)===GQ(0x223))throw new f(w,GQ(ej.r)+x+GQ(0x242));return{'kind':GQ(0x1db),'document':G1,'expectedRevision':G1[GQ(0x1d0)]};}if(D[GQ(0x203)]!==h){const G2=this[GQ(ej.d)](x,b,L,M,O,A[GQ(0x1f4)]());if(await this[GQ(0x1fa)][GQ(ej.L)]({'expectedRevision':m(D),'replaceIncompatible':!0x0},G2)===GQ(ej.l))throw new f(w,GQ(ej.r)+x+GQ(0x242));return{'kind':GQ(0x1db),'document':G2,'expectedRevision':G2[GQ(ej.M)]};}if(G(D[GQ(0x207)])&&D[GQ(0x207)]?.['owner']!==v)throw new f(w,GQ(0x244)+x+GQ(ej.D));const G0={...D,'revision':m(D)+0x1,'turn':O,'modifiedAt':A[GQ(0x1f4)]()};if(await this['container'][GQ(0x250)]({'expectedRevision':m(D),'requireFreeLease':!0x0,'allowOwner':v},G0)==='conflict')throw new f(w,'Session\x20\x27'+x+GQ(ej.D));return{'kind':GQ(ej.A),'document':G0,'expectedRevision':m(G0)};}async[GY(0x1e7)](u,x){const Gs=GY,v=await this[Gs(0x237)](u);if(v)return this['restoreSessionDocument'](v,x);}['restoreSessionDocument'](u,x){const eC={u:0x1fe,x:0x26b,v:0x25e,t:0x208},GK=GY,v=N[GK(0x1ee)](x);T(u,v);const {graph:b}=u;if(!b[GK(eC.u)])return;const L=Y({},b[GK(eC.u)]),d=ne(b[GK(0x21c)]);return{'currentNode':b[GK(eC.x)],'config':b['config']??{},'completed':u[GK(eC.v)]===GK(0x24a)||b[GK(0x26b)]===i,'nodes':L,'tokens':n(u[GK(eC.t)]),'histories':d,'inputConsumed':!0x0,'response':''};}async[GY(0x1e0)](x,v,b,L=s(),M={}){const eg={u:0x228,x:0x1ec,v:0x26b,t:0x25d},Gn=GY,D=N['assertId'](b['graphId']),A=H(b[Gn(0x1d8)]),G0=await this['readDocument'](x),G1=G0?.[Gn(0x203)]===h?G0:void 0x0;G1&&(T(G1,D),U(G1,A));const G2=new Date()[Gn(0x1f4)](),G3=ee(Y({},v[Gn(0x1fe)])),{tokens:G4,histories:G5}=v,G6=this[Gn(0x218)](G0,M),G7={'version':h,'id':x,'revision':G6===null?0x0:G6+0x1,'status':v['completed']?'completed':Gn(eg.u),'tokens':n(G4),'errors':[...G1?.[Gn(eg.x)]??[],...L[Gn(0x1ec)]],'warnings':[...G1?.[Gn(0x22e)]??[],...L[Gn(0x22e)]],'graph':{'id':D,'schemaVersion':A,'currentNode':v[Gn(eg.v)],'config':v[Gn(0x1f6)],'histories':re(G5),'model':o['modelMetadata'](b['llmConfig']),'nodes':G3},'createdAt':G1?.['createdAt']??G2,'modifiedAt':G2};if(await this[Gn(0x1fa)]['compareAndSwap'](this['commitPredicate'](G0,M,G6),G7)===Gn(0x223))throw new f(M[Gn(eg.t)]?$:w,M[Gn(eg.t)]?'Session\x20\x27'+x+Gn(0x1da):'Session\x20\x27'+x+Gn(0x242));return G7;}async['appendLogs'](x,v,b,L={}){const eE={u:0x237,x:0x1f4,v:0x25e,t:0x1ec,b:0x22e,L:0x26b,r:0x1f6,d:0x246,l:0x22b,M:0x1e1,D:0x1fd,A:0x24e,O:0x244},Gp=GY,l=N[Gp(0x1ee)](b[Gp(0x206)]),M=H(b[Gp(0x1d8)]),D=await this[Gp(eE.u)](x);D&&(T(D,l),U(D,M));const A=new Date()[Gp(eE.x)](),O=this[Gp(0x218)](D,L),G0={'version':h,'id':x,'revision':O===null?0x0:O+0x1,'status':v['errors']['length']>0x0?'error':D?.[Gp(eE.v)]??Gp(0x228),'tokens':D?.[Gp(0x208)]??K(),'errors':[...D?.[Gp(0x1ec)]??[],...v[Gp(eE.t)]],'warnings':[...D?.[Gp(eE.b)]??[],...v['warnings']],'graph':{'id':l,'schemaVersion':M,...D?{'currentNode':D[Gp(0x21f)][Gp(eE.L)],'config':D[Gp(0x21f)][Gp(eE.r)]}:{},'histories':D?.[Gp(0x21f)][Gp(0x21c)]??{},'model':o[Gp(eE.d)](b[Gp(eE.l)]),...D?.['graph']['nodes']?{'nodes':D[Gp(0x21f)]['nodes']}:{}},'createdAt':D?.[Gp(0x230)]??A,'modifiedAt':A};if(await this[Gp(0x1fa)]['compareAndSwap'](this[Gp(0x21b)](D,L,O),G0)===Gp(0x223)){if(L[Gp(0x25d)]){console[Gp(0x1e5)](Gp(0x244)+x+Gp(eE.M)+v['errors']['length']+Gp(eE.D)+v['warnings'][Gp(eE.A)]+'\x20warning(s)\x20were\x20dropped.');return;}throw new f(w,Gp(eE.O)+x+Gp(0x242));}return G0;}async[GY(0x21e)](u,x,v,b,L){const eX={u:0x22e,x:0x24e,v:0x20c},GH=GY;if(b&&(b['errors'][GH(0x24e)]>0x0||b[GH(eX.u)][GH(eX.x)]>0x0)){await this[GH(eX.v)](u,b,v,{'owner':x,...L!==void 0x0?{'expectedRevision':L}:{}});return;}await this['releaseTurn'](u,x,L);}async['releaseTurn'](u,x,v){const ea={u:0x237,x:0x250},Gu=GY,b=await this[Gu(ea.u)](u);if(!b||b['turn']?.[Gu(0x25d)]!==x)return;const L=v??m(b),{turn:l,...M}=b,D={...M,'modifiedAt':new Date()[Gu(0x1f4)]()};await this[Gu(0x1fa)][Gu(ea.x)]({'expectedRevision':L,'requireOwner':x},D);}async['deleteSession'](u){const Gx=GY;try{await this[Gx(0x1fa)][Gx(0x1f5)](u,u)['delete']();}catch(x){if(!V(x))throw x;}}async[GY(0x1ea)](u,x={}){const eF={u:0x203,x:0x227,v:0x1ee,t:0x21f,b:0x207,L:0x230,r:0x1fa,d:0x25d,l:0x210},Gv=GY;if(u[Gv(eF.u)]!==h)throw new Error(Gv(eF.x)+u['version']+';\x20expected\x20'+h+'.');N[Gv(eF.v)](u[Gv(eF.t)]['id']),H(u['graph']['schemaVersion']);const v=await this['getSession'](u['id']),b=x['expectedRevision']??m(v||u),L=v?.[Gv(0x207)]??u[Gv(eF.b)],d={...u,'revision':b,'createdAt':v?.[Gv(0x230)]??u[Gv(eF.L)],'modifiedAt':v?.['modifiedAt']??u['modifiedAt'],...L?{'turn':L}:{}};if(await this[Gv(eF.r)]['compareAndSwap']({'expectedRevision':b,...x['owner']?{'requireOwner':x[Gv(0x25d)]}:{'requireFreeLease':!0x0}},d)===Gv(0x223))throw new f(x[Gv(eF.d)]?$:w,Gv(0x244)+u['id']+Gv(eF.l));}async['close'](){const eU={u:0x1fa},Gt=GY;await this[Gt(eU.u)]['close']?.();}[GY(0x219)](u,x,v,b,L,d){const ew={u:0x228,x:0x246},Gb=GY;return{'version':h,'id':u,'revision':0x0,'status':Gb(ew.u),'tokens':K(),'errors':[],'warnings':[],'graph':{'id':v,'schemaVersion':b,'histories':{},'model':o[Gb(ew.x)](x[Gb(0x22b)])},'turn':L,'createdAt':d,'modifiedAt':d};}['commitExpectedRevision'](u,x){const ei={u:0x1e2},GB=GY;return x['expectedRevision']!==void 0x0?x[GB(ei.u)]:u?m(u):null;}[GY(0x21b)](u,x,v){const GL=GY;return x['owner']?{'expectedRevision':v,'requireOwner':x[GL(0x25d)]}:u&&u[GL(0x203)]!==h?{'expectedRevision':v,'replaceIncompatible':!0x0}:{'expectedRevision':v,'requireFreeLease':!0x0};}}function p(u,...x){const Gr=GY;for(const v of x){const b=u[Gr(0x214)](v);if(b)return b;}}c(p,GY(0x24d));function T(u,x){const ef={u:0x21f,x:0x244},Gz=GY;if(u[Gz(ef.u)]['id']!==x)throw new Error(Gz(ef.x)+u['id']+'\x27\x20belongs\x20to\x20graph\x20\x27'+u[Gz(0x21f)]['id']+Gz(0x23c)+x+'\x27.\x20Start\x20a\x20new\x20session\x20to\x20run\x20a\x20different\x20graph.');}c(T,GY(0x267));function U(u,x){const eo={u:0x21f,x:0x244,v:0x21f,t:0x1f8},Gh=GY;if(u[Gh(eo.u)][Gh(0x263)]!==x)throw new Error(Gh(eo.x)+u['id']+'\x27\x20uses\x20graph\x20\x27'+u[Gh(eo.v)]['id']+Gh(0x26c)+u[Gh(eo.u)][Gh(0x263)]+Gh(eo.t)+x+Gh(0x1cd));}c(U,'assertSessionGraphSchema');function ee(u){const eR={u:0x251},Gd=GY;return Object[Gd(0x226)](Object[Gd(eR.u)](u)[Gd(0x253)](([x,v])=>{const Gl=Gd;if(!v||typeof v!=Gl(0x222))return[x,v];const {toolTrace:b,...L}=v;return[x,L];}));}c(ee,GY(0x202));function te(u){const em={u:0x253},eZ={u:0x1d1,x:0x20e,v:0x1df,t:0x24e,b:0x22f,L:0x1fb,r:0x23e},GM=GY;return u[GM(em.u)](x=>{const GV=GM,v={...x[GV(eZ.u)]},b=x[GV(eZ.x)]==='ai'&&Array[GV(0x1fb)](v[GV(eZ.v)])&&v[GV(0x1df)][GV(eZ.t)]>0x0?oe(v[GV(0x241)]):void 0x0;return delete v['additional_kwargs'],b&&(v[GV(0x241)]={'originalTextContentBlock':b}),delete v['response_metadata'],delete v[GV(eZ.b)],x[GV(0x20e)]==='ai'&&(Array[GV(eZ.L)](v[GV(0x1df)])&&v[GV(eZ.v)]['length']===0x0&&delete v[GV(eZ.v)],Array[GV(eZ.L)](v[GV(eZ.r)])&&v[GV(eZ.r)]['length']===0x0&&delete v[GV(0x23e)]),{...x,'data':v};});}c(te,GY(0x220));function re(u){const eI={u:0x226},Gy=GY;return Object[Gy(eI.u)](Object[Gy(0x251)](u)[Gy(0x253)](([x,v])=>[x,te(g(v))]));}c(re,'storeHistories');function ne(u={}){const GP=GY;return Object[GP(0x226)](Object['entries'](u)[GP(0x253)](([x,v])=>[x,a(v)]));}c(ne,GY(0x217));function oe(u){const eQ={u:0x234,x:0x215},GD=GY;if(!P(u))return;const x=u[GD(eQ.u)];if(!(!P(x)||typeof x['thoughtSignature']!=GD(0x215)))return{...typeof x['text']==GD(eQ.x)?{'text':x[GD(0x213)]}:{},'thoughtSignature':x['thoughtSignature'],...x[GD(0x1d7)]===!0x0?{'thought':!0x0}:{}};}c(oe,GY(0x243));function P(u){const GT=GY;return u!==null&&typeof u==GT(0x222)&&!Array[GT(0x1fb)](u);}c(P,GY(0x25b));class q{static{c(this,'MemorySessionDocumentContainer');}['documents']=new Map();get[GY(0x232)](){return this['documents']['size'];}[GY(0x236)]={'upsert':c(async e=>{const en={u:0x260},GA=GY,t=e;return this[GA(0x256)][GA(en.u)](t['id'],structuredClone(t)),{};},'upsert')};async['compareAndSwap'](u,x){const ep={u:0x256,x:0x214,v:0x256,t:0x223},Gk=GY,v=this[Gk(ep.u)][Gk(ep.x)](x['id']);return ie(v,u)?(this[Gk(ep.v)][Gk(0x260)](x['id'],structuredClone(x)),'ok'):Gk(ep.t);}['item'](u,x){const eu={u:0x256},eH={u:0x261,x:0x22a},GO=GY;return{'read':c(async()=>{const GW=S,v=this[GW(0x256)][GW(0x214)](u);if(!v||v['id']!==x)throw Object[GW(eH.u)](new Error(GW(eH.x)),{'code':0x194});return{'resource':structuredClone(v)};},GO(0x1de)),'delete':c(async()=>{const e0=GO,v=this[e0(eu.u)]['get'](u);if(!v||v['id']!==x)throw Object['assign'](new Error('Not\x20found'),{'code':0x194});return this['documents']['delete'](u),{};},GO(0x258))};}}function V(u){const ev={u:0x222,x:0x1f3,v:0x1ed},e1=GY;if(!u||typeof u!=e1(ev.u))return!0x1;const x=u;return x[e1(ev.x)]===0x194||x[e1(ev.v)]===0x194;}c(V,GY(0x20f));function j(u=process.env.SESSION_TURN_LEASE_MS){const et={u:0x26a},e2=GY,x=Number(u??e2(0x1ce));return Number[e2(et.u)](x)&&x>0x0?x:0xea60;}c(j,GY(0x224));function m(u){return u?.['revision']??0x0;}c(m,GY(0x269));function G(u,x=Date['now']()){const eB={u:0x25d,x:0x24c,v:0x26a},e3=GY;if(!u?.[e3(eB.u)]||!u[e3(0x1e6)])return!0x1;const v=Date[e3(eB.x)](u[e3(0x1e6)]);return Number[e3(eB.v)](v)&&v>x;}function S(G,j){G=G-0x1cd;const C=e();let g=C[G];if(S['lWoyLP']===undefined){var E=function(F){const U='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let w='',i='';for(let c=0x0,q,f,o=0x0;f=F['charAt'](o++);~f&&(q=c%0x4?q*0x40+f:f,c++%0x4)?w+=String['fromCharCode'](0xff&q>>(-0x2*c&0x6)):0x0){f=U['indexOf'](f);}for(let Y=0x0,R=w['length'];Y<R;Y++){i+='%'+('00'+w['charCodeAt'](Y)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(i);};S['SPeVhq']=E,S['GnRdQF']={},S['lWoyLP']=!![];}const X=C[0x0],a=G+X,N=S['GnRdQF'][a];return!N?(g=S['SPeVhq'](g),S['GnRdQF'][a]=g):g=N,g;}function e(){const er=['tu9or09eqL9vuKW','lI9JB3nTB3mTC2vZC2LVBI1KB2n1BwvUDc5JB250ywLUzxiUANm','u0vtu0LptL9uvvjox0Xfqvnfx01t','qgf6DxjLl2LKzw50Axr5','DgHVDwDODa','z3jHCgHty2HLBwfwzxjZAw9U','Dg9mB3DLCKnHC2u','jYbJAgfUz2vKigjLzM9Yzsb0AgLZihr1CM4Gy291BgqGyMuGC2f2zwqU','BgvHC2vK','yMvNAw5uDxjU','mtvSvNLQANq','CMvHza','Dg9VBf9JywXSCW','C2f2zvn0yxrL','jYbSB3n0igL0CYbSzwfZzsbIzwzVCMuGBg9NCYb3zxjLigfWCgvUzgvKoYa','zxHWzwn0zwrszxzPC2LVBG','CgfYDgL0Aw9Us2v5','u0vtu0LptL9tve9srq','D2fYBG','zxHWAxjLC0f0','CMvZDg9Yzvn0yxrL','AxnmAxzLu2vZC2LVBLr1CM4','q09ttu9tx0rbvefcqvnf','CgvYC2LZDe1Pz3jHDgvKu2vZC2LVBG','q09ttu9eqL9trvntsu9ox0Le','zxjYB3jZ','C3rHDhvZq29Kzq','yxnZzxj0swq','q09ttu9tx1riuK9vr0Hqvvq','mJa4mJq0ntjIv3jiBem','ywXS','mtmWs0jrDwP4','y29Kzq','Dg9ju09tDhjPBMC','AxrLBq','y29UzMLN','BM93','lcbUB3qG','Aw5JBhvKzxm','y29UDgfPBMvY','AxnbCNjHEq','BMfTzq','igvYCM9YkhmPigfUzca','BM9Kzxm','ntuXmJm4ANbYqK1b','z2v0vgLTzq','Bw9Uz28','CMvTB3zLtgvNywn5vg9VBfrYywnLCW','DMvYC2LVBG','zgvMAw5LuhjVCgvYDhK','jY4GvxnLicDTzw1VCNKNlcaNC3fSAxrLjYWGj21VBMDVzgiNlcbVCIaNy29ZBw9ZjY4','z3jHCgHjza','DhvYBG','Dg9Rzw5Z','n0vxCMXoAG','tw9Uz29eqIbZzxnZAw9UihbLCNnPC3rLBMnLihjLCxvPCMvZie1ptKDprejFvvjmlcbnt05ht0rcx05btuuSigfUzcbnt05ht0rcx0npteXfq1rjt04U','u0vtu0LptL9dt05gteLdva','yxbWzw5Ktg9NCW','q09ttu9FrejFq0Xjru5ux0Le','DhLWzq','AxnoB3rgB3vUza','jYbJAgfUz2vKigjLzM9YzsbPDhmGBwLNCMf0Aw9UignVDwXKigjLihnHDMvKlG','qgf6DxjLl2nVC21VCW','BgfUz2DYyxbO','Dgv4Da','z2v0','C3rYAw5N','mtu3ndq0s0DgvwDb','CMvZDg9YzuHPC3rVCMLLCW','y29TBwL0rxHWzwn0zwrszxzPC2LVBG','CgXHy2vOB2XKzxjeB2n1BwvUDa','y29ZBw9Zzgi','y29TBwL0uhjLzgLJyxrL','AgLZDg9YAwvZ','l2LK','zw5KrMfPBgvKvhvYBG','z3jHCgG','y29TCgfJDfn0B3jLze1LC3nHz2vZ','y29UBMvJDa','B2jQzwn0','y29UzMXPy3q','C2vZC2LVBLr1CM5mzwfZzu1Z','q29ZBw9ZihnLC3nPB24GCgvYC2LZDgvUy2uGCMvXDwLYzxmGq09ttu9eqL9vuKWGyw5Kienpu01prejFs0vzlcbVCIbdt1nnt19ftKrqt0LovcWGqvPvuKvFvevoqu5ux0Lelcbdt1nnt19eqL9dteLftLrFsuqSigfUzcbdt1nnt19eqL9dteLftLrFu0vduKvulG','zNjVBuvUDhjPzxm','q2fUBM90ihbLCNnPC3qGC2vZC2LVBIbKB2n1BwvUDcb2zxjZAw9Uia','Aw5FChjVz3jLC3m','q09ttu9FrejFu0vtu0LptL9dt05uquLorvjFsuq','tM90igzVDw5K','BgXTq29UzMLN','mZm2odC2ohfHAw9pAa','u1fmsvrfx0rcx1bbveG','D2fYBMLUz3m','DxnHz2vFBwv0ywrHDge','y3jLyxrLzef0','ywXSB3DpD25LCG','C2L6zq','y3jLyxrLswzoB3rfEgLZDhm','B3jPz2LUywXuzxH0q29UDgvUDejSB2nR','DhvYBKXLyxnLtxm','AxrLBxm','z2v0u2vZC2LVBG','C3fSAxrL','zgf0ywjHC2vZ','CMvXDwLYzuzYzwvmzwfZzq','CMvXDwLYzu93BMvY','jYWGBM90icC','odK2mtqYug93z053','Aw52ywXPzf90B29Sx2nHBgXZ','u0vtu0LptL9dt01qtevuruq','mZbQEvHOzLq','ywrKAxrPB25HBf9RD2fYz3m','jYbPCYbHBhjLywr5ihbYB2nLC3nPBMCGysb0DxjUlG','C2LNBMf0DxjLqMvHCMLUz0nVBNrLBNrcBg9JAW','u2vZC2LVBIaN','mJiXoduWoxP4C0XRsq','Bw9KzwXnzxrHzgf0yq','DhjPBq','qvPvuKvFvevoqu5ux0Le','y29ZBw9Z','y29TCgXLDgvK','Bw9Uz29KyG','CgfYC2u','zMLYC3q','BgvUz3rO','BM9Uzq','y29TCgfYzufUzfn3yxa','zw50CMLLCW','lI9KyxrHl3nLC3nPB25ZlNnXBgL0zq','BwfW','zNjVBunVBMzPzW','y3jLyxrLsw5KzxG','zg9JDw1LBNrZ','u2vZC2LVBK1HBMfNzxi','zgvSzxrL','zgLZCg9Zzq','mJa4mZu2txHXBhHs','AxnszwnVCMq','Cgf0Ahm','B3DUzxi','C3rHDhvZ','u0vtu0LptL9cvvnz','C2v0','yxnZAwDU','y29UDgfPBMvYCW','C2nOzw1HvMvYC2LVBG','jYbTDxn0ihvZzsbWyxj0AxrPB24GA2v5ic9PzdSGzM91BMqG','BwvTB3j5','Bwf0y2HLC1nLC3nPB25xCML0zvbYzwrPy2f0zq','yxnZzxj0u2vZC2LVBKDYyxbO','q09ttu9tx0nptLrbsu5fuG','C2vZC2LVBLjLDMLZAw9U','AxngAw5PDgu','y3vYCMvUDe5Vzgu','jYbZy2HLBweGDMvYC2LVBIa','lIbszxn0B3jLig9Yig1Pz3jHDguGAxqGyMvMB3jLihnHDMLUzY4','nJaWmda','tu9or09eqL9dt0Xmrunusu9o','CMv2AxnPB24','zgf0yq','CMvHzerVy3vTzw50'];e=function(){return er;};return e();}c(G,GY(0x1e8));function ie(u,x,v=Date[GY(0x1f7)]()){const eL={u:0x23b,x:0x207,v:0x231},e4=GY;return x['replaceIncompatible']?u!==void 0x0&&u[e4(0x203)]!==h:x[e4(0x1e2)]===null?u===void 0x0:!(!u||m(u)!==x['expectedRevision']||x[e4(0x23b)]&&u[e4(0x207)]?.[e4(0x25d)]!==x[e4(eL.u)]||x[e4(0x23a)]&&G(u[e4(eL.x)],v)&&u['turn']?.[e4(0x25d)]!==x[e4(eL.v)]);}c(ie,GY(0x266));export{q as MemorySessionDocumentContainer,w as SESSION_BUSY,we as SESSION_COMPLETED,$ as SESSION_CONFLICT,h as SESSION_DOCUMENT_VERSION,C as SessionManager,f as SessionTurnError,G as isLiveSessionTurn,ie as matchesSessionWritePredicate,m as sessionRevision,j as sessionTurnLeaseMs};
|
|
1
|
+
const hu=d;(function(S,L){const m6={S:0x1d9,L:0x1ef,t:0x1cb,g:0x224,o:0x1f3,l:0x1cd,O:0x1da},hJ=d,t=S();while(!![]){try{const g=-parseInt(hJ(m6.S))/0x1+-parseInt(hJ(0x1d7))/0x2*(parseInt(hJ(m6.L))/0x3)+-parseInt(hJ(m6.t))/0x4+-parseInt(hJ(0x220))/0x5+-parseInt(hJ(m6.g))/0x6*(-parseInt(hJ(m6.o))/0x7)+parseInt(hJ(0x1a8))/0x8*(parseInt(hJ(m6.l))/0x9)+parseInt(hJ(m6.O))/0xa*(parseInt(hJ(0x228))/0xb);if(g===L)break;else t['push'](t['shift']());}catch(o){t['push'](t['shift']());}}}(N,0x71173));var z=Object[hu(0x1a0)],c=(S,L)=>z(S,'name',{'value':L,'configurable':!0x0});import{mapChatMessagesToStoredMessages as n,mapStoredMessagesToChatMessages as Y}from'@langchain/core/messages';import{BaseGraph as x}from'../base-graph.js';import{ConfigManager as e}from'../config-manager.js';import{GRAPH_END_NODE as u}from'../graph-state.js';import{GraphLlm as D}from'../graph-llm.config.js';import{replaceNodeStates as r}from'../node-state.js';import{createSessionLogs as b}from'../session-log.js';import{emptyTokenUsage as F,normalizeTokenUsage as A}from'../token-usage.js';import{assertGraphSchemaVersion as a}from'../stable-id.js';const h=0x10,w=hu(0x1fb),$='SESSION_CONFLICT',we=hu(0x1b9);class f extends Error{static{c(this,'SessionTurnError');}[hu(0x1fd)];constructor(S,L){const m7={S:0x22d},hD=hu;super(L),this[hD(0x1b2)]=hD(m7.S),this['code']=S;}}class C{static{c(this,'SessionManager');}[hu(0x23e)];[hu(0x20d)];constructor(S=new q(),L=j()){const m8={S:0x20d},hW=hu;this['container']=S,this[hW(m8.S)]=L;}static async[hu(0x1af)](h0=new e()){const m9={S:0x206,L:0x20c,t:0x1e8,g:0x245,o:0x1dd,l:0x1e1,O:0x241,i:0x225,K:0x218,H:0x1fc,s:0x1b8,v:0x1a2,M:0x1d4,h0:0x1eb,h1:0x1c9,h2:0x1d0,h3:0x23d,h4:0x21a,h5:0x211,h6:0x235,h7:0x233,h8:0x1ed,h9:0x1e9,hh:0x242,hm:0x1c0,hT:0x210},hk=hu,h1=h0[hk(0x1e8)](hk(m9.S),'memory')[hk(m9.L)]()['toLowerCase'](),h2=j(h0[hk(m9.t)](hk(m9.g)));if(h1===hk(0x202))return new C(new q(),h2);if(h1===hk(0x205)){const {SqliteSessionDocumentContainer:hf}=await import(hk(m9.o));return new C(new hf(h0['get'](hk(m9.l),'./data/sessions.sqlite')),h2);}if(h1===hk(m9.O)||h1===hk(0x1f2)){const hC=p(h0,'MONGODB_URL'),hQ=p(h0,hk(0x22a)),hn=p(h0,'MONGODB_COLLECTION');if(!hC||!hQ||!hn)throw new Error(hk(m9.i));const [{MongoClient:hw},{MongoDbSessionDocumentContainer:hY}]=await Promise[hk(m9.K)]([import(hk(0x241)),import('./mongodb-session-document.container.js')]),hx=new hw(hC);await hx[hk(0x1c8)]();const he=hx['db'](hQ)[hk(m9.H)](hn);return await he['createIndex']({'id':0x1},{'unique':!0x0}),new C(new hY(he,hx),h2);}if(h1!==hk(0x1c2)&&h1!==hk(0x232))throw new Error('Unsupported\x20SESSION_STORE\x20\x27'+h1+hk(m9.s));const h3=p(h0,hk(m9.v),hk(m9.M),'COSMODB_URL'),h4=p(h0,hk(m9.h0),hk(m9.h1)),h5=p(h0,hk(m9.h2)),h6=p(h0,hk(m9.h3)),h7=p(h0,'COSMO_DB_CLIENT_SECRET'),h8=p(h0,hk(m9.h4),hk(m9.h5),'COSMODB_ID')??'langgraph',h9=p(h0,hk(m9.h6),hk(0x22e),hk(0x212))??'sessions';if(!h3||!h4&&(!h5||!h6||!h7))throw new Error(hk(0x1f4));const [{CosmosClient:hh},{ClientSecretCredential:hm}]=await Promise[hk(m9.K)]([import(hk(0x215)),import(hk(0x1a1))]),hT=h4?new hh({'endpoint':h3,'key':h4}):new hh({'endpoint':h3,'aadCredentials':new hm(h5,h6,h7)}),{database:hN}=await hT[hk(0x237)][hk(0x1ae)]({'id':h8}),hU=Number(h0[hk(m9.t)](hk(0x1bf),'400')),{container:hZ}=await hN['containers'][hk(0x1ae)]({'id':h9,'partitionKey':{'paths':[hk(m9.h7)]},...Number[hk(0x1d5)](hU)&&hU>0x0?{'throughput':hU}:{}}),{resource:hd}=await hZ[hk(m9.h8)](),hB=hd?.[hk(m9.h9)]?.[hk(m9.hh)]??[];if(!hB[hk(m9.hm)]('/id'))throw new Error(hk(m9.hT)+h9+hk(0x219)+(hB[hk(0x1ce)](',\x20')||hk(0x1a6))+'.');const {CosmosSessionDocumentContainer:hE}=await import('./cosmos-session-document.container.js');return new C(new hE(hZ,()=>hT[hk(0x1f6)]()),h2);}async[hu(0x23b)](S){const hz=hu,L=await this['readDocument'](S);return L?.[hz(0x223)]===h?L:void 0x0;}async[hu(0x20b)](S){const mm={S:0x23e,L:0x1b4,t:0x1ed},hr=hu;try{const {resource:L}=await this[hr(mm.S)][hr(mm.L)](S,S)[hr(mm.t)]();return L;}catch(g){if(V(g))return;throw g;}}async[hu(0x1cf)](S,L,g){const mT={S:0x1c3,L:0x23e,t:0x23c,g:0x21c,o:0x1aa,l:0x223,O:0x1ca,i:0x1ca,K:0x243,H:0x1c1},hb=hu,O=x['assertId'](g[hb(0x1db)]),K=a(g['graphSchemaVersion']),H=await this[hb(0x20b)](S);H&&H['version']===h&&y(H,O);const v=new Date(),M={'owner':L,'expiresAt':new Date(v['getTime']()+this[hb(0x20d)])[hb(mT.S)]()};if(!H){const h1=this['placeholderDocument'](S,g,O,K,M,v[hb(mT.S)]());if(await this[hb(mT.L)]['compareAndSwap']({'expectedRevision':null},h1)===hb(mT.t))throw new f(w,hb(mT.g)+S+'\x27\x20is\x20already\x20processing\x20a\x20turn.');return{'kind':hb(mT.o),'document':h1,'expectedRevision':h1[hb(0x1ba)]};}if(H[hb(mT.l)]!==h){const h2=this[hb(0x1d2)](S,g,O,K,M,v['toISOString']());if(await this[hb(0x23e)][hb(0x1c1)]({'expectedRevision':m(H),'replaceIncompatible':!0x0},h2)==='conflict')throw new f(w,'Session\x20\x27'+S+'\x27\x20is\x20already\x20processing\x20a\x20turn.');return{'kind':hb(0x1aa),'document':h2,'expectedRevision':h2['revision']};}if(G(H[hb(mT.O)])&&H[hb(mT.i)]?.[hb(0x209)]!==L)throw new f(w,hb(0x21c)+S+hb(mT.K));const h0={...H,'revision':m(H)+0x1,'turn':M,'modifiedAt':v[hb(0x1c3)]()};if(await this['container'][hb(mT.H)]({'expectedRevision':m(H),'requireFreeLease':!0x0,'allowOwner':L},h0)==='conflict')throw new f(w,hb(0x21c)+S+hb(mT.K));return{'kind':hb(0x1aa),'document':h0,'expectedRevision':m(h0)};}async['restoreState'](S,L){const hp=hu,g=await this['getSession'](S);if(g)return this[hp(0x239)](g,L);}[hu(0x239)](S,L){const mU={S:0x1a5,L:0x1a5,t:0x1ac,g:0x1c5},hF=hu,g=x['assertId'](L);y(S,g);const {graph:l}=S;if(!l[hF(mU.S)])return;const O=r({},l[hF(mU.L)]),i=ne(l[hF(0x23a)]);return{'currentNode':l[hF(0x231)],'config':l['config']??{},'completed':S['status']===hF(mU.t)||l['currentNode']===u,'nodes':O,'tokens':A(S[hF(mU.g)]),'histories':i,'inputConsumed':!0x0,'response':''};}async['saveState'](L,K,H,v=b(),M={}){const mZ={S:0x1c7,L:0x1b6,t:0x20b,g:0x223,o:0x1a3,l:0x1ac,O:0x229,i:0x229,K:0x1ad,H:0x1b1,s:0x1ca,v:0x22c,M:0x20d,h0:0x1c3,h1:0x23e,h2:0x209,h3:0x209,h4:0x243},hA=hu,h0=x[hA(mZ.S)](H[hA(0x1db)]),h1=a(H[hA(mZ.L)]),h2=await this[hA(mZ.t)](L),h3=h2?.[hA(mZ.g)]===h?h2:void 0x0;h3&&(y(h3,h0),U(h3,h1));const h4=new Date()[hA(0x1c3)](),h5=ee(r({},K[hA(0x1a5)])),{tokens:h6,histories:h7}=K,h8=this[hA(mZ.o)](h2,M),h9={'version':h,'id':L,'revision':h8===null?0x0:h8+0x1,'status':K[hA(mZ.l)]?hA(mZ.l):hA(0x1e2),'tokens':A(h6),'errors':[...h3?.[hA(mZ.O)]??[],...v[hA(mZ.i)]],'warnings':[...h3?.['warnings']??[],...v[hA(mZ.K)]],'graph':{'id':h0,'schemaVersion':h1,'currentNode':K['currentNode'],'config':K[hA(mZ.H)],'histories':re(h7),'model':D[hA(0x221)](H['llmConfig']),'nodes':h5},...M[hA(0x216)]&&h3?.[hA(mZ.s)]?{'turn':{'owner':h3[hA(0x1ca)][hA(0x209)],'expiresAt':new Date(Date[hA(mZ.v)]()+this[hA(mZ.M)])[hA(mZ.h0)]()}}:{},'createdAt':h3?.[hA(0x1dc)]??h4,'modifiedAt':h4};if(await this[hA(mZ.h1)][hA(0x1c1)](this['commitPredicate'](h2,M,h8),h9)===hA(0x23c))throw new f(M[hA(mZ.h2)]?$:w,M[hA(mZ.h3)]?hA(0x21c)+L+'\x27\x20changed\x20before\x20this\x20turn\x20could\x20be\x20saved.':hA(0x21c)+L+hA(mZ.h4));return h9;}async[hu(0x22b)](L,g,l,O={}){const md={S:0x1c7,L:0x1b6,t:0x23b,g:0x1c3,o:0x1a3,l:0x1ff,O:0x1d8,i:0x1e7,K:0x1c5,H:0x1b1,s:0x23a,v:0x221,M:0x1b5,h0:0x23e,h1:0x23f,h2:0x23c,h3:0x209,h4:0x1b3,h5:0x208,h6:0x21c,h7:0x243},hc=hu,K=x[hc(md.S)](l[hc(0x1db)]),H=a(l[hc(md.L)]),v=await this[hc(md.t)](L);v&&(y(v,K),U(v,H));const M=new Date()[hc(md.g)](),h0=this[hc(md.o)](v,O),h1={'version':h,'id':L,'revision':h0===null?0x0:h0+0x1,'status':g[hc(0x229)][hc(md.l)]>0x0?hc(md.O):v?.[hc(md.i)]??hc(0x1e2),'tokens':v?.[hc(md.K)]??F(),'errors':[...v?.[hc(0x229)]??[],...g[hc(0x229)]],'warnings':[...v?.[hc(0x1ad)]??[],...g[hc(0x1ad)]],'graph':{'id':K,'schemaVersion':H,...v?{'currentNode':v[hc(0x1a4)][hc(0x231)],'config':v[hc(0x1a4)][hc(md.H)]}:{},'histories':v?.['graph'][hc(md.s)]??{},'model':D[hc(md.v)](l[hc(md.M)]),...v?.['graph'][hc(0x1a5)]?{'nodes':v['graph'][hc(0x1a5)]}:{}},'createdAt':v?.[hc(0x1dc)]??M,'modifiedAt':M};if(await this[hc(md.h0)][hc(0x1c1)](this[hc(md.h1)](v,O,h0),h1)===hc(md.h2)){if(O[hc(md.h3)]){console[hc(md.h4)]('Session\x20\x27'+L+'\x27\x20lost\x20its\x20lease\x20before\x20logs\x20were\x20appended;\x20'+g[hc(0x229)][hc(0x1ff)]+hc(md.h5)+g['warnings'][hc(0x1ff)]+hc(0x1f8));return;}throw new f(w,hc(md.h6)+L+hc(md.h7));}return h1;}async[hu(0x217)](S,L,g,l,O){const mB={S:0x22b,L:0x20e},ha=hu;if(l&&(l['errors']['length']>0x0||l['warnings'][ha(0x1ff)]>0x0)){await this[ha(mB.S)](S,l,g,{'owner':L,...O!==void 0x0?{'expectedRevision':O}:{}});return;}await this[ha(mB.L)](S,L,O);}async[hu(0x20e)](S,L,g){const hV=hu,l=await this[hV(0x23b)](S);if(!l||l['turn']?.['owner']!==L)return;const O=g??m(l),{turn:K,...H}=l,v={...H,'modifiedAt':new Date()[hV(0x1c3)]()};await this[hV(0x23e)]['compareAndSwap']({'expectedRevision':O,'requireOwner':L},v);}async[hu(0x1be)](S){const hS=hu;try{await this['container']['item'](S,S)[hS(0x203)]();}catch(L){if(!V(L))throw L;}}async[hu(0x1e4)](S,L={}){const mC={S:0x227,L:0x1a4,t:0x1e3,g:0x1ca,o:0x1dc,l:0x23e,O:0x1c1,i:0x209,K:0x23c,H:0x21c},hj=hu;if(S['version']!==h)throw new Error(hj(0x236)+S[hj(0x223)]+hj(mC.S)+h+'.');x[hj(0x1c7)](S[hj(mC.L)]['id']),a(S[hj(0x1a4)][hj(0x214)]);const g=await this['getSession'](S['id']),l=L[hj(mC.t)]??m(g||S),O=g?.[hj(mC.g)]??S['turn'],i={...S,'revision':l,'createdAt':g?.[hj(mC.o)]??S[hj(0x1dc)],'modifiedAt':g?.[hj(0x1c4)]??S[hj(0x1c4)],...O?{'turn':O}:{}};if(await this[hj(mC.l)][hj(mC.O)]({'expectedRevision':l,...L[hj(0x209)]?{'requireOwner':L[hj(mC.i)]}:{'requireFreeLease':!0x0}},i)===hj(mC.K))throw new f(L[hj(mC.i)]?$:w,hj(mC.H)+S['id']+hj(0x200));}async[hu(0x204)](){const mQ={S:0x204},hL=hu;await this[hL(0x23e)][hL(mQ.S)]?.();}[hu(0x1d2)](S,L,g,l,O,i){return{'version':h,'id':S,'revision':0x0,'status':'in_progress','tokens':F(),'errors':[],'warnings':[],'graph':{'id':g,'schemaVersion':l,'histories':{},'model':D['modelMetadata'](L['llmConfig'])},'turn':O,'createdAt':i,'modifiedAt':i};}[hu(0x1a3)](S,L){const mw={S:0x1e3},ht=hu;return L[ht(mw.S)]!==void 0x0?L[ht(0x1e3)]:S?m(S):null;}[hu(0x23f)](S,L,g){const mY={S:0x209},hg=hu;return L[hg(mY.S)]?{'expectedRevision':g,'requireOwner':L[hg(mY.S)]}:S&&S[hg(0x223)]!==h?{'expectedRevision':g,'replaceIncompatible':!0x0}:{'expectedRevision':g,'requireFreeLease':!0x0};}}function p(S,...L){const mx={S:0x1e8},ho=hu;for(const g of L){const o=S[ho(mx.S)](g);if(o)return o;}}c(p,hu(0x21f));function y(S,L){const me={S:0x1a4,L:0x230},hq=hu;if(S[hq(0x1a4)]['id']!==L)throw new Error(hq(0x21c)+S['id']+hq(0x1de)+S[hq(me.S)]['id']+'\x27,\x20not\x20\x27'+L+hq(me.L));}c(y,hu(0x21d));function U(S,L){const mJ={S:0x1a4,L:0x21c,t:0x1e6,g:0x1f7,o:0x1a7,l:0x1ab},hl=hu;if(S[hl(mJ.S)][hl(0x214)]!==L)throw new Error(hl(mJ.L)+S['id']+hl(mJ.t)+S['graph']['id']+hl(mJ.g)+S[hl(mJ.S)]['schemaVersion']+hl(mJ.o)+L+hl(mJ.l));}c(U,hu(0x1f9));function ee(S){const mD={S:0x22f},mu={S:0x1d6},hO=hu;return Object[hO(0x226)](Object['entries'](S)[hO(mD.S)](([L,g])=>{const hG=hO;if(!g||typeof g!=hG(mu.S))return[L,g];const {toolTrace:l,...O}=g;return[L,O];}));}function N(){const mq=['CMvHzerVy3vTzw50','DhjPBq','DhvYBKXLyxnLtxm','CMvSzwfZzvr1CM4','ywXSB3DpD25LCG','q29ZBw9ZignVBNrHAw5LCIaN','q09ttu9tx0rbvefcqvnf','q09ttu9eqL9trvntsu9ox0Le','DxnHz2vFBwv0ywrHDge','C2nOzw1HvMvYC2LVBG','qgf6DxjLl2nVC21VCW','A2vLCfr1CM4','zw5KrMfPBgvKvhvYBG','ywXS','jYbTDxn0ihvZzsbWyxj0AxrPB24GA2v5ic9PzdSGzM91BMqG','q09ttu9FrejFsuq','nJaWmda','u2vZC2LVBIaN','yxnZzxj0u2vZC2LVBKDYyxbO','zxHWAxjLC0f0','zMLYC3q','mZy4ndyWme9sB3Hbsq','Bw9KzwXnzxrHzgf0yq','AxnbCNjHEq','DMvYC2LVBG','mJu2nty2EhLMqw1j','tw9Uz29eqIbZzxnZAw9UihbLCNnPC3rLBMnLihjLCxvPCMvZie1ptKDprejFvvjmlcbnt05ht0rcx05btuuSigfUzcbnt05ht0rcx0npteXfq1rjt04U','zNjVBuvUDhjPzxm','oYbLEhbLy3rLzca','mtf5DKfOALC','zxjYB3jZ','tu9or09eqL9oqu1f','yxbWzw5Ktg9NCW','BM93','u2vZC2LVBLr1CM5fCNjVCG','q09ttu9tx0nptLrbsu5fuG','BwfW','jY4Gu3rHCNqGysbUzxCGC2vZC2LVBIb0BYbYDw4GysbKAwzMzxjLBNqGz3jHCgGU','y3vYCMvUDe5Vzgu','y29ZBw9Zzgi','l2LK','AxnoB3rgB3vUza','q09ttu9FrejFu0vtu0LptL9dt05uquLorvjFsuq','q2fUBM90ihbLCNnPC3qGC2vZC2LVBIbKB2n1BwvUDcb2zxjZAw9Uia','zgf0ywjHC2vZ','zgf0yq','CMvZDg9YzvnLC3nPB25eB2n1BwvUDa','AgLZDg9YAwvZ','z2v0u2vZC2LVBG','y29UzMXPy3q','q09ttu9FrejFq0Xjru5ux0Le','y29UDgfPBMvY','y29TBwL0uhjLzgLJyxrL','Dg9VBf9JywXSCW','Bw9Uz29KyG','Cgf0Ahm','jYbPCYbHBhjLywr5ihbYB2nLC3nPBMCGysb0DxjUlG','Dgv4Da','u0vtu0LptL9uvvjox0Xfqvnfx01t','zgvMAw5LuhjVCgvYDhK','qgf6DxjLl2LKzw50Axr5','q09ttu9Fru5eue9jtLq','y29TBwL0rxHWzwn0zwrszxzPC2LVBG','z3jHCgG','BM9Kzxm','BM9Uzq','lcbUB3qG','nteYmdCYmgf5D0DnuG','AxrLBxm','BgvHC2vK','lIbszxn0B3jLig9Yig1Pz3jHDguGAxqGyMvMB3jLihnHDMLUzY4','y29TCgXLDgvK','D2fYBMLUz3m','y3jLyxrLswzoB3rfEgLZDhm','zNjVBunVBMzPzW','CMvTB3zLtgvNywn5vg9VBfrYywnLCW','y29UzMLN','BMfTzq','D2fYBG','AxrLBq','BgXTq29UzMLN','z3jHCgHty2HLBwfwzxjZAw9U','CgfYC2u','jY4GvxnLicDTzw1VCNKNlcaNC3fSAxrLjYWGj21VBMDVzgiNlcbVCIaNy29ZBw9ZjY4','u0vtu0LptL9dt01qtevuruq','CMv2AxnPB24','Aw52ywXPzf90B29Sx2nHBgXZ','Bwf0y2HLC1nLC3nPB25xCML0zvbYzwrPy2f0zq','DgHVDwDODa','zgvSzxrLu2vZC2LVBG','q09ttu9tx1riuK9vr0Hqvvq','Aw5JBhvKzxm','y29TCgfYzufUzfn3yxa','y29ZBw9Z','Dg9ju09tDhjPBMC','Bw9KAwzPzwrbDa','Dg9Rzw5Z','DhLWzq','yxnZzxj0swq','y29UBMvJDa','q09ttu9tx0Tfwq','DhvYBG','mZeYnJKWnejdwwLIvW','C3rHDhvZq29Kzq','oxL6EgHQCq','AM9PBG','yMvNAw5uDxjU','qvPvuKvFvevoqu5ux0Le','tM90igzVDw5K','CgXHy2vOB2XKzxjeB2n1BwvUDa','C2L6zq','q09ttu9tx0vorfbpsu5u','AxngAw5PDgu','B2jQzwn0','mNPzCfHSyG','zxjYB3i','otm2otv5DwPewfG','mtG2otuZmtb2wgPRzvq','z3jHCgHjza','y3jLyxrLzef0','lI9ZCwXPDguTC2vZC2LVBI1KB2n1BwvUDc5JB250ywLUzxiUANm','jYbIzwXVBMDZihrVigDYyxbOicC','CMvZDg9YzuHPC3rVCMLLCW','C2LNBMf0DxjLqMvHCMLUz0nVBNrLBNrcBg9JAW','u1fmsvrfx0rcx1bbveG','Aw5FChjVz3jLC3m','zxHWzwn0zwrszxzPC2LVBG','CgvYC2LZDe1Pz3jHDgvKu2vZC2LVBG','C2v0','jYb1C2vZigDYyxbOicC','C3rHDhvZ','z2v0','CgfYDgL0Aw9Us2v5','yxnZAwDU','q09ttu9eqL9lrvK','B3jPz2LUywXuzxH0q29UDgvUDejSB2nR','CMvHza','zg9JDw1LBNrZ','mJa3mtG4mxvyCevjyG','ywrKAxrPB25HBf9RD2fYz3m','DxbZzxj0','Bw9Uz28','ndj1BxDpCKK','q29ZBw9ZihnLC3nPB24GCgvYC2LZDgvUy2uGCMvXDwLYzxmGq09ttu9eqL9vuKWGyw5Kienpu01prejFs0vzlcbVCIbdt1nnt19ftKrqt0LovcWGqvPvuKvFvevoqu5ux0Lelcbdt1nnt19eqL9dteLftLrFsuqSigfUzcbdt1nnt19eqL9dteLftLrFu0vduKvulG','C2vZC2LVBLjLDMLZAw9U','zgLZCg9Zzq','jYbZy2HLBweGDMvYC2LVBIa','ihDHCM5PBMCOCYKGD2vYzsbKCM9WCgvKlG','yxnZzxj0u2vZC2LVBKDYyxbOu2nOzw1H','CMvWBgfJzuLUy29TCgf0AwjSzq','u0vtu0LptL9cvvnz','y29SBgvJDgLVBG','y29Kzq','DgHVDwDODfnPz25HDhvYzq','BgvUz3rO','jYbJAgfUz2vKigjLzM9YzsbPDhmGBwLNCMf0Aw9UignVDwXKigjLihnHDMvKlG','zw50CMLLCW','BwvTB3j5','zgvSzxrL','y2XVC2u','C3fSAxrL','u0vtu0LptL9tve9srq','AxnszwnVCMq','igvYCM9YkhmPigfUzca','B3DUzxi','y29TCgfJDfn0B3jLze1LC3nHz2vZ'];N=function(){return mq;};return N();}c(ee,hu(0x1b0));function te(S){const mW={S:0x238,L:0x222,t:0x1f0,g:0x213,o:0x240,l:0x1ff,O:0x240,i:0x222,K:0x1bb},hi=hu;return S[hi(0x22f)](L=>{const hy=hi,g={...L[hy(mW.S)]},l=L['type']==='ai'&&Array[hy(mW.L)](g[hy(0x240)])&&g['tool_calls']['length']>0x0?oe(g[hy(mW.t)]):void 0x0;return delete g['additional_kwargs'],l&&(g[hy(0x1f0)]={'originalTextContentBlock':l}),delete g['response_metadata'],delete g[hy(mW.g)],L[hy(0x1c6)]==='ai'&&(Array[hy(mW.L)](g['tool_calls'])&&g[hy(mW.o)][hy(mW.l)]===0x0&&delete g[hy(mW.O)],Array[hy(mW.i)](g[hy(mW.K)])&&g[hy(0x1bb)][hy(0x1ff)]===0x0&&delete g['invalid_tool_calls']),{...L,'data':g};});}c(te,hu(0x20a));function re(S){const mz={S:0x226,L:0x22f},hP=hu;return Object[hP(mz.S)](Object['entries'](S)[hP(mz.L)](([L,g])=>[L,te(n(g))]));}c(re,'storeHistories');function ne(S={}){const hR=hu;return Object[hR(0x226)](Object[hR(0x201)](S)[hR(0x22f)](([L,g])=>[L,Y(g)]));}c(ne,hu(0x1df));function oe(S){const hK=hu;if(!P(S))return;const L=S[hK(0x1ec)];if(!(!P(L)||typeof L['thoughtSignature']!='string'))return{...typeof L[hK(0x244)]=='string'?{'text':L[hK(0x244)]}:{},'thoughtSignature':L[hK(0x1fe)],...L[hK(0x1bd)]===!0x0?{'thought':!0x0}:{}};}c(oe,hu(0x1e0));function P(S){const mp={S:0x1d6},hH=hu;return S!==null&&typeof S==hH(mp.S)&&!Array['isArray'](S);}c(P,hu(0x207));class q{static{c(this,'MemorySessionDocumentContainer');}[hu(0x1ee)]=new Map();get[hu(0x1d3)](){const mF={S:0x1ee},hs=hu;return this[hs(mF.S)][hs(0x1d3)];}[hu(0x1a9)]={'upsert':c(async e=>{const mA={S:0x1ee},hv=hu,t=e;return this[hv(mA.S)][hv(0x1e5)](t['id'],structuredClone(t)),{};},hu(0x1f1))};async[hu(0x1c1)](S,L){const hI=hu,g=this[hI(0x1ee)][hI(0x1e8)](L['id']);return ie(g,S)?(this[hI(0x1ee)]['set'](L['id'],structuredClone(L)),'ok'):hI(0x23c);}[hu(0x1b4)](S,L){const mS={S:0x203},mV={S:0x1ea,L:0x1d1},ma={S:0x1e8,L:0x1ea},hM=hu;return{'read':c(async()=>{const hX=d,g=this['documents'][hX(ma.S)](S);if(!g||g['id']!==L)throw Object[hX(ma.L)](new Error('Not\x20found'),{'code':0x194});return{'resource':structuredClone(g)};},hM(0x1ed)),'delete':c(async()=>{const m0=hM,g=this[m0(0x1ee)][m0(0x1e8)](S);if(!g||g['id']!==L)throw Object[m0(mV.S)](new Error(m0(mV.L)),{'code':0x194});return this[m0(0x1ee)][m0(0x203)](S),{};},hM(mS.S))};}}function V(S){const m1=hu;if(!S||typeof S!=m1(0x1d6))return!0x1;const L=S;return L[m1(0x1fd)]===0x194||L[m1(0x1cc)]===0x194;}c(V,hu(0x234));function j(S=process.env.SESSION_TURN_LEASE_MS){const mL={S:0x21b,L:0x1d5},m2=hu,L=Number(S??m2(mL.S));return Number[m2(mL.L)](L)&&L>0x0?L:0xea60;}c(j,'sessionTurnLeaseMs');function m(S){const m3=hu;return S?.[m3(0x1ba)]??0x0;}c(m,hu(0x1f5));function G(S,L=Date[hu(0x22c)]()){const mg={S:0x1b7},m4=hu;if(!S?.[m4(0x209)]||!S[m4(0x21e)])return!0x1;const g=Date[m4(mg.S)](S[m4(0x21e)]);return Number[m4(0x1d5)](g)&&g>L;}c(G,'isLiveSessionTurn');function d(h,m){h=h-0x1a0;const T=N();let U=T[h];if(d['JBIzjs']===undefined){var Z=function(C){const Q='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let n='',w='';for(let Y=0x0,x,e,J=0x0;e=C['charAt'](J++);~e&&(x=Y%0x4?x*0x40+e:e,Y++%0x4)?n+=String['fromCharCode'](0xff&x>>(-0x2*Y&0x6)):0x0){e=Q['indexOf'](e);}for(let u=0x0,D=n['length'];u<D;u++){w+='%'+('00'+n['charCodeAt'](u)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(w);};d['KmuqMm']=Z,d['UpVtOL']={},d['JBIzjs']=!![];}const B=T[0x0],E=h+B,f=d['UpVtOL'][E];return!f?(U=d['KmuqMm'](U),d['UpVtOL'][E]=U):U=f,U;}function ie(S,L,g=Date[hu(0x22c)]()){const mo={S:0x1fa,L:0x1e3,t:0x1ca,g:0x20f},m5=hu;return L[m5(mo.S)]?S!==void 0x0&&S[m5(0x223)]!==h:L[m5(0x1e3)]===null?S===void 0x0:!(!S||m(S)!==L[m5(mo.L)]||L['requireOwner']&&S[m5(mo.t)]?.['owner']!==L['requireOwner']||L['requireFreeLease']&&G(S['turn'],g)&&S[m5(0x1ca)]?.[m5(0x209)]!==L[m5(mo.g)]);}c(ie,hu(0x1bc));export{q as MemorySessionDocumentContainer,w as SESSION_BUSY,we as SESSION_COMPLETED,$ as SESSION_CONFLICT,h as SESSION_DOCUMENT_VERSION,C as SessionManager,f as SessionTurnError,G as isLiveSessionTurn,ie as matchesSessionWritePredicate,m as sessionRevision,j as sessionTurnLeaseMs};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const L=N;(function(Y,e){const h6={Y:0xe8,e:0xc4,J:0xde,D:0x10f,W:0xc5,k:0x10d},j=N,J=Y();while(!![]){try{const D=parseInt(j(h6.Y))/0x1+parseInt(j(0x108))/0x2*(-parseInt(j(h6.e))/0x3)+parseInt(j(h6.J))/0x4*(-parseInt(j(0xd7))/0x5)+parseInt(j(h6.D))/0x6*(-parseInt(j(0xfa))/0x7)+parseInt(j(0xe2))/0x8*(-parseInt(j(0xcd))/0x9)+-parseInt(j(0xf3))/0xa*(-parseInt(j(h6.W))/0xb)+parseInt(j(h6.k))/0xc;if(D===e)break;else J['push'](J['shift']());}catch(W){J['push'](J['shift']());}}}(T,0x39347));var m=Object[L(0xc9)],p=(Y,J)=>m(Y,L(0xd8),{'value':J,'configurable':!0x0});import{END as U,isCommand as Z,START as d,StateGraph as B}from'@langchain/langgraph';import{GRAPH_NODE_CLASS as f,GraphNode as C}from'./graph-node.js';function N(h,m){h=h-0xc3;const U=T();let Z=U[h];if(N['uhJOwZ']===undefined){var d=function(C){const Q='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let n='',w='';for(let Y=0x0,x,e,J=0x0;e=C['charAt'](J++);~e&&(x=Y%0x4?x*0x40+e:e,Y++%0x4)?n+=String['fromCharCode'](0xff&x>>(-0x2*Y&0x6)):0x0){e=Q['indexOf'](e);}for(let u=0x0,D=n['length'];u<D;u++){w+='%'+('00'+n['charCodeAt'](u)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(w);};N['CPtMFs']=d,N['PUoJpy']={},N['uhJOwZ']=!![];}const B=U[0x0],E=h+B,f=N['PUoJpy'][E];return!f?(Z=N['CPtMFs'](Z),N['PUoJpy'][E]=Z):Z=f,Z;}import{GRAPH_END_NODE as Q}from'./graph-state.js';import{stableClassId as n}from'./stable-id.js';class x{static{p(this,'StateGraphExt');}[L(0xca)];[L(0xdd)];[L(0xdc)];[L(0xe7)]=new Set();[L(0xfd)]=new Map();[L(0x107)]=new Map();constructor(Y,J,D=Q){const t=L;this['createGraphNode']=J,this[t(0xdd)]=D,this[t(0xdc)]=new B(Y);}[L(0xe3)](Y){const h8={Y:0xca,e:0xca,J:0x10e,D:0xd3},o=L;if(!g(Y))throw new Error(o(0xcc));if(!this[o(h8.Y)])throw new Error('This\x20graph\x20has\x20no\x20GraphNode\x20factory.');const J=this[o(h8.e)](Y),D=n(Y,'graph\x20node');if(J['id']!==D)throw new Error(o(h8.J)+D+o(h8.D)+J['id']+'\x27.');return this[o(0xfd)][o(0xd5)](D,Y),this['registerNode'](J,[...this['addedNodeIds'],D,U]);}[L(0xea)](...Y){const hh={Y:0xca,e:0xec,J:0xf5,D:0xd3},h9={Y:0xe6,e:0x101},q=L;if(!this[q(hh.Y)])throw new Error('This\x20graph\x20has\x20no\x20GraphNode\x20factory.');const J=Y['map'](k=>{const O=q;if(!g(k))throw new Error(O(h9.Y));return n(k,O(h9.e));}),D=J['find']((k,z)=>J['indexOf'](k)!==z||this[q(0xe7)][q(0xd6)](k));if(D)throw new Error(q(hh.e)+D+q(hh.J));const W=[...this[q(0xe7)],...J,U];for(const [k,z]of Y['entries']()){const F=this[q(0xca)](z),A=J[k];if(F['id']!==A)throw new Error(q(0x10e)+A+q(hh.D)+F['id']+'\x27.');this['nodeClasses'][q(0xd5)](A,z),this[q(0xd4)](F,W);}return this;}[L(0xee)](...Y){const i=L;return this['nodes'](...Y),this[i(0xdf)](...Y),this;}[L(0xcf)](Y,J){const hT={Y:0x100,e:0x103,J:0xcf},P=L,D=Array[P(hT.Y)](Y)?Y:[Y];for(const k of D)this[P(0x10a)](k);this[P(0xf1)](J);const W=D[P(hT.e)](c);return this['graph'][P(hT.J)](W['length']===0x1?W[0x0]:W,c(J)),this;}[L(0xf0)](Y,J){const hN={Y:0xf4},R=L,D=n(Y,'graph\x20node'),W=this[R(0x107)][R(0x10c)](D);if(!W)throw new Error('Graph\x20node\x20\x27'+D+'\x27\x20must\x20be\x20added\x20before\x20it\x20is\x20connected.');return this[R(hN.Y)](Y,W[R(0xf8)]['bind'](W),J),this;}[L(0xd9)](Y,J){const hZ={Y:0xfc,e:0xf4,J:0x106,D:0x103},hU={Y:0xef},K=L,D=n(Y,K(0x101));if(!this['nodeInstances'][K(0xd6)](D))throw new Error(K(0xec)+D+K(0xc7));if(J[K(hZ.Y)][K(0xd0)]===0x0)throw new Error('branchBy()\x20requires\x20at\x20least\x20one\x20case.');const W=J[K(hZ.Y)]['map'](({when:A})=>this['currentNodeSelectorName'](A)),k=W[K(0xd1)]((A,V)=>W[K(0xe0)](A)!==V);if(k)throw new Error(K(0xe5)+k+'\x27.');const z=W['map']((A,V)=>K(0x10b)+V),F='otherwise';return this[K(hZ.e)](Y,A=>{const H=K,V=A[H(0xfe)];if(typeof V!=H(hU.Y))throw new Error(H(0xec)+D+H(0xf7));const S=W[H(0xe0)](V);return S===-0x1?F:z[S];},{...Object[K(hZ.J)](J['cases'][K(hZ.D)](({routeTo:A},V)=>[z[V],A])),[F]:J[K(0xdb)]}),this;}['registerTurns'](...Y){const hd={Y:0xf9,e:0x102,J:0x103},s=L;if(Y[s(hd.Y)](J=>n(J,'graph\x20node')===this[s(0xdd)]))throw new Error(s(hd.e)+this[s(0xdd)]+'\x27\x20is\x20reserved\x20by\x20StateGraphExt.registerTurns().');return this['addConditionalEdge'](d,J=>J[s(0xfe)],{...Object[s(0x106)](Y[s(hd.J)](J=>[n(J,s(0x101)),J])),[this[s(0xdd)]]:U}),this;}[L(0xda)](){const hB={Y:0x107,e:0xcb,J:0xda},v=L;for(const Y of this[v(hB.Y)][v(hB.e)]())Y['validateTools']?.();return this['graph'][v(hB.J)]();}['addConditionalEdge'](Y,J,D){const hE={Y:0xf1,e:0xce},I=L;this['assertSource'](Y);for(const W of Object[I(0xcb)](D))this[I(hE.Y)](W);this['graph'][I(0xe9)](c(Y),J,Object['fromEntries'](Object[I(hE.e)](D)['map'](([k,z])=>[k,c(z)])));}[L(0xd4)](Y,J){const hC={Y:0xec},hf={Y:0xc3,e:0xc3,J:0xc3},X=L;if(this[X(0xe7)]['has'](Y['id']))throw new Error(X(hC.Y)+Y['id']+'\x27\x20is\x20already\x20registered.');return this[X(0xdc)]['addNode'](Y['id'],async D=>{const M=X,W=await Y['invoke'](D);if(Z(W)){const k=Array['isArray'](W['goto'])?W[M(hf.Y)]:W[M(hf.e)]===void 0x0?[]:[W[M(hf.J)]];for(const z of k)typeof z=='string'&&this['assertTarget'](z);}return W;},{'ends':[...new Set(J)]}),this['addedNodeIds'][X(0xd2)](Y['id']),this['nodeInstances']['set'](Y['id'],Y),this;}[L(0x10a)](Y){const hQ={Y:0x104},h0=L;c(Y)!==d&&this[h0(hQ.Y)](Y,h0(0xe1));}['assertTarget'](Y){const h1=L;c(Y)!==U&&this['assertAddedNode'](Y,h1(0xeb));}[L(0x104)](Y,J){const hw={Y:0xd6,e:0xfb},h2=L,D=c(Y);if(!this['addedNodeIds'][h2(hw.Y)](D))throw new Error(h2(hw.e)+J+'\x20\x27'+D+h2(0xc7));}[L(0xf2)](Y){const hY={Y:0xef,e:0x101,J:0xf6,D:0xd6,W:0xe4},h3=L;if(typeof Y!=h3(hY.Y)){if(!g(Y))throw new Error(h3(0xff));const J=n(Y,h3(hY.e));if(!this['addedNodeIds'][h3(0xd6)](J))throw new Error(h3(hY.J)+J+h3(0xc6));return J;}if(Y!==this[h3(0xdd)]&&!this[h3(0xe7)][h3(hY.D)](Y))throw new Error(h3(0xf6)+Y+h3(hY.W)+this[h3(0xdd)]+'\x27.');return Y;}}function g(Y){const h4=L,J=Y;return typeof Y==h4(0x105)&&Y!==null&&J[f]===!0x0&&J[h4(0xed)]instanceof C;}p(g,L(0x109));function c(Y){const he={Y:0xef},h5=L;return typeof Y==h5(he.Y)?Y:n(Y,'graph\x20node');}p(c,L(0xc8));export{x as StateGraphExt};function T(){const hJ=['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'];T=function(){return hJ;};return T();}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u=Object.defineProperty;var i=(e,s)=>u(e,"name",{value:s,configurable:!0});function o(e){return n({kind:"go",target:e})}i(o,"go");function f(e="OK"){return n({kind:"stay",feedback:e})}i(f,"stay");function l(e){return n({kind:"direct",response:typeof e=="string"?e:JSON.stringify(e)})}i(l,"direct");function d(e){return n({kind:"finish",response:typeof e=="string"?e:JSON.stringify(e)})}i(d,"finish");function c(e){return!e||typeof e!="object"||!("kind"in e)?!1:["go","stay","direct","finish"].includes(String(e.kind))}i(c,"isToolResponse");function n(e){const s={...e},t=i(r=>n({...e,...r}),"derive");return Object.defineProperties(s,{withState:{enumerable:!1,value:i(r=>t({state:r}),"value")},withMessage:{enumerable:!1,value:i(r=>t({message:r}),"value")},withMessages:{enumerable:!1,value:i(r=>t({messages:r}),"value")},withCleanup:{enumerable:!1,value:i(r=>t({cleanup:r}),"value")},withToolFeedback:{enumerable:!1,value:i(r=>t({feedback:r}),"value")}}),s}i(n,"createBuilder");export{l as direct,d as finish,o as go,c as isToolResponse,f as stay};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BaseGraph as r}from"./framework/base-graph.js";import{GRAPH_NODE_CLASS as n,GraphNode as s,GraphNodeRuntime as a,Tool as i}from"./framework/graph-node.js";import{ConversationNode as m}from"./framework/conversation-node.js";import{LLM_GATEWAY_FACTORY as E,assertLlmTimeoutMs as x}from"./framework/llm-gateway.js";import{ConversationRunner as _,DEFAULT_CONVERSATION_POLICY as T,DEFAULT_EMPTY_HISTORY_SEED as
|
|
1
|
+
import{BaseGraph as r}from"./framework/base-graph.js";import{GRAPH_NODE_CLASS as n,GraphNode as s,GraphNodeRuntime as a,Tool as i}from"./framework/graph-node.js";import{ConversationNode as m}from"./framework/conversation-node.js";import{LLM_GATEWAY_FACTORY as E,assertLlmTimeoutMs as x}from"./framework/llm-gateway.js";import{ConversationRunner as _,DEFAULT_CONVERSATION_POLICY as T,DEFAULT_EMPTY_HISTORY_SEED as f,DEFAULT_EMPTY_RESPONSE_RECOVERY as R,DEFAULT_MAX_AGENT_ROUNDS as g,EmptyModelResponseError as M,assertEmptyResponseRetries as C,assertMaxAgentRounds as A}from"./framework/conversation-runner.js";import{describeStopReason as N,isRetryableStopReason as l,modelStopReason as O}from"./framework/model-stop-reason.js";import{currentTurnContext as D,currentTurnSignal as G,withTurnContext as I}from"./framework/turn-context.js";import{direct as h,finish as c,go as U,isToolResponse as y,stay as F}from"./framework/tool-response.js";import{GraphStateSupport as v}from"./framework/graph-state-support.js";import{GRAPH_END_NODE as k,createGraphStateAnnotation as B}from"./framework/graph-state.js";import{GraphRegistry as b}from"./framework/graph-registry.js";import{GraphEngine as W}from"./framework/graph-engine.js";import{ConfigManager as q}from"./framework/config-manager.js";import{StateGraphExt as j}from"./framework/state-graph-ext.js";import{TerminateSessionNode as K}from"./framework/terminate-session.node.js";import{SessionLogError as Z,SessionLogWarning as $,createSessionLogs as ee,withSessionLogs as oe}from"./framework/session-log.js";import{ProviderFileManager as te}from"./framework/llm-file.js";import{SessionManager as se,SessionTurnError as ae,SESSION_BUSY as ie,SESSION_CONFLICT as Se,SESSION_COMPLETED as me,SESSION_DOCUMENT_VERSION as pe,MemorySessionDocumentContainer as Ee,sessionTurnLeaseMs as xe,sessionRevision as Le,isLiveSessionTurn as _e,matchesSessionWritePredicate as Te}from"./framework/persistence/session-manager.js";import{MongoDbSessionDocumentContainer as Re}from"./framework/persistence/mongodb-session-document.container.js";import{SqliteSessionDocumentContainer as Me}from"./framework/persistence/sqlite-session-document.container.js";import{CosmosSessionDocumentContainer as Ae}from"./framework/persistence/cosmos-session-document.container.js";import{mergeNodeStates as Ne,replaceNodeStates as le}from"./framework/node-state.js";import{LangChainLlmGateway as ue}from"./framework/langchain-llm-gateway.js";import{ModelProvider as Ge}from"./framework/model-provider.js";import{langChainModelInitialization as Pe}from"./framework/langchain-provider.adapter.js";import{GRAPH_LLM_PROVIDERS as ce,GRAPH_LLM_FAMILIES as Ue,GRAPH_LLM_CAPABILITIES as ye,BUILT_IN_MODEL_CATALOG as Fe,GraphLlm as Ye,ModelCatalog as ve,ModelProviderRegistry as He}from"./framework/graph-llm.config.js";import{addTokenUsage as Be,emptyTokenUsage as Ve,modelExecution as be,normalizeTokenUsage as we,tokenUsageFromMessage as We}from"./framework/token-usage.js";export{Fe as BUILT_IN_MODEL_CATALOG,r as BaseGraph,q as ConfigManager,m as ConversationNode,_ as ConversationRunner,Ae as CosmosSessionDocumentContainer,T as DEFAULT_CONVERSATION_POLICY,f as DEFAULT_EMPTY_HISTORY_SEED,R as DEFAULT_EMPTY_RESPONSE_RECOVERY,g as DEFAULT_MAX_AGENT_ROUNDS,M as EmptyModelResponseError,k as GRAPH_END_NODE,ye as GRAPH_LLM_CAPABILITIES,Ue as GRAPH_LLM_FAMILIES,ce as GRAPH_LLM_PROVIDERS,n as GRAPH_NODE_CLASS,W as GraphEngine,Ye as GraphLlm,s as GraphNode,a as GraphNodeRuntime,b as GraphRegistry,v as GraphStateSupport,E as LLM_GATEWAY_FACTORY,ue as LangChainLlmGateway,Ee as MemorySessionDocumentContainer,ve as ModelCatalog,Ge as ModelProvider,He as ModelProviderRegistry,Re as MongoDbSessionDocumentContainer,te as ProviderFileManager,ie as SESSION_BUSY,me as SESSION_COMPLETED,Se as SESSION_CONFLICT,pe as SESSION_DOCUMENT_VERSION,Z as SessionLogError,$ as SessionLogWarning,se as SessionManager,ae as SessionTurnError,Me as SqliteSessionDocumentContainer,j as StateGraphExt,K as TerminateSessionNode,i as Tool,Be as addTokenUsage,C as assertEmptyResponseRetries,x as assertLlmTimeoutMs,A as assertMaxAgentRounds,B as createGraphStateAnnotation,ee as createSessionLogs,D as currentTurnContext,G as currentTurnSignal,N as describeStopReason,h as direct,Ve as emptyTokenUsage,c as finish,U as go,_e as isLiveSessionTurn,l as isRetryableStopReason,y as isToolResponse,Pe as langChainModelInitialization,Te as matchesSessionWritePredicate,Ne as mergeNodeStates,be as modelExecution,O as modelStopReason,we as normalizeTokenUsage,le as replaceNodeStates,Le as sessionRevision,xe as sessionTurnLeaseMs,F as stay,We as tokenUsageFromMessage,oe as withSessionLogs,I as withTurnContext};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { BaseGraph, type GraphDefinition, type GraphNodeConstructor, type GraphSchemaMigration, type HistorySpace, } from "../../src/framework/base-graph.js";
|
|
2
|
-
export { GRAPH_NODE_CLASS, GraphNode, GraphNodeRuntime, Tool, type EmptyModelResponseContext, type GraphNodeUpdate, type InvalidJsonResponseContext, type ToolDefinition, type ToolInput, type GraphNodeLocalState, type GraphNodeTarget,
|
|
2
|
+
export { GRAPH_NODE_CLASS, GraphNode, GraphNodeRuntime, Tool, type EmptyModelResponseContext, type GraphNodeUpdate, type GraphNodeResult, type InvalidJsonResponseContext, type ToolDefinition, type ToolInput, type GraphNodeLocalState, type GraphNodeTarget, } from "../../src/framework/graph-node.js";
|
|
3
3
|
export { ConversationNode, type ConversationNodeRunResult, } from "../../src/framework/conversation-node.js";
|
|
4
4
|
export { LLM_GATEWAY_FACTORY, assertLlmTimeoutMs, type LlmCallOptions, type LlmGateway, type LlmGatewayFactory, type LlmGatewayTool, type LlmGatewayToolCall, } from "../../src/framework/llm-gateway.js";
|
|
5
|
-
export { ConversationRunner, DEFAULT_CONVERSATION_POLICY, DEFAULT_EMPTY_HISTORY_SEED, DEFAULT_EMPTY_RESPONSE_RECOVERY, DEFAULT_MAX_AGENT_ROUNDS, EmptyModelResponseError, assertEmptyResponseRetries, assertMaxAgentRounds, type ConversationPolicy, type ConversationRunResult, type
|
|
5
|
+
export { ConversationRunner, DEFAULT_CONVERSATION_POLICY, DEFAULT_EMPTY_HISTORY_SEED, DEFAULT_EMPTY_RESPONSE_RECOVERY, DEFAULT_MAX_AGENT_ROUNDS, EmptyModelResponseError, assertEmptyResponseRetries, assertMaxAgentRounds, type ConversationPolicy, type ConversationRunResult, type EmptyResponseRecovery, } from "../../src/framework/conversation-runner.js";
|
|
6
6
|
export { describeStopReason, isRetryableStopReason, modelStopReason, type ModelStopCategory, type ModelStopReason, } from "../../src/framework/model-stop-reason.js";
|
|
7
7
|
export { currentTurnContext, currentTurnSignal, withTurnContext, type TurnContext, } from "../../src/framework/turn-context.js";
|
|
8
|
-
export { type
|
|
8
|
+
export { direct, finish, go, isToolResponse, stay, type ToolResponse, type ToolResponseBuilder, type ToolResponseKind, } from "../../src/framework/tool-response.js";
|
|
9
9
|
export { GraphStateSupport } from "../../src/framework/graph-state-support.js";
|
|
10
10
|
export { GRAPH_END_NODE, createGraphStateAnnotation, type GraphState, } from "../../src/framework/graph-state.js";
|
|
11
11
|
export { GraphRegistry, type RegisteredGraph, } from "../../src/framework/graph-registry.js";
|
|
@@ -19,7 +19,7 @@ export { SessionManager, SessionTurnError, SESSION_BUSY, SESSION_CONFLICT, SESSI
|
|
|
19
19
|
export { MongoDbSessionDocumentContainer } from "../../src/framework/persistence/mongodb-session-document.container.js";
|
|
20
20
|
export { SqliteSessionDocumentContainer } from "../../src/framework/persistence/sqlite-session-document.container.js";
|
|
21
21
|
export { CosmosSessionDocumentContainer } from "../../src/framework/persistence/cosmos-session-document.container.js";
|
|
22
|
-
export { mergeNodeStates, type GraphNodeStates, type NodeStateValue, } from "../../src/framework/node-state.js";
|
|
22
|
+
export { mergeNodeStates, replaceNodeStates, type GraphNodeStates, type NodeStateValue, } from "../../src/framework/node-state.js";
|
|
23
23
|
export { LangChainLlmGateway, type LangChainLlmGatewayOptions, } from "../../src/framework/langchain-llm-gateway.js";
|
|
24
24
|
export { ModelProvider, type BuiltInModelProviderConfigs, type CustomModelProviderOptions, type ModelProviderRuntimeConfig, type RegisteredModelProviderAdapter, } from "../../src/framework/model-provider.js";
|
|
25
25
|
export { langChainModelInitialization, type LangChainModelInitialization, } from "../../src/framework/langchain-provider.adapter.js";
|
|
@@ -7,6 +7,7 @@ import { StateGraphExt, type GraphNodeClass } from './state-graph-ext.js';
|
|
|
7
7
|
import type { StateDefinitionInit } from '@langchain/langgraph';
|
|
8
8
|
import type { SessionDocument } from './persistence/session-manager.js';
|
|
9
9
|
import { type ConversationPolicy } from './conversation-runner.js';
|
|
10
|
+
import type { GraphNodeLocalState, GraphNodeTarget } from './node-outcome.js';
|
|
10
11
|
export type HistorySpace = readonly [GraphNodeClass, string];
|
|
11
12
|
export type GraphSchemaMigration<State extends GraphState = GraphState> = Readonly<{
|
|
12
13
|
from: number;
|
|
@@ -53,13 +54,20 @@ export declare abstract class BaseGraph<State extends GraphState> {
|
|
|
53
54
|
protected constructor(llmGateway: LlmGateway, definition: GraphDefinition<State['currentNode'], State>);
|
|
54
55
|
get graph(): {
|
|
55
56
|
invoke(input: unknown): Promise<State>;
|
|
57
|
+
stream(input: unknown, options?: {
|
|
58
|
+
streamMode?: 'values';
|
|
59
|
+
}): Promise<AsyncIterable<State>>;
|
|
56
60
|
};
|
|
57
61
|
prepareInput(state: State | undefined, message: HumanMessage): Partial<State>;
|
|
62
|
+
saveNodeState<NodeClass extends GraphNodeTarget>(NodeClass: NodeClass, patch: Partial<GraphNodeLocalState<NodeClass>>): void;
|
|
58
63
|
restoreSessionDoc(sessionDoc: SessionDocument<State>): Promise<SessionDocument<State> | null>;
|
|
59
64
|
protected onRestoreSessionDoc(sessionDoc: SessionDocument<State>): Promise<SessionDocument<State> | null>;
|
|
60
65
|
protected idleMs(sessionDoc: Pick<SessionDocument, 'modifiedAt'>): number;
|
|
61
66
|
protected abstract buildGraph(): {
|
|
62
67
|
invoke(input: unknown): Promise<State>;
|
|
68
|
+
stream(input: unknown, options?: {
|
|
69
|
+
streamMode?: 'values';
|
|
70
|
+
}): Promise<AsyncIterable<State>>;
|
|
63
71
|
};
|
|
64
72
|
protected createStateGraph<StateDefinition extends StateDefinitionInit>(state: StateDefinition): StateGraphExt<StateDefinition>;
|
|
65
73
|
private createNode;
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import type { ConversationRunResult
|
|
2
|
-
import { GraphNode, type
|
|
1
|
+
import type { ConversationRunResult } from './conversation-runner.js';
|
|
2
|
+
import { GraphNode, type GraphNodeResult } from './graph-node.js';
|
|
3
3
|
import type { GraphState } from './graph-state.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare abstract class ConversationNode<State extends GraphState, LocalState extends object = Record<string, never>, Context extends object = Record<string, never>> extends GraphNode<State, LocalState, Context> {
|
|
8
|
-
private readonly quitRequests;
|
|
9
|
-
readonly supportsAutomaticOutcomeRouting = true;
|
|
10
|
-
protected abstract createContext(state: State): Context;
|
|
11
|
-
protected abstract nextStep(state: State, context: Context, conversation: ConversationNodeRunResult): GraphNodeUpdate<State> | Promise<GraphNodeUpdate<State>>;
|
|
4
|
+
import { type ToolResponse } from './tool-response.js';
|
|
5
|
+
export type ConversationNodeRunResult = ConversationRunResult;
|
|
6
|
+
export declare abstract class ConversationNode<State extends GraphState> extends GraphNode<State> {
|
|
12
7
|
protected endChat(input: {
|
|
13
8
|
message?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
protected runConversation(state: State, context: Context): Promise<ConversationNodeRunResult>;
|
|
9
|
+
}): Promise<ToolResponse>;
|
|
10
|
+
run(state: State): Promise<GraphNodeResult<State>>;
|
|
11
|
+
private resolveToolResponse;
|
|
18
12
|
}
|
|
@@ -3,14 +3,14 @@ import type { ToolCall } from '@langchain/core/messages/tool';
|
|
|
3
3
|
import type { GraphLlmConfig } from './graph-llm.config.js';
|
|
4
4
|
import type { LlmCallOptions, LlmGateway, LlmGatewayTool } from './llm-gateway.js';
|
|
5
5
|
import { type TokenUsage } from './token-usage.js';
|
|
6
|
-
import type
|
|
6
|
+
import { type ToolResponse } from './tool-response.js';
|
|
7
7
|
import { type ModelStopReason } from './model-stop-reason.js';
|
|
8
|
-
export type { ConversationToolResult } from './conversation-tool-result.js';
|
|
9
8
|
export type ConversationRunResult = {
|
|
10
9
|
messages: BaseMessage[];
|
|
11
10
|
usage: TokenUsage;
|
|
12
11
|
response?: string;
|
|
13
12
|
stoppedAfterTool: boolean;
|
|
13
|
+
toolResponse?: ToolResponse;
|
|
14
14
|
stopReason?: ModelStopReason;
|
|
15
15
|
};
|
|
16
16
|
export declare class EmptyModelResponseError extends Error {
|
|
@@ -40,7 +40,7 @@ export declare class ConversationRunner {
|
|
|
40
40
|
history: readonly BaseMessage[];
|
|
41
41
|
tools: readonly LlmGatewayTool[];
|
|
42
42
|
llmConfig: GraphLlmConfig;
|
|
43
|
-
executeTool: (call: ToolCall) => Promise<
|
|
43
|
+
executeTool: (call: ToolCall) => Promise<ToolResponse>;
|
|
44
44
|
maxAgentRounds?: number;
|
|
45
45
|
emptyHistorySeed?: string | null;
|
|
46
46
|
emptyResponseRecovery?: EmptyResponseRecovery | null;
|
|
@@ -3,16 +3,18 @@ import type { LlmCallOptions, LlmGateway, LlmGatewayTool } from './llm-gateway.j
|
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import { type BaseMessage } from '@langchain/core/messages';
|
|
5
5
|
import type { ToolCall } from '@langchain/core/messages/tool';
|
|
6
|
+
import { Command } from '@langchain/langgraph';
|
|
6
7
|
import { type GraphLlmConfig, type GraphLlmConfigOverride } from './graph-llm.config.js';
|
|
7
8
|
import type { NodeStateValue } from './node-state.js';
|
|
8
9
|
import { GraphStateSupport } from './graph-state-support.js';
|
|
9
|
-
import { type ConversationPolicy, type ConversationRunResult
|
|
10
|
+
import { type ConversationPolicy, type ConversationRunResult } from './conversation-runner.js';
|
|
10
11
|
import type { ModelStopReason } from './model-stop-reason.js';
|
|
11
|
-
import { type
|
|
12
|
-
import {
|
|
13
|
-
export { GRAPH_NODE_LOCAL_STATE, type GraphNodeLocalState, type GraphNodeTarget, type GraphNodeUpdate,
|
|
12
|
+
import { GRAPH_NODE_LOCAL_STATE, type GraphNodeLocalState, type GraphNodeTarget, type GraphNodeUpdate } from './node-outcome.js';
|
|
13
|
+
import { type ToolResponse } from './tool-response.js';
|
|
14
|
+
export { GRAPH_NODE_LOCAL_STATE, type GraphNodeLocalState, type GraphNodeTarget, type GraphNodeUpdate, } from './node-outcome.js';
|
|
14
15
|
export type ToolDefinition<Input extends Record<string, unknown> = Record<string, unknown>> = Readonly<LlmGatewayTool<Input>>;
|
|
15
16
|
export type ToolInput<Tool extends ToolDefinition<any>> = Tool extends ToolDefinition<infer Input> ? Input : never;
|
|
17
|
+
export type GraphNodeResult<State extends GraphState> = GraphNodeUpdate<State> | Command<unknown, GraphNodeUpdate<State>, string>;
|
|
16
18
|
export type InvalidJsonResponseContext<State extends GraphState> = Readonly<{
|
|
17
19
|
state: Readonly<State>;
|
|
18
20
|
update: Readonly<GraphNodeUpdate<State>>;
|
|
@@ -26,49 +28,43 @@ export type EmptyModelResponseContext<State extends GraphState> = Readonly<{
|
|
|
26
28
|
}>;
|
|
27
29
|
export declare const GRAPH_NODE_CLASS: unique symbol;
|
|
28
30
|
export declare function Tool(toolName: string): MethodDecorator;
|
|
29
|
-
export declare abstract class GraphNode<State extends GraphState, LocalState extends object = Record<string,
|
|
31
|
+
export declare abstract class GraphNode<State extends GraphState, LocalState extends object = Record<string, unknown>, ToolContext extends object = Record<string, unknown>> {
|
|
30
32
|
protected readonly llmGateway: LlmGateway;
|
|
31
33
|
private readonly runtime;
|
|
32
34
|
static readonly [GRAPH_NODE_CLASS] = true;
|
|
33
35
|
static id(): string;
|
|
34
36
|
static readonly name: string;
|
|
35
37
|
readonly [GRAPH_NODE_LOCAL_STATE]: LocalState;
|
|
36
|
-
readonly supportsAutomaticOutcomeRouting: boolean;
|
|
37
38
|
readonly name: string;
|
|
38
39
|
readonly id: string;
|
|
39
40
|
constructor(llmGateway: LlmGateway, runtime: GraphNodeRuntime<State>);
|
|
41
|
+
protected get graph(): GraphNodeRuntime<State>;
|
|
40
42
|
abstract getPrompt(state: State): string;
|
|
41
43
|
defineTool(): readonly ToolDefinition[];
|
|
42
44
|
getLlmConfig(): GraphLlmConfigOverride;
|
|
43
45
|
route(_state: State): string;
|
|
44
|
-
protected handleTool(state: State, call: ToolCall, context: ToolContext): Promise<
|
|
46
|
+
protected handleTool(state: State, call: ToolCall, context: ToolContext): Promise<ToolResponse>;
|
|
45
47
|
private rejectToolCall;
|
|
46
|
-
abstract run(state: State):
|
|
48
|
+
abstract run(state: State): GraphNodeResult<State> | Promise<GraphNodeResult<State>>;
|
|
47
49
|
protected onInvalidJsonResponse(context: InvalidJsonResponseContext<State>): GraphNodeUpdate<State> | Promise<GraphNodeUpdate<State>>;
|
|
48
50
|
protected onEmptyModelResponse(context: EmptyModelResponseContext<State>): string | Promise<string>;
|
|
49
|
-
readonly invoke: (state: State) => Promise<
|
|
51
|
+
readonly invoke: (state: State) => Promise<GraphNodeResult<State>>;
|
|
50
52
|
obtainTools(): readonly ToolDefinition[];
|
|
51
53
|
validateTools(): void;
|
|
52
54
|
protected llmConfig(): GraphLlmConfig;
|
|
53
55
|
protected llmCallOptions(): LlmCallOptions;
|
|
54
56
|
protected runConversation(state: State, context: ToolContext): Promise<ConversationRunResult>;
|
|
55
57
|
private runAgentLoop;
|
|
56
|
-
protected toolResult(output: unknown): ConversationToolResultBuilder<ToolContext>;
|
|
57
58
|
protected historySpace(): string;
|
|
58
59
|
protected history(state: Pick<State, 'histories'>): BaseMessage[];
|
|
59
60
|
protected historyUpdate(messages: BaseMessage[]): Pick<State, 'histories'>;
|
|
60
61
|
protected respond(message: string): GraphNodeUpdate<State>;
|
|
61
62
|
protected complete(message: string): GraphNodeUpdate<State>;
|
|
62
|
-
protected stay(conversation: ConversationRunResult, response?: string | undefined): NodeOutcomeBuilder<State, LocalState>;
|
|
63
|
-
protected resumeAt<NodeClass extends GraphNodeTarget>(NodeClass: NodeClass, conversation: ConversationRunResult): NodeOutcomeBuilder<State, LocalState>;
|
|
64
|
-
protected advance<NodeClass extends GraphNodeTarget>(NodeClass: NodeClass, conversation: ConversationRunResult): NodeOutcomeBuilder<State, LocalState, true>;
|
|
65
|
-
protected transition<NodeClass extends GraphNodeTarget>(NodeClass: NodeClass, conversation: ConversationRunResult, canForwardInput: false): NodeOutcomeBuilder<State, LocalState>;
|
|
66
|
-
protected transition<NodeClass extends GraphNodeTarget>(NodeClass: NodeClass, conversation: ConversationRunResult, canForwardInput: true): NodeOutcomeBuilder<State, LocalState, true>;
|
|
67
|
-
protected finish(response: string, conversation: ConversationRunResult): NodeOutcomeBuilder<State, LocalState>;
|
|
68
63
|
protected state(state: Pick<State, 'nodes'>): NodeStateValue<LocalState>;
|
|
64
|
+
protected getState(): Readonly<NodeStateValue<LocalState>>;
|
|
65
|
+
protected saveState(patch: Partial<LocalState>): void;
|
|
69
66
|
protected save(patch: Partial<LocalState>): GraphNodeUpdate<State>;
|
|
70
67
|
protected remove(...keys: (keyof LocalState & string)[]): GraphNodeUpdate<State>;
|
|
71
|
-
private outcomeBuilder;
|
|
72
68
|
private toolHandler;
|
|
73
69
|
private resolveJsonResponse;
|
|
74
70
|
private toolHandlers;
|
|
@@ -99,8 +95,15 @@ export declare class GraphNodeRuntime<State extends GraphState> extends GraphSta
|
|
|
99
95
|
response: string;
|
|
100
96
|
inputConsumed: boolean;
|
|
101
97
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
withInvocation<Result>(nodeId: string, state: State, run: () => Promise<Result>): Promise<Result>;
|
|
99
|
+
nodeState(nodeName: string): Record<string, unknown>;
|
|
100
|
+
hasInvocation(): boolean;
|
|
101
|
+
graphState(): State;
|
|
102
|
+
appendHistory(space: string, messages: readonly BaseMessage[]): void;
|
|
103
|
+
invocationHistory(space: string): BaseMessage[];
|
|
104
|
+
stagedUpdate(): GraphNodeUpdate<State>;
|
|
105
|
+
stageNodeEntries(nodes: State['nodes'] | undefined): void;
|
|
106
|
+
saveNode(nodeName: string, values: NodeStateValue): GraphNodeUpdate<State>;
|
|
107
|
+
saveNodeState<NodeClass extends GraphNodeTarget>(NodeClass: NodeClass, patch: Partial<GraphNodeLocalState<NodeClass>>): void;
|
|
108
|
+
removeNode(nodeName: string, ...keys: string[]): Partial<State>;
|
|
106
109
|
}
|
|
@@ -11,6 +11,9 @@ export interface RegisteredGraph<State extends GraphState = GraphState> {
|
|
|
11
11
|
readonly responseMode?: 'chat' | 'json';
|
|
12
12
|
readonly graph: {
|
|
13
13
|
invoke(input: any): Promise<State>;
|
|
14
|
+
stream?(input: any, options?: {
|
|
15
|
+
streamMode?: 'values';
|
|
16
|
+
}): Promise<AsyncIterable<State>>;
|
|
14
17
|
};
|
|
15
18
|
prepareInput(state: State | undefined, message: HumanMessage): Partial<State>;
|
|
16
19
|
restoreSessionDoc?(sessionDoc: SessionDocument<State>): Promise<SessionDocument<State> | null>;
|
|
@@ -11,7 +11,6 @@ export type GraphState<CurrentNode extends string = string, Nodes extends object
|
|
|
11
11
|
inputConsumed: boolean;
|
|
12
12
|
response: string;
|
|
13
13
|
completed: boolean;
|
|
14
|
-
outcomeRoute: string | undefined;
|
|
15
14
|
};
|
|
16
15
|
export declare function createGraphStateAnnotation<CurrentNode extends string = string, Nodes extends object = GraphNodeStates>(defaultCurrentNode: string, createInitialNodes?: () => Nodes): import("@langchain/langgraph").AnnotationRoot<{
|
|
17
16
|
histories: import("@langchain/langgraph").BaseChannel<Record<string, BaseMessage<import("@langchain/core/messages").MessageStructure<import("@langchain/core/messages").MessageToolSet>, import("@langchain/core/messages").MessageType>[]>, Record<string, BaseMessage<import("@langchain/core/messages").MessageStructure<import("@langchain/core/messages").MessageToolSet>, import("@langchain/core/messages").MessageType>[]> | import("@langchain/langgraph").OverwriteValue<Record<string, BaseMessage<import("@langchain/core/messages").MessageStructure<import("@langchain/core/messages").MessageToolSet>, import("@langchain/core/messages").MessageType>[]>>, unknown>;
|
|
@@ -22,5 +21,4 @@ export declare function createGraphStateAnnotation<CurrentNode extends string =
|
|
|
22
21
|
inputConsumed: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
23
22
|
response: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
24
23
|
completed: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
25
|
-
outcomeRoute: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
26
24
|
}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
2
|
+
import type { GraphState } from './graph-state.js';
|
|
3
|
+
export declare function hasNodeInvocation(owner: object): boolean;
|
|
4
|
+
export declare function withNodeInvocation<State extends GraphState, Result>(owner: object, nodeId: string, state: State, run: () => Promise<Result>): Promise<Result>;
|
|
5
|
+
export declare function invocationNodeId(owner: object): string;
|
|
6
|
+
export declare function invocationNodeState(owner: object, nodeId: string): Record<string, unknown>;
|
|
7
|
+
export declare function saveInvocationNodeState(owner: object, nodeId: string, patch: Record<string, unknown>): void;
|
|
8
|
+
export declare function replaceInvocationNodeState(owner: object, nodeId: string, value: Record<string, unknown>): void;
|
|
9
|
+
export declare function appendInvocationHistory(owner: object, space: string, messages: readonly BaseMessage[]): void;
|
|
10
|
+
export declare function invocationHistory(owner: object, space: string): BaseMessage[];
|
|
11
|
+
export declare function invocationGraphState<State extends GraphState>(owner: object): State;
|
|
12
|
+
export declare function invocationUpdate<State extends GraphState>(owner: object): Partial<State>;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { HumanMessage, type BaseMessage } from '@langchain/core/messages';
|
|
2
|
-
import { END } from '@langchain/langgraph';
|
|
3
1
|
import type { GraphState } from './graph-state.js';
|
|
4
2
|
export declare const GRAPH_NODE_LOCAL_STATE: unique symbol;
|
|
5
3
|
export type GraphNodeTarget<LocalState extends object = object> = {
|
|
@@ -11,31 +9,4 @@ export type GraphNodeTarget<LocalState extends object = object> = {
|
|
|
11
9
|
};
|
|
12
10
|
export type GraphNodeLocalState<NodeClass extends GraphNodeTarget> = NodeClass['prototype'][typeof GRAPH_NODE_LOCAL_STATE];
|
|
13
11
|
export type GraphNodeUpdate<State extends GraphState> = Partial<State>;
|
|
14
|
-
export
|
|
15
|
-
export declare const OUTCOME_ROUTE_TARGET: unique symbol;
|
|
16
|
-
type OutcomeState<State extends GraphState> = Pick<State, 'histories' | 'currentNode'>;
|
|
17
|
-
export type NodeOutcomeBuilder<State extends GraphState, LocalState extends object, CanForwardInput extends boolean = false> = Readonly<GraphNodeUpdate<State>> & {
|
|
18
|
-
withState(patch: Partial<LocalState>): NodeOutcomeBuilder<State, LocalState, CanForwardInput>;
|
|
19
|
-
withStateFor<NodeClass extends GraphNodeTarget>(NodeClass: NodeClass, patch: Partial<GraphNodeLocalState<NodeClass>>): NodeOutcomeBuilder<State, LocalState, CanForwardInput>;
|
|
20
|
-
withHistory(space: string, messages: BaseMessage | readonly BaseMessage[]): NodeOutcomeBuilder<State, LocalState, CanForwardInput>;
|
|
21
|
-
via<NodeClass extends GraphNodeTarget>(NodeClass: NodeClass): NodeOutcomeBuilder<State, LocalState, CanForwardInput>;
|
|
22
|
-
} & (CanForwardInput extends true ? {
|
|
23
|
-
forwardInput(state: OutcomeState<State>, fallbackMessage?: string): NodeOutcomeBuilder<State, LocalState>;
|
|
24
|
-
} : object);
|
|
25
|
-
type BuilderOptions<State extends GraphState, LocalState extends object, CanForwardInput extends boolean> = Readonly<{
|
|
26
|
-
update: GraphNodeUpdate<State>;
|
|
27
|
-
nodeName: string;
|
|
28
|
-
saveNode: (nodeName: string, patch: Record<string, unknown>) => GraphNodeUpdate<State>;
|
|
29
|
-
forwardInput?: (state: OutcomeState<State>, fallbackMessage?: string) => GraphNodeUpdate<State>;
|
|
30
|
-
routeTarget: OutcomeRouteTarget;
|
|
31
|
-
}>;
|
|
32
|
-
export declare function createNodeOutcomeBuilder<State extends GraphState, LocalState extends object, CanForwardInput extends boolean>(options: BuilderOptions<State, LocalState, CanForwardInput>): NodeOutcomeBuilder<State, LocalState, CanForwardInput>;
|
|
33
|
-
export declare function outcomeRouteTarget(update: GraphNodeUpdate<GraphState>): OutcomeRouteTarget | undefined;
|
|
34
|
-
export declare function preserveOutcomeRouteTarget<State extends GraphState, Update extends GraphNodeUpdate<State>>(source: GraphNodeUpdate<State>, update: Update): Update;
|
|
35
|
-
export declare function forwardedHistoryUpdate<State extends GraphState>(options: {
|
|
36
|
-
sourceSpace: string;
|
|
37
|
-
targetSpace: string;
|
|
38
|
-
latestInput?: HumanMessage;
|
|
39
|
-
fallbackMessage?: string;
|
|
40
|
-
}): GraphNodeUpdate<State>;
|
|
41
|
-
export {};
|
|
12
|
+
export declare function combineGraphNodeUpdates<State extends GraphState>(current: GraphNodeUpdate<State>, addition: GraphNodeUpdate<State>): GraphNodeUpdate<State>;
|
|
@@ -3,4 +3,5 @@ export type NodeStateValue<T extends object = Record<string, unknown>> = T & {
|
|
|
3
3
|
model?: GraphLlmModelMetadata | undefined;
|
|
4
4
|
};
|
|
5
5
|
export type GraphNodeStates = Record<string, NodeStateValue>;
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function replaceNodeStates<NodeStates extends object>(current: NodeStates, update: Partial<NodeStates>): NodeStates;
|
|
7
|
+
export declare const mergeNodeStates: typeof replaceNodeStates;
|