@picoflow/ezgraph 0.0.5 → 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 +174 -68
- 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/model-catalog.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/openai-auth-provider.js +4 -0
- 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 +5 -5
- 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-llm.config.d.ts +1 -1
- 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/model-catalog.d.ts +20 -1
- 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/openai-auth-provider.d.ts +12 -0
- 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
|
-
var x=Object.defineProperty;var
|
|
1
|
+
var x=Object.defineProperty;var m=(i,e)=>x(i,"name",{value:e,configurable:!0});import{z as o}from"zod";const y=["openai","openai-auth","anthropic","google","azure_openai","bedrock","ollama","cohere","cerebras","deepseek","fireworks","groq","mistral","mistralai","perplexity","together","xai","scripted"],E=["chat","reasoning","thinking"],S=["imageInputs","imageUrlInputs","pdfInputs","audioInputs","videoInputs","reasoningOutput","toolCalling","toolChoice","structuredOutput"],$=Symbol("ezgraph.builtInModelConfig");class k{static{m(this,"ModelProviderRegistry")}adapters=new Map;static create(){return new k}register(e,r){const t=e.trim();if(!/^[a-z][a-z0-9_-]*$/.test(t))throw new Error(`Model provider ID '${e}' is invalid.`);if(y.includes(t))throw new Error(`Model provider '${t}' is built in and cannot be replaced.`);if(this.adapters.has(t))throw new Error(`Model provider '${t}' is already registered.`);return this.adapters.set(t,r),this}adapter(e){return this.adapters.get(e)}}const g=Symbol("ezgraph.runtimeModelDescriptor"),T={type:"object",additionalProperties:!1,properties:Object.fromEntries(S.map(i=>[i,{const:!0}]))},I={retries:{type:"integer",minimum:0},maxOutputTokens:{type:"integer",minimum:1},forceToolCalls:{type:"boolean"},requiredCapabilities:T},l={retries:"maxRetries",forceToolCalls:null,requiredCapabilities:null};function d(i){return{type:"object",additionalProperties:!1,required:["retries"],properties:{...I,...i}}}m(d,"parameterSchema");const h={"openai.chat":{provider:"openai",family:"chat",paramsSchema:d({temperature:{type:"number"},serviceTier:{enum:["auto","default","flex","priority"]},promptCacheKey:{type:"string",minLength:1}}),parameterMappings:{...l,maxOutputTokens:"maxTokens",temperature:"temperature",serviceTier:"service_tier",promptCacheKey:"promptCacheKey"}},"openai.reasoning":{provider:"openai",family:"reasoning",paramsSchema:d({reasoningEffort:{enum:["none","minimal","low","medium","high","xhigh","max"]},serviceTier:{enum:["auto","default","flex","priority"]},promptCacheKey:{type:"string",minLength:1}}),parameterMappings:{...l,maxOutputTokens:"maxTokens",reasoningEffort:"reasoningEffort",serviceTier:"service_tier",promptCacheKey:"promptCacheKey"}},"openai-auth.reasoning":{provider:"openai-auth",family:"reasoning",paramsSchema:d({reasoningEffort:{enum:["none","minimal","low","medium","high","xhigh","max"]}}),parameterMappings:{...l,maxOutputTokens:"maxTokens",reasoningEffort:"reasoningEffort"}},"anthropic.chat":{provider:"anthropic",family:"chat",paramsSchema:d({temperature:{type:"number"},outputEffort:{enum:["low","medium","high","xhigh","max"]}}),parameterMappings:{...l,maxOutputTokens:"maxTokens",temperature:"temperature",outputEffort:"outputConfig.effort"}},"anthropic.thinking":{provider:"anthropic",family:"thinking",paramsSchema:d({thinking:{oneOf:[{type:"object",additionalProperties:!1,required:["type"],properties:{type:{const:"adaptive"}}},{type:"object",additionalProperties:!1,required:["type"],properties:{type:{const:"disabled"}}},{type:"object",additionalProperties:!1,required:["type","budget_tokens"],properties:{type:{const:"enabled"},budget_tokens:{type:"integer",minimum:1024}}}]},outputEffort:{enum:["low","medium","high","xhigh","max"]}}),parameterMappings:{...l,maxOutputTokens:"maxTokens",thinking:"thinking",outputEffort:"outputConfig.effort"}},"google.chat":{provider:"google",family:"chat",paramsSchema:d({temperature:{type:"number"},thinkingBudget:{type:"integer",minimum:0},reasoningEffort:{enum:["minimal","low","medium","high"]},safetySettings:{type:"array",items:{type:"object",additionalProperties:!1,required:["category","threshold"],properties:{category:{type:"string",minLength:1},threshold:{type:"string",minLength:1}}}}}),parameterMappings:{...l,maxOutputTokens:"maxOutputTokens",temperature:"temperature",thinkingBudget:"thinkingConfig.thinkingBudget",reasoningEffort:"thinkingConfig.reasoningEffort",safetySettings:"safetySettings"}},"scripted.chat":{provider:"scripted",family:"chat",paramsSchema:d({temperature:{type:"number"}}),parameterMappings:{...l,maxOutputTokens:"maxTokens",temperature:"temperature"}}},O={version:1,profiles:h,models:{"openai:gpt-4o":{profile:"openai.chat"},"openai:gpt-4o-mini":{profile:"openai.chat"},"openai:gpt-5.1":{profile:"openai.reasoning"},"openai:gpt-5.4":{profile:"openai.reasoning"},"openai-auth:gpt-5.4":{profile:"openai-auth.reasoning"},"anthropic:claude-sonnet-4-5":{profile:"anthropic.chat"},"anthropic:claude-opus-4-1":{profile:"anthropic.thinking"},"google:gemini-3.1-flash-lite":{profile:"google.chat"},"google:gemini-3.5-flash":{profile:"google.chat"},"scripted:scripted-model":{profile:"scripted.chat"}}},C=o.object({provider:o.string().regex(/^[a-z][a-z0-9_-]*$/),family:o.enum(E),paramsSchema:o.record(o.string(),o.unknown()),parameterMappings:o.record(o.string(),o.string().min(1).nullable())}).strict(),_=o.object({$schema:o.string().min(1).optional(),version:o.literal(1),profiles:o.record(o.string().min(1),C).optional(),models:o.record(o.string().min(1),o.object({profile:o.string().min(1),providerModel:o.string().min(1).optional()}).strict())}).strict();class f{static{m(this,"ModelCatalog")}descriptors;static create(e,r={}){return new f(e,r)}static model(e,r){const t={model:e,params:r,[$]:!0};return f.validateConfig(t),t}static validateConfig(e){return f.resolveModelDescriptor(e).paramsSchema.parse(e.params),e}static resolveModelDescriptor(e){if(g in e)return e[g];const r=b().get(e.model);if(!r)throw new Error(`Unknown model '${e.model}'. Add it to a ModelCatalog and construct it with catalog.model().`);return r}constructor(e,r={}){const t=_.parse(e);for(const n of Object.keys(t.profiles??{}))if(n in h)throw new Error(`Model catalog cannot replace built-in profile '${n}'.`);const a=v(t.profiles??{}),p=new Map(b());for(const[n,s]of a){const c=s.definition.provider;if(!y.includes(c)&&!r.providers?.adapter(c))throw new Error(`Model parameter profile '${n}' uses unregistered provider '${c}'.`)}for(const[n,s]of Object.entries(t.models)){if(p.has(n))throw new Error(`Model catalog cannot replace built-in model '${n}'.`);const c=a.get(s.profile)??w().get(s.profile);if(!c)throw new Error(`Model '${n}' references unknown profile '${s.profile}'.`);p.set(n,M(n,s.providerModel,c,r.providers?.adapter(c.definition.provider)))}this.descriptors=p}model(e,r){const t=this.descriptors.get(e);if(!t)throw new Error(`Model '${e}' is not present in the model catalog.`);const a=t.paramsSchema.parse(r);return{model:e,params:a,[g]:t}}}function w(){return P??=v(h)}m(w,"builtInProfiles");function b(){if(u)return u;const i=w(),e=new Map;for(const[r,t]of Object.entries(O.models)){const a=i.get(t.profile);if(!a)throw new Error(`Built-in model '${r}' has an invalid profile.`);e.set(r,M(r,void 0,a))}return u=e,u}m(b,"builtInDescriptors");let P,u;function v(i){const e=new Map;for(const[r,t]of Object.entries(i)){let a;try{a=o.fromJSONSchema(t.paramsSchema)}catch(n){throw new Error(`Model parameter profile '${r}' has an invalid paramsSchema: ${n instanceof Error?n.message:String(n)}`)}const p=t.paramsSchema.properties;if(!p||typeof p!="object"||Array.isArray(p))throw new Error(`Model parameter profile '${r}' must define object properties.`);for(const n of Object.keys(t.parameterMappings)){if(!(n in p))throw new Error(`Model parameter profile '${r}' maps undeclared parameter '${n}'.`);const s=t.parameterMappings[n];typeof s=="string"&&j(r,n,s)}e.set(r,{definition:t,schema:a})}return e}m(v,"compileProfiles");function j(i,e,r){const t=new Set(["__proto__","prototype","constructor"]);if(r.split(".").some(p=>!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(p)||t.has(p)))throw new Error(`Model parameter profile '${i}' has unsafe mapping for '${e}': '${r}'.`)}m(j,"validateMappingPath");function M(i,e,r,t){const a=i.indexOf(":");if(a<=0||a===i.length-1)throw new Error(`Model ID '${i}' must use the '<provider>:<model>' format.`);const p=i.slice(0,a);if(p!==r.definition.provider)throw new Error(`Model '${i}' uses provider '${p}' but profile uses '${r.definition.provider}'.`);return{id:i,providerModel:e??i.slice(a+1),provider:r.definition.provider,family:r.definition.family,paramsSchema:r.schema,parameterMappings:r.definition.parameterMappings,...t?{providerAdapter:t}:{}}}m(M,"descriptor");export{O as BUILT_IN_MODEL_CATALOG,S as GRAPH_LLM_CAPABILITIES,E as GRAPH_LLM_FAMILIES,y as GRAPH_LLM_PROVIDERS,f as ModelCatalog,k as ModelProviderRegistry};
|
|
@@ -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};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var l=Object.defineProperty;var i=(t,n)=>l(t,"name",{value:n,configurable:!0});import{readFileSync as h}from"node:fs";import{homedir as x}from"node:os";import{resolve as g}from"node:path";const f="openai-auth",m="https://chatgpt.com/backend-api/codex",I=".codex/auth.json";function J(t,n){const e=y(),r=process.env.EZGRAPH_OPENAI_AUTH_BASE_URL?.trim()||m;return{model:t,options:{...n,modelProvider:"openai",useResponsesApi:!0,streaming:!0,zdrEnabled:!0,apiKey:_(e),configuration:{baseURL:r,fetch:E(e)}},cacheKey:JSON.stringify({provider:f,model:t,baseURL:r,authFile:e,options:n})}}i(J,"initializeOpenAIAuthProvider");function z(t){return t.model.startsWith(`${f}:`)}i(z,"isOpenAIAuthConfig");function F(t){if(typeof t=="string")return t;if(!Array.isArray(t))return JSON.stringify(t);const n=[];for(const e of t){if(typeof e!="object"||e===null||!("type"in e)||e.type!=="text"&&e.type!=="output_text"||!("text"in e)||typeof e.text!="string")return JSON.stringify(t);n.push(e.text)}return n.join("")}i(F,"openAIAuthMessageText");function y(){const t=process.env.EZGRAPH_OPENAI_AUTH_FILE?.trim();return g(t||`${x()}/${I}`)}i(y,"openAIAuthFile");function d(t=y()){let n;try{n=JSON.parse(h(t,"utf8"))}catch(s){throw new Error(`Unable to read OpenAI auth credentials from ${t}. Run \`codex\` to sign in first.`,{cause:s})}const e=n.tokens?.access_token;if(typeof e!="string"||!e.trim())throw new Error(`OpenAI auth credentials in ${t} do not include an access token. Run \`codex\` to sign in again.`);if(j(e))throw new Error("The local Codex OAuth access token is expired. Run `codex` to refresh it, then retry.");const r=n.tokens?.account_id,o=P(e)||(typeof r=="string"&&r?r:void 0);return o?{accessToken:e,accountId:o}:{accessToken:e}}i(d,"readOpenAIAuthCredentials");async function O(t){if(!t.url.endsWith("/responses")||t.method!=="POST")return t;let n;try{n=JSON.parse(await t.clone().text())}catch{return t}if(typeof n!="object"||n===null||Array.isArray(n))return t;const e=n,r=Array.isArray(e.input)?e.input:[],o=[],s=[];for(const u of r){if(typeof u!="object"||u===null||Array.isArray(u)){s.push(u);continue}const c=u;if(c.type==="message"&&c.role==="developer"){const p=R(c.content);p&&o.push(p);continue}s.push(b(c))}const a={...e,input:s,...o.length>0?{instructions:o.join(`
|
|
2
|
+
|
|
3
|
+
`)}:{}};return T(a.text)&&delete a.text,new Request(t,{body:JSON.stringify(a)})}i(O,"normalizeOpenAIAuthResponsesRequest");function _(t){return async()=>d(t).accessToken}i(_,"openAIAuthAccessToken");function E(t){return async(...n)=>{const e=d(t),r=new Request(...n),o=new Headers(r.headers);o.set("User-Agent","@picoflow/ezgraph"),o.set("originator","ezgraph"),e.accountId&&o.set("ChatGPT-Account-ID",e.accountId);const s=new Request(r,{headers:o});return fetch(await O(s))}}i(E,"createOpenAIAuthFetch");function b(t){return t.type!=="message"||typeof t.role!="string"?t:{...t,content:w(t.content,t.role)}}i(b,"normalizeOpenAIAuthInputItem");function w(t,n){const e=n==="assistant"?"output_text":"input_text";return typeof t=="string"?[{type:e,text:t}]:Array.isArray(t)?t.map(r=>{if(typeof r!="object"||r===null||Array.isArray(r))return r;const o=r;return o.type==="text"&&typeof o.text=="string"?{...o,type:e}:o}):t}i(w,"normalizeOpenAIAuthContent");function R(t){return typeof t=="string"?t:Array.isArray(t)?t.map(n=>{if(typeof n!="object"||n===null||Array.isArray(n))return"";const e=n.text;return typeof e=="string"?e:""}).filter(Boolean).join(`
|
|
4
|
+
`):""}i(R,"responseContentText");function T(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length===0}i(T,"isEmptyObject");function j(t){const n=A(t);return typeof n?.exp=="number"&&Number.isFinite(n.exp)&&n.exp*1e3<=Date.now()}i(j,"isExpiredJwt");function P(t){const n=A(t)?.["https://api.openai.com/auth"];if(typeof n=="object"&&n!==null&&"chatgpt_account_id"in n){const e=n.chatgpt_account_id;return typeof e=="string"&&e?e:void 0}}i(P,"accountIdFromJwt");function A(t){const n=t.split(".")[1];if(n)try{const e=JSON.parse(Buffer.from(n,"base64url").toString("utf8"));return typeof e=="object"&&e!==null?e:void 0}catch{return}}i(A,"decodeJwtPayload");export{f as OPENAI_AUTH_PROVIDER,J as initializeOpenAIAuthProvider,z as isOpenAIAuthConfig,O as normalizeOpenAIAuthResponsesRequest,y as openAIAuthFile,F as openAIAuthMessageText,d as readOpenAIAuthCredentials};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const Ue=D;(function(N,S){const M4={N:0x1dd,S:0x216,F:0x1f2,H:0x23d,i:0x22c,n:0x245},UV=D,F=N();while(!![]){try{const H=parseInt(UV(0x1ff))/0x1+parseInt(UV(0x25a))/0x2*(-parseInt(UV(M4.N))/0x3)+parseInt(UV(M4.S))/0x4*(-parseInt(UV(M4.F))/0x5)+-parseInt(UV(M4.H))/0x6*(-parseInt(UV(0x209))/0x7)+parseInt(UV(M4.i))/0x8+parseInt(UV(M4.n))/0x9*(-parseInt(UV(0x240))/0xa)+parseInt(UV(0x1f0))/0xb;if(H===S)break;else F['push'](F['shift']());}catch(i){F['push'](F['shift']());}}}(M,0xb27a4));var z=Object[Ue(0x204)],c=(N,S)=>z(N,Ue(0x1fc),{'value':S,'configurable':!0x0});import{mapChatMessagesToStoredMessages as A,mapStoredMessagesToChatMessages as K}from'@langchain/core/messages';import{BaseGraph as g}from'../base-graph.js';import{ConfigManager as x}from'../config-manager.js';import{GRAPH_END_NODE as u}from'../graph-state.js';import{GraphLlm as v}from'../graph-llm.config.js';import{mergeNodeStates as e}from'../node-state.js';import{createSessionLogs as O}from'../session-log.js';import{emptyTokenUsage as d,normalizeTokenUsage as a}from'../token-usage.js';import{assertGraphSchemaVersion as b}from'../stable-id.js';const h=0x10,w=Ue(0x25f),$=Ue(0x20b),we=Ue(0x23f);class f extends Error{static{c(this,'SessionTurnError');}[Ue(0x1f3)];constructor(N,S){const M5={N:0x1f3},UO=Ue;super(S),this['name']='SessionTurnError',this[UO(M5.N)]=N;}}class C{static{c(this,Ue(0x257));}['container'];['turnLeaseMs'];constructor(N=new q(),S=j()){const M6={N:0x235},Ud=Ue;this[Ud(0x1fa)]=N,this[Ud(M6.N)]=S;}static async[Ue(0x254)](n=new x()){const M7={N:0x247,S:0x214,F:0x1d5,H:0x238,i:0x201,n:0x1cf,t:0x1f1,s:0x21a,o:0x205,Y:0x248,l:0x20d,L:0x268,r:0x1eb,U0:0x225,U1:0x1d6,U2:0x214,U3:0x233,U4:0x21d,U5:0x1de,U6:0x25c,U7:0x21d,U8:0x264,U9:0x24f,UU:0x1d4},UP=Ue,U0=n['get'](UP(0x1e4),UP(0x265))[UP(M7.N)]()[UP(0x1d9)](),U1=j(n[UP(M7.S)](UP(M7.F)));if(U0==='memory')return new C(new q(),U1);if(U0===UP(M7.H)){const {SqliteSessionDocumentContainer:UK}=await import('./sqlite-session-document.container.js');return new C(new UK(n[UP(0x214)](UP(0x22d),UP(0x252))),U1);}if(U0===UP(0x24b)||U0===UP(M7.i)){const Uh=p(n,UP(0x1d3)),Ug=p(n,'MONGODB_NAME'),Uf=p(n,UP(M7.n));if(!Uh||!Ug||!Uf)throw new Error(UP(0x20a));const [{MongoClient:Ux},{MongoDbSessionDocumentContainer:Uu}]=await Promise[UP(M7.t)]([import('mongodb'),import('./mongodb-session-document.container.js')]),Uv=new Ux(Uh);await Uv[UP(0x221)]();const UG=Uv['db'](Ug)['collection'](Uf);return await UG[UP(0x255)]({'id':0x1},{'unique':!0x0}),new C(new Uu(UG,Uv),U1);}if(U0!==UP(0x249)&&U0!==UP(M7.s))throw new Error('Unsupported\x20SESSION_STORE\x20\x27'+U0+UP(M7.o));const U2=p(n,'COSMO_ENDPOINT','COSMOS_ENDPOINT','COSMODB_URL'),U3=p(n,'COSMODB_KEY','COSMOS_KEY'),U4=p(n,UP(M7.Y)),U5=p(n,UP(M7.l)),U6=p(n,'COSMO_DB_CLIENT_SECRET'),U7=p(n,'COSMO_DB_ID',UP(0x1e9),'COSMODB_ID')??UP(0x212),U8=p(n,UP(0x229),UP(M7.L),UP(M7.r))??'sessions';if(!U2||!U3&&(!U4||!U5||!U6))throw new Error(UP(M7.U0));const [{CosmosClient:U9},{ClientSecretCredential:UU}]=await Promise[UP(0x1f1)]([import(UP(0x211)),import(UP(M7.U1))]),UM=U3?new U9({'endpoint':U2,'key':U3}):new U9({'endpoint':U2,'aadCredentials':new UU(U4,U5,U6)}),{database:UT}=await UM[UP(0x239)][UP(0x233)]({'id':U7}),UC=Number(n[UP(M7.U2)](UP(0x1ef),'400')),{container:UD}=await UT[UP(0x262)][UP(M7.U3)]({'id':U8,'partitionKey':{'paths':[UP(M7.U4)]},...Number[UP(0x26a)](UC)&&UC>0x0?{'throughput':UC}:{}}),{resource:Uc}=await UD[UP(M7.U5)](),UA=Uc?.[UP(0x1e3)]?.[UP(M7.U6)]??[];if(!UA[UP(0x1f9)](UP(M7.U7)))throw new Error('Cosmos\x20container\x20\x27'+U8+UP(M7.U8)+(UA['join'](',\x20')||UP(M7.U9))+'.');const {CosmosSessionDocumentContainer:UB}=await import(UP(M7.UU));return new C(new UB(UD,()=>UM[UP(0x259)]()),U1);}async['getSession'](N){const M8={N:0x1d2},UE=Ue,S=await this[UE(M8.N)](N);return S?.[UE(0x203)]===h?S:void 0x0;}async[Ue(0x1d2)](N){const Uk=Ue;try{const {resource:S}=await this[Uk(0x1fa)]['item'](N,N)[Uk(0x1de)]();return S;}catch(F){if(V(F))return;throw F;}}async[Ue(0x1dc)](N,S,F){const MU={N:0x206,S:0x1d8,F:0x203,H:0x1f4,i:0x219,n:0x250,t:0x244,s:0x219,o:0x223,Y:0x1d0,l:0x242,L:0x1db},Ua=Ue,H=g['assertId'](F[Ua(MU.N)]),n=b(F[Ua(MU.S)]),Y=await this[Ua(0x1d2)](N);Y&&Y[Ua(MU.F)]===h&&T(Y,H);const L=new Date(),U0={'owner':S,'expiresAt':new Date(L[Ua(0x200)]()+this['turnLeaseMs'])[Ua(MU.H)]()};if(!Y){const U2=this[Ua(MU.i)](N,F,H,n,U0,L['toISOString']());if(await this[Ua(0x1fa)][Ua(MU.n)]({'expectedRevision':null},U2)===Ua(0x223))throw new f(w,Ua(MU.t)+N+Ua(0x242));return{'kind':Ua(0x1db),'document':U2,'expectedRevision':U2[Ua(0x1d0)]};}if(Y[Ua(0x203)]!==h){const U3=this[Ua(MU.s)](N,F,H,n,U0,L[Ua(0x1f4)]());if(await this[Ua(0x1fa)][Ua(MU.n)]({'expectedRevision':m(Y),'replaceIncompatible':!0x0},U3)===Ua(MU.o))throw new f(w,Ua(MU.t)+N+Ua(0x242));return{'kind':Ua(0x1db),'document':U3,'expectedRevision':U3[Ua(MU.Y)]};}if(G(Y[Ua(0x207)])&&Y[Ua(0x207)]?.['owner']!==S)throw new f(w,Ua(0x244)+N+Ua(MU.l));const U1={...Y,'revision':m(Y)+0x1,'turn':U0,'modifiedAt':L[Ua(0x1f4)]()};if(await this['container'][Ua(0x250)]({'expectedRevision':m(Y),'requireFreeLease':!0x0,'allowOwner':S},U1)==='conflict')throw new f(w,'Session\x20\x27'+N+Ua(MU.l));return{'kind':Ua(MU.L),'document':U1,'expectedRevision':m(U1)};}async[Ue(0x1e7)](N,S){const Uq=Ue,F=await this[Uq(0x237)](N);if(F)return this['restoreSessionDocument'](F,S);}['restoreSessionDocument'](N,S){const MT={N:0x1fe,S:0x26b,F:0x25e,H:0x208},Ub=Ue,F=g[Ub(0x1ee)](S);T(N,F);const {graph:H}=N;if(!H[Ub(MT.N)])return;const i=e({},H[Ub(MT.N)]),n=ne(H[Ub(0x21c)]);return{'currentNode':H[Ub(MT.S)],'config':H['config']??{},'completed':N[Ub(MT.F)]===Ub(0x24a)||H[Ub(0x26b)]===u,'nodes':i,'tokens':a(N[Ub(MT.H)]),'histories':n,'inputConsumed':!0x0,'response':''};}async[Ue(0x1e0)](F,H,n,Y=O(),L={}){const MC={N:0x228,S:0x1ec,F:0x26b,H:0x25d},UN=Ue,U0=g['assertId'](n['graphId']),U1=b(n[UN(0x1d8)]),U2=await this['readDocument'](F),U3=U2?.[UN(0x203)]===h?U2:void 0x0;U3&&(T(U3,U0),U(U3,U1));const U4=new Date()[UN(0x1f4)](),U5=ee(e({},H[UN(0x1fe)])),{tokens:U6,histories:U7}=H,U8=this[UN(0x218)](U2,L),U9={'version':h,'id':F,'revision':U8===null?0x0:U8+0x1,'status':H['completed']?'completed':UN(MC.N),'tokens':a(U6),'errors':[...U3?.[UN(MC.S)]??[],...Y[UN(0x1ec)]],'warnings':[...U3?.[UN(0x22e)]??[],...Y[UN(0x22e)]],'graph':{'id':U0,'schemaVersion':U1,'currentNode':H[UN(MC.F)],'config':H[UN(0x1f6)],'histories':re(U7),'model':v['modelMetadata'](n['llmConfig']),'nodes':U5},'createdAt':U3?.['createdAt']??U4,'modifiedAt':U4};if(await this[UN(0x1fa)]['compareAndSwap'](this['commitPredicate'](U2,L,U8),U9)===UN(0x223))throw new f(L[UN(MC.H)]?$:w,L[UN(MC.H)]?'Session\x20\x27'+F+UN(0x1da):'Session\x20\x27'+F+UN(0x242));return U9;}async['appendLogs'](N,F,H,n={}){const MD={N:0x237,S:0x1f4,F:0x25e,H:0x1ec,i:0x22e,n:0x26b,t:0x1f6,s:0x246,o:0x22b,Y:0x1e1,l:0x1fd,L:0x24e,r:0x244},US=Ue,Y=g[US(0x1ee)](H[US(0x206)]),l=b(H[US(0x1d8)]),L=await this[US(MD.N)](N);L&&(T(L,Y),U(L,l));const U0=new Date()[US(MD.S)](),U1=this[US(0x218)](L,n),U2={'version':h,'id':N,'revision':U1===null?0x0:U1+0x1,'status':F['errors']['length']>0x0?'error':L?.[US(MD.F)]??US(0x228),'tokens':L?.[US(0x208)]??d(),'errors':[...L?.[US(0x1ec)]??[],...F[US(MD.H)]],'warnings':[...L?.[US(MD.i)]??[],...F['warnings']],'graph':{'id':Y,'schemaVersion':l,...L?{'currentNode':L[US(0x21f)][US(MD.n)],'config':L[US(0x21f)][US(MD.t)]}:{},'histories':L?.[US(0x21f)][US(0x21c)]??{},'model':v[US(MD.s)](H[US(MD.o)]),...L?.['graph']['nodes']?{'nodes':L[US(0x21f)]['nodes']}:{}},'createdAt':L?.[US(0x230)]??U0,'modifiedAt':U0};if(await this[US(0x1fa)]['compareAndSwap'](this[US(0x21b)](L,n,U1),U2)===US(0x223)){if(n[US(0x25d)]){console[US(0x1e5)](US(0x244)+N+US(MD.Y)+F['errors']['length']+US(MD.l)+F['warnings'][US(MD.L)]+'\x20warning(s)\x20were\x20dropped.');return;}throw new f(w,US(MD.r)+N+US(0x242));}return U2;}async[Ue(0x21e)](N,S,F,H,i){const Mc={N:0x22e,S:0x24e,F:0x20c},UR=Ue;if(H&&(H['errors'][UR(0x24e)]>0x0||H[UR(Mc.N)][UR(Mc.S)]>0x0)){await this[UR(Mc.F)](N,H,F,{'owner':S,...i!==void 0x0?{'expectedRevision':i}:{}});return;}await this['releaseTurn'](N,S,i);}async['releaseTurn'](N,S,F){const MA={N:0x237,S:0x250},Uz=Ue,H=await this[Uz(MA.N)](N);if(!H||H['turn']?.[Uz(0x25d)]!==S)return;const n=F??m(H),{turn:Y,...l}=H,L={...l,'modifiedAt':new Date()[Uz(0x1f4)]()};await this[Uz(0x1fa)][Uz(MA.S)]({'expectedRevision':n,'requireOwner':S},L);}async['deleteSession'](N){const UF=Ue;try{await this[UF(0x1fa)][UF(0x1f5)](N,N)['delete']();}catch(S){if(!V(S))throw S;}}async[Ue(0x1ea)](N,S={}){const MK={N:0x203,S:0x227,F:0x1ee,H:0x21f,i:0x207,n:0x230,t:0x1fa,s:0x25d,o:0x210},Up=Ue;if(N[Up(MK.N)]!==h)throw new Error(Up(MK.S)+N['version']+';\x20expected\x20'+h+'.');g[Up(MK.F)](N[Up(MK.H)]['id']),b(N['graph']['schemaVersion']);const F=await this['getSession'](N['id']),H=S['expectedRevision']??m(F||N),i=F?.[Up(0x207)]??N[Up(MK.i)],n={...N,'revision':H,'createdAt':F?.[Up(0x230)]??N[Up(MK.n)],'modifiedAt':F?.['modifiedAt']??N['modifiedAt'],...i?{'turn':i}:{}};if(await this[Up(MK.t)]['compareAndSwap']({'expectedRevision':H,...S['owner']?{'requireOwner':S[Up(0x25d)]}:{'requireFreeLease':!0x0}},n)===Up(0x223))throw new f(S[Up(MK.s)]?$:w,Up(0x244)+N['id']+Up(MK.o));}async['close'](){const Mh={N:0x1fa},UQ=Ue;await this[UQ(Mh.N)]['close']?.();}[Ue(0x219)](N,S,F,H,i,n){const Mg={N:0x228,S:0x246},UW=Ue;return{'version':h,'id':N,'revision':0x0,'status':UW(Mg.N),'tokens':d(),'errors':[],'warnings':[],'graph':{'id':F,'schemaVersion':H,'histories':{},'model':v[UW(Mg.S)](S[UW(0x22b)])},'turn':i,'createdAt':n,'modifiedAt':n};}['commitExpectedRevision'](N,S){const Mf={N:0x1e2},UH=Ue;return S['expectedRevision']!==void 0x0?S[UH(Mf.N)]:N?m(N):null;}[Ue(0x21b)](N,S,F){const Ui=Ue;return S['owner']?{'expectedRevision':F,'requireOwner':S[Ui(0x25d)]}:N&&N[Ui(0x203)]!==h?{'expectedRevision':F,'replaceIncompatible':!0x0}:{'expectedRevision':F,'requireFreeLease':!0x0};}}function p(N,...S){const UZ=Ue;for(const F of S){const H=N[UZ(0x214)](F);if(H)return H;}}c(p,Ue(0x24d));function T(N,S){const Mv={N:0x21f,S:0x244},Uw=Ue;if(N[Uw(Mv.N)]['id']!==S)throw new Error(Uw(Mv.S)+N['id']+'\x27\x20belongs\x20to\x20graph\x20\x27'+N[Uw(0x21f)]['id']+Uw(0x23c)+S+'\x27.\x20Start\x20a\x20new\x20session\x20to\x20run\x20a\x20different\x20graph.');}c(T,Ue(0x267));function U(N,S){const MG={N:0x21f,S:0x244,F:0x21f,H:0x1f8},UJ=Ue;if(N[UJ(MG.N)][UJ(0x263)]!==S)throw new Error(UJ(MG.S)+N['id']+'\x27\x20uses\x20graph\x20\x27'+N[UJ(MG.F)]['id']+UJ(0x26c)+N[UJ(MG.N)][UJ(0x263)]+UJ(MG.H)+S+UJ(0x1cd));}c(U,'assertSessionGraphSchema');function ee(N){const Me={N:0x251},Uj=Ue;return Object[Uj(0x226)](Object[Uj(Me.N)](N)[Uj(0x253)](([S,F])=>{const Un=Uj;if(!F||typeof F!=Un(0x222))return[S,F];const {toolTrace:H,...i}=F;return[S,i];}));}c(ee,Ue(0x202));function te(N){const Md={N:0x253},MO={N:0x1d1,S:0x20e,F:0x1df,H:0x24e,i:0x22f,n:0x1fb,t:0x23e},Ut=Ue;return N[Ut(Md.N)](S=>{const Um=Ut,F={...S[Um(MO.N)]},H=S[Um(MO.S)]==='ai'&&Array[Um(0x1fb)](F[Um(MO.F)])&&F[Um(0x1df)][Um(MO.H)]>0x0?oe(F[Um(0x241)]):void 0x0;return delete F['additional_kwargs'],H&&(F[Um(0x241)]={'originalTextContentBlock':H}),delete F['response_metadata'],delete F[Um(MO.i)],S[Um(0x20e)]==='ai'&&(Array[Um(MO.n)](F[Um(0x1df)])&&F[Um(MO.F)]['length']===0x0&&delete F[Um(MO.F)],Array[Um(MO.n)](F[Um(MO.t)])&&F[Um(MO.t)]['length']===0x0&&delete F[Um(0x23e)]),{...S,'data':F};});}c(te,Ue(0x220));function re(N){const MP={N:0x226},Us=Ue;return Object[Us(MP.N)](Object[Us(0x251)](N)[Us(0x253)](([S,F])=>[S,te(A(F))]));}c(re,'storeHistories');function ne(N={}){const Uo=Ue;return Object[Uo(0x226)](Object['entries'](N)[Uo(0x253)](([S,F])=>[S,K(F)]));}c(ne,Ue(0x217));function oe(N){const Mk={N:0x234,S:0x215},UY=Ue;if(!P(N))return;const S=N[UY(Mk.N)];if(!(!P(S)||typeof S['thoughtSignature']!=UY(0x215)))return{...typeof S['text']==UY(Mk.S)?{'text':S[UY(0x213)]}:{},'thoughtSignature':S['thoughtSignature'],...S[UY(0x1d7)]===!0x0?{'thought':!0x0}:{}};}c(oe,Ue(0x243));function P(N){const Ul=Ue;return N!==null&&typeof N==Ul(0x222)&&!Array[Ul(0x1fb)](N);}c(P,Ue(0x25b));class q{static{c(this,'MemorySessionDocumentContainer');}['documents']=new Map();get[Ue(0x232)](){return this['documents']['size'];}[Ue(0x236)]={'upsert':c(async e=>{const Mb={N:0x260},Uy=Ue,t=e;return this[Uy(0x256)][Uy(Mb.N)](t['id'],structuredClone(t)),{};},'upsert')};async['compareAndSwap'](N,S){const MN={N:0x256,S:0x214,F:0x256,H:0x223},UX=Ue,F=this[UX(MN.N)][UX(MN.S)](S['id']);return ie(F,N)?(this[UX(MN.F)][UX(0x260)](S['id'],structuredClone(S)),'ok'):UX(MN.H);}['item'](N,S){const MR={N:0x256},MS={N:0x261,S:0x22a},UL=Ue;return{'read':c(async()=>{const UI=D,F=this[UI(0x256)][UI(0x214)](N);if(!F||F['id']!==S)throw Object[UI(MS.N)](new Error(UI(MS.S)),{'code':0x194});return{'resource':structuredClone(F)};},UL(0x1de)),'delete':c(async()=>{const Ur=UL,F=this[Ur(MR.N)]['get'](N);if(!F||F['id']!==S)throw Object['assign'](new Error('Not\x20found'),{'code':0x194});return this['documents']['delete'](N),{};},UL(0x258))};}}function V(N){const MF={N:0x222,S:0x1f3,F:0x1ed},M0=Ue;if(!N||typeof N!=M0(MF.N))return!0x1;const S=N;return S[M0(MF.S)]===0x194||S[M0(MF.F)]===0x194;}c(V,Ue(0x20f));function j(N=process.env.SESSION_TURN_LEASE_MS){const Mp={N:0x26a},M1=Ue,S=Number(N??M1(0x1ce));return Number[M1(Mp.N)](S)&&S>0x0?S:0xea60;}c(j,Ue(0x224));function m(N){return N?.['revision']??0x0;}c(m,Ue(0x269));function G(N,S=Date['now']()){const MW={N:0x25d,S:0x24c,F:0x26a},M2=Ue;if(!N?.[M2(MW.N)]||!N[M2(0x1e6)])return!0x1;const F=Date[M2(MW.S)](N[M2(0x1e6)]);return Number[M2(MW.F)](F)&&F>S;}function D(U,T){U=U-0x1cd;const C=M();let c=C[U];if(D['lWoyLP']===undefined){var A=function(g){const f='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let x='',u='';for(let v=0x0,G,V,e=0x0;V=g['charAt'](e++);~V&&(G=v%0x4?G*0x40+V:V,v++%0x4)?x+=String['fromCharCode'](0xff&G>>(-0x2*v&0x6)):0x0){V=f['indexOf'](V);}for(let O=0x0,d=x['length'];O<d;O++){u+='%'+('00'+x['charCodeAt'](O)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(u);};D['SPeVhq']=A,D['GnRdQF']={},D['lWoyLP']=!![];}const B=C[0x0],K=U+B,h=D['GnRdQF'][K];return!h?(c=D['SPeVhq'](c),D['GnRdQF'][K]=c):c=h,c;}function M(){const Mi=['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'];M=function(){return Mi;};return M();}c(G,Ue(0x1e8));function ie(N,S,F=Date[Ue(0x1f7)]()){const MH={N:0x23b,S:0x207,F:0x231},M3=Ue;return S['replaceIncompatible']?N!==void 0x0&&N[M3(0x203)]!==h:S[M3(0x1e2)]===null?N===void 0x0:!(!N||m(N)!==S['expectedRevision']||S[M3(0x23b)]&&N[M3(0x207)]?.[M3(0x25d)]!==S[M3(MH.N)]||S[M3(0x23a)]&&G(N[M3(MH.S)],F)&&N['turn']?.[M3(0x25d)]!==S[M3(MH.F)]);}c(ie,Ue(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,9 +19,9 @@ 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";
|
|
26
|
-
export { GRAPH_LLM_PROVIDERS, GRAPH_LLM_FAMILIES, GRAPH_LLM_CAPABILITIES, BUILT_IN_MODEL_CATALOG, GraphLlm, ModelCatalog, ModelProviderRegistry, type BuiltInGraphLlmConfig, type BuiltInModelId, type BuiltInModelParameters, type CommonModelParameters, type GraphLlmConfig, type GraphLlmConfigOverride, type GraphLlmCapability, type GraphLlmFamily, type GraphLlmModelMetadata, type GraphLlmParameters, type GraphLlmProvider, type GraphLlmRequiredCapabilities, type ModelCatalogDocument, type ModelParameterProfile, type ModelProviderAdapter, type ModelProviderInitialization, type RuntimeGraphLlmConfig, } from "../../src/framework/graph-llm.config.js";
|
|
26
|
+
export { GRAPH_LLM_PROVIDERS, GRAPH_LLM_FAMILIES, GRAPH_LLM_CAPABILITIES, BUILT_IN_MODEL_CATALOG, GraphLlm, ModelCatalog, ModelProviderRegistry, type BuiltInGraphLlmConfig, type BuiltInModelId, type BuiltInModelParameters, type CommonModelParameters, type GraphLlmConfig, type GraphLlmConfigOverride, type GraphLlmCapability, type GraphLlmFamily, type GraphLlmModelMetadata, type GraphLlmParameters, type GraphLlmProvider, type GraphLlmRequiredCapabilities, type ModelCatalogDocument, type ModelParameterProfile, type ModelProviderAdapter, type ModelProviderInitialization, type OpenAIAuthReasoningParameters, type RuntimeGraphLlmConfig, } from "../../src/framework/graph-llm.config.js";
|
|
27
27
|
export { addTokenUsage, emptyTokenUsage, modelExecution, normalizeTokenUsage, tokenUsageFromMessage, type ModelExecution, type ModelResult, type TokenUsage, } from "../../src/framework/token-usage.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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ModelProfile } from '@langchain/core/language_models/profile';
|
|
2
2
|
import { type GraphLlmConfig, type GraphLlmFamily, type GraphLlmParameters } from './model-catalog.js';
|
|
3
|
-
export { BUILT_IN_MODEL_CATALOG, GRAPH_LLM_CAPABILITIES, GRAPH_LLM_FAMILIES, GRAPH_LLM_PROVIDERS, ModelCatalog, ModelProviderRegistry, type AnthropicChatParameters, type AnthropicThinkingParameters, type BasicChatParameters, type BuiltInGraphLlmConfig, type BuiltInModelId, type BuiltInModelParameters, type CommonModelParameters, type GoogleChatParameters, type GraphLlmCapability, type GraphLlmConfig, type GraphLlmFamily, type GraphLlmParameters, type GraphLlmProvider, type GraphLlmRequiredCapabilities, type ModelCatalogDocument, type ModelParameterProfile, type ModelProviderAdapter, type ModelProviderInitialization, type OpenAIChatParameters, type OpenAIReasoningParameters, type ResolvedModelDescriptor, type RuntimeGraphLlmConfig, } from './model-catalog.js';
|
|
3
|
+
export { BUILT_IN_MODEL_CATALOG, GRAPH_LLM_CAPABILITIES, GRAPH_LLM_FAMILIES, GRAPH_LLM_PROVIDERS, ModelCatalog, ModelProviderRegistry, type AnthropicChatParameters, type AnthropicThinkingParameters, type BasicChatParameters, type BuiltInGraphLlmConfig, type BuiltInModelId, type BuiltInModelParameters, type CommonModelParameters, type GoogleChatParameters, type GraphLlmCapability, type GraphLlmConfig, type GraphLlmFamily, type GraphLlmParameters, type GraphLlmProvider, type GraphLlmRequiredCapabilities, type ModelCatalogDocument, type ModelParameterProfile, type ModelProviderAdapter, type ModelProviderInitialization, type OpenAIAuthReasoningParameters, type OpenAIChatParameters, type OpenAIReasoningParameters, type ResolvedModelDescriptor, type RuntimeGraphLlmConfig, } from './model-catalog.js';
|
|
4
4
|
export type GraphLlmConfigOverride = GraphLlmConfig | Readonly<{
|
|
5
5
|
model?: never;
|
|
6
6
|
params?: Readonly<Record<string, unknown | 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
|
}>;
|