feat(webui): show attachment metadata in the session transcript
A message's attachments persist as metadata (messaging.Message.Media) and
cross the gateway wire, but the dashboard transcript rendered text only, so
a photo was invisible to the operator while the model had seen it.
The transcript view now carries the persisted metadata, and the browser
labels each attachment in the placeholder vocabulary the channels already
write into a message's text ('[photo]', '[document: report.pdf]'), with the
surviving metadata (mime, name, size, dimensions, duration) in the chip's
tooltip.
Bytes are never rendered: they are turn-scoped and stripped before a record
is stored, so there is nothing to fetch and no broken image or 404 link. The
platform file id is deliberately not served either -- it is a download
handle, not an address -- so the chip links out only when the attachment
itself carried a URL. A message with no attachments omits the media key, so
transcripts written before this change keep the payload they had.
This commit is contained in:
1 parent
d60fcad18f
commit
a7efb9bb00
9 files changed
+354
-13
No files matched your search
@@ -56,6 +56,50 @@ type chatMessageView struct {
|
||||
From string
|
||||
Text string
|
||||
At time.Time
|
||||
// Tagged, alone among these fields: a transcript written before
|
||||
// attachments persisted must keep the payload it has always had, so a
|
||||
// message with no media omits the key rather than serving null.
|
||||
Media []chatMediaView `json:"media,omitempty"`
|
||||
}
|
||||
|
||||
// chatMediaView is one attachment a message carried, as the dashboard reads
|
||||
// it. The bytes are turn-scoped and are gone before a record is stored, so
|
||||
// this view carries only what survived persistence, and FileID is left out on
|
||||
// purpose: it is the platform's download handle, not an address, so handing
|
||||
// it to a browser only invites a fetch that cannot work. URL is present
|
||||
// exactly when the attachment itself carried one.
|
||||
type chatMediaView struct {
|
||||
Type string `json:"type"`
|
||||
FileName string `json:"file_name,omitempty"`
|
||||
MIMEType string `json:"mime_type,omitempty"`
|
||||
FileSize *int64 `json:"file_size,omitempty"`
|
||||
Width *int `json:"width,omitempty"`
|
||||
Height *int `json:"height,omitempty"`
|
||||
Duration *int `json:"duration,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// chatMediaViews maps a message's stored attachments onto the transcript
|
||||
// view, keeping the descriptive fields a reader needs to know a file was
|
||||
// there.
|
||||
func chatMediaViews(media []messaging.MediaAttachment) []chatMediaView {
|
||||
if len(media) == 0 {
|
||||
return nil
|
||||
}
|
||||
views := make([]chatMediaView, 0, len(media))
|
||||
for _, attachment := range media {
|
||||
views = append(views, chatMediaView{
|
||||
Type: attachment.Type,
|
||||
FileName: attachment.FileName,
|
||||
MIMEType: attachment.MIMEType,
|
||||
FileSize: attachment.FileSize,
|
||||
Width: attachment.Width,
|
||||
Height: attachment.Height,
|
||||
Duration: attachment.Duration,
|
||||
URL: attachment.URL,
|
||||
})
|
||||
}
|
||||
return views
|
||||
}
|
||||
|
||||
type chatPersonaRequest struct {
|
||||
@@ -189,6 +233,7 @@ func (s *Server) handleChatMessages(w http.ResponseWriter, r *http.Request) {
|
||||
views = append(views, chatMessageView{
|
||||
MessageID: string(message.ID), SourceID: message.SourceID,
|
||||
From: message.Sender, Text: message.Text, At: message.At,
|
||||
Media: chatMediaViews(message.Media),
|
||||
})
|
||||
}
|
||||
writeJSON(w, views)
|
||||
|
||||
@@ -509,6 +509,113 @@ func TestChatSessionsFiltersNonWeb(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// chatMediaWire is the attachment block a transcript message carries, spelled
|
||||
// out here rather than reusing the handler's own type: the response's field
|
||||
// names are the contract, so renaming one has to break this test rather than
|
||||
// be silently decoded away.
|
||||
type chatMediaWire struct {
|
||||
Type string `json:"type"`
|
||||
FileName string `json:"file_name"`
|
||||
MIMEType string `json:"mime_type"`
|
||||
FileSize *int64 `json:"file_size"`
|
||||
Width *int `json:"width"`
|
||||
Height *int `json:"height"`
|
||||
Duration *int `json:"duration"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
// oneTranscriptMessage serves the single-message transcript the attachment
|
||||
// tests below build, keeping each message's raw keys so a field the handler
|
||||
// invents -- or omits -- is visible here.
|
||||
func oneTranscriptMessage(t *testing.T, server *Server, sessionID string) map[string]json.RawMessage {
|
||||
t.Helper()
|
||||
res := httptest.NewRecorder()
|
||||
server.Handler().ServeHTTP(res, httptest.NewRequestWithContext(context.Background(), http.MethodGet, "/api/chat/sessions/"+sessionID+"/messages", nil))
|
||||
if res.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d, body = %s", res.Code, res.Body)
|
||||
}
|
||||
var messages []map[string]json.RawMessage
|
||||
if err := json.Unmarshal(res.Body.Bytes(), &messages); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(messages) != 1 {
|
||||
t.Fatalf("transcript = %#v, want the one saved message", messages)
|
||||
}
|
||||
return messages[0]
|
||||
}
|
||||
|
||||
// A message's attachments reach the transcript as metadata and nothing else.
|
||||
// The bytes are turn-scoped by design and are stripped at the persist
|
||||
// boundary, and the platform's file id is a download handle rather than an
|
||||
// address -- so the view carries the descriptive fields, and a URL only when
|
||||
// the attachment itself had one.
|
||||
func TestChatMessagesServeAttachmentMetadataNotDownloadHandles(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
save := func(t *testing.T, msg messaging.Message) map[string]json.RawMessage {
|
||||
t.Helper()
|
||||
server, sessions := chatTestServer(t)
|
||||
saveWebSession(t, sessions, "web-1")
|
||||
if err := sessions.SaveMessage(context.Background(), "web-1", msg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return oneTranscriptMessage(t, server, "web-1")
|
||||
}
|
||||
|
||||
t.Run("an inbound attachment keeps its metadata and loses its handle and bytes", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
record := save(t, messaging.Message{
|
||||
SourceID: "42",
|
||||
Sender: "sam",
|
||||
Text: "[photo]\nwhat is this?",
|
||||
At: time.Now().UTC(),
|
||||
Media: []messaging.MediaAttachment{{
|
||||
Type: "image", FileID: "AgAD-file-handle", MIMEType: "image/jpeg",
|
||||
FileSize: new(int64(2024)), Width: new(int(1280)), Height: new(int(960)),
|
||||
Data: []byte{0xff, 0xd8, 0xff, 0xe0},
|
||||
}},
|
||||
})
|
||||
want := `[{"type":"image","mime_type":"image/jpeg","file_size":2024,"width":1280,"height":960}]`
|
||||
if got := string(record["media"]); got != want {
|
||||
t.Fatalf("media = %s, want %s", got, want)
|
||||
}
|
||||
var media []chatMediaWire
|
||||
if err := json.Unmarshal(record["media"], &media); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(media) != 1 || media[0].FileName != "" || media[0].URL != "" {
|
||||
t.Fatalf("media = %+v, want one attachment with no name and no URL", media)
|
||||
}
|
||||
for _, forbidden := range []string{"file_id", "data"} {
|
||||
if _, ok := record[forbidden]; ok {
|
||||
t.Errorf("transcript message carries %q", forbidden)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("an attachment that genuinely has a URL keeps it", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
record := save(t, messaging.Message{
|
||||
SourceID: "43",
|
||||
Sender: "archie",
|
||||
At: time.Now().UTC(),
|
||||
Media: []messaging.MediaAttachment{{Type: "video", URL: "https://example.com/v.mp4", Duration: new(int(12))}},
|
||||
})
|
||||
want := `[{"type":"video","duration":12,"url":"https://example.com/v.mp4"}]`
|
||||
if got := string(record["media"]); got != want {
|
||||
t.Fatalf("media = %s, want %s", got, want)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("a message with no attachments is served exactly as before", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
record := save(t, messaging.Message{SourceID: "44", Sender: "web", Text: "hello", At: time.Now().UTC()})
|
||||
if raw, ok := record["media"]; ok {
|
||||
t.Fatalf("a text-only message grew a media field: %s", raw)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// chatSSEEvent is one parsed `data: {...}` frame from the stream endpoint.
|
||||
type chatSSEEvent struct {
|
||||
Type string `json:"type"`
|
||||
|
||||
Vendored
+11
-11
@@ -1,20 +1,20 @@
|
||||
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function n(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var r={},i=[],a=()=>{},o=()=>!1,s=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),c=e=>e.startsWith(`onUpdate:`),l=Object.assign,u=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},d=Object.prototype.hasOwnProperty,f=(e,t)=>d.call(e,t),p=Array.isArray,m=e=>C(e)===`[object Map]`,h=e=>C(e)===`[object Set]`,g=e=>C(e)===`[object Date]`,_=e=>C(e)===`[object RegExp]`,v=e=>typeof e==`function`,y=e=>typeof e==`string`,b=e=>typeof e==`symbol`,x=e=>typeof e==`object`&&!!e,ee=e=>(x(e)||v(e))&&v(e.then)&&v(e.catch),S=Object.prototype.toString,C=e=>S.call(e),te=e=>C(e).slice(8,-1),ne=e=>C(e)===`[object Object]`,re=e=>y(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,ie=n(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),ae=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},oe=/-\w/g,se=ae(e=>e.replace(oe,e=>e.slice(1).toUpperCase())),ce=/\B([A-Z])/g,le=ae(e=>e.replace(ce,`-$1`).toLowerCase()),ue=ae(e=>e.charAt(0).toUpperCase()+e.slice(1)),de=ae(e=>e?`on${ue(e)}`:``),w=(e,t)=>!Object.is(e,t),fe=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},pe=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},me=e=>{let t=parseFloat(e);return isNaN(t)?e:t},he=e=>{let t=y(e)?Number(e):NaN;return isNaN(t)?e:t},ge,_e=()=>ge||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{},ve=n(`Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol`);function ye(e){if(p(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=y(r)?Ce(r):ye(r);if(i)for(let e in i)t[e]=i[e]}return t}if(y(e)||x(e))return e}var be=/;(?![^(]*\))/g,xe=/:([^]+)/,Se=/"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;function Ce(e){let t={};return e.replace(Se,e=>e.startsWith(`/*`)?``:e).split(be).forEach(e=>{if(e){let n=e.split(xe);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function T(e){let t=``;if(y(e))t=e;else if(p(e))for(let n=0;n<e.length;n++){let r=T(e[n]);r&&(t+=r+` `)}else if(x(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}function we(e){if(!e)return null;let{class:t,style:n}=e;return t&&!y(t)&&(e.class=T(t)),n&&(e.style=ye(n)),e}var Te=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`,Ee=n(Te);Te+``;function De(e){return!!e||e===``}function Oe(e,t,n){if(e.length!==t.length)return!1;let r=!0;for(let i=0;r&&i<e.length;i++)r=Me(e[i],t[i],n);return r}function ke(e,t,n){if(e.size!==t.size)return!1;let r=Array.from(t),i=new Uint8Array(r.length);for(let t of e){let e=-1;for(let a=0;a<r.length;a++)if(!i[a]&&Me(t,r[a],n)){e=a;break}if(e<0)return!1;i[e]=1}return!0}function Ae(e,t,n){let r=m(e),i=m(t);if(r||i||(r=h(e),i=h(t),r||i))return r&&i?ke(e,t,n):!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e){let i=e.hasOwnProperty(r),a=t.hasOwnProperty(r);if(i&&!a||!i&&a||!Me(e[r],t[r],n))return!1}return String(e)===String(t)}function je(e,t,n,r){n||=[new Map,new Map];let[i,a]=n;if(i.has(e)||a.has(t))return i.get(e)===t&&a.get(t)===e;i.set(e,t),a.set(t,e);let o=r(e,t,n);return i.delete(e),a.delete(t),o}function Me(e,t,n){if(e===t)return!0;let r=g(e),i=g(t);return r||i?r&&i?e.getTime()===t.getTime():!1:(r=b(e),i=b(t),r||i?e===t:(r=p(e),i=p(t),r||i?r&&i?je(e,t,n,Oe):!1:(r=x(e),i=x(t),r||i?!r||!i?!1:je(e,t,n,Ae):String(e)===String(t))))}function Ne(e,t){return e.findIndex(e=>Me(e,t))}var Pe=e=>!!(e&&e.__v_isRef===!0),E=e=>y(e)?e:e==null?``:p(e)||x(e)&&(e.toString===S||!v(e.toString))?Pe(e)?E(e.value):JSON.stringify(e,Fe,2):String(e),Fe=(e,t)=>Pe(t)?Fe(e,t.value):m(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[Ie(t,r)+` =>`]=n,e),{})}:h(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>Ie(e))}:b(t)?Ie(t):x(t)&&!p(t)&&!ne(t)?String(t):t,Ie=(e,t=``)=>b(e)?`Symbol(${e.description??t})`:e;function Le(e){return e==null?`initial`:tLine truncated
|
||||
`&&(e.tagName===`PRE`||e.tagName===`TEXTAREA`)&&(n=n.slice(1));let{textContent:r}=e;r!==n&&r!==n.replace(/\r\n|\r/g,`
|
||||
`)&&(Ai(e,0)||bi(),e.textContent=t.children)}if(d){if(_||b||!o||f&48){let t=e.tagName.includes(`-`),i=e.namespaceURI.includes(`svg`)?`svg`:e.namespaceURI.includes(`MathML`)?`mathml`:void 0;for(let a in d)if(_&&(a.endsWith(`value`)||a===`indeterminate`)||s(a)&&!ie(a)||a[0]===`.`||t&&!ie(a)||u&&u.includes(a)){if(Di(e,a,d[a]))continue;r(e,a,null,d[a],i,n)}}else if(d.onClick)r(e,`onClick`,null,d.onClick,void 0,n);else if(f&4&&ln(d.style))for(let e in d.style)d.style[e]}let x;(x=d&&d.onVnodeBeforeMount)&&Ps(x,n,t),h&&Tr(t,null,n,`beforeMount`),((x=d&&d.onVnodeMounted)||h||l)&&us(()=>{x&&Ps(x,n,t),l&&g.enter(e),h&&Tr(t,null,n,`mounted`)},i)}return e.nextSibling},m=(e,t,r,o,s,c,u)=>{u||=!!t.dynamicChildren;let d=t.children,p=d.length,m=!1;for(let t=0;t<p;t++){let h=u?d[t]:d[t]=js(d[t]),g=h.type===ps;e?(g&&!u&&t+1<p&&js(d[t+1]).type===ps&&(l(i(e.data.slice(h.children.length)),r,a(e)),e.data=h.children),e=f(e,h,o,s,c,u)):g&&!h.children?l(h.el=i(``),r):(m||(m=!0,Ai(r,1)||bi()),n(null,h,r,null,o,s,Ci(r),c))}return e},h=(e,t,n,r,i,s)=>{let{slotScopeIds:c}=t;c&&(i=i?i.concat(c):c);let d=o(e),f=m(a(e),t,d,n,r,i,s);return f&&wi(f)&&f.data===`]`?a(t.anchor=f):(bi(),l(t.anchor=u(`]`),d,f),f)},g=(e,t,r,i,s,l)=>{if(Mi(e,t)||bi(),t.el=null,l){let t=_(e);for(;;){let n=a(e);if(n&&n!==t)c(n);else break}}let u=a(e),d=o(e);return c(e),n(null,t,d,u,r,i,Ci(d),s),r&&(r.vnode.el=t.el,Co(r,t.el)),u},_=(e,t=`[`,n=`]`)=>{let r=0;for(;e;)if(e=a(e),e&&wi(e)&&(e.data===t&&r++,e.data===n)){if(r===0)return a(e);r--}return e},v=(e,t,n)=>{let r=t.parentNode;r&&r.replaceChild(e,t);let i=n;for(;i;)i.vnode.el===t&&(i.vnode.el=i.subTree.el=e),i=i.parent},y=e=>e.nodeType===1&&e.tagName===`TEMPLATE`;return[d,f]}var Ei=new Set([`src`,`srcset`,`href`,`poster`]);function Di(e,t,n){return Ei.has(t)?e.getAttribute(t)===(n==null?null:`${n}`):!1}var Oi=`data-allow-mismatch`,ki={0:`text`,1:`children`,2:`class`,3:`style`,4:`attribute`};function Ai(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(Oi);)e=e.parentElement;return ji(e&&e.getAttribute(Oi),t)}function ji(e,t){if(e==null)return!1;if(e===``)return!0;{let n=e.split(`,`);return t===0&&n.includes(`children`)?!0:n.includes(ki[t])}}function Mi(e,t){return Ai(e.parentElement,1)||Ni(e)||Pi(t)}function Ni(e){return e.nodeType===1&&ji(e.getAttribute(Oi),1)}function Pi({props:e}){let t=e&&e[Oi];return typeof t==`string`&&ji(t,1)}var Fi=_e().requestIdleCallback||(e=>setTimeout(e,1)),Ii=_e().cancelIdleCallback||(e=>clearTimeout(e)),Li=(e=1e4)=>t=>{let n=Fi(t,{timeout:e});return()=>Ii(n)};function Ri(e){let{top:t,left:n,bottom:r,right:i}=e.getBoundingClientRect(),{innerHeight:a,innerWidth:o}=window;return(t>0&&t<a||r>0&&r<a)&&(n>0&&n<o||i>0&&i<o)}var zi=e=>(t,n)=>{let r=new IntersectionObserver(e=>{for(let n of e)if(n.isIntersecting){r.disconnect(),t();break}},e);return n(e=>{if(e instanceof Element){if(Ri(e))return t(),r.disconnect(),!1;r.observe(e)}}),()=>r.disconnect()},Bi=e=>t=>{if(e){let n=matchMedia(e);if(n.matches)t();else return n.addEventListener(`change`,t,{once:!0}),()=>n.removeEventListener(`change`,t)}},Vi=(e=[])=>(t,n)=>{y(e)&&(e=[e]);let r=!1,i=e=>{r||(r=!0,a(),t(),e.target.dispatchEvent(new e.constructor(e.type,e)))},a=()=>{n(t=>{for(let n of e)t.removeEventListener(n,i)})};return n(t=>{for(let n of e)t.addEventListener(n,i,{once:!0})}),a};function Hi(e,t){if(wi(e)&&e.data===`[`){let n=1,r=e.nextSibling;for(;r;){if(r.nodeType===1){if(t(r)===!1)break}else if(wi(r)){if(r.data===`]`){if(--n===0)break}else r.data===`[`&&n++}r=r.nextSibling}}else t(e)}var Ui=e=>!!e.type.__asyncLoader;function Wi(e){v(e)&&(e={loader:e});let{loader:t,loadingComponent:n,errorComponent:r,delay:i=200,hydrate:a,timeout:o,suspensible:s=!0,onError:c}=e,l=null,u,d=0,f=()=>(d++,l=null,p()),p=()=>{let e;return l||(e=l=t().catch(e=>{if(e=e instanceof Error?e:Error(String(e)),c)return new Promise((t,n)=>{c(e,()=>t(f()),()=>n(e),d+1)});throw e}).then(t=>e!==l&&l?l:(t&&(t.__esModule||t[Symbol.toStringTag]===`Module`)&&(t=t.default),u=t,t)))};return j({name:`AsyncComponentWrapper`,__asyncLoader:p,__asyncHydrate(e,t,n){let r=e.isConnected,i=!1;(t.bu||=[]).push(()=>i=!0);let o=()=>{i||!e.parentNode||r&&!e.isConnected||n()},s=a?()=>{let n=a(o,t=>Hi(e,t));n&&(t.bum||=[]).push(n)}:o;u?s():p().then(()=>!t.isUnmounted&&s())},get __asyncResolved(){return u},setup(){let e=Rs;if(pi(e),u)return()=>Gi(u,e);let t=t=>{l=null,Zn(t,e,13,!r)};if(s&&e.suspense||Gs)return p().then(t=>()=>Gi(t,e)).catch(e=>(t(e),()=>r?z(r,{error:e}):null));let a=D(!1),c=D(),d=D(!!i),f,m;return ca(()=>{f!=null&&clearTimeout(f),m!=null&&clearTimeout(m)}),i&&(m=setTimeout(()=>{e.isUnmounted||(d.value=!1)},i)),o!=null&&(f=setTimeout(()=>{if(!e.isUnmounted&&!a.value&&!c.value){let e=Error(`Async component timed out after ${o}ms.`);t(e),c.value=e}},o)),p().then(()=>{e.isUnmounted||(a.value=!0,e.parent&&Ki(e.parent.vnode)&&e.parent.update())}).catch(n=>{if(e.isUnmounted){l=null;return}t(n),c.value=n}),()=>{if(a.value&&u)return Gi(u,e);if(c.value&&r)return z(r,{error:c.value});if(n&&
Line truncated
|
||||
`))),e[Kl]=Ul(i);let a=r||i.props&&i.props.type===`number`;ul(e,t?`change`:`input`,t=>{t.target.composing||e[Kl](Jl(e.value,n,a))}),(n||a)&&ul(e,`change`,()=>{e.value=Jl(e.value,n,a)}),t||(ul(e,`compositionstart`,Wl),ul(e,`compositionend`,Gl),ul(e,`change`,Gl))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[ql];delete e[ql],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[Kl](Jl(e.value,n,r)):e.value=i},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Kl]=Ul(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?me(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},Xl={deep:!0,created(e,t,n){e[Kl]=Ul(n),ul(e,`change`,()=>{let t=e._modelValue,n=nu(e),r=e.checked,i=e[Kl];if(p(t)){let e=Ne(t,n),a=e!==-1;if(r&&!a)i(t.concat(n));else if(!r&&a){let n=[...t];n.splice(e,1),i(n)}}else if(h(t)){let e=new Set(t);r?e.add(n):e.delete(n),i(e)}else i(ru(e,r))})},mounted:Zl,beforeUpdate(e,t,n){e[Kl]=Ul(n),Zl(e,t,n)}};function Zl(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(p(t))i=Ne(t,r.props.value)>-1;else if(h(t))i=t.has(r.props.value);else{if(t===n)return;i=Me(t,ru(e,!0))}e.checked!==i&&(e.checked=i)}var Ql={created(e,{value:t},n){e.checked=Me(t,n.props.value),e[Kl]=Ul(n),ul(e,`change`,()=>{e[Kl](nu(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[Kl]=Ul(r),t!==n&&(e.checked=Me(t,r.props.value))}},$l={deep:!0,created(e,{value:t,modifiers:{number:n}},r){e._modelValue=t,ul(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?me(nu(e)):nu(e)),r=e.multiple,i=r?h(e._modelValue)?new Set(t):t:t[0],a=e._pendingValue=[r,r?p(i)?t.slice():t:i];try{e[Kl](i)}finally{or(()=>{e._pendingValue===a&&(e._pendingValue=void 0)})}}),e[Kl]=Ul(r)},mounted(e,{value:t}){tu(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[Kl]=Ul(n)},updated(e,{value:t}){let n=e._pendingValue;e._pendingValue=void 0,(!n||n[0]!==e.multiple||!eu(t,n[1],n[0]))&&tu(e,t)}};function eu(e,t,n){if(!n||p(e))return Me(e,t);if(h(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function tu(e,t){let n=e.multiple,r=p(t);if(!n||r||h(t)){for(let i=0,a=e.options.length;i<a;i++){let a=e.options[i],o=nu(a);if(n){if(r){let e=typeof o;a.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(o)):Ne(t,o)>-1}else a.selected=t.has(o)}else if(Me(nu(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function nu(e){return`_value`in e?e._value:e.value}function ru(e,t){let n=t?`_trueValue`:`_falseValue`;return n in e?e[n]:t}var iu={created(e,t,n){ou(e,t,n,null,`created`)},mounted(e,t,n){ou(e,t,n,null,`mounted`)},beforeUpdate(e,t,n,r){ou(e,t,n,r,`beforeUpdate`)},updated(e,t,n,r){ou(e,t,n,r,`updated`)}};function au(e,t){switch(e){case`SELECT`:return $l;case`TEXTAREA`:return Yl;default:switch(t){case`checkbox`:return Xl;case`radio`:return Ql;default:return Yl}}}function ou(e,t,n,r,i){let a=au(e.tagName,n.props&&n.props.type)[i];a&&a(e,t,n,r)}function su(){Yl.getSSRProps=({value:e})=>({value:e}),Ql.getSSRProps=({value:e},t)=>{if(t.props&&Me(t.props.value,e))return{checked:!0}},Xl.getSSRProps=({value:e},t)=>{if(p(e)){if(t.props&&Ne(e,t.props.value)>-1)return{checked:!0}}else if(h(e)){if(t.props&&e.has(t.props.value))return{checked:!0}}else if(e)return{checked:!0}},iu.getSSRProps=(e,t)=>{if(typeof t.type!=`string`)return;let n=au(t.type.toUpperCase(),t.props&&t.props.type);if(n.getSSRProps)return n.getSSRProps(e,t)}}var cu=[`ctrl`,`shift`,`alt`,`meta`],lu={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>cu.some(n=>e[`${n}Key`]&&!t.includes(n))},uu=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=lu[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},du={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},fu=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=le(n.key);if(t.some(e=>e===r||du[e]===r))return e(n)}))},pu=l({patchProp:Sl},Sc),mu,hu=!1;function gu(){return mu||=Uo(pu)}function _u(){return mu=hu?mu:Wo(pu),hu=!0,mu}var vu=((...e)=>{gu().render(...e)}),yu=((...e)=>{_u().hydrate(...e)}),bu=((...e)=>{let t=gu().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=Cu(e);if(!r)return;let i=t._component;!v(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,Su(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t}),xu=((
Line truncated
|
||||
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Kp;function qp(e){Kp=e}var Jp=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function Yp(e){let t=e instanceof Jp?e.status:void 0,n=e instanceof Error&&e.message?e.message:`Action failed`;return t===401?{kind:`session-expired`,message:n}:t!==void 0&&t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Xp(e,t){let n=await fetch(e,t);if(Kp?.(n.status===401),!n.ok)throw new Jp(await Gp(n),n.status);return n}async function Zp(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=Up,parse:a=!0}=t,o={Accept:`application/json`},s={method:n,headers:o,signal:AbortSignal.timeout(i)};n!==`GET`&&(o[`Content-Type`]=`application/json`,o[`X-Archie-CSRF`]=`1`),r!==void 0&&(s.body=JSON.stringify(r));let c=await Xp(e,s);return a?await c.json():void 0}var q={health:()=>Zp(`/health/detailed`),summary:()=>Zp(`/api/summary`),tasks:()=>Zp(`/api/tasks`),taskMeta:()=>Zp(`/api/task-meta`),task:e=>Zp(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>Zp(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>Zp(`/api/tasks/${encodeURIComponent(e)}/changes`+Wp(t)),taskDebug:(e,t)=>Zp(`/api/tasks/${encodeURIComponent(e)}/debug`+Wp(t)),taskAction:(e,t)=>Zp(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t}}),setup:()=>Zp(`/api/setup`),capabilities:()=>Zp(`/api/capabilities`),workflows:()=>Zp(`/api/workflows`),workflowEnabled:(e,t)=>Zp(`/api/workflows/${encodeURIComponent(e)}/enabled`,{method:`PUT`,body:{enabled:t},parse:!1}),workRequest:e=>Zp(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>Zp(`/api/skills`),channels:()=>Zp(`/api/channels`),curators:()=>Zp(`/api/curators`),channelReload:e=>Zp(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>Zp(`/api/config`),logs:e=>Zp(`/api/logs`+Wp(e)),taskLogs:(e,t)=>Zp(`/api/tasks/${encodeURIComponent(e)}/logs`+Wp(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),version:()=>Zp(`/api/version`),updateSnapshot:()=>Zp(`/api/chat/update`),updateInstall:e=>Zp(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:9e5}),captures:e=>Zp(`/api/captures`+Wp({limit:e})),eventTypes:()=>Zp(`/api/event-types`),eventTypeCreate:e=>Zp(`/api/event-types`,{method:`POST`,body:e}),eventTypeUpdate:(e,t)=>Zp(`/api/event-types/${encodeURIComponent(e)}`,{method:`PUT`,body:t}),eventTypeDelete:e=>Zp(`/api/event-types/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappings:()=>Zp(`/api/mappings`),mappingCreate:e=>Zp(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>Zp(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>Zp(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>Zp(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>Zp(`/api/bindings`),bindingCreate:e=>Zp(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>Zp(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>Zp(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>Zp(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),sources:()=>Zp(`/api/sources`),sourceCreate:e=>Zp(`/api/sources`,{method:`POST`,body:{path:e}}),sourceSigning:(e,t)=>Zp(`/api/sources/${encodeURIComponent(e)}/signing`,{method:`POST`,body:{signed:t}}),sourceApproveUnsigned:e=>Zp(`/api/sources/${encodeURIComponent(e)}/approve-unsigned`,{method:`POST`}),sourceSecret:e=>Zp(`/api/sources/${encodeURIComponent(e)}/secret`,{method:`POST`}),chatSessions:()=>Zp(`/api/chat/sessions`),chatMessages:e=>Zp(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>Zp(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>Zp(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>Zp(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:Hp(),text:t,page:location.pathname+location.search||`/`}}),chatPersona:(e,t)=>Zp(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatDangerous:()=>Zp(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>Zp(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>Zp(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,t={})=>Xp(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t.signal})};function Qp(e,t,n=``,r=!1){let i=new EventSource(Vp(n,r));return i.onopen=()=>t(`live`),i.onerror=()=>t(zp(i.readyState)),i.onmessage=t=>{try{e(JSON.parse(t.data),t.lastEventId)}catch{}},()=>i.close()}var $p=`archie.web.chat.channel`;function em(){let e=localStorage.getItem($p);return e||(e=Hp(),localStorage.setItem($p,e)),e}var tm=/(?:^|\s)\/([^\sLine truncated
|
||||
`))),e[Kl]=Ul(i);let a=r||i.props&&i.props.type===`number`;ul(e,t?`change`:`input`,t=>{t.target.composing||e[Kl](Jl(e.value,n,a))}),(n||a)&&ul(e,`change`,()=>{e.value=Jl(e.value,n,a)}),t||(ul(e,`compositionstart`,Wl),ul(e,`compositionend`,Gl),ul(e,`change`,Gl))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[ql];delete e[ql],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[Kl](Jl(e.value,n,r)):e.value=i},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Kl]=Ul(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?me(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},Xl={deep:!0,created(e,t,n){e[Kl]=Ul(n),ul(e,`change`,()=>{let t=e._modelValue,n=nu(e),r=e.checked,i=e[Kl];if(p(t)){let e=Ne(t,n),a=e!==-1;if(r&&!a)i(t.concat(n));else if(!r&&a){let n=[...t];n.splice(e,1),i(n)}}else if(h(t)){let e=new Set(t);r?e.add(n):e.delete(n),i(e)}else i(ru(e,r))})},mounted:Zl,beforeUpdate(e,t,n){e[Kl]=Ul(n),Zl(e,t,n)}};function Zl(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(p(t))i=Ne(t,r.props.value)>-1;else if(h(t))i=t.has(r.props.value);else{if(t===n)return;i=Me(t,ru(e,!0))}e.checked!==i&&(e.checked=i)}var Ql={created(e,{value:t},n){e.checked=Me(t,n.props.value),e[Kl]=Ul(n),ul(e,`change`,()=>{e[Kl](nu(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[Kl]=Ul(r),t!==n&&(e.checked=Me(t,r.props.value))}},$l={deep:!0,created(e,{value:t,modifiers:{number:n}},r){e._modelValue=t,ul(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?me(nu(e)):nu(e)),r=e.multiple,i=r?h(e._modelValue)?new Set(t):t:t[0],a=e._pendingValue=[r,r?p(i)?t.slice():t:i];try{e[Kl](i)}finally{or(()=>{e._pendingValue===a&&(e._pendingValue=void 0)})}}),e[Kl]=Ul(r)},mounted(e,{value:t}){tu(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[Kl]=Ul(n)},updated(e,{value:t}){let n=e._pendingValue;e._pendingValue=void 0,(!n||n[0]!==e.multiple||!eu(t,n[1],n[0]))&&tu(e,t)}};function eu(e,t,n){if(!n||p(e))return Me(e,t);if(h(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function tu(e,t){let n=e.multiple,r=p(t);if(!n||r||h(t)){for(let i=0,a=e.options.length;i<a;i++){let a=e.options[i],o=nu(a);if(n){if(r){let e=typeof o;a.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(o)):Ne(t,o)>-1}else a.selected=t.has(o)}else if(Me(nu(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function nu(e){return`_value`in e?e._value:e.value}function ru(e,t){let n=t?`_trueValue`:`_falseValue`;return n in e?e[n]:t}var iu={created(e,t,n){ou(e,t,n,null,`created`)},mounted(e,t,n){ou(e,t,n,null,`mounted`)},beforeUpdate(e,t,n,r){ou(e,t,n,r,`beforeUpdate`)},updated(e,t,n,r){ou(e,t,n,r,`updated`)}};function au(e,t){switch(e){case`SELECT`:return $l;case`TEXTAREA`:return Yl;default:switch(t){case`checkbox`:return Xl;case`radio`:return Ql;default:return Yl}}}function ou(e,t,n,r,i){let a=au(e.tagName,n.props&&n.props.type)[i];a&&a(e,t,n,r)}function su(){Yl.getSSRProps=({value:e})=>({value:e}),Ql.getSSRProps=({value:e},t)=>{if(t.props&&Me(t.props.value,e))return{checked:!0}},Xl.getSSRProps=({value:e},t)=>{if(p(e)){if(t.props&&Ne(e,t.props.value)>-1)return{checked:!0}}else if(h(e)){if(t.props&&e.has(t.props.value))return{checked:!0}}else if(e)return{checked:!0}},iu.getSSRProps=(e,t)=>{if(typeof t.type!=`string`)return;let n=au(t.type.toUpperCase(),t.props&&t.props.type);if(n.getSSRProps)return n.getSSRProps(e,t)}}var cu=[`ctrl`,`shift`,`alt`,`meta`],lu={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>cu.some(n=>e[`${n}Key`]&&!t.includes(n))},uu=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=lu[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},du={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},fu=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=le(n.key);if(t.some(e=>e===r||du[e]===r))return e(n)}))},pu=l({patchProp:Sl},Sc),mu,hu=!1;function gu(){return mu||=Uo(pu)}function _u(){return mu=hu?mu:Wo(pu),hu=!0,mu}var vu=((...e)=>{gu().render(...e)}),yu=((...e)=>{_u().hydrate(...e)}),bu=((...e)=>{let t=gu().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=Cu(e);if(!r)return;let i=t._component;!v(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,Su(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t}),xu=((
Line truncated
|
||||
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var qp;function Jp(e){qp=e}var Yp=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function Xp(e){let t=e instanceof Yp?e.status:void 0,n=e instanceof Error&&e.message?e.message:`Action failed`;return t===401?{kind:`session-expired`,message:n}:t!==void 0&&t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Zp(e,t){let n=await fetch(e,t);if(qp?.(n.status===401),!n.ok)throw new Yp(await Kp(n),n.status);return n}async function Qp(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=Wp,parse:a=!0}=t,o={Accept:`application/json`},s={method:n,headers:o,signal:AbortSignal.timeout(i)};n!==`GET`&&(o[`Content-Type`]=`application/json`,o[`X-Archie-CSRF`]=`1`),r!==void 0&&(s.body=JSON.stringify(r));let c=await Zp(e,s);return a?await c.json():void 0}var q={health:()=>Qp(`/health/detailed`),summary:()=>Qp(`/api/summary`),tasks:()=>Qp(`/api/tasks`),taskMeta:()=>Qp(`/api/task-meta`),task:e=>Qp(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>Qp(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>Qp(`/api/tasks/${encodeURIComponent(e)}/changes`+Gp(t)),taskDebug:(e,t)=>Qp(`/api/tasks/${encodeURIComponent(e)}/debug`+Gp(t)),taskAction:(e,t)=>Qp(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t}}),setup:()=>Qp(`/api/setup`),capabilities:()=>Qp(`/api/capabilities`),workflows:()=>Qp(`/api/workflows`),workflowEnabled:(e,t)=>Qp(`/api/workflows/${encodeURIComponent(e)}/enabled`,{method:`PUT`,body:{enabled:t},parse:!1}),workRequest:e=>Qp(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>Qp(`/api/skills`),channels:()=>Qp(`/api/channels`),curators:()=>Qp(`/api/curators`),channelReload:e=>Qp(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>Qp(`/api/config`),logs:e=>Qp(`/api/logs`+Gp(e)),taskLogs:(e,t)=>Qp(`/api/tasks/${encodeURIComponent(e)}/logs`+Gp(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),version:()=>Qp(`/api/version`),updateSnapshot:()=>Qp(`/api/chat/update`),updateInstall:e=>Qp(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:9e5}),captures:e=>Qp(`/api/captures`+Gp({limit:e})),eventTypes:()=>Qp(`/api/event-types`),eventTypeCreate:e=>Qp(`/api/event-types`,{method:`POST`,body:e}),eventTypeUpdate:(e,t)=>Qp(`/api/event-types/${encodeURIComponent(e)}`,{method:`PUT`,body:t}),eventTypeDelete:e=>Qp(`/api/event-types/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappings:()=>Qp(`/api/mappings`),mappingCreate:e=>Qp(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>Qp(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>Qp(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>Qp(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>Qp(`/api/bindings`),bindingCreate:e=>Qp(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>Qp(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>Qp(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>Qp(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),sources:()=>Qp(`/api/sources`),sourceCreate:e=>Qp(`/api/sources`,{method:`POST`,body:{path:e}}),sourceSigning:(e,t)=>Qp(`/api/sources/${encodeURIComponent(e)}/signing`,{method:`POST`,body:{signed:t}}),sourceApproveUnsigned:e=>Qp(`/api/sources/${encodeURIComponent(e)}/approve-unsigned`,{method:`POST`}),sourceSecret:e=>Qp(`/api/sources/${encodeURIComponent(e)}/secret`,{method:`POST`}),chatSessions:()=>Qp(`/api/chat/sessions`),chatMessages:e=>Qp(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>Qp(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>Qp(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>Qp(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:Up(),text:t,page:location.pathname+location.search||`/`}}),chatPersona:(e,t)=>Qp(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatDangerous:()=>Qp(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>Qp(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>Qp(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,t={})=>Zp(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t.signal})};function $p(e,t,n=``,r=!1){let i=new EventSource(Hp(n,r));return i.onopen=()=>t(`live`),i.onerror=()=>t(Bp(i.readyState)),i.onmessage=t=>{try{e(JSON.parse(t.data),t.lastEventId)}catch{}},()=>i.close()}var em=`archie.web.chat.channel`;function tm(){let e=localStorage.getItem(em);return e||(e=Up(),localStorage.setItem(em,e)),e}var nm=/(?:^|\s)\/([^\sLine truncated
|
||||
|
||||
`);u=r.pop()||``;for(let e of r){let t=e.split(`
|
||||
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(pm.value=n.session_id),n.type===`delta`&&(o+=n.text,vm.value=vm.value?{...vm.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],vm.value=vm.value?{...vm.value,tools:a}:null),n.type===`done`&&(s=!0,o||=n.text||``),n.type===`error`)throw Error(n.text)}if(t)break}if(!s)throw Error(`chat stream ended before completion`);mm.value=[...mm.value,{from:`assistant`,text:o,tool_calls:a}],vm.value=null,gm.value=`Ready`,await Nm()}catch(e){let t=e;t.name===`AbortError`&&!c?(vm.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},gm.value=`Stopped`):(vm.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?cm(r):void 0,isRetry:i},gm.value=`Error — retry available`)}finally{clearTimeout(l),jm=null,_m.value=!1}}function Km(){gm.value=`Stopping…`,pm.value&&q.chatCancel(pm.value).catch(()=>{}),Mm()}function qm(){ia(()=>{Nm().catch(e=>{gm.value=e.message||`Chat unavailable`})}),ca(()=>{Mm()})}var Jm=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],Ym=j({__name:`ChatFab`,props:{open:{type:Boolean}},emits:[`toggle`],setup(e,{emit:t}){let n=t;function r(e){return K(`col-start-1 row-start-1 grid place-items-center transition-[opacity,transform] duration-[140ms]`,e?`opacity-100`:`-rotate-45 scale-[0.7] opacity-0`)}return(t,i)=>(F(),I(`button`,{type:`button`,class:`relative z-10 grid size-14 cursor-pointer place-items-center rounded-full border border-border-strong bg-secondary text-primary shadow-[var(--shadow-md)] transition-transform duration-[140ms] hover:-translate-y-px focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:translate-y-0`,"aria-label":e.open?`Close chat`:`Chat with Archie`,title:e.open?`Close chat`:`Chat with Archie`,"aria-expanded":e.open,"aria-controls":O(um),onClick:i[0]||=e=>n(`toggle`)},[R(`span`,{"aria-hidden":`true`,class:T(r(!e.open))},[z(O(Hd),{size:22})],2),R(`span`,{"aria-hidden":`true`,class:T(r(e.open))},[z(O(uf),{size:22})],2)],8,Jm))}});function Xm(e){return typeof e==`string`?`'${e}'`:new eh().serialize(e)}var Zm=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,Qm=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[Zm.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function $m(e,t){if(e===t)return 0;let n=Math.min(e.length,t.length),r=0;for(let i=0;i<n;i++){let n=e.charCodeAt(i),a=t.charCodeAt(i);if(n===a)continue;let o=n<128&&Qm[n]?Qm[n]:n+128,s=a<128&&Qm[a]?Qm[a]:a+128;if(o!==s)return o<s?-1:1;r===0&&(r=n>a?-1:1)}return e.length===t.length?r:e.length<t.length?-1:1}var eh=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?$m(e,t):n===`number`&&r===`number`?e-t:$m(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}let i=Object.keys(e).sort($m),a=`${r}{`;for(let t=0;t<i.length;t++){let n=i[t];a+=`${n}:${this.serialize(e[n])}`,t<i.length-1&&(a+=`,`)}return a+`}`}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`]
Line truncated
|
||||
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(mm.value=n.session_id),n.type===`delta`&&(o+=n.text,ym.value=ym.value?{...ym.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],ym.value=ym.value?{...ym.value,tools:a}:null),n.type===`done`&&(s=!0,o||=n.text||``),n.type===`error`)throw Error(n.text)}if(t)break}if(!s)throw Error(`chat stream ended before completion`);hm.value=[...hm.value,{from:`assistant`,text:o,tool_calls:a}],ym.value=null,_m.value=`Ready`,await Pm()}catch(e){let t=e;t.name===`AbortError`&&!c?(ym.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},_m.value=`Stopped`):(ym.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?lm(r):void 0,isRetry:i},_m.value=`Error — retry available`)}finally{clearTimeout(l),Mm=null,vm.value=!1}}function qm(){_m.value=`Stopping…`,mm.value&&q.chatCancel(mm.value).catch(()=>{}),Nm()}function Jm(){ia(()=>{Pm().catch(e=>{_m.value=e.message||`Chat unavailable`})}),ca(()=>{Nm()})}var Ym=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],Xm=j({__name:`ChatFab`,props:{open:{type:Boolean}},emits:[`toggle`],setup(e,{emit:t}){let n=t;function r(e){return K(`col-start-1 row-start-1 grid place-items-center transition-[opacity,transform] duration-[140ms]`,e?`opacity-100`:`-rotate-45 scale-[0.7] opacity-0`)}return(t,i)=>(F(),I(`button`,{type:`button`,class:`relative z-10 grid size-14 cursor-pointer place-items-center rounded-full border border-border-strong bg-secondary text-primary shadow-[var(--shadow-md)] transition-transform duration-[140ms] hover:-translate-y-px focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:translate-y-0`,"aria-label":e.open?`Close chat`:`Chat with Archie`,title:e.open?`Close chat`:`Chat with Archie`,"aria-expanded":e.open,"aria-controls":O(dm),onClick:i[0]||=e=>n(`toggle`)},[R(`span`,{"aria-hidden":`true`,class:T(r(!e.open))},[z(O(Hd),{size:22})],2),R(`span`,{"aria-hidden":`true`,class:T(r(e.open))},[z(O(df),{size:22})],2)],8,Ym))}});function Zm(e){return typeof e==`string`?`'${e}'`:new th().serialize(e)}var Qm=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,$m=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[Qm.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function eh(e,t){if(e===t)return 0;let n=Math.min(e.length,t.length),r=0;for(let i=0;i<n;i++){let n=e.charCodeAt(i),a=t.charCodeAt(i);if(n===a)continue;let o=n<128&&$m[n]?$m[n]:n+128,s=a<128&&$m[a]?$m[a]:a+128;if(o!==s)return o<s?-1:1;r===0&&(r=n>a?-1:1)}return e.length===t.length?r:e.length<t.length?-1:1}var th=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?eh(e,t):n===`number`&&r===`number`?e-t:eh(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}let i=Object.keys(e).sort(eh),a=`${r}{`;for(let t=0;t<i.length;t++){let n=i[t];a+=`${n}:${this.serialize(e[n])}`,t<i.length-1&&(a+=`,`)}return a+`}`}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`]
Line truncated
|
||||
`)].join(`
|
||||
`))}return()=>i.value||r.value||o.value?ac(t.default({present:o.value})[0],{ref:e=>{let t=Mh(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?a.value=t.firstElementChild:a.value=t),t}}):null}}),Zg=j({name:`PrimitiveSlot`,inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let e=Jh(n.default()),r=e.findIndex(e=>e.type!==ms);if(r===-1)return e;let i=e[r];delete i.props?.ref;let a=i.props?H(t,i.props):t,o=ks({...i,props:{}},a);return e.length===1?o:(e[r]=o,e)}}}),Qg=[`area`,`img`,`input`],Y=j({name:`Primitive`,inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:`div`}},setup(e,{attrs:t,slots:n}){let r=e.asChild?`template`:e.as;return typeof r==`string`&&Qg.includes(r)?()=>ac(r,t):r===`template`?()=>ac(Zg,t,{default:n.default}):()=>ac(e.as,t,{default:n.default})}});function $g(){let e=D();return{primitiveElement:e,currentElement:U(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:Mh(e))}}var[e_,t_]=ah(`CollapsibleRoot`),n_=j({__name:`CollapsibleRoot`,props:{defaultOpen:{type:Boolean,required:!1,default:!1},open:{type:Boolean,required:!1,default:void 0},disabled:{type:Boolean,required:!1},unmountOnHide:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:open`],setup(e,{expose:t,emit:n}){let r=e,i=qh(r,`open`,n,{defaultValue:r.defaultOpen,passive:r.open===void 0}),{disabled:a,unmountOnHide:o}=Dn(r);return t_({contentId:``,disabled:a,open:i,unmountOnHide:o,onOpenToggle:()=>{a.value||(i.value=!i.value)}}),t({open:i}),J(),(e,t)=>(F(),L(O(Y),{as:e.as,"as-child":r.asChild,"data-state":O(i)?`open`:`closed`,"data-disabled":O(a)?``:void 0},{default:k(()=>[N(e.$slots,`default`,{open:O(i)})]),_:3},8,[`as`,`as-child`,`data-state`,`data-disabled`]))}}),r_=j({inheritAttrs:!1,__name:`CollapsibleContent`,props:{forceMount:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`contentFound`],setup(e,{emit:t}){let n=e,r=t,i=e_();i.contentId||=Bg(void 0,`reka-collapsible-content`);let a=D(),{forwardRef:o,currentElement:s}=J(),c=D(0),l=D(0),u=U(()=>i.open.value),d=D(u.value),f=D();A(()=>[u.value,a.value?.present],async()=>{await or();let e=s.value;if(!e)return;f.value=f.value||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();l.value=t.height,c.value=t.width,d.value||(e.style.transitionDuration=f.value.transitionDuration,e.style.animationName=f.value.animationName)},{immediate:!0});let p=U(()=>d.value&&i.open.value);return ia(()=>{requestAnimationFrame(()=>{d.value=!1})}),Nh(s,`beforematch`,e=>{requestAnimationFrame(()=>{i.onOpenToggle(),r(`contentFound`)})}),(e,t)=>(F(),L(O(Xg),{ref_key:`presentRef`,ref:a,present:e.forceMount||O(i).open.value,"force-mount":!0},{default:k(({present:t})=>[z(O(Y),H(e.$attrs,{id:O(i).contentId,ref:O(o),"as-child":n.asChild,as:e.as,hidden:t?void 0:O(i).unmountOnHide.value?``:`until-found`,"data-state":p.value?void 0:O(i).open.value?`open`:`closed`,"data-disabled":O(i).disabled?.value?``:void 0,style:{"--reka-collapsible-content-height":`${l.value}px`,"--reka-collapsible-content-width":`${c.value}px`}}),{default:k(()=>[!O(i).unmountOnHide.value||t?N(e.$slots,`default`,{key:0}):V(`v-if`,!0)]),_:2},1040,[`id`,`as-child`,`as`,`hidden`,`data-state`,`data-disabled`,`style`])]),_:3},8,[`present`]))}}),i_=j({__name:`CollapsibleTrigger`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e;J();let n=e_();return(e,r)=>(F(),L(O(Y),{type:e.as===`button`?`button`:void 0,as:e.as,"as-child":t.asChild,"aria-controls":O(n).contentId,"aria-expanded":O(n).open.value,"data-state":O(n).open.value?`open`:`closed`,"data-disabled":O(n).disabled?.value?``:void 0,disabled:O(n).disabled?.value,onClick:O(n).onOpenToggle},{default:k(()=>[N(e.$slots,`default`)]),_:3},8,[`type`,`as`,`as-child`,`aria-controls`,`aria-expanded`,`data-state`,`data-disabled`,`disabled`,`onClick`]))}});function a_({type:e,defaultValue:t,modelValue:n}){let r=n||t;return n!==void 0||t!==void 0?Array.isArray(r)?`multiple`:`single`:e??`single`}function o_({type:e,defaultValue:t,modelValue:n}){return e||a_({type:e,defaultValue:t,modelValue:n})}function s_({type:e,defaultValue:t}){return t===void 0?e===`single`?void 0:[]:t}function c_(e,t){let n=U(()=>o_(e)),r=qh(e,`modelValue`,t,{defaultValue:s_(e),passive:e.modelValue===void 0,deep:!0});function i(e){if(n.value===`single`)r.value=th(e,r.value)?void 0:e;else{let t=Array.isArray(r.value)?[...r.value||[]]:[r.value].filter(Boolean);if(lh(t,e)){let n=t.findIndex(t=>th(t,e));t.splice(n,1)}else t.push(e);r.value=t}}return{modelValue:r,changeModelValue:i,isSingle:U(()=>n.value===`single`)}}var[l_,u_]=ah(`AccordionRoot`),d_=j({__name:`AccordionRoot`,props:{collapsible:{type:Boolean,required:!1,de
Line truncated
|
||||
`))}return()=>i.value||r.value||o.value?ac(t.default({present:o.value})[0],{ref:e=>{let t=Nh(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?a.value=t.firstElementChild:a.value=t),t}}):null}}),Qg=j({name:`PrimitiveSlot`,inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let e=Yh(n.default()),r=e.findIndex(e=>e.type!==ms);if(r===-1)return e;let i=e[r];delete i.props?.ref;let a=i.props?H(t,i.props):t,o=ks({...i,props:{}},a);return e.length===1?o:(e[r]=o,e)}}}),$g=[`area`,`img`,`input`],Y=j({name:`Primitive`,inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:`div`}},setup(e,{attrs:t,slots:n}){let r=e.asChild?`template`:e.as;return typeof r==`string`&&$g.includes(r)?()=>ac(r,t):r===`template`?()=>ac(Qg,t,{default:n.default}):()=>ac(e.as,t,{default:n.default})}});function e_(){let e=D();return{primitiveElement:e,currentElement:U(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:Nh(e))}}var[t_,n_]=oh(`CollapsibleRoot`),r_=j({__name:`CollapsibleRoot`,props:{defaultOpen:{type:Boolean,required:!1,default:!1},open:{type:Boolean,required:!1,default:void 0},disabled:{type:Boolean,required:!1},unmountOnHide:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:open`],setup(e,{expose:t,emit:n}){let r=e,i=Jh(r,`open`,n,{defaultValue:r.defaultOpen,passive:r.open===void 0}),{disabled:a,unmountOnHide:o}=Dn(r);return n_({contentId:``,disabled:a,open:i,unmountOnHide:o,onOpenToggle:()=>{a.value||(i.value=!i.value)}}),t({open:i}),J(),(e,t)=>(F(),L(O(Y),{as:e.as,"as-child":r.asChild,"data-state":O(i)?`open`:`closed`,"data-disabled":O(a)?``:void 0},{default:k(()=>[N(e.$slots,`default`,{open:O(i)})]),_:3},8,[`as`,`as-child`,`data-state`,`data-disabled`]))}}),i_=j({inheritAttrs:!1,__name:`CollapsibleContent`,props:{forceMount:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`contentFound`],setup(e,{emit:t}){let n=e,r=t,i=t_();i.contentId||=Vg(void 0,`reka-collapsible-content`);let a=D(),{forwardRef:o,currentElement:s}=J(),c=D(0),l=D(0),u=U(()=>i.open.value),d=D(u.value),f=D();A(()=>[u.value,a.value?.present],async()=>{await or();let e=s.value;if(!e)return;f.value=f.value||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();l.value=t.height,c.value=t.width,d.value||(e.style.transitionDuration=f.value.transitionDuration,e.style.animationName=f.value.animationName)},{immediate:!0});let p=U(()=>d.value&&i.open.value);return ia(()=>{requestAnimationFrame(()=>{d.value=!1})}),Ph(s,`beforematch`,e=>{requestAnimationFrame(()=>{i.onOpenToggle(),r(`contentFound`)})}),(e,t)=>(F(),L(O(Zg),{ref_key:`presentRef`,ref:a,present:e.forceMount||O(i).open.value,"force-mount":!0},{default:k(({present:t})=>[z(O(Y),H(e.$attrs,{id:O(i).contentId,ref:O(o),"as-child":n.asChild,as:e.as,hidden:t?void 0:O(i).unmountOnHide.value?``:`until-found`,"data-state":p.value?void 0:O(i).open.value?`open`:`closed`,"data-disabled":O(i).disabled?.value?``:void 0,style:{"--reka-collapsible-content-height":`${l.value}px`,"--reka-collapsible-content-width":`${c.value}px`}}),{default:k(()=>[!O(i).unmountOnHide.value||t?N(e.$slots,`default`,{key:0}):V(`v-if`,!0)]),_:2},1040,[`id`,`as-child`,`as`,`hidden`,`data-state`,`data-disabled`,`style`])]),_:3},8,[`present`]))}}),a_=j({__name:`CollapsibleTrigger`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e;J();let n=t_();return(e,r)=>(F(),L(O(Y),{type:e.as===`button`?`button`:void 0,as:e.as,"as-child":t.asChild,"aria-controls":O(n).contentId,"aria-expanded":O(n).open.value,"data-state":O(n).open.value?`open`:`closed`,"data-disabled":O(n).disabled?.value?``:void 0,disabled:O(n).disabled?.value,onClick:O(n).onOpenToggle},{default:k(()=>[N(e.$slots,`default`)]),_:3},8,[`type`,`as`,`as-child`,`aria-controls`,`aria-expanded`,`data-state`,`data-disabled`,`disabled`,`onClick`]))}});function o_({type:e,defaultValue:t,modelValue:n}){let r=n||t;return n!==void 0||t!==void 0?Array.isArray(r)?`multiple`:`single`:e??`single`}function s_({type:e,defaultValue:t,modelValue:n}){return e||o_({type:e,defaultValue:t,modelValue:n})}function c_({type:e,defaultValue:t}){return t===void 0?e===`single`?void 0:[]:t}function l_(e,t){let n=U(()=>s_(e)),r=Jh(e,`modelValue`,t,{defaultValue:c_(e),passive:e.modelValue===void 0,deep:!0});function i(e){if(n.value===`single`)r.value=nh(e,r.value)?void 0:e;else{let t=Array.isArray(r.value)?[...r.value||[]]:[r.value].filter(Boolean);if(uh(t,e)){let n=t.findIndex(t=>nh(t,e));t.splice(n,1)}else t.push(e);r.value=t}}return{modelValue:r,changeModelValue:i,isSingle:U(()=>n.value===`single`)}}var[u_,d_]=oh(`AccordionRoot`),f_=j({__name:`AccordionRoot`,props:{collapsible:{type:Boolean,required:!1,de
Line truncated
|
||||
- a positive number
|
||||
- less than the value passed to \`max\` (or ${FS} if no \`max\` prop is set)
|
||||
- less than the value passed to \`max\` (or ${IS} if no \`max\` prop is set)
|
||||
- \`null\` or \`undefined\` if the progress is indeterminate.
|
||||
|
||||
Defaulting to \`null\`.`),null)}function BS(e){return RS(e)&&!Number.isNaN(e)&&e>0?e:(console.error(`Invalid prop \`max\` of value \`${e}\` supplied to \`ProgressRoot\`. Only numbers greater than 0 are valid max values. Defaulting to \`${FS}\`.`),FS)}var VS=j({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:FS},getValueLabel:{type:Function,required:!1,default:(e,t)=>RS(e)?`${Math.round(e/t*FS)}%`:void 0},getValueText:{type:Function,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:modelValue`,`update:max`],setup(e,{emit:t}){let n=e,r=t;J();let i=qh(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=qh(n,`max`,r,{passive:n.max===void 0});A(()=>i.value,async e=>{let t=zS(e,n.max);t!==e&&(await or(),i.value=t)},{immediate:!0}),A(()=>n.max,e=>{let t=BS(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=U(()=>ch(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return LS({modelValue:i,max:a,progressState:o}),(e,t)=>(F(),L(O(Y),{"as-child":e.asChild,as:e.as,"aria-valuemax":O(a),"aria-valuemin":0,"aria-valuenow":RS(O(i))?O(i):void 0,"aria-valuetext":e.getValueText?.(O(i),O(a)),"aria-label":e.getValueLabel(O(i),O(a)),role:`progressbar`,"data-state":o.value,"data-value":O(i)??void 0,"data-max":O(a)},{default:k(()=>[N(e.$slots,`default`,{modelValue:O(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),HS=j({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=IS();return J(),(e,r)=>(F(),L(O(Y),H(t,{"data-state":O(n).progressState.value,"data-value":O(n).modelValue?.value??void 0,"data-max":O(n).max.value}),{default:k(()=>[N(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),US=`radio.select`;function WS(e,t,n){sh(US,n,{originalEvent:e,value:t})}var GS=j({inheritAttrs:!1,__name:`Radio`,props:{id:{type:String,required:!1},value:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},checked:{type:Boolean,required:!1,default:void 0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:checked`,`select`],setup(e,{emit:t}){let n=e,r=t,i=qh(n,`checked`,r,{passive:n.checked===void 0}),{value:a}=Dn(n),{forwardRef:o,currentElement:s}=J(),c=vg(s),l=xg(),u=U(()=>n.id&&s.value?document.querySelector(`[for="${n.id}"]`)?.innerText:void 0);function d(e){n.disabled||WS(e,n.value,e=>{r(`select`,e),!e?.defaultPrevented&&(i.value=!0,c.value&&e.stopPropagation())})}return(e,t)=>(F(),I(P,null,[z(O(Y),H({id:e.id,ref:O(o),role:`radio`,type:e.as===`button`?`button`:void 0,as:e.as,"aria-checked":O(i)??!1,"aria-label":u.value,"as-child":e.asChild,disabled:e.disabled?``:void 0,"data-state":O(i)?`checked`:`unchecked`,"data-disabled":e.disabled?``:void 0,value:O(a),required:e.required,name:e.name},{...O(l),...e.$attrs},{onClick:uu(d,[`stop`])}),{default:k(()=>[N(e.$slots,`default`,{checked:O(i)})]),_:3},16,[`id`,`type`,`as`,`aria-checked`,`aria-label`,`as-child`,`disabled`,`data-state`,`data-disabled`,`value`,`required`,`name`]),O(c)&&e.name?(F(),L(O(Tv),H({key:0,type:`radio`,tabindex:`-1`,value:O(a),checked:!!O(i),name:e.name,disabled:e.disabled,required:e.required},O(l)),null,16,[`value`,`checked`,`name`,`disabled`,`required`])):V(`v-if`,!0)],64))}}),[KS,qS]=ah(`RadioGroupRoot`),JS=j({__name:`RadioGroupRoot`,props:{modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},orientation:{type:String,required:!1,default:void 0},dir:{type:String,required:!1},loop:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,{forwardRef:i,currentElement:a}=J(),o=qh(n,`modelValue`,r,{defaultValue:n.defaultValue,passive:n.modelValue===void 0}),{disabled:s,loop:c,orientation:l,name:u,required:d,dir:f}=Dn(n),p=pg(f),m=vg(a);return qS({modelValue:o,changeModelValue:e=>{o.value=e},disabled:s,loop:c,orientation:l,name:u?.value,required:d}),(e,t)=>(F(),L(O(sx),{"as-child":``,orientation:O(l),dir:O(p),loop:O(c)},{default:k(()=>[z(O(Y),{ref:O(i),role:`radiogroup`,"data-disabled":O(s)?``:void 0,"as-child":e.asChild,as:e.as,"aria-orientation":O(l),"aria-required":O(d),dir:O(p)},{default:k(()=>[N(e.$slots,`default`,{modelValue:O(o)}),O(m)&&O(u)?(F(),L(O(Tv),{key:0,required:O(d),disabled:O(s),value:O(o),name:O(u)},null,8,[`required`,`disabled`,`value`,`name`])):V(`v-if`,!0)]),_:3},8,[`data-disabled`,`as-child`,`as`,`aria-orientation`,`aria-required`,`dir`])]),_:3},8,[`orientation`,`dir`,`loop`]))}}),[YS,XS]=ah(`RadioGroupItem`),ZS=j({inheritAttrs:!1,__name:`RadioGroupItem`,props:{id:{type:String,required:!1},value:{type:null,reLine truncated
|
||||
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:HE(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>HE(e))}),null)};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.push({kind:`pre`,code:a.join(`
|
||||
`)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=WE(c),u=e+1<n.length?WE(n[e+1]):null;if(l&&u&&GE(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=WE(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>HE(e)),rows:r.map(e=>e.map(e=>HE(e)))});continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.push({kind:`h${d[1].length}`,inline:HE(d[2])});continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tag!==e)&&(s(),i={tag:e,items:[]}),i.items.push((f||p)[1]);continue}if(c.startsWith(`>`)){o(),s(),t.push({kind:`blockquote`,inline:HE(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
|
||||
`)}),t}function WE(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function GE(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var KE={class:`[overflow-wrap:anywhere]`},qE={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},JE={class:`font-mono text-[0.85em]`},YE={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},XE={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},ZE={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},QE={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},$E={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},eD={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},tD={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},nD={key:8,class:`mb-2.5 last:mb-0`},rD=j({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=U(()=>UE(t.text));return(e,t)=>(F(),I(`div`,KE,[(F(!0),I(P,null,M(n.value,(e,t)=>(F(),I(P,{key:t},[e.kind===`pre`?(F(),I(`pre`,qE,[R(`code`,JE,E(e.code),1)])):e.kind===`table`?(F(),I(`table`,YE,[R(`thead`,null,[R(`tr`,null,[(F(!0),I(P,null,M(e.head,(e,t)=>(F(),I(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[z(BE,{inline:e},null,8,[`inline`])]))),128))])]),R(`tbody`,null,[(F(!0),I(P,null,M(e.rows,(e,t)=>(F(),I(`tr`,{key:t},[(F(!0),I(P,null,M(e,(e,t)=>(F(),I(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[z(BE,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(F(),I(`blockquote`,XE,[z(BE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(F(),I(`h1`,ZE,[z(BE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(F(),I(`h2`,QE,[z(BE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(F(),I(`h3`,$E,[z(BE,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(F(),I(`ul`,eD,[(F(!0),I(P,null,M(e.items,(e,t)=>(F(),I(`li`,{key:t},[z(BE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(F(),I(`ol`,tD,[(F(!0),I(P,null,M(e.items,(e,t)=>(F(),I(`li`,{key:t},[z(BE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(F(),I(`p`,nD,[z(BE,{inline:e.inline},null,8,[`inline`])])):V(``,!0)],64))),128))]))}}),iD={class:`truncate`},aD=j({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ha(`RouterLink`);return F(),L(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:k(()=>[z(O(xd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),R(`span`,iD,E(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),oD={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},sD={class:`font-semibold text-foreground`},cD={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},lD=j({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=U(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=U(()=>t.tool.parameters||t.tool.Parameters||``),i=U(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=U(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(F(),L(aD,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(F(),I(`div`,oD,[z(O(lf),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),R(`span`,sD,E(n.value),1),r.value?(F(),I(`code`,cD,E(r.value),1)):V(``,!0),R(`span`,{class:T(O(K)(`text-fg-muted`,i.value&&`text-danger`))},E(a.value),3)]))}}),uD={key:0,class:`mb-2 grid gap-0.5 text-xs`},dD={key:2,class:`whitespace-pre-wrap`},fD=j({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(F(),I(`div`,{class:T([`flex`,e.assistant?`justify-start`:`justify-end`])},[R(`div`,{class:T(O(K)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(F(),I(`div`,uD,[(F(!0),I(P,null,M(e.tools,(t,n)=>(F(),L(lD,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):V(``,!0),e.assistant?(F(),L(rD,{key:1,text:e.text},null,8,[`text`])):(F(),I(`div`,dD,E(e.text),1)),N(t.$slots,`default`)],2)],2))}}),pD={class:`w-full self-center justify-self-center py-6 text-center`},mD={class:`grid gap-2`},hD=[`onClick`],gD=j({__name:`ChatEmptyState`,emits:[`prompt`],setup(e,{emit:t}){let n=t,r=[`Summarise active tasks`,`Show running agents`,`Check system status`];return(e,t)=>(F(),I(`div`,pD,[t[0]||=R(`span`,{"aria-hidden":`true`,class:`mx-auto mb-3 grid size-9 placLine truncated
|
||||
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>DM?`${n.slice(0,DM).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var kM=[`title`],AM=j({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>aM(n.event)),a=U(()=>OM(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=U(()=>n.event.at?hj(n.event.at):`—`);return(e,t)=>(F(),L(O(wM),{class:T(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[fu(uu(o,[`prevent`]),[`enter`]),fu(uu(o,[`prevent`]),[`space`])]},{default:k(()=>[z(O($),{class:`font-medium`},{default:k(()=>[B(E(n.event.kind||n.event.type||`event`),1)]),_:1}),z(O($),{class:`font-mono`},{default:k(()=>[B(E(i.value>0?`#${i.value}`:`—`),1)]),_:1}),z(O($),{class:`w-[55%] max-w-0`},{default:k(()=>[R(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},E(a.value.text),9,kM)]),_:1}),z(O($),null,{default:k(()=>[B(E(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}});function jM(e,t){return`${e}:${t??0}`}function MM(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=jM(OM(n).text,r),a=t[t.length-1];if(a&&a.key===i){a.count+=1,a.events.push(n);continue}t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var NM={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},PM={class:`max-h-[28rem] overflow-y-auto`},FM=[`aria-expanded`,`aria-label`,`onClick`],IM=[`title`],LM=j({__name:`LiveActivityCard`,setup(e){let t=zD(),{activity:n,streamKind:r,streamState:i}=od(CA()),a=rn(new Set),o=U(()=>MM(n.value));function s(e){a.has(e)?a.delete(e):a.add(e)}function c(e){return a.has(e.key)}function l(e){return OM(e.representative)}function u(e){return e.representative.at?hj(e.representative.at):`—`}function d(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(F(),L(O(cj),null,{default:k(()=>[z(O(pj),null,{default:k(()=>[z(O(mj),null,{default:k(()=>[...t[0]||=[B(`Live activity`,-1)]]),_:1}),z(O(lj),null,{default:k(()=>[z(O(aj),{variant:O(r)},{default:k(()=>[B(E(O(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),z(O(uj),null,{default:k(()=>[R(`div`,NM,[R(`div`,PM,[z(O(SM),null,{default:k(()=>[z(O(EM),{class:`sticky top-0 z-10 bg-card`},{default:k(()=>[z(O(wM),null,{default:k(()=>[z(O(TM),null,{default:k(()=>[...t[1]||=[B(`Event`,-1)]]),_:1}),z(O(TM),null,{default:k(()=>[...t[2]||=[B(`Task`,-1)]]),_:1}),z(O(TM),null,{default:k(()=>[...t[3]||=[B(`Detail`,-1)]]),_:1}),z(O(TM),null,{default:k(()=>[...t[4]||=[B(`When`,-1)]]),_:1})]),_:1})]),_:1}),z(O(CM),null,{default:k(()=>[O(n).length?V(``,!0):(F(),L(O(wM),{key:0},{default:k(()=>[z(O($),{colspan:`4`},{default:k(()=>[z(O(ZA),null,{default:k(()=>[z(O(ej),null,{default:k(()=>[z(O(rj),null,{default:k(()=>[...t[5]||=[B(`Waiting for activity`,-1)]]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),O(n).length?(F(!0),I(P,{key:1},M(o.value,e=>(F(),I(P,{key:e.key},[e.count===1?(F(),L(AM,{key:0,event:e.representative,onOpen:d},null,8,[`event`])):(F(),I(P,{key:1},[z(O(wM),{class:T(e.taskID>0?`cursor-pointer`:``),role:e.taskID>0?`link`:void 0,tabindex:e.taskID>0?0:void 0,title:e.taskID>0?`Open task details`:void 0,onClick:t=>e.taskID>0&&d(e.taskID),onKeydown:[fu(uu(t=>e.taskID>0&&d(e.taskID),[`prevent`]),[`enter`]),fu(uu(t=>e.taskID>0&&d(e.taskID),[`prevent`]),[`space`])]},{default:k(()=>[z(O($),{class:`font-medium`},{default:k(()=>[R(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":c(e),"aria-label":`${c(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:uu(t=>s(e.key),[`stop`])},[c(e)?(F(),L(O(Td),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(F(),L(O(Ed),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),B(` `+E(e.label)+` `,1),z(O(aj),{variant:`idle`},{default:k(()=>[B(`×`+E(e.count),1)]),_:2},1024)],8,FM)]),_:2},1024),z(O($),{class:`font-mono`},{default:k(()=>[B(E(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),z(O($),{class:`w-[55%] max-w-0`},{default:k(()=>[R(`span`,{class:`block truncate`,title:l(e).truncated?l(e).full:void 0},E(l(e).text),9,IM)]),_:2},1024),z(O($),null,{default:k(()=>[B(E(u(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),c(e)?(F(!0),I(P,{key:0},M(e.events,(t,n)=>(F(),L(AM,{key:`${e.key}:${n}`,event:t,onOpen:d},null,8,[`event`]))),128)):V(``,!0)],64))],64))),128)):V(``,!0)]),_:1})]),_:1})])])]),_:1})]),_:1}))}}),RM=j({__name:`Alert`,props:{class:{type:[Boolean,null,String,Object,Array]},variant:{}},setup(e){let t=e;return(n,r)=>(F(),I(`div`,{"data-slot":`alert`,class:T(O(K)(O(HM)({variant:e.variant}),t.class)),role:`alert`},[N(n.$slots,`default`)],2))}}),zM=j({__name:`AlertAction`,props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e;return(e,n)=>(F(),I(`div`,{"data-slot":`alert-action`,class:T(O(K)(`absolute top-2 right-2`,t.class))},[N(e.$slots,`default`)],2))}}),BM=j(
Line truncated
|
||||
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function zN(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function BN(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function VN(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function HN(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var UN=D([]),WN=D([]),GN=D(!0),KN=D(null),qN=D(null),JN=D(!1),YN=D(null);async function XN(){try{let e=await q.eventTypes();GN.value=e.enabled!==!1,UN.value=e.event_types||[],WN.value=e.proposals||[],KN.value=null}catch(e){KN.value=e.message||String(e)}}function ZN(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function QN(e){YN.value=null,qN.value=e}function $N(e){let t=sP.value.find(t=>String(t.id)===e.sample_id);QN({mode:`proposal`,id:null,source:e.source,name:``,rule:ZN(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function eP(e=``){QN({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function tP(e){QN({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:ZN(e.rule),headersText:``,body:``,exampleHeaders:{}})}function nP(){qN.value=null}async function rP(){let e=qN.value;if(e){JN.value=!0;try{if(e.mode===`edit`&&e.id)await q.eventTypeUpdate(e.id,{name:e.name,rule:HN(e.rule)});else{let t=e.mode===`paste`?RN(e.headersText):e.exampleHeaders;await q.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:HN(e.rule),example:{headers:t,body:e.body}})}qN.value=null,await XN()}catch(e){YN.value=e.message||String(e)}finally{JN.value=!1}}}var iP=D(null);async function aP(){let e=iP.value;if(iP.value=null,e)try{await q.eventTypeDelete(e.id),await XN()}catch(e){KN.value=e.message||String(e)}}var oP=100,sP=D([]),cP=D(!0),lP=D(null),uP=D(!0),dP=D(null);async function fP(){try{let e=await q.captures(oP);cP.value=e.enabled!==!1,sP.value=e.captures||[],lP.value=null}catch(e){lP.value=e.message||String(e)}finally{uP.value=!1}}function pP(e){let t=sP.value.find(t=>t.id===e);return t&&(dP.value=t),!!t}function mP(){sP.value.length&&(dP.value=sP.value[0])}function hP(){wA(`captures`,()=>{fP(),XN()})}var gP=j({__name:`Tabs`,props:{defaultValue:{},orientation:{},dir:{},activationMode:{},modelValue:{},unmountOnHide:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,i=bg(Pw(n,`class`),r);return(e,t)=>(F(),L(O(VC),H({"data-slot":`tabs`,"data-orientation":O(i).orientation||`horizontal`},O(i),{class:O(K)(`gap-2 group/tabs flex data-horizontal:flex-col`,n.class)}),{default:k(t=>[N(e.$slots,`default`,we(Os(t)))]),_:3},16,[`data-orientation`,`class`]))}}),_P=j({__name:`TabsContent`,props:{value:{},forceMount:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=Pw(t,`class`);return(e,r)=>(F(),L(O(WC),H({"data-slot":`tabs-content`,class:O(K)(`text-sm flex-1 outline-none`,t.class)},O(n)),{default:k(()=>[N(e.$slots,`default`)]),_:3},16,[`class`]))}}),vP=j({__name:`TabsList`,props:{loop:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]},variant:{default:`default`}},setup(e){let t=e,n=Pw(t,`class`,`variant`);return(r,i)=>(F(),L(O(GC),H({"data-slot":`tabs-list`,"data-variant":e.variant},O(n),{class:O(K)(O(bP)({variant:e.variant}),t.class)}),{default:k(()=>[N(r.$slots,`default`)]),_:3},16,[`data-variant`,`class`]))}}),yP=j({__name:`TabsTrigger`,props:{value:{},disabled:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=yg(Pw(t,`class`));return(e,r)=>(F(),L(O(KC),H({"data-slot":`tabs-trigger`,class:O(K)(`gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg:not([class*=size-])]:size-4 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabledLine truncated
|
||||
Defaulting to \`null\`.`),null)}function VS(e){return zS(e)&&!Number.isNaN(e)&&e>0?e:(console.error(`Invalid prop \`max\` of value \`${e}\` supplied to \`ProgressRoot\`. Only numbers greater than 0 are valid max values. Defaulting to \`${IS}\`.`),IS)}var HS=j({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:IS},getValueLabel:{type:Function,required:!1,default:(e,t)=>zS(e)?`${Math.round(e/t*IS)}%`:void 0},getValueText:{type:Function,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:modelValue`,`update:max`],setup(e,{emit:t}){let n=e,r=t;J();let i=Jh(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=Jh(n,`max`,r,{passive:n.max===void 0});A(()=>i.value,async e=>{let t=BS(e,n.max);t!==e&&(await or(),i.value=t)},{immediate:!0}),A(()=>n.max,e=>{let t=VS(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=U(()=>lh(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return RS({modelValue:i,max:a,progressState:o}),(e,t)=>(F(),L(O(Y),{"as-child":e.asChild,as:e.as,"aria-valuemax":O(a),"aria-valuemin":0,"aria-valuenow":zS(O(i))?O(i):void 0,"aria-valuetext":e.getValueText?.(O(i),O(a)),"aria-label":e.getValueLabel(O(i),O(a)),role:`progressbar`,"data-state":o.value,"data-value":O(i)??void 0,"data-max":O(a)},{default:k(()=>[N(e.$slots,`default`,{modelValue:O(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),US=j({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=LS();return J(),(e,r)=>(F(),L(O(Y),H(t,{"data-state":O(n).progressState.value,"data-value":O(n).modelValue?.value??void 0,"data-max":O(n).max.value}),{default:k(()=>[N(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),WS=`radio.select`;function GS(e,t,n){ch(WS,n,{originalEvent:e,value:t})}var KS=j({inheritAttrs:!1,__name:`Radio`,props:{id:{type:String,required:!1},value:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},checked:{type:Boolean,required:!1,default:void 0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:checked`,`select`],setup(e,{emit:t}){let n=e,r=t,i=Jh(n,`checked`,r,{passive:n.checked===void 0}),{value:a}=Dn(n),{forwardRef:o,currentElement:s}=J(),c=yg(s),l=Sg(),u=U(()=>n.id&&s.value?document.querySelector(`[for="${n.id}"]`)?.innerText:void 0);function d(e){n.disabled||GS(e,n.value,e=>{r(`select`,e),!e?.defaultPrevented&&(i.value=!0,c.value&&e.stopPropagation())})}return(e,t)=>(F(),I(P,null,[z(O(Y),H({id:e.id,ref:O(o),role:`radio`,type:e.as===`button`?`button`:void 0,as:e.as,"aria-checked":O(i)??!1,"aria-label":u.value,"as-child":e.asChild,disabled:e.disabled?``:void 0,"data-state":O(i)?`checked`:`unchecked`,"data-disabled":e.disabled?``:void 0,value:O(a),required:e.required,name:e.name},{...O(l),...e.$attrs},{onClick:uu(d,[`stop`])}),{default:k(()=>[N(e.$slots,`default`,{checked:O(i)})]),_:3},16,[`id`,`type`,`as`,`aria-checked`,`aria-label`,`as-child`,`disabled`,`data-state`,`data-disabled`,`value`,`required`,`name`]),O(c)&&e.name?(F(),L(O(Ev),H({key:0,type:`radio`,tabindex:`-1`,value:O(a),checked:!!O(i),name:e.name,disabled:e.disabled,required:e.required},O(l)),null,16,[`value`,`checked`,`name`,`disabled`,`required`])):V(`v-if`,!0)],64))}}),[qS,JS]=oh(`RadioGroupRoot`),YS=j({__name:`RadioGroupRoot`,props:{modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},orientation:{type:String,required:!1,default:void 0},dir:{type:String,required:!1},loop:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,{forwardRef:i,currentElement:a}=J(),o=Jh(n,`modelValue`,r,{defaultValue:n.defaultValue,passive:n.modelValue===void 0}),{disabled:s,loop:c,orientation:l,name:u,required:d,dir:f}=Dn(n),p=mg(f),m=yg(a);return JS({modelValue:o,changeModelValue:e=>{o.value=e},disabled:s,loop:c,orientation:l,name:u?.value,required:d}),(e,t)=>(F(),L(O(cx),{"as-child":``,orientation:O(l),dir:O(p),loop:O(c)},{default:k(()=>[z(O(Y),{ref:O(i),role:`radiogroup`,"data-disabled":O(s)?``:void 0,"as-child":e.asChild,as:e.as,"aria-orientation":O(l),"aria-required":O(d),dir:O(p)},{default:k(()=>[N(e.$slots,`default`,{modelValue:O(o)}),O(m)&&O(u)?(F(),L(O(Ev),{key:0,required:O(d),disabled:O(s),value:O(o),name:O(u)},null,8,[`required`,`disabled`,`value`,`name`])):V(`v-if`,!0)]),_:3},8,[`data-disabled`,`as-child`,`as`,`aria-orientation`,`aria-required`,`dir`])]),_:3},8,[`orientation`,`dir`,`loop`]))}}),[XS,ZS]=oh(`RadioGroupItem`),QS=j({inheritAttrs:!1,__name:`RadioGroupItem`,props:{id:{type:String,required:!1},value:{type:null,reLine truncated
|
||||
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:qE(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>qE(e))}),null)};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.push({kind:`pre`,code:a.join(`
|
||||
`)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=YE(c),u=e+1<n.length?YE(n[e+1]):null;if(l&&u&&XE(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=YE(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>qE(e)),rows:r.map(e=>e.map(e=>qE(e)))});continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.push({kind:`h${d[1].length}`,inline:qE(d[2])});continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tag!==e)&&(s(),i={tag:e,items:[]}),i.items.push((f||p)[1]);continue}if(c.startsWith(`>`)){o(),s(),t.push({kind:`blockquote`,inline:qE(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
|
||||
`)}),t}function YE(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function XE(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var ZE={class:`[overflow-wrap:anywhere]`},QE={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},$E={class:`font-mono text-[0.85em]`},eD={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},tD={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},nD={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},rD={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},iD={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},aD={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},oD={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},sD={key:8,class:`mb-2.5 last:mb-0`},cD=j({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=U(()=>JE(t.text));return(e,t)=>(F(),I(`div`,ZE,[(F(!0),I(P,null,M(n.value,(e,t)=>(F(),I(P,{key:t},[e.kind===`pre`?(F(),I(`pre`,QE,[R(`code`,$E,E(e.code),1)])):e.kind===`table`?(F(),I(`table`,eD,[R(`thead`,null,[R(`tr`,null,[(F(!0),I(P,null,M(e.head,(e,t)=>(F(),I(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[z(GE,{inline:e},null,8,[`inline`])]))),128))])]),R(`tbody`,null,[(F(!0),I(P,null,M(e.rows,(e,t)=>(F(),I(`tr`,{key:t},[(F(!0),I(P,null,M(e,(e,t)=>(F(),I(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[z(GE,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(F(),I(`blockquote`,tD,[z(GE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(F(),I(`h1`,nD,[z(GE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(F(),I(`h2`,rD,[z(GE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(F(),I(`h3`,iD,[z(GE,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(F(),I(`ul`,aD,[(F(!0),I(P,null,M(e.items,(e,t)=>(F(),I(`li`,{key:t},[z(GE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(F(),I(`ol`,oD,[(F(!0),I(P,null,M(e.items,(e,t)=>(F(),I(`li`,{key:t},[z(GE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(F(),I(`p`,sD,[z(GE,{inline:e.inline},null,8,[`inline`])])):V(``,!0)],64))),128))]))}}),lD={class:`truncate`},uD=j({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ha(`RouterLink`);return F(),L(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:k(()=>[z(O(xd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),R(`span`,lD,E(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),dD={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},fD={class:`font-semibold text-foreground`},pD={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},mD=j({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=U(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=U(()=>t.tool.parameters||t.tool.Parameters||``),i=U(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=U(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(F(),L(uD,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(F(),I(`div`,dD,[z(O(uf),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),R(`span`,fD,E(n.value),1),r.value?(F(),I(`code`,pD,E(r.value),1)):V(``,!0),R(`span`,{class:T(O(K)(`text-fg-muted`,i.value&&`text-danger`))},E(a.value),3)]))}}),hD={key:0,class:`mb-2 grid gap-0.5 text-xs`},gD={key:1,class:`mb-2 flex flex-wrap gap-1.5`},_D={key:3,class:`whitespace-pre-wrap`},vD=j({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(F(),I(`div`,{class:T([`flex`,e.assistant?`justify-start`:`justify-end`])},[R(`div`,{class:T(O(K)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(F(),I(`div`,hD,[(F(!0),I(P,null,M(e.tools,(t,n)=>(F(),L(mD,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):V(``,!0),e.media.length?(F(),I(`div`,gD,[(F(!0),I(P,null,M(e.media,(e,t)=>(F(),L(RE,{key:t,attachment:e},null,8,[`attachment`]))),128))])):V(``,!0),e.assistant?(F(),L(cD,{key:2,text:e.text},null,8,[`text`])):(F(),I(`div`,_D,E(e.text),1)),N(t.$slots,`default`)],2)],2))}}),yD={class:`w-full self-center justify-self-center py-6 text-center`},bD={class:`grid gap-2`},xD=[`onClick`],SD=j({__name:`ChatEmptyState`,emits:[`proLine truncated
|
||||
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>NM?`${n.slice(0,NM).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var FM=[`title`],IM=j({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>dM(n.event)),a=U(()=>PM(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=U(()=>n.event.at?xj(n.event.at):`—`);return(e,t)=>(F(),L(O(AM),{class:T(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[fu(uu(o,[`prevent`]),[`enter`]),fu(uu(o,[`prevent`]),[`space`])]},{default:k(()=>[z(O($),{class:`font-medium`},{default:k(()=>[B(E(n.event.kind||n.event.type||`event`),1)]),_:1}),z(O($),{class:`font-mono`},{default:k(()=>[B(E(i.value>0?`#${i.value}`:`—`),1)]),_:1}),z(O($),{class:`w-[55%] max-w-0`},{default:k(()=>[R(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},E(a.value.text),9,FM)]),_:1}),z(O($),null,{default:k(()=>[B(E(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}});function LM(e,t){return`${e}:${t??0}`}function RM(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=LM(PM(n).text,r),a=t[t.length-1];if(a&&a.key===i){a.count+=1,a.events.push(n);continue}t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var zM={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},BM={class:`max-h-[28rem] overflow-y-auto`},VM=[`aria-expanded`,`aria-label`,`onClick`],HM=[`title`],UM=j({__name:`LiveActivityCard`,setup(e){let t=GD(),{activity:n,streamKind:r,streamState:i}=od(kA()),a=rn(new Set),o=U(()=>RM(n.value));function s(e){a.has(e)?a.delete(e):a.add(e)}function c(e){return a.has(e.key)}function l(e){return PM(e.representative)}function u(e){return e.representative.at?xj(e.representative.at):`—`}function d(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(F(),L(O(mj),null,{default:k(()=>[z(O(yj),null,{default:k(()=>[z(O(bj),null,{default:k(()=>[...t[0]||=[B(`Live activity`,-1)]]),_:1}),z(O(hj),null,{default:k(()=>[z(O(dj),{variant:O(r)},{default:k(()=>[B(E(O(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),z(O(gj),null,{default:k(()=>[R(`div`,zM,[R(`div`,BM,[z(O(OM),null,{default:k(()=>[z(O(MM),{class:`sticky top-0 z-10 bg-card`},{default:k(()=>[z(O(AM),null,{default:k(()=>[z(O(jM),null,{default:k(()=>[...t[1]||=[B(`Event`,-1)]]),_:1}),z(O(jM),null,{default:k(()=>[...t[2]||=[B(`Task`,-1)]]),_:1}),z(O(jM),null,{default:k(()=>[...t[3]||=[B(`Detail`,-1)]]),_:1}),z(O(jM),null,{default:k(()=>[...t[4]||=[B(`When`,-1)]]),_:1})]),_:1})]),_:1}),z(O(kM),null,{default:k(()=>[O(n).length?V(``,!0):(F(),L(O(AM),{key:0},{default:k(()=>[z(O($),{colspan:`4`},{default:k(()=>[z(O(rj),null,{default:k(()=>[z(O(oj),null,{default:k(()=>[z(O(lj),null,{default:k(()=>[...t[5]||=[B(`Waiting for activity`,-1)]]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),O(n).length?(F(!0),I(P,{key:1},M(o.value,e=>(F(),I(P,{key:e.key},[e.count===1?(F(),L(IM,{key:0,event:e.representative,onOpen:d},null,8,[`event`])):(F(),I(P,{key:1},[z(O(AM),{class:T(e.taskID>0?`cursor-pointer`:``),role:e.taskID>0?`link`:void 0,tabindex:e.taskID>0?0:void 0,title:e.taskID>0?`Open task details`:void 0,onClick:t=>e.taskID>0&&d(e.taskID),onKeydown:[fu(uu(t=>e.taskID>0&&d(e.taskID),[`prevent`]),[`enter`]),fu(uu(t=>e.taskID>0&&d(e.taskID),[`prevent`]),[`space`])]},{default:k(()=>[z(O($),{class:`font-medium`},{default:k(()=>[R(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":c(e),"aria-label":`${c(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:uu(t=>s(e.key),[`stop`])},[c(e)?(F(),L(O(Td),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(F(),L(O(Ed),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),B(` `+E(e.label)+` `,1),z(O(dj),{variant:`idle`},{default:k(()=>[B(`×`+E(e.count),1)]),_:2},1024)],8,VM)]),_:2},1024),z(O($),{class:`font-mono`},{default:k(()=>[B(E(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),z(O($),{class:`w-[55%] max-w-0`},{default:k(()=>[R(`span`,{class:`block truncate`,title:l(e).truncated?l(e).full:void 0},E(l(e).text),9,HM)]),_:2},1024),z(O($),null,{default:k(()=>[B(E(u(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),c(e)?(F(!0),I(P,{key:0},M(e.events,(t,n)=>(F(),L(IM,{key:`${e.key}:${n}`,event:t,onOpen:d},null,8,[`event`]))),128)):V(``,!0)],64))],64))),128)):V(``,!0)]),_:1})]),_:1})])])]),_:1})]),_:1}))}}),WM=j({__name:`Alert`,props:{class:{type:[Boolean,null,String,Object,Array]},variant:{}},setup(e){let t=e;return(n,r)=>(F(),I(`div`,{"data-slot":`alert`,class:T(O(K)(O(JM)({variant:e.variant}),t.class)),role:`alert`},[N(n.$slots,`default`)],2))}}),GM=j({__name:`AlertAction`,props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e;return(e,n)=>(F(),I(`div`,{"data-slot":`alert-action`,class:T(O(K)(`absolute top-2 right-2`,t.class))},[N(e.$slots,`default`)],2))}}),KM=j(
Line truncated
|
||||
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function GN(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function KN(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function qN(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function JN(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var YN=D([]),XN=D([]),ZN=D(!0),QN=D(null),$N=D(null),eP=D(!1),tP=D(null);async function nP(){try{let e=await q.eventTypes();ZN.value=e.enabled!==!1,YN.value=e.event_types||[],XN.value=e.proposals||[],QN.value=null}catch(e){QN.value=e.message||String(e)}}function rP(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function iP(e){tP.value=null,$N.value=e}function aP(e){let t=pP.value.find(t=>String(t.id)===e.sample_id);iP({mode:`proposal`,id:null,source:e.source,name:``,rule:rP(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function oP(e=``){iP({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function sP(e){iP({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:rP(e.rule),headersText:``,body:``,exampleHeaders:{}})}function cP(){$N.value=null}async function lP(){let e=$N.value;if(e){eP.value=!0;try{if(e.mode===`edit`&&e.id)await q.eventTypeUpdate(e.id,{name:e.name,rule:JN(e.rule)});else{let t=e.mode===`paste`?WN(e.headersText):e.exampleHeaders;await q.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:JN(e.rule),example:{headers:t,body:e.body}})}$N.value=null,await nP()}catch(e){tP.value=e.message||String(e)}finally{eP.value=!1}}}var uP=D(null);async function dP(){let e=uP.value;if(uP.value=null,e)try{await q.eventTypeDelete(e.id),await nP()}catch(e){QN.value=e.message||String(e)}}var fP=100,pP=D([]),mP=D(!0),hP=D(null),gP=D(!0),_P=D(null);async function vP(){try{let e=await q.captures(fP);mP.value=e.enabled!==!1,pP.value=e.captures||[],hP.value=null}catch(e){hP.value=e.message||String(e)}finally{gP.value=!1}}function yP(e){let t=pP.value.find(t=>t.id===e);return t&&(_P.value=t),!!t}function bP(){pP.value.length&&(_P.value=pP.value[0])}function xP(){AA(`captures`,()=>{vP(),nP()})}var SP=j({__name:`Tabs`,props:{defaultValue:{},orientation:{},dir:{},activationMode:{},modelValue:{},unmountOnHide:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,i=xg(Fw(n,`class`),r);return(e,t)=>(F(),L(O(HC),H({"data-slot":`tabs`,"data-orientation":O(i).orientation||`horizontal`},O(i),{class:O(K)(`gap-2 group/tabs flex data-horizontal:flex-col`,n.class)}),{default:k(t=>[N(e.$slots,`default`,we(Os(t)))]),_:3},16,[`data-orientation`,`class`]))}}),CP=j({__name:`TabsContent`,props:{value:{},forceMount:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=Fw(t,`class`);return(e,r)=>(F(),L(O(GC),H({"data-slot":`tabs-content`,class:O(K)(`text-sm flex-1 outline-none`,t.class)},O(n)),{default:k(()=>[N(e.$slots,`default`)]),_:3},16,[`class`]))}}),wP=j({__name:`TabsList`,props:{loop:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]},variant:{default:`default`}},setup(e){let t=e,n=Fw(t,`class`,`variant`);return(r,i)=>(F(),L(O(KC),H({"data-slot":`tabs-list`,"data-variant":e.variant},O(n),{class:O(K)(O(EP)({variant:e.variant}),t.class)}),{default:k(()=>[N(r.$slots,`default`)]),_:3},16,[`data-variant`,`class`]))}}),TP=j({__name:`TabsTrigger`,props:{value:{},disabled:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=bg(Fw(t,`class`));return(e,r)=>(F(),L(O(qC),H({"data-slot":`tabs-trigger`,class:O(K)(`gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg:not([class*=size-])]:size-4 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabledLine truncated
|
||||
@@ -0,0 +1,31 @@
|
||||
<script setup lang="ts">
|
||||
import { Paperclip } from "@lucide/vue";
|
||||
|
||||
import { mediaDetail, mediaLabel } from "./attachment";
|
||||
import type { ChatMedia } from "./state";
|
||||
|
||||
/**
|
||||
* One attachment a message carried, as the transcript shows it.
|
||||
*
|
||||
* The bytes are gone by design — they are turn-scoped and are stripped before
|
||||
* the record is stored — so this is a labelled chip rather than a preview. It
|
||||
* links out only when the attachment itself carried a URL; a platform file id
|
||||
* is deliberately never rendered, because it is a handle rather than an
|
||||
* address and a chip that 404s is worse than no chip.
|
||||
*/
|
||||
defineProps<{ attachment: ChatMedia }>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<component
|
||||
:is="attachment.url ? 'a' : 'span'"
|
||||
:href="attachment.url"
|
||||
:target="attachment.url ? '_blank' : undefined"
|
||||
:rel="attachment.url ? 'noopener noreferrer' : undefined"
|
||||
:title="mediaDetail(attachment)"
|
||||
class="inline-flex max-w-full items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 py-1 text-xs font-medium text-muted-foreground"
|
||||
>
|
||||
<Paperclip aria-hidden="true" class="size-3.5 shrink-0" />
|
||||
<span class="truncate">{{ mediaLabel(attachment) }}</span>
|
||||
</component>
|
||||
</template>
|
||||
@@ -1,8 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { cn } from "@/lib/utils";
|
||||
import ChatAttachment from "./ChatAttachment.vue";
|
||||
import ChatMarkdown from "./ChatMarkdown.vue";
|
||||
import ChatToolCall from "./ChatToolCall.vue";
|
||||
import type { ChatToolCall as ToolCall } from "./state";
|
||||
import type { ChatMedia, ChatToolCall as ToolCall } from "./state";
|
||||
|
||||
/**
|
||||
* One message, from either side of the conversation. There is no speaker
|
||||
@@ -14,11 +15,13 @@ withDefaults(
|
||||
defineProps<{
|
||||
text: string;
|
||||
tools?: ToolCall[];
|
||||
/** Attachments the message carried, which have no bytes left to render. */
|
||||
media?: ChatMedia[];
|
||||
assistant?: boolean;
|
||||
/** The turn is still arriving: a tool call with no outcome is running. */
|
||||
streaming?: boolean;
|
||||
}>(),
|
||||
{ tools: () => [], assistant: false, streaming: false },
|
||||
{ tools: () => [], media: () => [], assistant: false, streaming: false },
|
||||
);
|
||||
</script>
|
||||
|
||||
@@ -40,6 +43,13 @@ withDefaults(
|
||||
:streaming="streaming"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="media.length" class="mb-2 flex flex-wrap gap-1.5">
|
||||
<ChatAttachment
|
||||
v-for="(attachment, i) in media"
|
||||
:key="i"
|
||||
:attachment="attachment"
|
||||
/>
|
||||
</div>
|
||||
<ChatMarkdown v-if="assistant" :text="text" />
|
||||
<div v-else class="whitespace-pre-wrap">{{ text }}</div>
|
||||
<slot />
|
||||
|
||||
@@ -37,6 +37,9 @@ function parts(message: ChatMessage) {
|
||||
return {
|
||||
text: message.text ?? message.Text ?? "",
|
||||
tools: message.tool_calls || message.ToolCalls || [],
|
||||
// Attachments have no bytes left to render -- the record kept their
|
||||
// metadata only -- so the bubble labels them.
|
||||
media: message.media || [],
|
||||
assistant: from !== "web",
|
||||
};
|
||||
}
|
||||
@@ -63,6 +66,7 @@ const bubbles = computed(() => messages.value.map(parts));
|
||||
<ChatBubble
|
||||
:text="bubble.text"
|
||||
:tools="bubble.tools"
|
||||
:media="bubble.media"
|
||||
:assistant="bubble.assistant"
|
||||
/>
|
||||
</MessageScrollerItem>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import type { ChatMedia } from "./state";
|
||||
|
||||
/**
|
||||
* How a transcript renders an attachment whose bytes it does not have.
|
||||
*
|
||||
* The bytes are turn-scoped and never reach a browser, so the label stands in
|
||||
* for the file. It reuses the placeholder vocabulary the channels already
|
||||
* write into a message's text (`[photo]`, `[document: report.pdf]` — see the
|
||||
* notes in `internal/channels/telegram/inboundmedia.go`), so the same
|
||||
* attachment reads the same whether its metadata survived persistence or only
|
||||
* the note in its text did.
|
||||
*/
|
||||
export function mediaLabel(attachment: ChatMedia): string {
|
||||
switch (attachment.type) {
|
||||
case "image":
|
||||
return "[photo]";
|
||||
case "video":
|
||||
return "[video]";
|
||||
case "audio":
|
||||
return "[audio]";
|
||||
case "document":
|
||||
return attachment.file_name
|
||||
? `[document: ${attachment.file_name}]`
|
||||
: "[document]";
|
||||
default:
|
||||
return `[${attachment.type || "attachment"}]`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The metadata behind the label, for the chip's tooltip: mime type, file name,
|
||||
* size, dimensions and duration, in the order a reader asks about them.
|
||||
*
|
||||
* It reports only what the record actually carried, so an unknown size reads
|
||||
* as absent rather than as zero, and it never names the platform file id — a
|
||||
* handle is not information about the file.
|
||||
*/
|
||||
export function mediaDetail(attachment: ChatMedia): string {
|
||||
const parts: string[] = [];
|
||||
if (attachment.mime_type) parts.push(attachment.mime_type);
|
||||
if (attachment.file_name) parts.push(attachment.file_name);
|
||||
if (attachment.file_size !== undefined) {
|
||||
parts.push(`${attachment.file_size} bytes`);
|
||||
}
|
||||
if (attachment.width && attachment.height) {
|
||||
parts.push(`${attachment.width}×${attachment.height}`);
|
||||
}
|
||||
if (attachment.duration !== undefined) parts.push(`${attachment.duration} s`);
|
||||
return parts.join(" · ");
|
||||
}
|
||||
@@ -58,10 +58,31 @@ export interface ChatToolCall {
|
||||
err?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* One attachment a message carried, as a recorded transcript serves it. The
|
||||
* bytes are turn-scoped and never reach a browser, so this is metadata only;
|
||||
* `url` is present exactly when the attachment itself carried one, and a
|
||||
* platform file id never appears here because it is a handle, not an address.
|
||||
*/
|
||||
export interface ChatMedia {
|
||||
type: string;
|
||||
file_name?: string;
|
||||
mime_type?: string;
|
||||
file_size?: number;
|
||||
width?: number;
|
||||
height?: number;
|
||||
duration?: number;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
/** One message in the transcript, from either side. */
|
||||
export interface ChatMessage {
|
||||
from?: string;
|
||||
text?: string;
|
||||
// Attachments only ever arrive in the served transcript, never from this
|
||||
// browser's composer, so unlike the fields below this one has no second
|
||||
// spelling to read.
|
||||
media?: ChatMedia[];
|
||||
tool_calls?: ChatToolCall[];
|
||||
// The same view reaches the browser from more than one composition, so both
|
||||
// spellings are read rather than assuming one serialiser.
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
import { mediaDetail, mediaLabel, type ChatMedia } from "../src/chat/attachment.ts";
|
||||
|
||||
// The transcript cannot show an attachment's bytes -- they are turn-scoped and
|
||||
// never reach a browser -- so the label is the entire rendering. It reuses the
|
||||
// placeholder vocabulary the channels write into a message's text, so a photo
|
||||
// reads the same whether its metadata survived or only its note did.
|
||||
test("an attachment is labelled in the channel's own placeholder vocabulary", () => {
|
||||
const cases: Array<[ChatMedia, string]> = [
|
||||
[{ type: "image", mime_type: "image/jpeg" }, "[photo]"],
|
||||
[{ type: "video" }, "[video]"],
|
||||
[{ type: "audio" }, "[audio]"],
|
||||
[{ type: "document", file_name: "report.pdf" }, "[document: report.pdf]"],
|
||||
[{ type: "document" }, "[document]"],
|
||||
[{ type: "sticker" }, "[sticker]"],
|
||||
[{ type: "" }, "[attachment]"],
|
||||
];
|
||||
for (const [attachment, want] of cases) {
|
||||
assert.equal(mediaLabel(attachment), want, JSON.stringify(attachment));
|
||||
}
|
||||
});
|
||||
|
||||
// The label says what arrived; the detail says what is known about it, which
|
||||
// is the metadata persistence kept. Nothing here is fetchable, and nothing
|
||||
// here is invented from a file id.
|
||||
test("the detail names the metadata that survived persistence", () => {
|
||||
assert.equal(
|
||||
mediaDetail({
|
||||
type: "image",
|
||||
mime_type: "image/jpeg",
|
||||
file_name: "beach.jpg",
|
||||
file_size: 2024,
|
||||
width: 1280,
|
||||
height: 960,
|
||||
}),
|
||||
"image/jpeg · beach.jpg · 2024 bytes · 1280×960",
|
||||
);
|
||||
assert.equal(mediaDetail({ type: "audio", duration: 12 }), "12 s");
|
||||
assert.equal(mediaDetail({ type: "document" }), "");
|
||||
});
|
||||
|
||||
// A file id is a platform download handle, not an address: a chip that linked
|
||||
// it would 404. The chip links out only when the attachment itself carried a
|
||||
// URL, and the transcript reaches the label and the URL through this module.
|
||||
test("the transcript renders attachments from metadata, never from a file id", async () => {
|
||||
const chip = await readFile(
|
||||
new URL("../src/chat/ChatAttachment.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(chip, /mediaLabel\(attachment\)/, "the chip shows the label");
|
||||
assert.match(chip, /mediaDetail\(attachment\)/, "the chip carries the metadata detail");
|
||||
assert.match(chip, /:href="attachment\.url"/, "the only link target is a URL the attachment had");
|
||||
assert.doesNotMatch(chip, /file_?id/i, "a file id is a handle, not a link target");
|
||||
|
||||
const bubble = await readFile(
|
||||
new URL("../src/chat/ChatBubble.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(bubble, /ChatAttachment/, "the bubble renders the attachment chips");
|
||||
|
||||
const transcript = await readFile(
|
||||
new URL("../src/chat/ChatTranscript.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(
|
||||
transcript,
|
||||
/media: message\.media \|\| \[\]/,
|
||||
"a recorded message's attachments reach the bubble",
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user