From 590e5c5a4e4e45d66ae0aec82fa289ba41b7e1ae Mon Sep 17 00:00:00 2001 From: Lucas Woodward <31957045+SketchingDev@users.noreply.github.com> Date: Tue, 1 Sep 2026 21:48:26 +0100 Subject: [PATCH] Increase version --- .claude-plugin/marketplace.json | 2 +- .claude-plugin/plugin.json | 2 +- package.json | 2 +- servers/genesys-cloud-architect-mcp.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 7e4e689..f9d180f 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -10,7 +10,7 @@ "name": "genesys-cloud-architect", "source": "./", "description": "Create, test, and debug Genesys Cloud Architect flows", - "version": "1.0.9" + "version": "2.0.0" } ] } diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 2796ca9..ca31eaf 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "genesys-cloud-architect", "description": "Create, test, and debug Genesys Cloud Architect flows", - "version": "1.0.9", + "version": "2.0.0", "author": { "name": "Lucas Woodward", "url": "https://makingchatbots.com/" diff --git a/package.json b/package.json index 60ae326..baa1534 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "genesys-cloud-architect", - "version": "1.0.9", + "version": "2.0.0", "private": true, "packageManager": "pnpm@11.1.3+sha512.c85357fe17ca12dd23dd7071822666dfd7e3cb76fe214e3370b5ea2fb34f2a231185509b63e717f3cd0acb38dd3f8d82bcd5e8172400ae678b70ea4fbed0896d", "author": { diff --git a/servers/genesys-cloud-architect-mcp.js b/servers/genesys-cloud-architect-mcp.js index 77796cb..6eec3dc 100644 --- a/servers/genesys-cloud-architect-mcp.js +++ b/servers/genesys-cloud-architect-mcp.js @@ -157,7 +157,7 @@ ${s.warnings.join(` `)}`),l({content:[{type:"text",text:f.join(` `)+m}]})}else{let f=s?.error??`Deploy runner exited with code ${h}`;l({isError:!0,content:[{type:"text",text:`Deploy failed: ${f}${m}`}]})}})})}});var H7=50,I7=200;function R7(t,e){return t.slice().sort((i,n)=>Number(Db(n,e))-Number(Db(i,e)))}function Db(t,e){return t.name.toLowerCase()===e.toLowerCase()}function z7(t){return{id:t.id??"",name:t.name,type:t.type??"",publishedVersion:t.publishedVersion?.commitVersion??null,...t.description?{description:t.description}:{}}}var D7={name:je.string().min(1).describe("The flow name, or a portion of it, to search for. Matched case-insensitively against flow names, so a partial name like 'payment' finds 'Book_Payment'."),type:je.array(je.string()).optional().describe('Optional flow types to restrict the search to, e.g. ["inboundcall"], ["bot", "digitalbot"], ["workflow"]. Omit to search flows of every type.')},bI=({architectApi:t})=>({config:{description:"Finds Genesys Cloud Architect flows by name, resolving the human-readable name users know (e.g. 'Book_Payment') to the flow id every other flow tool requires. Returns each matching flow's id, name, type and published version. Matching is a case-insensitive search over flow names that accepts a portion of the name; flows whose name equals the query exactly are listed first. The returned id is accepted verbatim by flow_ir, flow_action, search_in_flow and flow_dependencies. A publishedVersion of null means the flow has never been published.",annotations:{title:"Find Flow",readOnlyHint:!0,destructiveHint:!1},inputSchema:D7},handler:async({name:e,type:i})=>{try{let n=[],a=0,r=1;for(;;){let u=await t.getFlows({name:e,pageSize:100,pageNumber:r,...i?.length?{type:i}:{}});if(u.entities&&n.push(...u.entities),a=u.total??a,!u.nextUri||n.length>=I7)break;r++}a=Math.max(a,n.length);let s=R7(n,e).slice(0,H7),o=[];if(s.length===0)o.push(`No flows matched "${e}". The search already accepts a portion of the name, so try a shorter fragment, or drop the type filter if one was given.`);else if(a>s.length){let u=`${a} flows matched; only ${s.length} are returned${Db(s[0],e)?", exact name matches first":""}.`;n.length0?{notes:o}:{}};return{content:[{type:"text",text:JSON.stringify(l)}]}}catch(n){return{isError:!0,content:[{type:"text",text:`Failed to search for flows: ${n instanceof Error?n.message:String(n)}`}]}}}});var vt=t=>`${t}::start`,ws=(t,e)=>`${t}::${e}`;function yI(t,e,i,n){let a=new Set(e.backEdges.map(h=>`${h.from} ${h.to}`)),r=new Map,s=new Map,o=new Map,l=new Map;for(let h of t.nodes.keys())r.set(h,[]),s.set(h,new Set),o.set(h,[]),l.set(h,new Set);for(let h of t.edges){let g=a.has(`${h.from} ${h.to}`),m=r.get(h.to);if(m){let w=`${h.from} ${h.label??""} ${g}`,b=s.get(h.to);b&&!b.has(w)&&(b.add(w),m.push({id:h.from,label:h.label,backEdge:g}))}let f=o.get(h.from);if(f){let w=`${h.to} ${h.label??""} ${g}`,b=l.get(h.from);b&&!b.has(w)&&(b.add(w),f.push({id:h.to,label:h.label,backEdge:g}))}}let u=-1;for(let h of e.order.values())h>u&&(u=h);let c=u+1,p=[];for(let[h,g]of t.nodes){let m=e.order.has(h),f=m?e.order.get(h):c++;p.push({id:h,kind:g.kind,actionType:g.actionType,label:g.label,description:g.description,predecessors:r.get(h)??[],successors:o.get(h)??[],order:f,taskId:g.taskId,taskName:g.taskName,reachable:m,terminal:g.terminal})}p.sort((h,g)=>h.order-g.order);let d=i.taskOrder.flatMap(h=>{let g=i.tasks.get(h);return g?[{id:h,name:g.name,reusable:i.reusableTaskIds.has(h)}]:[]});return{flowName:i.flowName,flowType:i.flowType,entryTaskId:i.entryTaskId,reachabilityIsComplete:n,tasks:d,nodes:p}}function ir(t,e){let i=t;for(let n of e.split(".")){if(i==null||typeof i!="object")return;i=i[n]}return typeof i=="string"&&i.length>0?i:void 0}function it(t,e){for(let i of e){let n=ir(t,i);if(n!==void 0)return n}}function PI(t){let e=t.expression;if(e==null||typeof e!="object")return;let{text:i,type:n}=e;if(typeof i=="string"&&i.trim().length>0)return i;if(typeof n=="string"&&n.length>0)return n}function Gb(t,e){let i=t.find(n=>n.outputId===e);return i?(i.terminal=!0,t):[{outputId:e,label:$b(e),synthetic:!0,terminal:!0},...t]}var Tl={isTerminal:()=>!0,outputs:()=>[]},jI={isTerminal:()=>!0,describe:t=>it(t,["transferTo","group.text","flowName","externalNumber.text","user.text","transferTarget.text","transferTargetGroup.text","queues.0.text"]),outputs:t=>Gb(vs(t).map(nr),"__SUCCESS__")},G7={isTerminal:()=>!1,outputs:t=>{let e=t.path;if(!e||typeof e!="object")return[];let i=nr(e,0);return i.outputId="__LOOP__",typeof e.label=="string"&&e.label.length>0||(i.label="Loop"),[i]}},$7={describe:()=>"Exits the innermost enclosing loop; control continues at the loop's next action (jump edge not modelled \u2014 this node's successors omit it)",outputs:()=>[]},N7={outputs:t=>Gb(vs(t).map(nr),"__SUCCESS__")},U7={isTerminal:()=>!0,describe:t=>it(t,["flowName"]),outputs:t=>Gb(vs(t).map(nr),"__DISCONNECT__")},W7={outputs:t=>{let e=vs(t);return e.length>0?[nr(e[0],0)]:[]}},Ni=t=>({describe:t}),nd={DisconnectAction:Tl,EndFlowAction:Tl,EndTaskAction:Tl,EndStateAction:Tl,ExitBotFlowAction:Tl,LoopAction:G7,ExitLoopAction:$7,ProcessVoicemailInputAction:N7,CallBotFlowAction:U7,AskForNLUNextIntentAction:W7,WaitForInputAction:{},CallTaskAction:{},TaskAction:{},TransferMenuAction:{},TransferTaskAction:{},LoopUntilAction:{},DecisionAction:Ni(PI),SwitchAction:Ni(PI),DataAction:Ni(t=>it(t,["actionName"])),DataTableLookupAction:Ni(t=>it(t,["datatableName"])),CallCommonModuleAction:Ni(t=>it(t,["flowName"])),CallBotConnectorAction:Ni(t=>it(t,["botName"])),CallDigitalBotFlowAction:Ni(t=>it(t,["flowName"])),AddFlowMilestoneAction:Ni(t=>it(t,["milestoneName"])),ScreenPopAction:Ni(t=>it(t,["inputs.0.value.text"])),PlayAudioAction:Ni(t=>it(t,["prompts.defaultAudio.text"])),SetFlowOutcomeAction:Ni(t=>{let e=ir(t,"outcomeName"),i=ir(t,"outcomeValue.text");return e&&i?`${e} = ${i}`:e??i}),InitializeFlowOutcomeAction:Ni(t=>ir(t,"outcomeName")),EvaluateScheduleGroupAction:Ni(t=>ir(t,"scheduleGroup.text")),FindSystemPromptAction:Ni(t=>ir(t,"findName.text")),SetUUIDataAction:Ni(t=>ir(t,"uuiData.text")),UpdateVariableAction:{},SetAttributesAction:{},GetAttributesAction:{},EvaluateScheduleAction:{},CollectInputAction:{},GetResponseAction:{},AskForBooleanAction:{},AskForSlotAction:{},CommunicateAction:{},DigitalMenuAction:{},SendResponseAction:{},TranscriptionAction:{},FindQueueAction:{},FindUserPromptAction:{},SetWhisperAudio:{},BridgeServerAction:{}};function td(t){return typeof t=="string"&&t.length>0}function vs(t){let e=[];if(Array.isArray(t.paths))for(let i of t.paths)i&&typeof i=="object"&&e.push(i);return t.path&&typeof t.path=="object"&&e.push(t.path),e}function $b(t){let e=t.replace(/^__/,"").replace(/__$/,"");if(e.length===0)return t;let i=e.toLowerCase();return i.charAt(0).toUpperCase()+i.slice(1)}function nr(t,e){let i=t.outputId??`__OUTPUT_${e}__`,n=typeof t.label=="string"&&t.label.length>0?t.label:$b(i),a={outputId:i,label:n,nextActionId:t.nextActionId,synthetic:!1,terminal:!1};return t.enabled===!1&&(a.disabled=!0),a}var L7=["taskReference","menuReference"],SI={describe:()=>{},outputs:t=>vs(t).map(nr),isTerminal:()=>!1,referencedTaskIds:t=>{let e=[];for(let i of L7){let n=t[i];typeof n=="string"&&n.length>0&&e.push(n)}return e}},B7=new Set(["TransferMenuAction","TransferTaskAction"]);function OI(t){return typeof t=="string"&&t.startsWith("Transfer")&&!B7.has(t)}function TI(t){return t?t in nd||OI(t):!1}function xI(t){let e=OI(t)?{...SI,...jI}:SI,i=t&&t in nd?nd[t]:void 0;return i?{...e,...i}:e}function*ad(t){for(let e of t.taskOrder){let i=t.tasks.get(e);if(i)for(let n of i.orderedActions)typeof n.id=="string"&&(yield{taskId:e,task:i,action:n,actionId:n.id,handler:xI(n.__type)})}}function MI(t){let e=[],i=[];for(let n of t.taskOrder){let a=t.tasks.get(n);if(a){td(a.startAction)&&e.push({from:vt(n),to:a.startAction,kind:"fallthrough"});for(let r of a.menuChoices)e.push({from:vt(n),to:r.actionId,kind:"reference",label:r.label})}}for(let{taskId:n,actionId:a,action:r,handler:s}of ad(t)){let o=s.isTerminal(r);td(r.nextAction)&&!o&&e.push({from:a,to:r.nextAction,kind:"fallthrough"});for(let l of s.outputs(r)){let u=ws(a,l.outputId);e.push({from:a,to:u,kind:"branch",label:l.label}),td(l.nextActionId)&&!l.terminal&&e.push({from:u,to:l.nextActionId,kind:l.outputId==="__LOOP__"?"loop":"branch"})}for(let l of s.referencedTaskIds(r)){let u=t.tasks.get(l);u?e.push({from:a,to:vt(l),kind:"reference",label:u.name}):i.push({code:"UNRESOLVED_REFERENCE",message:`Reference from ${a} to task ${l} is unresolvable.`,nodeId:a,taskId:n})}}return{edges:e,warnings:i}}function EI(t,e,i){let n=new Map;for(let u of t)n.set(u.id,u);let a=new Map;for(let u of n.keys())a.set(u,[]);let r=[],s=[],o=[];for(let u of e){let c=n.has(u.from),p=n.has(u.to);if(!c||!p){let d=c?`unknown target node "${u.to}"`:`unknown source node "${u.from}"`;s.push({...u,reason:d}),o.push({code:"DROPPED_EDGE",message:`Dropped ${u.kind} edge ${u.from} \u2192 ${u.to}: ${d}.`});continue}r.push(u),a.get(u.from)?.push(u.to)}let l=i.taskOrder.map(vt).filter(u=>n.has(u));return{graph:{nodes:n,edges:r,adjacency:a,roots:l,dropped:s},warnings:o}}function F7(t,e,i){let n=[],a=[];if(Array.isArray(t.actionList))for(let r of t.actionList)r&&typeof r=="object"&&n.push(r);if(Array.isArray(t.menuChoiceList))for(let r of t.menuChoiceList){let s=r?.action;if(!s||typeof s!="object")continue;if(typeof s.id!="string"){i.push({code:"MISSING_ACTION_ID",message:`Menu-choice action of type "${s.__type??"(missing)"}" in task ${e} has no id and was skipped.`,taskId:e});continue}n.push(s);let o=typeof r.name=="string"&&r.name.length>0?r.name:s.name??s.id;a.push({actionId:s.id,label:o})}return{orderedActions:n,menuChoices:a}}function V7(t){if(typeof t=="string")return t;if(t&&typeof t=="object"){let e=t.id;if(typeof e=="string")return e}}function kI(t){let e=[],i=new Map,n=Array.isArray(t.flowSequenceItemList)?t.flowSequenceItemList:[];for(let p of n){if(!p||typeof p!="object"||typeof p.id!="string")continue;let d=typeof p.name=="string"&&p.name.length>0?p.name:p.id,{orderedActions:h,menuChoices:g}=F7(p,p.id,e);i.set(p.id,{id:p.id,name:d,startAction:typeof p.startAction=="string"?p.startAction:void 0,orderedActions:h,menuChoices:g})}let a=new Set;for(let{id:p,orderedActions:d}of i.values())for(let h of d){if(typeof h.id!="string"){e.push({code:"MISSING_ACTION_ID",message:`Action of type "${h.__type??"(missing)"}" in task ${p} has no id and was skipped.`,taskId:p});continue}a.has(h.id)&&e.push({code:"DUPLICATE_ACTION_ID",message:`Duplicate action id "${h.id}" in task ${p}; the later definition wins.`,nodeId:h.id,taskId:p}),a.add(h.id)}let r=[...i.keys()],s=t.initialSequence,o=typeof s=="string"&&i.has(s),l=o?[s,...r.filter(p=>p!==s)]:r;typeof s=="string"&&s.length>0&&!o&&e.push({code:"UNRESOLVED_INITIAL_SEQUENCE",message:`initialSequence "${s}" matches no task; using declaration order.`});let u=new Set,c=t.uiMetaData?.task;if(Array.isArray(c))for(let p of c){let d=V7(p);d!==void 0&&u.add(d)}return{flowName:typeof t.name=="string"?t.name:"",flowType:typeof t.type=="string"?t.type:"",tasks:i,taskOrder:l,entryTaskId:o?s:void 0,reusableTaskIds:u,warnings:e}}var J7=new Set(["AskForNLUNextIntentAction","WaitForInputAction"]);function qI(t){let e=[],i=[];for(let n of t.taskOrder){let a=t.tasks.get(n);a&&e.push({id:vt(n),kind:"task-start",label:a.name,taskId:n,taskName:a.name,terminal:!1})}for(let{taskId:n,task:a,action:r,actionId:s,handler:o}of ad(t)){let l=r.__type,u=typeof r.name=="string"&&r.name.length>0?r.name:l??s;e.push({id:s,kind:"action",actionType:l,label:u,description:o.describe(r),taskId:n,taskName:a.name,terminal:o.isTerminal(r)}),TI(l)||i.push({code:"UNKNOWN_ACTION_TYPE",message:`Unknown action __type "${l??"(missing)"}" \u2014 handled generically.`,nodeId:s,taskId:n}),J7.has(l??"")&&i.push({code:"UNRESOLVED_INTENT_FANOUT",message:`Intent fan-out for ${s} is not resolved: per-intent routing (nluMetaData) is not modelled.`,nodeId:s,taskId:n});for(let c of o.outputs(r))e.push({id:ws(s,c.outputId),kind:"branch-output",label:c.label,taskId:n,taskName:a.name,terminal:c.terminal}),c.disabled&&i.push({code:"DISABLED_BRANCH",message:`Output ${c.outputId} of ${s} is disabled.`,nodeId:ws(s,c.outputId),taskId:n})}return{nodes:e,warnings:i}}function Nb(t){let e=new Map;for(let s of t.nodes.keys())e.set(s,0);let i=new Map,n=[],a=0;for(let s of t.roots){if(e.get(s)!==0)continue;e.set(s,1),i.set(s,a++);let o=[{node:s,index:0}];for(;o.length>0;){let l=o[o.length-1],u=t.adjacency.get(l.node)??[];if(l.indexp.code==="UNRESOLVED_INTENT_FANOUT");return{ok:!0,ir:yI(s,l,e,u),graph:s,warnings:[...e.warnings,...n,...r,...o]}}catch(e){return{ok:!1,error:{code:"INTERNAL",message:e instanceof Error?e.message:String(e)}}}}function _I(t,e){if(Array.isArray(t.actionList))for(let i of t.actionList)i&&typeof i=="object"&&e(i);if(Array.isArray(t.menuChoiceList))for(let i of t.menuChoiceList){if(!i||typeof i!="object")continue;let n=i.action;!n||typeof n!="object"||e(n,Z7(i))}}function Z7(t){let e={};return typeof t.id=="string"&&(e.id=t.id),typeof t.name=="string"&&(e.name=t.name),typeof t.digit=="string"&&(e.digit=t.digit),e}function HI(t){if(t===null||typeof t!="object"||Array.isArray(t))return[];let e=t.flowSequenceItemList;return Array.isArray(e)?e:[]}function Wb(t,e){let i=[],n=new Set;for(let o of Array.isArray(e)?e:[])typeof o=="string"&&!n.has(o)&&(n.add(o),i.push(o));if(i.length===0)return{found:[],notFound:[]};let a=new Map;for(let o of HI(t)){if(!o||typeof o!="object"||typeof o.id!="string")continue;let l=o.id,u=typeof o.name=="string"&&o.name.length>0?o.name:l;_I(o,(c,p)=>{if(typeof c.id!="string"||!n.has(c.id))return;let d={actionId:c.id,action:c,taskId:l,taskName:u};p&&(d.menuChoice=p);let h=a.get(c.id);h?h.push(d):a.set(c.id,[d])})}let r=[],s=[];for(let o of i){let l=a.get(o);l?r.push(...l):s.push(o)}return{found:r,notFound:s}}var K7=64;function Q7(t,e){if(t instanceof RegExp){let n=new RegExp(t.source,t.flags);return a=>{n.lastIndex=0;let r=n.exec(a);return r?{index:r.index,length:r[0].length}:void 0}}if(typeof t!="string"||t.length===0)return;if(e?.caseSensitive===!0)return n=>{let a=n.indexOf(t);return a===-1?void 0:{index:a,length:t.length}};let i=t.toLowerCase();return n=>{let a=n.toLowerCase().indexOf(i);if(a===-1)return;let r=Math.min(a,n.length);return{index:r,length:Math.min(t.length,n.length-r)}}}function Y7(t,e,i){let n=[],a=0,r=new Set,s=(o,l,u)=>{if(typeof o=="string"){let c=e(o);c&&(a+=1,n.length=K7||r.has(o))){if(r.add(o),Array.isArray(o))for(let c=0;cn.length}}function Lb(t,e,i){let n=Q7(e,i);if(!n)return{hasMatches:!1};let a=i?.maxMatchesPerAction,r=typeof a=="number"&&a>0?Math.floor(a):Number.POSITIVE_INFINITY,s=[];for(let o of HI(t)){if(!o||typeof o!="object"||typeof o.id!="string")continue;let l=o.id,u=typeof o.name=="string"&&o.name.length>0?o.name:l;_I(o,(c,p)=>{if(typeof c.id!="string")return;let{hits:d,truncated:h}=Y7(c,n,r);if(d.length===0)return;let g={actionId:c.id,taskId:l,taskName:u,matchedPaths:d};typeof c.__type=="string"&&(g.actionType=c.__type),typeof c.name=="string"&&c.name.length>0&&(g.name=c.name),p&&(g.menuChoice=p),h&&(g.truncated=!0),s.push(g)})}return s.length>0?{hasMatches:!0,matches:s}:{hasMatches:!1}}async function Cs(t,e){try{return{ok:!0,configuration:await t.getFlowLatestconfiguration(e)}}catch(i){return{ok:!1,message:X7(e,i)}}}function X7(t,e){let i=e!==null&&typeof e=="object"&&"status"in e&&typeof e.status=="number"?e.status:void 0,n=e!==null&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&e.message.length>0?e.message:void 0;return i===404?`Flow "${t}" not found. Check the flow id.`:i===401?`Not authenticated with Genesys Cloud (401) fetching flow "${t}": the access token is missing or expired. The flow may well exist \u2014 re-authenticate (restart the MCP server) and retry rather than concluding anything about the flow.`:i===403?`Not authorised to read flow "${t}" (403): the OAuth client lacks permission or division access to it. The flow exists but this client cannot see it.`:i===429?`Rate limited by Genesys Cloud (429) fetching flow "${t}". Transient \u2014 wait and retry; this says nothing about the flow.`:i!==void 0&&i>=500?`Genesys Cloud returned ${i} fetching flow "${t}". Transient server-side error \u2014 retry; this says nothing about the flow.`:`Failed to fetch flow "${t}"`+(i!==void 0?` (HTTP ${i})`:"")+(n?`: ${n}`:".")+" Likely transient (network or gateway) \u2014 retry rather than concluding the flow does not exist."}var II=50;function eY(t){let e=[],i=new Map,n=!1;for(let a of t){let r=a.split("::")[0]||a;r!==a&&(n=!0),i.has(r)||(i.set(r,a),e.push(r))}return{lookupIds:e,requestedFor:i,strippedAny:n}}var iY={flowId:je.string().min(1).describe("The Genesys Cloud Architect flow ID"),actionIds:je.array(je.string().min(1)).min(1).max(II).describe(`Action GUIDs, taken from the \`id\` of flow_ir nodes whose \`kind\` is "action". Batch every action of interest into as few calls as possible rather than calling this tool once per action. Branch-output ids of the form \`::\` are also accepted; the suffix is stripped and the underlying action is returned. Maximum ${II} ids per call; chunk a larger set into successive calls.`)},RI=({architectApi:t})=>({config:{description:"Retrieves the raw Architect configuration of specific actions in a Genesys Cloud Architect flow: decision expressions, prompt text, data action inputs and outputs, and any other per-action settings that the flow_ir tool omits. Use flow_ir first to find action ids and to understand the control flow, then use this tool to find out what an action actually does. Do not use the raw fields returned here to make control-flow claims: flow_ir has already resolved those, and its answer accounts for branches the raw configuration does not reflect.",annotations:{title:"Flow Action",readOnlyHint:!0,destructiveHint:!1},inputSchema:iY},handler:async({flowId:e,actionIds:i})=>{let n=await Cs(t,e);if(!n.ok)return{isError:!0,content:[{type:"text",text:n.message}]};let{lookupIds:a,requestedFor:r,strippedAny:s}=eY(i),o=Wb(n.configuration,a),l=c=>({...c,actionId:r.get(c.actionId)??c.actionId}),u=[];return s&&u.push("Some requested ids were flow_ir synthetic node ids of the form ::; the suffix was stripped and the underlying action looked up, then reported under the id as requested. A ::start id identifies a task rather than an action, so it never matches."),o.notFound.length>0&&u.push("Ids in notFound are absent from this flow's latest configuration. The flow may have been redeployed since flow_ir was called, so re-run flow_ir and re-join rather than concluding those actions no longer exist."),{content:[{type:"text",text:JSON.stringify({flowId:e,found:o.found.map(l),notFound:o.notFound.map(c=>r.get(c)??c),...u.length>0?{notes:u}:{}})}]}}});function zI(t){let e=t.toUpperCase();return e.endsWith("FLOW")?e:`${e}FLOW`}function nY(t,e){let i={};for(let n of e){let a=n.type??"UNKNOWN";i[a]||(i[a]=[]),i[a].push({id:n.id??"",name:n.name??"",...n.version?{version:n.version}:{},deleted:n.deleted??!1,updated:n.updated??!1})}return{flow:{id:t.id??"",name:t.name,type:zI(t.type??""),version:t.publishedVersion?.commitVersion??"1"},dependencies:i}}var tY={flowId:je.string().min(1).describe("The Genesys Cloud Architect flow ID")},DI=({architectApi:t})=>({config:{description:"Retrieves all dependencies consumed by a Genesys Cloud Architect flow. Returns the flow metadata and its dependencies grouped by type.",annotations:{title:"Flow Dependencies",readOnlyHint:!0,destructiveHint:!1},inputSchema:tY},handler:async({flowId:e})=>{try{let i;try{i=await t.getFlow(e)}catch{return{isError:!0,content:[{type:"text",text:`Flow "${e}" not found.`}]}}let n=zI(i.type??""),a=i.publishedVersion?.commitVersion??"1",r=[],s=1;for(;;){let l=await t.getArchitectDependencytrackingConsumedresources(i.id,a,n,{pageSize:100,pageNumber:s});if(l.entities&&r.push(...l.entities),!l.nextUri)break;s++}let o=nY(i,r);return{content:[{type:"text",text:JSON.stringify(o)}]}}catch(i){return{isError:!0,content:[{type:"text",text:`Failed to retrieve flow dependencies: ${i instanceof Error?i.message:String(i)}`}]}}}});function aY(t,e){let i=t.find(r=>r.id===e);if(i)return{match:i};let n=e.toLowerCase(),a=t.filter(r=>r.name.toLowerCase()===n);return a.length>1?{ambiguous:a}:a[0]?{match:a[0]}:void 0}var rY={flowId:je.string().min(1).describe("The Genesys Cloud Architect flow ID"),task:je.string().min(1).optional().describe("Optional. Restrict the returned nodes to a single task, by task id or task name (case-insensitive). Use this to explore a large flow one task at a time. The full task list is always returned, and a node's predecessors and successors may reference nodes in other tasks, which will not appear in the filtered node list.")},GI=({architectApi:t})=>({config:{description:"Retrieves the intermediate representation (IR) of a Genesys Cloud Architect flow: a flat, ordered list of its actions with the branches connecting them. Use this to understand what an existing flow does. It answers what follows an action, which branch leads where, which actions are unreachable, and how tasks call each other.",annotations:{title:"Flow IR",readOnlyHint:!0,destructiveHint:!1},inputSchema:rY},handler:async({flowId:e,task:i})=>{let n=await Cs(t,e);if(!n.ok)return{isError:!0,content:[{type:"text",text:n.message}]};let a=Ub(n.configuration);if(!a.ok)return{isError:!0,content:[{type:"text",text:`Failed to parse flow "${e}" (${a.error.code}): ${a.error.message}`}]};let r=a.ir;if(typeof i=="string"){let s=aY(r.tasks,i);if(!s){let o=r.tasks.map(l=>l.name).join(", ");return{isError:!0,content:[{type:"text",text:`No task matching "${i}" in flow "${e}". Available tasks: ${o||"(none)"}.`}]}}if("ambiguous"in s){let o=s.ambiguous.map(l=>`"${l.name}" (id: ${l.id})`).join(", ");return{isError:!0,content:[{type:"text",text:`Task name "${i}" is ambiguous in flow "${e}". It matches ${o}. Retry with the task id.`}]}}r={...r,nodes:r.nodes.filter(o=>o.taskId===s.match.id)}}return{content:[{type:"text",text:JSON.stringify({flowId:e,ir:r,warnings:a.warnings})}]}}});var $I=100,NI=10,xl=160,sY=512;function oY(t,e,i){if(!e)return{ok:!0,query:t};try{return{ok:!0,query:new RegExp(t,i?"":"i")}}catch(n){let a=n instanceof Error?n.message:String(n);return{ok:!1,error:`Invalid regular expression "${t}": ${a}. Set regex to false for a literal substring search.`}}}function lY(t,e,i){if(t.length<=xl)return t;let n=e+Math.floor(i/2),a=Math.max(0,Math.min(n-Math.floor(xl/2),t.length-xl)),r=a+xl;return`${a>0?"\u2026":""}${t.slice(a,r)}${r({config:{description:'Searches the raw Architect configuration of a Genesys Cloud Architect flow for text, and returns the actions containing it along with where in each action it matched. Answers "which actions reference X" \u2014 a queue name, a data action, a variable such as Flow.DNIS, a phrase in a prompt \u2014 in a single call. Use it instead of sweeping a flow with bulk flow_action lookups, which return whole action subtrees for actions that may not be relevant at all. Each returned actionId is an Architect GUID: it joins directly to flow_ir nodes whose kind is "action", and is accepted verbatim by flow_action. Search here to find the ids, then fetch those ids with flow_action when an excerpt is not enough. Matching is against string values only, never key names. A match in a wiring field locates text and is not a control-flow claim; flow_ir owns wiring.',annotations:{title:"Search In Flow",readOnlyHint:!0,destructiveHint:!1},inputSchema:cY},handler:async({flowId:e,pattern:i,regex:n,caseSensitive:a})=>{let r=oY(i,n,a);if(!r.ok)return{isError:!0,content:[{type:"text",text:r.error}]};let s=await Cs(t,e);if(!s.ok)return{isError:!0,content:[{type:"text",text:s.message}]};let o=s.configuration;if(!uY(o))return{isError:!0,content:[{type:"text",text:`The latest configuration of flow "${e}" has no flowSequenceItemList to search \u2014 the flow type may be unsupported. Nothing was searched, so this is not a zero-match result.`}]};let l=Lb(o,r.query,{caseSensitive:a,maxMatchesPerAction:NI}),u=l.hasMatches?l.matches:[],c=u.slice(0,$I),p=c.map(h=>({...h,matchedPaths:h.matchedPaths.map(g=>({path:g.path,excerpt:lY(g.value,g.matchIndex,g.matchLength)}))})),d=[];return u.length>c.length&&d.push(`${u.length} actions matched; only the first ${$I} are returned, in encounter order. Narrow the pattern to see the rest.`),c.some(h=>h.truncated)&&d.push(`Some actions matched in more than ${NI} places; matchedPaths is not exhaustive for entries marked truncated.`),c.some(h=>h.matchedPaths.some(g=>g.value.length>xl))&&d.push("Excerpts are clipped windows around the match, not whole values; fetch the action with flow_action when the full text matters."),{content:[{type:"text",text:JSON.stringify({flowId:e,pattern:i,totalMatchedActions:u.length,matchedActions:p,...d.length>0?{notes:d}:{}})}]}}});var Bb=new Map;function pY(t){let{id:e,previousTurn:i,...n}=t;return n}async function WI(t,e,i){let n=[],a=i;for(;n.push(pY(a)),Bb.set(e,a.id),a.nextActionType==="NoOp";)a=await t.postTextbotsBotflowsSessionTurns(e,{previousTurn:{id:a.id},inputEventType:"NoOp",inputEventUserInput:{mode:"Text",alternatives:[{transcript:{text:""}}]}});let r=a.nextActionType;return(r==="Disconnect"||r==="Exit")&&Bb.delete(e),{content:[{type:"text",text:JSON.stringify({sessionId:e,turns:n})}]}}var dY={flowId:je.string().optional().describe("The bot flow ID to test. Required when starting a new session."),sessionId:je.string().optional().describe("Session ID from a previous call. Required when continuing an existing conversation."),message:je.string().optional().describe("User message to send to the bot. Required when continuing a session.")},LI=({textbotsApi:t})=>({config:{description:"Tests a deployed Genesys Cloud Architect Bot Flow and Digital Bot Flow by simulating a text conversation. To start: provide flowId. To continue: provide the returned sessionId and a message. Turn tracking is managed server-side \u2014 only the sessionId is needed between calls. Returns { sessionId, turns[] } where each turn contains the raw API response (prompts with segments, outputLanguage, nextActionType, and action-specific data like modeConstraints or outputData). Multiple turns are returned when the flow sends consecutive messages (NoOp turns are automatically drained). nextActionType values: WaitForInput (send another message), Disconnect/Exit (conversation ended).",annotations:{title:"Test Bot Flow",readOnlyHint:!1,destructiveHint:!1},inputSchema:dY},handler:async({flowId:e,sessionId:i,message:n})=>{try{if(i&&e)return{isError:!0,content:[{type:"text",text:"Provide either flowId (to start) or sessionId (to continue), not both."}]};if(!i&&!e)return{isError:!0,content:[{type:"text",text:"Provide flowId to start a new session or sessionId to continue an existing one."}]};if(e){let s=await t.postTextbotsBotflowsSessions({flow:{id:e},externalSessionId:"",inputData:{variables:{}},channel:{inputModes:["Text"],outputModes:["Text"],name:"Messaging",userAgent:{name:"GenesysWebWidget"}},language:""}),o=await t.postTextbotsBotflowsSessionTurns(s.id,{inputEventType:"NoOp",inputEventUserInput:{mode:"Text",alternatives:[{transcript:{text:""}}]}});return WI(t,s.id,o)}if(!i||!n)return{isError:!0,content:[{type:"text",text:"A message is required when continuing an existing session."}]};let a=Bb.get(i);if(!a)return{isError:!0,content:[{type:"text",text:`No active session found for ID "${i}". It may have expired or already ended. Start a new session with a flowId.`}]};let r=await t.postTextbotsBotflowsSessionTurns(i,{previousTurn:{id:a},inputEventType:"UserInput",inputEventUserInput:{mode:"Text",alternatives:[{transcript:{text:n}}]}});return WI(t,i,r)}catch(a){return{isError:!0,content:[{type:"text",text:`Bot flow test failed: ${a instanceof Error?a.message:JSON.stringify(a)}`}]}}}});var Fb=je.object({GENESYS_REGION:je.string().min(1),GENESYS_CLIENT_ID:je.string().min(1),GENESYS_CLIENT_SECRET:je.string().min(1),DEPLOY_SCRIPT_PATH:je.string().min(1),PREVENT_LOGIN:je.enum(["TRUE","FALSE"]).default("FALSE").transform(t=>t==="TRUE")}).safeParse(process.env);if(!Fb.success){let t=Fb.error.issues.map(e=>e.path[0]).join(` `);console.error(`Missing required environment variables: - ${t}`),process.exit(1)}var Qt=Fb.data,Yt=new Cc({name:"genesys-cloud-architect",version:"1.0.9"}),Ml=new rd.default.ArchitectApi,BI=bI({architectApi:Ml});Yt.registerTool("find_flow",BI.config,BI.handler);var FI=DI({architectApi:Ml});Yt.registerTool("flow_dependencies",FI.config,FI.handler);var VI=GI({architectApi:Ml});Yt.registerTool("flow_ir",VI.config,VI.handler);var JI=RI({architectApi:Ml});Yt.registerTool("flow_action",JI.config,JI.handler);var ZI=UI({architectApi:Ml});Yt.registerTool("search_in_flow",ZI.config,ZI.handler);var KI=AI({region:Qt.GENESYS_REGION,clientId:Qt.GENESYS_CLIENT_ID,clientSecret:Qt.GENESYS_CLIENT_SECRET,deployScriptPath:Qt.DEPLOY_SCRIPT_PATH});Yt.registerTool("deploy_flow",KI.config,KI.handler);var QI=LI({textbotsApi:new rd.default.TextbotsApi});Yt.registerTool("test_bot_flow",QI.config,QI.handler);(async()=>{if(Qt.PREVENT_LOGIN)console.warn("Login for Platform API skipped. Calling tools will result in an auth failure.");else{let e=rd.default.ApiClient.instance;e.setEnvironment(Qt.GENESYS_REGION),await e.loginClientCredentialsGrant(Qt.GENESYS_CLIENT_ID,Qt.GENESYS_CLIENT_SECRET)}let t=new bc;await Yt.connect(t)})().catch(t=>{console.error("Failed to start server:",t),process.exit(1)}); + ${t}`),process.exit(1)}var Qt=Fb.data,Yt=new Cc({name:"genesys-cloud-architect",version:"2.0.0"}),Ml=new rd.default.ArchitectApi,BI=bI({architectApi:Ml});Yt.registerTool("find_flow",BI.config,BI.handler);var FI=DI({architectApi:Ml});Yt.registerTool("flow_dependencies",FI.config,FI.handler);var VI=GI({architectApi:Ml});Yt.registerTool("flow_ir",VI.config,VI.handler);var JI=RI({architectApi:Ml});Yt.registerTool("flow_action",JI.config,JI.handler);var ZI=UI({architectApi:Ml});Yt.registerTool("search_in_flow",ZI.config,ZI.handler);var KI=AI({region:Qt.GENESYS_REGION,clientId:Qt.GENESYS_CLIENT_ID,clientSecret:Qt.GENESYS_CLIENT_SECRET,deployScriptPath:Qt.DEPLOY_SCRIPT_PATH});Yt.registerTool("deploy_flow",KI.config,KI.handler);var QI=LI({textbotsApi:new rd.default.TextbotsApi});Yt.registerTool("test_bot_flow",QI.config,QI.handler);(async()=>{if(Qt.PREVENT_LOGIN)console.warn("Login for Platform API skipped. Calling tools will result in an auth failure.");else{let e=rd.default.ApiClient.instance;e.setEnvironment(Qt.GENESYS_REGION),await e.loginClientCredentialsGrant(Qt.GENESYS_CLIENT_ID,Qt.GENESYS_CLIENT_SECRET)}let t=new bc;await Yt.connect(t)})().catch(t=>{console.error("Failed to start server:",t),process.exit(1)}); /*! Bundled license information: mime-db/index.js: