@redocly/replay 0.27.1 → 0.28.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.
- package/dist/{replay-AiChatProvider-Cdve_kxz.js → replay-AiChatProvider-COJYrrQ6.js} +6 -6
- package/dist/{replay-AiChatProvider-IuOVaWMC.js → replay-AiChatProvider-DjEmmTbN.js} +1 -1
- package/dist/{replay-AiChatSqliteDBStorage-jEhfZgK3.js → replay-AiChatSqliteDBStorage-BenAoLmM.js} +1 -1
- package/dist/{replay-AiChatSqliteDBStorage-B3aaY0Uo.js → replay-AiChatSqliteDBStorage-CBeRerfX.js} +1 -1
- package/dist/{replay-AiPanel-BT_RLVeR.js → replay-AiPanel-BN1uduZr.js} +37 -37
- package/dist/{replay-AiPanel-0GXuobhF.js → replay-AiPanel-FAJJA4QT.js} +1 -1
- package/dist/replay-FileWatcher-DDlINC06.js +1 -0
- package/dist/replay-FileWatcher-paEMsDuu.js +352 -0
- package/dist/{replay-SemanticSearchService--QXHzf7_.js → replay-SemanticSearchService-DwIcsNYC.js} +1 -1
- package/dist/{replay-SemanticSearchService-DJ_jBUyi.js → replay-SemanticSearchService-OutwGWqD.js} +1 -1
- package/dist/{replay-SqliteDBStorage-0JYq0UPY.js → replay-SqliteDBStorage-Cn8L_KB1.js} +1 -1
- package/dist/{replay-SqliteDBStorage-ClD7MBeX.js → replay-SqliteDBStorage-CrB-WSIX.js} +1 -1
- package/dist/{replay-TauriFileSystemAdapter-BnSXgnQc.js → replay-TauriFileSystemAdapter-CocGBrH_.js} +1 -1
- package/dist/{replay-TauriFileSystemAdapter-BuHbmM-L.js → replay-TauriFileSystemAdapter-q89YsNXx.js} +1 -1
- package/dist/{replay-TauriRootStorage-B1vFT2Rg.js → replay-TauriRootStorage-CZXVp2Zw.js} +1 -1
- package/dist/{replay-TauriRootStorage-D6K0MuWv.js → replay-TauriRootStorage-DHVdmo5Z.js} +5 -3
- package/dist/{replay-agent-loop-jUYXZfye.js → replay-agent-loop-cbxVIXnO.js} +9 -9
- package/dist/{replay-agent-loop-X2MrvEk-.js → replay-agent-loop-vzQUCpCA.js} +1 -1
- package/dist/{replay-ai-chat-mappers-B0Ay6VKi.js → replay-ai-chat-mappers-BnAf2rpg.js} +1 -1
- package/dist/{replay-ai-chat-mappers-sgE5XiwA.js → replay-ai-chat-mappers-pb8lpkUD.js} +1 -1
- package/dist/{replay-create-model-DB6xE5Ap.js → replay-create-model-CqA612v0.js} +3 -3
- package/dist/{replay-create-model-NrGYVueM.js → replay-create-model-Dr80k74P.js} +4 -4
- package/dist/{replay-db-BZNR8xEd.js → replay-db-Bq7IGfIa.js} +1 -1
- package/dist/{replay-db-BiP6dME4.js → replay-db-C8RC-t2R.js} +1 -1
- package/dist/{replay-external-resolver-PLyV0HZs.js → replay-external-resolver-Bw7R-LTs.js} +1 -1
- package/dist/{replay-external-resolver-DPAdPRks.js → replay-external-resolver-D6WP4NJY.js} +2 -2
- package/dist/{replay-index-yAV5TCua.js → replay-index-B3sCvU48.js} +1 -1
- package/dist/{replay-index-HHtp5T42.js → replay-index-BFdS3tY7.js} +1 -1
- package/dist/{replay-index-B2RZCGOF.js → replay-index-BizzVzWT.js} +22420 -21604
- package/dist/{replay-index-DTD47ryK.js → replay-index-CI5L8ebr.js} +1 -1
- package/dist/{replay-index-D85qPcEF.js → replay-index-D3evrr0U.js} +1205 -1098
- package/dist/{replay-index-DDUSidTx.js → replay-index-DZwTSW3m.js} +2 -2
- package/dist/{replay-index-DmAVD_C4.js → replay-index-DsAn0c_r.js} +1 -1
- package/dist/{replay-index-DKNhWzy4.js → replay-index-bspotqBs.js} +5 -5
- package/dist/{replay-lint-DyUeemr_.js → replay-lint-D5d7AeDU.js} +3 -3
- package/dist/{replay-lint-graphql-D_p-TkyV.js → replay-lint-graphql-CYl9hbRz.js} +1 -1
- package/dist/{replay-lint-graphql-pt1vf5MX.js → replay-lint-graphql-C_f79j2l.js} +1 -1
- package/dist/{replay-lint-Bico-a-1.js → replay-lint-q7b2-PPR.js} +3 -3
- package/dist/{replay-resolve-CQzlNcS2.js → replay-resolve-CftMmcPx.js} +1 -1
- package/dist/{replay-resolve-IKJYgmPW.js → replay-resolve-Km_DObpf.js} +1 -1
- package/dist/{replay-respect-run-CtDn7oS8.js → replay-respect-run-CfbJ-uak.js} +3 -3
- package/dist/{replay-respect-run-rx_nPWZM.js → replay-respect-run-DBe6ZUcc.js} +1 -1
- package/dist/{replay-tauri-path-iA6pF5e0.js → replay-tauri-path-BrtMOZvF.js} +1 -1
- package/dist/{replay-tauri-path-DrwBKGJP.js → replay-tauri-path-Ek8BSAa0.js} +2 -2
- package/dist/{replay-useAiChatQueries-PECgHJpT.js → replay-useAiChatQueries-BR1eEjUB.js} +4 -4
- package/dist/{replay-useAiChatQueries-BIZfilWh.js → replay-useAiChatQueries-DjjzEorX.js} +1 -1
- package/dist/{replay-validate-key-CvZaTfXj.js → replay-validate-key-CZSwxFid.js} +2 -2
- package/dist/{replay-validate-key-CTJn216O.js → replay-validate-key-Cox-cRT6.js} +1 -1
- package/dist/replay.cjs +1 -1
- package/dist/replay.d.ts +9 -0
- package/dist/replay.js +6 -6
- package/package.json +2 -2
- package/dist/replay-FileWatcher-CtHVgewC.js +0 -343
- package/dist/replay-FileWatcher-NkpXJA-C.js +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as te } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as R, useCallback as f, useSyncExternalStore as re, useEffect as b, useMemo as w, useState as z } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import { A as Qe, D as Ve, l as Ge } from "./replay-create-model-
|
|
5
|
-
import { AgentLoop as He } from "./replay-agent-loop-
|
|
6
|
-
import { s as ze } from "./replay-db-
|
|
7
|
-
import { r as Ye, g as Je, a as Xe, o as Ze, s as et, w as tt, m as nt, b as st, u as rt, c as ot, d as at, e as it, f as lt, h as ct, i as ut, A as dt, j as ht, k as pt } from "./replay-useAiChatQueries-
|
|
3
|
+
import { h as S, A as ce, g as Re, I as xe, T as $e, j as x, k as Pe, m as De, u as Te, o as We, p as Be, q as Oe, s as Ue, v as Ae, w as se, x as ue, z as ye, B as Fe, C as Le, E as Se, F as ge, G as je, H as ne, J as Ne, K as ae, L as Ke, N as qe } from "./replay-index-BizzVzWT.js";
|
|
4
|
+
import { A as Qe, D as Ve, l as Ge } from "./replay-create-model-Dr80k74P.js";
|
|
5
|
+
import { AgentLoop as He } from "./replay-agent-loop-cbxVIXnO.js";
|
|
6
|
+
import { s as ze } from "./replay-db-C8RC-t2R.js";
|
|
7
|
+
import { r as Ye, g as Je, a as Xe, o as Ze, s as et, w as tt, m as nt, b as st, u as rt, c as ot, d as at, e as it, f as lt, h as ct, i as ut, A as dt, j as ht, k as pt } from "./replay-useAiChatQueries-BR1eEjUB.js";
|
|
8
8
|
import { useQueryClient as de, useMutation as he } from "@tanstack/react-query";
|
|
9
|
-
import { b as be, g as me } from "./replay-ai-chat-mappers-
|
|
9
|
+
import { b as be, g as me } from "./replay-ai-chat-mappers-BnAf2rpg.js";
|
|
10
10
|
class ft {
|
|
11
11
|
handlers = /* @__PURE__ */ new Map();
|
|
12
12
|
middlewares;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const X=require("react/jsx-runtime"),i=require("react"),a=require("./replay-index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const X=require("react/jsx-runtime"),i=require("react"),a=require("./replay-index-D3evrr0U.js"),te=require("./replay-create-model-CqA612v0.js"),pe=require("./replay-agent-loop-vzQUCpCA.js"),ge=require("./replay-db-Bq7IGfIa.js"),m=require("./replay-useAiChatQueries-DjjzEorX.js"),F=require("@tanstack/react-query"),Z=require("./replay-ai-chat-mappers-pb8lpkUD.js");class Ce{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=(o,r)=>({isError:!0,error:{message:o,details:r}}),s=this.applyMiddlewares(t.name,t.execute);return(o,r)=>{if(r.abortSignal?.aborted)return n("Tool execution was aborted.");try{const l=s(o,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,o)=>o(t,s),n)}}function ue(){const e=F.useQueryClient();return F.useMutation({async mutationFn(t){const n=Z.buildPersistableUiChat(t);await a.AiChatServiceFactory.getInstance().upsert(n)},onSuccess(){e.invalidateQueries({queryKey:a.aiChatKeys.all()})},onError(t){console.error("Failed to upsert ai chat item:",t)}})}function me(e){const t=F.useQueryClient(),n=a.aiChatKeys.detailTitle(e??"");return F.useMutation({mutationKey:n,async mutationFn(s){if(t.isMutating({mutationKey:n,exact:!0})>1)return;const o=Z.buildPersistableUiChat(s);await a.AiChatServiceFactory.getInstance().upsert(o)},onSuccess(){t.invalidateQueries({queryKey:a.aiChatKeys.all()})},onError(s){console.error("Failed to upsert ai chat item:",s)}})}function ve(){const e=F.useQueryClient();return F.useMutation({async mutationFn(t){await a.AiChatServiceFactory.getInstance().remove(t)},onMutate:async t=>{await e.cancelQueries({queryKey:a.aiChatKeys.all()});const n=e.getQueryData(a.aiChatKeys.all());n&&e.setQueryData(a.aiChatKeys.all(),n.filter(s=>s.id!==t)),e.setQueryData(a.aiChatKeys.detail(t),null),e.setQueriesData({queryKey:a.aiChatKeys.infiniteHistories()},s=>s&&{...s,pages:s.pages.map(o=>({...o,items:o.items.filter(r=>r.id!==t)}))})},onError(t){console.error("Failed to remove ai chat:",t)},onSettled(){e.invalidateQueries({queryKey:a.aiChatKeys.all()})}})}var ee,ae;function we(){if(ae)return ee;ae=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,o=0;return function(...l){clearTimeout(s);const c=Date.now(),u=c-o,h=n-u;h<=0?(o=c,t.apply(this,l)):s=setTimeout(()=>{o=Date.now(),t.apply(this,l)},h)}}return ee=e,ee}var Ie=we();const Te=a.getDefaultExportFromCjs(Ie);var de=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},f=(e,t,n)=>(de(e,t,"read from private field"),n?n.call(e):t.get(e)),b=(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)},M=(e,t,n,s)=>(de(e,t,"write to private field"),t.set(e,n),n);function ye(e,t){return t!=null?Te(e,t):e}var w,Y,J,j,Q,V,B,ne,se,be=class{constructor(e=[]){b(this,w,void 0),b(this,Y,"ready"),b(this,J,void 0),b(this,j,new Set),b(this,Q,new Set),b(this,V,new Set),this.pushMessage=t=>{M(this,w,f(this,w).concat(t)),f(this,B).call(this)},this.popMessage=()=>{M(this,w,f(this,w).slice(0,-1)),f(this,B).call(this)},this.replaceMessage=(t,n)=>{M(this,w,[...f(this,w).slice(0,t),this.snapshot(n),...f(this,w).slice(t+1)]),f(this,B).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const s=n?ye(t,n):t;return f(this,j).add(s),()=>{f(this,j).delete(s)}},this["~registerStatusCallback"]=t=>(f(this,Q).add(t),()=>{f(this,Q).delete(t)}),this["~registerErrorCallback"]=t=>(f(this,V).add(t),()=>{f(this,V).delete(t)}),b(this,B,()=>{f(this,j).forEach(t=>t())}),b(this,ne,()=>{f(this,Q).forEach(t=>t())}),b(this,se,()=>{f(this,V).forEach(t=>t())}),M(this,w,e)}get status(){return f(this,Y)}set status(e){M(this,Y,e),f(this,ne).call(this)}get error(){return f(this,J)}set error(e){M(this,J,e),f(this,se).call(this)}get messages(){return f(this,w)}set messages(e){M(this,w,[...e]),f(this,B).call(this)}};w=new WeakMap;Y=new WeakMap;J=new WeakMap;j=new WeakMap;Q=new WeakMap;V=new WeakMap;B=new WeakMap;ne=new WeakMap;se=new WeakMap;var L,ie=class extends te.AbstractChat{constructor({messages:e,...t}){const n=new be(e);super({...t,state:n}),b(this,L,void 0),this["~registerMessagesCallback"]=(s,o)=>f(this,L)["~registerMessagesCallback"](s,o),this["~registerStatusCallback"]=s=>f(this,L)["~registerStatusCallback"](s),this["~registerErrorCallback"]=s=>f(this,L)["~registerErrorCallback"](s),M(this,L,n)}};L=new WeakMap;function Se({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 o={...n,onToolCall:d=>{var g,p;return(p=(g=s.current).onToolCall)==null?void 0:p.call(g,d)},onData:d=>{var g,p;return(p=(g=s.current).onData)==null?void 0:p.call(g,d)},onFinish:d=>{var g,p;return(p=(g=s.current).onFinish)==null?void 0:p.call(g,d)},onError:d=>{var g,p;return(p=(g=s.current).onError)==null?void 0:p.call(g,d)},sendAutomaticallyWhen:d=>{var g,p,R;return(R=(p=(g=s.current).sendAutomaticallyWhen)==null?void 0:p.call(g,d))!=null?R:!1}},r=i.useRef("chat"in n?n.chat:new ie(o));("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 ie(o));const c=i.useCallback(d=>r.current["~registerMessagesCallback"](d,e),[e,r.current.id]),u=i.useSyncExternalStore(c,()=>r.current.messages,()=>r.current.messages),h=i.useSyncExternalStore(r.current["~registerStatusCallback"],()=>r.current.status,()=>r.current.status),I=i.useSyncExternalStore(r.current["~registerErrorCallback"],()=>r.current.error,()=>r.current.error),T=i.useCallback(d=>{typeof d=="function"&&(d=d(r.current.messages)),r.current.messages=d},[r]);return i.useEffect(()=>{t&&r.current.resumeStream()},[t,r]),{id:r.current.id,messages:u,setMessages:T,sendMessage:r.current.sendMessage,regenerate:r.current.regenerate,clearError:r.current.clearError,stop:r.current.stop,error:I,resumeStream:r.current.resumeStream,status:h,addToolResult:r.current.addToolOutput,addToolOutput:r.current.addToolOutput,addToolApprovalResponse:r.current.addToolApprovalResponse}}const Ae=20;function ke(e){if(e.length===0)return"No OpenAPI specs loaded.";const t=e.slice(0,Ae),n=t.map(Ee),s=e.length-t.length;return s>0&&n.push(` …and ${s} more API(s) not shown.`),[`Loaded APIs (${e.length}):`,...n].join(`
|
|
2
2
|
`)}function Ee(e){return[` apiId="${e.apiId}"`,`title="${e.title}"`,e.version?`version="${e.version}"`:null,e.primaryServer?`server="${e.primaryServer}"`:null].filter(Boolean).join(" ")}const Me=30;function Re(e){if(e.length===0)return"No Arazzo collections loaded.";const t=[`Arazzo collections (${e.length}):`];let n=Me,s=0,o=0;for(const l of e){if(n<=0){s+=l.workflows.length,o++;continue}if(t.push(_e(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(` ${xe(c)}`),n--):s++}else s+=l.workflows.length}const r=[s>0?`${s} more workflow(s)`:null,o>0?`${o} more collection(s)`:null].filter(Boolean);return r.length>0&&t.push(` …and ${r.join(", plus ")} not shown.`),t.join(`
|
|
3
3
|
`)}function _e(e){const t=e.sourceApiIds.length>0?` apis=[${e.sourceApiIds.join(", ")}]`:"";return` collectionId="${e.collectionId}" title="${e.title}"${t}`}function xe(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($e),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
4
|
`)}function $e(e){return[`${e.isActive?"*":" "} name="${e.name}"`,`inputs=${e.inputCount}`,`servers=${e.serverCount}`].join(" ")}const Oe=30;function We(e){if(e.length===0)return"No tabs are open.";const t=e.slice(0,Oe),n=t.map(Ue),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(`
|
package/dist/{replay-AiChatSqliteDBStorage-jEhfZgK3.js → replay-AiChatSqliteDBStorage-BenAoLmM.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./replay-history.schema-miM3Etuf.js");require("./replay-step-context.schema-BuuXkAck.js");const i=require("./replay-ai-message-parts.schema-BBdjwldJ.js"),h=require("./replay-ai-chat-mappers-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./replay-history.schema-miM3Etuf.js");require("./replay-step-context.schema-BuuXkAck.js");const i=require("./replay-ai-message-parts.schema-BBdjwldJ.js"),h=require("./replay-ai-chat-mappers-pb8lpkUD.js"),s=require("./replay-indexes-Dqjl8m6C.js"),c={orderBy:[s.asc(i.aiMessages.createdAt),s.asc(i.aiMessages.indexWithinInsertBatch)],with:{parts:{orderBy:[s.asc(i.aiMessageParts.index)]}}};class g{constructor(e){this.sqliteDB=e}sqliteDB;async findAll(){return await this.initialize(),(await this.db.query.aiChats.findMany({with:{messages:c}})).map(h.convertAiChatRowToUiChat)}async findRecentChatsPage(e){await this.initialize();const a=e.limit+1,r=await this.db.query.aiChats.findMany({orderBy:(d,{desc:o})=>o(d.updatedAt),limit:a,offset:e.offset}),t=r.slice(0,e.limit),n=r.length>e.limit,w=e.offset+t.length;return{items:t.map(d=>{const o={...d,messages:[]};return h.convertAiChatRowToUiChat(o)}),hasMore:n,nextOffset:w}}async findOne(e){await this.initialize();const a=await this.db.query.aiChats.findFirst({where:s.eq(i.aiChats.id,e),with:{messages:c}});return a&&h.convertAiChatRowToUiChat(a)}async upsert(e){await this.initialize();const a=h.convertUiChatToAiChatRow(e);await this.db.query.aiChats.findFirst({where:s.eq(i.aiChats.id,a.id),columns:{id:!0}})?await this.db.update(i.aiChats).set(a).where(s.eq(i.aiChats.id,a.id)):await this.db.insert(i.aiChats).values(a);for(let t=0;t<e.messages.length;t++)await this.upsertMessageRowAndParts(e.id,t,e.messages[t])}async remove(e){await this.initialize(),await this.db.delete(i.aiChats).where(s.eq(i.aiChats.id,e))}async upsertMessageRowAndParts(e,a,r){const t=await this.db.query.aiMessages.findFirst({where:s.and(s.eq(i.aiMessages.aiChatId,e),s.eq(i.aiMessages.uiId,r.id))}),n=h.convertUiMessageToAiChatMessage(e,a,r,t?.id);t?await this.db.update(i.aiMessages).set({...n,indexWithinInsertBatch:t.indexWithinInsertBatch}).where(s.eq(i.aiMessages.id,t.id)):await this.db.insert(i.aiMessages).values(n),await this.db.delete(i.aiMessageParts).where(s.eq(i.aiMessageParts.aiMessageId,n.id)),n.parts.length>0&&await this.db.insert(i.aiMessageParts).values(n.parts)}get db(){return this.sqliteDB.db}async initialize(){await this.sqliteDB.initialize()}}exports.AiChatSqliteDBStorage=g;
|
package/dist/{replay-AiChatSqliteDBStorage-B3aaY0Uo.js → replay-AiChatSqliteDBStorage-CBeRerfX.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./replay-history.schema-5ce6X0R1.js";
|
|
2
2
|
import "./replay-step-context.schema-DBk4jufr.js";
|
|
3
3
|
import { a as h, b as r, c as n } from "./replay-ai-message-parts.schema-E9u9-nqr.js";
|
|
4
|
-
import { c, a as u, d as m } from "./replay-ai-chat-mappers-
|
|
4
|
+
import { c, a as u, d as m } from "./replay-ai-chat-mappers-BnAf2rpg.js";
|
|
5
5
|
import { a as l, e, b as y } from "./replay-indexes-CfsvVMi_.js";
|
|
6
6
|
const g = {
|
|
7
7
|
orderBy: [l(r.createdAt), l(r.indexWithinInsertBatch)],
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsxs as h, jsx as i, Fragment as Ne } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback as _, useMemo as A, useState as G, Fragment as gt, useRef as F, useEffect as B, useLayoutEffect as je } from "react";
|
|
3
3
|
import c, { css as pe } from "styled-components";
|
|
4
|
-
import { T as te,
|
|
5
|
-
import { l as At, n as St, p as Lt, q as Pt, T as Et, t as Rt, v as Ot, x as qe, C as I, y as Dt, z as Ke, L as Mt, B as Q, D as _t, E as zt, F as Vt, G as $t, H as N } from "./replay-useAiChatQueries-
|
|
4
|
+
import { T as te, a5 as Te, a6 as mt, j as vt, z as Ue, s as yt, v as xt, c as wt, a7 as he, a8 as ge, a9 as V, aa as be, ab as bt, ac as Ct, ad as We, ae as Tt, af as kt, H as me, X as ue, ag as Ye, E as Ge, ah as Ce, ai as U, aj as It } from "./replay-index-BizzVzWT.js";
|
|
5
|
+
import { l as At, n as St, p as Lt, q as Pt, T as Et, t as Rt, v as Ot, x as qe, C as I, y as Dt, z as Ke, L as Mt, B as Q, D as _t, E as zt, F as Vt, G as $t, H as N } from "./replay-useAiChatQueries-BR1eEjUB.js";
|
|
6
6
|
import { AI_SEARCH_MAX_MESSAGE_LENGTH as Ht } from "@redocly/theme/core/constants/search";
|
|
7
7
|
import { Button as P } from "@redocly/theme/components/Button/Button";
|
|
8
8
|
import { SendIcon as Bt } from "@redocly/theme/icons/SendIcon/SendIcon";
|
|
9
9
|
import { StopIcon as Ft } from "@redocly/theme/icons/StopIcon/StopIcon";
|
|
10
|
-
import { M as z } from "./replay-db-
|
|
10
|
+
import { M as z } from "./replay-db-C8RC-t2R.js";
|
|
11
11
|
import { CheckboxIcon as Nt } from "@redocly/theme/icons/CheckboxIcon/CheckboxIcon";
|
|
12
12
|
import { CheckmarkFilledIcon as jt } from "@redocly/theme/icons/CheckmarkFilledIcon/CheckmarkFilledIcon";
|
|
13
13
|
import { CloseFilledIcon as Ut } from "@redocly/theme/icons/CloseFilledIcon/CloseFilledIcon";
|
|
@@ -17,15 +17,15 @@ import { capitalize as oe } from "@redocly/theme/core/utils";
|
|
|
17
17
|
import { ChevronDownIcon as Gt } from "@redocly/theme/icons/ChevronDownIcon/ChevronDownIcon";
|
|
18
18
|
import { ChevronRightIcon as qt } from "@redocly/theme/icons/ChevronRightIcon/ChevronRightIcon";
|
|
19
19
|
import { Dropdown as Kt } from "@redocly/theme/components/Dropdown/Dropdown";
|
|
20
|
-
import { DropdownMenu as
|
|
21
|
-
import { DropdownMenuItem as
|
|
22
|
-
import { CheckmarkIcon as
|
|
20
|
+
import { DropdownMenu as Xt } from "@redocly/theme/components/Dropdown/DropdownMenu";
|
|
21
|
+
import { DropdownMenuItem as Xe } from "@redocly/theme/components/Dropdown/DropdownMenuItem";
|
|
22
|
+
import { CheckmarkIcon as Jt } from "@redocly/theme/icons/CheckmarkIcon/CheckmarkIcon";
|
|
23
23
|
import { SettingsCogIcon as Zt } from "@redocly/theme/icons/SettingsCogIcon/SettingsCogIcon";
|
|
24
24
|
import { ChatGptIcon as Qt } from "@redocly/theme/icons/ChatGptIcon/ChatGptIcon";
|
|
25
25
|
import { GeminiIcon as en } from "@redocly/theme/icons/GeminiIcon/GeminiIcon";
|
|
26
26
|
import { ClaudeIcon as tn } from "@redocly/theme/icons/ClaudeIcon/ClaudeIcon";
|
|
27
27
|
import { Tooltip as W } from "@redocly/theme/components/Tooltip/Tooltip";
|
|
28
|
-
import { g as ke } from "./replay-SemanticSearchService-
|
|
28
|
+
import { g as ke } from "./replay-SemanticSearchService-OutwGWqD.js";
|
|
29
29
|
import "@tanstack/react-query";
|
|
30
30
|
import { Typography as Z } from "@redocly/theme/components/Typography/Typography";
|
|
31
31
|
import { TrashCanIcon as nn } from "@redocly/theme/icons/TrashCanIcon/TrashCanIcon";
|
|
@@ -288,7 +288,7 @@ function xn(e, t, n, r = {}) {
|
|
|
288
288
|
const o = mn(n);
|
|
289
289
|
o && yn(e, t, o, r);
|
|
290
290
|
}
|
|
291
|
-
function
|
|
291
|
+
function Je({
|
|
292
292
|
workflowRunHistoryIds: e
|
|
293
293
|
} = {}) {
|
|
294
294
|
const t = Ue(), { getApiOperation: n } = yt(), {
|
|
@@ -749,8 +749,8 @@ function Gn({
|
|
|
749
749
|
/* @__PURE__ */ i(Zn, { checked: e }),
|
|
750
750
|
/* @__PURE__ */ i(er, { type: "checkbox", checked: e, onChange: t })
|
|
751
751
|
] }),
|
|
752
|
-
/* @__PURE__ */ i(
|
|
753
|
-
o ? /* @__PURE__ */ i(
|
|
752
|
+
/* @__PURE__ */ i(Xn, { children: r }),
|
|
753
|
+
o ? /* @__PURE__ */ i(Jn, { children: o }) : null
|
|
754
754
|
] }),
|
|
755
755
|
a
|
|
756
756
|
] });
|
|
@@ -772,7 +772,7 @@ const qn = c.div`
|
|
|
772
772
|
align-items: center;
|
|
773
773
|
gap: var(--spacing-xs);
|
|
774
774
|
min-width: 0;
|
|
775
|
-
`,
|
|
775
|
+
`, Xn = c.span`
|
|
776
776
|
flex: 1;
|
|
777
777
|
min-width: 0;
|
|
778
778
|
color: var(--text-color-primary);
|
|
@@ -782,7 +782,7 @@ const qn = c.div`
|
|
|
782
782
|
overflow: hidden;
|
|
783
783
|
text-overflow: ellipsis;
|
|
784
784
|
white-space: nowrap;
|
|
785
|
-
`,
|
|
785
|
+
`, Jn = c.span`
|
|
786
786
|
flex-shrink: 0;
|
|
787
787
|
font-family: var(--code-block-font-family, var(--font-family-monospace, monospace));
|
|
788
788
|
font-size: var(--font-size-sm);
|
|
@@ -870,7 +870,7 @@ function dr(e) {
|
|
|
870
870
|
function ur(e) {
|
|
871
871
|
const t = e && "changes" in e ? e.changes : void 0;
|
|
872
872
|
if (!Array.isArray(t)) return /* @__PURE__ */ new Set();
|
|
873
|
-
const n =
|
|
873
|
+
const n = X(e, "stepId"), r = t.map((o) => X(o, "stepId") ?? n);
|
|
874
874
|
return new Set(r.filter((o) => !!o));
|
|
875
875
|
}
|
|
876
876
|
function et(e, t, n) {
|
|
@@ -974,18 +974,18 @@ function gr(e) {
|
|
|
974
974
|
}
|
|
975
975
|
function mr(e) {
|
|
976
976
|
return {
|
|
977
|
-
collectionId:
|
|
978
|
-
workflowId:
|
|
979
|
-
stepId:
|
|
977
|
+
collectionId: X(e, "collectionId"),
|
|
978
|
+
workflowId: X(e, "workflowId"),
|
|
979
|
+
stepId: X(e, "stepId")
|
|
980
980
|
};
|
|
981
981
|
}
|
|
982
|
-
function
|
|
982
|
+
function X(e, t) {
|
|
983
983
|
if (typeof e != "object" || e === null || !(t in e)) return null;
|
|
984
984
|
const n = e[t];
|
|
985
985
|
return typeof n == "string" && n.trim() || null;
|
|
986
986
|
}
|
|
987
987
|
function tt({ toolName: e, input: t }) {
|
|
988
|
-
const n = sr(e, t), r =
|
|
988
|
+
const n = sr(e, t), r = Je();
|
|
989
989
|
return /* @__PURE__ */ i(vr, { onClick: r, children: /* @__PURE__ */ i(yr, { children: n.map(
|
|
990
990
|
(o, a) => o.kind === "text" ? /* @__PURE__ */ i("span", { children: o.text }, a) : /* @__PURE__ */ i(xr, { href: o.href, children: o.label }, a)
|
|
991
991
|
) }) });
|
|
@@ -1709,7 +1709,7 @@ const Wr = c.div`
|
|
|
1709
1709
|
padding-top: 0;
|
|
1710
1710
|
padding-bottom: 0;
|
|
1711
1711
|
`;
|
|
1712
|
-
function
|
|
1712
|
+
function Xr({ items: e, isLast: t }) {
|
|
1713
1713
|
const [n, r] = G(t), o = _(() => {
|
|
1714
1714
|
r((s) => !s);
|
|
1715
1715
|
}, []), a = A(() => e.filter((s) => s.kind === "action"), [e]);
|
|
@@ -1722,10 +1722,10 @@ function Jr({ items: e, isLast: t }) {
|
|
|
1722
1722
|
a.length === 1 ? "action" : "actions"
|
|
1723
1723
|
] })
|
|
1724
1724
|
] }),
|
|
1725
|
-
n && /* @__PURE__ */ i(no, { children: a.map((s, d) => /* @__PURE__ */ i(
|
|
1725
|
+
n && /* @__PURE__ */ i(no, { children: a.map((s, d) => /* @__PURE__ */ i(Jr, { text: s.text }, d)) })
|
|
1726
1726
|
] });
|
|
1727
1727
|
}
|
|
1728
|
-
function
|
|
1728
|
+
function Jr({ text: e }) {
|
|
1729
1729
|
return /* @__PURE__ */ h(ro, { children: [
|
|
1730
1730
|
/* @__PURE__ */ h(oo, { children: [
|
|
1731
1731
|
/* @__PURE__ */ i(io, { "aria-hidden": !0 }),
|
|
@@ -1828,7 +1828,7 @@ function lo({
|
|
|
1828
1828
|
return /* @__PURE__ */ i(fo, { children: e.map((n, r) => {
|
|
1829
1829
|
if (n.kind === "reasoning-block") {
|
|
1830
1830
|
const s = r === e.length - 1;
|
|
1831
|
-
return /* @__PURE__ */ i(
|
|
1831
|
+
return /* @__PURE__ */ i(Xr, { items: n.items, isLast: s }, n.key);
|
|
1832
1832
|
}
|
|
1833
1833
|
if (n.kind === "text")
|
|
1834
1834
|
return /* @__PURE__ */ i(
|
|
@@ -1866,7 +1866,7 @@ function uo({
|
|
|
1866
1866
|
rawMarkdown: e,
|
|
1867
1867
|
workflowRunHistoryIds: t
|
|
1868
1868
|
}) {
|
|
1869
|
-
const n =
|
|
1869
|
+
const n = Je({ workflowRunHistoryIds: t });
|
|
1870
1870
|
return /* @__PURE__ */ i(po, { onClick: n, children: /* @__PURE__ */ i(Tt, { rawMarkdown: e, parser: kt }) });
|
|
1871
1871
|
}
|
|
1872
1872
|
const fo = c.div`
|
|
@@ -1891,7 +1891,7 @@ const fo = c.div`
|
|
|
1891
1891
|
font-size: var(--font-size-sm);
|
|
1892
1892
|
line-height: var(--line-height-sm);
|
|
1893
1893
|
color: var(--text-color-primary);
|
|
1894
|
-
`,
|
|
1894
|
+
`, J = c.div`
|
|
1895
1895
|
width: var(--search-ai-thinking-dot-size);
|
|
1896
1896
|
height: var(--search-ai-thinking-dot-size);
|
|
1897
1897
|
border-radius: 50%;
|
|
@@ -1925,9 +1925,9 @@ const fo = c.div`
|
|
|
1925
1925
|
`;
|
|
1926
1926
|
function ho() {
|
|
1927
1927
|
return /* @__PURE__ */ h(go, { children: [
|
|
1928
|
-
/* @__PURE__ */ i(
|
|
1929
|
-
/* @__PURE__ */ i(
|
|
1930
|
-
/* @__PURE__ */ i(
|
|
1928
|
+
/* @__PURE__ */ i(J, {}),
|
|
1929
|
+
/* @__PURE__ */ i(J, {}),
|
|
1930
|
+
/* @__PURE__ */ i(J, {})
|
|
1931
1931
|
] });
|
|
1932
1932
|
}
|
|
1933
1933
|
const go = c.div`
|
|
@@ -2162,7 +2162,7 @@ function Oo({
|
|
|
2162
2162
|
function He({ model: e, activeModelId: t, onModelSelect: n }) {
|
|
2163
2163
|
const r = e.id === t;
|
|
2164
2164
|
return /* @__PURE__ */ i(
|
|
2165
|
-
|
|
2165
|
+
Xe,
|
|
2166
2166
|
{
|
|
2167
2167
|
prefix: Eo(e.provider),
|
|
2168
2168
|
suffix: r ? /* @__PURE__ */ i(Ho, { size: "var(--font-size-base)", color: "var(--text-color-primary)" }) : void 0,
|
|
@@ -2211,7 +2211,7 @@ const Do = c.div`
|
|
|
2211
2211
|
width: 100%;
|
|
2212
2212
|
max-width: 200px;
|
|
2213
2213
|
}
|
|
2214
|
-
`, Vo = c(
|
|
2214
|
+
`, Vo = c(Xt)`
|
|
2215
2215
|
--dropdown-menu-item-gap: calc(var(--spacing-unit) / 2);
|
|
2216
2216
|
--dropdown-menu-item-padding-vertical: var(--spacing-xxs);
|
|
2217
2217
|
--dropdown-menu-item-padding-horizontal: var(--spacing-xs);
|
|
@@ -2226,7 +2226,7 @@ const Do = c.div`
|
|
|
2226
2226
|
overflow: hidden;
|
|
2227
2227
|
text-overflow: ellipsis;
|
|
2228
2228
|
white-space: nowrap;
|
|
2229
|
-
`, Ho = c(
|
|
2229
|
+
`, Ho = c(Jt)`
|
|
2230
2230
|
margin-left: var(--spacing-xxs);
|
|
2231
2231
|
`, Be = c.li`
|
|
2232
2232
|
flex-shrink: 0;
|
|
@@ -2242,7 +2242,7 @@ const Do = c.div`
|
|
|
2242
2242
|
list-style: none;
|
|
2243
2243
|
min-height: 0;
|
|
2244
2244
|
overflow-y: auto;
|
|
2245
|
-
`, Fo = c(
|
|
2245
|
+
`, Fo = c(Xe)`
|
|
2246
2246
|
flex-shrink: 0;
|
|
2247
2247
|
`, No = 280;
|
|
2248
2248
|
function dt({ pinToBottom: e = !1 }) {
|
|
@@ -2259,7 +2259,7 @@ function dt({ pinToBottom: e = !1 }) {
|
|
|
2259
2259
|
width: "240px",
|
|
2260
2260
|
arrowPosition: "left",
|
|
2261
2261
|
children: /* @__PURE__ */ h(Uo, { role: "status", "aria-live": "polite", "aria-label": "Indexing in progress...", children: [
|
|
2262
|
-
/* @__PURE__ */ i("div", { children: /* @__PURE__ */ i(
|
|
2262
|
+
/* @__PURE__ */ i("div", { children: /* @__PURE__ */ i(J, {}) }),
|
|
2263
2263
|
/* @__PURE__ */ i(Wo, { children: "Indexing in progress..." })
|
|
2264
2264
|
] })
|
|
2265
2265
|
}
|
|
@@ -2285,7 +2285,7 @@ const jo = c.div`
|
|
|
2285
2285
|
transition: opacity ${No}ms ease-out;
|
|
2286
2286
|
pointer-events: ${({ $open: e }) => e ? "auto" : "none"};
|
|
2287
2287
|
|
|
2288
|
-
${
|
|
2288
|
+
${J} {
|
|
2289
2289
|
animation-play-state: ${({ $open: e }) => e ? "running" : "paused"};
|
|
2290
2290
|
}
|
|
2291
2291
|
`, Uo = c.div`
|
|
@@ -2409,21 +2409,21 @@ const Go = c.div`
|
|
|
2409
2409
|
LAST_WEEK: "last_week",
|
|
2410
2410
|
LAST_MONTH: "last_month",
|
|
2411
2411
|
OLDER: "older"
|
|
2412
|
-
},
|
|
2412
|
+
}, Xo = {
|
|
2413
2413
|
[M.TODAY]: "Today",
|
|
2414
2414
|
[M.YESTERDAY]: "Yesterday",
|
|
2415
2415
|
[M.LAST_WEEK]: "Last 7 days",
|
|
2416
2416
|
[M.LAST_MONTH]: "Last 30 days",
|
|
2417
2417
|
[M.OLDER]: "Older"
|
|
2418
2418
|
};
|
|
2419
|
-
function
|
|
2419
|
+
function Jo(e, t = Date.now()) {
|
|
2420
2420
|
const n = U(e).startOf("day"), r = U(t).startOf("day"), o = U(t).subtract(1, "day").startOf("day"), a = U(t).subtract(7, "day").startOf("day"), s = U(t).subtract(30, "day").startOf("day");
|
|
2421
2421
|
return n.isSame(r, "day") ? M.TODAY : n.isSame(o, "day") ? M.YESTERDAY : !n.isBefore(a, "day") && n.isBefore(o, "day") ? M.LAST_WEEK : !n.isBefore(s, "day") && n.isBefore(a, "day") ? M.LAST_MONTH : M.OLDER;
|
|
2422
2422
|
}
|
|
2423
2423
|
function Zo(e) {
|
|
2424
2424
|
const t = [];
|
|
2425
2425
|
for (const n of e) {
|
|
2426
|
-
const r =
|
|
2426
|
+
const r = Jo(n.updatedAt), o = t[t.length - 1];
|
|
2427
2427
|
!o || o.bucket !== r ? t.push({ bucket: r, chats: [n] }) : o.chats.push(n);
|
|
2428
2428
|
}
|
|
2429
2429
|
return t;
|
|
@@ -2548,7 +2548,7 @@ function ui(e) {
|
|
|
2548
2548
|
function fi(e) {
|
|
2549
2549
|
const { group: t, onChatSelect: n, onChatRemove: r } = e;
|
|
2550
2550
|
return /* @__PURE__ */ h(ti, { children: [
|
|
2551
|
-
/* @__PURE__ */ i(ai, { children:
|
|
2551
|
+
/* @__PURE__ */ i(ai, { children: Xo[t.bucket] }),
|
|
2552
2552
|
t.chats.map((o) => /* @__PURE__ */ i(
|
|
2553
2553
|
ui,
|
|
2554
2554
|
{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),p=require("react"),X=require("styled-components"),f=require("./replay-index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),p=require("react"),X=require("styled-components"),f=require("./replay-index-D3evrr0U.js"),x=require("./replay-useAiChatQueries-DjjzEorX.js"),Ue=require("@redocly/theme/core/constants/search"),E=require("@redocly/theme/components/Button/Button"),We=require("@redocly/theme/icons/SendIcon/SendIcon"),Ye=require("@redocly/theme/icons/StopIcon/StopIcon"),M=require("./replay-db-Bq7IGfIa.js"),Ke=require("@redocly/theme/icons/CheckboxIcon/CheckboxIcon"),Je=require("@redocly/theme/icons/CheckmarkFilledIcon/CheckmarkFilledIcon"),Xe=require("@redocly/theme/icons/CloseFilledIcon/CloseFilledIcon"),Ze=require("@redocly/theme/icons/AddIcon/AddIcon"),Qe=require("@redocly/theme/icons/SubtractIcon/SubtractIcon"),K=require("@redocly/theme/core/utils"),et=require("@redocly/theme/icons/ChevronDownIcon/ChevronDownIcon"),tt=require("@redocly/theme/icons/ChevronRightIcon/ChevronRightIcon"),nt=require("@redocly/theme/components/Dropdown/Dropdown"),rt=require("@redocly/theme/components/Dropdown/DropdownMenu"),je=require("@redocly/theme/components/Dropdown/DropdownMenuItem"),ot=require("@redocly/theme/icons/CheckmarkIcon/CheckmarkIcon"),it=require("@redocly/theme/icons/SettingsCogIcon/SettingsCogIcon"),st=require("@redocly/theme/icons/ChatGptIcon/ChatGptIcon"),at=require("@redocly/theme/icons/GeminiIcon/GeminiIcon"),lt=require("@redocly/theme/icons/ClaudeIcon/ClaudeIcon"),B=require("@redocly/theme/components/Tooltip/Tooltip"),le=require("./replay-SemanticSearchService-DwIcsNYC.js");require("@tanstack/react-query");const G=require("@redocly/theme/components/Typography/Typography"),ct=require("@redocly/theme/icons/TrashCanIcon/TrashCanIcon"),dt=require("@redocly/theme/icons/AiStarsGradientIcon/AiStarsGradientIcon"),ut=require("@redocly/theme/icons/CloseIcon/CloseIcon"),ft=require("@redocly/theme/icons/NewChatIcon/NewChatIcon"),pt=require("@redocly/theme/icons/RecentlyViewedIcon/RecentlyViewedIcon"),ht=require("@redocly/theme/icons/ArrowLeftIcon/ArrowLeftIcon"),xt=e=>e&&e.__esModule?e:{default:e},l=xt(X);function gt({placeholder:e="Ask anything...",className:t,disabled:n,isStreaming:r=!1,onStop:o,modelSelector:s,value:a,onValueChange:d,onSubmit:c,textareaRef:u}){const h=a.trim(),g=!n&&h.length>0&&!r,v=!n&&h.length>0,w=A=>{d(A.target.value)},m=()=>{!h||n||r||c()},b=()=>{!r||!o||o()},C=A=>{A.key==="Enter"&&!A.shiftKey&&!A.nativeEvent.isComposing&&(A.preventDefault(),r&&o?b():m())};return i.jsxs(vt,{className:t,$isActive:v,children:[i.jsx(mt,{ref:u,rows:1,maxLength:Ue.AI_SEARCH_MAX_MESSAGE_LENGTH,placeholder:e,value:a,disabled:n,spellCheck:!1,onChange:w,onKeyDown:C}),i.jsxs(yt,{children:[s,r&&o?i.jsx(bt,{type:"button",size:"small","aria-label":"Stop generating",icon:i.jsx(Ye.StopIcon,{color:"var(--icon-color-on-color)"}),onClick:b}):i.jsx(wt,{type:"button",size:"small","aria-label":"Send message",icon:i.jsx(We.SendIcon,{color:"var(--icon-color-on-color)"}),onClick:m,disabled:!g})]})]})}const vt=l.default.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
gap: var(--spacing-xs);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./replay-index-D3evrr0U.js"),v=require("./replay-SemanticSearchService-DwIcsNYC.js");require("react");var m;(function(r){r.WINDOW_RESIZED="tauri://resize",r.WINDOW_MOVED="tauri://move",r.WINDOW_CLOSE_REQUESTED="tauri://close-requested",r.WINDOW_DESTROYED="tauri://destroyed",r.WINDOW_FOCUS="tauri://focus",r.WINDOW_BLUR="tauri://blur",r.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",r.WINDOW_THEME_CHANGED="tauri://theme-changed",r.WINDOW_CREATED="tauri://window-created",r.WEBVIEW_CREATED="tauri://webview-created",r.DRAG_ENTER="tauri://drag-enter",r.DRAG_OVER="tauri://drag-over",r.DRAG_DROP="tauri://drag-drop",r.DRAG_LEAVE="tauri://drag-leave"})(m||(m={}));async function E(r,e){await l.invoke("plugin:event|unlisten",{event:r,eventId:e})}async function w(r,e,s){var t;const i=(t=void 0)!==null&&t!==void 0?t:{kind:"Any"};return l.invoke("plugin:event|listen",{event:r,target:i,handler:l.transformCallback(e)}).then(a=>async()=>E(r,a))}const p="replay-environments.yaml";class y{constructor(e,s,t,i){this.storage=e,this.state=s,this.projectDir=t,this.aiEnabled=i}storage;state;projectDir;aiEnabled;watchPath=null;unlistenEvent=null;get tauriStorage(){return this.storage}indexApis(e){!this.aiEnabled||e.length===0||v.getSemanticSearchService().indexApis(e).catch(s=>console.error("Semantic index (apis):",s))}indexCollections(e){!this.aiEnabled||e.length===0||v.getSemanticSearchService().indexCollections(e).catch(s=>console.error("Semantic index (collections):",s))}removeApis(e){if(!this.aiEnabled||e.length===0)return;const s=v.getSemanticSearchService();Promise.all(e.map(t=>s.removeApi(t))).catch(t=>console.error("Semantic remove (apis):",t))}removeCollections(e){if(!this.aiEnabled||e.length===0)return;const s=v.getSemanticSearchService();Promise.all(e.map(t=>s.removeCollection(t))).catch(t=>console.error("Semantic remove (collections):",t))}async start(){if(this.watchPath){console.warn("Watcher already started for:",this.watchPath);return}try{this.unlistenEvent=await w("fs-watch-event",async e=>{const s=e.payload;try{await this.handleEvent(s)}catch(t){console.error("Error handling file change:",t)}}),await l.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 l.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:s,paths:t,pathTypes:i,type:a}=e;if(await this.isProjectFolderRemoved(t,s)){await this.handleProjectFolderRemoval();return}const o=this.filterSpecFiles(t,i);if(o.paths.length===0)return;const n=await this.toFileEntries(o.paths,o.pathTypes);switch(s){case"changed":(a.includes("Data")||a.includes("Name"))&&await this.handleModify(n);break;case"added":await this.handleCreate(n);break;case"deleted":await this.handleDelete(n);break;case"renamed":await this.handleRename(n);break;default:console.log("Unhandled change type:",s)}}filterSpecFiles(e,s){const t=[],i=[];for(let a=0;a<e.length;a++){const o=e[a],n=o.split(".").pop()?.toLowerCase();n&&["yaml","yml","json"].includes(n)&&(t.push(o),i.push(s[a]||"unknown"))}return{paths:t,pathTypes:i}}async toFileEntries(e,s){return Promise.all(e.map(async(t,i)=>({relative_path:await l.PathUtils.relative(this.projectDir,t),absolute_path:t,type:s[i]||"unknown"})))}hasEnvironmentsFileChange(e){return!this.storage.isWatchExcluded(p)&&e.some(s=>s.relative_path===p)}withoutEnvironmentsFile(e){return e.filter(s=>s.relative_path!==p)}consolidateFileEntries(e){const s=[],t=new Set;for(const i of e)t.has(i.relative_path)||(t.add(i.relative_path),this.storage.isWatchExcluded(i.relative_path)||s.push(i));return s}async handleModify(e){const s=this.hasEnvironmentsFileChange(e),t=this.withoutEnvironmentsFile(e),{newApiFiles:i,existingApiFiles:a}=this.categorizeApisFromFiles(t),{newCollectionFiles:o,existingCollectionFiles:n}=this.categorizeCollectionsFromFiles(t),d=await this.findApisToReload(e),h=await this.findCollectionsToReload(e),u=[...i,...o];u.length>0&&await this.handleCreate(u),s&&await this.reloadEnvironments();const g=this.consolidateFileEntries([...a,...d]),f=this.consolidateFileEntries([...n,...h]);await this.reloadApis(g),await this.reloadCollections(f)}async handleCreate(e){this.hasEnvironmentsFileChange(e)&&await this.reloadEnvironments();const s=this.withoutEnvironmentsFile(e),t=s.filter(h=>h.type==="api"),i=s.filter(h=>h.type==="collection"),{newApiFiles:a,existingApiFiles:o}=this.categorizeApisFromFiles(t),{newCollectionFiles:n,existingCollectionFiles:d}=this.categorizeCollectionsFromFiles(i);if(a.length>0||n.length>0){a.forEach(c=>this.storage.addPersistExcludedId(c.relative_path)),n.forEach(c=>this.storage.addPersistExcludedId(c.relative_path));const h=a.length>0?await this.tauriStorage.loadAndParseApis(a,void 0,!0):[],u=n.length>0?await this.tauriStorage.loadAndParseCollections(n,void 0):[],g=h.filter(c=>c!==null),f=u.filter(c=>c!==null);this.state.apis.merge(g),this.state.collections.merge(f),this.indexApis(g),this.indexCollections(f),setTimeout(()=>{a.forEach(c=>this.storage.removePersistExcludedId(c.relative_path)),n.forEach(c=>this.storage.removePersistExcludedId(c.relative_path))},500)}o.length>0&&await this.reloadApis(o),d.length>0&&await this.reloadCollections(d)}categorizeApisFromFiles(e){const s=new Set,t=[],i=[];for(const a of e){if(s.has(a.relative_path))continue;s.add(a.relative_path),this.state.apis.get({noproxy:!0}).some(n=>n.id===a.relative_path)?i.push(a):a.type==="api"&&t.push(a)}return{newApiFiles:t,existingApiFiles:i}}categorizeCollectionsFromFiles(e){const s=new Set,t=[],i=[];for(const a of e){if(s.has(a.relative_path))continue;s.add(a.relative_path),this.state.collections.get({noproxy:!0}).some(n=>n.id===a.relative_path)?i.push(a):a.type==="collection"&&t.push(a)}return{newCollectionFiles:t,existingCollectionFiles:i}}async handleDelete(e){this.hasEnvironmentsFileChange(e)&&await this.reloadEnvironments();const s=[],t=[];for(const i of this.withoutEnvironmentsFile(e)){this.storage.addPersistExcludedId(i.relative_path);const a=this.state.apis.get({noproxy:!0}).findIndex(n=>n.id===i.relative_path);a>=0&&(this.state.apis[a].set(l.none),this.tauriStorage.deleteApiFromCache(i.relative_path),s.push(i.relative_path));const o=this.state.collections.get({noproxy:!0}).findIndex(n=>n.id===i.relative_path);o>=0&&(this.state.collections[o].set(l.none),t.push(i.relative_path)),setTimeout(()=>{this.storage.removePersistExcludedId(i.relative_path)},500)}this.removeApis(s),this.removeCollections(t)}async handleRename(e){if(e.length>=2){const[s,t]=e;await this.handleDelete([s]),await this.handleCreate([t])}else await this.handleCreate(e)}async isProjectFolderRemoved(e,s){if(e.length===0)return!1;if(s==="deleted"||s==="renamed"){for(const i of e)if(i===this.projectDir)return!0}return e.filter(i=>!i.startsWith(this.projectDir+"/")&&i!==this.projectDir).length>0&&s==="renamed"}async handleProjectFolderRemoval(){const e=this.state.apis.get({noproxy:!0}),s=e.map(a=>a.id);e.forEach(a=>{this.storage.addPersistExcludedId(a.id),this.tauriStorage.deleteApiFromCache(a.id)}),this.state.apis.set([]);const t=this.state.collections.get({noproxy:!0}),i=t.map(a=>a.id);t.forEach(a=>{this.storage.addPersistExcludedId(a.id)}),this.state.collections.set([]),setTimeout(()=>{e.forEach(a=>this.storage.removePersistExcludedId(a.id)),t.forEach(a=>this.storage.removePersistExcludedId(a.id))},500),this.removeApis(s),this.removeCollections(i),await this.stop()}async findApisToReload(e){const s=[];return await Promise.all(this.state.apis.map(async t=>{const i=t.fileDependencies?.get({noproxy:!0})??new Set,a=t.get({noproxy:!0}).id,o=e.find(n=>i.has(n.absolute_path));if(!this.storage.isWatchExcluded(a)&&o){const n=await l.PathUtils.join(this.projectDir,a);s.push({relative_path:a,absolute_path:n,type:"api"})}})),s}async findCollectionsToReload(e){const s=[];return await Promise.all(this.state.collections.map(async t=>{const i=t.fileDependencies?.get({noproxy:!0})??new Set,a=t.get({noproxy:!0}).id,o=e.find(n=>i.has(n.absolute_path));if(!this.storage.isWatchExcluded(a)&&o){const n=await l.PathUtils.join(this.projectDir,a);s.push({relative_path:a,absolute_path:n,type:"collection"})}})),s}async reloadEnvironments(){const e=await this.tauriStorage.readEnviroments();this.storage.addPersistExcludedId(p),this.state.environments.set(e.length>0?e:l.cloneObject(l.DEFAULT_ENVIRONMENTS)),this.state.configFileError.set(this.storage.getEnvironmentsConfigError()),setTimeout(()=>{this.storage.removePersistExcludedId(p)},500)}async reloadApis(e){if(e.length===0)return;const s=await this.tauriStorage.loadAndParseApis(e,void 0,!0),t=[];await Promise.all(s.map(async(i,a)=>{if(!i){await this.handleDelete([e[a]]);return}const o=this.state.apis.get({noproxy:!0}).findIndex(n=>n.id===i.id);o>=0?(this.storage.addPersistExcludedId(i.id),this.state.apis[o].set(i),t.push(i),setTimeout(()=>this.storage.removePersistExcludedId(i.id),500)):console.warn("API not found in state after reload:",i.id)})),t.length>0&&this.indexApis(t)}async reloadCollections(e){if(e.length===0)return;const s=await this.tauriStorage.loadAndParseCollections(e,void 0),t=[];await Promise.all(s.map(async(i,a)=>{if(!i){await this.handleDelete([e[a]]);return}const o=this.state.collections.get({noproxy:!0}).findIndex(n=>n.id===i.id);o>=0?(this.storage.addPersistExcludedId(i.id),this.state.collections[o].set(i),t.push(i),setTimeout(()=>this.storage.removePersistExcludedId(i.id),500)):console.warn("Collection not found in state after reload:",i.id)})),t.length>0&&this.indexCollections(t)}}exports.FileWatcher=y;
|