@transai/connector-runner-ai-agent 0.20.0 → 0.22.0
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/CHANGELOG.md +8 -0
- package/index.cjs +1 -1
- package/index.cjs.map +2 -2
- package/libs/types/src/lib/management-api/dataset/dataset.interface.d.ts +3 -0
- package/libs/types/src/lib/management-api/dataset/datasets.interface.d.ts +3 -0
- package/libs/types/src/lib/management-api/dataset/dimension.interface.d.ts +2 -0
- package/libs/types/src/lib/management-api/dataset/dimensions.interface.d.ts +1 -0
- package/libs/types/src/lib/management-api/dataset/measure.interface.d.ts +2 -0
- package/libs/types/src/lib/management-api/dataset/measures.interface.d.ts +1 -0
- package/libs/types/src/lib/management-api/dataset/segment.interface.d.ts +2 -0
- package/libs/types/src/lib/management-api/dataset/segments.interface.d.ts +1 -0
- package/libs/types/src/lib/management-api/semantic-trigger/semantic-trigger-record.interface.d.ts +0 -2
- package/libs/types/src/lib/management-api/template-implementation-overrides.interface.d.ts +3 -0
- package/libs/types/src/lib/management-api/template-implementation.interface.d.ts +6 -0
- package/libs/types/src/lib/management-api/template.interface.d.ts +3 -0
- package/libs/types/src/lib/management-api/workflow/workflow-drawing.interface.d.ts +7 -1
- package/libs/types/src/lib/management-api/workflow/workflow-run.interface.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 0.21.0 (2026-04-09)
|
|
2
|
+
|
|
3
|
+
This was a version bump only for connector-runner-ai-agent to align it with other projects, there were no code changes.
|
|
4
|
+
|
|
5
|
+
## 0.20.0 (2026-04-08)
|
|
6
|
+
|
|
7
|
+
This was a version bump only for connector-runner-ai-agent to align it with other projects, there were no code changes.
|
|
8
|
+
|
|
1
9
|
## 0.19.1 (2026-04-03)
|
|
2
10
|
|
|
3
11
|
### 🧱 Updated Dependencies
|
package/index.cjs
CHANGED
|
@@ -650,7 +650,7 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
|
|
|
650
650
|
|
|
651
651
|
Received: ${JSON.stringify(i,null,2)}`)};if(typeof i=="string")return i;if(Array.isArray(i)){let u=t(s),c=[];return i.forEach(l=>{if(l.type==="text"||l.type==="image_url")c.push(a(l,u));else throw new Error('Mistral only supports types "text" or "image_url" for complex message types.')}),c}throw new Error(`Message content must be a string or an array.
|
|
652
652
|
|
|
653
|
-
Received: ${JSON.stringify(i,null,2)}`)},n=i=>{if(Id(i)&&i.tool_calls?.length)return i.tool_calls.map(s=>({...s,id:xM(s.id??"")})).map($E)},o=new Set;for(let i of e)"tool_call_id"in i&&typeof i.tool_call_id=="string"&&o.add(xM(i.tool_call_id));return e.flatMap(i=>{let s=n(i),a=r(i.content,i.getType());if("tool_call_id"in i&&typeof i.tool_call_id=="string")return[{role:t(i.getType()),content:a,name:i.name,toolCallId:xM(i.tool_call_id)}];if(Id(i)){if(s===void 0)return[{role:t(i.getType()),content:a}];{let u=s.filter(c=>o.has(xM(c.id??"")));return u.length===0?typeof a=="string"&&a.trim()===""||Array.isArray(a)&&a.length===0?[]:[{role:t(i.getType()),content:a}]:[{role:t(i.getType()),toolCalls:u}]}}return[{role:t(i.getType()),content:a}]})}function fPr(e,t){let{message:r}=e;if(r===void 0)throw new Error("No message found in response");let n=[];"toolCalls"in r&&Array.isArray(r.toolCalls)&&(n=r.toolCalls);let o=mse(r.content);switch(r.role){case"assistant":{let i=[],s=[];for(let a of n)try{let u=d_(a,{returnId:!0});i.push({...u,id:u.id??Oz().replace(/-/g,"")})}catch(u){s.push(Ch(a,u.message))}return new de({content:o,tool_calls:i,invalid_tool_calls:s,additional_kwargs:{},usage_metadata:t?{input_tokens:t.promptTokens,output_tokens:t.completionTokens,total_tokens:t.totalTokens}:void 0})}default:return new Yt({content:o})}}function pPr(e,t){if(!e.content&&!e.toolCalls)return t?new It({content:"",usage_metadata:t?{input_tokens:t.promptTokens,output_tokens:t.completionTokens,total_tokens:t.totalTokens}:void 0}):null;let r=e.toolCalls?.length?e.toolCalls?.map((a,u)=>({...a,index:u,id:a.id??Oz().replace(/-/g,""),type:"function"})):void 0,n="assistant";e.role&&(n=e.role);let o=mse(e.content),i,s=[];if(r!==void 0)for(let a of r){let u=a.function?.arguments,c=u===void 0||typeof u=="string"?u:JSON.stringify(u);s.push({name:a.function?.name,args:c,id:a.id,index:a.index,type:"tool_call_chunk"})}else i={};return n==="user"?new mf({content:o}):n==="assistant"?new It({content:o,tool_call_chunks:s,additional_kwargs:i,usage_metadata:t?{input_tokens:t.promptTokens,output_tokens:t.completionTokens,total_tokens:t.totalTokens}:void 0}):n==="tool"?new Lf({content:o,additional_kwargs:i,tool_call_id:r?.[0].id??""}):n==="function"?new Wp({content:o,additional_kwargs:i}):new Zp({content:o,role:n})}function ktt(e){if(!(!e||!e.length))return e.map(t=>{if("function"in t)return{type:t.type??"function",function:t.function};if(Nd(t)){let r=t.description??`Tool: ${t.name}`;return{type:"function",function:{name:t.name,description:r,parameters:Vo(t.schema)?$r(t.schema):t.schema}}}throw new Error(`Unknown tool type passed to ChatMistral: ${JSON.stringify(t,null,2)}`)})}var mle=class extends Cc{static lc_name(){return"ChatMistralAI"}lc_namespace=["langchain","chat_models","mistralai"];model="mistral-small-latest";apiKey;endpoint;serverURL;temperature=.7;streaming=!1;topP=1;maxTokens;safeMode=!1;safePrompt=!1;randomSeed;seed;maxRetries;lc_serializable=!0;streamUsage=!0;beforeRequestHooks;requestErrorHooks;responseHooks;httpClient;presencePenalty;frequencyPenalty;numCompletions;constructor(e){super(e??{});let t=e?.apiKey??mo("MISTRAL_API_KEY");if(!t)throw new Error("API key MISTRAL_API_KEY is missing for MistralAI, but it is required.");this.apiKey=t,this.streaming=e?.streaming??this.streaming,this.serverURL=e?.serverURL??this.serverURL,this.temperature=e?.temperature??this.temperature,this.topP=e?.topP??this.topP,this.maxTokens=e?.maxTokens??this.maxTokens,this.safePrompt=e?.safePrompt??this.safePrompt,this.randomSeed=e?.seed??e?.randomSeed??this.seed,this.seed=this.randomSeed,this.maxRetries=e?.maxRetries,this.httpClient=e?.httpClient,this.model=e?.model??e?.modelName??this.model,this.streamUsage=e?.streamUsage??this.streamUsage,this.beforeRequestHooks=e?.beforeRequestHooks??this.beforeRequestHooks,this.requestErrorHooks=e?.requestErrorHooks??this.requestErrorHooks,this.responseHooks=e?.responseHooks??this.responseHooks,this.presencePenalty=e?.presencePenalty??this.presencePenalty,this.frequencyPenalty=e?.frequencyPenalty??this.frequencyPenalty,this.numCompletions=e?.numCompletions??this.numCompletions,this.addAllHooksToHttpClient()}get lc_secrets(){return{apiKey:"MISTRAL_API_KEY"}}get lc_aliases(){return{apiKey:"mistral_api_key"}}getLsParams(e){let t=this.invocationParams(e);return{ls_provider:"mistral",ls_model_name:this.model,ls_model_type:"chat",ls_temperature:t.temperature??void 0,ls_max_tokens:t.maxTokens??void 0}}_llmType(){return"mistral_ai"}invocationParams(e){let{response_format:t,tools:r,tool_choice:n}=e??{},o=r?.length?ktt(r):void 0;return{model:this.model,tools:o,temperature:this.temperature,maxTokens:this.maxTokens,topP:this.topP,randomSeed:this.seed,safePrompt:this.safePrompt,toolChoice:n,responseFormat:t,presencePenalty:this.presencePenalty,frequencyPenalty:this.frequencyPenalty,n:this.numCompletions}}bindTools(e,t){let r=ktt(e);return new qi({bound:this,kwargs:{...t??{},tools:r},config:{}})}async completionWithRetry(e,t){let r=new zf({maxRetries:this.maxRetries}),n=new Ftt.Mistral({apiKey:this.apiKey,serverURL:this.serverURL,...this.httpClient?{httpClient:this.httpClient}:{}});return r.call(async()=>{try{let o;return t?o=await n.chat.stream(e):o=await n.chat.complete(e),o}catch(o){throw(o.message?.includes("status: 400")||o.message?.toLowerCase().includes("status 400")||o.message?.includes("validation failed"))&&(o.status=400),o}})}async _generate(e,t,r){let n={},o=this.invocationParams(t),i=ple(e),s={...o,messages:i},a=t.signal??!!t.timeout;if(this.streaming||a){let f=this._streamResponseChunks(e,t,r),m={};for await(let _ of f){let g=_.generationInfo?.completion??0;m[g]===void 0?m[g]=_:m[g]=m[g].concat(_)}return{generations:Object.entries(m).sort(([_],[g])=>parseInt(_,10)-parseInt(g,10)).map(([_,g])=>g),llmOutput:{estimatedTokenUsage:n}}}let u=await this.completionWithRetry(s,!1),{completionTokens:c,promptTokens:l,totalTokens:d}=u?.usage??{};c&&(n.completionTokens=(n.completionTokens??0)+c),l&&(n.promptTokens=(n.promptTokens??0)+l),d&&(n.totalTokens=(n.totalTokens??0)+d);let p=[];for(let f of u?.choices??[]){if("delta"in f)throw new Error("Delta not supported in non-streaming mode.");if(!("message"in f))throw new Error("No message found in the choice.");let m=f.message?.content??"";Array.isArray(m)&&(m=m[0].type==="text"?m[0].text:"");let h={text:m,message:fPr(f,u?.usage)};f.finishReason&&(h.generationInfo={finishReason:f.finishReason}),p.push(h)}return{generations:p,llmOutput:{tokenUsage:n}}}async*_streamResponseChunks(e,t,r){let n=ple(e),i={...this.invocationParams(t),messages:n},s=await this.completionWithRetry(i,!0);for await(let{data:a}of s){if(t.signal?.aborted)throw new Error("AbortError");let u=a?.choices[0];if(!u||!("delta"in u))continue;let{delta:c}=u;if(!c)continue;let l={prompt:0,completion:u.index??0},d=this.streamUsage||t.streamUsage,p=pPr(c,d?a.usage:null);if(p===null)continue;let f=c.content??"";Array.isArray(f)&&(f=f[0].type==="text"?f[0].text:"");let m=new $i({message:p,text:f,generationInfo:l});yield m,r?.handleLLMNewToken(m.text??"",l,void 0,void 0,void 0,{chunk:m})}}addAllHooksToHttpClient(){try{if(this.removeAllHooksFromHttpClient(),[this.beforeRequestHooks,this.requestErrorHooks,this.responseHooks].some(t=>t&&t.length>0)&&!this.httpClient&&(this.httpClient=new Ltt.HTTPClient),this.beforeRequestHooks)for(let t of this.beforeRequestHooks)this.httpClient?.addHook("beforeRequest",t);if(this.requestErrorHooks)for(let t of this.requestErrorHooks)this.httpClient?.addHook("requestError",t);if(this.responseHooks)for(let t of this.responseHooks)this.httpClient?.addHook("response",t)}catch{throw new Error("Error in adding all hooks")}}removeAllHooksFromHttpClient(){try{if(this.beforeRequestHooks)for(let e of this.beforeRequestHooks)this.httpClient?.removeHook("beforeRequest",e);if(this.requestErrorHooks)for(let e of this.requestErrorHooks)this.httpClient?.removeHook("requestError",e);if(this.responseHooks)for(let e of this.responseHooks)this.httpClient?.removeHook("response",e)}catch{throw new Error("Error in removing hooks")}}removeHookFromHttpClient(e){try{this.httpClient?.removeHook("beforeRequest",e),this.httpClient?.removeHook("requestError",e),this.httpClient?.removeHook("response",e)}catch{throw new Error("Error in removing hook")}}_combineLLMOutput(){return[]}withStructuredOutput(e,t){let r=e,n=t?.name,o=t?.method,i=t?.includeRaw,s,a;if(o==="jsonMode"){let d;Vo(r)?(a=Th.fromZodSchema(r),d=$r(r)):a=new l_,s=this.withConfig({response_format:{type:"json_object"},ls_structured_output_format:{kwargs:{method:"jsonMode"},schema:d}})}else{let d=n??"extract";if(Vo(r)){let p=$r(r);s=this.bindTools([{type:"function",function:{name:d,description:p.description,parameters:p}}]).withConfig({tool_choice:"any",ls_structured_output_format:{kwargs:{method:"functionCalling"},schema:p}}),a=new bS({returnSingle:!0,keyName:d,zodSchema:r})}else{let p;typeof r.name=="string"&&typeof r.parameters=="object"&&r.parameters!=null?(p=r,d=r.name):p={name:d,description:r.description??"",parameters:r},s=this.bindTools([{type:"function",function:p}]).withConfig({tool_choice:"any"}),a=new bS({returnSingle:!0,keyName:d})}}if(!i)return s.pipe(a);let u=Ss.assign({parsed:(d,p)=>a.invoke(d.raw,p)}),c=Ss.assign({parsed:()=>null}),l=u.withFallbacks({fallbacks:[c]});return mi.from([{raw:s},l])}};var hle=(Ve=>(Ve.API="api",Ve.API_SINK="api-sink",Ve.API_SOURCE="api-source",Ve.DUMMY_NODE="dummy-node",Ve.FILE_COPY="file-copy",Ve.FILE="file",Ve.FILE_SINK="file-sink",Ve.FILE_SOURCE="file-source",Ve.SAMBA_SINK="samba-sink",Ve.SAMBA_SOURCE="samba-source",Ve.SQL_SINK="sql-sink",Ve.SQL_SOURCE="sql-source",Ve.MQTT="mqtt",Ve.CUBE_QUERY_RUNNER="cube-query-runner",Ve.FACTORY_NEBULA_SOURCE="factory-nebula-source",Ve.BYSTRONIC="bystronic",Ve.IMAP_SOURCE="imap-source",Ve.IMAP_SINK="imap-sink",Ve.OPCUA_SOURCE="opcua-source",Ve.OPCUA_SINK="opcua-sink",Ve.AI_AGENT="ai-agent",Ve.MICROSOFT_OFFICE365_EMAIL="microsoft-office365-email",Ve.MKG="mkg",Ve.EZ_MES="ez-mes",Ve.OTTO_FLEET_MANAGER_V2="otto-fleet-manager-v2",Ve.FRAUNHOFER_BATTERY_ASSEMBLY_CELLS="fraunhofer-battery-assembly-cells",Ve.PDF_GENERATE="pdf-generate",Ve.ONSHAPE="onshape",Ve.OROOX="oroox",Ve.GPMS="gpms",Ve.KEIZERSMETAAL_TRUMPF_API="keizersmetaal-trumpf-api",Ve.HP_INDIGO="hp-indigo",Ve))(hle||{});var Utt=["gpt-3.5-turbo","gpt-4","gpt-4-turbo","gpt-4o","gpt-4o-mini","gpt-5-nano","gpt-5-mini","gpt-5","o1-preview","o1-mini"],Btt=["claude-2","claude-2-100k","claude-instant-100k","claude-sonnet-4-5"],Jtt=["mistral-large-2512","mistral-medium-2508","mistral-small-2506"];var gle=(n=>(n.documents="documents",n.metrics="metrics",n.events="events",n))(gle||{});var _le=(a=>(a.equals="=",a.notEquals="<>",a.greaterThan=">",a.greaterThanOrEqual=">=",a.lessThan="<",a.lessThanOrEqual="<=",a.in="IN",a))(_le||{}),k3=S.union([S.string().min(1),S.number(),S.boolean(),S.array(S.union([S.string().min(1),S.number(),S.boolean()])).min(1)]),ble=(r=>(r.and="AND",r.or="OR",r))(ble||{}),ztt=S.union([S.string().min(1),S.array(S.string().min(1)).min(1)]),yle=(o=>(o.string="string",o.number="number",o.boolean="boolean",o.time="time",o))(yle||{}),Sle=(i=>(i.id="image_url",i.imageUrl="image_url",i.link="link",i.percent="percent",i.currency="currency",i))(Sle||{}),vle=(o=>(o.oneToOne="one_to_one",o.oneToMany="one_to_many",o.manyToOne="many_to_one",o.manyToMany="many_to_many",o))(vle||{}),wle=(d=>(d.count="count",d.countDistinct="count_distinct",d.countDistinctApprox="count_distinct_approx",d.sum="sum",d.avg="avg",d.min="min",d.max="max",d.string="string",d.time="time",d.boolean="boolean",d.number="number",d))(wle||{}),Ole=(r=>(r.percent="percent",r.currency="currency",r))(Ole||{}),Tle=(C=>(C.equals="equals",C.notEquals="notEquals",C.contains="contains",C.notContains="notContains",C.startsWith="startsWith",C.notStartsWith="notStartsWith",C.endsWith="endsWith",C.notEndsWith="notEndsWith",C.gt="gt",C.gte="gte",C.lt="lt",C.lte="lte",C.set="set",C.notSet="notSet",C.inDateRange="inDateRange",C.notInDateRange="notInDateRange",C.beforeDate="beforeDate",C.beforeOrOnDate="beforeOrOnDate",C.afterDate="afterDate",C.afterOrOnDate="afterOrOnDate",C))(Tle||{}),Cle=(r=>(r.from_template="from_template",r.manual="manual",r))(Cle||{});var Vtt=S.union([S.string().min(1),S.object({name:S.string().min(1),email:S.email().optional(),website:S.url().optional()})]);var Htt=S.object({identifier:S.string(),version:S.string(),name:S.string(),description:S.string().optional(),config:S.record(S.string(),S.any()),inputParameters:S.array(S.object({name:S.string(),description:S.string().optional(),type:S.enum(["string","number","boolean","array","simple-array","unknown"]),required:S.boolean().optional(),itemType:S.enum(["string","number","boolean"]).optional(),items:S.array(S.any()).optional()})),outputParameters:S.record(S.string(),S.any()),mode:S.enum(Cle).optional(),createdAt:S.date().optional(),updatedAt:S.date().optional()});var Gtt=S.object({dimension:S.string().min(1),operator:S.enum(Tle),values:k3});var Ktt=S.record(S.string(),S.union([Gtt,S.literal(!1)]));var Ele=S.object({name:S.string().min(1).optional(),description:S.string().min(1).optional(),eventType:S.string().min(1).optional(),dataset:S.string().min(1),dimensions:S.array(S.string().min(1)).min(1),limit:S.number().min(1).optional(),filters:Ktt.optional(),cron:S.string().nullable().optional(),tz:S.string().nullable().optional(),incrementalField:S.string().optional(),ungrouped:S.boolean().optional()}),o6n=Ele.extend({identifier:S.string().min(1),key:S.string().min(1)});var F3=S.record(S.string(),S.union([Ele,S.boolean()]));var Ztt=S.lazy(()=>S.object({type:S.enum(ble),filters:L3}));var M$=S.object({sql:S.string().min(1).optional(),dimension:S.string().min(1).optional(),operator:S.enum(_le).optional(),value:k3.optional()}).superRefine((e,t)=>{if(e.sql===void 0&&e.dimension===void 0){t.addIssue({code:S.ZodIssueCode.custom,message:"One of sql or dimension must be defined."});return}if(e.sql!==void 0&&e.dimension!==void 0){t.addIssue({code:S.ZodIssueCode.custom,message:"One of sql or dimension must be defined."});return}e.dimension!==void 0&&(e.operator===void 0||e.value===void 0)&&t.addIssue({code:S.ZodIssueCode.custom,message:"When dimension is defined, operator and values must be defined."})});var L3=S.record(S.string(),S.union([S.lazy(()=>Ztt),M$,S.literal(!1)]));var Wtt=S.object({collection:S.string().min(1),filters:L3.optional()});var Xtt=S.intersection(M$,S.object({label:S.string().min(1),description:S.string().min(1).optional()}));var Ytt=S.record(S.string(),S.union([Xtt,S.literal(!1)]));var Qtt=S.object({when:Ytt,else:S.string().min(1).optional(),segment:S.boolean().optional()});var mPr=S.record(S.string().regex(/^[a-z]{2}$/),S.record(S.string(),S.string())),N$=S.record(S.string(),S.union([mPr,S.string().min(1),S.number(),S.boolean()]));var ert=S.object({name:S.string().min(1),description:S.string().min(1),type:S.enum(yle),format:S.enum(Sle).optional(),explode:S.boolean().optional(),index:S.union([S.boolean(),S.string()]).optional(),upperIndex:S.union([S.boolean(),S.string()]).optional(),switch:Qtt.optional(),field:ztt.optional(),sql:S.string().min(1).optional(),public:S.boolean().optional(),primaryKey:S.boolean().optional(),subQuery:S.boolean().optional(),meta:N$.optional()}).superRefine((e,t)=>{if(e.switch!==void 0&&(e.field!==void 0||e.sql!==void 0))t.addIssue({code:S.ZodIssueCode.custom,message:"If switch is chosen, do not provide field or sql."});else if(e.switch!==void 0)return;if(e.field!==void 0&&e.sql!==void 0)t.addIssue({code:S.ZodIssueCode.custom,message:"If field is chosen, do not provide sql."});else if(e.field!==void 0)return;e.sql===void 0&&t.addIssue({code:S.ZodIssueCode.custom,message:"Please provide switch, field or sql."})});var trt=S.record(S.string(),S.union([ert,S.literal(!1)]));var rrt=S.object({name:S.string().min(1),description:S.string().min(1).optional(),type:S.enum(wle),format:S.enum(Ole).optional(),index:S.string().optional(),upperIndex:S.string().optional(),sql:S.string().min(1).optional(),dimension:S.string().min(1).optional(),public:S.boolean().optional(),meta:N$.optional()}).refine(e=>!(e.sql===void 0&&e.dimension===void 0||e.sql!==void 0&&e.dimension!==void 0),{message:"One of sql or dimension must be defined.",path:["sql","dimension"]});var nrt=S.record(S.string(),S.union([rrt,S.literal(!1)]));var ort=S.object({type:S.enum(["rollup","original_sql","rollup_join"]).optional(),measures:S.array(S.string()).optional(),dimensions:S.array(S.string()).optional(),segments:S.array(S.string()).optional(),timeDimension:S.string().optional(),granularity:S.string().optional(),partitionGranularity:S.string().optional(),rollups:S.array(S.string()).optional(),refreshKeySql:S.string().optional(),refreshKeyEvery:S.string().optional(),refreshKeyIncremental:S.boolean().optional(),refreshKeyUpdateWindow:S.string().optional(),buildRangeStartSql:S.string().optional(),buildRangeEndSql:S.string().optional(),lambda:S.boolean().optional()});var irt=S.record(S.string(),S.union([ort,S.literal(!1)]));var srt=S.object({type:S.enum(vle),dimension:S.string().min(1).optional(),targetDataset:S.string().min(1),targetDimension:S.string().min(1).optional(),sql:S.string().min(1).optional()}).superRefine((e,t)=>{e.sql!==void 0&&(e.dimension!==void 0||e.targetDimension!==void 0)&&t.addIssue({code:S.ZodIssueCode.custom,message:"Use sql field or dimension/targetDimension."})});var art=S.record(S.string(),S.union([srt,S.literal(!1)]));var urt=S.intersection(M$,S.object({name:S.string().min(1).optional(),description:S.string().min(1).optional(),public:S.boolean().optional()}));var crt=S.record(S.string(),S.union([urt,S.literal(!1)]));var lrt=S.object({name:S.string().min(1),description:S.string().min(1),type:S.enum(gle),prefix:S.string().min(1),parent:S.string().min(1).optional(),sql:S.string().min(1).optional(),meta:N$.optional(),collection:Wtt.optional(),dimensions:trt.optional(),segments:crt.optional(),relations:art.optional(),measures:nrt.optional(),preAggregations:irt.optional()}).superRefine((e,t)=>{if(!e.parent&&e.sql===void 0&&e.collection===void 0){t.addIssue({code:S.ZodIssueCode.custom,message:"You need to define either sql or collection."});return}e.sql!==void 0&&e.collection!==void 0&&t.addIssue({code:S.ZodIssueCode.custom,message:"You need to define either sql or collection."})});var U3=S.record(S.string(),lrt.or(S.boolean()));var drt=S.record(S.string(),S.union([S.string(),S.object({selector:S.string(),items:S.lazy(()=>drt).optional()})])),frt=(o=>(o.equals="equals",o.contains="contains",o.startsWith="startsWith",o.endsWith="endsWith",o))(frt||{}),hPr=S.object({selector:S.string(),operator:S.enum(frt).optional().default("equals"),value:S.string()}),gPr=S.array(hPr),prt=S.object({identifier:S.string(),name:S.string(),description:S.string().optional(),actionIdentifier:S.string(),inputParameters:drt.optional(),validation:gPr.optional()});var mrt=S.object({identifier:S.string(),connectorType:S.enum(hle),name:S.string(),location:S.string(),config:S.looseObject({}),enabled:S.boolean(),actions:S.array(Htt).optional(),webhooks:S.array(prt).optional(),createdAt:S.date().optional(),updatedAt:S.date().optional()}).superRefine((e,t)=>{let r=e.actions?.reduce((n,o)=>(n[o.identifier]=o,n),{})??{};e.webhooks?.forEach(n=>{let o=r[n.actionIdentifier];if(!o){t.addIssue({code:"custom",message:"Action identifier does not exist in the connector's actions.",params:{actionIdentifier:n.actionIdentifier},input:e});return}let i=o.inputParameters.filter(s=>s.required).map(s=>s.name);Object.keys(n.inputParameters??{}).forEach(s=>{i.includes(s)||t.addIssue({code:"custom",message:"Required input parameters has not been defined in webhook input parameter mapping.",params:{parameterName:s,actionIdentifier:n.actionIdentifier},input:e})})})});var B3=S.record(S.string(),mrt.or(S.boolean()));var IGn=S.object({identifier:S.string().min(1),version:S.string().min(1),name:S.string().min(1),prefix:S.string().min(1),description:S.string(),logo:S.string().nullable().optional(),author:Vtt.nullable().optional(),tenantIdentifier:S.string().nullable().optional(),datasets:U3,semanticTriggers:F3,connectors:B3.optional()});var hrt=S.object({datasets:U3.optional(),semanticTriggers:F3.optional(),connectors:B3.optional()});var _Pr=S.object({templateVersion:S.literal("latest").or(S.string().min(1)),name:S.string().min(1),description:S.string().min(1),overrides:hrt}),kGn=_Pr.extend({templateId:S.string().min(1),tenantId:S.string().min(1)});function bPr(e){return Utt.includes(e)}function grt(e){return Btt.includes(e)}function yPr(e){return Jtt.includes(e)}function _rt(e){let{provider:t,apiKey:r,model:n,temperature:o,timeout:i,credentials:s,region:a}=e.model;switch(t){case"openai":if(!r)throw new Error("API key is required for OpenAI provider");if(n&&!bPr(n))throw new Error(`Model ${n} is not a valid OpenAI model type`);return new iF({apiKey:r,model:n??"gpt-5",temperature:Number(o)||1,timeout:i,useResponsesApi:!0,verbose:!0});case"anthropic":if(!r)throw new Error("API key is required for Anthropic provider");if(n&&!grt(n))throw new Error(`Model ${n} is not a valid Anthropic model type`);return new Aee({apiKey:r,model:n??"claude-sonnet-4-5",temperature:o});case"aws":if(!s||!a)throw new Error("Credentials and region are required for AWS Bedrock provider");if(n&&!grt(n))throw new Error(`Model ${n} is not a valid Anthropic model type, which is used by AWS Bedrock`);return new pse({region:a,credentials:s,model:n??"claude-sonnet-4-5",temperature:Number(o)||1,timeout:i});case"mistral":if(!r)throw new Error("API key is required for Mistral provider");if(n&&!yPr(n))throw new Error(`Model ${n} is not a valid Mistral model type`);return new mle({apiKey:r,model:n??"mistral-small-3.2",temperature:Number(o)||1});default:throw new Error(`Unsupported provider: ${t}`)}}var brt=e=>e.replace(/_([a-z])/g,(t,r)=>r.toUpperCase()),J3=e=>{let t;if(Array.isArray(e.type))if(e.type.includes("null")&&e.type.length===2){let r=e.type.find(n=>n!=="null");r==="integer"||r==="number"?(t=S.number(),e.minimum!==void 0&&(t=t.min(e.minimum)),e.maximum!==void 0&&(t=t.max(e.maximum))):r==="string"?t=S.string():t=S.any(),t=t.nullable()}else t=S.any();else if(e.type==="string")e.enum?t=S.enum(e.enum):t=S.string();else if(e.type==="number"||e.type==="integer")t=S.number(),e.minimum!==void 0&&(t=t.min(e.minimum)),e.maximum!==void 0&&(t=t.max(e.maximum));else if(e.type==="boolean")t=S.boolean();else if(e.type==="object")if(e.properties){let r={};Object.entries(e.properties).forEach(([n,o])=>{let i=brt(n);r[i]=J3(o),o.description&&(r[i]=r[i].describe(o.description))}),t=S.object(r)}else t=S.object({});else if(e.type==="array")if(e.items?.type==="string")t=S.array(S.string());else if(e.items?.type==="number"||e.items?.type==="integer")t=S.array(S.number());else if(e.items?.type==="object"){let r=J3(e.items);t=S.array(r)}else if(Array.isArray(e.items?.type)){let r=J3(e.items);t=S.array(r)}else t=S.array(S.any());else t=S.any();return t},yrt=e=>{let t={};return Object.entries(e).forEach(([r,n])=>{let o=brt(r),{required:i,...s}=n,a=J3(s);s.description&&(a=a.describe(s.description)),i!==!0&&(a=a.nullable()),t[o]=a}),S.object(t)};var Ile=class extends aF{CONNECTOR_INSTANCE="XOD_CONNECTOR_AI_AGENT_CONFIG";#e;#r;#t;constructor(t,r){super(t,r),this.#r=this.connectorSDK.config.model,this.#e=this.connectorSDK.logger,this.#e.debug(`Initializing AI Agent Connector Runner with model: ${this.#r.model}`),this.#t=sn({name:"LoggingMiddleware",beforeModel:n=>{this.#e.debug(`Invoking model: ${n.messages[n.messages.length-1].text.trim().replace(/\s+/g," ").slice(0,100)}...`)},afterModel:n=>{this.#e.debug(`Model invocation completed: ${n.messages[n.messages.length-1].text.trim().replace(/\s+/g," ").slice(0,100)}...`)}})}init=async()=>{this.#e.debug("Initializing AI Agent Connector Runner"),this.callbackFunction=async(t,r)=>{let n=setInterval(()=>{this.#e.debug(`AI agent still processing for message ID: ${t.eventId}`)},1e4),o=r.config,i=()=>clearInterval(n),{systemPrompt:s,userPrompt:a}=o;if(!s||s.trim()==="")return i(),this.connectorSDK.telemetry.increment("ai_agent.invocation.missing_system_prompt"),this.connectorSDK.receiver.responses.unprocessableEntity("System prompt not found")(t);if(!a||a.trim()==="")return i(),this.connectorSDK.telemetry.increment("ai_agent.invocation.missing_user_prompt"),this.connectorSDK.receiver.responses.unprocessableEntity("Prompt not found")(t);let u=this.processPromptTemplate(s,r.inputParameters,t.payload),c=this.processPromptTemplate(a,r.inputParameters,t.payload),l=yrt(r.outputParameters);this.connectorSDK.telemetry.gauge("ai_agent.invocation.system_prompt_length",u.length),this.connectorSDK.telemetry.gauge("ai_agent.invocation.user_prompt_length",c.length);let d=await this.#n(t.payload.filepaths),p={...this.connectorSDK.config,model:{...this.#r,...o.model?{model:o.model}:{},...o.temperature?{temperature:o.temperature}:{}}},f=_rt(p),m=SL({model:f,responseFormat:fF({schema:l,strict:!0}),systemPrompt:u,tools:[],middleware:[this.#t]});try{this.#e.debug("Invoking AI agent...",r.outputParameters);let h=await m.invoke({messages:[new Yt({contentBlocks:[...d,{type:"text",text:c}]})]});this.#e.debug(`LLM response structure: messages=${h.messages?.length}, hasStructuredResponse=${!!h.structuredResponse}, responseKeys=${JSON.stringify(Object.keys(h||{}))}`),this.connectorSDK.telemetry.increment("ai_agent.invocation.success"),this.connectorSDK.telemetry.gauge("ai_agent.invocation.response_messages_length",h.messages.length),this.#e.info("AI agent invoked successfully."),!h.structuredResponse||Object.keys(h.structuredResponse).length===0?this.#e.warn(`Received empty structured response from AI agent. Last message: ${JSON.stringify(h.messages[h.messages.length-1]?.content||"no content").slice(0,500)}`):this.#e.debug(`Structured response populated with ${Object.keys(h.structuredResponse).length} fields`);let _={...t,payload:{...h.structuredResponse}};return this.connectorSDK.receiver.responses.ok()(_)}catch(h){return this.#e.error(`Error processing AI agent request: ${h?.message} - ${h} - ${h?.stack}`),this.#e.error("Error processing AI agent request STACK:",h?.message,h?.stack),this.connectorSDK.telemetry.increment("ai_agent.invocation.error"),this.connectorSDK.receiver.responses.internalServerError(`Error processing AI agent request: ${h}`)(t)}finally{i()}}};processPromptTemplate(t,r,n){let o=t;return r.forEach(i=>{let s=n[i.name];o=o.replace(new RegExp(`\\{\\{inputs\\.${i.name}\\}\\}`,"g"),s)}),o}async#n(t){try{let r=this.#s(t);return!Array.isArray(r)||r.length===0?(this.#e?.debug("No file paths to process."),[]):(this.#e?.debug(`Parsed file paths: ${r.join(", ")}`),(await Promise.all(r.map(async o=>this.#o(o)))).filter(o=>o!==null))}catch(r){this.#e?.error(`Error processing files: ${r}`)}return[]}async#o(t){this.#e.debug(`Processing file at path: ${t}`);try{let r=await this.#a(t),n=D$.default.basename(t);if(this.#u(n))return this.#e?.debug(`Adding image file: ${n}`),{type:"image",source_type:"base64",data:r.toString("base64"),mimeType:`image/${D$.default.extname(n).substring(1)}`,metadata:{filename:n}};if(this.#c(n)){let o={type:"file",data:`${r.toString("base64").substring(0,30)}...`,mimeType:"application/pdf",metadata:{filename:n}};return this.#e?.debug(`Adding PDF file: ${n}`,o,Qk(o)),{type:"file",data:r.toString("base64"),mimeType:"application/pdf",metadata:{filename:n}}}if(this.#i(n))return this.#e?.debug(`Adding text file: ${n}`),{type:"text",text:r.toString("utf-8"),metadata:{filename:n}};this.#e?.warn(`Unsupported file type ${n}, skipping embedding.`)}catch(r){this.#e?.error(`Error reading file ${t}: ${r}`)}return null}async#a(t){return String(t).startsWith("file://")?(await this.connectorSDK.files(t).read(".")).get():(0,Srt.readFileSync)(t)}#u(t){return[".png",".jpg",".jpeg",".gif",".bmp",".tiff"].includes(D$.default.extname(t).toLowerCase())}#c(t){return D$.default.extname(t).toLowerCase()===".pdf"}#i(t){return D$.default.extname(t).toLowerCase()===".txt"}#s(t){let r=t;if(r==null)return[];if(typeof t=="string")try{r=JSON.parse(t)}catch{r=t}return Array.isArray(r)?r:typeof r=="string"?[r]:[]}};0&&(module.exports={ConnectorRunnerAiAgent});
|
|
653
|
+
Received: ${JSON.stringify(i,null,2)}`)},n=i=>{if(Id(i)&&i.tool_calls?.length)return i.tool_calls.map(s=>({...s,id:xM(s.id??"")})).map($E)},o=new Set;for(let i of e)"tool_call_id"in i&&typeof i.tool_call_id=="string"&&o.add(xM(i.tool_call_id));return e.flatMap(i=>{let s=n(i),a=r(i.content,i.getType());if("tool_call_id"in i&&typeof i.tool_call_id=="string")return[{role:t(i.getType()),content:a,name:i.name,toolCallId:xM(i.tool_call_id)}];if(Id(i)){if(s===void 0)return[{role:t(i.getType()),content:a}];{let u=s.filter(c=>o.has(xM(c.id??"")));return u.length===0?typeof a=="string"&&a.trim()===""||Array.isArray(a)&&a.length===0?[]:[{role:t(i.getType()),content:a}]:[{role:t(i.getType()),toolCalls:u}]}}return[{role:t(i.getType()),content:a}]})}function fPr(e,t){let{message:r}=e;if(r===void 0)throw new Error("No message found in response");let n=[];"toolCalls"in r&&Array.isArray(r.toolCalls)&&(n=r.toolCalls);let o=mse(r.content);switch(r.role){case"assistant":{let i=[],s=[];for(let a of n)try{let u=d_(a,{returnId:!0});i.push({...u,id:u.id??Oz().replace(/-/g,"")})}catch(u){s.push(Ch(a,u.message))}return new de({content:o,tool_calls:i,invalid_tool_calls:s,additional_kwargs:{},usage_metadata:t?{input_tokens:t.promptTokens,output_tokens:t.completionTokens,total_tokens:t.totalTokens}:void 0})}default:return new Yt({content:o})}}function pPr(e,t){if(!e.content&&!e.toolCalls)return t?new It({content:"",usage_metadata:t?{input_tokens:t.promptTokens,output_tokens:t.completionTokens,total_tokens:t.totalTokens}:void 0}):null;let r=e.toolCalls?.length?e.toolCalls?.map((a,u)=>({...a,index:u,id:a.id??Oz().replace(/-/g,""),type:"function"})):void 0,n="assistant";e.role&&(n=e.role);let o=mse(e.content),i,s=[];if(r!==void 0)for(let a of r){let u=a.function?.arguments,c=u===void 0||typeof u=="string"?u:JSON.stringify(u);s.push({name:a.function?.name,args:c,id:a.id,index:a.index,type:"tool_call_chunk"})}else i={};return n==="user"?new mf({content:o}):n==="assistant"?new It({content:o,tool_call_chunks:s,additional_kwargs:i,usage_metadata:t?{input_tokens:t.promptTokens,output_tokens:t.completionTokens,total_tokens:t.totalTokens}:void 0}):n==="tool"?new Lf({content:o,additional_kwargs:i,tool_call_id:r?.[0].id??""}):n==="function"?new Wp({content:o,additional_kwargs:i}):new Zp({content:o,role:n})}function ktt(e){if(!(!e||!e.length))return e.map(t=>{if("function"in t)return{type:t.type??"function",function:t.function};if(Nd(t)){let r=t.description??`Tool: ${t.name}`;return{type:"function",function:{name:t.name,description:r,parameters:Vo(t.schema)?$r(t.schema):t.schema}}}throw new Error(`Unknown tool type passed to ChatMistral: ${JSON.stringify(t,null,2)}`)})}var mle=class extends Cc{static lc_name(){return"ChatMistralAI"}lc_namespace=["langchain","chat_models","mistralai"];model="mistral-small-latest";apiKey;endpoint;serverURL;temperature=.7;streaming=!1;topP=1;maxTokens;safeMode=!1;safePrompt=!1;randomSeed;seed;maxRetries;lc_serializable=!0;streamUsage=!0;beforeRequestHooks;requestErrorHooks;responseHooks;httpClient;presencePenalty;frequencyPenalty;numCompletions;constructor(e){super(e??{});let t=e?.apiKey??mo("MISTRAL_API_KEY");if(!t)throw new Error("API key MISTRAL_API_KEY is missing for MistralAI, but it is required.");this.apiKey=t,this.streaming=e?.streaming??this.streaming,this.serverURL=e?.serverURL??this.serverURL,this.temperature=e?.temperature??this.temperature,this.topP=e?.topP??this.topP,this.maxTokens=e?.maxTokens??this.maxTokens,this.safePrompt=e?.safePrompt??this.safePrompt,this.randomSeed=e?.seed??e?.randomSeed??this.seed,this.seed=this.randomSeed,this.maxRetries=e?.maxRetries,this.httpClient=e?.httpClient,this.model=e?.model??e?.modelName??this.model,this.streamUsage=e?.streamUsage??this.streamUsage,this.beforeRequestHooks=e?.beforeRequestHooks??this.beforeRequestHooks,this.requestErrorHooks=e?.requestErrorHooks??this.requestErrorHooks,this.responseHooks=e?.responseHooks??this.responseHooks,this.presencePenalty=e?.presencePenalty??this.presencePenalty,this.frequencyPenalty=e?.frequencyPenalty??this.frequencyPenalty,this.numCompletions=e?.numCompletions??this.numCompletions,this.addAllHooksToHttpClient()}get lc_secrets(){return{apiKey:"MISTRAL_API_KEY"}}get lc_aliases(){return{apiKey:"mistral_api_key"}}getLsParams(e){let t=this.invocationParams(e);return{ls_provider:"mistral",ls_model_name:this.model,ls_model_type:"chat",ls_temperature:t.temperature??void 0,ls_max_tokens:t.maxTokens??void 0}}_llmType(){return"mistral_ai"}invocationParams(e){let{response_format:t,tools:r,tool_choice:n}=e??{},o=r?.length?ktt(r):void 0;return{model:this.model,tools:o,temperature:this.temperature,maxTokens:this.maxTokens,topP:this.topP,randomSeed:this.seed,safePrompt:this.safePrompt,toolChoice:n,responseFormat:t,presencePenalty:this.presencePenalty,frequencyPenalty:this.frequencyPenalty,n:this.numCompletions}}bindTools(e,t){let r=ktt(e);return new qi({bound:this,kwargs:{...t??{},tools:r},config:{}})}async completionWithRetry(e,t){let r=new zf({maxRetries:this.maxRetries}),n=new Ftt.Mistral({apiKey:this.apiKey,serverURL:this.serverURL,...this.httpClient?{httpClient:this.httpClient}:{}});return r.call(async()=>{try{let o;return t?o=await n.chat.stream(e):o=await n.chat.complete(e),o}catch(o){throw(o.message?.includes("status: 400")||o.message?.toLowerCase().includes("status 400")||o.message?.includes("validation failed"))&&(o.status=400),o}})}async _generate(e,t,r){let n={},o=this.invocationParams(t),i=ple(e),s={...o,messages:i},a=t.signal??!!t.timeout;if(this.streaming||a){let f=this._streamResponseChunks(e,t,r),m={};for await(let _ of f){let g=_.generationInfo?.completion??0;m[g]===void 0?m[g]=_:m[g]=m[g].concat(_)}return{generations:Object.entries(m).sort(([_],[g])=>parseInt(_,10)-parseInt(g,10)).map(([_,g])=>g),llmOutput:{estimatedTokenUsage:n}}}let u=await this.completionWithRetry(s,!1),{completionTokens:c,promptTokens:l,totalTokens:d}=u?.usage??{};c&&(n.completionTokens=(n.completionTokens??0)+c),l&&(n.promptTokens=(n.promptTokens??0)+l),d&&(n.totalTokens=(n.totalTokens??0)+d);let p=[];for(let f of u?.choices??[]){if("delta"in f)throw new Error("Delta not supported in non-streaming mode.");if(!("message"in f))throw new Error("No message found in the choice.");let m=f.message?.content??"";Array.isArray(m)&&(m=m[0].type==="text"?m[0].text:"");let h={text:m,message:fPr(f,u?.usage)};f.finishReason&&(h.generationInfo={finishReason:f.finishReason}),p.push(h)}return{generations:p,llmOutput:{tokenUsage:n}}}async*_streamResponseChunks(e,t,r){let n=ple(e),i={...this.invocationParams(t),messages:n},s=await this.completionWithRetry(i,!0);for await(let{data:a}of s){if(t.signal?.aborted)throw new Error("AbortError");let u=a?.choices[0];if(!u||!("delta"in u))continue;let{delta:c}=u;if(!c)continue;let l={prompt:0,completion:u.index??0},d=this.streamUsage||t.streamUsage,p=pPr(c,d?a.usage:null);if(p===null)continue;let f=c.content??"";Array.isArray(f)&&(f=f[0].type==="text"?f[0].text:"");let m=new $i({message:p,text:f,generationInfo:l});yield m,r?.handleLLMNewToken(m.text??"",l,void 0,void 0,void 0,{chunk:m})}}addAllHooksToHttpClient(){try{if(this.removeAllHooksFromHttpClient(),[this.beforeRequestHooks,this.requestErrorHooks,this.responseHooks].some(t=>t&&t.length>0)&&!this.httpClient&&(this.httpClient=new Ltt.HTTPClient),this.beforeRequestHooks)for(let t of this.beforeRequestHooks)this.httpClient?.addHook("beforeRequest",t);if(this.requestErrorHooks)for(let t of this.requestErrorHooks)this.httpClient?.addHook("requestError",t);if(this.responseHooks)for(let t of this.responseHooks)this.httpClient?.addHook("response",t)}catch{throw new Error("Error in adding all hooks")}}removeAllHooksFromHttpClient(){try{if(this.beforeRequestHooks)for(let e of this.beforeRequestHooks)this.httpClient?.removeHook("beforeRequest",e);if(this.requestErrorHooks)for(let e of this.requestErrorHooks)this.httpClient?.removeHook("requestError",e);if(this.responseHooks)for(let e of this.responseHooks)this.httpClient?.removeHook("response",e)}catch{throw new Error("Error in removing hooks")}}removeHookFromHttpClient(e){try{this.httpClient?.removeHook("beforeRequest",e),this.httpClient?.removeHook("requestError",e),this.httpClient?.removeHook("response",e)}catch{throw new Error("Error in removing hook")}}_combineLLMOutput(){return[]}withStructuredOutput(e,t){let r=e,n=t?.name,o=t?.method,i=t?.includeRaw,s,a;if(o==="jsonMode"){let d;Vo(r)?(a=Th.fromZodSchema(r),d=$r(r)):a=new l_,s=this.withConfig({response_format:{type:"json_object"},ls_structured_output_format:{kwargs:{method:"jsonMode"},schema:d}})}else{let d=n??"extract";if(Vo(r)){let p=$r(r);s=this.bindTools([{type:"function",function:{name:d,description:p.description,parameters:p}}]).withConfig({tool_choice:"any",ls_structured_output_format:{kwargs:{method:"functionCalling"},schema:p}}),a=new bS({returnSingle:!0,keyName:d,zodSchema:r})}else{let p;typeof r.name=="string"&&typeof r.parameters=="object"&&r.parameters!=null?(p=r,d=r.name):p={name:d,description:r.description??"",parameters:r},s=this.bindTools([{type:"function",function:p}]).withConfig({tool_choice:"any"}),a=new bS({returnSingle:!0,keyName:d})}}if(!i)return s.pipe(a);let u=Ss.assign({parsed:(d,p)=>a.invoke(d.raw,p)}),c=Ss.assign({parsed:()=>null}),l=u.withFallbacks({fallbacks:[c]});return mi.from([{raw:s},l])}};var hle=(Ve=>(Ve.API="api",Ve.API_SINK="api-sink",Ve.API_SOURCE="api-source",Ve.DUMMY_NODE="dummy-node",Ve.FILE_COPY="file-copy",Ve.FILE="file",Ve.FILE_SINK="file-sink",Ve.FILE_SOURCE="file-source",Ve.SAMBA_SINK="samba-sink",Ve.SAMBA_SOURCE="samba-source",Ve.SQL_SINK="sql-sink",Ve.SQL_SOURCE="sql-source",Ve.MQTT="mqtt",Ve.CUBE_QUERY_RUNNER="cube-query-runner",Ve.FACTORY_NEBULA_SOURCE="factory-nebula-source",Ve.BYSTRONIC="bystronic",Ve.IMAP_SOURCE="imap-source",Ve.IMAP_SINK="imap-sink",Ve.OPCUA_SOURCE="opcua-source",Ve.OPCUA_SINK="opcua-sink",Ve.AI_AGENT="ai-agent",Ve.MICROSOFT_OFFICE365_EMAIL="microsoft-office365-email",Ve.MKG="mkg",Ve.EZ_MES="ez-mes",Ve.OTTO_FLEET_MANAGER_V2="otto-fleet-manager-v2",Ve.FRAUNHOFER_BATTERY_ASSEMBLY_CELLS="fraunhofer-battery-assembly-cells",Ve.PDF_GENERATE="pdf-generate",Ve.ONSHAPE="onshape",Ve.OROOX="oroox",Ve.GPMS="gpms",Ve.KEIZERSMETAAL_TRUMPF_API="keizersmetaal-trumpf-api",Ve.HP_INDIGO="hp-indigo",Ve))(hle||{});var Utt=["gpt-3.5-turbo","gpt-4","gpt-4-turbo","gpt-4o","gpt-4o-mini","gpt-5-nano","gpt-5-mini","gpt-5","o1-preview","o1-mini"],Btt=["claude-2","claude-2-100k","claude-instant-100k","claude-sonnet-4-5"],Jtt=["mistral-large-2512","mistral-medium-2508","mistral-small-2506"];var gle=(n=>(n.documents="documents",n.metrics="metrics",n.events="events",n))(gle||{});var _le=(a=>(a.equals="=",a.notEquals="<>",a.greaterThan=">",a.greaterThanOrEqual=">=",a.lessThan="<",a.lessThanOrEqual="<=",a.in="IN",a))(_le||{}),k3=S.union([S.string().min(1),S.number(),S.boolean(),S.array(S.union([S.string().min(1),S.number(),S.boolean()])).min(1)]),ble=(r=>(r.and="AND",r.or="OR",r))(ble||{}),ztt=S.union([S.string().min(1),S.array(S.string().min(1)).min(1)]),yle=(o=>(o.string="string",o.number="number",o.boolean="boolean",o.time="time",o))(yle||{}),Sle=(i=>(i.id="image_url",i.imageUrl="image_url",i.link="link",i.percent="percent",i.currency="currency",i))(Sle||{}),vle=(o=>(o.oneToOne="one_to_one",o.oneToMany="one_to_many",o.manyToOne="many_to_one",o.manyToMany="many_to_many",o))(vle||{}),wle=(d=>(d.count="count",d.countDistinct="count_distinct",d.countDistinctApprox="count_distinct_approx",d.sum="sum",d.avg="avg",d.min="min",d.max="max",d.string="string",d.time="time",d.boolean="boolean",d.number="number",d))(wle||{}),Ole=(r=>(r.percent="percent",r.currency="currency",r))(Ole||{}),Tle=(C=>(C.equals="equals",C.notEquals="notEquals",C.contains="contains",C.notContains="notContains",C.startsWith="startsWith",C.notStartsWith="notStartsWith",C.endsWith="endsWith",C.notEndsWith="notEndsWith",C.gt="gt",C.gte="gte",C.lt="lt",C.lte="lte",C.set="set",C.notSet="notSet",C.inDateRange="inDateRange",C.notInDateRange="notInDateRange",C.beforeDate="beforeDate",C.beforeOrOnDate="beforeOrOnDate",C.afterDate="afterDate",C.afterOrOnDate="afterOrOnDate",C))(Tle||{}),Cle=(r=>(r.from_template="from_template",r.manual="manual",r))(Cle||{});var Vtt=S.union([S.string().min(1),S.object({name:S.string().min(1),email:S.email().optional(),website:S.url().optional()})]);var Htt=S.object({identifier:S.string(),version:S.string(),name:S.string(),description:S.string().optional(),config:S.record(S.string(),S.any()),inputParameters:S.array(S.object({name:S.string(),description:S.string().optional(),type:S.enum(["string","number","boolean","array","simple-array","unknown"]),required:S.boolean().optional(),itemType:S.enum(["string","number","boolean"]).optional(),items:S.array(S.any()).optional()})),outputParameters:S.record(S.string(),S.any()),mode:S.enum(Cle).optional(),createdAt:S.date().optional(),updatedAt:S.date().optional()});var Gtt=S.object({dimension:S.string().min(1),operator:S.enum(Tle),values:k3});var Ktt=S.record(S.string(),S.union([Gtt,S.literal(!1)]));var Ele=S.object({name:S.string().min(1).optional(),description:S.string().min(1).optional(),eventType:S.string().min(1).optional(),dataset:S.string().min(1),dimensions:S.array(S.string().min(1)).min(1),limit:S.number().min(1).optional(),filters:Ktt.optional(),cron:S.string().nullable().optional(),tz:S.string().nullable().optional(),incrementalField:S.string().optional(),ungrouped:S.boolean().optional()}),o6n=Ele.extend({identifier:S.string().min(1),key:S.string().min(1)});var F3=S.record(S.string(),S.union([Ele,S.boolean()]));var Ztt=S.lazy(()=>S.object({type:S.enum(ble),filters:L3}));var M$=S.object({sql:S.string().min(1).optional(),dimension:S.string().min(1).optional(),operator:S.enum(_le).optional(),value:k3.optional()}).superRefine((e,t)=>{if(e.sql===void 0&&e.dimension===void 0){t.addIssue({code:S.ZodIssueCode.custom,message:"One of sql or dimension must be defined."});return}if(e.sql!==void 0&&e.dimension!==void 0){t.addIssue({code:S.ZodIssueCode.custom,message:"One of sql or dimension must be defined."});return}e.dimension!==void 0&&(e.operator===void 0||e.value===void 0)&&t.addIssue({code:S.ZodIssueCode.custom,message:"When dimension is defined, operator and values must be defined."})});var L3=S.record(S.string(),S.union([S.lazy(()=>Ztt),M$,S.literal(!1)]));var Wtt=S.object({collection:S.string().min(1),filters:L3.optional()});var Xtt=S.intersection(M$,S.object({label:S.string().min(1),description:S.string().min(1).optional()}));var Ytt=S.record(S.string(),S.union([Xtt,S.literal(!1)]));var Qtt=S.object({when:Ytt,else:S.string().min(1).optional(),segment:S.boolean().optional()});var mPr=S.record(S.string().regex(/^[a-z]{2}$/),S.record(S.string(),S.string())),N$=S.record(S.string(),S.union([mPr,S.string().min(1),S.number(),S.boolean()]));var ert=S.object({name:S.string().min(1),description:S.string().min(1),type:S.enum(yle),format:S.enum(Sle).optional(),explode:S.boolean().optional(),index:S.union([S.boolean(),S.string()]).optional(),upperIndex:S.union([S.boolean(),S.string()]).optional(),switch:Qtt.optional(),field:ztt.optional(),sql:S.string().min(1).optional(),public:S.boolean().optional(),primaryKey:S.boolean().optional(),subQuery:S.boolean().optional(),override:S.union([S.boolean(),S.literal("custom")]).optional(),meta:N$.optional()}).superRefine((e,t)=>{if(e.switch!==void 0&&(e.field!==void 0||e.sql!==void 0))t.addIssue({code:S.ZodIssueCode.custom,message:"If switch is chosen, do not provide field or sql."});else if(e.switch!==void 0)return;if(e.field!==void 0&&e.sql!==void 0)t.addIssue({code:S.ZodIssueCode.custom,message:"If field is chosen, do not provide sql."});else if(e.field!==void 0)return;e.sql===void 0&&t.addIssue({code:S.ZodIssueCode.custom,message:"Please provide switch, field or sql."})});var trt=S.record(S.string(),S.union([ert,S.literal(!1)]));var rrt=S.object({name:S.string().min(1),description:S.string().min(1).optional(),type:S.enum(wle),format:S.enum(Ole).optional(),index:S.string().optional(),upperIndex:S.string().optional(),sql:S.string().min(1).optional(),dimension:S.string().min(1).optional(),public:S.boolean().optional(),override:S.union([S.boolean(),S.literal("custom")]).optional(),meta:N$.optional()}).refine(e=>!(e.sql===void 0&&e.dimension===void 0||e.sql!==void 0&&e.dimension!==void 0),{message:"One of sql or dimension must be defined.",path:["sql","dimension"]});var nrt=S.record(S.string(),S.union([rrt,S.literal(!1)]));var ort=S.object({type:S.enum(["rollup","original_sql","rollup_join"]).optional(),measures:S.array(S.string()).optional(),dimensions:S.array(S.string()).optional(),segments:S.array(S.string()).optional(),timeDimension:S.string().optional(),granularity:S.string().optional(),partitionGranularity:S.string().optional(),rollups:S.array(S.string()).optional(),refreshKeySql:S.string().optional(),refreshKeyEvery:S.string().optional(),refreshKeyIncremental:S.boolean().optional(),refreshKeyUpdateWindow:S.string().optional(),buildRangeStartSql:S.string().optional(),buildRangeEndSql:S.string().optional(),lambda:S.boolean().optional()});var irt=S.record(S.string(),S.union([ort,S.literal(!1)]));var srt=S.object({type:S.enum(vle),dimension:S.string().min(1).optional(),targetDataset:S.string().min(1),targetDimension:S.string().min(1).optional(),sql:S.string().min(1).optional()}).superRefine((e,t)=>{e.sql!==void 0&&(e.dimension!==void 0||e.targetDimension!==void 0)&&t.addIssue({code:S.ZodIssueCode.custom,message:"Use sql field or dimension/targetDimension."})});var art=S.record(S.string(),S.union([srt,S.literal(!1)]));var urt=S.intersection(M$,S.object({name:S.string().min(1).optional(),description:S.string().min(1).optional(),public:S.boolean().optional(),override:S.union([S.boolean(),S.literal("custom")]).optional()}));var crt=S.record(S.string(),S.union([urt,S.literal(!1)]));var lrt=S.object({name:S.string().min(1),description:S.string().min(1),type:S.enum(gle),prefix:S.string().min(1),parent:S.string().min(1).optional(),sql:S.string().min(1).optional(),meta:N$.optional(),collection:Wtt.optional(),dimensions:trt.optional(),segments:crt.optional(),relations:art.optional(),measures:nrt.optional(),preAggregations:irt.optional()}).superRefine((e,t)=>{if(!e.parent&&e.sql===void 0&&e.collection===void 0){t.addIssue({code:S.ZodIssueCode.custom,message:"You need to define either sql or collection."});return}e.sql!==void 0&&e.collection!==void 0&&t.addIssue({code:S.ZodIssueCode.custom,message:"You need to define either sql or collection."})});var U3=S.record(S.string(),lrt.or(S.boolean()));var drt=S.record(S.string(),S.union([S.string(),S.object({selector:S.string(),items:S.lazy(()=>drt).optional()})])),frt=(o=>(o.equals="equals",o.contains="contains",o.startsWith="startsWith",o.endsWith="endsWith",o))(frt||{}),hPr=S.object({selector:S.string(),operator:S.enum(frt).optional().default("equals"),value:S.string()}),gPr=S.array(hPr),prt=S.object({identifier:S.string(),name:S.string(),description:S.string().optional(),actionIdentifier:S.string(),inputParameters:drt.optional(),validation:gPr.optional()});var mrt=S.object({identifier:S.string(),connectorType:S.enum(hle),name:S.string(),location:S.string(),config:S.looseObject({}),enabled:S.boolean(),actions:S.array(Htt).optional(),webhooks:S.array(prt).optional(),createdAt:S.date().optional(),updatedAt:S.date().optional()}).superRefine((e,t)=>{let r=e.actions?.reduce((n,o)=>(n[o.identifier]=o,n),{})??{};e.webhooks?.forEach(n=>{let o=r[n.actionIdentifier];if(!o){t.addIssue({code:"custom",message:"Action identifier does not exist in the connector's actions.",params:{actionIdentifier:n.actionIdentifier},input:e});return}let i=o.inputParameters.filter(s=>s.required).map(s=>s.name);Object.keys(n.inputParameters??{}).forEach(s=>{i.includes(s)||t.addIssue({code:"custom",message:"Required input parameters has not been defined in webhook input parameter mapping.",params:{parameterName:s,actionIdentifier:n.actionIdentifier},input:e})})})});var B3=S.record(S.string(),mrt.or(S.boolean()));var IGn=S.object({identifier:S.string().min(1),version:S.string().min(1),name:S.string().min(1),prefix:S.string().min(1),description:S.string(),logo:S.string().nullable().optional(),author:Vtt.nullable().optional(),tenantIdentifier:S.string().nullable().optional(),datasets:U3,semanticTriggers:F3,connectors:B3.optional()});var hrt=S.object({datasets:U3.optional(),semanticTriggers:F3.optional(),connectors:B3.optional()});var _Pr=S.object({templateVersion:S.literal("latest").or(S.string().min(1)),name:S.string().min(1),description:S.string().min(1),overrides:hrt}),kGn=_Pr.extend({templateId:S.string().min(1),tenantId:S.string().min(1)});function bPr(e){return Utt.includes(e)}function grt(e){return Btt.includes(e)}function yPr(e){return Jtt.includes(e)}function _rt(e){let{provider:t,apiKey:r,model:n,temperature:o,timeout:i,credentials:s,region:a}=e.model;switch(t){case"openai":if(!r)throw new Error("API key is required for OpenAI provider");if(n&&!bPr(n))throw new Error(`Model ${n} is not a valid OpenAI model type`);return new iF({apiKey:r,model:n??"gpt-5",temperature:Number(o)||1,timeout:i,useResponsesApi:!0,verbose:!0});case"anthropic":if(!r)throw new Error("API key is required for Anthropic provider");if(n&&!grt(n))throw new Error(`Model ${n} is not a valid Anthropic model type`);return new Aee({apiKey:r,model:n??"claude-sonnet-4-5",temperature:o});case"aws":if(!s||!a)throw new Error("Credentials and region are required for AWS Bedrock provider");if(n&&!grt(n))throw new Error(`Model ${n} is not a valid Anthropic model type, which is used by AWS Bedrock`);return new pse({region:a,credentials:s,model:n??"claude-sonnet-4-5",temperature:Number(o)||1,timeout:i});case"mistral":if(!r)throw new Error("API key is required for Mistral provider");if(n&&!yPr(n))throw new Error(`Model ${n} is not a valid Mistral model type`);return new mle({apiKey:r,model:n??"mistral-small-3.2",temperature:Number(o)||1});default:throw new Error(`Unsupported provider: ${t}`)}}var brt=e=>e.replace(/_([a-z])/g,(t,r)=>r.toUpperCase()),J3=e=>{let t;if(Array.isArray(e.type))if(e.type.includes("null")&&e.type.length===2){let r=e.type.find(n=>n!=="null");r==="integer"||r==="number"?(t=S.number(),e.minimum!==void 0&&(t=t.min(e.minimum)),e.maximum!==void 0&&(t=t.max(e.maximum))):r==="string"?t=S.string():t=S.any(),t=t.nullable()}else t=S.any();else if(e.type==="string")e.enum?t=S.enum(e.enum):t=S.string();else if(e.type==="number"||e.type==="integer")t=S.number(),e.minimum!==void 0&&(t=t.min(e.minimum)),e.maximum!==void 0&&(t=t.max(e.maximum));else if(e.type==="boolean")t=S.boolean();else if(e.type==="object")if(e.properties){let r={};Object.entries(e.properties).forEach(([n,o])=>{let i=brt(n);r[i]=J3(o),o.description&&(r[i]=r[i].describe(o.description))}),t=S.object(r)}else t=S.object({});else if(e.type==="array")if(e.items?.type==="string")t=S.array(S.string());else if(e.items?.type==="number"||e.items?.type==="integer")t=S.array(S.number());else if(e.items?.type==="object"){let r=J3(e.items);t=S.array(r)}else if(Array.isArray(e.items?.type)){let r=J3(e.items);t=S.array(r)}else t=S.array(S.any());else t=S.any();return t},yrt=e=>{let t={};return Object.entries(e).forEach(([r,n])=>{let o=brt(r),{required:i,...s}=n,a=J3(s);s.description&&(a=a.describe(s.description)),i!==!0&&(a=a.nullable()),t[o]=a}),S.object(t)};var Ile=class extends aF{CONNECTOR_INSTANCE="XOD_CONNECTOR_AI_AGENT_CONFIG";#e;#r;#t;constructor(t,r){super(t,r),this.#r=this.connectorSDK.config.model,this.#e=this.connectorSDK.logger,this.#e.debug(`Initializing AI Agent Connector Runner with model: ${this.#r.model}`),this.#t=sn({name:"LoggingMiddleware",beforeModel:n=>{this.#e.debug(`Invoking model: ${n.messages[n.messages.length-1].text.trim().replace(/\s+/g," ").slice(0,100)}...`)},afterModel:n=>{this.#e.debug(`Model invocation completed: ${n.messages[n.messages.length-1].text.trim().replace(/\s+/g," ").slice(0,100)}...`)}})}init=async()=>{this.#e.debug("Initializing AI Agent Connector Runner"),this.callbackFunction=async(t,r)=>{let n=setInterval(()=>{this.#e.debug(`AI agent still processing for message ID: ${t.eventId}`)},1e4),o=r.config,i=()=>clearInterval(n),{systemPrompt:s,userPrompt:a}=o;if(!s||s.trim()==="")return i(),this.connectorSDK.telemetry.increment("ai_agent.invocation.missing_system_prompt"),this.connectorSDK.receiver.responses.unprocessableEntity("System prompt not found")(t);if(!a||a.trim()==="")return i(),this.connectorSDK.telemetry.increment("ai_agent.invocation.missing_user_prompt"),this.connectorSDK.receiver.responses.unprocessableEntity("Prompt not found")(t);let u=this.processPromptTemplate(s,r.inputParameters,t.payload),c=this.processPromptTemplate(a,r.inputParameters,t.payload),l=yrt(r.outputParameters);this.connectorSDK.telemetry.gauge("ai_agent.invocation.system_prompt_length",u.length),this.connectorSDK.telemetry.gauge("ai_agent.invocation.user_prompt_length",c.length);let d=await this.#n(t.payload.filepaths),p={...this.connectorSDK.config,model:{...this.#r,...o.model?{model:o.model}:{},...o.temperature?{temperature:o.temperature}:{}}},f=_rt(p),m=SL({model:f,responseFormat:fF({schema:l,strict:!0}),systemPrompt:u,tools:[],middleware:[this.#t]});try{this.#e.debug("Invoking AI agent...",r.outputParameters);let h=await m.invoke({messages:[new Yt({contentBlocks:[...d,{type:"text",text:c}]})]});this.#e.debug(`LLM response structure: messages=${h.messages?.length}, hasStructuredResponse=${!!h.structuredResponse}, responseKeys=${JSON.stringify(Object.keys(h||{}))}`),this.connectorSDK.telemetry.increment("ai_agent.invocation.success"),this.connectorSDK.telemetry.gauge("ai_agent.invocation.response_messages_length",h.messages.length),this.#e.info("AI agent invoked successfully."),!h.structuredResponse||Object.keys(h.structuredResponse).length===0?this.#e.warn(`Received empty structured response from AI agent. Last message: ${JSON.stringify(h.messages[h.messages.length-1]?.content||"no content").slice(0,500)}`):this.#e.debug(`Structured response populated with ${Object.keys(h.structuredResponse).length} fields`);let _={...t,payload:{...h.structuredResponse}};return this.connectorSDK.receiver.responses.ok()(_)}catch(h){return this.#e.error(`Error processing AI agent request: ${h?.message} - ${h} - ${h?.stack}`),this.#e.error("Error processing AI agent request STACK:",h?.message,h?.stack),this.connectorSDK.telemetry.increment("ai_agent.invocation.error"),this.connectorSDK.receiver.responses.internalServerError(`Error processing AI agent request: ${h}`)(t)}finally{i()}}};processPromptTemplate(t,r,n){let o=t;return r.forEach(i=>{let s=n[i.name];o=o.replace(new RegExp(`\\{\\{inputs\\.${i.name}\\}\\}`,"g"),s)}),o}async#n(t){try{let r=this.#s(t);return!Array.isArray(r)||r.length===0?(this.#e?.debug("No file paths to process."),[]):(this.#e?.debug(`Parsed file paths: ${r.join(", ")}`),(await Promise.all(r.map(async o=>this.#o(o)))).filter(o=>o!==null))}catch(r){this.#e?.error(`Error processing files: ${r}`)}return[]}async#o(t){this.#e.debug(`Processing file at path: ${t}`);try{let r=await this.#a(t),n=D$.default.basename(t);if(this.#u(n))return this.#e?.debug(`Adding image file: ${n}`),{type:"image",source_type:"base64",data:r.toString("base64"),mimeType:`image/${D$.default.extname(n).substring(1)}`,metadata:{filename:n}};if(this.#c(n)){let o={type:"file",data:`${r.toString("base64").substring(0,30)}...`,mimeType:"application/pdf",metadata:{filename:n}};return this.#e?.debug(`Adding PDF file: ${n}`,o,Qk(o)),{type:"file",data:r.toString("base64"),mimeType:"application/pdf",metadata:{filename:n}}}if(this.#i(n))return this.#e?.debug(`Adding text file: ${n}`),{type:"text",text:r.toString("utf-8"),metadata:{filename:n}};this.#e?.warn(`Unsupported file type ${n}, skipping embedding.`)}catch(r){this.#e?.error(`Error reading file ${t}: ${r}`)}return null}async#a(t){return String(t).startsWith("file://")?(await this.connectorSDK.files(t).read(".")).get():(0,Srt.readFileSync)(t)}#u(t){return[".png",".jpg",".jpeg",".gif",".bmp",".tiff"].includes(D$.default.extname(t).toLowerCase())}#c(t){return D$.default.extname(t).toLowerCase()===".pdf"}#i(t){return D$.default.extname(t).toLowerCase()===".txt"}#s(t){let r=t;if(r==null)return[];if(typeof t=="string")try{r=JSON.parse(t)}catch{r=t}return Array.isArray(r)?r:typeof r=="string"?[r]:[]}};0&&(module.exports={ConnectorRunnerAiAgent});
|
|
654
654
|
/*! Bundled license information:
|
|
655
655
|
|
|
656
656
|
@langchain/core/dist/utils/fast-json-patch/src/helpers.js:
|