llmspy 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/proxy/dist/index.js +15 -1
- package/proxy/dist/proxy.js +16 -0
- package/proxy/package.json +1 -1
- package/ui/dist/assets/{index-CyJmqpbn.js → index-B9XIilZJ.js} +3 -2
- package/ui/dist/index.html +1 -1
package/README.md
CHANGED
|
@@ -150,7 +150,7 @@ claude
|
|
|
150
150
|
|
|
151
151
|
Each request then appears in the UI at `http://127.0.0.1:8080`. The app keeps its own API key, which LLMSpy passes on to the provider.
|
|
152
152
|
|
|
153
|
-
For coding agents and scripts, [llms.txt](llms.txt) is a compact reference: how to run LLMSpy, point an app at it, read the captured traffic as JSON or one call as Markdown, and wait for a call that is still running.
|
|
153
|
+
For coding agents and scripts, [llms.txt](llms.txt) is a compact reference: how to run LLMSpy, point an app at it, read the captured traffic as JSON or one call as Markdown, and wait for a call that is still running. A running LLMSpy serves it too, for its own version, at `http://127.0.0.1:8080/llms.txt`.
|
|
154
154
|
|
|
155
155
|
### Keep apps apart with projects
|
|
156
156
|
|
package/llms.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# LLMSpy
|
|
2
2
|
|
|
3
|
-
> A local reverse proxy that records the LLM API calls an app makes and shows each one in a web UI: the prompt, the system message, the tools, the reply and the token counts. An app is pointed at it by its base URL setting (`ANTHROPIC_BASE_URL`, `OPENAI_BASE_URL`); requests are forwarded unchanged and a copy is kept. This file is the reference for AI agents and scripts; it ships in the repository and in the npm package `llmspy`, and `README.md` is the human guide.
|
|
3
|
+
> A local reverse proxy that records the LLM API calls an app makes and shows each one in a web UI: the prompt, the system message, the tools, the reply and the token counts. An app is pointed at it by its base URL setting (`ANTHROPIC_BASE_URL`, `OPENAI_BASE_URL`); requests are forwarded unchanged and a copy is kept. This file is the reference for AI agents and scripts; it ships in the repository and in the npm package `llmspy`, a running LLMSpy serves it at `/llms.txt` (`http://127.0.0.1:8080/llms.txt` by default) for the version that is running, and `README.md` is the human guide.
|
|
4
4
|
|
|
5
5
|
## What it does and does not do
|
|
6
6
|
|
package/package.json
CHANGED
package/proxy/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, mkdirSync } from 'node:fs';
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import { hostForUrl } from './guard.js';
|
|
@@ -10,8 +10,21 @@ import { readVersion } from './version.js';
|
|
|
10
10
|
// Built layout: proxy/dist/index.js next to ui/dist/ (also in the image and
|
|
11
11
|
// the npm package).
|
|
12
12
|
const uiDir = path.resolve(import.meta.dirname, '../../ui/dist');
|
|
13
|
+
// llms.txt is at the root of the repo, the image and the npm package.
|
|
14
|
+
const llmsTxtFile = path.resolve(import.meta.dirname, '../../llms.txt');
|
|
13
15
|
const dbFile = path.join(homedir(), '.llmspy', 'llmspy.db');
|
|
14
16
|
const HOUR_MS = 60 * 60 * 1000;
|
|
17
|
+
/** The text of llms.txt, or undefined when it is not there (then `/llms.txt` is a 404). */
|
|
18
|
+
function readLlmsTxt() {
|
|
19
|
+
try {
|
|
20
|
+
return readFileSync(llmsTxtFile, 'utf8');
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (error.code === 'ENOENT')
|
|
24
|
+
return undefined;
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
15
28
|
let config;
|
|
16
29
|
let store;
|
|
17
30
|
let retentionDays;
|
|
@@ -21,6 +34,7 @@ try {
|
|
|
21
34
|
host: process.env.LLMSPY_HOST ?? '127.0.0.1',
|
|
22
35
|
upstreams: parseUpstreams(process.env.LLMSPY_UPSTREAMS),
|
|
23
36
|
uiDir,
|
|
37
|
+
llmsTxt: readLlmsTxt(),
|
|
24
38
|
version: readVersion(),
|
|
25
39
|
};
|
|
26
40
|
retentionDays = parseRetentionDays(process.env.LLMSPY_RETENTION_DAYS);
|
package/proxy/dist/proxy.js
CHANGED
|
@@ -51,6 +51,12 @@ export class ProxyServer {
|
|
|
51
51
|
this.handlePing(res);
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
+
if (path === '/llms.txt' &&
|
|
55
|
+
this.config.llmsTxt !== undefined &&
|
|
56
|
+
(req.method === 'GET' || req.method === 'HEAD')) {
|
|
57
|
+
this.handleLlmsTxt(req, res, this.config.llmsTxt);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
54
60
|
if (path === '/events') {
|
|
55
61
|
this.handleSSE(req, res);
|
|
56
62
|
return;
|
|
@@ -269,6 +275,16 @@ export class ProxyServer {
|
|
|
269
275
|
res.writeHead(400, { 'content-type': 'text/plain; charset=utf-8' });
|
|
270
276
|
res.end(`LLMSpy: ${message}`);
|
|
271
277
|
}
|
|
278
|
+
/** `GET /llms.txt`: the reference for agents. Not guarded: it holds no captured data. */
|
|
279
|
+
handleLlmsTxt(req, res, text) {
|
|
280
|
+
res.writeHead(200, {
|
|
281
|
+
'content-type': 'text/plain; charset=utf-8',
|
|
282
|
+
'content-length': Buffer.byteLength(text),
|
|
283
|
+
'cache-control': 'no-cache',
|
|
284
|
+
'x-content-type-options': 'nosniff',
|
|
285
|
+
});
|
|
286
|
+
res.end(req.method === 'HEAD' ? undefined : text);
|
|
287
|
+
}
|
|
272
288
|
handlePing(res) {
|
|
273
289
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
274
290
|
res.end(JSON.stringify({
|
package/proxy/package.json
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
shows its number of matches.</li> <li>The chips under Today show only the calls of the last 5 to 90
|
|
19
19
|
minutes.</li> <li>The red Failed chip shows only the calls that went wrong: an error,
|
|
20
20
|
a status of 400 or above, or an error inside the reply.</li> <li>The cards at the top count the calls in the list: how many, how many
|
|
21
|
-
failed, their tokens and their latency.</li> <li>
|
|
21
|
+
failed, their tokens and their latency.</li> <li>Coding agents and scripts can read the captured calls too; point them
|
|
22
|
+
at the reference: <code class="help-code"> </code></li> <li>API keys are masked. Prompts and replies are shown in full.</li> <li>Calls are kept in a file on your machine, so they survive a restart:
|
|
22
23
|
the last 7 days unless <code>LLMSPY_RETENTION_DAYS</code> says
|
|
23
|
-
otherwise. Clear All empties the project you are viewing.</li></ul> <p class="help-more">More in the <a target="_blank" rel="noreferrer">README</a>.</p></div>`);function Zs(e,t){let n=M(()=>`${location.protocol}//${t.address??`127.0.0.1:8080`}`);Js(e,{id:`help-popover`,label:`Help`,buttonClass:`icon-btn`,buttonLabel:`Help`,trigger:e=>{J(e,Ys())},children:(e,t)=>{var r=Xs(),i=z(I(r),2),a=I(i),o=z(I(a)),s=R(o),c=R(z(o,2));we(),D(a),we(4),D(i);var l=z(i,4),u=z(I(l),2),d=R(z(I(u),3));we(3),D(u),we(12),D(l);var f=z(l,2);$(z(I(f)),`href`,`https://github.com/piyook/llmspy#readme`),we(),D(f),D(r),B(()=>{Y(s,`ANTHROPIC_BASE_URL=${U(n)??``}/anthropic`),Y(c,`OPENAI_BASE_URL=${U(n)??``}/openai/v1`),Y(d,`ANTHROPIC_BASE_URL=${U(n)??``}/@my-app/anthropic`)}),J(e,r)},$$slots:{trigger:!0,default:!0}})}var Qs=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}],$s=`llmspy-theme`;function ec(){try{let e=localStorage.getItem($s);if(e===`light`||e===`dark`)return e}catch{}return`system`}function tc(e){let t=document.documentElement;e===`system`?delete t.dataset.theme:t.dataset.theme=e;try{e===`system`?localStorage.removeItem($s):localStorage.setItem($s,e)}catch{}}var nc=xr(`<svg viewBox="0 0 24 24" width="28" height="28" fill="none" stroke="currentColor" aria-hidden="true"><circle cx="12" cy="12" r="6.5" stroke-width="2"></circle><circle cx="12" cy="12" r="2.5" stroke-width="2"></circle><path stroke-width="3" d="M19 12h3M12 19v3M5 12H2M12 5V2M16.95 16.95l2.12 2.12M7.05 16.95l-2.12 2.12M7.05 7.05 4.93 4.93M16.95 7.05l2.12-2.12"></path></svg>`),rc=K(`<label><input type="radio" name="theme"/> </label>`),ic=K(`<p class="setting-version"> </p>`),ac=K(`<fieldset class="setting"><legend>Theme</legend> <div class="setting-options"></div></fieldset> <!>`,1);function oc(e,t){k(t,!0);let n=[],r=P(Wt(ec()));Js(e,{id:`settings-popover`,label:`Settings`,buttonClass:`icon-btn`,buttonLabel:`Settings`,trigger:e=>{J(e,nc())},children:(e,i)=>{var a=ac(),o=L(a),s=z(I(o),2);Z(s,21,()=>Qs,e=>e.value,(e,t)=>{var i=rc(),a=I(i);ri(a);var o,s=z(a);D(i),B(()=>{o!==(o=U(t).value)&&(a.value=(a.__value=o)??``),Y(s,` ${U(t).label??``}`)}),W(`change`,a,()=>tc(U(r))),li(n,[],a,()=>(U(t).value,U(r)),e=>F(r,e)),J(e,i)}),D(s),D(o);var c=z(o,2),l=e=>{var n=ic(),r=R(n);B(()=>Y(r,`LLMSpy ${t.version??``}`)),J(e,n)};X(c,e=>{t.version&&e(l)}),J(e,a)},$$slots:{trigger:!0,default:!0}}),A()}G([`change`]);var sc=xr(`<path class="wave wave-far" d="M26 4.5a10 10 0 0 1 0 15"></path><path class="wave wave-mid" d="M22.5 7a7 7 0 0 1 0 10"></path><path class="wave wave-near" d="M19.5 9.5a3.5 3.5 0 0 1 0 5"></path>`,1),cc=xr(`<line x1="3" y1="4" x2="18" y2="21"></line>`),lc=K(`<span role="status"><svg viewBox="0 0 30 24" width="45" height="36" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 9.5A6.5 6.5 0 0 1 17 9.5C17 14 12.5 15 12.5 18.5A3.5 3.5 0 0 1 5.5 18.5"></path><path d="M13.5 9.5A3 3 0 0 0 7.5 9.5v1a2 2 0 0 1 0 4"></path><!></svg> <span class="visually-hidden"> </span></span>`);function uc(e,t){let n=M(()=>t.connected?`Listening${t.address?` on ${t.address}`:``}`:`Not connected to the proxy`);var r=lc();let i;var a=I(r),o=z(I(a),2),s=e=>{var t=sc();we(2),J(e,t)},c=e=>{J(e,cc())};X(o,e=>{t.connected?e(s):e(c,-1)}),D(a);var l=R(z(a,2),!0);D(r),B(()=>{i=Q(r,1,`status-icon`,null,i,{connected:t.connected}),$(r,`title`,U(n)),Y(l,U(n))}),J(e,r)}var dc=K(`<p class="popover-error">Not connected to the proxy.</p>`),fc=K(`<p class="popover-error">Couldn't load the list from the proxy.</p>`),pc=K(`<p class="popover-hint">Loading...</p>`),mc=K(`<li class="upstream"><span class="upstream-name"> </span> <code class="upstream-url"> </code> <button type="button" class="small-btn"> </button> <span class="upstream-target"> </span></li>`),hc=K(`<ul class="upstream-list"></ul>`),gc=K(`<p class="popover-hint">Point an app's base URL at one of these.</p> <!>`,1);function _c(e,t){k(t,!0);let n=P(void 0),r=P(!1),i=P(void 0),a;function o(e){return`${location.protocol}//${t.address}/${e}`}async function s(){F(r,!1);try{let e=await fetch(`/api/upstreams`);if(!e.ok)throw Error(`HTTP ${e.status}`);F(n,await e.json(),!0)}catch{F(n,void 0),F(r,!0)}}async function c(e){let t=`Copied`;try{await navigator.clipboard.writeText(o(e))}catch{t=`Failed`}F(i,{name:e,label:t},!0),clearTimeout(a),a=setTimeout(()=>F(i,void 0),1500)}Js(e,{id:`upstream-popover`,label:`Base URLs`,align:`center`,onopen:s,trigger:e=>{we(),J(e,Sr(`Base URLs`))},children:(e,a)=>{var s=gc(),l=z(L(s),2),u=e=>{J(e,dc())},d=e=>{J(e,fc())},f=e=>{J(e,pc())},p=e=>{var t=hc();Z(t,21,()=>U(n),e=>e.name,(e,t)=>{var n=mc(),r=I(n),a=R(r,!0),s=z(r,2),l=R(s,!0),u=z(s,2),d=R(u,!0),f=R(z(u,2));D(n),B(e=>{Y(a,U(t).name),Y(l,e),$(u,`aria-label`,`Copy the ${U(t).name} base URL`),Y(d,U(i)?.name===U(t).name?U(i).label:`Copy`),Y(f,`to ${U(t).target??``}`)},[()=>o(U(t).name)]),W(`click`,u,()=>c(U(t).name)),J(e,n)}),D(t),J(e,t)};X(l,e=>{t.address?U(r)?e(d,1):U(n)?e(p,-1):e(f,2):e(u)}),J(e,s)},$$slots:{trigger:!0,default:!0}}),A()}G([`click`]);var vc=K(`<div class="header"><div class="title"><h1>LLMSpy</h1> <!></div> <div class="controls"><!> <input type="search" placeholder="Search requests..." aria-label="Search requests" class="search"/> <button type="button" class="clear-btn">Clear All</button> <!> <!></div></div>`);function yc(e,t){k(t,!0);let n=vi(t,`search`,15,``);var r=vc(),i=I(r);uc(z(I(i),2),{get connected(){return t.connected},get address(){return t.address}}),D(i);var a=z(i,2),o=I(a);{let e=M(()=>t.connected?t.address:void 0);_c(o,{get address(){return U(e)}})}var s=z(o,2);ri(s);var c=z(s,2),l=z(c,2);{let e=M(()=>t.connected?t.address:void 0);Zs(l,{get address(){return U(e)}})}oc(z(l,2),{get version(){return t.version}}),D(a),D(r),si(s,n),W(`click`,c,function(...e){t.onclear?.apply(this,e)}),J(e,r),A()}G([`click`]);var bc=K(`<p class="pick-hint" role="status">Click the call to compare with. <button type="button" class="small-btn">Cancel</button></p>`),xc=K(`<div class="day"><!> <!> <!></div>`),Sc=K(`<div class="no-requests">Loading…</div>`),Cc=K(`<div class="no-requests">Select a request to see it here.</div>`),wc=K(`<!> <!> <!> <div class="panes"><section aria-label="Captured requests"><!> <!> <!></section> <section class="detail" aria-label="Selected request"><!></section></div>`,1);function Tc(e,t){k(t,!0);let n=new bi,r=P(``),i=P(void 0),a=P(!1),o=P(void 0),s=P(void 0);async function c(){try{let e=await(await fetch(`/ping`)).json();typeof e.port==`number`&&F(o,`${location.hostname}:${e.port}`),typeof e.version==`string`&&F(s,e.version,!0)}catch{}}let l=M(()=>hs(n.values())),u=P(Wt(ms)),d=M(()=>U(l).includes(U(u))?U(u):ms),f=Date.now(),p=new bi,m=e=>vs(n.values(),e,p.get(e)??f);function h(e){if(e===U(d))return;let t=Date.now();p.set(U(d),t),p.set(e,t),F(u,e,!0),F(i,void 0),F(y,void 0),F(b,!1)}let g=M(()=>U(i)?n.get(U(i)):void 0),_=bs(()=>U(g)),v=P(`conversation`),y=P(void 0),b=P(!1),x=M(()=>{if(U(g))return(U(y)?n.get(U(y)):void 0)??ta(n.values(),U(g))}),S=M(()=>U(g)!==void 0&&U(v)===`compare`),ee=bs(()=>U(S)?U(x):void 0),te=M(()=>!_.current||U(S)&&U(x)!==void 0&&!ee.current);function ne(e){U(b)?(F(b,!1),e!==U(i)&&F(y,e,!0)):(F(i,e,!0),F(y,void 0))}function re(e){e.key===`Escape`&&F(b,!1)}let ie=P(void 0),ae=M(()=>U(ie)?.filter(({id:e})=>n.has(e))),oe=M(()=>U(ae)&&new Set(U(ae).map(({id:e})=>e))),se=M(()=>U(ae)&&gs(U(ae))),ce=M(()=>[...n.values()].filter(e=>Ho(e)===`done`).length);pn(()=>{let e=U(r);if(U(ce),!e){F(ie,void 0);return}let t=!1,n=setTimeout(async()=>{try{let n=await fetch(`/api/requests?${new URLSearchParams({q:e})}`);if(!n.ok)return;let r=await n.json();t||F(ie,r)}catch(e){console.error(`Failed to search requests:`,e)}},250);return()=>{t=!0,clearTimeout(n)}});let le=M(()=>U(l).flatMap(e=>{let t=U(se)?.get(e)??0;return e!==U(d)&&t>0?[[e,t]]:[]})),ue=P(!1),de=M(()=>[...n.values()].filter(e=>zo(e,{project:U(d),matches:U(r)?U(oe):void 0})).sort(Go)),fe=M(()=>U(ue)?Bo(U(de)):U(de)),pe=P(Wt(Date.now())),me=M(()=>cs(U(pe))),he=new bi;pn(()=>{let e=setInterval(()=>{let e=Date.now(),t=cs(U(pe));cs(e)!==t&&!he.has(t)&&he.set(t,!0),F(pe,e,!0)},6e4);return()=>clearInterval(e)});let ge=M(()=>ps(U(fe))),_e=e=>!!U(r)||U(ue)||(he.get(e)??e===U(me)),C=P(void 0),ve=M(()=>U(C)!==void 0&&!U(r)),ye=P(Wt(Date.now()));pn(()=>{if(!U(ve))return;F(ye,Date.now(),!0);let e=setInterval(()=>F(ye,Date.now(),!0),5e3);return()=>clearInterval(e)});let be=e=>e===U(me)&&!U(r)&&_e(e),xe=e=>U(ve)&&U(C)!==void 0&&e.key===U(me)?fs(e.calls,U(C),U(ye)):e.calls,w=M(()=>U(ge).flatMap(xe)),Se=M(()=>xs(Si(U(w)))),T=M(()=>Vo(ps(U(de)).flatMap(xe)));yi(()=>{let e,t;function r(){e=new EventSource(`/events`),e.onopen=()=>{F(a,!0),n.clear(),c()},e.onmessage=e=>{let t=JSON.parse(e.data);n.set(t.id,t)},e.addEventListener(`clear`,e=>{let{project:t}=JSON.parse(e.data);we(typeof t==`string`?t:void 0)}),e.addEventListener(`delete`,e=>{let{id:t}=JSON.parse(e.data);typeof t==`string`&&E(t)}),e.onerror=()=>{F(a,!1),e?.readyState===EventSource.CLOSED&&(t=setTimeout(r,3e3))}}return r(),()=>{clearTimeout(t),e?.close()}});function E(e){n.delete(e),U(i)===e&&(F(i,void 0),F(b,!1)),U(y)===e&&F(y,void 0)}async function Ce(e){try{let t=await fetch(`/api/requests/${e}`,{method:`DELETE`});(t.ok||t.status===404)&&E(e)}catch(e){console.error(`Failed to delete request:`,e)}}function we(e){for(let t of[...n.values()])(e===void 0||t.project===e)&&E(t.id)}async function Te(){let e=U(d);try{await fetch(`/api/clear?project=${encodeURIComponent(e)}`,{method:`POST`}),we(e)}catch(e){console.error(`Failed to clear requests:`,e)}}var Ee=wc();fr(`keydown`,qt,re);var De=L(Ee);yc(De,{get connected(){return U(a)},get address(){return U(o)},get version(){return U(s)},onclear:Te,get search(){return U(r)},set search(e){F(r,e,!0)}});var Oe=z(De,2);{let e=M(()=>U(r)?U(se):void 0);Es(Oe,{get projects(){return U(l)},get current(){return U(d)},unseen:m,get matches(){return U(e)},onchoose:h})}var ke=z(Oe,2);{let e=M(()=>U(w).length>0);Gs(ke,{get shown(){return U(e)},get cards(){return U(Se)}})}var Ae=z(ke,2),je=I(Ae);let Me;var Ne=I(je),Pe=e=>{var t=bc(),n=z(I(t));D(t),W(`click`,n,()=>F(b,!1)),J(e,t)};X(Ne,e=>{U(b)&&e(Pe)});var Fe=z(Ne,2);ss(Fe,{get pressed(){return U(ue)},get count(){return U(T)},ontoggle:()=>F(ue,!U(ue))}),Z(z(Fe,2),17,()=>U(ge),e=>e.key,(e,t)=>{let n=M(()=>_e(U(t).key)),r=M(()=>xe(U(t)));var a=xc(),o=I(a);{let e=M(()=>us(U(t).key,U(pe)));Ei(o,{get label(){return U(e)},get count(){return U(r).length},get total(){return U(t).calls.length},get open(){return U(n)},ontoggle:()=>he.set(U(t).key,!U(n))})}var s=z(o,2);{let e=M(()=>be(U(t).key));As(s,{get shown(){return U(e)},get minutes(){return U(C)},get count(){return U(r).length},onchoose:e=>F(C,e,!0)})}var c=z(s,2),l=e=>{var t=q();Z(L(t),17,()=>U(r),e=>e.id,(e,t)=>{{let n=M(()=>U(t).id===U(i)),r=M(()=>U(S)&&U(t).id===U(x)?.id);Vs(e,{get request(){return U(t)},get selected(){return U(n)},get comparing(){return U(S)},get compared(){return U(r)},onselect:()=>ne(U(t).id),ondelete:()=>Ce(U(t).id)})}}),J(e,t)};X(c,e=>{U(n)&&e(l)}),D(a),J(e,a)},e=>{as(e,{get project(){return U(d)},get search(){return U(r)},get failedOnly(){return U(ue)},get elsewhere(){return U(le)},onchoose:h})}),D(je);var Ie=z(je,2),Le=I(Ie),Re=e=>{J(e,Sc())},ze=e=>{ts(e,{get request(){return _.current},get other(){return ee.current},get picking(){return U(b)},onpick:()=>F(b,!U(b)),get chosen(){return U(v)},set chosen(e){F(v,e,!0)}})},Be=e=>{J(e,Cc())};X(Le,e=>{U(g)&&U(te)?e(Re):_.current?e(ze,1):e(Be,-1)}),D(Ie),D(Ae),B(()=>Me=Q(je,1,`list`,null,Me,{picking:U(b)})),J(e,Ee),A()}G([`click`]);var Ec=document.getElementById(`app`);if(!Ec)throw Error(`#app element not found in index.html`);Dr(Tc,{target:Ec});
|
|
24
|
+
otherwise. Clear All empties the project you are viewing.</li></ul> <p class="help-more">More in the <a target="_blank" rel="noreferrer">README</a>.</p></div>`);function Zs(e,t){let n=M(()=>`${location.protocol}//${t.address??`127.0.0.1:8080`}`);Js(e,{id:`help-popover`,label:`Help`,buttonClass:`icon-btn`,buttonLabel:`Help`,trigger:e=>{J(e,Ys())},children:(e,t)=>{var r=Xs(),i=z(I(r),2),a=I(i),o=z(I(a)),s=R(o),c=R(z(o,2));we(),D(a),we(4),D(i);var l=z(i,4),u=z(I(l),2),d=R(z(I(u),3));we(3),D(u);var f=z(u,10),p=R(z(I(f)));D(f),we(4),D(l);var m=z(l,2);$(z(I(m)),`href`,`https://github.com/piyook/llmspy#readme`),we(),D(m),D(r),B(()=>{Y(s,`ANTHROPIC_BASE_URL=${U(n)??``}/anthropic`),Y(c,`OPENAI_BASE_URL=${U(n)??``}/openai/v1`),Y(d,`ANTHROPIC_BASE_URL=${U(n)??``}/@my-app/anthropic`),Y(p,`${U(n)??``}/llms.txt`)}),J(e,r)},$$slots:{trigger:!0,default:!0}})}var Qs=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}],$s=`llmspy-theme`;function ec(){try{let e=localStorage.getItem($s);if(e===`light`||e===`dark`)return e}catch{}return`system`}function tc(e){let t=document.documentElement;e===`system`?delete t.dataset.theme:t.dataset.theme=e;try{e===`system`?localStorage.removeItem($s):localStorage.setItem($s,e)}catch{}}var nc=xr(`<svg viewBox="0 0 24 24" width="28" height="28" fill="none" stroke="currentColor" aria-hidden="true"><circle cx="12" cy="12" r="6.5" stroke-width="2"></circle><circle cx="12" cy="12" r="2.5" stroke-width="2"></circle><path stroke-width="3" d="M19 12h3M12 19v3M5 12H2M12 5V2M16.95 16.95l2.12 2.12M7.05 16.95l-2.12 2.12M7.05 7.05 4.93 4.93M16.95 7.05l2.12-2.12"></path></svg>`),rc=K(`<label><input type="radio" name="theme"/> </label>`),ic=K(`<p class="setting-version"> </p>`),ac=K(`<fieldset class="setting"><legend>Theme</legend> <div class="setting-options"></div></fieldset> <!>`,1);function oc(e,t){k(t,!0);let n=[],r=P(Wt(ec()));Js(e,{id:`settings-popover`,label:`Settings`,buttonClass:`icon-btn`,buttonLabel:`Settings`,trigger:e=>{J(e,nc())},children:(e,i)=>{var a=ac(),o=L(a),s=z(I(o),2);Z(s,21,()=>Qs,e=>e.value,(e,t)=>{var i=rc(),a=I(i);ri(a);var o,s=z(a);D(i),B(()=>{o!==(o=U(t).value)&&(a.value=(a.__value=o)??``),Y(s,` ${U(t).label??``}`)}),W(`change`,a,()=>tc(U(r))),li(n,[],a,()=>(U(t).value,U(r)),e=>F(r,e)),J(e,i)}),D(s),D(o);var c=z(o,2),l=e=>{var n=ic(),r=R(n);B(()=>Y(r,`LLMSpy ${t.version??``}`)),J(e,n)};X(c,e=>{t.version&&e(l)}),J(e,a)},$$slots:{trigger:!0,default:!0}}),A()}G([`change`]);var sc=xr(`<path class="wave wave-far" d="M26 4.5a10 10 0 0 1 0 15"></path><path class="wave wave-mid" d="M22.5 7a7 7 0 0 1 0 10"></path><path class="wave wave-near" d="M19.5 9.5a3.5 3.5 0 0 1 0 5"></path>`,1),cc=xr(`<line x1="3" y1="4" x2="18" y2="21"></line>`),lc=K(`<span role="status"><svg viewBox="0 0 30 24" width="45" height="36" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 9.5A6.5 6.5 0 0 1 17 9.5C17 14 12.5 15 12.5 18.5A3.5 3.5 0 0 1 5.5 18.5"></path><path d="M13.5 9.5A3 3 0 0 0 7.5 9.5v1a2 2 0 0 1 0 4"></path><!></svg> <span class="visually-hidden"> </span></span>`);function uc(e,t){let n=M(()=>t.connected?`Listening${t.address?` on ${t.address}`:``}`:`Not connected to the proxy`);var r=lc();let i;var a=I(r),o=z(I(a),2),s=e=>{var t=sc();we(2),J(e,t)},c=e=>{J(e,cc())};X(o,e=>{t.connected?e(s):e(c,-1)}),D(a);var l=R(z(a,2),!0);D(r),B(()=>{i=Q(r,1,`status-icon`,null,i,{connected:t.connected}),$(r,`title`,U(n)),Y(l,U(n))}),J(e,r)}var dc=K(`<p class="popover-error">Not connected to the proxy.</p>`),fc=K(`<p class="popover-error">Couldn't load the list from the proxy.</p>`),pc=K(`<p class="popover-hint">Loading...</p>`),mc=K(`<li class="upstream"><span class="upstream-name"> </span> <code class="upstream-url"> </code> <button type="button" class="small-btn"> </button> <span class="upstream-target"> </span></li>`),hc=K(`<ul class="upstream-list"></ul>`),gc=K(`<p class="popover-hint">Point an app's base URL at one of these.</p> <!>`,1);function _c(e,t){k(t,!0);let n=P(void 0),r=P(!1),i=P(void 0),a;function o(e){return`${location.protocol}//${t.address}/${e}`}async function s(){F(r,!1);try{let e=await fetch(`/api/upstreams`);if(!e.ok)throw Error(`HTTP ${e.status}`);F(n,await e.json(),!0)}catch{F(n,void 0),F(r,!0)}}async function c(e){let t=`Copied`;try{await navigator.clipboard.writeText(o(e))}catch{t=`Failed`}F(i,{name:e,label:t},!0),clearTimeout(a),a=setTimeout(()=>F(i,void 0),1500)}Js(e,{id:`upstream-popover`,label:`Base URLs`,align:`center`,onopen:s,trigger:e=>{we(),J(e,Sr(`Base URLs`))},children:(e,a)=>{var s=gc(),l=z(L(s),2),u=e=>{J(e,dc())},d=e=>{J(e,fc())},f=e=>{J(e,pc())},p=e=>{var t=hc();Z(t,21,()=>U(n),e=>e.name,(e,t)=>{var n=mc(),r=I(n),a=R(r,!0),s=z(r,2),l=R(s,!0),u=z(s,2),d=R(u,!0),f=R(z(u,2));D(n),B(e=>{Y(a,U(t).name),Y(l,e),$(u,`aria-label`,`Copy the ${U(t).name} base URL`),Y(d,U(i)?.name===U(t).name?U(i).label:`Copy`),Y(f,`to ${U(t).target??``}`)},[()=>o(U(t).name)]),W(`click`,u,()=>c(U(t).name)),J(e,n)}),D(t),J(e,t)};X(l,e=>{t.address?U(r)?e(d,1):U(n)?e(p,-1):e(f,2):e(u)}),J(e,s)},$$slots:{trigger:!0,default:!0}}),A()}G([`click`]);var vc=K(`<div class="header"><div class="title"><h1>LLMSpy</h1> <!></div> <div class="controls"><!> <input type="search" placeholder="Search requests..." aria-label="Search requests" class="search"/> <button type="button" class="clear-btn">Clear All</button> <!> <!></div></div>`);function yc(e,t){k(t,!0);let n=vi(t,`search`,15,``);var r=vc(),i=I(r);uc(z(I(i),2),{get connected(){return t.connected},get address(){return t.address}}),D(i);var a=z(i,2),o=I(a);{let e=M(()=>t.connected?t.address:void 0);_c(o,{get address(){return U(e)}})}var s=z(o,2);ri(s);var c=z(s,2),l=z(c,2);{let e=M(()=>t.connected?t.address:void 0);Zs(l,{get address(){return U(e)}})}oc(z(l,2),{get version(){return t.version}}),D(a),D(r),si(s,n),W(`click`,c,function(...e){t.onclear?.apply(this,e)}),J(e,r),A()}G([`click`]);var bc=K(`<p class="pick-hint" role="status">Click the call to compare with. <button type="button" class="small-btn">Cancel</button></p>`),xc=K(`<div class="day"><!> <!> <!></div>`),Sc=K(`<div class="no-requests">Loading…</div>`),Cc=K(`<div class="no-requests">Select a request to see it here.</div>`),wc=K(`<!> <!> <!> <div class="panes"><section aria-label="Captured requests"><!> <!> <!></section> <section class="detail" aria-label="Selected request"><!></section></div>`,1);function Tc(e,t){k(t,!0);let n=new bi,r=P(``),i=P(void 0),a=P(!1),o=P(void 0),s=P(void 0);async function c(){try{let e=await(await fetch(`/ping`)).json();typeof e.port==`number`&&F(o,`${location.hostname}:${e.port}`),typeof e.version==`string`&&F(s,e.version,!0)}catch{}}let l=M(()=>hs(n.values())),u=P(Wt(ms)),d=M(()=>U(l).includes(U(u))?U(u):ms),f=Date.now(),p=new bi,m=e=>vs(n.values(),e,p.get(e)??f);function h(e){if(e===U(d))return;let t=Date.now();p.set(U(d),t),p.set(e,t),F(u,e,!0),F(i,void 0),F(y,void 0),F(b,!1)}let g=M(()=>U(i)?n.get(U(i)):void 0),_=bs(()=>U(g)),v=P(`conversation`),y=P(void 0),b=P(!1),x=M(()=>{if(U(g))return(U(y)?n.get(U(y)):void 0)??ta(n.values(),U(g))}),S=M(()=>U(g)!==void 0&&U(v)===`compare`),ee=bs(()=>U(S)?U(x):void 0),te=M(()=>!_.current||U(S)&&U(x)!==void 0&&!ee.current);function ne(e){U(b)?(F(b,!1),e!==U(i)&&F(y,e,!0)):(F(i,e,!0),F(y,void 0))}function re(e){e.key===`Escape`&&F(b,!1)}let ie=P(void 0),ae=M(()=>U(ie)?.filter(({id:e})=>n.has(e))),oe=M(()=>U(ae)&&new Set(U(ae).map(({id:e})=>e))),se=M(()=>U(ae)&&gs(U(ae))),ce=M(()=>[...n.values()].filter(e=>Ho(e)===`done`).length);pn(()=>{let e=U(r);if(U(ce),!e){F(ie,void 0);return}let t=!1,n=setTimeout(async()=>{try{let n=await fetch(`/api/requests?${new URLSearchParams({q:e})}`);if(!n.ok)return;let r=await n.json();t||F(ie,r)}catch(e){console.error(`Failed to search requests:`,e)}},250);return()=>{t=!0,clearTimeout(n)}});let le=M(()=>U(l).flatMap(e=>{let t=U(se)?.get(e)??0;return e!==U(d)&&t>0?[[e,t]]:[]})),ue=P(!1),de=M(()=>[...n.values()].filter(e=>zo(e,{project:U(d),matches:U(r)?U(oe):void 0})).sort(Go)),fe=M(()=>U(ue)?Bo(U(de)):U(de)),pe=P(Wt(Date.now())),me=M(()=>cs(U(pe))),he=new bi;pn(()=>{let e=setInterval(()=>{let e=Date.now(),t=cs(U(pe));cs(e)!==t&&!he.has(t)&&he.set(t,!0),F(pe,e,!0)},6e4);return()=>clearInterval(e)});let ge=M(()=>ps(U(fe))),_e=e=>!!U(r)||U(ue)||(he.get(e)??e===U(me)),C=P(void 0),ve=M(()=>U(C)!==void 0&&!U(r)),ye=P(Wt(Date.now()));pn(()=>{if(!U(ve))return;F(ye,Date.now(),!0);let e=setInterval(()=>F(ye,Date.now(),!0),5e3);return()=>clearInterval(e)});let be=e=>e===U(me)&&!U(r)&&_e(e),xe=e=>U(ve)&&U(C)!==void 0&&e.key===U(me)?fs(e.calls,U(C),U(ye)):e.calls,w=M(()=>U(ge).flatMap(xe)),Se=M(()=>xs(Si(U(w)))),T=M(()=>Vo(ps(U(de)).flatMap(xe)));yi(()=>{let e,t;function r(){e=new EventSource(`/events`),e.onopen=()=>{F(a,!0),n.clear(),c()},e.onmessage=e=>{let t=JSON.parse(e.data);n.set(t.id,t)},e.addEventListener(`clear`,e=>{let{project:t}=JSON.parse(e.data);we(typeof t==`string`?t:void 0)}),e.addEventListener(`delete`,e=>{let{id:t}=JSON.parse(e.data);typeof t==`string`&&E(t)}),e.onerror=()=>{F(a,!1),e?.readyState===EventSource.CLOSED&&(t=setTimeout(r,3e3))}}return r(),()=>{clearTimeout(t),e?.close()}});function E(e){n.delete(e),U(i)===e&&(F(i,void 0),F(b,!1)),U(y)===e&&F(y,void 0)}async function Ce(e){try{let t=await fetch(`/api/requests/${e}`,{method:`DELETE`});(t.ok||t.status===404)&&E(e)}catch(e){console.error(`Failed to delete request:`,e)}}function we(e){for(let t of[...n.values()])(e===void 0||t.project===e)&&E(t.id)}async function Te(){let e=U(d);try{await fetch(`/api/clear?project=${encodeURIComponent(e)}`,{method:`POST`}),we(e)}catch(e){console.error(`Failed to clear requests:`,e)}}var Ee=wc();fr(`keydown`,qt,re);var De=L(Ee);yc(De,{get connected(){return U(a)},get address(){return U(o)},get version(){return U(s)},onclear:Te,get search(){return U(r)},set search(e){F(r,e,!0)}});var Oe=z(De,2);{let e=M(()=>U(r)?U(se):void 0);Es(Oe,{get projects(){return U(l)},get current(){return U(d)},unseen:m,get matches(){return U(e)},onchoose:h})}var ke=z(Oe,2);{let e=M(()=>U(w).length>0);Gs(ke,{get shown(){return U(e)},get cards(){return U(Se)}})}var Ae=z(ke,2),je=I(Ae);let Me;var Ne=I(je),Pe=e=>{var t=bc(),n=z(I(t));D(t),W(`click`,n,()=>F(b,!1)),J(e,t)};X(Ne,e=>{U(b)&&e(Pe)});var Fe=z(Ne,2);ss(Fe,{get pressed(){return U(ue)},get count(){return U(T)},ontoggle:()=>F(ue,!U(ue))}),Z(z(Fe,2),17,()=>U(ge),e=>e.key,(e,t)=>{let n=M(()=>_e(U(t).key)),r=M(()=>xe(U(t)));var a=xc(),o=I(a);{let e=M(()=>us(U(t).key,U(pe)));Ei(o,{get label(){return U(e)},get count(){return U(r).length},get total(){return U(t).calls.length},get open(){return U(n)},ontoggle:()=>he.set(U(t).key,!U(n))})}var s=z(o,2);{let e=M(()=>be(U(t).key));As(s,{get shown(){return U(e)},get minutes(){return U(C)},get count(){return U(r).length},onchoose:e=>F(C,e,!0)})}var c=z(s,2),l=e=>{var t=q();Z(L(t),17,()=>U(r),e=>e.id,(e,t)=>{{let n=M(()=>U(t).id===U(i)),r=M(()=>U(S)&&U(t).id===U(x)?.id);Vs(e,{get request(){return U(t)},get selected(){return U(n)},get comparing(){return U(S)},get compared(){return U(r)},onselect:()=>ne(U(t).id),ondelete:()=>Ce(U(t).id)})}}),J(e,t)};X(c,e=>{U(n)&&e(l)}),D(a),J(e,a)},e=>{as(e,{get project(){return U(d)},get search(){return U(r)},get failedOnly(){return U(ue)},get elsewhere(){return U(le)},onchoose:h})}),D(je);var Ie=z(je,2),Le=I(Ie),Re=e=>{J(e,Sc())},ze=e=>{ts(e,{get request(){return _.current},get other(){return ee.current},get picking(){return U(b)},onpick:()=>F(b,!U(b)),get chosen(){return U(v)},set chosen(e){F(v,e,!0)}})},Be=e=>{J(e,Cc())};X(Le,e=>{U(g)&&U(te)?e(Re):_.current?e(ze,1):e(Be,-1)}),D(Ie),D(Ae),B(()=>Me=Q(je,1,`list`,null,Me,{picking:U(b)})),J(e,Ee),A()}G([`click`]);var Ec=document.getElementById(`app`);if(!Ec)throw Error(`#app element not found in index.html`);Dr(Tc,{target:Ec});
|
package/ui/dist/index.html
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
if (theme === 'light' || theme === 'dark') document.documentElement.dataset.theme = theme;
|
|
13
13
|
} catch {}
|
|
14
14
|
</script>
|
|
15
|
-
<script type="module" crossorigin src="/assets/index-
|
|
15
|
+
<script type="module" crossorigin src="/assets/index-B9XIilZJ.js"></script>
|
|
16
16
|
<link rel="stylesheet" crossorigin href="/assets/index-moM-ONoJ.css">
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|