@hugex/ai 2.8.15 → 2.9.4

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.
Files changed (89) hide show
  1. package/dist/chunk-3TXHFKDN.js +1 -0
  2. package/dist/{chunk-TUI5H3ZB.js → chunk-G3SGJ7XJ.js} +1 -1
  3. package/dist/chunk-R6EKV3WR.js +1 -0
  4. package/dist/{chunk-43NDF544.js → chunk-RYHQGPX5.js} +1 -1
  5. package/dist/client/hooks/useAgent.d.ts +31 -0
  6. package/dist/client/states/agent-store.d.ts +95 -0
  7. package/dist/client.d.ts +4 -129
  8. package/dist/client.js +1 -1
  9. package/dist/common/constants/ai-models.d.ts +10 -0
  10. package/dist/common/constants/tools-registry.d.ts +8 -0
  11. package/dist/common/types/agent-types.d.ts +61 -0
  12. package/dist/common/types/ai-models-types.d.ts +94 -0
  13. package/dist/common/types/memory-types.d.ts +28 -0
  14. package/dist/common/types/node-types.d.ts +9 -0
  15. package/dist/common/types/user-types.d.ts +11 -0
  16. package/dist/common/types/var-mapping.d.ts +29 -0
  17. package/dist/common/types/ws-message.d.ts +58 -0
  18. package/dist/common/utils/agent-utils.d.ts +0 -0
  19. package/dist/common/utils/generationParams.d.ts +19 -0
  20. package/dist/common/utils/logc.d.ts +17 -0
  21. package/dist/common/utils/reasoning.d.ts +32 -0
  22. package/dist/common/utils/templateUtils.d.ts +7 -0
  23. package/dist/common.d.ts +12 -362
  24. package/dist/common.js +1 -1
  25. package/dist/{composioTool-EXCSM6F4.js → composioTool-TVURCFXP.js} +1 -1
  26. package/dist/convertTempMessure-5CAGRLBY.js +1 -0
  27. package/dist/{httpTool-EU63HPF5.js → httpTool-NTDDXZZE.js} +1 -1
  28. package/dist/index.d.ts +27 -431
  29. package/dist/index.js +13 -13
  30. package/dist/{oraApi-3JWDQQUE.js → oraApi-YIJGMXX7.js} +1 -1
  31. package/dist/{recall-SD6FENAS.js → recall-IABRCSHY.js} +1 -1
  32. package/dist/server/api/agents.d.ts +1 -0
  33. package/dist/server/api/auth.d.ts +1 -0
  34. package/dist/server/api/commons.d.ts +1 -0
  35. package/dist/server/api/composio.d.ts +1 -0
  36. package/dist/server/api/instances.d.ts +1 -0
  37. package/dist/server/core/AgentDO.d.ts +80 -0
  38. package/dist/server/core/AgentHTTP.d.ts +2 -0
  39. package/dist/server/logic/FlowEngine.d.ts +38 -0
  40. package/dist/server/logic/llm/files.d.ts +2 -0
  41. package/dist/server/logic/llm/images.d.ts +5 -0
  42. package/dist/server/logic/serverMessages.d.ts +13 -0
  43. package/dist/server/runners/answerNodeRunner.d.ts +4 -0
  44. package/dist/server/runners/apiNodeRunner.d.ts +4 -0
  45. package/dist/server/runners/classifierNodeRunner.d.ts +6 -0
  46. package/dist/server/runners/llmNodeRunner.d.ts +6 -0
  47. package/dist/server/runners/memoNodeRunner.d.ts +4 -0
  48. package/dist/server/runners/startNodeRunner.d.ts +4 -0
  49. package/dist/server/sql/agentSQL.d.ts +24 -0
  50. package/dist/server/tools/composioTool.d.ts +4 -0
  51. package/dist/server/tools/convertTempMessure.d.ts +15 -0
  52. package/dist/server/tools/httpTool.d.ts +18 -0
  53. package/dist/server/tools/recall.d.ts +7 -0
  54. package/dist/server/tools/skillTool.d.ts +6 -0
  55. package/dist/server/tools/tempTool.d.ts +4 -0
  56. package/dist/server/tools/twitter.d.ts +5 -0
  57. package/dist/server/tools/vectorize.d.ts +6 -0
  58. package/dist/server/types/node.d.ts +25 -0
  59. package/dist/server/utils/apiUtils.d.ts +14 -0
  60. package/dist/server/utils/auth.d.ts +3 -0
  61. package/dist/server/utils/composio.d.ts +114 -0
  62. package/dist/server/utils/contextMemory.d.ts +25 -0
  63. package/dist/server/utils/cookies.d.ts +1 -0
  64. package/dist/server/utils/coreApi.d.ts +7 -0
  65. package/dist/server/utils/embeddings.d.ts +3 -0
  66. package/dist/server/utils/flowRefresh.d.ts +22 -0
  67. package/dist/server/utils/flowValidation.d.ts +2 -0
  68. package/dist/server/utils/jsonSchemaToZod.d.ts +12 -0
  69. package/dist/server/utils/modelProvider.d.ts +20 -0
  70. package/dist/server/utils/oraApi.d.ts +6 -0
  71. package/dist/server/utils/oraExtract.d.ts +11 -0
  72. package/dist/server/utils/secrets.d.ts +2 -0
  73. package/dist/server/utils/secretsRefs.d.ts +6 -0
  74. package/dist/server/utils/sessionEnvMemory.d.ts +12 -0
  75. package/dist/server/utils/sessionIndex.d.ts +16 -0
  76. package/dist/server/utils/telemetry.d.ts +10 -0
  77. package/dist/server/utils/templateUtils.d.ts +7 -0
  78. package/dist/{skillTool-Y5GZ4ZAR.js → skillTool-BSQFKZGK.js} +1 -1
  79. package/dist/tempTool-2RXAF56M.js +1 -0
  80. package/dist/{twitter-QNCTAE4E.js → twitter-OMDEG7T2.js} +1 -1
  81. package/dist/vectorize-UJXIDL2E.js +1 -0
  82. package/package.json +19 -19
  83. package/dist/chunk-2JN3IX2Y.js +0 -1
  84. package/dist/chunk-6BYZCJPP.js +0 -1
  85. package/dist/convertTempMessure-TT7DIP6C.js +0 -1
  86. package/dist/magic-string.es-S3C7UPCH.js +0 -13
  87. package/dist/skillTool.test-6UDHQARG.js +0 -190
  88. package/dist/tempTool-6Q6C4HEJ.js +0 -1
  89. package/dist/vectorize-SQROWLSU.js +0 -1
@@ -0,0 +1 @@
1
+ var d=c=>a=>{var b=c[a];if(b)return b();throw new Error("Module not found in bundle: "+a)};export{d as a};
@@ -1 +1 @@
1
- import{tool as x}from"ai";import{z as p}from"zod";async function T(t,o){let r=await fetch(`${o.HX_CORE_URL}/ora/flow/${t}`,{method:"GET",headers:{Authorization:`${o.HX_API_KEY}`},cache:"no-store"});if(!r.ok)throw new Error("Failed to fetch flow KV");return r.json()}async function D(t,o){let r=await fetch(`${o.HX_CORE_URL}/ora/flow/${t}/state`,{method:"GET",headers:{Authorization:`${o.HX_API_KEY}`},cache:"no-store"});if(!r.ok)throw new Error("Failed to fetch flow state");return r.json()}async function A(t,o){let r=await fetch(`${o.HX_CORE_URL}/ora/vectorize/get`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`${o.HX_API_KEY}`},body:JSON.stringify({hashes:t})});if(!r.ok)throw new Error("Failed to fetch embeddings from cache");return r.json()}async function P(t,o){let r=await fetch(`${o.HX_CORE_URL}/ora/vectorize/put`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`${o.HX_API_KEY}`},body:JSON.stringify({items:t})});if(!r.ok)throw new Error("Failed to store embeddings in cache");return r.json()}var S=async t=>{let o=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(o)).map(r=>r.toString(16).padStart(2,"0")).join("")},_=async(t,o,r=!1)=>{var f,b,w,y;let i=Array.isArray(o)?o:[o],c=await Promise.all(i.map(e=>S(e))),s=!!((f=t==null?void 0:t.env)!=null&&f.HX_CORE_URL)&&!!((b=t==null?void 0:t.env)!=null&&b.HX_API_KEY);console.log("Debug: KV cache API available:",s);let l=[],n=[];if(s){console.log("Debug: Attempting to get embeddings from KV cache via API");try{l=await A(c,t.env)}catch(e){console.warn("Failed to fetch from KV cache API",e),l=c.map(()=>null)}n=l.map((e,a)=>e===null?a:-1).filter(e=>e!==-1),console.log("Debug: Cached embeddings found:",l.filter(e=>e!==null).length,"missing:",n.length)}else console.log("Debug: KV cache API not available, skipping cache lookup"),n=i.map((e,a)=>a);if(n.length===0)return console.log("Debug: All embeddings retrieved from cache"),{data:l};let d=n.map(e=>i[e]),g,h;console.log("Debug: Generating embeddings for missing texts, count:",d.length);for(let e=0;e<3;e++)try{console.log("Debug: Primary embedding generation attempt",e+1);let a=new Promise((E,$)=>setTimeout(()=>$(new Error("Timeout after 2 seconds")),2e3)),u=(w=t==null?void 0:t.env)==null?void 0:w.AI.run("@cf/baai/bge-m3",{text:d});g=await Promise.race([u,a]),console.log("Debug: Primary embedding generation successful on attempt",e+1);break}catch(a){if(console.warn(`Primary embedding attempt ${e+1} failed:`,a),h=a,e===2)break}if(!g){if(!r)throw h;console.warn("Falling back to Ollama");try{let e=await fetch(`${(y=t==null?void 0:t.env)==null?void 0:y.OLLAMA_BASE_URL}/api/embed`,{method:"POST",headers:{"Content-Type":"application/json",Cookie:"hxsecure=1"},body:JSON.stringify({model:"bge-m3:latest",input:d})});if(!e.ok)throw new Error(`Ollama API error: ${e.statusText}`);let a=await e.json();console.log("Embedding response data:",a.embeddings.length),g={data:a.embeddings},console.log("Debug: Fallback embedding generation successful")}catch(e){throw console.error("Both embedding methods failed:",e),e}}if(s&&n.length>0){console.log("Debug: Storing new embeddings in KV cache via API");let e=n.map((a,u)=>({hash:c[a],embedding:g.data[u]}));try{await P(e,t.env)}catch(a){console.warn("Failed to store in KV cache API",a)}}else console.log("Debug: Skipping cache storage as KV API not available or no new embeddings");let m=l.slice();for(let e=0;e<n.length;e++)m[n[e]]=g.data[e];return console.log("Debug: Embedding generation complete, total embeddings:",m.length),{data:m}};function V(t,o,r){return x({description:"Perform semantic vector search on memo data with optional static parameters. Returns relevant matches with scores and metadata.",inputSchema:p.object({query:p.string().min(1).describe("The search query to vectorize and search for"),topK:p.number().optional().default(5).describe("Number of top results to return (overrides static params if provided)")}),execute:async({query:i,topK:c=3})=>{var l;let s=r==null?void 0:r.namespace;if(!s)return{results:[]};if(`${i}${s}${c}`,!i||typeof i!="string"||i.trim()==="")return{results:[]};try{let n=await _(t,i,!0),d=await t.env[`VDB_${(l=o.flowData)==null?void 0:l.tenant}_1024`].query(n.data[0],{namespace:s,topK:c,returnMetadata:"all"}),h=(Array.isArray(d.matches)?d.matches:[]).map(m=>{var f;return(f=m.metadata)==null?void 0:f.value}).filter(m=>typeof m=="string");return`${i}${s}${c}${h.length}`,{query:i,topK:c,matches:h}}catch(n){return`${i}${s}${c}${n}`,{results:[]}}}})}export{T as a,D as b,S as c,_ as d,V as e};
1
+ import{tool as T}from"ai";import{z as p}from"zod";async function E(t,o){let r=await fetch(`${o.HX_CORE_URL}/ora/flow/${t}`,{method:"GET",headers:{Authorization:`${o.HX_API_KEY}`},cache:"no-store"});if(!r.ok)throw new Error("Failed to fetch flow KV");return r.json()}async function D(t,o){let r=await fetch(`${o.HX_CORE_URL}/ora/flow/${t}/state`,{method:"GET",headers:{Authorization:`${o.HX_API_KEY}`},cache:"no-store"});if(!r.ok)throw new Error("Failed to fetch flow state");return r.json()}async function A(t,o){let r=await fetch(`${o.HX_CORE_URL}/ora/vectorize/get`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`${o.HX_API_KEY}`},body:JSON.stringify({hashes:t})});if(!r.ok)throw new Error("Failed to fetch embeddings from cache");return r.json()}async function P(t,o){let r=await fetch(`${o.HX_CORE_URL}/ora/vectorize/put`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`${o.HX_API_KEY}`},body:JSON.stringify({items:t})});if(!r.ok)throw new Error("Failed to store embeddings in cache");return r.json()}var S=async t=>{let o=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(o)).map(r=>r.toString(16).padStart(2,"0")).join("")},_=async(t,o,r=!1)=>{var f,b,w,y;let i=Array.isArray(o)?o:[o],c=await Promise.all(i.map(e=>S(e))),s=!!((f=t==null?void 0:t.env)!=null&&f.HX_CORE_URL)&&!!((b=t==null?void 0:t.env)!=null&&b.HX_API_KEY);console.log("Debug: KV cache API available:",s);let l=[],n=[];if(s){console.log("Debug: Attempting to get embeddings from KV cache via API");try{l=await A(c,t.env)}catch(e){console.warn("Failed to fetch from KV cache API",e),l=c.map(()=>null)}n=l.map((e,a)=>e===null?a:-1).filter(e=>e!==-1),console.log("Debug: Cached embeddings found:",l.filter(e=>e!==null).length,"missing:",n.length)}else console.log("Debug: KV cache API not available, skipping cache lookup"),n=i.map((e,a)=>a);if(n.length===0)return console.log("Debug: All embeddings retrieved from cache"),{data:l};let d=n.map(e=>i[e]),g,h;console.log("Debug: Generating embeddings for missing texts, count:",d.length);for(let e=0;e<3;e++)try{console.log("Debug: Primary embedding generation attempt",e+1);let a=new Promise((x,$)=>setTimeout(()=>$(new Error("Timeout after 2 seconds")),2e3)),u=(w=t==null?void 0:t.env)==null?void 0:w.AI.run("@cf/baai/bge-m3",{text:d});g=await Promise.race([u,a]),console.log("Debug: Primary embedding generation successful on attempt",e+1);break}catch(a){if(console.warn(`Primary embedding attempt ${e+1} failed:`,a),h=a,e===2)break}if(!g){if(!r)throw h;console.warn("Falling back to Ollama");try{let e=await fetch(`${(y=t==null?void 0:t.env)==null?void 0:y.OLLAMA_BASE_URL}/api/embed`,{method:"POST",headers:{"Content-Type":"application/json",Cookie:"hxsecure=1"},body:JSON.stringify({model:"bge-m3:latest",input:d})});if(!e.ok)throw new Error(`Ollama API error: ${e.statusText}`);let a=await e.json();console.log("Embedding response data:",a.embeddings.length),g={data:a.embeddings},console.log("Debug: Fallback embedding generation successful")}catch(e){throw console.error("Both embedding methods failed:",e),e}}if(s&&n.length>0){console.log("Debug: Storing new embeddings in KV cache via API");let e=n.map((a,u)=>({hash:c[a],embedding:g.data[u]}));try{await P(e,t.env)}catch(a){console.warn("Failed to store in KV cache API",a)}}else console.log("Debug: Skipping cache storage as KV API not available or no new embeddings");let m=l.slice();for(let e=0;e<n.length;e++)m[n[e]]=g.data[e];return console.log("Debug: Embedding generation complete, total embeddings:",m.length),{data:m}};function V(t,o,r){return T({description:"Perform semantic vector search on memo data with optional static parameters. Returns relevant matches with scores and metadata.",inputSchema:p.object({query:p.string().min(1).describe("The search query to vectorize and search for"),topK:p.number().optional().default(5).describe("Number of top results to return (overrides static params if provided)")}),execute:async({query:i,topK:c=3})=>{var l;let s=r==null?void 0:r.namespace;if(!s)return{results:[]};if(`${i}${s}${c}`,!i||typeof i!="string"||i.trim()==="")return{results:[]};try{let n=await _(t,i,!0),d=await t.env[`VDB_${(l=o.flowData)==null?void 0:l.tenant}_1024`].query(n.data[0],{namespace:s,topK:c,returnMetadata:"all"}),h=(Array.isArray(d.matches)?d.matches:[]).map(m=>{var f;return(f=m.metadata)==null?void 0:f.value}).filter(m=>typeof m=="string");return`${i}${s}${c}${h.length}`,{query:i,topK:c,matches:h}}catch(n){return`${i}${s}${c}${n}`,{results:[]}}}})}export{E as a,D as b,S as c,_ as d,V as e};
@@ -0,0 +1 @@
1
+ import{tool as t}from"ai";import{z as o}from"zod";var p=(n,i,r,a)=>t({description:"Get the weather in a location (in Celsius)",inputSchema:o.object({location:o.string().describe("The location to get the weather for")}),execute:async({location:e})=>(`${e}`,{location:e,temperature:Math.floor(Math.random()*21)})});export{p as a};
@@ -1 +1 @@
1
- import{tool as m}from"ai";import{z as u}from"zod";function F(p,v,n,d){let o=e=>{let t=e.toLowerCase().replace("\xB0","").replace("kelvin","k");if(t==="c"||t==="celsius")return"C";if(t==="f"||t==="fahrenheit")return"F";if(t==="k"||t==="kelvin")return"K";throw new Error(`Invalid temperature unit: ${e}. Supported units: C/\xB0C/Celsius, F/\xB0F/Fahrenheit, K/Kelvin`)},l=(e,t,a)=>{let i=o(t),s=o(a),r;switch(i){case"C":r=e;break;case"F":r=(e-32)*5/9;break;case"K":r=e-273.15;break;default:throw new Error(`Unsupported source unit: ${t}`)}switch(s){case"C":return r;case"F":return r*9/5+32;case"K":return r+273.15;default:throw new Error(`Unsupported target unit: ${a}`)}};return m({description:"Convert temperature between Celsius, Fahrenheit, and Kelvin with optional static parameters. Always prioritizes output results over input.",inputSchema:u.object({temperature:u.number().describe("Temperature value to convert"),source:u.string().optional().describe("Source temperature unit (C/\xB0C/Celsius, F/\xB0F/Fahrenheit, K/Kelvin). Overrides static params if provided."),target:u.string().optional().describe("Target temperature unit (C/\xB0C/Celsius, F/\xB0F/Fahrenheit, K/Kelvin). Overrides static params if provided.")}),execute:async({temperature:e,source:t,target:a})=>{let i=(n==null?void 0:n.source)||t||"C",s=(n==null?void 0:n.target)||a||"F";if(`${e}${i}${s}`,typeof e!="number"||!Number.isFinite(e))throw new Error(`Invalid temperature value: ${e}. Must be a finite number.`);try{let r=l(e,i,s),g=o(i),c=o(s);return{input:{temperature:e,source:g,target:c},output:{value:Number(r.toFixed(2)),unit:c,important:"If source and target is different from your input, is because it is being force by defaults settings."}}}catch(r){throw new Error(`Conversion failed: ${r instanceof Error?r.message:String(r)}`)}}})}export{F as a};
1
+ import{tool as m}from"ai";import{z as u}from"zod";function F(p,v,n,d){let s=e=>{let t=e.toLowerCase().replace("\xB0","").replace("kelvin","k");if(t==="c"||t==="celsius")return"C";if(t==="f"||t==="fahrenheit")return"F";if(t==="k"||t==="kelvin")return"K";throw new Error(`Invalid temperature unit: ${e}. Supported units: C/\xB0C/Celsius, F/\xB0F/Fahrenheit, K/Kelvin`)},l=(e,t,a)=>{let i=s(t),o=s(a),r;switch(i){case"C":r=e;break;case"F":r=(e-32)*5/9;break;case"K":r=e-273.15;break;default:throw new Error(`Unsupported source unit: ${t}`)}switch(o){case"C":return r;case"F":return r*9/5+32;case"K":return r+273.15;default:throw new Error(`Unsupported target unit: ${a}`)}};return m({description:"Convert temperature between Celsius, Fahrenheit, and Kelvin with optional static parameters. Always prioritizes output results over input.",inputSchema:u.object({temperature:u.number().describe("Temperature value to convert"),source:u.string().optional().describe("Source temperature unit (C/\xB0C/Celsius, F/\xB0F/Fahrenheit, K/Kelvin). Overrides static params if provided."),target:u.string().optional().describe("Target temperature unit (C/\xB0C/Celsius, F/\xB0F/Fahrenheit, K/Kelvin). Overrides static params if provided.")}),execute:async({temperature:e,source:t,target:a})=>{let i=(n==null?void 0:n.source)||t||"C",o=(n==null?void 0:n.target)||a||"F";if(`${e}${i}${o}`,typeof e!="number"||!Number.isFinite(e))throw new Error(`Invalid temperature value: ${e}. Must be a finite number.`);try{let r=l(e,i,o),g=s(i),c=s(o);return{input:{temperature:e,source:g,target:c},output:{value:Number(r.toFixed(2)),unit:c,important:"If source and target is different from your input, is because it is being force by defaults settings."}}}catch(r){throw new Error(`Conversion failed: ${r instanceof Error?r.message:String(r)}`)}}})}export{F as a};
@@ -0,0 +1,31 @@
1
+ import { type AgentStoreApi } from '../states/agent-store';
2
+ type QueryObject = Record<string, string | null>;
3
+ export declare function useAgent(opts?: {
4
+ host?: string;
5
+ basePath?: string;
6
+ agent?: string;
7
+ name?: string;
8
+ query?: QueryObject | (() => Promise<QueryObject>);
9
+ /** Optional client-supplied session identity (fallback when no JWT user). Sent on connect via `UID`. */
10
+ user?: string;
11
+ storeKey?: string;
12
+ }): {
13
+ connection: any;
14
+ store: AgentStoreApi;
15
+ send: (text: string, images?: {
16
+ mimeType: string;
17
+ data: string;
18
+ }[], documents?: {
19
+ name: string;
20
+ mimeType: string;
21
+ data: string;
22
+ }[]) => void;
23
+ clearHistory: () => void;
24
+ sendAuth: (name: string, value: string) => void;
25
+ setIdentity: (userId: string) => void;
26
+ toggleEventsVisible: () => void;
27
+ clearEvents: () => void;
28
+ approve: (toolCallId: string) => void;
29
+ reject: (toolCallId: string) => void;
30
+ };
31
+ export {};
@@ -0,0 +1,95 @@
1
+ import type { ApprovalRequestPayload, EventItem, FlowConfig, Message, StepInfo, TypingMessage } from '../../common/types/agent-types';
2
+ export interface AgentState {
3
+ messages: Message[];
4
+ events: EventItem[];
5
+ eventsVisible: boolean;
6
+ status: 'connecting' | 'connected' | 'disconnected';
7
+ typingMessage: TypingMessage;
8
+ reasoningMessage: TypingMessage;
9
+ isReasoning: boolean;
10
+ stepInfo: StepInfo;
11
+ approvals: Array<{
12
+ id: string;
13
+ toolCallId: string;
14
+ toolName: string;
15
+ args: Record<string, unknown>;
16
+ description: string;
17
+ ts: number;
18
+ status: 'pending' | 'approved' | 'rejected';
19
+ }>;
20
+ error: string | null;
21
+ flowConfig: FlowConfig | null;
22
+ composioAuth: ComposioAuthRequest | null;
23
+ }
24
+ export interface ComposioAuthRequest {
25
+ toolkit?: string;
26
+ redirectUrl: string;
27
+ toolRowId?: string;
28
+ }
29
+ export interface AgentActions {
30
+ initHistory: (messages: Message[]) => void;
31
+ addEvent: (event: EventItem) => void;
32
+ clearEvents: () => void;
33
+ setMessages: (messages: Message[]) => void;
34
+ addMessage: (message: Message) => void;
35
+ setTyping: (typing: TypingMessage) => void;
36
+ appendTyping: (id: string, chunk: string) => void;
37
+ clearTyping: () => void;
38
+ setReasoning: (reasoning: TypingMessage) => void;
39
+ appendReasoning: (id: string, chunk: string) => void;
40
+ clearReasoning: () => void;
41
+ setReasoningActive: (active: boolean) => void;
42
+ setStep: (step: StepInfo) => void;
43
+ clearStep: () => void;
44
+ setStatus: (status: AgentState['status']) => void;
45
+ toggleEvents: () => void;
46
+ clearHistory: () => void;
47
+ addApprovalRequest: (payload: ApprovalRequestPayload) => void;
48
+ updateApprovalStatus: (payload: {
49
+ toolCallId: string;
50
+ status: 'approved' | 'rejected';
51
+ }) => void;
52
+ removeApproval: (toolCallId: string) => void;
53
+ setError: (error: string | null) => void;
54
+ setFlowConfig: (config: FlowConfig | null) => void;
55
+ setComposioAuth: (request: ComposioAuthRequest | null) => void;
56
+ clearComposioAuth: () => void;
57
+ }
58
+ export type AgentStore = AgentState & AgentActions;
59
+ declare function createAgentStoreImpl(devtoolsName: string): import("node_modules/zustand/esm/react.mjs").UseBoundStore<Omit<import("node_modules/zustand/esm/vanilla.mjs").StoreApi<AgentStore>, "devtools" | "setState"> & {
60
+ setState(partial: Partial<AgentStore> | ((state: AgentStore) => Partial<AgentStore> | AgentStore) | AgentStore, replace?: false | undefined, action?: (string | {
61
+ [x: string]: unknown;
62
+ [x: number]: unknown;
63
+ [x: symbol]: unknown;
64
+ type: string;
65
+ }) | undefined): void;
66
+ setState(state: ((state: AgentStore) => AgentStore) | AgentStore, replace: true, action?: (string | {
67
+ [x: string]: unknown;
68
+ [x: number]: unknown;
69
+ [x: symbol]: unknown;
70
+ type: string;
71
+ }) | undefined): void;
72
+ devtools: {
73
+ cleanup: () => void;
74
+ };
75
+ }>;
76
+ export type AgentStoreApi = ReturnType<typeof createAgentStoreImpl>;
77
+ export declare const useAgentStore: import("node_modules/zustand/esm/react.mjs").UseBoundStore<Omit<import("node_modules/zustand/esm/vanilla.mjs").StoreApi<AgentStore>, "devtools" | "setState"> & {
78
+ setState(partial: Partial<AgentStore> | ((state: AgentStore) => Partial<AgentStore> | AgentStore) | AgentStore, replace?: false | undefined, action?: (string | {
79
+ [x: string]: unknown;
80
+ [x: number]: unknown;
81
+ [x: symbol]: unknown;
82
+ type: string;
83
+ }) | undefined): void;
84
+ setState(state: ((state: AgentStore) => AgentStore) | AgentStore, replace: true, action?: (string | {
85
+ [x: string]: unknown;
86
+ [x: number]: unknown;
87
+ [x: symbol]: unknown;
88
+ type: string;
89
+ }) | undefined): void;
90
+ devtools: {
91
+ cleanup: () => void;
92
+ };
93
+ }>;
94
+ export declare function getAgentStore(key?: string): AgentStoreApi;
95
+ export {};
package/dist/client.d.ts CHANGED
@@ -1,129 +1,4 @@
1
- import * as zustand from 'zustand';
2
- import { Message, EventItem, TypingMessage, StepInfo, FlowConfig, ApprovalRequestPayload } from './common.js';
3
- export { Capabilities, ChatHistoryItem, EffectiveParams, FlowNode, GENERATION_PARAM_KEYS, GENERATION_PRESETS, GenerationParamKey, GenerationPresetId, MAX_USER_IDENTITY_LENGTH, MODEL_REGISTRY_SNAPSHOT, MessageType, ModelEntry, ModelRegistrySnapshot, NODETYPES, NodeType, OutVar, PRESET_PARAM_KEYS, ParamAdjustment, ParamRange, ParamSupport, REASONING_EFFORT_LEVELS, ReasoningCapability, ReasoningEffortLevel, ResolveInput, ResolveOptions, ResolvedModel, TOOL_REGISTRY_SNAPSHOT, ToolExecutionResultPayload, UserAuthPayload, UserInterface, UserMessagePayload, VariableMapping, WsClientMessage, WsClientMessageType, WsComplete, WsError, WsHistory, WsMessage, WsServerMessage, WsServerMessageType, applyPresetToOverrides, buildReasoningProviderOptions, deriveParamSupport, getDefaultOutVars, getEffectiveOutVars, getModelEntry, logc, messageTypes, normalizeEffectiveParams, normalizeReasoning, openAiReasoningParamSupport, openAiStandardParamSupport, parseUserAuth, parseUserMessage, pickNodeOverrides, reasoningEffortLevels, reasoningExposable, resolveOutVarRef, resolvePreset, resolveReasoningEffort, resolveTemplate, sanitizeUserIdentity, stripUnsupportedFromNodeData, toStreamTextSettings, walkPath, workersAiParamSupport, wsDebug, xaiParamSupport } from './common.js';
4
-
5
- interface AgentState {
6
- messages: Message[];
7
- events: EventItem[];
8
- eventsVisible: boolean;
9
- status: 'connecting' | 'connected' | 'disconnected';
10
- typingMessage: TypingMessage;
11
- reasoningMessage: TypingMessage;
12
- isReasoning: boolean;
13
- stepInfo: StepInfo;
14
- approvals: Array<{
15
- id: string;
16
- toolCallId: string;
17
- toolName: string;
18
- args: Record<string, unknown>;
19
- description: string;
20
- ts: number;
21
- status: 'pending' | 'approved' | 'rejected';
22
- }>;
23
- error: string | null;
24
- flowConfig: FlowConfig | null;
25
- composioAuth: ComposioAuthRequest | null;
26
- }
27
- interface ComposioAuthRequest {
28
- toolkit?: string;
29
- redirectUrl: string;
30
- toolRowId?: string;
31
- }
32
- interface AgentActions {
33
- initHistory: (messages: Message[]) => void;
34
- addEvent: (event: EventItem) => void;
35
- clearEvents: () => void;
36
- setMessages: (messages: Message[]) => void;
37
- addMessage: (message: Message) => void;
38
- setTyping: (typing: TypingMessage) => void;
39
- appendTyping: (id: string, chunk: string) => void;
40
- clearTyping: () => void;
41
- setReasoning: (reasoning: TypingMessage) => void;
42
- appendReasoning: (id: string, chunk: string) => void;
43
- clearReasoning: () => void;
44
- setReasoningActive: (active: boolean) => void;
45
- setStep: (step: StepInfo) => void;
46
- clearStep: () => void;
47
- setStatus: (status: AgentState['status']) => void;
48
- toggleEvents: () => void;
49
- clearHistory: () => void;
50
- addApprovalRequest: (payload: ApprovalRequestPayload) => void;
51
- updateApprovalStatus: (payload: {
52
- toolCallId: string;
53
- status: 'approved' | 'rejected';
54
- }) => void;
55
- removeApproval: (toolCallId: string) => void;
56
- setError: (error: string | null) => void;
57
- setFlowConfig: (config: FlowConfig | null) => void;
58
- setComposioAuth: (request: ComposioAuthRequest | null) => void;
59
- clearComposioAuth: () => void;
60
- }
61
- type AgentStore = AgentState & AgentActions;
62
- declare function createAgentStoreImpl(devtoolsName: string): zustand.UseBoundStore<Omit<zustand.StoreApi<AgentStore>, "setState" | "devtools"> & {
63
- setState(partial: AgentStore | Partial<AgentStore> | ((state: AgentStore) => AgentStore | Partial<AgentStore>), replace?: false | undefined, action?: (string | {
64
- [x: string]: unknown;
65
- [x: number]: unknown;
66
- [x: symbol]: unknown;
67
- type: string;
68
- }) | undefined): void;
69
- setState(state: AgentStore | ((state: AgentStore) => AgentStore), replace: true, action?: (string | {
70
- [x: string]: unknown;
71
- [x: number]: unknown;
72
- [x: symbol]: unknown;
73
- type: string;
74
- }) | undefined): void;
75
- devtools: {
76
- cleanup: () => void;
77
- };
78
- }>;
79
- type AgentStoreApi = ReturnType<typeof createAgentStoreImpl>;
80
- declare const useAgentStore: zustand.UseBoundStore<Omit<zustand.StoreApi<AgentStore>, "setState" | "devtools"> & {
81
- setState(partial: AgentStore | Partial<AgentStore> | ((state: AgentStore) => AgentStore | Partial<AgentStore>), replace?: false | undefined, action?: (string | {
82
- [x: string]: unknown;
83
- [x: number]: unknown;
84
- [x: symbol]: unknown;
85
- type: string;
86
- }) | undefined): void;
87
- setState(state: AgentStore | ((state: AgentStore) => AgentStore), replace: true, action?: (string | {
88
- [x: string]: unknown;
89
- [x: number]: unknown;
90
- [x: symbol]: unknown;
91
- type: string;
92
- }) | undefined): void;
93
- devtools: {
94
- cleanup: () => void;
95
- };
96
- }>;
97
- declare function getAgentStore(key?: string): AgentStoreApi;
98
-
99
- type QueryObject = Record<string, string | null>;
100
- declare function useAgent(opts?: {
101
- host?: string;
102
- basePath?: string;
103
- agent?: string;
104
- name?: string;
105
- query?: QueryObject | (() => Promise<QueryObject>);
106
- /** Optional client-supplied session identity (fallback when no JWT user). Sent on connect via `UID`. */
107
- user?: string;
108
- storeKey?: string;
109
- }): {
110
- connection: any;
111
- store: AgentStoreApi;
112
- send: (text: string, images?: {
113
- mimeType: string;
114
- data: string;
115
- }[], documents?: {
116
- name: string;
117
- mimeType: string;
118
- data: string;
119
- }[]) => void;
120
- clearHistory: () => void;
121
- sendAuth: (name: string, value: string) => void;
122
- setIdentity: (userId: string) => void;
123
- toggleEventsVisible: () => void;
124
- clearEvents: () => void;
125
- approve: (toolCallId: string) => void;
126
- reject: (toolCallId: string) => void;
127
- };
128
-
129
- export { type AgentActions, type AgentState, type AgentStore, type AgentStoreApi, ApprovalRequestPayload, type ComposioAuthRequest, EventItem, FlowConfig, Message, StepInfo, TypingMessage, getAgentStore, useAgent, useAgentStore };
1
+ export * from './client/hooks/useAgent';
2
+ export * from './client/states/agent-store';
3
+ export * from './index.common';
4
+ export * from './common/utils/logc';
package/dist/client.js CHANGED
@@ -1 +1 @@
1
- import{a as d,b as G,c as E,d as $,e as L,f as Se,g as Ae,h as fe}from"./chunk-HAYNUZZB.js";import{a as J,b as Y,c as k,d as K,e as Q,f as X}from"./chunk-OYP6D5VN.js";import{a as z,b as B,c as W,d as Z,e as ee,f as te,g as ne,h as se,i as oe,j as re,k as ae,l as ie,m as ge,n as le,o as pe,p as ce,q as de,r as ue,s as ve,t as ye}from"./chunk-GRZ6ZRHM.js";import{a as P}from"./chunk-U56YWPSI.js";import"./chunk-6BYZCJPP.js";import{useAgent as H}from"agents/react";import{useCallback as u,useEffect as j,useMemo as U,useRef as S}from"react";import{create as q}from"zustand";import{devtools as V}from"zustand/middleware";var F={messages:[],events:[],eventsVisible:!1,status:"connecting",typingMessage:null,reasoningMessage:null,isReasoning:!1,stepInfo:null,approvals:[],error:null,flowConfig:null,composioAuth:null};function T(n){return q()(V((t,y)=>({...F,initHistory:e=>t({messages:e}),addEvent:e=>t(o=>({events:[...o.events,{...e,ts:Date.now()}]})),clearEvents:()=>t({events:[]}),setMessages:e=>{t({messages:e})},addMessage:e=>{t(o=>({messages:[...o.messages,e]}))},setTyping:e=>t({typingMessage:e}),appendTyping:(e,o)=>{let i=y().typingMessage;i&&i.id===e?t({typingMessage:{id:e,text:i.text+o}}):t({typingMessage:{id:e,text:o}})},clearTyping:()=>t({typingMessage:null}),setReasoning:e=>t({reasoningMessage:e}),appendReasoning:(e,o)=>{let i=y().reasoningMessage;i&&i.id===e?t({reasoningMessage:{id:e,text:i.text+o}}):t({reasoningMessage:{id:e,text:o}})},clearReasoning:()=>t({reasoningMessage:null,isReasoning:!1}),setReasoningActive:e=>t({isReasoning:e}),setStep:e=>t({stepInfo:e}),clearStep:()=>t({stepInfo:null}),setStatus:e=>t({status:e}),toggleEvents:()=>t(e=>({eventsVisible:!e.eventsVisible})),clearHistory:()=>t({messages:[],typingMessage:null,reasoningMessage:null,isReasoning:!1,stepInfo:null}),addApprovalRequest:e=>{let o={id:`approval-${Date.now()}-${Math.random()}`,toolCallId:e.toolCallId,toolName:e.toolName,args:e.args??{},description:e.description,ts:Date.now(),status:"pending"};t(i=>({approvals:[...i.approvals,o]}))},updateApprovalStatus:({toolCallId:e,status:o})=>{t(i=>({approvals:i.approvals.map(v=>v.toolCallId===e?{...v,status:o}:v)}))},removeApproval:e=>{t(o=>({approvals:o.approvals.filter(i=>i.toolCallId!==e)}))},setError:e=>t({error:e}),setFlowConfig:e=>t({flowConfig:e}),setComposioAuth:e=>t({composioAuth:e}),clearComposioAuth:()=>t({composioAuth:null})}),{name:n,enabled:!0}))}var D=T("agent-store"),M=new Map;function I(n){if(!n)return D;let t=M.get(n);return t||(t=T(`agent-store:${n}`),M.set(n,t)),t}function we(n){let t=U(()=>I(n==null?void 0:n.storeKey),[n==null?void 0:n.storeKey]),y=t(s=>s.typingMessage),e=S(null),o=S(null),i=S(null),v=S(null);j(()=>{e.current=y},[y]);let A=u(s=>{var g;let r=s.trim().slice(0,E);!r||typeof((g=v.current)==null?void 0:g.send)!="function"||v.current.send(d.USER_IDENTITY+":"+r)},[]),l=H({host:n==null?void 0:n.host,basePath:(n==null?void 0:n.basePath)??"/api/agents/base",agent:n==null?void 0:n.agent,name:n==null?void 0:n.name,query:n==null?void 0:n.query,onMessage:s=>{if(typeof s.data!="string")return;let[r,g]=s.data.split("::");if(!r||!g)return;let a=t.getState(),f={[d.SERVER_HISTORY]:p=>{let c=JSON.parse(p);a.setMessages(c.messages)},[d.SERVER_EVENT]:p=>{var R;let c=JSON.parse(p);if((c==null?void 0:c.type)==="info:composio:auth_required"&&((R=c==null?void 0:c.content)!=null&&R.redirectUrl)){let m=c.content;a.setComposioAuth({toolkit:m.toolkit,redirectUrl:m.redirectUrl,toolRowId:m.toolRowId})}a.addEvent({type:"server",...c})},[d.SERVER_ERROR]:p=>{a.setError(p),a.addEvent({type:"error",content:p})},[d.SERVER_TEXT_STREAM]:p=>{o.current?a.appendTyping(o.current,p):(o.current=String(Date.now()),a.setTyping({id:o.current,text:p}))},[d.SERVER_TEXT_STREAM_COMPLETE]:p=>{if(a.setReasoningActive(!1),o.current&&a.typingMessage){let c=a.typingMessage.text;a.addMessage({role:"assistant",type:"text",content:c,id:o.current,ts:Date.now()}),a.clearTyping(),o.current=null}},[d.SERVER_REASONING_STREAM]:p=>{a.setReasoningActive(!0),i.current?a.appendReasoning(i.current,p):(i.current=String(Date.now()),a.setReasoning({id:i.current,text:p}))},[d.SERVER_REASONING_STREAM_COMPLETE]:()=>{i.current=null,a.setReasoningActive(!1)},[d.SERVER_CONFIG]:p=>{a.setFlowConfig(JSON.parse(p))}};f[r]&&f[r](g)},onOpen:()=>{let s=t.getState();s.setStatus("connected"),s.clearTyping(),o.current=null,s.clearReasoning(),i.current=null,s.clearStep(),s.addEvent({type:"connection",content:"Connected to Agent Server"}),n!=null&&n.user&&A(n.user)},onClose:()=>{let s=t.getState();s.setStatus("disconnected"),s.setFlowConfig(null),s.addEvent({type:"connection",content:"Connection closed"})}});v.current=l;let C=u((s,r,g)=>{let a=s.trim();if(!a&&(!r||r.length===0)&&(!g||g.length===0))return;let p=((r==null?void 0:r.length)??0)>0||((g==null?void 0:g.length)??0)>0?JSON.stringify({text:a,images:r,documents:g}):a;l.send(d.USER_MESSAGE+":"+p);let c=t.getState();i.current=null,c.clearReasoning(),c.addMessage({id:String(Date.now())+Math.random(),role:"user",type:"text",content:a,images:r,ts:Date.now()})},[l]),h=u(()=>{t.getState().clearHistory(),l.send(d.USER_CLEAR_HISTORY+":1")},[l]),w=u((s,r)=>{let g=s.trim();g&&l.send(d.USER_AUTH+":"+JSON.stringify({name:g,value:r}))},[l]),x=u(s=>{A(s)},[A]),_=u(()=>t.getState().toggleEvents(),[]),b=u(()=>t.getState().clearEvents(),[]),N=u(s=>{let r=t.getState();r.updateApprovalStatus({toolCallId:s,status:"approved"});let g=JSON.stringify({type:"tool_approval",toolCallId:s,approved:!0});typeof(l==null?void 0:l.send)=="function"&&l.send(g),r.addEvent({type:"approval",content:`Approved tool call ${s}`,ts:Date.now()})},[l]),O=u(s=>{let r=t.getState();r.updateApprovalStatus({toolCallId:s,status:"rejected"});let g=JSON.stringify({type:"tool_approval",toolCallId:s,approved:!1});typeof(l==null?void 0:l.send)=="function"&&l.send(g),r.addEvent({type:"approval",content:`Rejected tool call ${s}`,ts:Date.now()})},[l]);return{connection:l,store:t,send:C,clearHistory:h,sendAuth:w,setIdentity:x,toggleEventsVisible:_,clearEvents:b,approve:N,reject:O}}export{z as GENERATION_PARAM_KEYS,W as GENERATION_PRESETS,E as MAX_USER_IDENTITY_LENGTH,Ae as MODEL_REGISTRY_SNAPSHOT,J as NodeType,B as PRESET_PARAM_KEYS,pe as REASONING_EFFORT_LEVELS,Se as TOOL_REGISTRY_SNAPSHOT,te as applyPresetToOverrides,ye as buildReasoningProviderOptions,Z as deriveParamSupport,I as getAgentStore,k as getDefaultOutVars,K as getEffectiveOutVars,fe as getModelEntry,P as logc,d as messageTypes,se as normalizeEffectiveParams,ce as normalizeReasoning,ae as openAiReasoningParamSupport,re as openAiStandardParamSupport,L as parseUserAuth,G as parseUserMessage,ne as pickNodeOverrides,de as reasoningEffortLevels,ue as reasoningExposable,Q as resolveOutVarRef,ee as resolvePreset,ve as resolveReasoningEffort,X as resolveTemplate,$ as sanitizeUserIdentity,le as stripUnsupportedFromNodeData,oe as toStreamTextSettings,we as useAgent,D as useAgentStore,Y as walkPath,ge as workersAiParamSupport,ie as xaiParamSupport};
1
+ import{a as d,b as G,c as E,d as $,e as L,f as Se,g as Ae,h as fe}from"./chunk-HAYNUZZB.js";import{a as J,b as Y,c as k,d as K,e as Q,f as X}from"./chunk-OYP6D5VN.js";import{a as z,b as B,c as W,d as Z,e as ee,f as te,g as ne,h as se,i as oe,j as re,k as ae,l as ie,m as ge,n as le,o as pe,p as ce,q as de,r as ue,s as ve,t as ye}from"./chunk-GRZ6ZRHM.js";import{a as P}from"./chunk-U56YWPSI.js";import"./chunk-3TXHFKDN.js";import{useAgent as H}from"agents/react";import{useCallback as u,useEffect as j,useMemo as U,useRef as S}from"react";import{create as q}from"zustand";import{devtools as V}from"zustand/middleware";var F={messages:[],events:[],eventsVisible:!1,status:"connecting",typingMessage:null,reasoningMessage:null,isReasoning:!1,stepInfo:null,approvals:[],error:null,flowConfig:null,composioAuth:null};function T(n){return q()(V((t,y)=>({...F,initHistory:e=>t({messages:e}),addEvent:e=>t(o=>({events:[...o.events,{...e,ts:Date.now()}]})),clearEvents:()=>t({events:[]}),setMessages:e=>{t({messages:e})},addMessage:e=>{t(o=>({messages:[...o.messages,e]}))},setTyping:e=>t({typingMessage:e}),appendTyping:(e,o)=>{let i=y().typingMessage;i&&i.id===e?t({typingMessage:{id:e,text:i.text+o}}):t({typingMessage:{id:e,text:o}})},clearTyping:()=>t({typingMessage:null}),setReasoning:e=>t({reasoningMessage:e}),appendReasoning:(e,o)=>{let i=y().reasoningMessage;i&&i.id===e?t({reasoningMessage:{id:e,text:i.text+o}}):t({reasoningMessage:{id:e,text:o}})},clearReasoning:()=>t({reasoningMessage:null,isReasoning:!1}),setReasoningActive:e=>t({isReasoning:e}),setStep:e=>t({stepInfo:e}),clearStep:()=>t({stepInfo:null}),setStatus:e=>t({status:e}),toggleEvents:()=>t(e=>({eventsVisible:!e.eventsVisible})),clearHistory:()=>t({messages:[],typingMessage:null,reasoningMessage:null,isReasoning:!1,stepInfo:null}),addApprovalRequest:e=>{let o={id:`approval-${Date.now()}-${Math.random()}`,toolCallId:e.toolCallId,toolName:e.toolName,args:e.args??{},description:e.description,ts:Date.now(),status:"pending"};t(i=>({approvals:[...i.approvals,o]}))},updateApprovalStatus:({toolCallId:e,status:o})=>{t(i=>({approvals:i.approvals.map(v=>v.toolCallId===e?{...v,status:o}:v)}))},removeApproval:e=>{t(o=>({approvals:o.approvals.filter(i=>i.toolCallId!==e)}))},setError:e=>t({error:e}),setFlowConfig:e=>t({flowConfig:e}),setComposioAuth:e=>t({composioAuth:e}),clearComposioAuth:()=>t({composioAuth:null})}),{name:n,enabled:!0}))}var D=T("agent-store"),M=new Map;function I(n){if(!n)return D;let t=M.get(n);return t||(t=T(`agent-store:${n}`),M.set(n,t)),t}function we(n){let t=U(()=>I(n==null?void 0:n.storeKey),[n==null?void 0:n.storeKey]),y=t(s=>s.typingMessage),e=S(null),o=S(null),i=S(null),v=S(null);j(()=>{e.current=y},[y]);let A=u(s=>{var g;let r=s.trim().slice(0,E);!r||typeof((g=v.current)==null?void 0:g.send)!="function"||v.current.send(d.USER_IDENTITY+":"+r)},[]),l=H({host:n==null?void 0:n.host,basePath:(n==null?void 0:n.basePath)??"/api/agents/base",agent:n==null?void 0:n.agent,name:n==null?void 0:n.name,query:n==null?void 0:n.query,onMessage:s=>{if(typeof s.data!="string")return;let[r,g]=s.data.split("::");if(!r||!g)return;let a=t.getState(),f={[d.SERVER_HISTORY]:p=>{let c=JSON.parse(p);a.setMessages(c.messages)},[d.SERVER_EVENT]:p=>{var R;let c=JSON.parse(p);if((c==null?void 0:c.type)==="info:composio:auth_required"&&((R=c==null?void 0:c.content)!=null&&R.redirectUrl)){let m=c.content;a.setComposioAuth({toolkit:m.toolkit,redirectUrl:m.redirectUrl,toolRowId:m.toolRowId})}a.addEvent({type:"server",...c})},[d.SERVER_ERROR]:p=>{a.setError(p),a.addEvent({type:"error",content:p})},[d.SERVER_TEXT_STREAM]:p=>{o.current?a.appendTyping(o.current,p):(o.current=String(Date.now()),a.setTyping({id:o.current,text:p}))},[d.SERVER_TEXT_STREAM_COMPLETE]:p=>{if(a.setReasoningActive(!1),o.current&&a.typingMessage){let c=a.typingMessage.text;a.addMessage({role:"assistant",type:"text",content:c,id:o.current,ts:Date.now()}),a.clearTyping(),o.current=null}},[d.SERVER_REASONING_STREAM]:p=>{a.setReasoningActive(!0),i.current?a.appendReasoning(i.current,p):(i.current=String(Date.now()),a.setReasoning({id:i.current,text:p}))},[d.SERVER_REASONING_STREAM_COMPLETE]:()=>{i.current=null,a.setReasoningActive(!1)},[d.SERVER_CONFIG]:p=>{a.setFlowConfig(JSON.parse(p))}};f[r]&&f[r](g)},onOpen:()=>{let s=t.getState();s.setStatus("connected"),s.clearTyping(),o.current=null,s.clearReasoning(),i.current=null,s.clearStep(),s.addEvent({type:"connection",content:"Connected to Agent Server"}),n!=null&&n.user&&A(n.user)},onClose:()=>{let s=t.getState();s.setStatus("disconnected"),s.setFlowConfig(null),s.addEvent({type:"connection",content:"Connection closed"})}});v.current=l;let C=u((s,r,g)=>{let a=s.trim();if(!a&&(!r||r.length===0)&&(!g||g.length===0))return;let p=((r==null?void 0:r.length)??0)>0||((g==null?void 0:g.length)??0)>0?JSON.stringify({text:a,images:r,documents:g}):a;l.send(d.USER_MESSAGE+":"+p);let c=t.getState();i.current=null,c.clearReasoning(),c.addMessage({id:String(Date.now())+Math.random(),role:"user",type:"text",content:a,images:r,ts:Date.now()})},[l]),h=u(()=>{t.getState().clearHistory(),l.send(d.USER_CLEAR_HISTORY+":1")},[l]),w=u((s,r)=>{let g=s.trim();g&&l.send(d.USER_AUTH+":"+JSON.stringify({name:g,value:r}))},[l]),x=u(s=>{A(s)},[A]),_=u(()=>t.getState().toggleEvents(),[]),b=u(()=>t.getState().clearEvents(),[]),N=u(s=>{let r=t.getState();r.updateApprovalStatus({toolCallId:s,status:"approved"});let g=JSON.stringify({type:"tool_approval",toolCallId:s,approved:!0});typeof(l==null?void 0:l.send)=="function"&&l.send(g),r.addEvent({type:"approval",content:`Approved tool call ${s}`,ts:Date.now()})},[l]),O=u(s=>{let r=t.getState();r.updateApprovalStatus({toolCallId:s,status:"rejected"});let g=JSON.stringify({type:"tool_approval",toolCallId:s,approved:!1});typeof(l==null?void 0:l.send)=="function"&&l.send(g),r.addEvent({type:"approval",content:`Rejected tool call ${s}`,ts:Date.now()})},[l]);return{connection:l,store:t,send:C,clearHistory:h,sendAuth:w,setIdentity:x,toggleEventsVisible:_,clearEvents:b,approve:N,reject:O}}export{z as GENERATION_PARAM_KEYS,W as GENERATION_PRESETS,E as MAX_USER_IDENTITY_LENGTH,Ae as MODEL_REGISTRY_SNAPSHOT,J as NodeType,B as PRESET_PARAM_KEYS,pe as REASONING_EFFORT_LEVELS,Se as TOOL_REGISTRY_SNAPSHOT,te as applyPresetToOverrides,ye as buildReasoningProviderOptions,Z as deriveParamSupport,I as getAgentStore,k as getDefaultOutVars,K as getEffectiveOutVars,fe as getModelEntry,P as logc,d as messageTypes,se as normalizeEffectiveParams,ce as normalizeReasoning,ae as openAiReasoningParamSupport,re as openAiStandardParamSupport,L as parseUserAuth,G as parseUserMessage,ne as pickNodeOverrides,de as reasoningEffortLevels,ue as reasoningExposable,Q as resolveOutVarRef,ee as resolvePreset,ve as resolveReasoningEffort,X as resolveTemplate,$ as sanitizeUserIdentity,le as stripUnsupportedFromNodeData,oe as toStreamTextSettings,we as useAgent,D as useAgentStore,Y as walkPath,ge as workersAiParamSupport,ie as xaiParamSupport};
@@ -0,0 +1,10 @@
1
+ import type { ModelEntry, ModelRegistrySnapshot } from '../types/ai-models-types';
2
+ /**
3
+ * @deprecated Static model registry removed. Runtime resolves models from hx-ora
4
+ * (KV/D1 via getOraModel / fetchOraModel). This export is an empty stub.
5
+ */
6
+ export declare const MODEL_REGISTRY_SNAPSHOT: ModelRegistrySnapshot;
7
+ /**
8
+ * @deprecated Use hx-ora backend model records instead.
9
+ */
10
+ export declare function getModelEntry(_id: string): ModelEntry | undefined;
@@ -0,0 +1,8 @@
1
+ interface ToolEntry {
2
+ id: string;
3
+ label: string;
4
+ description: string;
5
+ parameters?: Record<string, any>;
6
+ }
7
+ export declare const TOOL_REGISTRY_SNAPSHOT: Record<string, ToolEntry>;
8
+ export {};
@@ -0,0 +1,61 @@
1
+ export declare const messageTypes: {
2
+ readonly USER_MESSAGE: 'M';
3
+ readonly USER_CLEAR_HISTORY: 'CH';
4
+ readonly USER_AUTH: 'AUT';
5
+ readonly USER_IDENTITY: 'UID';
6
+ readonly SERVER_EVENT: 'SE';
7
+ readonly SERVER_HISTORY: 'HIS';
8
+ readonly SERVER_ERROR: 'ERR';
9
+ readonly SERVER_STEP: 'STEP';
10
+ readonly SERVER_TEXT_STREAM: 'TS';
11
+ readonly SERVER_TEXT_STREAM_COMPLETE: 'TSC';
12
+ readonly SERVER_REASONING_STREAM: 'RS';
13
+ readonly SERVER_REASONING_STREAM_COMPLETE: 'RSC';
14
+ readonly SERVER_CONFIG: 'CFG';
15
+ };
16
+ export type FlowConfig = {
17
+ allow_images: boolean;
18
+ allow_documents: boolean;
19
+ greeting?: string;
20
+ };
21
+ export type Message = {
22
+ id?: string;
23
+ role: 'user' | 'assistant';
24
+ type: 'text' | 'url';
25
+ content: any;
26
+ images?: {
27
+ mimeType: string;
28
+ data: string;
29
+ }[];
30
+ ts: number;
31
+ };
32
+ export type EventItem = {
33
+ type: string;
34
+ content: any;
35
+ [key: string]: any;
36
+ };
37
+ export type TypingMessage = {
38
+ id: string;
39
+ text: string;
40
+ } | null;
41
+ export type StepInfo = {
42
+ tool?: string;
43
+ phase?: string;
44
+ } | null;
45
+ export type MessageType = (typeof messageTypes)[keyof typeof messageTypes];
46
+ export type ChatHistoryItem = {
47
+ role: 'user' | 'assistant';
48
+ content: string;
49
+ };
50
+ export type ApprovalRequestPayload = {
51
+ type: 'tool_approval_request';
52
+ toolCallId: string;
53
+ toolName: string;
54
+ args: any;
55
+ description: string;
56
+ };
57
+ export type ToolExecutionResultPayload = {
58
+ toolCallId: string;
59
+ result: string;
60
+ approved: boolean;
61
+ };
@@ -0,0 +1,94 @@
1
+ export type EffectiveParams = {
2
+ temperature?: number;
3
+ topP?: number;
4
+ topK?: number;
5
+ frequencyPenalty?: number;
6
+ presencePenalty?: number;
7
+ maxOutputTokens?: number;
8
+ seed?: number;
9
+ stopSequences?: string[];
10
+ maxRetries?: number;
11
+ };
12
+ export type ParamRange = {
13
+ min: number;
14
+ max: number;
15
+ step?: number;
16
+ };
17
+ export type ParamSupport = {
18
+ temperature?: ParamRange | false;
19
+ topP?: ParamRange | false;
20
+ topK?: ParamRange | false;
21
+ frequencyPenalty?: ParamRange | false;
22
+ presencePenalty?: ParamRange | false;
23
+ maxOutputTokens?: {
24
+ max: number;
25
+ } | false;
26
+ seed?: boolean;
27
+ stopSequences?: {
28
+ max: number;
29
+ } | false;
30
+ };
31
+ export type ReasoningEffortLevel = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
32
+ /**
33
+ * Describes how a model exposes/controls "reasoning". This is the SOURCE OF TRUTH —
34
+ * declared per-model in the capabilities registry, never inferred from the provider at runtime.
35
+ *
36
+ * - `none` → model does not reason (or reasoning is not surfaced).
37
+ * - `effort` → opaque reasoning controlled via a provider `reasoningEffort` knob
38
+ * (e.g. OpenAI o-series / gpt-5, xAI grok). `levels` lists the values THIS
39
+ * model accepts; `exposesReasoning` marks models that can stream a reasoning
40
+ * summary (OpenAI needs `reasoningSummary` for this).
41
+ * - `tag` → model "thinks out loud" inside XML-like tags in the text stream
42
+ * (e.g. DeepSeek R1); reasoning is extracted via middleware (always exposable).
43
+ */
44
+ export type ReasoningCapability = {
45
+ kind: 'none';
46
+ } | {
47
+ kind: 'effort';
48
+ levels?: ReasoningEffortLevel[];
49
+ defaultLevel?: ReasoningEffortLevel;
50
+ exposesReasoning?: boolean;
51
+ } | {
52
+ kind: 'tag';
53
+ tagName?: string;
54
+ startWithReasoning?: boolean;
55
+ };
56
+ export type Capabilities = {
57
+ function_calling: boolean;
58
+ /** `true`/`false` is the legacy shape; prefer the structured {@link ReasoningCapability}. */
59
+ reasoning: boolean | ReasoningCapability;
60
+ multimodal: boolean;
61
+ params?: ParamSupport;
62
+ };
63
+ export type GenerationPresetId = 'precise' | 'balanced' | 'creative' | 'custom';
64
+ export type ModelEntry = {
65
+ id: string;
66
+ label: string;
67
+ provider: 'openai' | 'cloudflare' | 'workersai' | string;
68
+ providerModel: string;
69
+ author: string;
70
+ description?: string;
71
+ defaultParams?: EffectiveParams;
72
+ capabilities?: Capabilities;
73
+ tags?: string[];
74
+ price?: {
75
+ input: number;
76
+ output: number;
77
+ };
78
+ contextWindow?: number;
79
+ };
80
+ export type ModelRegistrySnapshot = Record<string, ModelEntry>;
81
+ export type ParamAdjustment = {
82
+ key: string;
83
+ action: 'stripped' | 'clamped';
84
+ detail?: string;
85
+ };
86
+ export type ResolvedModel = {
87
+ provider: string;
88
+ modelHandle: any;
89
+ entry: ModelEntry;
90
+ effectiveParams: EffectiveParams;
91
+ paramAdjustments?: ParamAdjustment[];
92
+ /** Normalized reasoning descriptor for this model (never the legacy boolean). */
93
+ reasoning: ReasoningCapability;
94
+ };
@@ -0,0 +1,28 @@
1
+ export type MemoryMode = 'raw' | 'summarize';
2
+ export type ContextDomain = 'tool' | 'summary' | 'keydata' | 'info' | 'skill';
3
+ export interface MemoryConfig {
4
+ enabled: boolean;
5
+ mode: MemoryMode;
6
+ summaryModel: string;
7
+ summaryThreshold: number;
8
+ toolCache: boolean;
9
+ }
10
+ export interface ContextMeta {
11
+ toolName?: string;
12
+ paramsHash?: string;
13
+ cacheable?: boolean;
14
+ truncated?: boolean;
15
+ }
16
+ export interface ContextRow {
17
+ ref: string;
18
+ domain: ContextDomain;
19
+ description: string;
20
+ data?: string;
21
+ cycle: number;
22
+ meta?: string;
23
+ ts: number;
24
+ }
25
+ export type ContextIndexEntry = Pick<ContextRow, 'ref' | 'domain' | 'description' | 'cycle' | 'ts' | 'meta'>;
26
+ export type ContextUpsertInput = Omit<ContextRow, 'ts'> & {
27
+ ts?: number;
28
+ };
@@ -0,0 +1,9 @@
1
+ export declare enum NodeType {
2
+ START_NODE = "startNode",
3
+ CLASSIFIER_NODE = "classifierNode",
4
+ MEMO_NODE = "memoNode",
5
+ LLM_NODE = "llmNode",
6
+ ANSWER_NODE = "answerNode",
7
+ API_NODE = "apiNode"
8
+ }
9
+ export type NODETYPES = NodeType.START_NODE | NodeType.CLASSIFIER_NODE | NodeType.MEMO_NODE | NodeType.LLM_NODE | NodeType.ANSWER_NODE | NodeType.API_NODE;
@@ -0,0 +1,11 @@
1
+ export interface UserInterface {
2
+ id: string;
3
+ email: string;
4
+ name: string;
5
+ first_name: string;
6
+ last_name: string;
7
+ tenant: string;
8
+ roles: string;
9
+ db_name: string | null;
10
+ user_id: string | null;
11
+ }
@@ -0,0 +1,29 @@
1
+ export interface FlowNode {
2
+ id: string;
3
+ type: string;
4
+ data?: any;
5
+ }
6
+ export interface VariableMapping {
7
+ var: string;
8
+ from: string;
9
+ default?: string;
10
+ }
11
+ export interface OutVar {
12
+ name: string;
13
+ path?: string;
14
+ label?: string;
15
+ description?: string;
16
+ type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'image' | 'file';
17
+ source?: 'default' | 'user';
18
+ }
19
+ export interface ResolveInput {
20
+ context: Record<string, any>;
21
+ results: Record<string, any>;
22
+ nodes: FlowNode[];
23
+ secrets?: Record<string, string>;
24
+ }
25
+ export interface ResolveOptions {
26
+ callerTag?: string;
27
+ serializeNonStrings?: boolean;
28
+ onError?: (msg: string) => void;
29
+ }
@@ -0,0 +1,58 @@
1
+ export type WsServerMessageType = 'chunk' | 'finish' | 'error' | 'complete' | 'history';
2
+ export type WsClientMessageType = 'message' | 'debug';
3
+ export interface WsServerMessage {
4
+ type: WsServerMessageType;
5
+ content: string;
6
+ timestamp: number;
7
+ }
8
+ export interface WsHistory extends WsServerMessage {
9
+ type: 'history';
10
+ messages: any[];
11
+ }
12
+ export interface WsError extends WsServerMessage {
13
+ type: 'error';
14
+ error: string;
15
+ }
16
+ export interface WsComplete extends WsServerMessage {
17
+ type: 'complete';
18
+ done: boolean;
19
+ }
20
+ export interface WsClientMessage {
21
+ type: WsClientMessageType;
22
+ timestamp: number;
23
+ }
24
+ export interface WsMessage extends WsClientMessage {
25
+ type: 'message';
26
+ role: 'user' | 'assistant' | 'system';
27
+ content: string;
28
+ }
29
+ export interface wsDebug extends WsClientMessage {
30
+ type: 'debug';
31
+ content: string;
32
+ }
33
+ export interface UserMessagePayload {
34
+ text: string;
35
+ images?: {
36
+ mimeType: string;
37
+ data: string;
38
+ }[];
39
+ documents?: {
40
+ name: string;
41
+ mimeType: string;
42
+ data: string;
43
+ }[];
44
+ }
45
+ export declare function parseUserMessage(content: string): UserMessagePayload;
46
+ export interface UserAuthPayload {
47
+ name: string;
48
+ value: string;
49
+ }
50
+ /**
51
+ * Parse an `AUT` message payload: JSON `{ name, value }`.
52
+ * `name` must match the secrets grammar `[A-Z][A-Z0-9_]*` so it aligns with the
53
+ * `{{ auth.NAME }}` template namespace. Returns null on any malformed input.
54
+ */
55
+ export declare const MAX_USER_IDENTITY_LENGTH = 256;
56
+ /** Trim and cap a client-supplied session identity string. Returns null if empty. */
57
+ export declare function sanitizeUserIdentity(content: string): string | null;
58
+ export declare function parseUserAuth(content: string): UserAuthPayload | null;