@redocly/replay 0.27.0-next.8 → 0.27.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.
Files changed (69) hide show
  1. package/dist/{replay-AiChatProvider-DHIxHTKX.js → replay-AiChatProvider-LQhrLIDL.js} +44 -44
  2. package/dist/{replay-AiChatProvider-O8HHQobN.js → replay-AiChatProvider-Oms5CFgT.js} +1 -1
  3. package/dist/{replay-AiChatSqliteDBStorage-DNMrzkJg.js → replay-AiChatSqliteDBStorage-3-p1mthX.js} +1 -1
  4. package/dist/{replay-AiChatSqliteDBStorage-DjUq9VX3.js → replay-AiChatSqliteDBStorage-GZibdHOQ.js} +1 -1
  5. package/dist/replay-AiPanel-BvwwBTh1.js +742 -0
  6. package/dist/{replay-AiPanel-CR815YqV.js → replay-AiPanel-lcDNvgo0.js} +973 -1176
  7. package/dist/replay-FileWatcher-ClVd_wG0.js +1 -0
  8. package/dist/replay-FileWatcher-DR-wJLe2.js +343 -0
  9. package/dist/replay-Observable-D6wKbFwB.js +31 -0
  10. package/dist/replay-Observable-bjJ6wkRB.js +1 -0
  11. package/dist/replay-SemanticSearchService-CCqwCRo6.js +1 -0
  12. package/dist/replay-SemanticSearchService-U1eXQGfF.js +723 -0
  13. package/dist/{replay-SqliteDBStorage-B3oYWXem.js → replay-SqliteDBStorage-Dn6DoVWW.js} +1 -1
  14. package/dist/{replay-SqliteDBStorage-CC9kLioX.js → replay-SqliteDBStorage-d_ZK6ScA.js} +1 -1
  15. package/dist/replay-TauriFileSystemAdapter-CpiUuG3T.js +99 -0
  16. package/dist/replay-TauriFileSystemAdapter-dwJ0xBYr.js +1 -0
  17. package/dist/replay-TauriRootStorage-CuVbYMXX.js +605 -0
  18. package/dist/replay-TauriRootStorage-DhzbAahU.js +1 -0
  19. package/dist/{replay-agent-loop-CTq5eJ4u.js → replay-agent-loop-BLSu4v_O.js} +1 -1
  20. package/dist/{replay-agent-loop-CCYOzyHo.js → replay-agent-loop-DgEHdXUt.js} +11 -11
  21. package/dist/{replay-ai-chat-mappers-C8y5UhCq.js → replay-ai-chat-mappers-BvfcEubB.js} +5 -5
  22. package/dist/{replay-ai-chat-mappers-B_wovMvG.js → replay-ai-chat-mappers-Dy2kJ7ZG.js} +1 -1
  23. package/dist/replay-core-BJmXmoC5.js +1 -0
  24. package/dist/replay-core-B_hiOZZr.js +10 -0
  25. package/dist/{replay-create-model-C5yvtnXA.js → replay-create-model-DNPFcOIp.js} +579 -578
  26. package/dist/{replay-create-model-CBCmuEKC.js → replay-create-model-bOIDB-e8.js} +10 -10
  27. package/dist/{replay-db-CCBQadnT.js → replay-db-BQGv3PGw.js} +1 -1
  28. package/dist/{replay-db-DfOjLqsq.js → replay-db-CMXZZs9v.js} +1 -1
  29. package/dist/{replay-external-resolver-BRouROm6.js → replay-external-resolver-mrykFC2h.js} +2 -2
  30. package/dist/{replay-external-resolver-B6tpqUZt.js → replay-external-resolver-n5OvQMRF.js} +1 -1
  31. package/dist/replay-index-3lwhSmvi.js +1 -0
  32. package/dist/{replay-index-BzzBKjHm.js → replay-index-Bc5RHu5L.js} +23771 -25420
  33. package/dist/replay-index-CFLu-XMV.js +25 -0
  34. package/dist/{replay-index-Xq6K7XSm.js → replay-index-CHGVyIdG.js} +1 -1
  35. package/dist/{replay-index-Cpkh9r0X.js → replay-index-CSR_qlua.js} +1 -1
  36. package/dist/replay-index-CepJ5Z0m.js +6875 -0
  37. package/dist/{replay-index-Bzttek8l.js → replay-index-CgCGhu4l.js} +6 -6
  38. package/dist/replay-index-DDjmUXWm.js +1 -0
  39. package/dist/replay-index-DiSy_1OY.js +21 -0
  40. package/dist/replay-index-Oct6Dygd.js +1 -0
  41. package/dist/{replay-index-B_OHqSlS.js → replay-index-QXosJxRc.js} +18 -18
  42. package/dist/replay-index-jkDlU0Lx.js +32 -0
  43. package/dist/{replay-lint-gtuMJgII.js → replay-lint-DoHQIATV.js} +122 -122
  44. package/dist/{replay-lint-DlDmPTBV.js → replay-lint-PWaLESz5.js} +8921 -8880
  45. package/dist/{replay-lint-graphql-DHOq8lRT.js → replay-lint-graphql-xh8VoAwd.js} +1 -1
  46. package/dist/{replay-lint-graphql-BQJ00lU4.js → replay-lint-graphql-zO8zunug.js} +1 -1
  47. package/dist/replay-periodic-revalidation-BoyLQHtg.js +1 -0
  48. package/dist/replay-periodic-revalidation-Dsp-n7ui.js +21 -0
  49. package/dist/replay-promise-map-limit-DRDkHc-b.js +1 -0
  50. package/dist/replay-promise-map-limit-Db_42GvV.js +14 -0
  51. package/dist/replay-resolve-B0AjmaE9.js +47 -0
  52. package/dist/{replay-resolve-DsgcWnjC.js → replay-resolve-MVe_8Ube.js} +1364 -1329
  53. package/dist/{replay-respect-run-7Cwe1_ri.js → replay-respect-run-BJsR4a4m.js} +1 -1
  54. package/dist/{replay-respect-run-D1zyh-5j.js → replay-respect-run-X4PSO6Fj.js} +3 -3
  55. package/dist/{replay-tauri-path-BAY3g5sW.js → replay-tauri-path-CkGiQWsb.js} +5 -5
  56. package/dist/{replay-tauri-path-CaVeI3a-.js → replay-tauri-path-D8FJsoZb.js} +1 -1
  57. package/dist/replay-useAiChatQueries-BXL-_N2Q.js +215 -0
  58. package/dist/{replay-useAiChatQueries-CxZNLVje.js → replay-useAiChatQueries-D7sHNAfV.js} +1078 -1022
  59. package/dist/{replay-validate-key-Cv0mvYDS.js → replay-validate-key-CmzSfORv.js} +1 -1
  60. package/dist/{replay-validate-key-Di8MCBz7.js → replay-validate-key-CtZEJRP7.js} +2 -2
  61. package/dist/replay.cjs +1 -1
  62. package/dist/replay.js +11 -11
  63. package/package.json +10 -9
  64. package/dist/replay-AiPanel-CfYBCkrN.js +0 -868
  65. package/dist/replay-index-C6SJPGDO.js +0 -23
  66. package/dist/replay-index-CUs62_1f.js +0 -1
  67. package/dist/replay-index-Dfnqt_IZ.js +0 -6899
  68. package/dist/replay-resolve-DqFS69S_.js +0 -47
  69. package/dist/replay-useAiChatQueries-D99tAUpY.js +0 -215
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("./replay-index-Dfnqt_IZ.js"),h0=require("./replay-resolve-DqFS69S_.js"),wu=require("./replay-lint-gtuMJgII.js");function q1(u){return C.isPlainObject(u)&&"name"in u&&"value"in u&&!("in"in u)}function ze(u){return C.isPlainObject(u)&&"in"in u&&typeof u.in=="string"&&["header","query","path","cookie"].includes(u.in)}const Z1=/^image\/(png|jpeg|gif|bmp|webp|svg\+xml)|application\/pdf$/;function ti(u){return u.startsWith("$file(")&&u.endsWith(")")?u.substring(7,u.length-2):u}const ha=async(u,a,e,r,i)=>{const n=C.pathBrowserifyExports.dirname(r),o=C.pathBrowserifyExports.resolve(n,ti(e));u.append(a,await i.options.requestFileLoader.getFileBody(o))},si=(u,a,e,r,i,n)=>{Object.entries(e).forEach(([o,s])=>{const E=n?`${n}[${o}]`:o;typeof s=="string"&&s.startsWith("$file(")&&s.endsWith(")")?u.push(ha(a,E,s,r,i)):Array.isArray(s)?s.forEach(l=>{typeof l=="string"&&l.startsWith("$file(")&&l.endsWith(")")?u.push(ha(a,E,l,r,i)):a.append(E,l.toString())}):C.isPlainObject(s)?si(u,a,s,r,i,E):(typeof s=="string"||typeof s=="number"||typeof s=="boolean")&&a.append(E,s.toString())})},U1=async(u,a,e,r)=>{if(C.isPlainObject(u)){const i=[];si(i,a,u,e,r),await Promise.all(i)}},Y1=async(u,a)=>{if(typeof u=="string"&&u.startsWith("$file(")&&u.endsWith(")")){const e=C.pathBrowserifyExports.resolve(C.pathBrowserifyExports.dirname(a.options.filePath),ti(u));return a.options.requestFileLoader.getFileBody(e)}else return u};async function Q1(u,a){if(!u)return{payload:void 0,contentType:void 0,encoding:void 0,replacements:void 0};const{payload:e,contentType:r}=u;if(r==="multipart/form-data"){const i=new FormData,n=C.pathBrowserifyExports.resolve(a.options.filePath);return await U1(e,i,n,a),{...u,payload:i}}else{if(r==="application/octet-stream"||typeof r=="string"&&Z1.test(r))return{...u,payload:await Y1(e,a),contentType:"application/octet-stream"};if(r==="application/x-www-form-urlencoded"&&typeof e=="string")return{...u,payload:Object.fromEntries(new URLSearchParams(e).entries()),contentType:"application/x-www-form-urlencoded"}}return u}function X1({payload:u,replacements:a,expressionContext:e,logger:r}){for(const i of a){const{target:n,value:o}=i;if(typeof n!="string")throw new Error(`Invalid JSON Pointer: ${n}`);try{const s=C.JsonPointerLib.get(u,n),E=C.evaluateRuntimeExpressionPayload({payload:o,context:e,logger:r});s!==void 0&&C.JsonPointerLib.set(u,n,E)}catch{throw new Error(`Invalid JSON Pointer: ${n}`)}}}const uo=["parameters","failureActions","successActions"];function eo(u,a){const{reference:e,value:r}=u;if(!uo.some(n=>e.includes(`$components.${n}`)))throw new Error("Invalid reference: available components are $components.parameters, $components.failureActions, or $components.successActions");const i=C.getValueFromContext({value:e,ctx:a,logger:a.options.logger});return C.isPlainObject(i)&&"value"in i&&r?{...i,value:r}:i}function k0(u,a){return"reference"in u?eo(u,a):u}const ru={SUCCESS_CRITERIA_CHECK:"success criteria check",STATUS_CODE_CHECK:"status code check",SCHEMA_CHECK:"schema check",CONTENT_TYPE_CHECK:"content-type check",GLOBAL_TIMEOUT_ERROR:"global timeout error",MAX_STEPS_REACHED_ERROR:"maximum steps reached",NETWORK_ERROR:"failed network request",UNEXPECTED_ERROR:"unexpected error"};class li extends Error{}class Ei extends li{}class Di extends li{}async function ao(u){const{descriptionPath:a,externalRefResolver:e,base:r}=u,i=await wu.bundle({base:r,ref:a,config:u.config,dereference:!0,externalRefResolver:e});if(!i)throw new Error(`Could not find source description file '${a}'.`);return i.bundle.parsed}const io={title:"[REPLACE WITH API title]",version:"[REPLACE WITH API version]"},pe=Symbol("skip");function c0(u){return u<10?"0"+u:u}function ro(u,a,e,r){var i=e?"":u.getUTCFullYear()+"-"+c0(u.getUTCMonth()+1)+"-"+c0(u.getUTCDate());return a||(i+="T"+c0(u.getUTCHours())+":"+c0(u.getUTCMinutes())+":"+c0(u.getUTCSeconds())+"Z"),i}function xi(u,a){return a>u.length?u.repeat(Math.trunc(a/u.length)+1).substring(0,a):u}function V0(...u){const a=e=>e&&typeof e=="object";return u.reduce((e,r)=>(Object.keys(r||{}).forEach(i=>{const n=e[i],o=r[i];a(n)&&a(o)?e[i]=V0(n,o):e[i]=o}),e),Array.isArray(u[u.length-1])?[]:{})}function no(u){var a=so(u),e=lo(a,a,a,a),r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{var n=e()*16%16|0;return(i=="x"?n:n&3|8).toString(16)});return r}function te(u){return{value:u==="object"?{}:u==="array"?[]:void 0}}function Vu(u,a){a&&u.pop()}function oo(u){return{name:u?.xml?.name||"",prefix:u?.xml?.prefix||"",namespace:u?.xml?.namespace||null,attribute:u?.xml?.attribute??!1,wrapped:u?.xml?.wrapped??!1}}function to(u){const a=u?.xml;return a?.nodeType?a.nodeType:a?.attribute===!0?"attribute":a?.wrapped===!0&&u?.type==="array"?"element":u?.$ref||u?.$dynamicRef||u?.type==="array"||u?.oneOf||u?.anyOf||u?.allOf?"none":"element"}function J0(u,a={},e={}){const{value:r}=u,{propertyName:i}=e,{name:n,prefix:o,namespace:s}=oo(a),E=to(a);let l=n||i?`${o?o+":":""}${n||i}`:null,D=typeof r=="object"?Array.isArray(r)?[...r]:{...r}:r;switch(E){case"attribute":l&&(l=`$${l}`);break;case"text":l="#text";break;case"cdata":l="#cdata";break;case"none":a.type==="array"?(l=null,a.example!==void 0&&(l=a.items?.xml?.name||l)):l=null;break;default:a.type==="array"&&Array.isArray(D)&&(D={[l]:[...D]});break}return s&&E!=="text"&&E!=="cdata"&&E!=="none"&&(typeof D=="object"?D[`$xmlns${o?":"+o:""}`]=s:D={[`$xmlns${o?":"+o:""}`]:s,"#text":D}),{propertyName:l,value:D}}function so(u){var a=0;if(u.length==0)return a;for(var e=0;e<u.length;e++){var r=u.charCodeAt(e);a=(a<<5)-a+r,a=a&a}return a}function lo(u,a,e,r){return function(){u|=0,a|=0,e|=0,r|=0;var i=u-(a<<27|a>>>5)|0;return u=a^(e<<17|e>>>15),a=e+r|0,e=r+i|0,r=u+i|0,(r>>>0)/4294967296}}function Eo(u,a,e,r,i){let n=Su(u,e,r);const o=[];for(let s of a){const{type:E,readOnly:l,writeOnly:D,value:d}=Su({type:n.type,...s},e,r,{...i,isAllOfChild:!0});n.type&&E&&E!==n.type&&(console.warn("allOf: schemas with different types can't be merged"),n.type=E),n.type=n.type||E,n.readOnly=n.readOnly||l,n.writeOnly=n.writeOnly||D,d!=null&&o.push(d)}if(n.type==="object"){n.value=V0(n.value||{},...o.filter(s=>typeof s=="object"));for(const s in n.value)n.value[s]===pe&&delete n.value[s];return n}else{n.type==="array"&&(e.quiet||console.warn('OpenAPI Sampler: found allOf with "array" type. Result may be incorrect'));const s=o[o.length-1];return n.value=s??n.value,n}}const ga={multipleOf:"number",maximum:"number",exclusiveMaximum:"number",minimum:"number",exclusiveMinimum:"number",maxLength:"string",minLength:"string",pattern:"string",items:"array",maxItems:"array",minItems:"array",uniqueItems:"array",additionalItems:"array",maxProperties:"object",minProperties:"object",required:"object",additionalProperties:"object",properties:"object",patternProperties:"object",dependencies:"object"};function z0(u){if(u.type!==void 0)return Array.isArray(u.type)?u.type.length===0?null:u.type[0]:u.type;const a=Object.keys(ga);for(var e=0;e<a.length;e++){let r=a[e],i=ga[r];if(u[r]!==void 0)return i}return null}let N0={},zu=[];function Do(){N0={},zu=[]}function ci(u){let a;return u.const!==void 0?a=u.const:u.examples!==void 0&&u.examples.length?a=u.examples[0]:u.enum!==void 0&&u.enum.length?a=u.enum[0]:u.default!==void 0&&(a=u.default),a}function pa(u){const a=ci(u);if(a!==void 0)return{value:a,readOnly:u.readOnly,writeOnly:u.writeOnly,type:null}}function Su(u,a,e,r){if(r){if(zu.includes(u))return te(z0(u));zu.push(u)}if(r&&r.depth>a.maxSampleDepth)return Vu(zu,r),te(z0(u));if(u.$ref){if(!e)throw new Error("Your schema contains $ref. You must provide full specification in the third parameter.");let s=decodeURIComponent(u.$ref);s.startsWith("#")&&(s=s.substring(1));const E=C.JsonPointerLib.get(e,s);let l;if(N0[s]!==!0){N0[s]=!0;const D=Su(E,a,e,r);if(a.format==="xml"){const d=s.split("/").pop(),F={...r,propertyName:r?.propertyName||d},{propertyName:k,value:B}=J0(D,E,F);l={...D,value:{[k||"root"]:B}}}else l=D;N0[s]=!1}else{const D=z0(E);l=te(D)}return Vu(zu,r),l}if(u.example!==void 0)return Vu(zu,r),{value:u.example,readOnly:u.readOnly,writeOnly:u.writeOnly,type:u.type};if(u.allOf!==void 0)return Vu(zu,r),pa(u)||Eo({...u,allOf:void 0},u.allOf,a,e,r);if(u.oneOf&&u.oneOf.length){u.anyOf&&(a.quiet||console.warn("oneOf and anyOf are not supported on the same level. Skipping anyOf")),Vu(zu,r);const s=Object.assign({readOnly:u.readOnly,writeOnly:u.writeOnly},u.oneOf[0]);return o(u,s)}if(u.anyOf&&u.anyOf.length){Vu(zu,r);const s=Object.assign({readOnly:u.readOnly,writeOnly:u.writeOnly},u.anyOf[0]);return o(u,s)}if(u.if&&u.then){Vu(zu,r);const{if:s,then:E,...l}=u;return Su(V0(l,s,E),a,e,r)}let i=ci(u),n=null;if(i===void 0){i=null,n=u.type,Array.isArray(n)&&u.type.length>0&&(n=u.type[0]),n||(n=z0(u));let s=Fi[n];s&&(i=s(u,a,e,r))}return Vu(zu,r),{value:i,readOnly:u.readOnly,writeOnly:u.writeOnly,type:n};function o(s,E){const l=pa(s);if(l!==void 0)return l;const D=Su({...s,oneOf:void 0,anyOf:void 0},a,e,r),d=Su(E,a,e,r);if(typeof D.value=="object"&&typeof d.value=="object"){const F=V0(D.value,d.value);return{...d,value:F}}return d}}function xo(u,a={},e,r){const i=r&&r.depth||1;let n=Math.min(u.maxItems!=null?u.maxItems:1/0,u.minItems||1);const o=u.prefixItems||u.items||u.contains;Array.isArray(o)&&(n=Math.max(n,o.length));let s=l=>Array.isArray(o)?o[l]||{}:o||{},E=[];if(!o)return E;for(let l=0;l<n;l++){let D=s(l),{value:d}=Su(D,a,e,{depth:i+1});if(a?.format==="xml"){const{value:F,propertyName:k}=J0({value:d},D,r);k?(E?.[k]||(E={...E,[k]:[]}),E[k].push(F)):E={...E,...F}}else E.push(d)}if(a?.format==="xml"&&i===1){const{value:l,propertyName:D}=J0({value:null},u,r);D&&(l?E=Array.isArray(E)?{[D]:{...l,...E.map(d=>({"#text":{...d}}))}}:{[D]:{...E,...l}}:E={[D]:E})}return E}function co(u){return!0}function di(u){let a=0;if(u.type==="number"&&(u.format==="float"||u.format==="double")&&(a=.1),typeof u.exclusiveMinimum=="boolean"||typeof u.exclusiveMaximum=="boolean"){if(u.maximum&&u.minimum)return a=u.exclusiveMinimum?Math.floor(u.minimum)+1:u.minimum,(u.exclusiveMaximum&&a>=u.maximum||!u.exclusiveMaximum&&a>u.maximum)&&(a=(u.maximum+u.minimum)/2),a;if(u.minimum)return u.exclusiveMinimum?Math.floor(u.minimum)+1:u.minimum;if(u.maximum)return u.exclusiveMaximum?u.maximum>0?0:Math.floor(u.maximum)-1:u.maximum>0?0:u.maximum}else{if(u.minimum)return u.minimum;u.exclusiveMinimum?(a=Math.floor(u.exclusiveMinimum)+1,a===u.exclusiveMaximum&&(a=(a+Math.floor(u.exclusiveMaximum)-1)/2)):u.exclusiveMaximum?a=Math.floor(u.exclusiveMaximum)-1:u.maximum&&(a=u.maximum)}return a}function mo(u,a={},e,r){let i={};const n=r&&r.depth||1;if(u&&typeof u.properties=="object"){const o=Array.isArray(u.required)?u.required:[],s={};for(const E of o)s[E]=!0;Object.keys(u.properties).forEach(E=>{if(a.skipNonRequired&&!s.hasOwnProperty(E))return;const l=Su(u.properties[E],a,e,{propertyName:E,depth:n+1});if(a.skipReadOnly&&l.readOnly){r?.isAllOfChild&&(i[E]=pe);return}if(a.skipWriteOnly&&l.writeOnly){r?.isAllOfChild&&(i[E]=pe);return}if(a?.format==="xml"){const{propertyName:D,value:d}=J0(l,u.properties[E],{propertyName:E});D?i[D]=d:d!==null&&typeof d=="object"&&(i={...i,...d})}else i[E]=l.value})}if(u&&typeof u.additionalProperties=="object"){const o=u.additionalProperties["x-additionalPropertiesName"]||"property";i[`${String(o)}1`]=Su(u.additionalProperties,a,e,{depth:n+1}).value,i[`${String(o)}2`]=Su(u.additionalProperties,a,e,{depth:n+1}).value}if(u&&typeof u.properties=="object"&&u.maxProperties!==void 0&&Object.keys(i).length>u.maxProperties){const o={};let s=0;(Array.isArray(u.required)?u.required:[]).forEach(l=>{i[l]!==void 0&&(o[l]=i[l],s++)}),Object.keys(i).forEach(l=>{s<u.maxProperties&&!o.hasOwnProperty(l)&&(o[l]=i[l],s++)}),i=o}return i}function g0(u,a){return u}function va(u,a,e){let r=1;if(u)switch(u){case"?":{r=0;break}case"*":{r=g0(0);break}case"+":{r=g0(1);break}default:throw new Error("Unknown quantifier symbol provided.")}else a!=null&&e!=null?r=g0(parseInt(a)):a!=null&&e==null&&(r=parseInt(a));return r}function Fo(u){let a=!1;u instanceof RegExp&&(a=u.flags.includes("i"),u=u.toString(),u=u.match(/\/(.+?)\//)?.[1]??""),u=u.replace(/^(\^)?(.*?)(\$)?$/,"$2");let e,r,i;const n=/([.A-Za-z0-9])(?:\{(\d+)(?:\,(\d+)|)\}|(\?|\*|\+))(?![^[]*]|[^{]*})/;let o=u.match(n);for(;o!=null;){const d=o[2],F=o[3],k=o[4];i=va(k,d,F),u=u.slice(0,o.index)+o[1].repeat(i)+u.slice(o.index+o[0].length),o=u.match(n)}const s=/(\d-\d|\w-\w|\d|\w|[-!@#$&()`.+,/"])/,E=/\[(\^|)(-|)(.+?)\](?:\{(\d+)(?:\,(\d+)|)\}|(\?|\*|\+)|)/;for(o=u.match(E);o!=null;){const d=o[1]==="^",F=o[2]==="-",k=o[4],B=o[5],y=o[6],K=[];let V=o[3],H=V.match(s);for(F&&K.push(45);H!=null;){if(H[0].indexOf("-")===-1)a&&isNaN(Number(H[0]))?(K.push(H[0].toUpperCase().charCodeAt(0)),K.push(H[0].toLowerCase().charCodeAt(0))):K.push(H[0].charCodeAt(0));else{const v=H[0].split("-").map(h=>h.charCodeAt(0));if(e=v[0],r=v[1],e>r)throw new Error("Character range provided is out of order.");for(let h=e;h<=r;h++)if(a&&isNaN(Number(String.fromCharCode(h)))){const z=String.fromCharCode(h);K.push(z.toUpperCase().charCodeAt(0)),K.push(z.toLowerCase().charCodeAt(0))}else K.push(h)}V=V.substring(H[0].length),H=V.match(s)}if(i=va(y,k,B),d){let v=-1;for(let h=48;h<=57;h++){if(v=K.indexOf(h),v>-1){K.splice(v,1);continue}K.push(h)}for(let h=65;h<=90;h++){if(v=K.indexOf(h),v>-1){K.splice(v,1);continue}K.push(h)}for(let h=97;h<=122;h++){if(v=K.indexOf(h),v>-1){K.splice(v,1);continue}K.push(h)}}const G=Array.from({length:i},()=>String.fromCharCode(K[g0(0)])).join("");u=u.slice(0,o.index)+G+u.slice(o.index+o[0].length),o=u.match(E)}const l=/(.)\{(\d+)\,(\d+)\}/;for(o=u.match(l);o!=null;){if(e=parseInt(o[2]),r=parseInt(o[3]),e>r)throw new Error("Numbers out of order in {} quantifier.");i=g0(e),u=u.slice(0,o.index)+o[1].repeat(i)+u.slice(o.index+o[0].length),o=u.match(l)}const D=/(.)\{(\d+)\}/;for(o=u.match(D);o!=null;)i=parseInt(o[2]),u=u.slice(0,o.index)+o[1].repeat(i)+u.slice(o.index+o[0].length),o=u.match(D);return u}const ko="qwerty!@#$%^123456";function Co(){return"user@example.com"}function ho(){return"пошта@укр.нет"}function go(u,a){let e="pa$$word";return u>e.length&&(e+="_",e+=xi(ko,u-e.length).substring(0,u-e.length)),e}function Se({min:u,max:a,omitTime:e,omitDate:r}){let i=ro(new Date("2019-08-24T14:15:22.123Z"),e,r);return i.length<u&&console.warn(`Using minLength = ${u} is incorrect with format "date-time"`),a&&i.length>a&&console.warn(`Using maxLength = ${a} is incorrect with format "date-time"`),i}function po(u,a){return Se({min:u,max:a,omitTime:!1,omitDate:!1})}function vo(u,a){return Se({min:u,max:a,omitTime:!0,omitDate:!1})}function bo(u,a){return Se({min:u,max:a,omitTime:!1,omitDate:!0}).slice(1)}function mi(u,a,e,r,i=!1){if(r&&i)return Fo(r);let n=xi("string",u);return a&&n.length>a&&(n=n.substring(0,a)),n}function Bo(){return"192.168.0.1"}function Ao(){return"2001:0db8:85a3:0000:0000:8a2e:0370:7334"}function yo(){return"example.com"}function fo(){return"приклад.укр"}function zo(){return"http://example.com"}function So(){return"../dictionary"}function Mo(){return"http://example.com/{endpoint}"}function jo(){return"http://example.com/entity/1"}function Po(){return"/entity/1"}function wo(u,a,e){return no(e||"id")}function Ko(){return"/json/pointer"}function To(){return"1/relative/json/pointer"}function Lo(){return"/regex/"}const No={email:Co,"idn-email":ho,password:go,"date-time":po,date:vo,time:bo,ipv4:Bo,ipv6:Ao,hostname:yo,"idn-hostname":fo,iri:jo,"iri-reference":Po,uri:zo,"uri-reference":So,"uri-template":Mo,uuid:wo,default:mi,"json-pointer":Ko,"relative-json-pointer":To,regex:Lo};function Ro(u,a,e,r){let i=u.format||"default",n=No[i]||mi,o=r&&r.propertyName;return n(u.minLength||0,u.maxLength,o,u.pattern,a?.enablePatterns)}var Fi={};const Ho={skipReadOnly:!1,maxSampleDepth:15};function Go(u,a){if(!u)throw new Error("Unknown format output for building XML.");return(Array.isArray(u)||Object.keys(u).length>1)&&(u={[a?.xml?.name||"root"]:u}),new C.Builder({ignoreAttributes:!1,format:!0,attributeNamePrefix:"$",textNodeName:"#text",cdataPropName:"#cdata"}).build(u)}function Vo(u,a,e){let r=Object.assign({},Ho,a);Do();let i=Su(u,r,e).value;return r?.format==="xml"?Go(i,u):i}function l0(u,a){Fi[u]=a}l0("array",xo);l0("boolean",co);l0("integer",di);l0("number",di);l0("object",mo);l0("string",Ro);function ki(u,a){if(u)try{return Vo(u,{skipReadOnly:!0,skipNonRequired:!1,quiet:!0})}catch(e){a.error(C.bgRed(" Error while generating test data from JSON Schema ")+`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("./replay-index-CepJ5Z0m.js"),h0=require("./replay-resolve-B0AjmaE9.js"),wu=require("./replay-lint-DoHQIATV.js");function q1(u){return C.isPlainObject(u)&&"name"in u&&"value"in u&&!("in"in u)}function ze(u){return C.isPlainObject(u)&&"in"in u&&typeof u.in=="string"&&["header","query","path","cookie"].includes(u.in)}const Z1=/^image\/(png|jpeg|gif|bmp|webp|svg\+xml)|application\/pdf$/;function ti(u){return u.startsWith("$file(")&&u.endsWith(")")?u.substring(7,u.length-2):u}const ha=async(u,a,e,r,i)=>{const n=C.pathBrowserifyExports.dirname(r),o=C.pathBrowserifyExports.resolve(n,ti(e));u.append(a,await i.options.requestFileLoader.getFileBody(o))},si=(u,a,e,r,i,n)=>{Object.entries(e).forEach(([o,s])=>{const E=n?`${n}[${o}]`:o;typeof s=="string"&&s.startsWith("$file(")&&s.endsWith(")")?u.push(ha(a,E,s,r,i)):Array.isArray(s)?s.forEach(l=>{typeof l=="string"&&l.startsWith("$file(")&&l.endsWith(")")?u.push(ha(a,E,l,r,i)):a.append(E,l.toString())}):C.isPlainObject(s)?si(u,a,s,r,i,E):(typeof s=="string"||typeof s=="number"||typeof s=="boolean")&&a.append(E,s.toString())})},U1=async(u,a,e,r)=>{if(C.isPlainObject(u)){const i=[];si(i,a,u,e,r),await Promise.all(i)}},Y1=async(u,a)=>{if(typeof u=="string"&&u.startsWith("$file(")&&u.endsWith(")")){const e=C.pathBrowserifyExports.resolve(C.pathBrowserifyExports.dirname(a.options.filePath),ti(u));return a.options.requestFileLoader.getFileBody(e)}else return u};async function Q1(u,a){if(!u)return{payload:void 0,contentType:void 0,encoding:void 0,replacements:void 0};const{payload:e,contentType:r}=u;if(r==="multipart/form-data"){const i=new FormData,n=C.pathBrowserifyExports.resolve(a.options.filePath);return await U1(e,i,n,a),{...u,payload:i}}else{if(r==="application/octet-stream"||typeof r=="string"&&Z1.test(r))return{...u,payload:await Y1(e,a),contentType:"application/octet-stream"};if(r==="application/x-www-form-urlencoded"&&typeof e=="string")return{...u,payload:Object.fromEntries(new URLSearchParams(e).entries()),contentType:"application/x-www-form-urlencoded"}}return u}function X1({payload:u,replacements:a,expressionContext:e,logger:r}){for(const i of a){const{target:n,value:o}=i;if(typeof n!="string")throw new Error(`Invalid JSON Pointer: ${n}`);try{const s=C.JsonPointerLib.get(u,n),E=C.evaluateRuntimeExpressionPayload({payload:o,context:e,logger:r});s!==void 0&&C.JsonPointerLib.set(u,n,E)}catch{throw new Error(`Invalid JSON Pointer: ${n}`)}}}const uo=["parameters","failureActions","successActions"];function eo(u,a){const{reference:e,value:r}=u;if(!uo.some(n=>e.includes(`$components.${n}`)))throw new Error("Invalid reference: available components are $components.parameters, $components.failureActions, or $components.successActions");const i=C.getValueFromContext({value:e,ctx:a,logger:a.options.logger});return C.isPlainObject(i)&&"value"in i&&r?{...i,value:r}:i}function k0(u,a){return"reference"in u?eo(u,a):u}const ru={SUCCESS_CRITERIA_CHECK:"success criteria check",STATUS_CODE_CHECK:"status code check",SCHEMA_CHECK:"schema check",CONTENT_TYPE_CHECK:"content-type check",GLOBAL_TIMEOUT_ERROR:"global timeout error",MAX_STEPS_REACHED_ERROR:"maximum steps reached",NETWORK_ERROR:"failed network request",UNEXPECTED_ERROR:"unexpected error"};class li extends Error{}class Ei extends li{}class Di extends li{}async function ao(u){const{descriptionPath:a,externalRefResolver:e,base:r}=u,i=await wu.bundle({base:r,ref:a,config:u.config,dereference:!0,externalRefResolver:e});if(!i)throw new Error(`Could not find source description file '${a}'.`);return i.bundle.parsed}const io={title:"[REPLACE WITH API title]",version:"[REPLACE WITH API version]"},pe=Symbol("skip");function c0(u){return u<10?"0"+u:u}function ro(u,a,e,r){var i=e?"":u.getUTCFullYear()+"-"+c0(u.getUTCMonth()+1)+"-"+c0(u.getUTCDate());return a||(i+="T"+c0(u.getUTCHours())+":"+c0(u.getUTCMinutes())+":"+c0(u.getUTCSeconds())+"Z"),i}function xi(u,a){return a>u.length?u.repeat(Math.trunc(a/u.length)+1).substring(0,a):u}function V0(...u){const a=e=>e&&typeof e=="object";return u.reduce((e,r)=>(Object.keys(r||{}).forEach(i=>{const n=e[i],o=r[i];a(n)&&a(o)?e[i]=V0(n,o):e[i]=o}),e),Array.isArray(u[u.length-1])?[]:{})}function no(u){var a=so(u),e=lo(a,a,a,a),r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{var n=e()*16%16|0;return(i=="x"?n:n&3|8).toString(16)});return r}function te(u){return{value:u==="object"?{}:u==="array"?[]:void 0}}function Vu(u,a){a&&u.pop()}function oo(u){return{name:u?.xml?.name||"",prefix:u?.xml?.prefix||"",namespace:u?.xml?.namespace||null,attribute:u?.xml?.attribute??!1,wrapped:u?.xml?.wrapped??!1}}function to(u){const a=u?.xml;return a?.nodeType?a.nodeType:a?.attribute===!0?"attribute":a?.wrapped===!0&&u?.type==="array"?"element":u?.$ref||u?.$dynamicRef||u?.type==="array"||u?.oneOf||u?.anyOf||u?.allOf?"none":"element"}function J0(u,a={},e={}){const{value:r}=u,{propertyName:i}=e,{name:n,prefix:o,namespace:s}=oo(a),E=to(a);let l=n||i?`${o?o+":":""}${n||i}`:null,D=typeof r=="object"?Array.isArray(r)?[...r]:{...r}:r;switch(E){case"attribute":l&&(l=`$${l}`);break;case"text":l="#text";break;case"cdata":l="#cdata";break;case"none":a.type==="array"?(l=null,a.example!==void 0&&(l=a.items?.xml?.name||l)):l=null;break;default:a.type==="array"&&Array.isArray(D)&&(D={[l]:[...D]});break}return s&&E!=="text"&&E!=="cdata"&&E!=="none"&&(typeof D=="object"?D[`$xmlns${o?":"+o:""}`]=s:D={[`$xmlns${o?":"+o:""}`]:s,"#text":D}),{propertyName:l,value:D}}function so(u){var a=0;if(u.length==0)return a;for(var e=0;e<u.length;e++){var r=u.charCodeAt(e);a=(a<<5)-a+r,a=a&a}return a}function lo(u,a,e,r){return function(){u|=0,a|=0,e|=0,r|=0;var i=u-(a<<27|a>>>5)|0;return u=a^(e<<17|e>>>15),a=e+r|0,e=r+i|0,r=u+i|0,(r>>>0)/4294967296}}function Eo(u,a,e,r,i){let n=Su(u,e,r);const o=[];for(let s of a){const{type:E,readOnly:l,writeOnly:D,value:d}=Su({type:n.type,...s},e,r,{...i,isAllOfChild:!0});n.type&&E&&E!==n.type&&(console.warn("allOf: schemas with different types can't be merged"),n.type=E),n.type=n.type||E,n.readOnly=n.readOnly||l,n.writeOnly=n.writeOnly||D,d!=null&&o.push(d)}if(n.type==="object"){n.value=V0(n.value||{},...o.filter(s=>typeof s=="object"));for(const s in n.value)n.value[s]===pe&&delete n.value[s];return n}else{n.type==="array"&&(e.quiet||console.warn('OpenAPI Sampler: found allOf with "array" type. Result may be incorrect'));const s=o[o.length-1];return n.value=s??n.value,n}}const ga={multipleOf:"number",maximum:"number",exclusiveMaximum:"number",minimum:"number",exclusiveMinimum:"number",maxLength:"string",minLength:"string",pattern:"string",items:"array",maxItems:"array",minItems:"array",uniqueItems:"array",additionalItems:"array",maxProperties:"object",minProperties:"object",required:"object",additionalProperties:"object",properties:"object",patternProperties:"object",dependencies:"object"};function z0(u){if(u.type!==void 0)return Array.isArray(u.type)?u.type.length===0?null:u.type[0]:u.type;const a=Object.keys(ga);for(var e=0;e<a.length;e++){let r=a[e],i=ga[r];if(u[r]!==void 0)return i}return null}let N0={},zu=[];function Do(){N0={},zu=[]}function ci(u){let a;return u.const!==void 0?a=u.const:u.examples!==void 0&&u.examples.length?a=u.examples[0]:u.enum!==void 0&&u.enum.length?a=u.enum[0]:u.default!==void 0&&(a=u.default),a}function pa(u){const a=ci(u);if(a!==void 0)return{value:a,readOnly:u.readOnly,writeOnly:u.writeOnly,type:null}}function Su(u,a,e,r){if(r){if(zu.includes(u))return te(z0(u));zu.push(u)}if(r&&r.depth>a.maxSampleDepth)return Vu(zu,r),te(z0(u));if(u.$ref){if(!e)throw new Error("Your schema contains $ref. You must provide full specification in the third parameter.");let s=decodeURIComponent(u.$ref);s.startsWith("#")&&(s=s.substring(1));const E=C.JsonPointerLib.get(e,s);let l;if(N0[s]!==!0){N0[s]=!0;const D=Su(E,a,e,r);if(a.format==="xml"){const d=s.split("/").pop(),F={...r,propertyName:r?.propertyName||d},{propertyName:k,value:B}=J0(D,E,F);l={...D,value:{[k||"root"]:B}}}else l=D;N0[s]=!1}else{const D=z0(E);l=te(D)}return Vu(zu,r),l}if(u.example!==void 0)return Vu(zu,r),{value:u.example,readOnly:u.readOnly,writeOnly:u.writeOnly,type:u.type};if(u.allOf!==void 0)return Vu(zu,r),pa(u)||Eo({...u,allOf:void 0},u.allOf,a,e,r);if(u.oneOf&&u.oneOf.length){u.anyOf&&(a.quiet||console.warn("oneOf and anyOf are not supported on the same level. Skipping anyOf")),Vu(zu,r);const s=Object.assign({readOnly:u.readOnly,writeOnly:u.writeOnly},u.oneOf[0]);return o(u,s)}if(u.anyOf&&u.anyOf.length){Vu(zu,r);const s=Object.assign({readOnly:u.readOnly,writeOnly:u.writeOnly},u.anyOf[0]);return o(u,s)}if(u.if&&u.then){Vu(zu,r);const{if:s,then:E,...l}=u;return Su(V0(l,s,E),a,e,r)}let i=ci(u),n=null;if(i===void 0){i=null,n=u.type,Array.isArray(n)&&u.type.length>0&&(n=u.type[0]),n||(n=z0(u));let s=Fi[n];s&&(i=s(u,a,e,r))}return Vu(zu,r),{value:i,readOnly:u.readOnly,writeOnly:u.writeOnly,type:n};function o(s,E){const l=pa(s);if(l!==void 0)return l;const D=Su({...s,oneOf:void 0,anyOf:void 0},a,e,r),d=Su(E,a,e,r);if(typeof D.value=="object"&&typeof d.value=="object"){const F=V0(D.value,d.value);return{...d,value:F}}return d}}function xo(u,a={},e,r){const i=r&&r.depth||1;let n=Math.min(u.maxItems!=null?u.maxItems:1/0,u.minItems||1);const o=u.prefixItems||u.items||u.contains;Array.isArray(o)&&(n=Math.max(n,o.length));let s=l=>Array.isArray(o)?o[l]||{}:o||{},E=[];if(!o)return E;for(let l=0;l<n;l++){let D=s(l),{value:d}=Su(D,a,e,{depth:i+1});if(a?.format==="xml"){const{value:F,propertyName:k}=J0({value:d},D,r);k?(E?.[k]||(E={...E,[k]:[]}),E[k].push(F)):E={...E,...F}}else E.push(d)}if(a?.format==="xml"&&i===1){const{value:l,propertyName:D}=J0({value:null},u,r);D&&(l?E=Array.isArray(E)?{[D]:{...l,...E.map(d=>({"#text":{...d}}))}}:{[D]:{...E,...l}}:E={[D]:E})}return E}function co(u){return!0}function di(u){let a=0;if(u.type==="number"&&(u.format==="float"||u.format==="double")&&(a=.1),typeof u.exclusiveMinimum=="boolean"||typeof u.exclusiveMaximum=="boolean"){if(u.maximum&&u.minimum)return a=u.exclusiveMinimum?Math.floor(u.minimum)+1:u.minimum,(u.exclusiveMaximum&&a>=u.maximum||!u.exclusiveMaximum&&a>u.maximum)&&(a=(u.maximum+u.minimum)/2),a;if(u.minimum)return u.exclusiveMinimum?Math.floor(u.minimum)+1:u.minimum;if(u.maximum)return u.exclusiveMaximum?u.maximum>0?0:Math.floor(u.maximum)-1:u.maximum>0?0:u.maximum}else{if(u.minimum)return u.minimum;u.exclusiveMinimum?(a=Math.floor(u.exclusiveMinimum)+1,a===u.exclusiveMaximum&&(a=(a+Math.floor(u.exclusiveMaximum)-1)/2)):u.exclusiveMaximum?a=Math.floor(u.exclusiveMaximum)-1:u.maximum&&(a=u.maximum)}return a}function mo(u,a={},e,r){let i={};const n=r&&r.depth||1;if(u&&typeof u.properties=="object"){const o=Array.isArray(u.required)?u.required:[],s={};for(const E of o)s[E]=!0;Object.keys(u.properties).forEach(E=>{if(a.skipNonRequired&&!s.hasOwnProperty(E))return;const l=Su(u.properties[E],a,e,{propertyName:E,depth:n+1});if(a.skipReadOnly&&l.readOnly){r?.isAllOfChild&&(i[E]=pe);return}if(a.skipWriteOnly&&l.writeOnly){r?.isAllOfChild&&(i[E]=pe);return}if(a?.format==="xml"){const{propertyName:D,value:d}=J0(l,u.properties[E],{propertyName:E});D?i[D]=d:d!==null&&typeof d=="object"&&(i={...i,...d})}else i[E]=l.value})}if(u&&typeof u.additionalProperties=="object"){const o=u.additionalProperties["x-additionalPropertiesName"]||"property";i[`${String(o)}1`]=Su(u.additionalProperties,a,e,{depth:n+1}).value,i[`${String(o)}2`]=Su(u.additionalProperties,a,e,{depth:n+1}).value}if(u&&typeof u.properties=="object"&&u.maxProperties!==void 0&&Object.keys(i).length>u.maxProperties){const o={};let s=0;(Array.isArray(u.required)?u.required:[]).forEach(l=>{i[l]!==void 0&&(o[l]=i[l],s++)}),Object.keys(i).forEach(l=>{s<u.maxProperties&&!o.hasOwnProperty(l)&&(o[l]=i[l],s++)}),i=o}return i}function g0(u,a){return u}function va(u,a,e){let r=1;if(u)switch(u){case"?":{r=0;break}case"*":{r=g0(0);break}case"+":{r=g0(1);break}default:throw new Error("Unknown quantifier symbol provided.")}else a!=null&&e!=null?r=g0(parseInt(a)):a!=null&&e==null&&(r=parseInt(a));return r}function Fo(u){let a=!1;u instanceof RegExp&&(a=u.flags.includes("i"),u=u.toString(),u=u.match(/\/(.+?)\//)?.[1]??""),u=u.replace(/^(\^)?(.*?)(\$)?$/,"$2");let e,r,i;const n=/([.A-Za-z0-9])(?:\{(\d+)(?:\,(\d+)|)\}|(\?|\*|\+))(?![^[]*]|[^{]*})/;let o=u.match(n);for(;o!=null;){const d=o[2],F=o[3],k=o[4];i=va(k,d,F),u=u.slice(0,o.index)+o[1].repeat(i)+u.slice(o.index+o[0].length),o=u.match(n)}const s=/(\d-\d|\w-\w|\d|\w|[-!@#$&()`.+,/"])/,E=/\[(\^|)(-|)(.+?)\](?:\{(\d+)(?:\,(\d+)|)\}|(\?|\*|\+)|)/;for(o=u.match(E);o!=null;){const d=o[1]==="^",F=o[2]==="-",k=o[4],B=o[5],y=o[6],K=[];let V=o[3],H=V.match(s);for(F&&K.push(45);H!=null;){if(H[0].indexOf("-")===-1)a&&isNaN(Number(H[0]))?(K.push(H[0].toUpperCase().charCodeAt(0)),K.push(H[0].toLowerCase().charCodeAt(0))):K.push(H[0].charCodeAt(0));else{const v=H[0].split("-").map(h=>h.charCodeAt(0));if(e=v[0],r=v[1],e>r)throw new Error("Character range provided is out of order.");for(let h=e;h<=r;h++)if(a&&isNaN(Number(String.fromCharCode(h)))){const z=String.fromCharCode(h);K.push(z.toUpperCase().charCodeAt(0)),K.push(z.toLowerCase().charCodeAt(0))}else K.push(h)}V=V.substring(H[0].length),H=V.match(s)}if(i=va(y,k,B),d){let v=-1;for(let h=48;h<=57;h++){if(v=K.indexOf(h),v>-1){K.splice(v,1);continue}K.push(h)}for(let h=65;h<=90;h++){if(v=K.indexOf(h),v>-1){K.splice(v,1);continue}K.push(h)}for(let h=97;h<=122;h++){if(v=K.indexOf(h),v>-1){K.splice(v,1);continue}K.push(h)}}const G=Array.from({length:i},()=>String.fromCharCode(K[g0(0)])).join("");u=u.slice(0,o.index)+G+u.slice(o.index+o[0].length),o=u.match(E)}const l=/(.)\{(\d+)\,(\d+)\}/;for(o=u.match(l);o!=null;){if(e=parseInt(o[2]),r=parseInt(o[3]),e>r)throw new Error("Numbers out of order in {} quantifier.");i=g0(e),u=u.slice(0,o.index)+o[1].repeat(i)+u.slice(o.index+o[0].length),o=u.match(l)}const D=/(.)\{(\d+)\}/;for(o=u.match(D);o!=null;)i=parseInt(o[2]),u=u.slice(0,o.index)+o[1].repeat(i)+u.slice(o.index+o[0].length),o=u.match(D);return u}const ko="qwerty!@#$%^123456";function Co(){return"user@example.com"}function ho(){return"пошта@укр.нет"}function go(u,a){let e="pa$$word";return u>e.length&&(e+="_",e+=xi(ko,u-e.length).substring(0,u-e.length)),e}function Se({min:u,max:a,omitTime:e,omitDate:r}){let i=ro(new Date("2019-08-24T14:15:22.123Z"),e,r);return i.length<u&&console.warn(`Using minLength = ${u} is incorrect with format "date-time"`),a&&i.length>a&&console.warn(`Using maxLength = ${a} is incorrect with format "date-time"`),i}function po(u,a){return Se({min:u,max:a,omitTime:!1,omitDate:!1})}function vo(u,a){return Se({min:u,max:a,omitTime:!0,omitDate:!1})}function bo(u,a){return Se({min:u,max:a,omitTime:!1,omitDate:!0}).slice(1)}function mi(u,a,e,r,i=!1){if(r&&i)return Fo(r);let n=xi("string",u);return a&&n.length>a&&(n=n.substring(0,a)),n}function Bo(){return"192.168.0.1"}function Ao(){return"2001:0db8:85a3:0000:0000:8a2e:0370:7334"}function yo(){return"example.com"}function fo(){return"приклад.укр"}function zo(){return"http://example.com"}function So(){return"../dictionary"}function Mo(){return"http://example.com/{endpoint}"}function jo(){return"http://example.com/entity/1"}function Po(){return"/entity/1"}function wo(u,a,e){return no(e||"id")}function Ko(){return"/json/pointer"}function To(){return"1/relative/json/pointer"}function Lo(){return"/regex/"}const No={email:Co,"idn-email":ho,password:go,"date-time":po,date:vo,time:bo,ipv4:Bo,ipv6:Ao,hostname:yo,"idn-hostname":fo,iri:jo,"iri-reference":Po,uri:zo,"uri-reference":So,"uri-template":Mo,uuid:wo,default:mi,"json-pointer":Ko,"relative-json-pointer":To,regex:Lo};function Ro(u,a,e,r){let i=u.format||"default",n=No[i]||mi,o=r&&r.propertyName;return n(u.minLength||0,u.maxLength,o,u.pattern,a?.enablePatterns)}var Fi={};const Ho={skipReadOnly:!1,maxSampleDepth:15};function Go(u,a){if(!u)throw new Error("Unknown format output for building XML.");return(Array.isArray(u)||Object.keys(u).length>1)&&(u={[a?.xml?.name||"root"]:u}),new C.Builder({ignoreAttributes:!1,format:!0,attributeNamePrefix:"$",textNodeName:"#text",cdataPropName:"#cdata"}).build(u)}function Vo(u,a,e){let r=Object.assign({},Ho,a);Do();let i=Su(u,r,e).value;return r?.format==="xml"?Go(i,u):i}function l0(u,a){Fi[u]=a}l0("array",xo);l0("boolean",co);l0("integer",di);l0("number",di);l0("object",mo);l0("string",Ro);function ki(u,a){if(u)try{return Vo(u,{skipReadOnly:!0,skipNonRequired:!1,quiet:!0})}catch(e){a.error(C.bgRed(" Error while generating test data from JSON Schema ")+`
2
2
  `+e);return}}function Jo(u,a){if(u?.example)return u.example;if(C.isPlainObject(u?.examples))return Ci(u.examples);if(u?.schema)return ki(u.schema,a)}function Ci(u){if(C.isPlainObject(u)){const a=Object.keys(u)[0];return a?u[a]?.value:void 0}else return}function _o(u,a){const e=u?.requestBody?.content||{},[r,i]=Object.entries(e)[0]||[],n=i?.example||Ci(i?.examples)||ki(i?.schema,a),o=$o(u);return{parameters:Io([...ba(u.pathParameters,a),...ba(u.parameters,a)]).filter(({value:E})=>E),contentTypeParameters:[...r?[{name:"content-type",in:"header",value:r}]:[],...o?[{name:"accept",in:"header",value:o}]:[]],requestBody:n,contentType:r}}function $o(u){return u?.responses?Array.from(new Set(Object.values(u.responses).flatMap(a=>C.isPlainObject(a)&&"content"in a?Object.keys(a.content||{}):[]))).join(", "):void 0}function ba(u,a){return(u||[]).filter(e=>e?.required===!0).map(e=>{if(ze(e))return{name:e.name,in:e.in,value:Jo(e,a),...e.allowReserved&&{allowReserved:e.allowReserved}}}).filter(e=>e!==void 0)}function Io(u){const a={};for(const e of u)ze(e)&&(a[(e.name+":"+e.in).toLowerCase()]=e);return Object.values(a)}function Oo(u,a){let e,r;if(u.includes("$sourceDescriptions.")){const[,E,l]=u.split(".");e=E,r=l}else u.includes(".")?[e,r]=u.split("."):(r=u,e=Object.keys(a)[0]);const i=Object.keys(a);if(!a[e])throw new Error(`Unknown description name ${C.red(e)} at ${C.red(u)}. Available descriptions: ${i.join(", ")}.`);const n=a[e],o=n?.components?.securitySchemes,s=n.servers;for(const[E,l]of Object.entries(a[e].paths)){if(!l)return;for(const[D,d]of Object.entries(l))if(d.operationId===r)return{servers:l.servers||s,...d,pathParameters:d.parameters||[],path:E,method:D,descriptionName:e,securitySchemes:o}}throw new Error(`Unknown operationId ${C.red(r)} at ${C.red(u)}.`)}function Wo(u,a){const{$sourceDescriptions:e,sourceDescriptions:r}=a,[i,n]=u.split("#");if(!r)throw new Error("Missing described sourceDescriptions");const o=r.find(y=>{if(["openapi","arazzo"].includes(y.type)){if(i.includes("$sourceDescriptions.")){const[,K]=i.split(".");return y.name===K}return"url"in y&&y.url===i}return!1})?.name;if(!o)throw new Error(`Unknown operationPath ${C.red(u)}. API description ${C.red(i)} is not listed in 'sourceDescriptions' workflow section.`);const s=e[o]||{},E=s?.components?.securitySchemes,[l,D,d]=C.JsonPointerLib.parse(n);if(l!=="paths")throw new Error(`Invalid fragment identifier: ${n} at operationPath ${C.red(u)}.`);const{servers:F}=s,k=C.JsonPointerLib.get(s,n)||{},B=C.JsonPointerLib.get(s,C.JsonPointerLib.compile(["paths",D]))||{};return{servers:B.servers||F,...k,pathParameters:B.parameters||[],path:D,method:d,descriptionName:o,securitySchemes:E}}function qo(u,a){if(!u.operationId&&!u.operationPath)return;const{$sourceDescriptions:e,sourceDescriptions:r}=a,{operationId:i,operationPath:n}=u;return i?Oo(i,e):n?Wo(n,{$sourceDescriptions:e,sourceDescriptions:r}):void 0}function Zo({statusCode:u,contentType:a,descriptionResponses:e}){return e?(e[u]||e.default)?.content?.[a]?.schema:void 0}function Uo(u,a){if(!a)return;const r=a.requestBody?.content;return r&&r[u]?.schema||void 0}function hi({ctx:u,security:a,operation:e}){const{scheme:r,schemeName:i}=a;if(r)return a.scheme;if(i){if(typeof i=="string"&&i.startsWith("$sourceDescriptions.")){const[n,o,s]=i.split("."),l=(o&&u.$sourceDescriptions[o])?.components?.securitySchemes;return s&&l?l[s]:void 0}return e?.securitySchemes?.[i]}}function S0(){}function Ba(){return typeof WeakMap<"u"?new WeakMap:Yo()}function Yo(){return{add:S0,delete:S0,get:S0,set:S0,has:function(u){return!1}}}var Qo=Object.prototype.hasOwnProperty,ve=function(u,a){return Qo.call(u,a)};function se(u,a){for(var e in a)ve(a,e)&&(u[e]=a[e]);return u}var Xo=/^[ \t]*(?:\r\n|\r|\n)/,u4=/(?:\r\n|\r|\n)[ \t]*$/,e4=/^(?:[\r\n]|$)/,a4=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,i4=/^[ \t]*[\r\n][ \t\r\n]*$/;function Aa(u,a,e){var r=0,i=u[0].match(a4);i&&(r=i[1].length);var n="(\\r\\n|\\r|\\n).{0,"+r+"}",o=new RegExp(n,"g");a&&(u=u.slice(1));var s=e.newline,E=e.trimLeadingNewline,l=e.trimTrailingNewline,D=typeof s=="string",d=u.length,F=u.map(function(k,B){return k=k.replace(o,"$1"),B===0&&E&&(k=k.replace(Xo,"")),B===d-1&&l&&(k=k.replace(u4,"")),D&&(k=k.replace(/\r\n|\n|\r/g,function(y){return s})),k});return F}function r4(u,a){for(var e="",r=0,i=u.length;r<i;r++)e+=u[r],r<i-1&&(e+=a[r]);return e}function n4(u){return ve(u,"raw")&&ve(u,"length")}function gi(u){var a=Ba(),e=Ba();function r(n){for(var o=[],s=1;s<arguments.length;s++)o[s-1]=arguments[s];if(n4(n)){var E=n,l=(o[0]===r||o[0]===Pu)&&i4.test(E[0])&&e4.test(E[1]),D=l?e:a,d=D.get(E);if(d||(d=Aa(E,l,u),D.set(E,d)),o.length===0)return d[0];var F=r4(d,l?o.slice(1):o);return F}else return gi(se(se({},u),n||{}))}var i=se(r,{string:function(n){return Aa([n],!1,u)[0]}});return i}var Pu=gi({trimLeadingNewline:!0,trimTrailingNewline:!0});if(typeof module<"u")try{module.exports=Pu,Object.defineProperty(Pu,"__esModule",{value:!0}),Pu.default=Pu,Pu.outdent=Pu}catch{}function o4(u){return!h0.isBrowser&&process.env.NODE_ENV==="test"?"<test>ms":`${Math.ceil(performance.now()-u)}ms`}function W0(u){const a=u.length;let e=0,r=0,i=0,n=0,o=0,s=0,E=0;const l=new Set;let D=0;const d=new Set,F=new Set;for(const k of u){const B=pi(k.executedSteps);let y=!1;for(const K of B){if(n++,K.retriesLeft&&K.retriesLeft!==0)continue;i++;let V=!1;for(const H of K.checks)if(r++,!H.passed)switch(H.severity){case"warn":o++,l.add(k.workflowId),F.add(k.workflowId+":"+K.stepId);break;case"off":s++,d.add(k.workflowId+":"+K.stepId);break;default:e++,V=!0}V&&(D++,y=!0)}y&&E++}return{workflows:{passed:a-E,failed:E,warnings:l.size,skipped:0,total:a},steps:{passed:i-D,failed:D,warnings:F.size,skipped:d.size,total:i},checks:{passed:r-e,failed:e,warnings:o,skipped:s,total:r},totalRequests:n}}function pi(u){return u.flatMap(a=>"executedSteps"in a?pi(a.executedSteps):[a])}function t4(u){try{return JSON.parse(u),!0}catch{return!1}}function s4(u,a){const e=u.endsWith("/")?u.slice(0,-1):u,r=a.startsWith("/")?a.slice(1):a;return`${e}/${r}`}const ya=50;function vi({testNameToDisplay:u,checks:a,verboseLogs:e,verboseResponseLogs:r,logger:i}){const n=a.every(({passed:o})=>o);i.output(` ${n?C.green("✓"):C.red("✗")} ${C.blue(u)}`),e&&(i.output(`${hu}
3
3
  `+(fa({logs:e,logger:i})||"")),i.printNewLine()),r&&(i.output(`${hu}
4
4
  `+(fa({logs:r,type:"response",logger:i})||"")),i.printNewLine()),i.printNewLine();for(const o of a)i.output(`${au(l4(o,o.severity),4)}
@@ -1,6 +1,6 @@
1
- import { aL as su, aK as Su, aR as s0, aS as Wu, aT as He, aU as mo, aV as I0, aW as eu, aX as d0, aY as Du, aZ as cu, a_ as qu, a$ as Zu, b0 as Bi, b1 as Fo, b2 as Pa, b3 as ko, b4 as Co, b5 as wa, g as Ge, b6 as ho, b7 as O0, b8 as je, b9 as Ka } from "./replay-index-BzzBKjHm.js";
2
- import { a as f0 } from "./replay-resolve-DsgcWnjC.js";
3
- import { y as Ai, a4 as Ta, c as go, Z as po, U as vo, J as bo, a9 as yi } from "./replay-lint-DlDmPTBV.js";
1
+ import { aS as su, aR as Su, aZ as s0, a_ as Wu, a$ as He, b0 as mo, b1 as I0, b2 as eu, b3 as d0, b4 as Du, b5 as cu, b6 as qu, b7 as Zu, b8 as Bi, b9 as Fo, aP as Pa, aQ as ko, ba as Co, bb as wa, g as Ge, bc as ho, bd as O0, be as je, bf as Ka } from "./replay-index-Bc5RHu5L.js";
2
+ import { a as f0 } from "./replay-resolve-MVe_8Ube.js";
3
+ import { y as Ai, a4 as Ta, c as go, Z as po, U as vo, J as bo, a9 as yi } from "./replay-lint-PWaLESz5.js";
4
4
  function Bo(u) {
5
5
  return su(u) && "name" in u && "value" in u && !("in" in u);
6
6
  }
@@ -1,5 +1,5 @@
1
- import { aE as h, aF as x, aG as i } from "./replay-index-BzzBKjHm.js";
2
- import { aH as E, aI as b, aJ as j } from "./replay-index-BzzBKjHm.js";
1
+ import { aV as h, $ as x, aW as i } from "./replay-index-Bc5RHu5L.js";
2
+ import { aX as b, aY as j, Y as y } from "./replay-index-Bc5RHu5L.js";
3
3
  async function u(n, e) {
4
4
  const t = x(), l = await i(n), c = await i(e), o = l.replace(new RegExp(`^${t}+`), "").split(t).filter(Boolean), r = c.replace(new RegExp(`^${t}+`), "").split(t).filter(Boolean), m = Math.min(o.length, r.length);
5
5
  let s = 0;
@@ -13,10 +13,10 @@ async function w(n) {
13
13
  return e ? `.${e}` : "";
14
14
  }
15
15
  export {
16
- E as dirname,
16
+ b as dirname,
17
17
  w as extname,
18
- b as isAbsolute,
19
- j as join,
18
+ j as isAbsolute,
19
+ y as join,
20
20
  u as relative,
21
21
  i as resolve
22
22
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./replay-index-Dfnqt_IZ.js");async function u(r,n){const t=e.sep(),l=await e.resolve(r),c=await e.resolve(n),a=l.replace(new RegExp(`^${t}+`),"").split(t).filter(Boolean),i=c.replace(new RegExp(`^${t}+`),"").split(t).filter(Boolean),m=Math.min(a.length,i.length);let s=0;for(let o=0;o<m&&a[o]===i[o];o++)s++;const p=a.slice(s).map(()=>".."),f=i.slice(s);return[...p,...f].join(t)}async function g(r){const n=await e.extname(r);return n?`.${n}`:""}exports.dirname=e.dirname;exports.isAbsolute=e.isAbsolute;exports.join=e.join;exports.resolve=e.resolve;exports.extname=g;exports.relative=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./replay-index-CepJ5Z0m.js");async function u(r,n){const t=e.sep(),l=await e.resolve(r),c=await e.resolve(n),a=l.replace(new RegExp(`^${t}+`),"").split(t).filter(Boolean),i=c.replace(new RegExp(`^${t}+`),"").split(t).filter(Boolean),m=Math.min(a.length,i.length);let s=0;for(let o=0;o<m&&a[o]===i[o];o++)s++;const p=a.slice(s).map(()=>".."),f=i.slice(s);return[...p,...f].join(t)}async function g(r){const n=await e.extname(r);return n?`.${n}`:""}exports.dirname=e.dirname;exports.isAbsolute=e.isAbsolute;exports.join=e.join;exports.resolve=e.resolve;exports.extname=g;exports.relative=u;
@@ -0,0 +1,215 @@
1
+ "use strict";const ge=require("react"),d=require("./replay-index-CepJ5Z0m.js"),m=require("./replay-db-BQGv3PGw.js"),n=require("./replay-create-model-bOIDB-e8.js"),S=require("./replay-SemanticSearchService-CCqwCRo6.js"),we=require("@tanstack/react-query"),$={path:"pathParameters",query:"queryParameters",header:"headers",cookie:"cookies"},rt={run_request:{approveLabel:"Run",denyLabel:"Skip"},update_step:{approveLabel:"Apply",denyLabel:"Dismiss"},update_security:{approveLabel:"Apply",denyLabel:"Dismiss"}},st={set_active_environment:{approveLabel:"Switch",denyLabel:"Cancel"},add_environment:{approveLabel:"Add",denyLabel:"Cancel"},upsert_input:{approveLabel:"Set",denyLabel:"Cancel"},upsert_server:{approveLabel:"Set",denyLabel:"Cancel"},remove_input:{approveLabel:"Remove",denyLabel:"Cancel"},remove_server:{approveLabel:"Remove",denyLabel:"Cancel"},create_collection:{approveLabel:"Create",denyLabel:"Cancel"},create_workflow:{approveLabel:"Create",denyLabel:"Cancel"},create_step:{approveLabel:"Create",denyLabel:"Cancel"},move_step:{approveLabel:"Move",denyLabel:"Cancel"},delete_collection:{approveLabel:"Delete",denyLabel:"Cancel"},delete_workflow:{approveLabel:"Delete",denyLabel:"Cancel"},delete_step:{approveLabel:"Delete",denyLabel:"Cancel"},save_tab_to_collection:{approveLabel:"Save",denyLabel:"Cancel"}},it={CHAT:"chat",HISTORY:"history"},at="report_status",ct="run_workflow",q={WEB_SEARCH:"web_search"};function lt(e){switch(e.provider){case d.AI_PROVIDERS.GEMINI:return{[q.WEB_SEARCH]:n.google.tools.googleSearch({})};case d.AI_PROVIDERS.OPENAI:return{[q.WEB_SEARCH]:n.openai.tools.webSearch({})};case d.AI_PROVIDERS.ANTHROPIC:return{[q.WEB_SEARCH]:n.anthropic.tools.webFetch_20250910()};case d.REUNITE_AI_PROVIDER:return{[q.WEB_SEARCH]:{type:"provider",id:"reunite.web_search",name:"web_search",args:{}}};default:return{}}}const dt=["info","workflows","sourceDescriptions"];function ut(e){const t=[];return e.collectionId&&t.push(`Collection ID: ${e.collectionId}`),e.collection?.info?.title&&t.push(`Title: ${e.collection.info.title}`),e.collection?.info?.summary&&t.push(`Summary: ${e.collection.info.summary}`),e.collection?.info?.description&&t.push(`Description: ${e.collection.info.description}`),m.buildMessageFromArray(t,`
2
+ `)}function pt(e){const t=[];if(e.collection?.workflows?.length){t.push("Workflows:");for(const o of e.collection.workflows)t.push(` workflowId=${o.workflowId} ${o.summary??""}`)}return m.buildMessageFromArray(t,`
3
+ `)}function ft(e){const t=[];if(e.collection?.sourceDescriptions?.length){t.push("Source descriptions:");for(const o of e.collection.sourceDescriptions)t.push(` name=${o.name} url=${o.url}`)}return m.buildMessageFromArray(t,`
4
+ `)}function mt(e,t){const o=["Current tab (collection)"];for(const r of t)switch(r){case"info":o.push(ut(e));break;case"workflows":o.push(pt(e));break;case"sourceDescriptions":o.push(ft(e));break}return m.buildMessageFromArray(o,`
5
+
6
+ `)}function ht(e,t){return m.buildMessageFromArray([e.collectionId?`Collection ID: ${e.collectionId}`:null,t.includes("title")&&e.title?`Title: ${e.title}`:null,t.includes("description")&&e.description?`Description: ${e.description}`:null],`
7
+ `)}function yt(e,t){return m.buildMessageFromArray([t.includes("title")?e.title:null,e.apiId?`API ID: ${e.apiId}`:null,t.includes("description")&&e.description?`Description: ${e.description}`:null,t.includes("path")&&e.path?`Path: ${e.path}`:null,t.includes("method")&&e.method?`Method: ${e.method}`:null,t.includes("operationId")&&e.operationId?`Operation ID: ${e.operationId}`:null,t.includes("requestBody")&&e.requestBodySchema?`Request body schema: ${e.requestBodySchema}`:null,t.includes("parameters")&&e.parameterDetails?`Parameter details: ${m.formatSearchParameterDetails(e.parameterDetails)}`:null,t.includes("security")&&e.relatedSecuritySchemes?`Security schemes: ${m.formatSecuritySchemes(e.relatedSecuritySchemes)}`:null,t.includes("tags")&&e.tags?`Tags: ${e.tags.join("; ")}`:null,t.includes("responses")&&e.responseSchemas?`Responses: ${m.formatResponseSchema(e.responseSchemas)}`:null],`
8
+ `)}const It=["info","inputs","parameters","security","outputs","steps","wiring"];function gt(e){return!e.inputs||Object.keys(e.inputs).length===0?null:`Workflow inputs (JSON Schema):
9
+ ${JSON.stringify(e.inputs,null,2)}`}function wt(e){return e.outputs?.length?`Workflow outputs:
10
+ ${e.outputs.map(t=>` id=${t.id} key=${t.key} value=${t.value} active=${t.active}`).join(`
11
+ `)}`:null}function be(e){return e.operation?` apiId=${e.operation.apiId} method=${e.operation.method} path=${e.operation.path}`:e.xOperation?` method=${e.xOperation.method} path=${e.xOperation.url}`:""}function bt(e){return e.steps?.length?`Steps:
12
+ ${e.steps.map(t=>` stepId=${t.stepId} ${be(t)}`).join(`
13
+ `)}`:null}function vt(e){return e.steps?.length?`Step wiring (security + outputs per step):
14
+ ${e.steps.map(o=>{const r=[` stepId=${o.stepId}${be(o)}`],s=m.buildSecuritySection(o.security);s&&r.push(m.indentBlock(s," "));const i=m.buildStepOutputsSection(o.outputs);return i&&r.push(m.indentBlock(i," ")),r.join(`
15
+ `)}).join(`
16
+ `)}`:null}function Tt(e,t){switch(t){case"inputs":return gt(e);case"parameters":return m.buildParametersSection(e.parameters);case"security":return m.buildSecuritySection(e.security);case"outputs":return wt(e);case"steps":return bt(e);case"wiring":return vt(e);default:return null}}function St(e){const t=[];return e.collectionId&&t.push(`Collection ID: ${e.collectionId}`),e.workflowId&&t.push(`Workflow ID: ${e.workflowId}`),e.workflow?.summary&&t.push(`Summary: ${e.workflow.summary}`),e.workflow?.description&&t.push(`Description: ${e.workflow.description}`),m.buildMessageFromArray(t,`
17
+ `)}function kt(e,t){const o=["Current tab (workflow)"],r=e.workflow;for(const s of t){if(s==="info"){o.push(St(e));continue}if(!r)continue;const i=Tt(r,s);i&&o.push(i)}return m.buildMessageFromArray(o,`
18
+
19
+ `)}function Ct(e,t){return m.buildMessageFromArray([e.collectionId?`Collection ID: ${e.collectionId}`:null,e.workflowId?`Workflow ID: ${e.workflowId}`:null,t.includes("title")&&e.title?`Summary: ${e.title}`:null,t.includes("description")&&e.description?`Description: ${e.description}`:null],`
20
+ `)}const At=["info","parameters","requestBody","security","outputs","successCriteria","response"];function Ot(e){const t=[`apiId: ${e.apiId}`,`method: ${e.method}`,`path: ${e.path}`,e.operationId?`operationId: ${e.operationId}`:null];return`Step is connected to API (${m.buildMessageFromArray(t,", ")})`}function Et(e){const t=[`method: ${e.method}`,`url: ${e.url}`];return`Step is not connected to API (${m.buildMessageFromArray(t,", ")})`}function _t(e){return e.description?.trim()?`Description:
21
+ ${e.description}`:null}function xt(e,t){switch(t){case"parameters":return m.buildParametersSection(e.parameters)||null;case"requestBody":return m.buildRequestBodySection(e.requestBody)||null;case"security":return m.buildSecuritySection(e.security)||null;case"outputs":return m.buildStepOutputsSection(e.outputs)||null;case"successCriteria":return m.buildSuccessCriteriaSection(e.successCriteria)||null;default:return null}}function Rt(e){const t=[];e.collectionId&&t.push(`Collection ID: ${e.collectionId}`),e.workflowId&&t.push(`Workflow ID: ${e.workflowId}`),e.stepId&&t.push(`Step ID: ${e.stepId}`),t.push(`Saved in collection: ${e.step?"yes":"no"}`);const o=e.draftStep??e.step;if(o){if(t.push(_t(o)),o.operation){const r=o.operation;t.push(Ot(r))}else if(o.xOperation){const r=o.xOperation;t.push(Et(r))}}return e.response&&t.push(`Last response: status=${e.response.status} durationMs=${e.response.duration} size=${e.response.size}`),e.requestError&&t.push(`Request error: ${e.requestError}`),m.buildMessageFromArray(t,`
22
+ `)}function $t(e){if(!e.response)return null;const t=e.response,o=t.headers?.length?t.headers.map(i=>` ${i[0]}: ${i[1]}`):[];let r="";t.bodyNotStored?r=" (body not stored)":t.body&&(r=`
23
+ Body:
24
+ ${t.body.length>m.RESPONSE_BODY_PREVIEW_MAX?`${t.body.slice(0,m.RESPONSE_BODY_PREVIEW_MAX)}…`:t.body}`);const s=["Last response (full)",`status: ${t.status}`,t.url?`url: ${t.url}`:null,`durationMs: ${t.duration}`,`size: ${t.size}`,o.length>0?`Headers:
25
+ ${m.buildMessageFromArray(o,`
26
+ `)}`:null,r||null];return m.buildMessageFromArray(s,`
27
+ `)}function te(e,t){const o=[];for(const r of t){const s=xt(e,r);s&&o.push(s)}return o.length?o.filter(Boolean).join(`
28
+ `):""}function Pt(e,t){const o=["Current tab (step)"];return t.length===0?null:(t.includes("info")&&o.push(Rt(e)),e.draftStep?o.push(te(e.draftStep,t)):e.step&&o.push(te(e.step,t)),t.includes("response")&&o.push($t(e)),m.buildMessageFromArray(o,`
29
+
30
+ `))}function qt(e){return e?.trim()?`Description:
31
+ ${e}`:null}function Nt(e,t){if(e.apiId&&e.path&&e.method){const o=[`apiId: ${e.apiId}`,t.includes("method")?`method: ${e.method}`:null,t.includes("path")?`path: ${e.path}`:null,t.includes("operationId")&&e.operationId?`operationId: ${e.operationId}`:null];return`Step is connected to API (${m.buildMessageFromArray(o,", ")})`}if(e.path||e.method){const o=[t.includes("method")&&e.method?`method: ${e.method}`:null,t.includes("path")&&e.path?`url: ${e.path}`:null];return`Step is not connected to API (${m.buildMessageFromArray(o,", ")})`}return null}function Ut(e,t){return m.buildMessageFromArray([e.collectionId?`Collection ID: ${e.collectionId}`:null,e.workflowId?`Workflow ID: ${e.workflowId}`:null,e.stepId?`Step ID: ${e.stepId}`:null,t.includes("description")?qt(e.description):null,Nt(e,t),t.includes("requestBody")&&e.requestBodySchema?`Request body schema: ${e.requestBodySchema}`:null,t.includes("parameters")&&e.parameterDetails?`Parameter details: ${m.formatSearchParameterDetails(e.parameterDetails)}`:null,t.includes("successCriteria")&&e.successCriteria?.length?`Success criteria: ${e.successCriteria.join("; ")}`:null,t.includes("tags")&&e.tags?`Tags: ${e.tags.join("; ")}`:null,t.includes("security")&&e.relatedSecuritySchemes?`Security schemes: ${m.formatSecuritySchemes(e.relatedSecuritySchemes)}`:null,t.includes("responses")&&e.responseSchemas?`Responses: ${m.formatResponseSchema(e.responseSchemas)}`:null],`
32
+ `)}function Dt(e,t){return e.type==="collection"?ht(e,t):e.type==="workflow"?Ct(e,t):e.type==="step"?Ut(e,t):yt(e,t)}function Mt(e,t){return e.map(o=>Dt(o,t))}const jt=["info","result","severity"],Lt=500,Wt=m.RESPONSE_BODY_PREVIEW_MAX*2;function Ft(e){const t=[];return e.collectionId&&t.push(`Collection ID: ${e.collectionId}`),e.workflowId&&t.push(`Workflow ID: ${e.workflowId}`),e.workflow?.summary&&t.push(`Summary: ${e.workflow.summary}`),e.workflow?.description&&t.push(`Description: ${e.workflow.description}`),e.runDate&&t.push(`Run date: ${new Date(e.runDate).toISOString()}`),m.buildMessageFromArray(t,`
33
+ `)}function Bt(e){return`Severity settings:
34
+ ${JSON.stringify(e.severitySettings,null,2)}`}function Yt(e,t){return e.length>t?`${e.slice(0,t)}…`:e}function oe(e,t,o,r=!1){if(e==null||e==="")return"(empty)";const s=typeof e=="string"?e:r?JSON.stringify(e,null,2):JSON.stringify(e);return Yt(d.maskSecretsInText(s,t),o)}function zt(e,t){const o=e.request?.method||e["x-operation"]?.method,r=e.verboseLog?`${e.verboseLog.host}${e.verboseLog.path}`:e.request?.url||e["x-operation"]?.url,s=e.response?.statusCode,i=[`${e.stepId}:`];(o||r)&&i.push([o?.toUpperCase(),r?d.maskSecretsInText(r,t):null].filter(Boolean).join(" "),"->"),i.push(`status=${s??"n/a"}`,d.hasAllStepPassed(e)?"passed":"failed");const a=e.checks?d.getStepFailures(e.checks):[];if(a.length>0){const l=a.map(c=>c.message?`${c.name}: ${d.maskSecretsInText(c.message,t)}`:c.name);i.push(`(${l.join("; ")})`)}return i.join(" ")}function Ht(e,t,o){const{steps:r,totalSteps:s,passedSteps:i,succeeded:a,timedOut:l}=d.getWorkflowRunVerdict(e),p=[`Run status: ${a?"SUCCEEDED":"FAILED"} (${i}/${s} steps passed, ${e.totalTimeMs}ms total${l?", global timeout reached":""})`];if(r.length>0){const u=[];let h=Wt,f=0;for(const{step:g}of r){if(u.push(` ${zt(g,t)}`),h<=0){f++;continue}const w=oe(g.response?.body,t,Lt);h-=w.length,u.push(` body: ${w}`)}f>0&&u.push(` (${f} step body previews omitted to save space; request them via stepIds)`),p.push(`Steps:
35
+ ${u.join(`
36
+ `)}`)}for(const u of o??[]){const h=r.find(f=>f.step.stepId===u);p.push(h?`Full response body for step ${u}:
37
+ ${oe(h.step.response?.body,t,m.RESPONSE_BODY_PREVIEW_MAX,!0)}`:`Full response body for step ${u}: step not found in this run.`)}return m.buildMessageFromArray(p,`
38
+ `)}function Gt(e,t){const o=e.secretValues?[...e.secretValues]:void 0;if(e.runStatus==="running")return"Run status: RUNNING - the workflow is still executing; re-read this section to get the outcome, which will be reported as SUCCEEDED or FAILED once the run finishes.";if(e.runStatus==="error"){const r=`Run status: FAILED - execution error: ${d.maskSecretsInText(e.runError||"unknown error",o)}`;return e.result?`${r}
39
+ (the stored result is from an earlier run and is omitted as stale)`:r}return e.result?Ht(e.result,o,t?.stepIds):"Run status: NOT STARTED - no run has executed on this tab yet."}function Vt(e,t,o){const r=["Current tab (workflow run)"];for(const s of t)switch(s){case"info":r.push(Ft(e));break;case"severity":r.push(Bt(e));break;case"result":r.push(Gt(e,o));break}return m.buildMessageFromArray(r,`
40
+
41
+ `)}function Kt(e,t=["info"],o){if(!e)return null;switch(e.type){case d.TabDataType.Step:return Pt(e,t);case d.TabDataType.Workflow:return kt(e,t);case d.TabDataType.Collection:return mt(e,t);case d.TabDataType.WorkflowRun:return Vt(e,t,o)}}function Jt(e){switch(e.type){case d.TabDataType.Collection:return dt;case d.TabDataType.Workflow:return It;case d.TabDataType.Step:return At;case d.TabDataType.WorkflowRun:return jt}}function ve(e){return e.trim().replace(/\s+/g," ").replace(/[.!?:;,…]+$/,"").toLowerCase()}function Xt(e,t){const o=[];let r=0;for(const s of e??[])if(!(s.role!=="assistant"||!Array.isArray(s.content)))for(const i of s.content)i.type==="tool-call"&&(i.toolName===t?(r+=1,o.push(i.input)):r=0);return{priorInputs:o,consecutiveCalls:r}}function Qt(e,t,o){const r=[];let s=!1;for(const i of e){const a=i(t,o);a&&(r.push(a.message),a.action==="block"&&(s=!0))}return{blocked:s,notes:r}}function Te(e){const t=e.warn!==void 0?"warn":"block",o=e.warn!==void 0?e.warn:e.block;return(r,s)=>{const i=ne(e.key,r);return i===null?null:s.priorInputs.some(l=>ne(e.key,l)===i)?{action:t,message:o}:null}}function ne(e,t){try{return e(t)}catch{return null}}function Zt(e){const t=re("warn",e.warnAfter,e.warnMessage),o=re("block",e.blockAfter,e.blockMessage);if(!t&&!o)throw new Error("consecutiveCallsRule requires at least warnAfter or blockAfter");if(t&&o&&o.after<=t.after)throw new Error("consecutiveCallsRule requires blockAfter to be greater than warnAfter");return(r,s)=>{const i=s.consecutiveCalls+1;return o&&i>=o.after?{action:"block",message:o.message(i)}:t&&i>=t.after?{action:"warn",message:t.message(i)}:null}}function re(e,t,o){if(!(t===void 0&&o===void 0)){if(t===void 0||o===void 0)throw new Error(`consecutiveCallsRule requires ${e}After and ${e}Message together`);if(!Number.isInteger(t)||t<1)throw new Error(`consecutiveCallsRule requires ${e}After to be a positive integer`);return{after:t,message:o}}}function eo(e){if(!e||typeof e.safeParse!="function")return;const t=e;return o=>{const r=t.safeParse(o);return r.success?r.data:null}}function to(e,t,o,r){return!t||t.length===0?o:async(s,i)=>{const a=Xt(i?.messages,e),l={consecutiveCalls:a.consecutiveCalls,priorInputs:r?a.priorInputs.map(r).filter(u=>u!==null):a.priorInputs},c=Qt(t,s,l);if(c.blocked)return{isError:!1,blocked:!0,note:c.notes.join(" ")};const p=await o(s,i);return c.notes.length===0||!oo(p)?p:{...p,note:[p.note,...c.notes].filter(Boolean).join(" ")}}}function oo(e){return e!==null&&typeof e=="object"&&e.isError===!1}function no(e,t){return{name:e.name,definition:e.definition,execute:to(e.name,e.guards,e.createExecutor(t),eo(e.definition.inputSchema))}}const ro={messages:[],isStreaming:!1,sendMessage:async()=>{},updateMessages:()=>{},stopGeneration:()=>{},addToolApprovalResponse:()=>{},chatStatus:"ready",chatError:void 0},Se=ge.createContext(ro);function so(){return ge.useContext(Se)}const io=n.objectType({message:n.stringType(),details:n.unknownType().optional()});n.objectType({collectionId:n.stringType().min(1).describe("Target collection id."),workflowId:n.stringType().min(1).describe("Target workflow id."),stepId:n.stringType().min(1).describe("Target step id.")});const V=n.objectType({action:n.enumType(["add","update","remove"]).describe('Action to perform: "add", "update" or "remove".'),approved:n.booleanType().default(!0)}),A=V.extend({id:n.stringType().optional().describe("Existing item id. Required for update/remove actions.")}),ao=V.extend({index:n.numberType().int().min(0).optional().describe("Existing item index. Required for update/remove actions.")}),co=n.objectType({isError:n.literalType(!1),blocked:n.literalType(!0),note:n.stringType(),data:n.neverType().optional(),error:n.neverType().optional()});function k(e){return n.unionType([n.objectType({isError:n.literalType(!0),error:io,data:n.neverType().optional(),blocked:n.neverType().optional()}),n.objectType({isError:n.literalType(!1),data:e,error:n.neverType().optional(),note:n.stringType().optional(),blocked:n.neverType().optional()}),co])}const lo=n.objectType({status:n.enumType(["applied","failed"]),summary:n.stringType().optional()}),uo=n.objectType({totalChanges:n.numberType().int().min(0),approvedChanges:n.numberType().int().min(0),applied:n.arrayType(lo),resultingState:n.stringType().optional().describe("Resulting state of the mutated fields after all changes were applied.")}),ke=k(uo),po="Read structured state from the **active** Replay tab.\n\n**What it does**\n- Returns structured data for the active tab.\n- Read-only: does not open/switch tabs and does not mutate saved or unsaved content.\n- Returns UI-facing tab data (editable fields, configured values, responses/results), not a full OpenAPI schema dump.\n\n**Use when**\n- You need to verify UI state in the active tab after an action (edit, save, execute, rerun, tab switch).\n- You need to inspect request/response/result content as rendered in Replay UI.\n\n**Never use when**\n- You are gathering **initial schema/context** for a request from project assets (OpenAPI/Arazzo); use project-asset lookup with exact ids/coordinates.\n- You need IDs or operation/workflow coordinates from project assets; resolve them via project-asset lookup, not active-tab UI reads.\n- You need a different tab; this tool never changes focus.\n- You need to run a request or change any saved/unsaved tab content; this tool is strictly read-only.\n\n**Input guidance**\n- Treat IDs from `info` as canonical for follow-up actions.\n- Request only needed sections and combine them in one call.\n- Prefer including `info` unless you need only one slice.\n- Sections by tab type:\n - Collection tab: `info`, `workflows`, `sourceDescriptions`.\n - Workflow tab: `info`, `inputs`, `parameters`, `security`, `outputs`, `steps`, `wiring` (every step's security bindings + outputs in one call - inspect or verify multi-step wiring without opening step tabs).\n - Step tab: `info`, `parameters`, `requestBody`, `security`, `outputs`, `successCriteria`, `response`.\n - Workflow run tab: `info`, `result` (status, per-step outcomes, masked bodies; `stepIds` fetches full ones), `severity`.\n- Invalid sections are skipped; if none apply, response falls back to `info`.\n\n**Loop/budget guidance**\n- Read each needed section once per turn.\n- Re-read only after mutation/save, or when you need to inspect new output.\n- If `result` is RUNNING, re-read until the run finishes.",fo=n.enumType(["info","workflows","sourceDescriptions","inputs","parameters","security","outputs","steps","wiring","requestBody","successCriteria","response","result","severity"]),mo=n.strictObjectType({sections:n.arrayType(fo).min(1).describe("Content blocks to include in the response. Use tab-type-specific sections from the tool description; invalid sections for the current tab are ignored."),stepIds:n.arrayType(n.stringType()).min(1).optional().describe("Workflow run tabs only, together with the `result` section: executed step ids to return the full (secret-masked) response body for. Use after the per-step preview proves insufficient.")}),ho=n.objectType({message:n.stringType()}),yo=k(ho),Io={description:po,inputSchema:mo,outputSchema:yo,needsApproval:!1};function y(e,t){return{isError:!0,error:{message:e,details:t}}}function go(e,t){const o=Jt(e),r=[],s=[];for(const i of t)o.includes(i)?r.push(i):s.push(i);return{sections:r,skipped:s}}function wo(e){return async(t,o)=>{const r=e();if(!r)return y("No active tab data available.");const{sections:s,skipped:i}=go(r,t.sections),a=s.length>0?s:["info"];let c=Kt(r,a,{stepIds:t.stepIds})??"Unable to build a summary for the active tab.";return i.length>0&&(c+=`
42
+
43
+ (Sections not applicable for this tab type were omitted: ${i.join(", ")}.)`),s.length===0&&t.sections.length>0&&(c+="\n\n(No requested sections applied to this tab type; showing `info` instead.)"),t.stepIds?.length&&(r.type!==d.TabDataType.WorkflowRun?c+=`
44
+
45
+ (stepIds applies only to workflow run tabs.)`:a.includes("result")||(c+="\n\n(stepIds requires the `result` section.)")),{isError:!1,data:{message:c}}}}const Ce={name:"get_current_tab",definition:Io,createExecutor:e=>wo(e.getActiveTabDetailedData)},bo=`Read top-level metadata of a loaded OpenAPI document in the current Replay project.
46
+
47
+ **What it does**
48
+ - Scan: omit \`field\` to list the metadata fields present in the document, each with its shape (and item count for lists/maps).
49
+ - Read: pass one \`field\` to get that section's value. Large sections are paginated — pass the returned cursor to get the next page.
50
+
51
+ **Use when**
52
+ - You need API-level context: server/base URLs, auth model, tag grouping, titles/descriptions, external docs.
53
+ - You want to discover which metadata a document has (scan), then read a specific section.
54
+
55
+ **Never use when**
56
+ - You need operations, request/response schemas, or reusable components — use the \`search\` tool. Not available here: paths, webhooks, components, definitions, parameters, responses.
57
+
58
+ **Input guidance**
59
+ - \`apiId\` is required (the loaded API's id, the same identifier the search tool uses).
60
+ - Read one \`field\` at a time; use \`cursor\` only to continue a section you already started.`,vo=n.strictObjectType({apiId:n.stringType().describe("ID of the loaded API document to read (the API URI, the same identifier used by the search tool)."),field:n.stringType().optional().describe('Top-level metadata field to read (e.g. "info", "servers", "tags", "externalDocs", "securitySchemes"). Omit to scan: list the metadata fields present in the document. Operations and reusable components (paths, webhooks, components, definitions, parameters, responses) are not available here — use the search tool for those.'),cursor:n.stringType().optional().describe("Opaque cursor to continue a previously truncated section. Only meaningful together with `field`.")}),To=n.objectType({name:n.stringType(),kind:n.enumType(["scalar","object","array"]),count:n.numberType().int().nonnegative().optional()}),So=n.objectType({name:n.stringType(),hint:n.stringType()}),ko=n.objectType({available:n.arrayType(To),blocked:n.arrayType(So)}),Co=n.objectType({field:n.stringType(),value:n.unknownType(),start:n.numberType().int().nonnegative().optional(),end:n.numberType().int().nonnegative().optional(),total:n.numberType().int().nonnegative().optional(),truncated:n.booleanType(),nextCursor:n.stringType().nullable()}),Ao=n.unionType([ko,Co]),Oo=k(Ao),Eo={description:bo,inputSchema:vo,outputSchema:Oo,needsApproval:!1},N={paths:"Use the search tool to read endpoints and operations.",webhooks:"Use the search tool to read webhook operations.",components:"Use the search tool to read reusable components such as schemas and responses.",definitions:"Use the search tool to read reusable schemas.",parameters:"Use the search tool to read reusable parameters.",responses:"Use the search tool to read reusable responses."},Ae=["id","srcType","fileDependencies"],j=[{name:"securitySchemes",sources:["components.securitySchemes","securityDefinitions"]}],_o=10,se=500;function Oe(e,t){for(const o of t.sources){const r=xo(e,o);if(Ro(r))return r}return null}function xo(e,t){return t.split(".").reduce((o,r)=>x(o)?o[r]:void 0,e)}function Ro(e){return e==null?!1:Array.isArray(e)?e.length>0:x(e)?Object.keys(e).length>0:!0}function x(e){return!(e===null||typeof e!="object"||Array.isArray(e))}const $o=new Set(j.flatMap(e=>e.sources.map(t=>t.split(".")[0])));function ie(e){const t=[],o=[];for(const[r,s]of Object.entries(e)){if(r in N){o.push({name:r,hint:N[r]});continue}Ae.includes(r)||$o.has(r)||t.push(ae(r,s))}for(const r of j){const s=Oe(e,r);s!==null&&t.push(ae(r.name,s))}return{available:t,blocked:o}}function ae(e,t){const o={name:e,kind:Po(t)};return Array.isArray(t)?o.count=t.length:x(t)&&(o.count=Object.keys(t).length),o}function Po(e){return Array.isArray(e)?"array":x(e)?"object":"scalar"}function qo(e,t,o){if(Array.isArray(t))return ce(e,t,o,r=>r);if(x(t)){const r=Object.keys(t).sort().map(s=>[s,t[s]]);return ce(e,r,o,s=>Object.fromEntries(s))}return{field:e,value:U(t),truncated:!1,nextCursor:null}}function No(e,t){if(!e)return 0;let o;try{o=atob(e)}catch{return null}const r=o.lastIndexOf(":");if(r===-1||o.slice(0,r)!==t)return null;const i=Number(o.slice(r+1));return!Number.isInteger(i)||i<0?null:i}function ce(e,t,o,r){const s=Math.min(Math.max(o,0),t.length),i=Math.min(s+_o,t.length),a=i<t.length;return{field:e,value:U(r(t.slice(s,i))),truncated:a,start:s,end:i,total:t.length,nextCursor:a?Uo(e,i):null}}function U(e){if(typeof e=="string")return e.length>se?`${e.slice(0,se)}…`:e;if(Array.isArray(e))return e.map(U);if(x(e)){const t={};for(const[o,r]of Object.entries(e))t[o]=U(r);return t}return e}function Uo(e,t){return btoa(`${e}:${t}`)}const Do=new Map(j.flatMap(e=>e.sources.map(t=>[t.split(".")[0],e.name])));function Mo(e,t,o){const r=j.find(a=>a.name===t);if(r){const a=Oe(e,r);return a===null?de(t):le(t,a,o)}if(t in N)return y(`"${t}" is not available from this tool. ${N[t]}`,{field:t});if(Ae.includes(t))return y(`"${t}" is not an OpenAPI metadata field.`,{field:t});const s=Do.get(t);if(s!==void 0)return y(`"${t}" is not a valid field name. Use "${s}" instead.`,{field:t});const i=e[t];return i==null?de(t):le(t,i,o)}function le(e,t,o){const r=No(o,e);return r===null?y(`The provided cursor is not valid for field "${e}". Omit the cursor to start from the first page.`,{field:e}):{isError:!1,data:qo(e,t,r)}}function de(e){return y(`"${e}" is not present in this API. Call this tool without a "field" to scan the available metadata fields.`,{field:e})}function jo(e){return async t=>{const o=e.apis.get({noproxy:!0})??[],r=o.find(i=>i.id===t.apiId);if(!r)return y(`API "${t.apiId}" is not loaded.`,{availableApiIds:o.map(i=>i.id)});const s=r;return t.field==null&&t.cursor!==void 0?y("`cursor` requires `field` to be set — omit `cursor` and pass `field` to read a specific section, or omit both to scan. Returning scan results.",{data:ie(s)}):t.field!==void 0?Mo(s,t.field,t.cursor):{isError:!1,data:ie(s)}}}const Ee={name:"get_api_metadata",definition:Eo,createExecutor:e=>jo(e.store)},Lo="Manage Replay collections and YAML-backed Arazzo workflows/steps.\n\n**What it does**\n- Creates or deletes collections, workflows, and steps.\n- Can copy the focused step tab into another workflow as a new step.\n- Returns a summary plus created/affected IDs when available.\n\n**Use when**\n- You need structural changes to collection/workflow/step hierarchy.\n- Create a step from an OpenAPI operation, ad-hoc request, or blank step.\n- Persist the focused step tab into a target collection/workflow.\n\n**Never use when**\n- Only editing fields on an existing step, no structural change needed.\n- Required target ids are unknown or ambiguous.\n- You are not sure destructive deletes are intended.\n\n**Input guidance**\n- Provide `payload` with one `action` from:\n - `create_collection`, `delete_collection`\n - `create_workflow`, `delete_workflow`\n - `create_step`, `delete_step`, `move_step`\n - `save_tab_to_collection`\n- Resolve missing `collectionId`, `workflowId`, and `stepId` before mutation.\n- `create_collection`: `title` is display name and derives file ID.\n- `create_step`: choose one source shape:\n - `operation` for OpenAPI link (`apiId`, `path`, `method`, optional `operationId`)\n - `xOperation` for ad-hoc HTTP (`method` + `url`)\n - omit both for a blank step\n- `create_step` optional initial fields: `description`, `parameters`, `body`, `outputs`, `successCriteria`.\n- `create_step` optional `index` inserts at that 0-based position (default: append). `move_step` moves a step to `toIndex` (0-based); indices clamp to the valid range.\n- `save_tab_to_collection`: provide `targetCollectionId`, `targetWorkflowId`, and `newStepName`.\n\n**Loop/budget guidance**\n- Prefer batching related structure setup in minimal calls per workflow.\n- Track returned `stepId` values; names may be uniquified on collisions.\n- Define outputs on producer steps; reference via `$steps.<stepId>.outputs.<name>` downstream.\n- Add `successCriteria` on created steps so workflow runs fail on unexpected responses.",Wo=n.objectType({action:n.literalType("create_collection"),title:n.stringType().min(1).describe("Collection display title (also used to derive the file id).")}).strict(),Fo=n.objectType({action:n.literalType("delete_collection"),collectionId:n.stringType().min(1).describe("Target collection id.")}).strict(),Bo=n.objectType({action:n.literalType("create_workflow"),collectionId:n.stringType().min(1).describe("Parent collection id."),name:n.stringType().min(1).describe("Workflow summary / display name.")}).strict(),Yo=n.objectType({action:n.literalType("delete_workflow"),collectionId:n.stringType().min(1),workflowId:n.stringType().min(1)}).strict(),zo=[d.TextContentType.Text,d.TextContentType.JSON,d.TextContentType.XML],Ho=n.objectType({name:n.stringType().min(1),in:n.enumType(["path","query","header","cookie"]),value:n.stringType()}).strict(),Go=n.objectType({name:n.stringType().min(1).describe("Output name."),expression:n.stringType().min(1).describe("Output expression.")}).strict(),Vo=n.objectType({condition:n.stringType().min(1),context:n.stringType().optional(),type:n.enumType(["simple","regex","jsonpath","xpath"]).optional()}).strict(),Ko=n.objectType({action:n.literalType("create_step"),collectionId:n.stringType().min(1),workflowId:n.stringType().min(1),stepName:n.stringType().min(1).optional().describe('Label used verbatim as the stepId, so pass a single camelCase token such as "updateUser", reusing the source operationId when there is one. Put prose in `description` instead (default: "New Step").'),description:n.stringType().min(1).optional().describe("Step description text (overrides default derived from stepName)."),parameters:n.arrayType(Ho).optional().describe("Initial request parameters (path, query, header, cookie)."),body:n.objectType({content:n.stringType().describe("Request body content as string."),contentType:n.enumType(zo).optional().describe("Request body content type.")}).strict().optional().describe("Initial request body."),outputs:n.arrayType(Go).optional().describe("Initial step outputs (mappings for later steps)."),successCriteria:n.arrayType(Vo).optional().describe("Initial success criteria rows."),operation:n.objectType({apiId:n.stringType().min(1).describe("API id."),path:n.stringType().min(1).describe("Request path."),method:n.stringType().min(1).describe("HTTP method."),operationId:n.stringType().min(1).optional().describe("Operation id.")}).optional().describe("OpenAPI operation link (apiId, path, method). Omit if using xOperation or a blank step."),xOperation:n.objectType({method:n.stringType().min(1).describe("HTTP method."),url:n.stringType().min(1).describe("Request URL.")}).optional().describe("Ad-hoc HTTP request (method + URL). Omit if using operation or a blank step."),index:n.numberType().int().min(0).optional().describe("0-based position to insert the new step at within the workflow. Omit to append at the end. Out-of-range values clamp to the nearest valid position.")}).strict(),Jo=n.objectType({action:n.literalType("delete_step"),collectionId:n.stringType().min(1),workflowId:n.stringType().min(1),stepId:n.stringType().min(1)}).strict(),Xo=n.objectType({action:n.literalType("move_step"),collectionId:n.stringType().min(1),workflowId:n.stringType().min(1),stepId:n.stringType().min(1).describe("Id of the existing step to move."),toIndex:n.numberType().int().min(0).describe("0-based target position for the step within the same workflow. Out-of-range values clamp to the nearest valid position.")}).strict(),Qo=n.objectType({action:n.literalType("save_tab_to_collection"),targetCollectionId:n.stringType().min(1),targetWorkflowId:n.stringType().min(1),newStepName:n.stringType().min(1).describe('Step id / label for the new step, used verbatim, so pass a single camelCase token such as "updateUser".')}).strict(),Zo=n.objectType({payload:n.discriminatedUnionType("action",[Wo,Fo,Bo,Yo,Ko,Jo,Xo,Qo])}).superRefine((e,t)=>{e.payload.action==="create_step"&&e.payload.operation&&e.payload.xOperation&&t.addIssue({code:n.ZodIssueCode.custom,message:"Only one of `operation` or `xOperation` may be specified."})}),en=n.objectType({summary:n.stringType(),collectionId:n.stringType().optional(),workflowId:n.stringType().optional(),stepId:n.stringType().optional()}),tn=k(en),on={description:Lo,inputSchema:Zo,outputSchema:tn,needsApproval:e=>e.payload.action==="delete_collection"||e.payload.action==="delete_workflow"||e.payload.action==="delete_step"||e.payload.action==="save_tab_to_collection"};function ue(e,t,o){return{...d.getEmptyRequestParameter(e),key:t,value:o,active:!0}}function nn(e,t,o){const r=new Map;for(const i of o)r.set(i.name,i.value);const s=[];for(const i of e){if(d.isInlineRequestParameter(i)&&i.key&&r.has(i.key)){const a=r.get(i.key);r.delete(i.key),s.push({...ue(t,i.key,a),id:i.id,...i.allowReserved!==void 0&&{allowReserved:i.allowReserved}});continue}s.push(i)}for(const i of o)r.has(i.name)&&(s.push(ue(t,i.name,r.get(i.name))),r.delete(i.name));return s}function rn(e,t){if(t.description!==void 0&&(e.description=t.description),t.body&&(e.requestBody={...e.requestBody,content:t.body.content,...t.body.contentType!==void 0&&{type:t.body.contentType}}),t.parameters?.length){const o=new Map;for(const r of t.parameters){const s=o.get(r.in)??[];s.push(r),o.set(r.in,s)}for(const r of Object.keys($)){const s=o.get(r);if(!s?.length)continue;const i=$[r];e.parameters[i]=nn(e.parameters[i],r,s)}}if(t.outputs?.length){const r=e.outputs.filter(s=>s.key||s.value);e.outputs=[...r,...t.outputs.map(s=>({id:crypto.randomUUID(),key:s.name,value:s.expression,active:!0}))]}if(t.successCriteria?.length)for(const o of t.successCriteria){const r=d.getEmptyCriterionObject(o.type??d.CriterionType.SIMPLE);e.successCriteria.push({...r,condition:o.condition,...o.context!==void 0&&{context:o.context}})}return e}function sn(e){return async t=>{switch(t.payload.action){case"create_collection":return an(t.payload,e);case"delete_collection":return cn(t.payload,e);case"create_workflow":return ln(t.payload,e);case"delete_workflow":return dn(t.payload,e);case"create_step":return un(t.payload,e);case"delete_step":return fn(t.payload,e);case"move_step":return mn(t.payload,e);case"save_tab_to_collection":return hn(t.payload,e)}}}function an(e,{store:t}){const o=d.getNewCollection({name:e.title.trim(),collections:t.collections});return t.collections.merge([o]),{isError:!1,data:{summary:`Created collection "${o.info.title}" (${o.id}).`,collectionId:o.id}}}function cn(e,{store:t,handleCloseByDataId:o}){const r=d.getCollectionFromStore(t,e.collectionId);if(!r)return y("Collection not found.",{collectionId:e.collectionId});const s=r.info.title.get();return D(r,o),r.set(d.none),{isError:!1,data:{summary:`Deleted collection "${s}" (${e.collectionId}).`,collectionId:e.collectionId}}}function ln(e,{store:t}){const o=d.getCollectionFromStore(t,e.collectionId);if(!o)return y("Collection not found.",{collectionId:e.collectionId});const r=d.getNewWorkflow({name:e.name.trim(),collection:o});return o.workflows.merge([r]),{isError:!1,data:{summary:`Created workflow "${r.summary??r.workflowId}" in collection ${e.collectionId}.`,collectionId:e.collectionId,workflowId:r.workflowId}}}function dn(e,{store:t,handleCloseByDataId:o}){if(!d.getCollectionFromStore(t,e.collectionId))return y("Collection not found.",{collectionId:e.collectionId});const s=d.getWorkflowFromStore(t,{collectionId:e.collectionId,workflowId:e.workflowId});return s?(D(s,o,{collectionId:e.collectionId,workflowId:null}),s.set(d.none),{isError:!1,data:{summary:`Deleted workflow ${e.workflowId} from collection ${e.collectionId}.`,collectionId:e.collectionId,workflowId:e.workflowId}}):y("Workflow not found.",{collectionId:e.collectionId,workflowId:e.workflowId})}async function un(e,{store:t,attachApiToCollection:o,convertOperationToReplayValue:r}){if(!d.getCollectionFromStore(t,e.collectionId))return y("Collection not found.",{collectionId:e.collectionId});const i=d.getWorkflowFromStore(t,{collectionId:e.collectionId,workflowId:e.workflowId});if(!i)return y("Workflow not found.",{collectionId:e.collectionId,workflowId:e.workflowId});const a=e.operation?{apiId:e.operation.apiId,path:e.operation.path.replace(/\{\{/g,"{").replace(/\}\}/g,"}"),method:e.operation.method.toLowerCase(),operationId:e.operation.operationId,isAdditionalOperation:!1}:void 0,l=e.xOperation?{method:e.xOperation.method,url:e.xOperation.url}:void 0;let c;a&&(c=d.getApiOperationFromStore(t.apis,a,r),c&&await o({collectionId:e.collectionId,apiId:a.apiId}));const p=d.getNewStep({name:e.stepName?.trim()||"New Step",workflow:i,operation:a,xOperation:l,apiOperation:c});rn(p,{description:e.description,parameters:e.parameters,body:e.body,outputs:e.outputs,successCriteria:e.successCriteria});const u=pn(i,p,e.index);return{isError:!1,data:{summary:`Created step ${p.stepId} at position ${u} in workflow ${e.workflowId}.`,collectionId:e.collectionId,workflowId:e.workflowId,stepId:p.stepId}}}function _e(e,t){return Math.min(Math.max(e,0),t)}function pn(e,t,o){const r=e.steps.length,s=o===void 0?r:_e(o,r);return e.steps.set(i=>(i.splice(s,0,t),i)),s}function fn(e,{store:t,handleCloseByDataId:o}){const r=d.getStepFromStore(t,{collectionId:e.collectionId,workflowId:e.workflowId,stepId:e.stepId});return r?(o({collectionId:e.collectionId,workflowId:e.workflowId,stepId:e.stepId}),r.set(d.none),{isError:!1,data:{summary:`Deleted step ${e.stepId} from workflow ${e.workflowId}.`,collectionId:e.collectionId,workflowId:e.workflowId,stepId:e.stepId}}):y("Step not found.",{collectionId:e.collectionId,workflowId:e.workflowId,stepId:e.stepId})}function mn(e,{store:t}){const o=d.getWorkflowFromStore(t,{collectionId:e.collectionId,workflowId:e.workflowId});if(!o)return y("Workflow not found.",{collectionId:e.collectionId,workflowId:e.workflowId});const r=o.steps.get({noproxy:!0}),s=r.findIndex(a=>a.stepId===e.stepId);if(s===-1)return y("Step not found.",{collectionId:e.collectionId,workflowId:e.workflowId,stepId:e.stepId});const i=_e(e.toIndex,r.length-1);return o.steps.set(a=>{const[l]=a.splice(s,1);return a.splice(i,0,l),a}),{isError:!1,data:{summary:`Moved step ${e.stepId} to position ${i} in workflow ${e.workflowId}.`,collectionId:e.collectionId,workflowId:e.workflowId,stepId:e.stepId}}}async function hn(e,{store:t,attachApiToCollection:o}){const r=d.getActiveTab(t);if(!r)return y("No active tab.");if(!d.isTabStepState(r))return y("Active tab is not a step tab.",{tabType:r.data.type.get()});const s=d.getStepForActiveStepTab(t,r);if(!s)return y("No step data available on the active tab.");if(!d.getCollectionFromStore(t,e.targetCollectionId))return y("Target collection not found.",{collectionId:e.targetCollectionId});const a=d.getWorkflowFromStore(t,{collectionId:e.targetCollectionId,workflowId:e.targetWorkflowId});if(!a)return y("Target workflow not found.",{collectionId:e.targetCollectionId,workflowId:e.targetWorkflowId});const l=d.getNewStep({name:e.newStepName.trim(),workflow:a,fromStep:s});return a.steps.merge([l]),l.operation?.apiId&&await o({collectionId:e.targetCollectionId,apiId:l.operation.apiId}),{isError:!1,data:{summary:`Added step ${l.stepId} to workflow ${e.targetWorkflowId}.`,collectionId:e.targetCollectionId,workflowId:e.targetWorkflowId,stepId:l.stepId}}}function D(e,t,o){if("workflows"in e){const s=e.id.get();e.workflows.forEach(i=>D(i,t,{collectionId:s,workflowId:null})),t({collectionId:s,workflowId:null,stepId:null});return}if("steps"in e){const s=e.workflowId.get();e.steps.forEach(i=>D(i,t,{collectionId:o?.collectionId,workflowId:s})),t({collectionId:o?.collectionId,workflowId:s,stepId:null});return}const r=e.stepId.get();t({collectionId:o?.collectionId,workflowId:o?.workflowId,stepId:r})}const xe={name:"manage_collection",definition:on,createExecutor:e=>sn(e)},yn=`Read, add, or change Replay environments (inputs and server mappings).
61
+
62
+ **What it does**
63
+ - Manages Replay project environments: inputs (values and secrecy) and per-\`apiId\` server URLs/variables.
64
+ - Supports reads (list/get) and mutations (add env, upsert/remove inputs and servers, set active).
65
+ - Uses Replay project state, not runtime OS/shell environment variables.
66
+
67
+ **Use when**
68
+ - You need current environment, input, or server values before configuring or running requests.
69
+ - You need reusable inputs or to point servers at different base URLs per environment.
70
+ - You need to create an environment or switch the active one for \`$inputs.*\` and server resolution.
71
+
72
+ **Never use when**
73
+ - You rely on stale chat context instead of a fresh read before accuracy-critical steps.
74
+ - You need to flip \`isSecret\` on an existing input via \`upsert_input\` (secrecy is preserved on update).
75
+
76
+ **Input guidance**
77
+ - Shape and per-action fields are defined by the tool schema: pass \`payload\` with a single \`action\`.
78
+ - Omit \`environment\` on supported actions to use the active environment (schema marks exceptions).
79
+ - Reference inputs in requests as \`$inputs.<name>\` or \`{$inputs.<name>}\`; names must exist in the target environment.
80
+
81
+ **Loop/budget guidance**
82
+ - Re-read environment/input data when decisions depend on up-to-date values.
83
+ - Batch related input/server changes for the same environment when practical.
84
+ - After changing the active environment, re-check assumptions that depended on the previous one.`,O=n.stringType().min(1).optional().describe("Environment name. Omit to use the active environment."),In=n.objectType({action:n.literalType("get_environments")}).strict(),gn=n.objectType({action:n.literalType("get_active_environment")}).strict(),wn=n.objectType({action:n.literalType("get_inputs"),environment:O}).strict(),bn=n.objectType({action:n.literalType("get_servers"),environment:O}).strict(),vn=n.objectType({action:n.literalType("get_input"),environment:O,inputName:n.stringType().min(1)}).strict(),Tn=n.objectType({action:n.literalType("upsert_input"),environment:O,name:n.stringType().min(1),value:n.stringType(),isSecret:n.booleanType().optional().describe("Only when creating a new input name: whether the value is secret (default false). Ignored when the name already exists.")}).strict(),Sn=n.objectType({action:n.literalType("remove_input"),environment:O,inputName:n.stringType().min(1)}).strict(),K=n.objectType({name:n.stringType().min(1),value:n.stringType()}).strict(),kn=n.objectType({action:n.literalType("upsert_server"),environment:O,apiId:n.stringType().min(1),value:n.stringType(),variables:n.arrayType(K).optional()}).strict(),Cn=n.objectType({name:n.stringType().min(1),value:n.stringType(),isSecret:n.booleanType().optional().describe("Defaults to false when omitted.")}).strict(),An=n.objectType({apiId:n.stringType().min(1),value:n.stringType(),variables:n.arrayType(K).optional()}).strict(),On=n.objectType({action:n.literalType("add_environment"),environment:n.stringType().min(1).describe("Name of a new environment to create."),inputs:n.arrayType(Cn).optional().describe("Optional initial inputs for the new environment."),servers:n.arrayType(An).optional().describe("Optional initial server mappings for the new environment."),setActive:n.booleanType().optional().describe("When true, also set the new environment as active.")}).strict(),En=n.objectType({action:n.literalType("remove_server"),environment:O,apiId:n.stringType().min(1)}).strict(),_n=n.objectType({action:n.literalType("set_active_environment"),environment:n.stringType().min(1).describe("Name of the environment to activate.")}).strict(),xn=n.objectType({payload:n.discriminatedUnionType("action",[In,On,gn,wn,bn,vn,Tn,Sn,kn,En,_n])}),Rn=n.objectType({summary:n.stringType(),environmentNames:n.arrayType(n.stringType()).optional(),inputs:n.arrayType(n.objectType({name:n.stringType(),isSecret:n.booleanType(),value:n.stringType()})).optional(),servers:n.arrayType(n.objectType({apiId:n.stringType(),value:n.stringType(),variables:n.arrayType(K)})).optional(),input:n.objectType({name:n.stringType(),isSecret:n.booleanType(),value:n.stringType()}).optional(),environment:n.stringType().optional(),apiId:n.stringType().optional()}),$n=k(Rn),Pn={description:yn,inputSchema:xn,outputSchema:$n,needsApproval:e=>e.payload.action==="add_environment"||e.payload.action==="set_active_environment"||e.payload.action==="upsert_input"||e.payload.action==="remove_input"||e.payload.action==="upsert_server"||e.payload.action==="remove_server"};function qn(e){return async(t,o)=>{switch(t.payload.action){case"get_environments":return Nn(e);case"add_environment":return Un(e,t.payload);case"get_active_environment":return Dn(e);case"set_active_environment":return zn(e,t.payload);case"get_inputs":return Mn(e,t.payload);case"get_servers":return jn(e,t.payload);case"get_input":return Ln(e,t.payload);case"upsert_input":return Wn(e,t.payload);case"remove_input":return Fn(e,t.payload);case"upsert_server":return Bn(e,t.payload);case"remove_server":return Yn(e,t.payload)}}}function Nn(e){const t=e.activeEnvironmentId.get(),o=e.environments.map(r=>r.name.get());return{isError:!1,data:{summary:`${o.length} environment(s). Active: "${t}".`,environmentNames:o}}}function Un(e,t){if(L(e,t.environment))return y("Environment already exists.",{environment:t.environment});const r=(t.inputs??[]).map(i=>({name:i.name,value:i.value,isSecret:i.isSecret??!1})),s=(t.servers??[]).map(i=>({apiId:i.apiId,value:i.value,variables:i.variables??[]}));return e.environments.merge([{name:t.environment,inputs:r,servers:s,state:d.ItemState.Normal}]),t.setActive&&e.activeEnvironmentId.set(t.environment),{isError:!1,data:{summary:t.setActive?`Added environment "${t.environment}" and set it active.`:`Added environment "${t.environment}".`,environment:t.environment}}}function Dn(e){const t=e.activeEnvironmentId.get();return L(e,t)?{isError:!1,data:{summary:`Active environment is "${t}".`,environment:t}}:y("Active environment not found.",{environment:t})}function Mn(e,t){const o=E(e,t.environment);if(!o.ok)return o.result;const{name:r,env:s}=o,i=Gn(s.get());return{isError:!1,data:{summary:`${i.length} input(s) in "${r}".`,environment:r,inputs:i}}}function jn(e,t){const o=E(e,t.environment);if(!o.ok)return o.result;const{name:r,env:s}=o,i=Vn(s.get());return{isError:!1,data:{summary:`${i.length} server(s) in "${r}".`,environment:r,servers:i}}}function Ln(e,t){const o=E(e,t.environment);if(!o.ok)return o.result;const{name:r,env:s}=o,i=s.inputs.find(p=>p.name.get()===t.inputName);if(!i)return y("Input not found.",{environment:r,inputName:t.inputName});const{name:a,isSecret:l,value:c}=i.get();return{isError:!1,data:{summary:`Input "${a}" (${l?"secret":"plain"}) in "${r}".`,environment:r,input:{name:a,isSecret:l,value:Re(l,c)}}}}function Wn(e,t){const o=E(e,t.environment);if(!o.ok)return o.result;const{name:r,env:s}=o,a=s.inputs.get().find(c=>c.name===t.name),l=a?a.isSecret:t.isSecret??!1;return s.inputs.set(c=>[...c.filter(p=>p.name!==t.name),{name:t.name,value:t.value,isSecret:l}]),{isError:!1,data:{summary:`Upserted input "${t.name}" in "${r}" (${l?"secret":"plain"}).`,environment:r}}}function Fn(e,t){const o=E(e,t.environment);if(!o.ok)return o.result;const{name:r,env:s}=o,i=s.inputs.get(),a=i.filter(l=>l.name!==t.inputName);return a.length===i.length?y("Input not found.",{environment:r,inputName:t.inputName}):(s.inputs.set(a),{isError:!1,data:{summary:`Removed input "${t.inputName}" from "${r}".`,environment:r}})}function Bn(e,t){const o=E(e,t.environment);if(!o.ok)return o.result;const{name:r,env:s}=o;return s.servers.set(i=>{const a=i.findIndex(p=>p.apiId===t.apiId),l=a>=0&&t.variables===void 0?i[a].variables:t.variables??[],c={apiId:t.apiId,value:t.value,variables:l};return a>=0?i.toSpliced(a,1,c):[c,...i]}),{isError:!1,data:{summary:`Upserted server "${t.apiId}" in "${r}".`,environment:r,apiId:t.apiId}}}function Yn(e,t){const o=E(e,t.environment);if(!o.ok)return o.result;const{name:r,env:s}=o,i=s.servers.get(),a=i.filter(l=>l.apiId!==t.apiId);return a.length===i.length?y("Server not found.",{environment:r,apiId:t.apiId}):(s.servers.set(a),{isError:!1,data:{summary:`Removed server "${t.apiId}" from "${r}".`,environment:r,apiId:t.apiId}})}function zn(e,t){return L(e,t.environment)?(e.activeEnvironmentId.set(t.environment),{isError:!1,data:{summary:`Active environment is now "${t.environment}".`}}):y("Environment not found.",{environment:t.environment})}function Hn(e,t){return t??e.activeEnvironmentId.get()}function E(e,t){const o=Hn(e,t),r=L(e,o);return r?{ok:!0,name:o,env:r}:{ok:!1,result:y(t!==void 0?"Environment not found.":"Active environment not found.",{environment:o})}}function L(e,t){return e.environments.find(o=>o.name.get()===t)}function Gn(e){return e.inputs.map(t=>({name:t.name,isSecret:t.isSecret,value:Re(t.isSecret,t.value)}))}function Vn(e){return e.servers.map(t=>({apiId:t.apiId,value:t.value,variables:t.variables.map(o=>({name:o.name,value:o.value}))}))}function Re(e,t){return e?d.SECRET_MASK:t}const $e={name:"manage_environment",definition:Pn,createExecutor:e=>qn(e.store)},Kn=d.REQUEST_METHODS,Jn="Open or focus a tab in Replay.\n\n**What it does**\n- Opens or focuses tabs only (navigation/state change).\n- Does not execute requests and does not create/update/delete saved assets.\n\n**Use when**\n- You need to open a request, operation, collection, workflow, or step tab.\n- You need to bring an already open tab into focus.\n\n**Never use when**\n- You need to execute an HTTP request.\n- You need to run a workflow — use `run_workflow`; it runs headlessly and returns the run's `historyId`.\n- You need to create or edit saved workflow content.\n- You are re-opening the same target only to re-verify unchanged state.\n\n**Input guidance**\n- Use ids exactly as stored in Replay (same spelling and casing).\n- Choose action by intent:\n - `open_new_request`: one-off HTTP call; blank tab when `requestUrl` is omitted, prefilled ad-hoc request when provided (`requestMethod` defaults to GET).\n - `open_operation`: open a spec operation by `operationId` in an unsaved request tab.\n - `open_collection` / `open_workflow` / `open_step`: open saved entities by their required ids.\n - `focus_tab`: focus an already open tab by zero-based `tabIndex`.\n\n**Loop/budget guidance**\n- Open or focus each target once per task unless state changed.\n- Prefer `focus_tab` for already open tabs instead of repeatedly opening the same target.",Xn=n.enumType(["focus_tab","open_operation","open_collection","open_workflow","open_step","open_new_request"]),Qn=n.strictObjectType({action:Xn.describe("Tab to open or focus; see tool description for unsaved vs collection actions."),tabIndex:n.numberType().optional().describe("focus_tab only: zero-based index of an already open tab."),collectionId:n.stringType().optional().describe("open_collection, open_workflow, or open_step."),workflowId:n.stringType().optional().describe("open_workflow or open_step."),stepId:n.stringType().optional().describe("open_step only."),operationId:n.stringType().optional().describe("open_operation only: OpenAPI operationId from the loaded spec; opens an unsaved request tab for that operation."),requestUrl:n.stringType().optional().describe("open_new_request only: absolute or host URL for an unsaved ad-hoc request (e.g. https://example.com/api). Omit for a blank tab."),requestMethod:n.enumType(Kn).optional().describe("open_new_request with requestUrl: HTTP method; defaults to GET if omitted.")}).superRefine((e,t)=>{const r=(e.requestUrl?.trim()??"").length>0,s=e.requestMethod!==void 0;(r||s)&&e.action!=="open_new_request"&&t.addIssue({code:n.ZodIssueCode.custom,message:"requestUrl and requestMethod are only valid with action open_new_request.",path:["requestUrl"]}),s&&!r&&t.addIssue({code:n.ZodIssueCode.custom,message:"requestMethod requires a non-empty requestUrl.",path:["requestMethod"]})}),Zn=n.objectType({outcome:n.enumType(["focused","opened"]),activeTabIndex:n.numberType().int().nonnegative(),tabId:n.stringType(),tabType:n.nativeEnumType(d.TabDataType)}),er=k(Zn),tr={description:Jn,inputSchema:Qn,outputSchema:er,needsApproval:!1};function W({items:e,id:t,messages:o,getItemId:r,formatAmbiguousMatch:s,buildNotFoundDetails:i}){const a=t.trim();if(!a)return{ok:!1,message:o.empty};const l=e.filter(c=>r(c)===a);return l.length===1?{ok:!0,value:l[0]}:l.length>1?{ok:!1,message:o.ambiguous,details:{matches:l.map(s)}}:{ok:!1,message:o.notFound,details:i(a)}}function Pe(e,t){const o=W({items:e.collections,id:t,messages:{empty:"Collection id is empty.",ambiguous:"Multiple collections share that id; ids must be unique.",notFound:"No collection found with that id."},getItemId:s=>s.id.get(),formatAmbiguousMatch:s=>({id:s.id.get(),title:s.info.title.get()}),buildNotFoundDetails:s=>({collectionId:s})});if(!o.ok)return o;const r=o.value;return{ok:!0,value:{collectionId:r.id.get(),collection:r}}}function J(e,t,o){const r=Pe(e,t);if(!r.ok)return r;const s=W({items:r.value.collection.workflows,id:o,messages:{empty:"Workflow id is empty.",ambiguous:"Multiple workflows share that id in this collection; ids must be unique.",notFound:"No workflow found with that id in the given collection."},getItemId:a=>a.workflowId.get(),formatAmbiguousMatch:a=>({workflowId:a.workflowId.get(),summary:a.summary?.get()}),buildNotFoundDetails:a=>({collectionId:r.value.collectionId,workflowId:a})});if(!s.ok)return s;const i=s.value;return{ok:!0,value:{collectionId:r.value.collectionId,workflowId:i.workflowId.get(),workflow:i}}}function qe(e,t,o,r){const s=J(e,t,o);if(!s.ok)return s;const i=W({items:s.value.workflow.steps,id:r,messages:{empty:"Step id is empty.",ambiguous:"Multiple steps share that id in this workflow; ids must be unique.",notFound:"No step found with that id in the given workflow."},getItemId:l=>l.stepId.get(),formatAmbiguousMatch:l=>({stepId:l.stepId.get(),description:l.description?.get()}),buildNotFoundDetails:l=>({collectionId:s.value.collectionId,workflowId:s.value.workflowId,stepId:l})});if(!i.ok)return i;const a=i.value;return{ok:!0,value:{collectionId:s.value.collectionId,workflowId:s.value.workflowId,stepId:a.stepId.get(),step:a}}}function Ne(e,t){const o=d.getOperationsList(e.apis).filter(s=>s.operationId!=null&&s.operationId!=="");if(!o.length)return{ok:!1,message:"No operations with operationId in loaded APIs."};const r=W({items:o,id:t,messages:{empty:"operationId is empty.",ambiguous:"Multiple operations share that operationId; disambiguation is not supported with id-only matching.",notFound:"No operation found with that operationId in loaded APIs."},getItemId:s=>s.operationId,formatAmbiguousMatch:s=>({apiId:s.apiId,path:s.path,method:s.method}),buildNotFoundDetails:s=>({operationId:s})});return r.ok?{ok:!0,value:r.value}:r}function X(e,t,o,r){t=t.trim(),o=o.trim(),r=r.trim();const s=!t&&!o&&!r,i=!!(t&&o&&r);if(!s&&!i)return{ok:!1,message:"Provide all three ids for a saved step, or three empty strings for the focused unsaved request tab."};if(i){const h=qe(e,t,o,r);return h.ok?{ok:!0,value:h.value.step}:h}const a=d.getActiveTab(e);if(!a||!d.isTabStepState(a))return{ok:!1,message:"Active tab is not a step tab.",details:{tabType:a?.data?.type?.get()}};const l=a.data.collectionId.get(),c=a.data.workflowId.get(),p=a.data.stepId.get();if(!d.tabStepUidsMatch(l,c,p,"","",""))return{ok:!1,message:"Active tab does not match unsaved draft target. Open the unsaved request tab first, or pass collection/workflow/step ids for a saved step.",details:{activeTab:{collectionId:l,workflowId:c,stepId:p}}};const u=a.data.draftStep.ornull;return u?{ok:!0,value:u}:{ok:!1,message:"No draft step on the active tab."}}function Ue(e){return{apiId:e.apiId,path:e.path,method:e.method,operationId:e.operationId||void 0,isAdditionalOperation:e.isAdditionalOperation}}function De(e,t,o){const r=o.getApiOperation(t),i=e.tabsState.tabs.get({noproxy:!0}).findIndex(l=>{const c=l.data;return d.isTabType(c,d.TabDataType.Step)&&c.draftStep?.operation?.apiId===t.apiId&&c.draftStep?.operation?.path===t.path&&c.draftStep?.operation?.method===t.method});if(i!==-1)return o.handleTabChange(i),"focused";const a=d.createTabFromOperation(t,r);return o.addNewTab({...a,state:d.TabState.Normal}),"opened"}function or(e,t){return(o,r)=>{try{switch(o.action){case"focus_tab":return nr(e,t,o.tabIndex);case"open_operation":return rr(e,t,o.operationId);case"open_collection":return sr(e,t,o.collectionId);case"open_workflow":return ir(e,t,o.collectionId,o.workflowId);case"open_step":return ar(e,t,o.collectionId,o.workflowId,o.stepId);case"open_new_request":return cr(e,t,o.requestUrl,o.requestMethod);default:{const s=o.action;return b("Unsupported open_tab action.",{action:s})}}}catch(s){return b("Failed to open or focus tab.",{cause:s instanceof Error?s.message:String(s)})}}}function nr(e,t,o){if(o===void 0)return b("tabIndex is required when action is focus_tab");const r=e.tabsState.tabs.get({noproxy:!0});return o<0||o>=r.length?b("Invalid tab index.",{tabIndex:o,tabCount:r.length}):(t.handleTabChange(o),R(e,"focused"))}function rr(e,t,o){const r=o?.trim();if(!r)return b("operationId is required when action is open_operation");const s=Ne(e,r);if(!s.ok)return b(s.message,s.details);const i=De(e,Ue(s.value),t);return R(e,i)}function sr(e,t,o){const r=o?.trim();if(!r)return b("collectionId is required when action is open_collection");const s=Pe(e,r);if(!s.ok)return b(s.message,s.details);const{collectionId:i}=s.value,a=e.tabsState.tabs.findIndex(l=>{const c=l.data.get();return d.isTabType(c,d.TabDataType.Collection)&&c.collectionId===i})!==-1;return t.openCollectionTab({collectionId:i,activeTabName:d.TAB_NAMES.COLLECTION_SETTINGS}),R(e,a?"focused":"opened")}function ir(e,t,o,r){const s=o?.trim(),i=r?.trim();if(!s)return b("collectionId is required when action is open_workflow");if(!i)return b("workflowId is required when action is open_workflow");const a=J(e,s,i);if(!a.ok)return b(a.message,a.details);const{collectionId:l,workflowId:c}=a.value,p=e.tabsState.tabs.findIndex(u=>{const h=u.data.get();return d.isTabType(h,d.TabDataType.Workflow)&&h.workflowId===c&&h.collectionId===l})!==-1;return t.openWorkflowTab({collectionId:l,workflowId:c,activeTabName:d.TAB_NAMES.WORKFLOW_SETTINGS}),R(e,p?"focused":"opened")}function ar(e,t,o,r,s){const i=o?.trim(),a=r?.trim(),l=s?.trim();if(!i)return b("collectionId is required when action is open_step");if(!a)return b("workflowId is required when action is open_step");if(!l)return b("stepId is required when action is open_step");const c=qe(e,i,a,l);if(!c.ok)return b(c.message,c.details);const{collectionId:p,workflowId:u,stepId:h}=c.value,f=e.tabsState.tabs.get().find(({data:g})=>d.isTabType(g,d.TabDataType.Step)&&g.collectionId===p&&g.workflowId===u&&g.stepId===h&&g.historyId===null)!==void 0;return t.openStepTabFromCollection({collectionId:p,workflowId:u,stepId:h,state:d.TabState.Normal}),R(e,f?"focused":"opened")}function cr(e,t,o,r){return o?t.openStepTabFromXOperation({method:r??"GET",url:o}):t.handleNewTabOpen(),R(e,"opened")}function R(e,t){const o=e.tabsState.activeTabIdx.get(),r=e.tabsState.tabs.get({noproxy:!0})[o];return r?lr(t,o,r.id,r.data.type):b("No active tab after navigation.",{activeTabIndex:o})}function b(e,t){return{isError:!0,error:{message:e,...t!==void 0?{details:t}:{}}}}function lr(e,t,o,r){return{isError:!1,data:{outcome:e,activeTabIndex:t,tabId:o,tabType:r}}}const Me={name:"open_tab",definition:tr,createExecutor:e=>or(e.store,e.context)},dr=`Report a short milestone status for the current task. UI-only: shows a one-line status above the next action; performs no workflow action and returns only acknowledgment.
85
+
86
+ Use when: starting a multi-step task after deciding the plan; crossing a major phase boundary (planning -> creating -> wiring -> verifying); starting a new debug attempt; or pivoting to a different approach.
87
+
88
+ Report at most one status per phase and only a few per task. Do not narrate routine tool calls, repeat the previous status, or use it in place of the final assistant response. Make the message concrete and user-facing: plain text, no markdown; name the relevant Arazzo object; describe milestone intent, not internal reasoning or tool names.
89
+
90
+ Duplicates of earlier statuses and statuses reported back-to-back with no action in between add no value; when detected, the acknowledgment includes a corrective note - act on it instead of reporting another status. Too many statuses in a row are blocked instead of acknowledged.`,ur=n.strictObjectType({message:n.stringType().trim().min(1).max(220).regex(/^[^\r\n]+$/,"must be a single line").describe("Short status line for a milestone (plan start, phase boundary, new debug attempt, pivot). Plain text, no markdown. Do not narrate every tool call.")}),pr=n.objectType({acknowledged:n.literalType(!0)}),fr=k(pr),mr={description:dr,inputSchema:ur,outputSchema:fr,needsApproval:!1};function hr(){return async()=>({isError:!1,data:{acknowledged:!0}})}const yr="Duplicate of a previous status - it adds nothing for the user. Do not repeat statuses; take a concrete action instead.";function Ir(e){return`You have reported ${e} statuses in a row with no action between them. Stop reporting status; take a concrete action (edit, run, or read) now.`}function gr(e){return`STOP: ${e} status messages in a row with no action taken. Reporting status is not progress. Do NOT call report_status again until you have made a change or run a request. Take the next concrete action now, or if you are blocked, say so in your final answer.`}const wr=[Te({key:e=>ve(e.message),warn:yr}),Zt({warnAfter:2,warnMessage:Ir,blockAfter:4,blockMessage:gr})],je={name:"report_status",definition:mr,guards:wr,createExecutor:e=>hr()},br=`Send the HTTP request for the **currently focused** Replay step tab and return the live response.
91
+
92
+ **What it does**
93
+ - Executes the request from the active step context (saved step or focused draft step).
94
+ - Returns response metadata: status, headers, cookies, body (truncated if large), url, duration, and size.
95
+ - Requires user approval before execution.
96
+
97
+ **Use when**
98
+ - You need to execute a saved workflow step currently open in Replay.
99
+ - You need to execute a focused unsaved draft request tab and inspect its live response.
100
+ - You need fresh runtime output before deciding edits, retries, or follow-up actions.
101
+
102
+ **Never use when**
103
+ - The wrong tab is focused; switch focus first so active tab and ids refer to the same target.
104
+ - You are only reading existing tab state without executing anything; use a read-only tab inspection tool.
105
+ - You have only partial identifiers for a saved step; provide all required ids together.
106
+ - You need project-asset lookup (schema/context/coordinates) rather than request execution.
107
+ - The request depends on cross-step \`$steps.*\` outputs; those resolve in workflow-run context, not single-step execution.
108
+
109
+ **Input guidance**
110
+ - Saved collection step: pass non-empty \`collectionId\`, \`workflowId\`, and \`stepId\`.
111
+ - Focused unsaved draft tab: pass three empty strings for \`collectionId\`, \`workflowId\`, and \`stepId\`.
112
+ - Mixed/partial ids are invalid; ids must be either all present or all empty.
113
+ - If needed, use tab switching first so ids and focus match the intended execution target.
114
+
115
+ **Loop/budget guidance**
116
+ - Execute when you need new runtime evidence, not by default after every edit.
117
+ - Re-run after meaningful request/config changes or when validating a fix/hypothesis.
118
+ - Avoid rapid duplicate runs with unchanged inputs when prior output already answers the question.
119
+ - For endpoint exploration, treat one run per endpoint as default budget unless inputs changed or rerun is explicitly needed.`,vr=n.objectType({collectionId:n.stringType().describe("Saved step: collection id. Unsaved draft tab on focus: empty string (with empty workflowId and stepId)."),workflowId:n.stringType().describe("Saved step: workflow id. Unsaved draft tab: empty string (with empty collectionId and stepId)."),stepId:n.stringType().describe("Saved step: step id. Unsaved draft tab: empty string (with empty collectionId and workflowId).")}).strict().superRefine((e,t)=>{const o=e.collectionId.trim(),r=e.workflowId.trim(),s=e.stepId.trim();!(o&&r&&s)&&!(!o&&!r&&!s)&&t.addIssue({code:n.ZodIssueCode.custom,message:"Provide all three ids for a saved step, or three empty strings for the focused unsaved request tab.",path:["collectionId"]})}),Tr=n.objectType({status:n.numberType().optional().describe("HTTP status code."),headers:n.arrayType(n.tupleType([n.stringType(),n.stringType()])).optional().describe("Response headers as key-value pairs."),cookies:n.arrayType(n.tupleType([n.stringType(),n.stringType()])).optional().describe("Response cookies as key-value pairs."),body:n.stringType().optional().describe("Response body, truncated if too large."),url:n.stringType().optional().describe("Final response URL."),duration:n.numberType().optional().describe("Request duration in milliseconds."),size:n.numberType().optional().describe("Response size in bytes.")}),Sr=k(Tr),kr={description:br,inputSchema:vr,outputSchema:Sr,needsApproval:()=>!0};function Cr(e,t){return async(r,s)=>{const i=d.getActiveTab(e);if(!i||!d.isTabStepState(i))return y("Active tab is not a step tab",{tabType:i?.data?.type?.get()});const a=i.data.collectionId.get(),l=i.data.workflowId.get(),c=i.data.stepId.get(),p=r.collectionId.trim(),u=r.workflowId.trim(),h=r.stepId.trim();if(!d.tabStepUidsMatch(a,l,c,p,u,h))return y("Active tab does not match the target step. Open the target tab first using open_tab.",{activeTab:{collectionId:a,workflowId:l,stepId:c},hint:a===null&&l===null&&c===null?"Focused tab is an unsaved request; pass empty strings for collectionId, workflowId, and stepId.":void 0});const g=d.getStepFromStore(e,{collectionId:p||null,workflowId:u||null,stepId:h||null})??i.data.draftStep.ornull;if(!g)return y("No step available for the active tab.");await d.makeRequest(e,g,t);const w=i.data.response.get();return w?{isError:!1,data:Ar(w)}:y("Request did not produce a response.")}}function Ar(e){return{status:e.status,headers:pe(e.headers),cookies:pe(e.cookies),body:Or(e.body??""),url:e.url??"",duration:e.duration,size:e.size}}function pe(e){const t=[];for(const o of e)t.push([String(o[0]),String(o[1])]);return t}function Or(e){return e.length<=m.RESPONSE_BODY_PREVIEW_MAX?e:`${e.slice(0,m.RESPONSE_BODY_PREVIEW_MAX)}… (truncated, total ${e.length} chars)`}const Le={name:"run_request",definition:kr,createExecutor:e=>Cr(e.store,e.settingsState)},Er=`Run an Arazzo workflow and return its result.
120
+
121
+ **What it does**
122
+ - Executes the whole workflow (all steps, with cross-step \`$steps.*\` resolution) and waits for it to finish.
123
+ - Saves the run and returns its \`historyId\` plus a per-step outcome summary.
124
+ - Does not open any tab. The user opens the finished run themselves from the link you provide.
125
+
126
+ **Use when**
127
+ - The user explicitly asks to run, re-run, test, or verify a workflow, or accepts a run you offered.
128
+ - You need the actual outcome of a workflow (status codes, which steps failed).
129
+
130
+ **Never use when**
131
+ - The user only asked to create, build, update, or fix a workflow. Creating is not running: finish at the saved workflow and offer the run instead of starting one.
132
+ - You want to confirm your own work. A build request never authorizes real traffic with the user's credentials.
133
+ - You need a single HTTP request — use \`run_request\`.
134
+ - You only need to read an already finished run that is open in a tab — use \`get_current_tab\`.
135
+
136
+ **Input guidance**
137
+ - \`collectionId\` and \`workflowId\` are required; use ids exactly as stored in Replay.
138
+
139
+ **After the run**
140
+ - Report the outcome from this tool's result; do not re-read it with other tools.
141
+ - When \`historyId\` is non-null, link to the run: \`[label](replay://workflow-run?collectionId=...&workflowId=...&historyId=...)\`. That link reopens this exact run; it never starts a new one. When it is null, say the run was not saved instead of building a link; never put the literal text null in the url.
142
+ - Each call starts a NEW run. Call it again only when the user wants another run.`,_r=n.strictObjectType({collectionId:n.stringType().describe("Id of the collection that holds the workflow."),workflowId:n.stringType().describe("Id of the workflow to run.")}),xr=n.objectType({stepId:n.stringType(),statusCode:n.numberType().int().nullable(),passed:n.booleanType()}),Rr=n.objectType({collectionId:n.stringType().describe("Resolved id of the collection that was run."),workflowId:n.stringType().describe("Resolved id of the workflow that was run."),historyId:n.stringType().nullable().describe("Id of this saved run. Put it in the workflow-run link as &historyId=... so the user can reopen this exact run. Null when history is not persisted."),success:n.booleanType().describe("Overall verdict from the execution engine. False when a step failed a non-warn check or the run hit the global timeout. Can be false even when passedSteps equals totalSteps: a step that failed and then passed on retry is not counted as failed here."),timedOut:n.booleanType().describe("True when the run hit the global execution timeout. Then success is false even if every listed step passed; report that the run timed out rather than blaming a step."),durationMs:n.numberType().describe("Total run time in milliseconds."),totalSteps:n.numberType().int().nonnegative(),passedSteps:n.numberType().int().nonnegative(),steps:n.arrayType(xr).describe("Per-step outcome, in execution order: stepId, HTTP statusCode, and pass/fail only — no check name or failure message.")}),$r=k(Rr),Pr={description:Er,inputSchema:_r,outputSchema:$r,needsApproval:!1};function qr(e,t){return async(o,r)=>{const s=o.collectionId.trim(),i=o.workflowId.trim();if(!s)return y("collectionId is required.");if(!i)return y("workflowId is required.");const a=J(e,s,i);if(!a.ok)return y(a.message,a.details);try{const{workflowResult:l,historyId:c,verdict:p}=await t({collectionId:a.value.collectionId,workflowId:a.value.workflowId});return{isError:!1,data:{collectionId:a.value.collectionId,workflowId:a.value.workflowId,historyId:c,success:p.succeeded,timedOut:p.timedOut,durationMs:l.totalTimeMs,totalSteps:p.totalSteps,passedSteps:p.passedSteps,steps:p.steps.map(({step:u,passed:h})=>({stepId:u.stepId,statusCode:u.response?.statusCode??null,passed:h}))}}}catch(l){return y(l instanceof Error?l.message:"Workflow execution failed.")}}}const We={name:"run_workflow",definition:Pr,createExecutor:e=>qr(e.store,e.runWorkflow)},Nr=25,Ur='RAG semantic search over OpenAPI specs and Arazzo assets in the current Replay project.\n\n**What it does**\n- Finds OpenAPI and Arazzo entities via natural-language query (scoped by `type`), returning up to `count` matches with detail via `include`.\n\n**Use when**\n- You need **initial schema/context** or request schema details from project assets.\n- You need canonical IDs/coordinates for an API, collection, workflow, or step.\n- You need to find operations/workflows/steps by natural language when IDs are unknown.\n\n**Never use when**\n- You are only verifying post-action UI changes in the active tab.\n- You already have exact IDs and only need active-tab state.\n- You are about to repeat an identical no-result query.\n\n**Input guidance**\n- Rewording the same query rarely helps; change `type`, `query`, or intent instead.\n- "Collection" is ambiguous (Arazzo entity vs API requests by tags/path/criteria). For request lists, use `type: api_operation` with query/filters—not Arazzo `collection`.\n- Pass all known filters (`apiId`, `path`, `method`, `operationId`, `collectionId`, `workflowId`, `stepId`); `query + filters` is most precise.\n- If semantic search returns no matches, ID filters enable direct lookup (see pairing on each filter field).\n- Phrase `query` like indexed text: titles/descriptions for collections/workflows; `step: …`; `operationId: …`; path/method/tags for endpoints.\n- If results are empty and lookup needs missing IDs, the tool may ask for them.\n',Dr=n.objectType({query:n.stringType().optional().describe("Natural language search query."),count:n.numberType().positive().max(Nr).optional().default(10),type:n.enumType(["api_operation","api","collection","workflow","step"]).describe("Scope results to this item type. api = OpenAPI spec; api_operation = API endpoint; collection = Arazzo collection; workflow = Arazzo workflow; step = Arazzo workflow step."),include:n.arrayType(n.enumType(["description","path","method","operationId","requestBody","parameters","security","responses","tags","successCriteria","title"])).describe("Fields to include in the response."),apiId:n.stringType().optional().describe("OpenAPI API ID (from loaded spec). For one endpoint, pair with operationId or path+method."),path:n.stringType().optional().describe("Filter by API path (e.g. /users). Use with method for precise operation matching."),method:n.stringType().optional().describe("Filter by HTTP method (GET, POST, PUT, DELETE, etc). Use with path for precise operation matching."),operationId:n.stringType().optional().describe("OpenAPI operationId. Requires apiId."),collectionId:n.stringType().optional().describe("Arazzo collection ID."),workflowId:n.stringType().optional().describe("Workflow ID within the collection. Requires collectionId."),stepId:n.stringType().optional().describe("Step ID within a workflow. Requires collectionId and workflowId.")}).strict(),Mr=n.unknownType(),jr={description:Ur,inputSchema:Dr,outputSchema:Mr,needsApproval:!1},Lr=["get","put","post","delete","options","head","patch","trace"],Wr=["query","x-query"];function Fr(e){return async(t,o)=>{const r=S.getSemanticSearchService(),s={type:t.type,apiId:t.apiId,operationId:t.operationId,path:t.path,method:t.method,collectionId:t.collectionId,workflowId:t.workflowId,stepId:t.stepId},i=t.query??"";let a=await r.search(i,t.count,s);return a.length===0&&(a=Gr(e,s)),a.length===0?{isError:!1,data:{message:`No results found. ${Br(t)}`}}:{isError:!1,data:{message:Vr(a,t.include)}}}}function Br(e){const t=[],{type:o,apiId:r,path:s,method:i,operationId:a,collectionId:l,workflowId:c,stepId:p,query:u}=e;switch(o){case"api":r||t.push("apiId");break;case"api_operation":{if(!r){t.push("apiId");break}const w=a!=null&&a!=="",T=s!=null&&s!==""&&i!=null&&i!=="";!w&&!T&&t.push("operationId","path","method");break}case"collection":l||t.push("collectionId");break;case"workflow":l?c||t.push("workflowId"):t.push("collectionId");break;case"step":l?c?p||t.push("stepId"):t.push("workflowId"):t.push("collectionId");break;default:if(l!=null&&l!==""&&(c?p||t.push("stepId"):t.push("workflowId")),r!=null&&r!==""){const w=a!=null&&a!=="",T=s!=null&&s!==""&&i!=null&&i!=="";!w&&!T&&t.push("operationId","path","method")}}u!=null&&u.trim()!==""||t.push("query");const f=[...new Set(t)];let g;return f.length===0?g="You already pass strong filters. Try a more specific natural-language query, or confirm IDs and paths match the project.":g=`To improve results, prefer adding (in order): ${f.slice(0,5).join(", ")}. When names are known but IDs are not, phrase query like indexed text: collection/workflow titles and descriptions; step: …; operationId: …; path/method/summary/tags for endpoints.`,g}function Yr(e,t){const o=e.paths??{};for(const[r,s]of Object.entries(o)){if(!s||typeof s!="object")continue;const i=s,a=[...Lr.filter(c=>c in s),...Wr.filter(c=>c in s)];for(const c of a){const p=s[c];if(!p||typeof p!="object")continue;const u=p;if(!(t.operationId&&(u.operationId??"")!==t.operationId)&&!(t.path&&r!==t.path)&&!(t.method&&c.toUpperCase()!==t.method.toUpperCase()))return{path:r,method:c,op:u,pathItem:i}}const l=i.additionalOperations;if(l&&typeof l=="object")for(const[c,p]of Object.entries(l)){if(!p||typeof p!="object")continue;const u=p;if(!(t.operationId&&(u.operationId??"")!==t.operationId)&&!(t.path&&r!==t.path)&&!(t.method&&c.toUpperCase()!==t.method.toUpperCase()))return{path:r,method:c,op:u,pathItem:i}}}return null}function zr(e,t){const{type:o,apiId:r,operationId:s,path:i,method:a}=t;if(!r)return[];const l=e.find(g=>g.id===r);if(!l)return[];if(o==="api")return[{...S.extractApiDocument(l).payload,score:1}];const c=s!=null&&s!=="",p=i!=null&&i!==""&&a!=null&&a!=="";if(!(o==="api_operation"||c||p||o==null&&(c||p)))return o==null?[{...S.extractApiDocument(l).payload,score:1}]:[];const h=Yr(l,{operationId:s,path:i,method:a});return h?[{...S.extractOperationDocument({apiId:l.id,apiTitle:l.info?.title??"Untitled API",path:h.path,method:h.method,op:h.op,pathItem:h.pathItem,globalSchemes:S.extractGlobalSecuritySchemes(l),apiSecurity:l.security}).payload,score:1}]:[]}function Hr(e,t){const{type:o,collectionId:r,workflowId:s,stepId:i}=t;if(!r)return[];const a=e.find(u=>u.id===r);if(!a)return[];const l=a.info?.title??"Untitled Collection";if(o==="collection")return[{...S.extractCollectionDocument(a).payload,score:1}];const c=()=>{if(!s||!i)return[];const u=a.workflows?.find(f=>(f.workflowId??"")===s);if(!u)return[];const h=u.steps?.find(f=>(f.stepId??"")===i);return h?[{...S.extractStepDocument({collectionId:r,collectionTitle:l,workflowId:s,workflowTitle:u.summary??s,step:h}).payload,score:1}]:[]},p=()=>{if(!s)return[];const u=a.workflows?.find(h=>(h.workflowId??"")===s);return u?[{...S.extractWorkflowDocument({collectionId:r,collectionTitle:l,workflow:u}).payload,score:1}]:[]};return o==="step"?c():o==="workflow"?p():o==null?i&&s?c():s?p():[{...S.extractCollectionDocument(a).payload,score:1}]:[]}function Gr(e,t){const o=e.apis.get(),r=e.collections.get(),{type:s}=t;return s==="api"||s==="api_operation"?zr(o,t):s==="collection"||s==="workflow"||s==="step"?Hr(r,t):[]}function Vr(e,t){return[Mt(e,t).join(`
143
+
144
+ `)].filter(r=>r!=null&&r.length>0).join(`
145
+
146
+ `)}const Kr="You already ran this exact search earlier in this conversation. If nothing has changed since then, reuse those results instead of repeating. If you expect different results (for example after an edit), do not just repeat the same search - change the query, the type, or the filters, or read the current state another way.",Jr=10;function Xr(e){const t=[e.type,C(e.query),C(e.apiId),C(e.operationId),C(e.path),C(e.method)?.toLowerCase(),C(e.collectionId),C(e.workflowId),C(e.stepId)];return t.every(o=>o==null)?null:JSON.stringify([...t,Qr(e),Zr(e)])}function Qr(e){return typeof e?.count=="number"?e.count:Jr}function Zr(e){return Array.isArray(e?.include)?[...new Set(e.include)].sort():[]}function C(e){if(typeof e!="string")return null;const t=ve(e);return t===""?null:t}const es=[Te({key:Xr,warn:Kr})],Fe={name:"search",definition:jr,guards:es,createExecutor:e=>Fr(e.store)},ts="Update security (x-security) for one or more Replay steps.\n\n**What it does**\n- Applies atomic add/update/remove changes to step security entries.\n- `add` UPSERTS by scheme identity: an existing entry with the same `schemeId` (or same `type` when `schemeId` is omitted) - including the auto-seeded entry created when the step was linked to its operation - is updated in place, never duplicated. Repeated identical wiring converges.\n- The result echoes each affected step's resulting security in `resultingState`; confirm from it, do NOT re-read tabs after mutation.\n- Empty security list falls back to No Auth.\n\n**Targeting**\n- Saved step: `collectionId` + `workflowId` + `stepId`.\n- Multi-step batch: set `changes[].stepId` per change (top-level `stepId` is the default and may be empty); wire a whole chain in ONE call.\n- Unsaved draft tab on focus: all three ids empty strings, no per-change stepId.\n\n**Choosing the type (match the OpenAPI scheme)**\n- http bearer -> `JWT` (`data.token`). A plain bearer token is NOT OAuth 2.0.\n- http basic -> `Basic Auth`, http digest -> `Digest Auth` (`data.username`, `data.password`).\n- apiKey -> `API key` (`data.name`, `data.key`, `data.location`); keep `data.key`'s `$inputs.<name>` segment identical to `data.name`.\n- oauth2 (grant-based flows only) -> `OAuth 2.0`; `data.grantType` is REQUIRED with flow values (`accessToken`, `clientId`, ...): `clientCredentials`, `clientCredentialsWithJwtAssertion`, `authorizationCode`, `authorizationCodeWithPkce`, `implicit`, `password`.\n- openIdConnect -> `OpenID Connect` (`data.openIdConnectUrl` plus OAuth2 fields).\n- `add` with a `schemeId` existing under a different type is rejected; use `update` at that index only to intentionally change a type.\n\n**Change shapes**\n- add/update: `{ action, stepId?, index?, type, schemeId?, data? }`; pass `schemeId` whenever known (it is the upsert identity), `index` is required for update.\n- remove: `{ action: \"remove\", stepId?, index }`.",os=["clientCredentials","clientCredentialsWithJwtAssertion","authorizationCode","authorizationCodeWithPkce","implicit","password"],ns={grantType:n.enumType(os).optional().describe("OAuth2 grant type."),clientId:n.stringType().optional(),clientSecret:n.stringType().optional(),tokenUrl:n.stringType().optional(),authorizationUrl:n.stringType().optional(),callbackUrl:n.stringType().optional(),accessToken:n.stringType().optional(),username:n.stringType().optional().describe("For password grant type."),password:n.stringType().optional().describe("For password grant type.")},rs=n.objectType({username:n.stringType().optional(),password:n.stringType().optional()}).strict(),ss=n.objectType({username:n.stringType().optional(),password:n.stringType().optional()}).strict(),is=n.objectType({token:n.stringType().optional()}).strict(),as=n.objectType({location:n.enumType(["header","query","cookie"]).optional(),name:n.stringType().optional().describe("Must match the OpenAPI security scheme `name` (header/query/cookie parameter name). Not the scheme component ref id (e.g. UserCookie)."),key:n.stringType().optional().describe("Secret value or `$inputs.<name>` / `{$inputs.<name>}`. The `<name>` segment must be identical to `data.name` (OpenAPI apiKey `name`, e.g. accessToken). Wrong example: `data.name` accessToken but key `$inputs.UserCookie` (UserCookie is the securitySchemes ref, not the cookie name).")}).strict(),Be=n.objectType({...ns}).strict(),cs=Be.extend({openIdConnectUrl:n.stringType().optional(),userInfoUrl:n.stringType().optional()}).strict(),Ye=n.stringType().optional().describe("Target step id for this change. Overrides the top-level stepId; use to batch changes for several steps of the same workflow in one call."),_=ao.extend({action:n.enumType(["add","update"]),schemeId:n.stringType().optional(),stepId:Ye}),ls=n.discriminatedUnionType("type",[_.extend({type:n.literalType(d.SecurityTypes.BasicAuth),data:rs.optional()}).strict(),_.extend({type:n.literalType(d.SecurityTypes.DigestAuth),data:ss.optional()}).strict(),_.extend({type:n.literalType(d.SecurityTypes.JWT),data:is.optional()}).strict(),_.extend({type:n.literalType(d.SecurityTypes.APIKey),data:as.optional()}).strict(),_.extend({type:n.literalType(d.SecurityTypes.OAuth2),data:Be.optional()}).strict(),_.extend({type:n.literalType(d.SecurityTypes.OpenIDConnect),data:cs.optional()}).strict()]),ds=V.extend({action:n.literalType("remove"),index:n.numberType().int().min(0).describe("0-based position of the entry in the step's current security list; every index in one call refers to that same list. Position, not schemeId, identifies the entry - a step can list the same scheme more than once."),stepId:Ye}).strict(),us=n.unionType([ls,ds]),ps=n.objectType({collectionId:n.stringType().describe("Saved step: collection id. Unsaved draft tab on focus: empty string (with empty workflowId and stepId)."),workflowId:n.stringType().describe("Saved step: workflow id. Unsaved draft tab: empty string (with empty collectionId and stepId)."),stepId:n.stringType().describe("Saved step: step id (default target for changes without their own stepId; may be empty when every change sets one). Unsaved draft tab: empty string (with empty collectionId and workflowId)."),changes:n.arrayType(us).min(1).describe("List of security changes to apply.")}).strict().superRefine((e,t)=>{const o=e.collectionId.trim(),r=e.workflowId.trim(),s=e.stepId.trim(),i=e.changes.map(u=>u.stepId?.trim()),a=i.every(Boolean),l=i.some(Boolean);!(o&&r&&(s||a))&&!(!o&&!r&&!s&&!l)&&t.addIssue({code:n.ZodIssueCode.custom,message:"Provide collectionId and workflowId plus a stepId for every change (top-level or per-change), or all empty ids for the focused unsaved request tab.",path:["collectionId"]})}),fs=ke,ms={description:ts,inputSchema:ps,outputSchema:fs,needsApproval:()=>!0},v={ADD:"add",UPDATE:"update",REMOVE:"remove"};function I(e,t){return{status:e,...t!==void 0&&{summary:t}}}function ze(e){if(!e||typeof e!="object"||!("meta"in e))return{};const{meta:t}=e;if(!t||typeof t!="object")return{};const o="totalChanges"in t&&typeof t.totalChanges=="number"?t.totalChanges:void 0,r="approvedChanges"in t&&typeof t.approvedChanges=="number"?t.approvedChanges:void 0;return{totalChanges:o,approvedChanges:r}}function He(e,t){return!Number.isInteger(t.index)||t.index<0||t.index>=e.length?{ok:!1,message:`Index ${t.index} out of bounds. Step has ${e.length} security entries.`}:{ok:!0,entry:e[t.index]}}const hs=new Set(["grantType","openIdConnectUrl","userInfoUrl"]);function ys(e){return e.type===d.SecurityTypes.OAuth2||e.type===d.SecurityTypes.OpenIDConnect}function fe(e,t){const o=e;for(const[r,s]of Object.entries(t))s!==void 0&&r in o&&(o[r]=s)}function me(e,t){const o=Object.entries(t);for(const[i,a]of o)i==="grantType"&&typeof a=="string"&&d.GRANT_TYPE_MAP[a]&&(e.grantType=d.GRANT_TYPE_MAP[a]);const r=e[e.grantType],s=new Set(Object.keys(d.OAUTH2_SECURITY[e.grantType]));for(const[i,a]of o)i!=="grantType"&&a!==void 0&&s.has(i)&&(r[i]=a)}function Ge(e){return e.securityType===d.SecurityTypes.NoAuth?null:e[e.securityType]?.schemeName??null}function Is(e,t){!t||e.securityType===d.SecurityTypes.NoAuth||(e.securitySchemeId=t,e[e.securityType].schemeName=t)}function Y(e,t){if(e.securityType=t.type,Is(e,t.schemeId),!t.data)return e;switch(t.type){case d.SecurityTypes.BasicAuth:case d.SecurityTypes.DigestAuth:case d.SecurityTypes.JWT:fe(e[t.type],t.data);break;case d.SecurityTypes.APIKey:{const{location:o,...r}=t.data;fe(e[d.SecurityTypes.APIKey],r),o&&(e[d.SecurityTypes.APIKey].location=d.getAPIKeyLocation(o));break}case d.SecurityTypes.OAuth2:me(e[d.SecurityTypes.OAuth2],t.data);break;case d.SecurityTypes.OpenIDConnect:{const{openIdConnectUrl:o,userInfoUrl:r,...s}=t.data;me(e[d.SecurityTypes.OpenIDConnect],s),o!==void 0&&(e[d.SecurityTypes.OpenIDConnect].openIdConnectUrl=o),r!==void 0&&(e[d.SecurityTypes.OpenIDConnect].userInfoUrl=r);break}}return e}function gs(e,t){return t.schemeId?e.findIndex(o=>o.securitySchemeId===t.schemeId||Ge(o)===t.schemeId):e.findIndex(o=>o.securityType===t.type)}function ws(e){return e.data?Object.entries(e.data).some(([t,o])=>o!==void 0&&!hs.has(t)):!1}function bs(e){return e.schemeId?`${e.type} (scheme '${e.schemeId}')`:e.type}function he(e,t,o,r){return e.has(t)?{ok:!1,message:`The security entry at index ${o} is targeted by both a mutation and a remove${r}; issue only one action for it.`}:null}function vs(e,t,o){let r=e;const s=[],i=t.filter(c=>c.action!==v.REMOVE),a=t.filter(c=>c.action===v.REMOVE),l=new Set;for(const c of a){const p=He(e,c);if(!p.ok)return{ok:!1,message:p.message};l.add(p.entry)}for(const c of i){if(c.action===v.ADD){const h=r.length===1&&r[0].securityType===d.SecurityTypes.NoAuth,f=h?-1:gs(r,c);if(f>=0){const w=r[f],T=he(l,w,f,o);if(T)return T;if(w.securityType!==c.type)return{ok:!1,message:`Scheme '${c.schemeId}' already exists${o} as ${w.securityType}, not ${c.type}. Match the documented scheme type (plain http/bearer -> JWT with data.token; OAuth 2.0 only for grant-based flows), or use action "update" at index ${f} to intentionally change the type.`};r=[...r],r[f]=Y(structuredClone(w),c),s.push(I("applied",`Updated existing ${bs(c)} in place (index: ${f})${o}`));continue}if(ys(c)&&ws(c)&&!c.data?.grantType)return{ok:!1,message:`grantType is required when adding ${c.type} security with flow values${o}. For a plain http/bearer token use type "${d.SecurityTypes.JWT}" with data.token instead.`};const g=Y(d.getEmptySingleSecurity(),c);r=h?[g]:[...r,g],s.push(I("applied",`Added ${c.type} security (index: ${r.length-1})${o}`));continue}if(c.index===void 0)return{ok:!1,message:"index is required for update action."};if(c.index>=r.length)return{ok:!1,message:`Index ${c.index} out of bounds. Step has ${r.length} security entries.`};const p=r[c.index],u=he(l,p,c.index,o);if(u)return u;if(p.securitySchemeId){const h=Ge(p);if(c.schemeId&&h!==c.schemeId)return{ok:!1,message:`schemeId mismatch at index ${c.index}. Expected ${h??"none"}.`}}r=[...r],r[c.index]=Y(structuredClone(p),c),s.push(I("applied",`Updated ${c.type} at index ${c.index}${o}`))}if(l.size>0){const c=r.filter(u=>!l.has(u)),p=r.length-c.length;r=c;for(let u=0;u<p;u++)s.push(I("applied"))}return r.length===0&&(r=[d.getEmptySingleSecurity()]),{ok:!0,security:r,applied:s}}function Ts(e){return async t=>{const{changes:o,collectionId:r,workflowId:s,stepId:i}=t,a=ze(t),l=i.trim(),c=new Map;for(const f of o){const g=f.stepId?.trim()||l,w=c.get(g);w?w.push(f):c.set(g,[f])}const p=[],u=[];for(const[f,g]of c){const w=X(e,r,s,f);if(!w.ok)return y(w.message,w.details);const T=w.value,ee=f||T.stepId.get(),ot=c.size>1?` for step '${ee}'`:"",nt=Array.from(T.security.get({noproxy:!0})),P=vs(nt,g,ot);if(!P.ok)return y(P.message);p.push(...P.applied),u.push({step:T,security:P.security,label:ee})}for(const f of u)f.step.security.set(f.security);const h=u.map(f=>`stepId=${f.label}
147
+ ${m.buildSecuritySection(f.security)}`).join(`
148
+
149
+ `);return{isError:!1,data:{totalChanges:a.totalChanges??o.length,approvedChanges:a.approvedChanges??o.length,applied:p,resultingState:h}}}}const Ve={name:"update_security",definition:ms,createExecutor:e=>Ts(e.store)},Ss=`Update an existing Replay step with atomic changes.
150
+
151
+ **What it does**
152
+ - Mutates an existing step only (no create/delete).
153
+ - Supports updates to \`url\`, \`method\`, \`description\`, \`body\`, \`parameters\`, \`outputs\`, and \`successCriteria\`.
154
+ - \`outputs\` \`add\` upserts by name: an existing output with the same name is updated in place, never duplicated.
155
+ - After outputs changes the result echoes the resulting outputs in \`resultingState\`; no follow-up read needed.
156
+
157
+ **Use when**
158
+ - You need targeted atomic edits to a saved step (by IDs) or the focused unsaved step.
159
+
160
+ **Never use when**
161
+ - IDs and focused tab refer to different execution contexts.
162
+ - You expect parameter edits to auto-rewrite URL; URL changes must be explicit.
163
+
164
+ **Input guidance**
165
+ - Saved step: non-empty \`collectionId\`, \`workflowId\`, \`stepId\`.
166
+ - Focused unsaved request tab: all three IDs are empty strings.
167
+ - \`changes\` must be non-empty; each item mutates one field and has \`action\` = \`add\` | \`update\` | \`remove\`.
168
+ - \`changes[].id\` is required for \`update/remove\`: use row UUID for \`parameters\`/\`outputs\` (never name/key), and exact existing \`condition\` for \`successCriteria\`.
169
+ - Data shapes:
170
+ - \`url\`: string
171
+ - \`description\`: string
172
+ - \`method\`: one of ${d.REQUEST_METHODS.join(", ")}
173
+ - \`parameters\`: \`{ name, in: path|query|header|cookie, value }\`
174
+ - \`outputs\`: \`{ name, expression }\`
175
+ - \`successCriteria\`: \`{ condition, context?, type? }\`
176
+ - \`body\`: \`{ content, contentType? }\` with \`contentType\` in text/plain, application/json, application/xml
177
+ - Environment variable refs in params/body: \`{$inputs.name}\` or bare \`$inputs.name\`; the input must exist on the active environment (create it there first if missing). Prefer \`$inputs.*\` for tokens/shared config.
178
+
179
+ **Loop/budget guidance**
180
+ - Batch related edits in one call; include all known edits up front.
181
+ - For OpenAPI-linked steps, avoid method/url changes.
182
+ - After changing path/query parameters, decide whether to add a separate URL change.
183
+ `,ks=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],Cs=[d.TextContentType.Text,d.TextContentType.JSON,d.TextContentType.XML],As=n.objectType({name:n.stringType().min(1),in:n.enumType(["path","query","header","cookie"]),value:n.stringType()}).strict(),Os=n.objectType({condition:n.stringType().min(1),context:n.stringType().optional().describe("Context for the expression."),type:n.enumType(["simple","regex","jsonpath","xpath"]).optional()}).strict(),Es=A.extend({field:n.literalType("url"),data:n.stringType().min(1).describe("New request URL for step.")}).strict(),_s=A.extend({field:n.literalType("description"),data:n.stringType().describe("New step description text.")}).strict(),xs=A.extend({field:n.literalType("method"),data:n.enumType(ks).describe("New HTTP method for x-operation step.")}).strict(),Rs=A.extend({field:n.literalType("parameters"),data:As.optional().describe("Parameter data. Required for add/update actions.")}).strict(),$s=A.extend({field:n.literalType("outputs"),data:n.objectType({name:n.stringType().min(1).describe("Output name."),expression:n.stringType().min(1).describe("Output expression.")}).strict().optional().describe("Output mapping. Required for add/update actions.")}).strict(),Ps=A.extend({field:n.literalType("successCriteria"),data:Os.optional().describe("Success criterion. Required for add/update actions.")}).strict(),qs=A.extend({field:n.literalType("body"),data:n.objectType({contentType:n.enumType(Cs).optional().describe("Request body content type. Allowed: text/plain, application/json, application/xml."),content:n.stringType().describe("Request body content as string.")}).strict().describe("Request body content and optional content type.")}).strict(),Ns=n.discriminatedUnionType("field",[Es,_s,xs,Rs,$s,Ps,qs]),Us=n.objectType({collectionId:n.stringType().describe("Saved step: collection id. Unsaved draft tab on focus: empty string (with empty workflowId and stepId)."),workflowId:n.stringType().describe("Saved step: workflow id. Unsaved draft tab: empty string (with empty collectionId and stepId)."),stepId:n.stringType().describe("Saved step: step id. Unsaved draft tab: empty string (with empty collectionId and workflowId)."),changes:n.arrayType(Ns).min(1).describe("List of individual changes to apply to the step.")}).strict().superRefine((e,t)=>{const o=e.collectionId.trim(),r=e.workflowId.trim(),s=e.stepId.trim();!(o&&r&&s)&&!(!o&&!r&&!s)&&t.addIssue({code:n.ZodIssueCode.custom,message:"Provide all three ids for a saved step, or three empty strings for the focused unsaved request tab.",path:["collectionId"]})}),Ds=ke,Ms={description:Ss,inputSchema:Us,outputSchema:Ds,needsApproval:()=>!0};function js(e){return e.replace(/\{\{([^{}\s]+)\}\}/g,"{$1}")}function z(e){return $[e]}function H(e,t){return e.id===t}function ye(e,t){return e.condition===t}function G(e,t){return d.isInlineRequestParameter(e)&&e.id===t}function Ie(e,t,o){return{...d.getEmptyRequestParameter(e),key:t,value:o,active:!0}}function Q(e,t){e.set(o=>[...o,...t])}function M(e,t,o){let r=!1;return e.set(s=>{const i=s.findIndex(l=>o.find(l,t));if(i<0)return s;const a=[...s];return a[i]=o.produce(s[i]),r=!0,a}),r}function Z(e,t,o){let r=!1;return e.set(s=>{const i=s.filter(a=>!o(a,t));return r=i.length<s.length,i}),r}function Ls(e,t){switch(e.action){case v.ADD:{if(!e.data)return I("failed","Failed parameter add because data is missing.");const{in:o,name:r,value:s}=e.data,i=z(o),a=Ie(o,r,s);return Q(t.parameters[i],[a]),I("applied",`Added ${o} parameter '${r}' (id: ${a.id})`)}case v.UPDATE:{if(!e.id)return I("failed","Failed parameter update because id is missing.");if(!e.data)return I("failed","Failed parameter update because data is missing.");const{in:o,name:r,value:s}=e.data,i=z(o);return M(t.parameters[i],e.id,{find:G,produce:l=>d.isInlineRequestParameter(l)?{...Ie(o,r,s),id:l.id,...l.allowReserved!==void 0&&{allowReserved:l.allowReserved}}:l})?I("applied"):I("failed",`Parameter with id '${e.id}' not found.`)}case v.REMOVE:{if(!e.id)return I("failed","Failed parameter remove because id is missing.");const o=e.id,r=e.data?.in,s=r?[z(r)]:Object.values($);let i=!1;for(const a of s)if(t.parameters[a].get({noproxy:!0}).some(c=>G(c,o))){i=Z(t.parameters[a],o,G);break}return i?I("applied"):I("failed",`Parameter with id '${o}' not found.`)}}}function Ws(e,t){switch(e.action){case v.ADD:{if(!e.data)return I("failed","Failed output add because data is missing.");const{name:o,expression:r}=e.data,s=t.outputs.get({noproxy:!0}).find(a=>a.key===o);if(s)return M(t.outputs,s.id,{find:H,produce:a=>({...a,key:o,value:r,active:!0})}),I("applied",`Updated existing output '${o}' in place (id: ${s.id})`);const i=crypto.randomUUID();return Q(t.outputs,[{id:i,key:o,value:r,active:!0}]),I("applied",`Added output '${o}' (id: ${i})`)}case v.UPDATE:{if(!e.id)return I("failed","Failed output update because id is missing.");if(!e.data)return I("failed","Failed output update because data is missing.");const{name:o,expression:r}=e.data;return M(t.outputs,e.id,{find:H,produce:i=>({...i,key:o,value:r,active:!0})})?I("applied"):I("failed",`Output with id '${e.id}' not found.`)}case v.REMOVE:return e.id?Z(t.outputs,e.id,H)?I("applied"):I("failed",`Output with id '${e.id}' not found.`):I("failed","Failed output remove because id is missing.")}}function Fs(e,t){switch(e.action){case v.ADD:{if(!e.data)return I("failed","Failed success criteria add because data is missing.");const{condition:o,context:r,type:s}=e.data,i=d.getEmptyCriterionObject(s??d.CriterionType.SIMPLE);return Q(t.successCriteria,[{...i,condition:o,...r!==void 0&&{context:r}}]),I("applied")}case v.UPDATE:{if(typeof e.id!="string")return I("failed","Failed success criteria update because id is missing.");if(!e.data)return I("failed","Failed success criteria update because data is missing.");const{condition:o,context:r,type:s}=e.data;return M(t.successCriteria,e.id,{find:ye,produce:a=>({...a,id:a.id||crypto.randomUUID(),condition:o,context:r??a.context,type:s??a.type??d.CriterionType.SIMPLE})})?I("applied"):I("failed",`Success criterion with condition '${e.id}' not found.`)}case v.REMOVE:return typeof e.id!="string"?I("failed","Failed success criteria remove because id is missing."):Z(t.successCriteria,e.id,ye)?I("applied"):I("failed",`Success criterion with condition '${e.id}' not found.`)}}function Bs(e){return async t=>{const{changes:o,collectionId:r,workflowId:s,stepId:i}=t,a=ze(t),l=X(e,r,s,i);if(!l.ok)return y(l.message,l.details);const c=l.value;if(o.some(f=>f.field==="method"||f.field==="url")&&c.operation.ornull!==null)return y("Cannot update method or url for a step linked to an OpenAPI operation.");const u=[];for(const f of o)switch(f.field){case"method":case"url":{c.xOperation.ornull===null&&c.xOperation.set({method:"GET",url:""});const g=c.xOperation.ornull;if(!g)return y("Step xOperation state is unavailable.");if(f.field==="method")g.method.set(f.data);else{const w=js(f.data);g.url.set(w);const T=c.parameters.queryParameters.get({noproxy:!0});c.parameters.queryParameters.set(d.mergeUrlParametersWithPreviousParameters(d.stringToQueryParameters(w),T))}u.push(I("applied"));break}case"description":c.description.set(f.data),u.push(I("applied"));break;case"body":c.requestBody.merge({content:f.data.content,...f.data.contentType!==void 0&&{type:f.data.contentType}}),u.push(I("applied"));break;case"parameters":u.push(Ls(f,c));break;case"outputs":u.push(Ws(f,c));break;case"successCriteria":u.push(Fs(f,c));break}const h=o.some(f=>f.field==="outputs");return{isError:!1,data:{totalChanges:a.totalChanges??o.length,approvedChanges:a.approvedChanges??o.length,applied:u,...h&&{resultingState:m.buildStepOutputsSection(c.outputs.get({noproxy:!0}))||"Outputs: (none)"}}}}}const Ke={name:"update_step",definition:Ms,createExecutor:e=>Bs(e.store)},Ys=`Search the public web via a nested agent and return a consolidated summary.
184
+
185
+ **What it does**
186
+ - Runs provider web search (results depend on the active model provider) and synthesizes findings for the parent agent.
187
+ - Does not read or mutate the Replay project, workflows, or UI.
188
+ - Requires user approval and costs multiple LLM round-trips.
189
+
190
+ **Use when**
191
+ - You need up-to-date or external information (docs, standards, release notes, vendor behavior) that is not in the project.
192
+ - The answer depends on the public internet rather than loaded specs or workflows.
193
+
194
+ **Never use when**
195
+ - You already have the URLs or facts needed to proceed.
196
+ - You need to edit workflows, run requests, or change environments.
197
+
198
+ **Input guidance**
199
+ - State a clear, self-contained query: what to look up and what to return (facts, links, version numbers, etc.).
200
+ - Prefer one web search call per distinct lookup; do not nest web search calls.`,zs=n.objectType({task:n.stringType().describe("What to search for on the web and what to return"),url:n.stringType().describe("The URL to execute search on")}),Hs=n.unknownType(),Gs={description:Ys,inputSchema:zs,outputSchema:Hs,needsApproval:!0},Vs=`
201
+ You are a web search subagent inside Replay, invoked by the parent agent to complete a single lookup task.
202
+
203
+ Your job is to search the public web and return verified findings for the parent agent to act on. You do not communicate with the end user directly.
204
+
205
+ You must use the provider web search tool to gather information. You cannot access the Replay project, UI, workflows, internal state, or any tools other than the web search tool.
206
+ `,Ks=`
207
+ - Never hallucinate or invent an answer when the information is not available from the web search.
208
+ - Do not use general knowledge, assumptions, prior training data, or speculation as evidence. Only make claims that are explicitly supported by the web search results.
209
+ - If the web search results do not contain enough information to answer the question, clearly state that the information could not be found or verified.
210
+ - Return a consolidated findings summary for the parent agent, not a user-facing completion message.
211
+ - Lead with the answer to the task, followed by supporting evidence (key facts, version numbers, dates, and relevant quotes).
212
+ - Include source URLs for all claims that are material to the parent agent's next steps.
213
+ - Clearly distinguish between verified findings, inferred conclusions, and information that could not be verified.
214
+ - When sources conflict, report the conflict and cite the competing sources rather than selecting a winner without evidence.
215
+ `,Js=m.prompt(m.section("role",Vs),m.section("output",Ks));function Xs(){return[m.createSystemMessage(Js)]}function Qs(e){const t=lt(e),o=n.createModel(e);return async(r,s)=>{try{return{isError:!1,data:{message:await n.streamText({model:o,system:Xs(),prompt:Zs(r),tools:t,toolChoice:"required",stopWhen:n.hasToolCall("web_search"),temperature:0,abortSignal:s.abortSignal}).text}}}catch(i){return{isError:!0,error:{message:i.message}}}}}function Zs(e){return m.buildMessageFromArray(["[URL]",e.url," ","[TASK]",e.task])}const Je={name:"web_search",definition:Gs,createExecutor:e=>Qs(e.model)},Xe=[Me,je,Le,We,Fe,Ve,Ke,Ce,xe,$e,Je,Ee];function ei(e){return Xe.some(t=>t.name===e)}function ti(e,t){for(const o of Xe)e.register(no(o,t[o.name]))}function Qe(e){const t=e.startsWith("tool-")?e.slice(5):e;return ei(t)?t:void 0}function Ze(e,t){return`${e}::${t}`}function F(e){return typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string"&&e.type.startsWith("tool-")&&"toolCallId"in e}function B(e){return e.state==="approval-requested"&&e.approval?.id!=null}function et(e){return e.state==="output-denied"?!0:e.state==="output-available"&&e.approval!=null}function tt(e){return e.parts.some(t=>F(t)&&B(t))}function oi(e){return e.some(tt)}function ni(e){return e.map(t=>tt(t)?{...t,parts:t.parts.map(ri)}:t)}function ri(e){return!F(e)||!B(e)?e:{...e,state:"output-denied",approval:{id:e.approval.id,approved:!1}}}function si(e){const t=[],o=[];let r=0;const s={},i=()=>{o.length!==0&&(t.push({kind:"reasoning-block",key:`reasoning-${r++}`,items:[...o]}),o.length=0)},a=l=>{const c=l.trim();if(c.length===0)return;const p=o[o.length-1];p?.kind==="action"&&p.text===c||o.push({kind:"action",text:c})};for(let l=0;l<e.length;l++){const c=e[l];if(c.type==="step-start")continue;if(c.type==="text"){i();const u=c.text??"";u.length>0&&t.push({kind:"text",text:u,key:`text-${l}`,workflowRunHistoryIds:Object.fromEntries(Object.entries(s).map(([h,f])=>[h,[...f]]))});continue}if(!F(c))continue;const p=Qe(c.type);if(p===ct){const u=ai(c);if(u){const h=Ze(u.collectionId,u.workflowId),f=s[h]??=[];f.includes(u.historyId)||f.push(u.historyId)}}if(p===at){const u=ci(c.input);u&&a(u);continue}if(B(c)||et(c)){i(),t.push({kind:"tool",part:c,key:`tool-${l}`});continue}}return i(),t}const ii=n.objectType({isError:n.literalType(!1),data:n.objectType({collectionId:n.stringType().min(1),workflowId:n.stringType().min(1),historyId:n.stringType().min(1)})});function ai(e){if(e.state!=="output-available")return;const t=ii.safeParse(e.output);return t.success?t.data.data:void 0}function ci(e){if(e==null||typeof e!="object")return;const t=e.message;if(typeof t!="string")return;const o=t.trim();return o.length>0?o:void 0}function li(e){return e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function di(e){return we.useQuery({queryKey:d.aiChatKeys.detail(e??""),queryFn:async()=>e?await d.AiChatServiceFactory.getInstance().findOne(e)??null:null,enabled:!!e})}function ui(e){return we.useInfiniteQuery({queryKey:d.aiChatKeys.infiniteHistory(e),initialPageParam:0,queryFn:async({pageParam:t})=>d.AiChatServiceFactory.getInstance().findRecentChatsPage({offset:t,limit:e}),getNextPageParam:t=>t.hasMore?t.nextOffset:void 0})}exports.AI_TAB=it;exports.AiConversationContext=Se;exports.CHANGE_ACTION=v;exports.LOCATION_TO_FIELD=$;exports.TOOL_APPROVAL_ACTION_BUTTON_LABELS=st;exports.TOOL_APPROVAL_BUTTON_LABELS=rt;exports.denyPendingApprovals=ni;exports.getApiMetadataBlueprint=Ee;exports.getContentItems=si;exports.getCurrentTabBlueprint=Ce;exports.getMessageTextContent=li;exports.hasPendingApprovalMessage=oi;exports.isApprovalRequested=B;exports.isApprovalSettled=et;exports.isToolApprovalPart=F;exports.manageCollectionBlueprint=xe;exports.manageEnvironmentBlueprint=$e;exports.openOrFocusOperationEditorTab=De;exports.openTabBlueprint=Me;exports.operationListItemToCollectionOperation=Ue;exports.parseToolName=Qe;exports.registerBuiltInTools=ti;exports.reportStatusBlueprint=je;exports.resolveOperation=Ne;exports.resolveRemovalTarget=He;exports.resolveStepOrDraft=X;exports.runRequestBlueprint=Le;exports.runWorkflowBlueprint=We;exports.searchBlueprint=Fe;exports.updateSecurityBlueprint=Ve;exports.updateStepBlueprint=Ke;exports.useAiChat=di;exports.useAiConversationContext=so;exports.useInfiniteChatHistory=ui;exports.webSearchBlueprint=Je;exports.workflowRunKey=Ze;