@redocly/replay 0.28.0 → 0.29.0-next.1

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 (57) hide show
  1. package/dist/replay-AiChatProvider-B1_-wlJK.js +6 -0
  2. package/dist/{replay-AiChatProvider-DUVoLgY2.js → replay-AiChatProvider-Z_799APd.js} +62 -58
  3. package/dist/{replay-AiChatSqliteDBStorage-C5AnRloD.js → replay-AiChatSqliteDBStorage-B9waB0dA.js} +1 -1
  4. package/dist/{replay-AiChatSqliteDBStorage-0evx56pl.js → replay-AiChatSqliteDBStorage-C_-_P0T7.js} +1 -1
  5. package/dist/{replay-AiPanel-CMjVD12K.js → replay-AiPanel-DvSoNrnz.js} +4 -4
  6. package/dist/{replay-AiPanel-PVgJioX3.js → replay-AiPanel-IRetnmbM.js} +1 -1
  7. package/dist/replay-FileWatcher-CUqV5dPp.js +1 -0
  8. package/dist/{replay-FileWatcher-CFYprlWN.js → replay-FileWatcher-CZZXT8GC.js} +4 -3
  9. package/dist/{replay-SemanticSearchService-Bh5xYa91.js → replay-SemanticSearchService-B8R-ATMA.js} +1 -1
  10. package/dist/{replay-SemanticSearchService-CulKCCNl.js → replay-SemanticSearchService-BzE8FK8a.js} +1 -1
  11. package/dist/{replay-SqliteDBStorage-Bz0muHEk.js → replay-SqliteDBStorage-CPOEQnSp.js} +1 -1
  12. package/dist/{replay-SqliteDBStorage-CVHRAsPD.js → replay-SqliteDBStorage-DVQZek3n.js} +1 -1
  13. package/dist/{replay-TauriFileSystemAdapter-B163-f2D.js → replay-TauriFileSystemAdapter-BfE1TXkK.js} +1 -1
  14. package/dist/{replay-TauriFileSystemAdapter-D4bOmvzP.js → replay-TauriFileSystemAdapter-Zb6LTS_-.js} +1 -1
  15. package/dist/{replay-TauriRootStorage-CjWUrnWz.js → replay-TauriRootStorage-BY7MGWGe.js} +1 -1
  16. package/dist/{replay-TauriRootStorage-2MPQE-3f.js → replay-TauriRootStorage-CUGppZsY.js} +2 -2
  17. package/dist/{replay-agent-loop-DYDFXAZj.js → replay-agent-loop-BB-UIrKo.js} +1 -1
  18. package/dist/{replay-agent-loop-BgYyBo9e.js → replay-agent-loop-BxPUGZq1.js} +3 -3
  19. package/dist/{replay-ai-chat-mappers-BEwNRQPV.js → replay-ai-chat-mappers-C4L8p2zl.js} +1 -1
  20. package/dist/{replay-ai-chat-mappers-CMtNqQHX.js → replay-ai-chat-mappers-DAyPOhQn.js} +1 -1
  21. package/dist/{replay-create-model-B2ZsGTjs.js → replay-create-model-BnoDQ7OX.js} +3 -3
  22. package/dist/{replay-create-model-DPxfOEfv.js → replay-create-model-ebcSRl3r.js} +3 -3
  23. package/dist/{replay-db-D4-LmLRk.js → replay-db-og5UtVrp.js} +1 -1
  24. package/dist/{replay-db-C9iqyMet.js → replay-db-xD_5VGuR.js} +1 -1
  25. package/dist/{replay-external-resolver-CTUbNZGW.js → replay-external-resolver-1bxcPBye.js} +1 -1
  26. package/dist/{replay-external-resolver-BXgVrfzk.js → replay-external-resolver-DtqY6Ddl.js} +2 -2
  27. package/dist/{replay-index-4TEahAPK.js → replay-index-C33Z16Rm.js} +16568 -16427
  28. package/dist/{replay-index-DcC173cC.js → replay-index-C7MCjO6i.js} +1 -1
  29. package/dist/{replay-index-Bdg7noSD.js → replay-index-Clfun2IN.js} +1 -1
  30. package/dist/{replay-index-Nz5obVS5.js → replay-index-LcDbGH39.js} +1090 -1077
  31. package/dist/{replay-index-B4U7iZuq.js → replay-index-PEthMsJx.js} +5 -5
  32. package/dist/replay-index-_srgnXqd.js +4 -0
  33. package/dist/{replay-index-B8O3wYqo.js → replay-index-rbCwID24.js} +1 -1
  34. package/dist/{replay-index-q63USe25.js → replay-index-wPsTqXSf.js} +1 -1
  35. package/dist/{replay-lint-s7ylMBWz.js → replay-lint-CVXT7IME.js} +3 -3
  36. package/dist/{replay-lint-4XFKTmSY.js → replay-lint-fhGv2lgR.js} +3 -3
  37. package/dist/{replay-lint-graphql-De2eDZnT.js → replay-lint-graphql-BhMbXKkF.js} +1 -1
  38. package/dist/{replay-lint-graphql-BsBWkZ6L.js → replay-lint-graphql-DtQhF_PM.js} +1 -1
  39. package/dist/{replay-periodic-revalidation-DJbblUef.js → replay-periodic-revalidation-Cuzq23M8.js} +1 -1
  40. package/dist/{replay-periodic-revalidation-BMFP7f-u.js → replay-periodic-revalidation-KHXYhF4T.js} +1 -1
  41. package/dist/{replay-resolve-BtNxNrKo.js → replay-resolve-C0VBozxM.js} +1 -1
  42. package/dist/{replay-resolve-BueEsOnR.js → replay-resolve-C2l91lf8.js} +1 -1
  43. package/dist/{replay-respect-run-Dfpbcsns.js → replay-respect-run-B25T_yI0.js} +3 -3
  44. package/dist/{replay-respect-run-B_dJjlti.js → replay-respect-run-BN4jlLVY.js} +1 -1
  45. package/dist/{replay-tauri-path-Bht3XIt7.js → replay-tauri-path-9tVlry3g.js} +1 -1
  46. package/dist/{replay-tauri-path-CiuYXh_j.js → replay-tauri-path-DpnuyiYr.js} +2 -2
  47. package/dist/{replay-useAiChatQueries-02CRdEPJ.js → replay-useAiChatQueries-Bi_6G8WU.js} +1 -1
  48. package/dist/{replay-useAiChatQueries-D2hh5omV.js → replay-useAiChatQueries-DLSFwWvn.js} +4 -4
  49. package/dist/{replay-validate-key-ALwOF1Ux.js → replay-validate-key-BQB45O00.js} +1 -1
  50. package/dist/{replay-validate-key-B7fbWbfv.js → replay-validate-key-DnQefCz3.js} +2 -2
  51. package/dist/replay.cjs +1 -1
  52. package/dist/replay.d.ts +13 -1
  53. package/dist/replay.js +1 -1
  54. package/package.json +2 -2
  55. package/dist/replay-AiChatProvider-BRqjyy2W.js +0 -6
  56. package/dist/replay-FileWatcher-DGLwO5Kd.js +0 -1
  57. package/dist/replay-index-CG9VN2JQ.js +0 -4
package/dist/replay.d.ts CHANGED
@@ -9,6 +9,7 @@ import { JSX } from 'react/jsx-runtime';
9
9
  import { NamedExoticComponent } from 'react';
10
10
  import { ReactElement } from 'react';
11
11
  import { ReactNode } from 'react';
12
+ import { ReplaySecurityType } from '../node_modules/@redocly/theme/src/components/ReplaySecuritySchemeActions/ReplaySecuritySchemeActions';
12
13
  import { SpanStatusCode } from '@opentelemetry/api';
13
14
  import { SystemModelMessage } from 'ai';
14
15
  import { Context as TelemetryContext } from '@opentelemetry/api';
@@ -774,6 +775,7 @@ declare type ReplayAppProps = {
774
775
  export declare type ReplayComponents = {
775
776
  ReplayGate: ComponentType<ReplayGateComponentProps> | null;
776
777
  ReplayTopBarActions: ComponentType<ReplayTopBarActionsComponentProps> | null;
778
+ ReplaySecuritySchemeActions: ComponentType<ReplaySecuritySchemeActionsComponentProps> | null;
777
779
  };
778
780
 
779
781
  declare type ReplayFeatures = {
@@ -800,13 +802,23 @@ export declare type ReplayOnChangeParams = {
800
802
  }>;
801
803
  };
802
804
 
803
- export declare function ReplayOverlay({ ReplayGate: ReplayGateProp, ReplayTopBarActions: ReplayTopBarActionsProp, ...props }: ReplayOverlayProps): JSX.Element;
805
+ export declare function ReplayOverlay({ ReplayGate: ReplayGateProp, ReplayTopBarActions: ReplayTopBarActionsProp, ReplaySecuritySchemeActions: ReplaySecuritySchemeActionsProp, ...props }: ReplayOverlayProps): JSX.Element;
804
806
 
805
807
  declare type ReplayOverlayProps = {
806
808
  onClose: () => void;
807
809
  onRequestChange?: (props: ReplayOnChangeParams) => void;
808
810
  } & ReplayAppProps & Partial<ReplayComponents>;
809
811
 
812
+ declare type ReplaySecuritySchemeActionsComponentProps = {
813
+ schemeId: string | null;
814
+ securityType: ReplaySecurityType;
815
+ environment: string;
816
+ operationId?: string;
817
+ value: string;
818
+ setValue: (value: string) => void;
819
+ apiId?: string;
820
+ };
821
+
810
822
  declare type ReplayTopBarActionsComponentProps = {
811
823
  environments: ReadonlyArray<{
812
824
  name: string;
package/dist/replay.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as s, ap as r, bF as t, bG as l, R as o, bH as b, bI as R, E as d, bJ as p, bK as m, F as n, bL as y, bM as A, bN as i, bO as u, ao as O, an as T, bP as h, bQ as E } from "./replay-index-4TEahAPK.js";
1
+ import { A as s, ap as r, bF as t, bG as l, R as o, bH as b, bI as R, E as d, bJ as p, bK as m, F as n, bL as y, bM as A, bN as i, bO as u, ao as O, an as T, bP as h, bQ as E } from "./replay-index-C33Z16Rm.js";
2
2
  import { O as P, h as C } from "./replay-oauth2-redirect-handler-CqKZB3aV.js";
3
3
  export {
4
4
  s as AI_PROVIDERS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/replay",
3
- "version": "0.28.0",
3
+ "version": "0.29.0-next.1",
4
4
  "type": "module",
5
5
  "main": "./dist/replay.cjs",
6
6
  "module": "./dist/replay.js",
@@ -16,7 +16,7 @@
16
16
  }
17
17
  },
18
18
  "peerDependencies": {
19
- "@redocly/theme": "0.69.0",
19
+ "@redocly/theme": "0.70.0-next.1",
20
20
  "@tanstack/react-query": "5.62.3",
21
21
  "react": "^19.2.7",
22
22
  "react-dom": "^19.2.7",
@@ -1,6 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const X=require("react/jsx-runtime"),i=require("react"),o=require("./replay-index-Nz5obVS5.js"),te=require("./replay-create-model-B2ZsGTjs.js"),fe=require("./replay-agent-loop-DYDFXAZj.js"),pe=require("./replay-db-C9iqyMet.js"),v=require("./replay-useAiChatQueries-02CRdEPJ.js"),B=require("@tanstack/react-query"),Z=require("./replay-ai-chat-mappers-CMtNqQHX.js");class ge{handlers=new Map;middlewares;constructor(t){this.middlewares=t?.middlewares??[]}register(t){this.handlers.set(t.name,t)}getToolSet(){const t={};for(const[n,s]of this.handlers)t[n]=this.buildTool(s);return t}buildTool(t){return{...t.definition,execute:this.wrapExecutor(t)}}wrapExecutor(t){const n=(a,r)=>({isError:!0,error:{message:a,details:r}}),s=this.applyMiddlewares(t.name,t.execute);return(a,r)=>{if(r.abortSignal?.aborted)return n("Tool execution was aborted.");try{const l=s(a,r);return typeof l=="object"&&l!==null&&"then"in l?l.then(c=>c,c=>n(c instanceof Error?c.message:"Unknown tool execution error")):l}catch(l){return n(l instanceof Error?l.message:"Unknown tool execution error")}}}applyMiddlewares(t,n){return this.middlewares.length===0?n:this.middlewares.reduceRight((s,a)=>a(t,s),n)}}function ce(){const e=B.useQueryClient();return B.useMutation({async mutationFn(t){const n=Z.buildPersistableUiChat(t);await o.AiChatServiceFactory.getInstance().upsert(n)},onSuccess(){e.invalidateQueries({queryKey:o.aiChatKeys.all()})},onError(t){console.error("Failed to upsert ai chat item:",t)}})}function Ce(e){const t=B.useQueryClient(),n=o.aiChatKeys.detailTitle(e??"");return B.useMutation({mutationKey:n,async mutationFn(s){if(t.isMutating({mutationKey:n,exact:!0})>1)return;const a=Z.buildPersistableUiChat(s);await o.AiChatServiceFactory.getInstance().upsert(a)},onSuccess(){t.invalidateQueries({queryKey:o.aiChatKeys.all()})},onError(s){console.error("Failed to upsert ai chat item:",s)}})}function me(){const e=B.useQueryClient();return B.useMutation({async mutationFn(t){await o.AiChatServiceFactory.getInstance().remove(t)},onMutate:async t=>{await e.cancelQueries({queryKey:o.aiChatKeys.all()});const n=e.getQueryData(o.aiChatKeys.all());n&&e.setQueryData(o.aiChatKeys.all(),n.filter(s=>s.id!==t)),e.setQueryData(o.aiChatKeys.detail(t),null),e.setQueriesData({queryKey:o.aiChatKeys.infiniteHistories()},s=>s&&{...s,pages:s.pages.map(a=>({...a,items:a.items.filter(r=>r.id!==t)}))})},onError(t){console.error("Failed to remove ai chat:",t)},onSettled(){e.invalidateQueries({queryKey:o.aiChatKeys.all()})}})}var ee,oe;function ve(){if(oe)return ee;oe=1;function e(t,n){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let s,a=0;return function(...l){clearTimeout(s);const c=Date.now(),p=c-a,h=n-p;h<=0?(a=c,t.apply(this,l)):s=setTimeout(()=>{a=Date.now(),t.apply(this,l)},h)}}return ee=e,ee}var we=ve();const Ie=o.getDefaultExportFromCjs(we);var ue=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},d=(e,t,n)=>(ue(e,t,"read from private field"),n?n.call(e):t.get(e)),A=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},R=(e,t,n,s)=>(ue(e,t,"write to private field"),t.set(e,n),n);function Te(e,t){return t!=null?Ie(e,t):e}var T,Y,J,j,Q,V,W,ne,se,ye=class{constructor(e=[]){A(this,T,void 0),A(this,Y,"ready"),A(this,J,void 0),A(this,j,new Set),A(this,Q,new Set),A(this,V,new Set),this.pushMessage=t=>{R(this,T,d(this,T).concat(t)),d(this,W).call(this)},this.popMessage=()=>{R(this,T,d(this,T).slice(0,-1)),d(this,W).call(this)},this.replaceMessage=(t,n)=>{R(this,T,[...d(this,T).slice(0,t),this.snapshot(n),...d(this,T).slice(t+1)]),d(this,W).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const s=n?Te(t,n):t;return d(this,j).add(s),()=>{d(this,j).delete(s)}},this["~registerStatusCallback"]=t=>(d(this,Q).add(t),()=>{d(this,Q).delete(t)}),this["~registerErrorCallback"]=t=>(d(this,V).add(t),()=>{d(this,V).delete(t)}),A(this,W,()=>{d(this,j).forEach(t=>t())}),A(this,ne,()=>{d(this,Q).forEach(t=>t())}),A(this,se,()=>{d(this,V).forEach(t=>t())}),R(this,T,e)}get status(){return d(this,Y)}set status(e){R(this,Y,e),d(this,ne).call(this)}get error(){return d(this,J)}set error(e){R(this,J,e),d(this,se).call(this)}get messages(){return d(this,T)}set messages(e){R(this,T,[...e]),d(this,W).call(this)}};T=new WeakMap;Y=new WeakMap;J=new WeakMap;j=new WeakMap;Q=new WeakMap;V=new WeakMap;W=new WeakMap;ne=new WeakMap;se=new WeakMap;var U,ae=class extends te.AbstractChat{constructor({messages:e,...t}){const n=new ye(e);super({...t,state:n}),A(this,U,void 0),this["~registerMessagesCallback"]=(s,a)=>d(this,U)["~registerMessagesCallback"](s,a),this["~registerStatusCallback"]=s=>d(this,U)["~registerStatusCallback"](s),this["~registerErrorCallback"]=s=>d(this,U)["~registerErrorCallback"](s),R(this,U,n)}};U=new WeakMap;function Ae({experimental_throttle:e,resume:t=!1,...n}={}){const s=i.useRef("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(s.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});const a={...n,onToolCall:u=>{var g,f;return(f=(g=s.current).onToolCall)==null?void 0:f.call(g,u)},onData:u=>{var g,f;return(f=(g=s.current).onData)==null?void 0:f.call(g,u)},onFinish:u=>{var g,f;return(f=(g=s.current).onFinish)==null?void 0:f.call(g,u)},onError:u=>{var g,f;return(f=(g=s.current).onError)==null?void 0:f.call(g,u)},sendAutomaticallyWhen:u=>{var g,f,_;return(_=(f=(g=s.current).sendAutomaticallyWhen)==null?void 0:f.call(g,u))!=null?_:!1}},r=i.useRef("chat"in n?n.chat:new ae(a));("chat"in n&&n.chat!==r.current||"id"in n&&n.id!=null&&r.current.id!==n.id)&&(r.current="chat"in n?n.chat:new ae(a));const c=i.useCallback(u=>r.current["~registerMessagesCallback"](u,e),[e,r.current.id]),p=i.useSyncExternalStore(c,()=>r.current.messages,()=>r.current.messages),h=i.useSyncExternalStore(r.current["~registerStatusCallback"],()=>r.current.status,()=>r.current.status),w=i.useSyncExternalStore(r.current["~registerErrorCallback"],()=>r.current.error,()=>r.current.error),I=i.useCallback(u=>{typeof u=="function"&&(u=u(r.current.messages)),r.current.messages=u},[r]);return i.useEffect(()=>{t&&r.current.resumeStream()},[t,r]),{id:r.current.id,messages:p,setMessages:I,sendMessage:r.current.sendMessage,regenerate:r.current.regenerate,clearError:r.current.clearError,stop:r.current.stop,error:w,resumeStream:r.current.resumeStream,status:h,addToolResult:r.current.addToolOutput,addToolOutput:r.current.addToolOutput,addToolApprovalResponse:r.current.addToolApprovalResponse}}const be=20;function Se(e){if(e.length===0)return"No OpenAPI specs loaded.";const t=e.slice(0,be),n=t.map(ke),s=e.length-t.length;return s>0&&n.push(` …and ${s} more API(s) not shown.`),[`Loaded APIs (${e.length}):`,...n].join(`
2
- `)}function ke(e){return[` apiId="${e.apiId}"`,`title="${e.title}"`,e.version?`version="${e.version}"`:null,e.primaryServer?`server="${e.primaryServer}"`:null].filter(Boolean).join(" ")}const Ee=30;function Me(e){if(e.length===0)return"No Arazzo collections loaded.";const t=[`Arazzo collections (${e.length}):`];let n=Ee,s=0,a=0;for(const l of e){if(n<=0){s+=l.workflows.length,a++;continue}if(t.push(Re(l)),n--,l.workflows.length===0)t.push(" (no workflows)");else if(n>=2){t.push(` workflows (${l.workflows.length}):`),n--;for(const c of l.workflows)n>0?(t.push(` ${_e(c)}`),n--):s++}else s+=l.workflows.length}const r=[s>0?`${s} more workflow(s)`:null,a>0?`${a} more collection(s)`:null].filter(Boolean);return r.length>0&&t.push(` …and ${r.join(", plus ")} not shown.`),t.join(`
3
- `)}function Re(e){const t=e.sourceApiIds.length>0?` apis=[${e.sourceApiIds.join(", ")}]`:"";return` collectionId="${e.collectionId}" title="${e.title}"${t}`}function _e(e){const t=`id="${e.workflowId}"`,n=e.summary?`label="${e.summary}"`:null,s=`[${e.stepCount} step${e.stepCount!==1?"s":""}]`;return[t,n,s].filter(Boolean).join(" ")}const Pe=20;function De(e){if(e.length===0)return"No environments configured.";const t=e.slice(0,Pe),n=t.map(xe),s=e.length-t.length;return s>0&&n.push(` …and ${s} more environment(s) not shown.`),[`Environments (${e.length}); * marks the active environment:`,...n].join(`
4
- `)}function xe(e){return[`${e.isActive?"*":" "} name="${e.name}"`,`inputs=${e.inputCount}`,`servers=${e.serverCount}`].join(" ")}const $e=30;function Oe(e){if(e.length===0)return"No tabs are open.";const t=e.slice(0,$e),n=t.map(We),s=e.length-t.length;return s>0&&n.push(` …and ${s} more tab(s) not shown.`),[`Open tabs (${e.length}), listed by tabIndex; * marks the active (focused) tab:`,...n].join(`
5
- `)}function We(e){const t=[e.collectionId?`collectionId="${e.collectionId}"`:null,e.workflowId?`workflowId="${e.workflowId}"`:null,e.stepId?`stepId="${e.stepId}"`:null,e.operationId?`operationId="${e.operationId}"`:null].filter(Boolean),n=[e.isPreview?"preview":null,e.isDraft?"draft":null,e.isHistory?"history":null].filter(Boolean);return[`${e.isActive?"*":" "} ${e.tabIndex}.`,`type="${e.type}"`,`label="${e.label}"`,...t,n.length>0?`(${n.join(", ")})`:null].filter(Boolean).join(" ")}const Ue="Auto-attached snapshot of the user's current Replay UI state. Generated by Replay before each step; not written by the user. It is a shallow summary — use tools to read detailed tab contents when needed.";function Be(e){const t=`
6
- `.repeat(2),n=[Ue,t,Oe(e.tabs),t,Se(e.apis),t,Me(e.collections),t,De(e.environments)].join("");return pe.section("active_state",n)}function Le(e){return e.map(Fe)}function Fe(e){return{apiId:e.id,title:e.info?.title??"Untitled API",version:e.info?.version,primaryServer:e.servers?.[0]?.url}}function Ne(e){return e.map(qe)}function qe(e){const t=(e.workflows??[]).map(s=>({workflowId:s.workflowId,summary:s.summary,stepCount:s.steps?.length??0})),n=(e.sourceDescriptions??[]).map(s=>s.apiId).filter(Boolean);return{collectionId:e.id,title:e.info?.title??"Untitled Collection",workflows:t,sourceApiIds:n}}function Ke(e,t){return e.filter(n=>n.state!==o.ItemState.Draft).map(n=>({name:n.name,isActive:n.name===t,inputCount:n.inputs.length,serverCount:n.servers.length}))}function je(e,t,n){return e.map((s,a)=>Qe(n,s,a,a===t))}function Qe(e,t,n,s){const a={tabIndex:n,type:t.data.type,isActive:s,isPreview:t.state===o.TabState.Preview};switch(t.data.type){case o.TabDataType.Collection:{const{collectionId:r}=t.data;return{...a,label:Ve(e,r)??r,collectionId:r}}case o.TabDataType.Workflow:{const{collectionId:r,workflowId:l}=t.data;return{...a,label:l,collectionId:r,workflowId:l}}case o.TabDataType.WorkflowRun:{const{collectionId:r,workflowId:l,historyId:c,label:p}=t.data;return{...a,label:p??`${l} run`,collectionId:r,workflowId:l,isHistory:c!=null}}case o.TabDataType.Step:{const r=t.data;return{...a,label:He(r),collectionId:r.collectionId,workflowId:r.workflowId,stepId:r.stepId,operationId:r.draftStep?.operation?.operationId??null,isDraft:!r.collectionId&&!r.workflowId,isHistory:r.historyId!=null}}}}function Ve(e,t){return e.find(n=>n.id===t)?.info.title}function He(e){if(e.stepId)return e.stepId;if(e.draftStep){const t=[o.getStepMethod(e.draftStep),o.getStepUrl(e.draftStep)].filter(Boolean).join(" ");if(t)return t}return"New Request"}function Ge(e){const t=e.get(o.collectionsAtom);return{tabs:je(e.get(o.tabsAtom),e.get(o.activeTabIdxAtom),t),apis:Le(e.get(o.apisAtom)),collections:Ne(t),environments:Ke(e.get(o.environmentsAtom),e.get(o.activeEnvironmentIdAtom))}}function ze(){const e=o.useCollections(),{tab:t}=o.useActiveTab(),n=t?.data??null;return i.useMemo(()=>{if(!n)return null;switch(n.type){case o.TabDataType.Collection:const a=o.findCollection(e,n.collectionId);return{...n,collection:a};case o.TabDataType.Workflow:const r=o.findWorkflow(e,{collectionId:n.collectionId,workflowId:n.workflowId});return{...n,workflow:r};case o.TabDataType.Step:const l=o.findStep(e,{collectionId:n.collectionId,workflowId:n.workflowId,stepId:n.stepId});return{...n,step:l};case o.TabDataType.WorkflowRun:const c=o.findWorkflow(e,{collectionId:n.collectionId,workflowId:n.workflowId});return{...n,workflow:c}}},[n,e])}function Ye(e){if(!e||typeof e!="object"||!("changes"in e)||!Array.isArray(e.changes))return e;const t=e.changes.filter(s=>s&&typeof s=="object"&&"approved"in s&&s.approved===!0),n="meta"in e&&typeof e.meta=="object"?e.meta:{};return{...e,changes:t,meta:{...n,totalChanges:e.changes.length,approvedChanges:t.length}}}function Je(){return(e,t)=>(n,s)=>t(Ye(n),s)}function Xe(){const{getApiOperation:e}=o.useApiOperationGetter(),t=o.useTabHandlers();return i.useMemo(()=>({getApiOperation:e,...t}),[e,t])}function Ze(e){const{convertOperationToReplayValue:t}=o.useSettingsContext(),n=ze(),s=Xe(),a=o.useSettings(),r=o.useStore(),{attachApiToCollection:l}=o.useCollectionActions(),{handleCloseByDataId:c}=o.useTabHandlers(),p=o.useRunWorkflow(),h=i.useRef(n);return h.current=n,{tools:i.useMemo(()=>{const I=new ge({middlewares:[Je()]});return v.registerBuiltInTools(I,{[v.reportStatusBlueprint.name]:void 0,[v.runRequestBlueprint.name]:{settings:a,store:r},[v.runWorkflowBlueprint.name]:{store:r,runWorkflow:p},[v.updateSecurityBlueprint.name]:{store:r},[v.updateStepBlueprint.name]:{store:r},[v.manageCollectionBlueprint.name]:{store:r,attachApiToCollection:l,handleCloseByDataId:c,convertOperationToReplayValue:t},[v.manageEnvironmentBlueprint.name]:{store:r},[v.webSearchBlueprint.name]:{model:e},[v.searchBlueprint.name]:{store:r},[v.openTabBlueprint.name]:{store:r,context:s},[v.getCurrentTabBlueprint.name]:{getActiveTabDetailedData:()=>h.current},[v.getApiMetadataBlueprint.name]:{store:r}}),I.getToolSet()},[l,t,c,e,s,p,a,r])}}function et(e){const{children:t,chatId:n,model:s,initialMessages:a,onChatFinish:r,onChatMessagesUpdated:l}=e,c=o.useSettings(),{getReuniteAuth:p}=o.useSettingsContext(),{tools:h}=Ze(s),{sendEvent:w}=o.useTelemetry(),I=i.useRef(h),u=i.useRef(s),{isOpen:g,openPanel:f,closePanel:_}=o.useAiPanel(),P=i.useRef(void 0),L=o.useStore();I.current=h,u.current=s;const C=i.useMemo(()=>{P.current?.end();const E=o.trace.getTracer("replay-ai-chat").startSpan("ai.chat.session",{attributes:{conversation_id:n}});P.current=E;const M=o.trace.setSpan(o.context.active(),E);return new fe.AgentLoop({activeConversationId:n,model:u.current,tools:I.current,sendEvent:w,parentCtx:M,getActiveStateMessage:()=>Be(Ge(L))})},[n,w,L]);i.useEffect(()=>()=>P.current?.end(),[]);const x=i.useMemo(()=>{if(C)return new te.DirectChatTransport({agent:C.getAgent()})},[C]);i.useEffect(()=>{C.setModel(s)},[C,s]),i.useEffect(()=>{C.registerTools(h)},[C,h]);const{messages:S,setMessages:D,sendMessage:F,status:k,error:H,stop:$,addToolApprovalResponse:N}=Ae({id:n,messages:a,transport:x,sendAutomaticallyWhen:te.lastAssistantMessageIsCompleteWithApprovalResponses,onFinish(E){if(!r||!C)return;r({agentLoop:C,chat:this},E)}}),b=i.useMemo(()=>k==="streaming"||k==="submitted",[k]),q=i.useCallback(()=>{c.aiEnabled===!0&&f()},[f,c.aiEnabled]),K=i.useCallback(()=>{_()},[_]),G=i.useCallback(async E=>{const M=E.trim();if(!(!M||!x)){if(s.provider===o.REUNITE_AI_PROVIDER){const y=await p?.();y?.baseUrl&&y?.accessToken&&C.setModel({provider:o.REUNITE_AI_PROVIDER,baseUrl:y.baseUrl,accessToken:y.accessToken})}D(y=>v.hasPendingApprovalMessage(y)?v.denyPendingApprovals(y):y),F({text:M})}},[C,p,s.provider,F,D,x]),m=i.useCallback(()=>{b&&$()},[b,$]);i.useEffect(()=>()=>{$()},[n,$]);const O=i.useCallback(E=>{const M=E(S),y=M.map(z=>z.message),re=[...S];for(const z of M)re[z.index]=z.message;D(re),l?.(y)},[S,l,D]),de=i.useMemo(()=>({messages:S,isStreaming:b,chatStatus:k,chatError:H,sendMessage:G,updateMessages:O,stopGeneration:m,addToolApprovalResponse:N}),[N,H,b,S,G,k,m,O]),he=i.useMemo(()=>({isOpen:g,openPanel:q,closePanel:K}),[g,q,K]);return X.jsx(v.AiConversationContext.Provider,{value:de,children:X.jsx(o.AiPanelContext.Provider,{value:he,children:t})})}function tt(e){return e.slice(-2)}function nt(e,t){return!!(e||t<1)}function st(e){return i.useCallback(async(t,n)=>{if(nt(e,n.messages.length))return null;const s=n.messages[0],a=v.getMessageTextContent(s.parts);try{return(await t.agentLoop.generateTitle(a)).trim()}catch(r){return console.error("Unable to generate chat title",r),null}},[e])}function rt({chatId:e,model:t,existingTitle:n}){const{mutate:s}=Ce(e),a=st(n);return i.useCallback(async(...r)=>{const l=await a(...r);l!==null&&l.length!==0&&s({id:e,model:t,messages:[],title:l})},[a,t,e,s])}function ot({chatId:e,model:t}){const{mutate:n}=ce();return i.useCallback((s,a)=>{const r=tt(a.messages);n({id:e,model:t,messages:r})},[t,e,n])}function at({chatId:e,model:t}){const{mutate:n}=ce();return i.useCallback(s=>{s.length!==0&&n({id:e,model:t,messages:s})},[t,e,n])}function it(e){return i.useMemo(()=>{const t=[o.REUNITE_MODEL_OPTION];if(e){for(const[n,s]of Object.entries(e))if(s.enabled&&s.apiKey){const a=s.models.map(r=>({...r,provider:n}));t.push(...a)}}return t},[e])}function ie(e){return typeof e=="function"?e():e}function le(e,t){try{const n=globalThis.localStorage.getItem(e);return n===null?ie(t):n}catch{return ie(t)}}function lt(e,t){try{globalThis.localStorage.setItem(e,t)}catch{console.error("Failed to write to localStorage",{key:e,value:t})}}function ct(e,t){const[n,s]=i.useState(()=>le(e,t)),a=i.useRef(t);a.current=t,i.useEffect(()=>{s(le(e,a.current))},[e]);const r=i.useCallback(l=>{s(c=>{const p=l instanceof Function?l(c):l;return lt(e,p),p})},[e]);return[n,r]}const ut="replay:ai:selectedModelId";function dt(e){const{availableModels:t,aiProviders:n,reuniteAuth:s}=e,[a,r]=ct(ut,o.REUNITE_MODEL_OPTION.id),l=t.some(p=>p.id===a)?a:o.REUNITE_MODEL_OPTION.id;return{model:i.useMemo(()=>{const p={provider:o.REUNITE_AI_PROVIDER,baseUrl:s.baseUrl,accessToken:s.accessToken},h=t.find(I=>I.id===l);if(!h||h.provider===o.REUNITE_AI_PROVIDER)return p;const w=n?.[h.provider];return!w||!w.apiKey||!w.enabled?p:{provider:h.provider,modelId:h.id,apiKey:w.apiKey}},[l,t,n,s]),selectedModelId:l,selectModel:r}}function ht(){const[e,t]=i.useState({baseUrl:"",accessToken:""}),{getReuniteAuth:n}=o.useSettingsContext();return i.useEffect(()=>{let s=!1;async function a(){const r=await n?.();s||t({baseUrl:r?.baseUrl??"",accessToken:r?.accessToken??""})}return a().catch(()=>{s||t({baseUrl:"",accessToken:""})}),()=>{s=!0}},[n]),e}function ft(e){const{children:t}=e,[n,s]=i.useState(Z.generateAiChatId),[a,r]=i.useState(n),[l,c]=i.useState(null),p=o.useSettings(),h=o.useSettingsContext(),{openPanel:w}=o.useAiPanel(),I=a!==n,u=i.useCallback(()=>{const m=Z.generateAiChatId();r(m),s(m)},[]),g=i.useCallback(m=>{r(m)},[]),{data:f}=v.useAiChat(a),_=ht(),P=it(h.aiProviders),{selectedModelId:L,model:C,selectModel:x}=dt({availableModels:P,aiProviders:h.aiProviders,reuniteAuth:_}),S=me(),D=ot({chatId:n,model:C}),F=at({chatId:n,model:C}),k=rt({chatId:n,model:C,existingTitle:f?.title}),H=i.useCallback((m,O)=>{O.isAbort||(D(m,O),k(m,O))},[D,k]),$=i.useCallback((...m)=>{F(...m)},[F]),N=i.useCallback(m=>{(a===m||n===m)&&u(),S.mutate(m)},[u,n,S,a]),b=f?.id;i.useEffect(()=>{b&&b!==n&&s(b)},[b,a,n]);const q=i.useCallback(()=>{c(null)},[]),K=i.useCallback(m=>{p.aiEnabled&&(u(),c(m),w())},[w,u,p.aiEnabled]),G=i.useMemo(()=>({chatId:n,model:C,availableModels:P,selectedModelId:L,selectModel:x,onSettingsOpen:h.onSettingsOpen,title:f?.title??o.defaultAiChatContextValue.title,isLoading:I,selectChat:g,removeChat:N,createNewChat:u,openAiChatWithPresetInput:K,pendingComposerPreset:l,clearPendingComposerPreset:q}),[n,P,f?.title,C,I,g,N,u,K,l,q,L,x,h.onSettingsOpen]);return X.jsx(o.AiChatContext.Provider,{value:G,children:X.jsx(et,{chatId:n,model:C,initialMessages:f?.messages,onChatFinish:H,onChatMessagesUpdated:$,children:t})})}exports.AiChatProvider=ft;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./replay-index-Nz5obVS5.js"),f=require("./replay-SemanticSearchService-CulKCCNl.js");var v;(function(l){l.WINDOW_RESIZED="tauri://resize",l.WINDOW_MOVED="tauri://move",l.WINDOW_CLOSE_REQUESTED="tauri://close-requested",l.WINDOW_DESTROYED="tauri://destroyed",l.WINDOW_FOCUS="tauri://focus",l.WINDOW_BLUR="tauri://blur",l.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",l.WINDOW_THEME_CHANGED="tauri://theme-changed",l.WINDOW_CREATED="tauri://window-created",l.WEBVIEW_CREATED="tauri://webview-created",l.DRAG_ENTER="tauri://drag-enter",l.DRAG_OVER="tauri://drag-over",l.DRAG_DROP="tauri://drag-drop",l.DRAG_LEAVE="tauri://drag-leave"})(v||(v={}));async function m(l,e){await h.invoke("plugin:event|unlisten",{event:l,eventId:e})}async function E(l,e,i){var s;const n=(s=void 0)!==null&&s!==void 0?s:{kind:"Any"};return h.invoke("plugin:event|listen",{event:l,target:n,handler:h.transformCallback(e)}).then(t=>async()=>m(l,t))}class w{constructor(e,i,s,n,t,o){this.storage=e,this.projectDir=i,this.aiEnabled=s,this.environments=n,this.apis=t,this.collections=o}storage;projectDir;aiEnabled;environments;apis;collections;watchPath=null;unlistenEvent=null;pendingEnvironmentsReload=Promise.resolve();get tauriStorage(){return this.storage}indexApis(e){!this.aiEnabled||e.length===0||f.getSemanticSearchService().indexApis(e).catch(i=>console.error("Semantic index (apis):",i))}indexCollections(e){!this.aiEnabled||e.length===0||f.getSemanticSearchService().indexCollections(e).catch(i=>console.error("Semantic index (collections):",i))}removeApis(e){if(!this.aiEnabled||e.length===0)return;const i=f.getSemanticSearchService();Promise.all(e.map(s=>i.removeApi(s))).catch(s=>console.error("Semantic remove (apis):",s))}removeCollections(e){if(!this.aiEnabled||e.length===0)return;const i=f.getSemanticSearchService();Promise.all(e.map(s=>i.removeCollection(s))).catch(s=>console.error("Semantic remove (collections):",s))}async start(){if(this.watchPath){console.warn("Watcher already started for:",this.watchPath);return}try{this.unlistenEvent=await E("fs-watch-event",async e=>{const i=e.payload;try{await this.handleEvent(i)}catch(s){console.error("Error handling file change:",s)}}),await h.invoke("fs_watch",{path:this.projectDir,options:{recursive:!0,delayMs:500}}),this.watchPath=this.projectDir}catch(e){throw console.error("Failed to start file watcher:",e),this.unlistenEvent&&(this.unlistenEvent(),this.unlistenEvent=null),e}}async stop(){if(this.watchPath)try{await h.invoke("fs_unwatch",{path:this.watchPath})}catch(e){console.error("Error stopping file watcher:",e)}finally{this.unlistenEvent&&(this.unlistenEvent(),this.unlistenEvent=null),this.watchPath=null}}async handleEvent(e){const{changeType:i,paths:s,pathTypes:n,type:t}=e;if(await this.isProjectFolderRemoved(s,i)){await this.handleProjectFolderRemoval();return}const o=this.filterSpecFiles(s,n);if(o.paths.length===0)return;const a=await this.toFileEntries(o.paths,o.pathTypes);switch(i){case"changed":(t.includes("Data")||t.includes("Name"))&&await this.handleModify(a);break;case"added":await this.handleCreate(a);break;case"deleted":await this.handleDelete(a);break;case"renamed":await this.handleRename(a);break;default:console.log("Unhandled change type:",i)}}filterSpecFiles(e,i){const s=[],n=[];for(let t=0;t<e.length;t++){const o=e[t],a=o.split(".").pop()?.toLowerCase();a&&["yaml","yml","json"].includes(a)&&(s.push(o),n.push(i[t]||"unknown"))}return{paths:s,pathTypes:n}}async toFileEntries(e,i){return Promise.all(e.map(async(s,n)=>({relative_path:await h.PathUtils.relative(this.projectDir,s),absolute_path:s,type:i[n]||"unknown"})))}hasExternalConfigChange(e){return e.some(i=>h.isRedoclyConfigFile(i.relative_path)&&!this.storage.isWatchExcluded(i.relative_path))}withoutConfigFile(e){return e.filter(i=>!h.isRedoclyConfigFile(i.relative_path))}consolidateFileEntries(e){const i=[],s=new Set;for(const n of e)s.has(n.relative_path)||(s.add(n.relative_path),this.storage.isWatchExcluded(n.relative_path)||i.push(n));return i}async handleModify(e){const i=this.hasExternalConfigChange(e),s=this.withoutConfigFile(e),{newApiFiles:n,existingApiFiles:t}=this.categorizeApisFromFiles(s),{newCollectionFiles:o,existingCollectionFiles:a}=this.categorizeCollectionsFromFiles(s),c=await this.findApisToReload(e),r=await this.findCollectionsToReload(e),p=[...n,...o];p.length>0&&await this.handleCreate(p),i&&await this.reloadEnvironments();const u=this.consolidateFileEntries([...t,...c]),g=this.consolidateFileEntries([...a,...r]);await this.reloadApis(u),await this.reloadCollections(g)}async handleCreate(e){this.hasExternalConfigChange(e)&&await this.reloadEnvironments();const i=this.withoutConfigFile(e),s=i.filter(r=>r.type==="api"),n=i.filter(r=>r.type==="collection"),{newApiFiles:t,existingApiFiles:o}=this.categorizeApisFromFiles(s),{newCollectionFiles:a,existingCollectionFiles:c}=this.categorizeCollectionsFromFiles(n);if(t.length>0||a.length>0){t.forEach(d=>this.storage.addPersistExcludedId(d.relative_path)),a.forEach(d=>this.storage.addPersistExcludedId(d.relative_path));const r=t.length>0?await this.tauriStorage.loadAndParseApis(t,void 0,!0):[],p=a.length>0?await this.tauriStorage.loadAndParseCollections(a,void 0):[],u=r.filter(d=>d!==null),g=p.filter(d=>d!==null);this.apis.set([...this.apis.get(),...u]),this.collections.set([...this.collections.get(),...g]),this.indexApis(u),this.indexCollections(g),setTimeout(()=>{t.forEach(d=>this.storage.removePersistExcludedId(d.relative_path)),a.forEach(d=>this.storage.removePersistExcludedId(d.relative_path))},500)}o.length>0&&await this.reloadApis(o),c.length>0&&await this.reloadCollections(c)}categorizeApisFromFiles(e){const i=new Set,s=[],n=[];for(const t of e){if(i.has(t.relative_path))continue;i.add(t.relative_path),this.apis.get().some(a=>a.id===t.relative_path)?n.push(t):t.type==="api"&&s.push(t)}return{newApiFiles:s,existingApiFiles:n}}categorizeCollectionsFromFiles(e){const i=new Set,s=[],n=[];for(const t of e){if(i.has(t.relative_path))continue;i.add(t.relative_path),this.collections.get().some(a=>a.id===t.relative_path)?n.push(t):t.type==="collection"&&s.push(t)}return{newCollectionFiles:s,existingCollectionFiles:n}}async handleDelete(e){this.hasExternalConfigChange(e)&&await this.reloadEnvironments();const i=this.withoutConfigFile(e),s=[],n=[];for(const t of i){this.storage.addPersistExcludedId(t.relative_path);const o=this.apis.get();o.some(r=>r.id===t.relative_path)&&(this.apis.set(o.filter(r=>r.id!==t.relative_path)),this.tauriStorage.deleteApiFromCache(t.relative_path),s.push(t.relative_path));const a=this.collections.get(),c=a.findIndex(r=>r.id===t.relative_path);c>=0&&(this.collections.set(a.filter((r,p)=>p!==c)),n.push(t.relative_path)),setTimeout(()=>{this.storage.removePersistExcludedId(t.relative_path)},500)}this.removeApis(s),this.removeCollections(n)}async handleRename(e){if(e.length>=2){const[i,s]=e;await this.handleDelete([i]),await this.handleCreate([s])}else await this.handleCreate(e)}async isProjectFolderRemoved(e,i){if(e.length===0)return!1;if(i==="deleted"||i==="renamed"){for(const n of e)if(n===this.projectDir)return!0}return e.filter(n=>!n.startsWith(this.projectDir+"/")&&n!==this.projectDir).length>0&&i==="renamed"}async handleProjectFolderRemoval(){const e=this.apis.get(),i=e.map(t=>t.id);e.forEach(t=>{this.storage.addPersistExcludedId(t.id),this.tauriStorage.deleteApiFromCache(t.id)}),this.apis.set([]);const s=this.collections.get(),n=s.map(t=>t.id);s.forEach(t=>{this.storage.addPersistExcludedId(t.id)}),this.collections.set([]),setTimeout(()=>{e.forEach(t=>this.storage.removePersistExcludedId(t.id)),s.forEach(t=>this.storage.removePersistExcludedId(t.id))},500),this.removeApis(i),this.removeCollections(n),await this.stop()}async findApisToReload(e){const i=[];return await Promise.all(this.apis.get().map(async s=>{const n=s.fileDependencies??new Set,t=s.id,o=e.find(a=>n.has(a.absolute_path));if(!this.storage.isWatchExcluded(t)&&o){const a=await h.PathUtils.join(this.projectDir,t);i.push({relative_path:t,absolute_path:a,type:"api"})}})),i}async findCollectionsToReload(e){const i=[];return await Promise.all(this.collections.get().map(async s=>{const n=s.fileDependencies??new Set,t=s.id,o=e.find(a=>n.has(a.absolute_path));if(!this.storage.isWatchExcluded(t)&&o){const a=await h.PathUtils.join(this.projectDir,t);i.push({relative_path:t,absolute_path:a,type:"collection"})}})),i}reloadEnvironments(){const e=this.pendingEnvironmentsReload.then(()=>this.readAndPublishEnvironments());return this.pendingEnvironmentsReload=e.catch(()=>{}),e}async readAndPublishEnvironments(){const e=this.environments.get(),i=await this.tauriStorage.readEnvironments();!(this.environments.get()!==e)&&(i.length>0||!this.storage.getEnvironmentsConfigError())&&this.environments.set(i.length>0?i:h.cloneObject(h.DEFAULT_ENVIRONMENTS)),this.storage.publishEnvironmentsConfigError()}async reloadApis(e){if(e.length===0)return;const i=await this.tauriStorage.loadAndParseApis(e,void 0,!0),s=[];await Promise.all(i.map(async(n,t)=>{if(!n){await this.handleDelete([e[t]]);return}const o=this.apis.get();o.some(a=>a.id===n.id)?(this.storage.addPersistExcludedId(n.id),this.apis.set(o.map(a=>a.id===n.id?n:a)),s.push(n),setTimeout(()=>this.storage.removePersistExcludedId(n.id),500)):console.warn("API not found in state after reload:",n.id)})),s.length>0&&this.indexApis(s)}async reloadCollections(e){if(e.length===0)return;const i=await this.tauriStorage.loadAndParseCollections(e,void 0),s=[];await Promise.all(i.map(async(n,t)=>{if(!n){await this.handleDelete([e[t]]);return}const o=this.collections.get(),a=o.findIndex(c=>c.id===n.id);a>=0?(this.storage.addPersistExcludedId(n.id),this.collections.set(o.map((c,r)=>r===a?n:c)),s.push(n),setTimeout(()=>this.storage.removePersistExcludedId(n.id),500)):console.warn("Collection not found in state after reload:",n.id)})),s.length>0&&this.indexCollections(s)}}exports.FileWatcher=w;
@@ -1,4 +0,0 @@
1
- import { g as r } from "./replay-SemanticSearchService-Bh5xYa91.js";
2
- export {
3
- r as getSemanticSearchService
4
- };