sliccy 2.49.4 → 2.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/ui/assets/{adobe-BepyDpQ7.js → adobe-DVwtzHxI.js} +1 -1
  2. package/dist/ui/assets/{adobe-BAbfJ3VU.js → adobe-VlJOhvPz.js} +1 -1
  3. package/dist/ui/assets/{agent-bridge-oJLo-WsG.js → agent-bridge-DsHLDU8V.js} +1 -1
  4. package/dist/ui/assets/{agent-message-to-chat-Cdz7eRwR.js → agent-message-to-chat-C6dml3OW.js} +1 -1
  5. package/dist/ui/assets/{azure-openai-B5YYIt3L.js → azure-openai-B8qTt0Fr.js} +1 -1
  6. package/dist/ui/assets/{azure-openai-DRDj59nu.js → azure-openai-CAsn2pUF.js} +1 -1
  7. package/dist/ui/assets/{cdp-pA9QGfop.js → cdp-DKSAtFO4.js} +4 -4
  8. package/dist/ui/assets/cost-command-CZfmQkvX.js +1 -0
  9. package/dist/ui/assets/{es-CcOiqWcA.js → es-BraVol3C.js} +1 -1
  10. package/dist/ui/assets/{fs-Cn7es-Jw.js → fs-CT7Y5NS0.js} +2 -2
  11. package/dist/ui/assets/{fs-DC7gcGTF.js → fs-s0F9YT_h.js} +1 -1
  12. package/dist/ui/assets/{github-DGXTjlte.js → github-C1HESy2C.js} +2 -2
  13. package/dist/ui/assets/{github-DXq11u4_.js → github-CBcAkmch.js} +1 -1
  14. package/dist/ui/assets/index-Cv13fIWN.js +1532 -0
  15. package/dist/ui/assets/{kernel-worker-CXKRu-lG.js → kernel-worker-CqyRKXBm.js} +10 -10
  16. package/dist/ui/assets/{local-llm-DD6tVT9A.js → local-llm-Cy8fUfwX.js} +1 -1
  17. package/dist/ui/assets/{local-llm-BlR-3H6h.js → local-llm-DTDLm5Sb.js} +1 -1
  18. package/dist/ui/assets/{magick-wasm-D1ZSe8nx.js → magick-wasm-BbaIA46K.js} +1 -1
  19. package/dist/ui/assets/{mount-CnCwwrLA.js → mount-D8M77aD2.js} +1 -1
  20. package/dist/ui/assets/{mount-D-ja8mOy.js → mount-DqdX0aJz.js} +2 -2
  21. package/dist/ui/assets/{nuke-command-BKOoyi54.js → nuke-command-BmCQQFws.js} +1 -1
  22. package/dist/ui/assets/{oauth-bootstrap-DF8lEhXL.js → oauth-bootstrap-rwNGPidZ.js} +1 -1
  23. package/dist/ui/assets/{oauth-service-Cipuy1zY.js → oauth-service-Jx8rqyjf.js} +1 -1
  24. package/dist/ui/assets/offscreen-client-NKbRDPeW.js +1 -0
  25. package/dist/ui/assets/{onboarding-orchestrator-BBOlbDGd.js → onboarding-orchestrator-DoO86elX.js} +1 -1
  26. package/dist/ui/assets/provider-settings-CWTeejO7.js +28 -0
  27. package/dist/ui/assets/{provider-settings-BxlLfcdq.js → provider-settings-Fm4AIIxK.js} +1 -1
  28. package/dist/ui/assets/{providers-B1u4aCVl.js → providers-FGQY_gVN.js} +1 -1
  29. package/dist/ui/assets/{spawn-DN2Az-yw.js → spawn-DYz9wTw2.js} +1 -1
  30. package/dist/ui/assets/tray-follower-status-DKq8RTLd.js +1 -0
  31. package/dist/ui/assets/{upgrade-detection-D4h85CJ5.js → upgrade-detection-CFxvnEBe.js} +1 -1
  32. package/dist/ui/electron-overlay-entry.js +5 -5
  33. package/dist/ui/index.html +5 -5
  34. package/dist/ui/packages/webapp/index.html +5 -5
  35. package/package.json +2 -2
  36. package/dist/ui/assets/cost-command-BzJDVRG1.js +0 -1
  37. package/dist/ui/assets/index-DSq-sjeA.js +0 -1532
  38. package/dist/ui/assets/offscreen-client-Rc4LkSrq.js +0 -1
  39. package/dist/ui/assets/provider-settings-CvswCVqz.js +0 -28
  40. package/dist/ui/assets/tray-follower-status-Bjjx7UWt.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./chunk-jRWAZmH_.js";import{i as t}from"./backend-local-P05Hg6Af.js";import{t as n}from"./mime-types-DVkB7Eq7.js";import{t as r}from"./remote-cache-DdfqyJ2A.js";function i(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var a=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=i(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new t(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);if(r&&!this.cache.isStale(r.cachedAt))return r.body;let i={};r&&(i[`if-none-match`]=r.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i});if(a.status===304&&r)return await this.cache.putBody(n,r.body,r.etag),r.body;if(a.status===404)throw await this.cache.invalidateBody(n),new t(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new t(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new t(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(n,c,l),c}async writeFile(e,n){this.assertOpen(e);let r=this.toMountRelative(e);if(n.byteLength>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=await this.cache.getBody(r),a={"content-type":`application/octet-stream`,"content-length":String(n.byteLength)};i?a[`if-match`]=i.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(r),headers:a,body:n}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let i=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(r)});if(i.status>=400)throw new t(`EIO`,`s3 reconcile HEAD failed: ${i.status}`,e);let a=i.headers.get(`etag`)??``;await this.cache.putBody(r,n,a);let o=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new t(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new t(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new t(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(r,n,l);let u=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],n;do{let r={"list-type":`2`};this.parsed.prefix&&(r.prefix=`${this.parsed.prefix}/`),n&&(r[`continuation-token`]=n);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:r});if(i.status>=400)throw new t(`EIO`,`s3 list failed: ${i.status}`,`/`);let a=await i.text(),o=this.parseListingXml(a);e.push(...o.contents),n=o.nextContinuationToken}while(n);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);if(r)return{kind:`file`,size:r.body.byteLength,mtime:r.cachedAt,etag:r.etag};let i=n.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let n=s.entries.find(e=>e.name===a);if(n?.kind===`file`&&n.size!==void 0)return{kind:`file`,size:n.size,mtime:n.lastModified??s.cachedAt,etag:n.etag??``};if(n?.kind===`directory`)return{kind:`directory`,size:0,mtime:n.lastModified??s.cachedAt};if(!n)throw new t(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let r=await this.cache.getListing(n);if(r)return{kind:`directory`,size:0,mtime:r.cachedAt};throw new t(`ENOENT`,`no such file or directory`,e)}throw new t(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,n){this.assertOpen(e);let r=this.toMountRelative(e);if(n?.recursive)throw new t(`EINVAL`,`recursive remove not yet supported on S3`,e);let i=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(r)});if(i.status===404)throw new t(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new t(`EACCES`,`s3 delete denied`,e);if(i.status>=400)throw new t(`EIO`,`s3 delete failed: ${i.status}`,e);await this.cache.invalidateBody(r);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function o(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function s(e){return e.split(`/`).pop()||`data`}function c(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var l=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=c(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new t(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);if(r&&!this.cache.isStale(r.cachedAt))return r.body;let i={};r&&(i[`if-none-match`]=r.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(n),headers:i});if(a.status===304&&r)return await this.cache.putBody(n,r.body,r.etag),r.body;if(a.status===404)throw await this.cache.invalidateBody(n),new t(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new t(`EACCES`,`da access denied`,e);if(a.status>=400)throw new t(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(n,c,l),c}async writeFile(e,r){if(this.assertOpen(e),r.byteLength>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=this.toMountRelative(e),a=await this.cache.getBody(i),c=o(s(e),n(e),r),l={"content-type":c.contentType,"content-length":String(c.body.byteLength)};a&&a.etag?l[`if-match`]=a.etag:a||(l[`if-none-match`]=`*`);let u=()=>this.transport({method:`POST`,path:this.toSourcePath(i),headers:l,body:c.body}),d,f=1;try{d=await u()}catch{f=2,d=await u()}if(d.status===412){if(f===2){let n=await this.transport({method:`HEAD`,path:this.toSourcePath(i)});if(n.status>=400)throw new t(`EIO`,`da reconcile HEAD failed: ${n.status}`,e);let a=n.headers.get(`etag`)??``;await this.cache.putBody(i,r,a);let o=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(i);try{await this.readFile(e)}catch{}throw new t(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(d.status===401||d.status===403)throw new t(`EACCES`,`da write denied`,e);if(d.status>=400)throw new t(`EIO`,`da writeFile failed: ${d.status}`,e);let p=d.headers.get(`etag`)??``;await this.cache.putBody(i,r,p);let m=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}async readDir(e){this.assertOpen(e);let n=this.toMountRelative(e).replace(/\/+$/,``),r=await this.cache.getListing(n);if(r&&!this.cache.isStale(r.cachedAt))return r.entries;let i=await this.transport({method:`GET`,path:this.toListPath(n)});if(i.status===404)throw new t(`ENOENT`,`no such directory`,e);if(i.status>=400)throw new t(`EIO`,`da list failed: ${i.status}`,e);let a=(await i.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(n,a),a}async stat(e){this.assertOpen(e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);if(r)return{kind:`file`,size:r.size,mtime:r.cachedAt,etag:r.etag};let i=n.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let n=s.entries.find(e=>e.name===a);if(n?.kind===`file`&&n.size!==void 0)return{kind:`file`,size:n.size,mtime:n.lastModified??s.cachedAt,etag:n.etag??``};if(n?.kind===`directory`)return{kind:`directory`,size:0,mtime:n.lastModified??s.cachedAt};if(!n)throw new t(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let r=await this.cache.getListing(n);if(r)return{kind:`directory`,size:0,mtime:r.cachedAt};throw new t(`ENOENT`,`no such file or directory`,e)}throw new t(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let n=this.toMountRelative(e),r=await this.transport({method:`DELETE`,path:this.toSourcePath(n)});if(r.status===404)throw new t(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new t(`EACCES`,`da delete denied`,e);if(r.status>=400)throw new t(`EIO`,`da delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});continue}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified});let i=await this.cache.getBody(n);i?r.etag&&i.etag!==r.etag?(await this.cache.invalidateBody(n),t.changed.push(n)):t.unchanged++:t.added.push(n)}else{a.push({name:r.name,kind:`directory`});let t=e?`${e}/${r.name}`:r.name;n.push(t)}await this.cache.putListing(e,a)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}if(e?.bodies)for(let e of t.changed)try{await this.readFile(e)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}return t}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},u=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function d(){let{getAccounts:e}=await import(`./provider-settings-BxlLfcdq.js`).then(e=>e.l),t=e().find(e=>e.providerId===`adobe`);if(!t||!t.accessToken)throw new u(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}function f(){return typeof chrome<`u`&&!!chrome?.runtime?.id}function p(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function m(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}const h=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),g=new Set([101,103,204,205,304]);function _(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new t(`EACCES`,e.error):e.errorCode===`invalid_request`?new t(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||h.has(String(e.errorCode))?new t(`EIO`,e.error):new t(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let n;try{n=p(e.bodyBase64)}catch(e){throw new t(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let r=g.has(e.status)?null:n;return new Response(r,{status:e.status,headers:new Headers(e.headers)})}async function v(e,n){let r;try{r=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)})}catch(e){throw new t(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await r.json()}catch(e){throw new t(`EIO`,`mount transport: response is not a JSON envelope (status ${r.status}): ${e instanceof Error?e.message:String(e)}`)}}async function y(e,n){try{return await chrome.runtime.sendMessage({type:e,envelope:n})}catch(e){throw new t(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}function b(e){return async t=>{let n={profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?m(t.body):void 0};return _(f()?await y(`mount.s3-sign-and-forward`,n):await v(`/api/s3-sign-and-forward`,n))}}function x(e){let n=e?.getImsToken??(async()=>(await d()).getBearerToken());return async e=>{let r;try{r=await n()}catch(e){throw new t(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}let i={imsToken:r,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?m(e.body):void 0};return _(f()?await y(`mount.da-sign-and-forward`,i):await v(`/api/da-sign-and-forward`,i))}}var S=e({DaMountBackend:()=>l,RemoteMountCache:()=>r,S3MountBackend:()=>a,makeSignedFetchDa:()=>x,makeSignedFetchS3:()=>b});export{a,l as i,x as n,b as r,S as t};
1
+ import{r as e}from"./chunk-jRWAZmH_.js";import{i as t}from"./backend-local-P05Hg6Af.js";import{t as n}from"./mime-types-DVkB7Eq7.js";import{t as r}from"./remote-cache-DdfqyJ2A.js";function i(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var a=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=i(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new t(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);if(r&&!this.cache.isStale(r.cachedAt))return r.body;let i={};r&&(i[`if-none-match`]=r.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i});if(a.status===304&&r)return await this.cache.putBody(n,r.body,r.etag),r.body;if(a.status===404)throw await this.cache.invalidateBody(n),new t(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new t(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new t(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(n,c,l),c}async writeFile(e,n){this.assertOpen(e);let r=this.toMountRelative(e);if(n.byteLength>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=await this.cache.getBody(r),a={"content-type":`application/octet-stream`,"content-length":String(n.byteLength)};i?a[`if-match`]=i.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(r),headers:a,body:n}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let i=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(r)});if(i.status>=400)throw new t(`EIO`,`s3 reconcile HEAD failed: ${i.status}`,e);let a=i.headers.get(`etag`)??``;await this.cache.putBody(r,n,a);let o=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new t(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new t(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new t(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(r,n,l);let u=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],n;do{let r={"list-type":`2`};this.parsed.prefix&&(r.prefix=`${this.parsed.prefix}/`),n&&(r[`continuation-token`]=n);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:r});if(i.status>=400)throw new t(`EIO`,`s3 list failed: ${i.status}`,`/`);let a=await i.text(),o=this.parseListingXml(a);e.push(...o.contents),n=o.nextContinuationToken}while(n);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);if(r)return{kind:`file`,size:r.body.byteLength,mtime:r.cachedAt,etag:r.etag};let i=n.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let n=s.entries.find(e=>e.name===a);if(n?.kind===`file`&&n.size!==void 0)return{kind:`file`,size:n.size,mtime:n.lastModified??s.cachedAt,etag:n.etag??``};if(n?.kind===`directory`)return{kind:`directory`,size:0,mtime:n.lastModified??s.cachedAt};if(!n)throw new t(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let r=await this.cache.getListing(n);if(r)return{kind:`directory`,size:0,mtime:r.cachedAt};throw new t(`ENOENT`,`no such file or directory`,e)}throw new t(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,n){this.assertOpen(e);let r=this.toMountRelative(e);if(n?.recursive)throw new t(`EINVAL`,`recursive remove not yet supported on S3`,e);let i=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(r)});if(i.status===404)throw new t(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new t(`EACCES`,`s3 delete denied`,e);if(i.status>=400)throw new t(`EIO`,`s3 delete failed: ${i.status}`,e);await this.cache.invalidateBody(r);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function o(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function s(e){return e.split(`/`).pop()||`data`}function c(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var l=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=c(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new t(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);if(r&&!this.cache.isStale(r.cachedAt))return r.body;let i={};r&&(i[`if-none-match`]=r.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(n),headers:i});if(a.status===304&&r)return await this.cache.putBody(n,r.body,r.etag),r.body;if(a.status===404)throw await this.cache.invalidateBody(n),new t(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new t(`EACCES`,`da access denied`,e);if(a.status>=400)throw new t(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(n,c,l),c}async writeFile(e,r){if(this.assertOpen(e),r.byteLength>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=this.toMountRelative(e),a=await this.cache.getBody(i),c=o(s(e),n(e),r),l={"content-type":c.contentType,"content-length":String(c.body.byteLength)};a&&a.etag?l[`if-match`]=a.etag:a||(l[`if-none-match`]=`*`);let u=()=>this.transport({method:`POST`,path:this.toSourcePath(i),headers:l,body:c.body}),d,f=1;try{d=await u()}catch{f=2,d=await u()}if(d.status===412){if(f===2){let n=await this.transport({method:`HEAD`,path:this.toSourcePath(i)});if(n.status>=400)throw new t(`EIO`,`da reconcile HEAD failed: ${n.status}`,e);let a=n.headers.get(`etag`)??``;await this.cache.putBody(i,r,a);let o=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(i);try{await this.readFile(e)}catch{}throw new t(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(d.status===401||d.status===403)throw new t(`EACCES`,`da write denied`,e);if(d.status>=400)throw new t(`EIO`,`da writeFile failed: ${d.status}`,e);let p=d.headers.get(`etag`)??``;await this.cache.putBody(i,r,p);let m=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}async readDir(e){this.assertOpen(e);let n=this.toMountRelative(e).replace(/\/+$/,``),r=await this.cache.getListing(n);if(r&&!this.cache.isStale(r.cachedAt))return r.entries;let i=await this.transport({method:`GET`,path:this.toListPath(n)});if(i.status===404)throw new t(`ENOENT`,`no such directory`,e);if(i.status>=400)throw new t(`EIO`,`da list failed: ${i.status}`,e);let a=(await i.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(n,a),a}async stat(e){this.assertOpen(e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);if(r)return{kind:`file`,size:r.size,mtime:r.cachedAt,etag:r.etag};let i=n.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let n=s.entries.find(e=>e.name===a);if(n?.kind===`file`&&n.size!==void 0)return{kind:`file`,size:n.size,mtime:n.lastModified??s.cachedAt,etag:n.etag??``};if(n?.kind===`directory`)return{kind:`directory`,size:0,mtime:n.lastModified??s.cachedAt};if(!n)throw new t(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let r=await this.cache.getListing(n);if(r)return{kind:`directory`,size:0,mtime:r.cachedAt};throw new t(`ENOENT`,`no such file or directory`,e)}throw new t(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let n=this.toMountRelative(e),r=await this.transport({method:`DELETE`,path:this.toSourcePath(n)});if(r.status===404)throw new t(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new t(`EACCES`,`da delete denied`,e);if(r.status>=400)throw new t(`EIO`,`da delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});continue}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified});let i=await this.cache.getBody(n);i?r.etag&&i.etag!==r.etag?(await this.cache.invalidateBody(n),t.changed.push(n)):t.unchanged++:t.added.push(n)}else{a.push({name:r.name,kind:`directory`});let t=e?`${e}/${r.name}`:r.name;n.push(t)}await this.cache.putListing(e,a)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}if(e?.bodies)for(let e of t.changed)try{await this.readFile(e)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}return t}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},u=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function d(){let{getAccounts:e}=await import(`./provider-settings-Fm4AIIxK.js`).then(e=>e.l),t=e().find(e=>e.providerId===`adobe`);if(!t||!t.accessToken)throw new u(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}function f(){return typeof chrome<`u`&&!!chrome?.runtime?.id}function p(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function m(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}const h=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),g=new Set([101,103,204,205,304]);function _(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new t(`EACCES`,e.error):e.errorCode===`invalid_request`?new t(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||h.has(String(e.errorCode))?new t(`EIO`,e.error):new t(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let n;try{n=p(e.bodyBase64)}catch(e){throw new t(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let r=g.has(e.status)?null:n;return new Response(r,{status:e.status,headers:new Headers(e.headers)})}async function v(e,n){let r;try{r=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)})}catch(e){throw new t(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await r.json()}catch(e){throw new t(`EIO`,`mount transport: response is not a JSON envelope (status ${r.status}): ${e instanceof Error?e.message:String(e)}`)}}async function y(e,n){try{return await chrome.runtime.sendMessage({type:e,envelope:n})}catch(e){throw new t(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}function b(e){return async t=>{let n={profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?m(t.body):void 0};return _(f()?await y(`mount.s3-sign-and-forward`,n):await v(`/api/s3-sign-and-forward`,n))}}function x(e){let n=e?.getImsToken??(async()=>(await d()).getBearerToken());return async e=>{let r;try{r=await n()}catch(e){throw new t(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}let i={imsToken:r,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?m(e.body):void 0};return _(f()?await y(`mount.da-sign-and-forward`,i):await v(`/api/da-sign-and-forward`,i))}}var S=e({DaMountBackend:()=>l,RemoteMountCache:()=>r,S3MountBackend:()=>a,makeSignedFetchDa:()=>x,makeSignedFetchS3:()=>b});export{a,l as i,x as n,b as r,S as t};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-settings-CvswCVqz.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-ca-nBW7U.js","assets/bedrock-camp-CqXHYC67.js","assets/env-api-keys-DxKb6C4Q.js","assets/simple-options-imi_RHvn.js","assets/json-parse-C5jSA6JB.js","assets/tray-follower-status-Bjjx7UWt.js","assets/logger-B-No_qN_.js","assets/tool-ui-B3Bihlxa.js","assets/telemetry-B7l3TtVP.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./chunk-jRWAZmH_.js";import{t}from"./mime-types-DL940yDZ.js";import{t as n}from"./preload-helper-ca-nBW7U.js";import{r}from"./backend-local-mju0Ps5U.js";var i=`slicc-mount-cache`,a=`listings`,o=`bodies`,s=class{mountId;ttlMs;dbName;dbPromise=null;constructor(e){this.mountId=e.mountId,this.ttlMs=e.ttlMs,this.dbName=e.dbName??i}isStale(e,t){return Date.now()-e>=(t??this.ttlMs)}async openDb(){return this.dbPromise||=new Promise((e,t)=>{let n=indexedDB.open(this.dbName,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(a)||e.createObjectStore(a),e.objectStoreNames.contains(o)||e.createObjectStore(o)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),this.dbPromise}key(e){return`${this.mountId}::${e}`}async getListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(a,`readonly`).objectStore(a).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putListing(e,t){let n=await this.openDb();return new Promise((r,i)=>{let o=n.transaction(a,`readwrite`),s={entries:t,cachedAt:Date.now()};o.objectStore(a).put(s,this.key(e)),o.oncomplete=()=>r(),o.onerror=()=>i(o.error)})}async invalidateListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(a,`readwrite`);i.objectStore(a).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async getBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(o,`readonly`).objectStore(o).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putBody(e,t,n){let r=await this.openDb(),i={body:t,etag:n,size:t.byteLength,cachedAt:Date.now()};try{await this.txPut(r,o,this.key(e),i)}catch(t){if(t instanceof DOMException&&t.name===`QuotaExceededError`){await this.evictLru(.25);try{await this.txPut(r,o,this.key(e),i)}catch{}return}throw t}}async invalidateBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(o,`readwrite`);i.objectStore(o).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async clearMount(){let e=await this.openDb(),t=`${this.mountId}::`,n=n=>new Promise((r,i)=>{let a=e.transaction(n,`readwrite`),o=a.objectStore(n),s=o.getAllKeys();s.onsuccess=()=>{for(let e of s.result)typeof e==`string`&&e.startsWith(t)&&o.delete(e)},a.oncomplete=()=>r(),a.onerror=()=>i(a.error)});await Promise.all([n(a),n(o)])}txPut(e,t,n,r){return new Promise((i,a)=>{let o=e.transaction(t,`readwrite`);o.objectStore(t).put(r,n),o.oncomplete=()=>i(),o.onerror=()=>a(o.error)})}async evictLru(e){let t=await this.openDb(),n=`${this.mountId}::`,r=await new Promise((e,r)=>{let i=t.transaction(o,`readonly`).objectStore(o),a=[],s=i.openCursor();s.onsuccess=()=>{let t=s.result;if(!t){e(a);return}if(typeof t.key==`string`&&t.key.startsWith(n)){let e=t.value;a.push({key:t.key,cachedAt:e.cachedAt})}t.continue()},s.onerror=()=>r(s.error)});r.sort((e,t)=>e.cachedAt-t.cachedAt);let i=Math.max(1,Math.ceil(r.length*e)),a=r.slice(0,i);await new Promise((e,n)=>{let r=t.transaction(o,`readwrite`),i=r.objectStore(o);for(let{key:e}of a)i.delete(e);r.oncomplete=()=>e(),r.onerror=()=>n(r.error)})}},c=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function l(){let{getAccounts:e}=await n(async()=>{let{getAccounts:e}=await import(`./provider-settings-CvswCVqz.js`).then(e=>e.m);return{getAccounts:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),t=e().find(e=>e.providerId===`adobe`);if(!t||!t.accessToken)throw new c(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}function u(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var d=25*1024*1024,f=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=u(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??d,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new r(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let i={};n&&(i[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:i});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new r(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new r(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new r(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};i?a[`if-match`]=i.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let i=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(i.status>=400)throw new r(`EIO`,`s3 reconcile HEAD failed: ${i.status}`,e);let a=i.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new r(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new r(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new r(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(i.status>=400)throw new r(`EIO`,`s3 list failed: ${i.status}`,`/`);let a=await i.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new r(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new r(`ENOENT`,`no such file or directory`,e)}throw new r(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new r(`EINVAL`,`recursive remove not yet supported on S3`,e);let i=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(i.status===404)throw new r(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new r(`EACCES`,`s3 delete denied`,e);if(i.status>=400)throw new r(`EIO`,`s3 delete failed: ${i.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function p(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function m(e){return e.split(`/`).pop()||`data`}function h(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var g=5*1024*1024,_=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=h(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??g,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new r(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let i={};n&&(i[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:i});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new r(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new r(`EACCES`,`da access denied`,e);if(a.status>=400)throw new r(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=this.toMountRelative(e),a=await this.cache.getBody(i),o=p(m(e),t(e),n),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a&&a.etag?s[`if-match`]=a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(i),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(i)});if(t.status>=400)throw new r(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let a=t.headers.get(`etag`)??``;await this.cache.putBody(i,n,a);let o=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(i);try{await this.readFile(e)}catch{}throw new r(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new r(`EACCES`,`da write denied`,e);if(l.status>=400)throw new r(`EIO`,`da writeFile failed: ${l.status}`,e);let d=l.headers.get(`etag`)??``;await this.cache.putBody(i,n,d);let f=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(f)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let i=await this.transport({method:`GET`,path:this.toListPath(t)});if(i.status===404)throw new r(`ENOENT`,`no such directory`,e);if(i.status>=400)throw new r(`EIO`,`da list failed: ${i.status}`,e);let a=(await i.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new r(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new r(`ENOENT`,`no such file or directory`,e)}throw new r(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new r(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new r(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new r(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let i=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});continue}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified});let i=await this.cache.getBody(n);i?r.etag&&i.etag!==r.etag?(await this.cache.invalidateBody(n),t.changed.push(n)):t.unchanged++:t.added.push(n)}else{a.push({name:r.name,kind:`directory`});let t=e?`${e}/${r.name}`:r.name;n.push(t)}await this.cache.putListing(e,a)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}if(e?.bodies)for(let e of t.changed)try{await this.readFile(e)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}return t}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function v(){return typeof chrome<`u`&&!!chrome?.runtime?.id}function y(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function b(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}var x=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),S=new Set([101,103,204,205,304]);function C(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new r(`EACCES`,e.error):e.errorCode===`invalid_request`?new r(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||x.has(String(e.errorCode))?new r(`EIO`,e.error):new r(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=y(e.bodyBase64)}catch(e){throw new r(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=S.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function w(e,t){let n;try{n=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)})}catch(e){throw new r(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new r(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function T(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new r(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}function E(e){return async t=>{let n={profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?b(t.body):void 0};return C(v()?await T(`mount.s3-sign-and-forward`,n):await w(`/api/s3-sign-and-forward`,n))}}function D(e){let t=e?.getImsToken??(async()=>(await l()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new r(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}let i={imsToken:n,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?b(e.body):void 0};return C(v()?await T(`mount.da-sign-and-forward`,i):await w(`/api/da-sign-and-forward`,i))}}var O=e({DaMountBackend:()=>_,RemoteMountCache:()=>s,S3MountBackend:()=>f,makeSignedFetchDa:()=>D,makeSignedFetchS3:()=>E});export{f as a,_ as i,D as n,s as o,E as r,O as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-settings-CWTeejO7.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-ca-nBW7U.js","assets/bedrock-camp-CqXHYC67.js","assets/env-api-keys-DxKb6C4Q.js","assets/simple-options-imi_RHvn.js","assets/json-parse-C5jSA6JB.js","assets/tray-follower-status-DKq8RTLd.js","assets/logger-B-No_qN_.js","assets/tool-ui-B3Bihlxa.js","assets/telemetry-B7l3TtVP.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./chunk-jRWAZmH_.js";import{t}from"./mime-types-DL940yDZ.js";import{t as n}from"./preload-helper-ca-nBW7U.js";import{r}from"./backend-local-mju0Ps5U.js";var i=`slicc-mount-cache`,a=`listings`,o=`bodies`,s=class{mountId;ttlMs;dbName;dbPromise=null;constructor(e){this.mountId=e.mountId,this.ttlMs=e.ttlMs,this.dbName=e.dbName??i}isStale(e,t){return Date.now()-e>=(t??this.ttlMs)}async openDb(){return this.dbPromise||=new Promise((e,t)=>{let n=indexedDB.open(this.dbName,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(a)||e.createObjectStore(a),e.objectStoreNames.contains(o)||e.createObjectStore(o)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),this.dbPromise}key(e){return`${this.mountId}::${e}`}async getListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(a,`readonly`).objectStore(a).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putListing(e,t){let n=await this.openDb();return new Promise((r,i)=>{let o=n.transaction(a,`readwrite`),s={entries:t,cachedAt:Date.now()};o.objectStore(a).put(s,this.key(e)),o.oncomplete=()=>r(),o.onerror=()=>i(o.error)})}async invalidateListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(a,`readwrite`);i.objectStore(a).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async getBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(o,`readonly`).objectStore(o).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putBody(e,t,n){let r=await this.openDb(),i={body:t,etag:n,size:t.byteLength,cachedAt:Date.now()};try{await this.txPut(r,o,this.key(e),i)}catch(t){if(t instanceof DOMException&&t.name===`QuotaExceededError`){await this.evictLru(.25);try{await this.txPut(r,o,this.key(e),i)}catch{}return}throw t}}async invalidateBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(o,`readwrite`);i.objectStore(o).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async clearMount(){let e=await this.openDb(),t=`${this.mountId}::`,n=n=>new Promise((r,i)=>{let a=e.transaction(n,`readwrite`),o=a.objectStore(n),s=o.getAllKeys();s.onsuccess=()=>{for(let e of s.result)typeof e==`string`&&e.startsWith(t)&&o.delete(e)},a.oncomplete=()=>r(),a.onerror=()=>i(a.error)});await Promise.all([n(a),n(o)])}txPut(e,t,n,r){return new Promise((i,a)=>{let o=e.transaction(t,`readwrite`);o.objectStore(t).put(r,n),o.oncomplete=()=>i(),o.onerror=()=>a(o.error)})}async evictLru(e){let t=await this.openDb(),n=`${this.mountId}::`,r=await new Promise((e,r)=>{let i=t.transaction(o,`readonly`).objectStore(o),a=[],s=i.openCursor();s.onsuccess=()=>{let t=s.result;if(!t){e(a);return}if(typeof t.key==`string`&&t.key.startsWith(n)){let e=t.value;a.push({key:t.key,cachedAt:e.cachedAt})}t.continue()},s.onerror=()=>r(s.error)});r.sort((e,t)=>e.cachedAt-t.cachedAt);let i=Math.max(1,Math.ceil(r.length*e)),a=r.slice(0,i);await new Promise((e,n)=>{let r=t.transaction(o,`readwrite`),i=r.objectStore(o);for(let{key:e}of a)i.delete(e);r.oncomplete=()=>e(),r.onerror=()=>n(r.error)})}},c=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function l(){let{getAccounts:e}=await n(async()=>{let{getAccounts:e}=await import(`./provider-settings-CWTeejO7.js`).then(e=>e.m);return{getAccounts:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),t=e().find(e=>e.providerId===`adobe`);if(!t||!t.accessToken)throw new c(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}function u(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var d=25*1024*1024,f=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=u(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??d,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new r(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let i={};n&&(i[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:i});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new r(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new r(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new r(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};i?a[`if-match`]=i.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let i=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(i.status>=400)throw new r(`EIO`,`s3 reconcile HEAD failed: ${i.status}`,e);let a=i.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new r(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new r(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new r(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(i.status>=400)throw new r(`EIO`,`s3 list failed: ${i.status}`,`/`);let a=await i.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new r(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new r(`ENOENT`,`no such file or directory`,e)}throw new r(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new r(`EINVAL`,`recursive remove not yet supported on S3`,e);let i=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(i.status===404)throw new r(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new r(`EACCES`,`s3 delete denied`,e);if(i.status>=400)throw new r(`EIO`,`s3 delete failed: ${i.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function p(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function m(e){return e.split(`/`).pop()||`data`}function h(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var g=5*1024*1024,_=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=h(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??g,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new r(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let i={};n&&(i[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:i});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new r(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new r(`EACCES`,`da access denied`,e);if(a.status>=400)throw new r(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=this.toMountRelative(e),a=await this.cache.getBody(i),o=p(m(e),t(e),n),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a&&a.etag?s[`if-match`]=a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(i),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(i)});if(t.status>=400)throw new r(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let a=t.headers.get(`etag`)??``;await this.cache.putBody(i,n,a);let o=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(i);try{await this.readFile(e)}catch{}throw new r(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new r(`EACCES`,`da write denied`,e);if(l.status>=400)throw new r(`EIO`,`da writeFile failed: ${l.status}`,e);let d=l.headers.get(`etag`)??``;await this.cache.putBody(i,n,d);let f=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(f)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let i=await this.transport({method:`GET`,path:this.toListPath(t)});if(i.status===404)throw new r(`ENOENT`,`no such directory`,e);if(i.status>=400)throw new r(`EIO`,`da list failed: ${i.status}`,e);let a=(await i.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new r(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new r(`ENOENT`,`no such file or directory`,e)}throw new r(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new r(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new r(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new r(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let i=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});continue}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified});let i=await this.cache.getBody(n);i?r.etag&&i.etag!==r.etag?(await this.cache.invalidateBody(n),t.changed.push(n)):t.unchanged++:t.added.push(n)}else{a.push({name:r.name,kind:`directory`});let t=e?`${e}/${r.name}`:r.name;n.push(t)}await this.cache.putListing(e,a)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}if(e?.bodies)for(let e of t.changed)try{await this.readFile(e)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}return t}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function v(){return typeof chrome<`u`&&!!chrome?.runtime?.id}function y(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function b(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}var x=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),S=new Set([101,103,204,205,304]);function C(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new r(`EACCES`,e.error):e.errorCode===`invalid_request`?new r(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||x.has(String(e.errorCode))?new r(`EIO`,e.error):new r(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=y(e.bodyBase64)}catch(e){throw new r(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=S.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function w(e,t){let n;try{n=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)})}catch(e){throw new r(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new r(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function T(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new r(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}function E(e){return async t=>{let n={profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?b(t.body):void 0};return C(v()?await T(`mount.s3-sign-and-forward`,n):await w(`/api/s3-sign-and-forward`,n))}}function D(e){let t=e?.getImsToken??(async()=>(await l()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new r(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}let i={imsToken:n,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?b(e.body):void 0};return C(v()?await T(`mount.da-sign-and-forward`,i):await w(`/api/da-sign-and-forward`,i))}}var O=e({DaMountBackend:()=>_,RemoteMountCache:()=>s,S3MountBackend:()=>f,makeSignedFetchDa:()=>D,makeSignedFetchS3:()=>E});export{f as a,_ as i,D as n,s as o,E as r,O as t};
@@ -1 +1 @@
1
- import"./index-DSq-sjeA.js";var e=`slicc-nuke-control`;function t(t=()=>location.reload()){if(typeof BroadcastChannel!=`function`)return()=>{};let n=new BroadcastChannel(e),r=e=>{let n=e.data;if(n?.type===`nuke-reload`){if(Array.isArray(n.keysToRemove)){for(let e of n.keysToRemove)if(typeof e==`string`)try{localStorage.removeItem(e)}catch{}}t()}};return n.addEventListener(`message`,r),()=>{n.removeEventListener(`message`,r),n.close()}}export{t as installNukeReloadListener};
1
+ import"./index-Cv13fIWN.js";var e=`slicc-nuke-control`;function t(t=()=>location.reload()){if(typeof BroadcastChannel!=`function`)return()=>{};let n=new BroadcastChannel(e),r=e=>{let n=e.data;if(n?.type===`nuke-reload`){if(Array.isArray(n.keysToRemove)){for(let e of n.keysToRemove)if(typeof e==`string`)try{localStorage.removeItem(e)}catch{}}t()}};return n.addEventListener(`message`,r),()=>{n.removeEventListener(`message`,r),n.close()}}export{t as installNukeReloadListener};
@@ -1 +1 @@
1
- import{t as e}from"./logger-B-No_qN_.js";import{r as t,v as n,x as r}from"./provider-settings-CvswCVqz.js";var i=e(`oauth-bootstrap`),a=6e4;async function o(){let e=t();i.info(`Bootstrap OAuth replicas`,{count:e.length});for(let t of e){if(!t.accessToken){i.debug(`Skipping account without token`,{providerId:t.providerId});continue}if((t.tokenExpiresAt??1/0)-Date.now()<=a){let e=r(t.providerId);if(e?.onSilentRenew)try{if(await e.onSilentRenew()){i.info(`Silently renewed OAuth token`,{providerId:t.providerId});continue}i.warn(`Silent renewal yielded no token; user must re-authenticate`,{providerId:t.providerId});continue}catch(e){i.warn(`Silent renewal failed`,{providerId:t.providerId,error:e instanceof Error?e.message:String(e)});continue}i.debug(`Skipping expired account (no silent-renew hook)`,{providerId:t.providerId});continue}try{await n({providerId:t.providerId,accessToken:t.accessToken,refreshToken:t.refreshToken,tokenExpiresAt:t.tokenExpiresAt,userName:t.userName,userAvatar:t.userAvatar}),i.debug(`Bootstrapped OAuth replica`,{providerId:t.providerId})}catch(e){i.error(`OAuth bootstrap failed`,{providerId:t.providerId,error:e instanceof Error?e.message:String(e)})}}}export{o as bootstrapOAuthReplicas};
1
+ import{t as e}from"./logger-B-No_qN_.js";import{r as t,v as n,x as r}from"./provider-settings-CWTeejO7.js";var i=e(`oauth-bootstrap`),a=6e4;async function o(){let e=t();i.info(`Bootstrap OAuth replicas`,{count:e.length});for(let t of e){if(!t.accessToken){i.debug(`Skipping account without token`,{providerId:t.providerId});continue}if((t.tokenExpiresAt??1/0)-Date.now()<=a){let e=r(t.providerId);if(e?.onSilentRenew)try{if(await e.onSilentRenew()){i.info(`Silently renewed OAuth token`,{providerId:t.providerId});continue}i.warn(`Silent renewal yielded no token; user must re-authenticate`,{providerId:t.providerId});continue}catch(e){i.warn(`Silent renewal failed`,{providerId:t.providerId,error:e instanceof Error?e.message:String(e)});continue}i.debug(`Skipping expired account (no silent-renew hook)`,{providerId:t.providerId});continue}try{await n({providerId:t.providerId,accessToken:t.accessToken,refreshToken:t.refreshToken,tokenExpiresAt:t.tokenExpiresAt,userName:t.userName,userAvatar:t.userAvatar}),i.debug(`Bootstrapped OAuth replica`,{providerId:t.providerId})}catch(e){i.error(`OAuth bootstrap failed`,{providerId:t.providerId,error:e instanceof Error?e.message:String(e)})}}}export{o as bootstrapOAuthReplicas};
@@ -1 +1 @@
1
- import{t as e}from"./kernel-worker-CXKRu-lG.js";const t=typeof chrome<`u`&&!!chrome?.runtime?.id;function n(){return t?o:typeof window>`u`?i:a}async function r(){if(typeof window<`u`)return{origin:window.location.origin,href:window.location.href};let t=e();if(!t)throw Error(`OAuth from worker context requires the panel-RPC bridge (no page-info available)`);let n=await t.call(`page-info`,void 0);return{origin:n.origin,href:n.href}}async function i(t){let n=e();if(!n)return console.error(`[oauth-service] panel-RPC client unavailable in worker`),null;try{return(await n.call(`oauth-popup`,{url:t},{timeoutMs:13e4})).redirectUrl}catch(e){return console.error(`[oauth-service] oauth-popup RPC failed:`,e instanceof Error?e.message:String(e)),null}}async function a(e){return new Promise(t=>{let n=window.open(e,`_blank`,`width=500,height=700,popup=yes`),r=!1,i=null,a=()=>{r||(r=!0,window.removeEventListener(`message`,o),clearTimeout(s),i&&clearInterval(i))},o=e=>{if(e.data?.type!==`oauth-callback`||e.origin!==window.location.origin||n&&e.source!==n)return;if(a(),e.data.error){console.error(`[oauth-service] CLI OAuth error:`,e.data.error),t(null);return}let r=e.data.redirectUrl;typeof r!=`string`&&r!=null||t(r??null)};window.addEventListener(`message`,o),(location.pathname.startsWith(`/electron`)||new URLSearchParams(location.search).get(`runtime`)===`electron-overlay`)&&(i=setInterval(async()=>{if(!r)try{let e=await fetch(`/api/oauth-result`);if(e.status===204)return;let n=await e.json();if(r)return;if(a(),n.error){console.error(`[oauth-service] Server relay OAuth error:`,n.error),t(null);return}t(n.redirectUrl??null)}catch(e){console.warn(`[oauth-service] Poll failed:`,e instanceof Error?e.message:String(e))}},1e3));let s=setTimeout(()=>{a();try{n?.close()}catch{}t(null)},12e4)})}async function o(e){return new Promise(t=>{let n=!1,r=()=>{n||(n=!0,chrome.runtime.onMessage.removeListener(i),clearTimeout(a))},i=e=>{if(e?.source===`service-worker`&&e?.payload?.type===`oauth-result`){if(r(),e.payload.error){console.error(`[oauth-service] Extension OAuth error:`,e.payload.error),t(null);return}t(e.payload.redirectUrl??null)}};chrome.runtime.onMessage.addListener(i),chrome.runtime.sendMessage({source:`panel`,payload:{type:`oauth-request`,providerId:`oauth`,authorizeUrl:e}}).catch(e=>{console.error(`[oauth-service] Failed to send OAuth request to service worker:`,e)});let a=setTimeout(()=>{r(),t(null)},12e4)})}export{n as createOAuthLauncher,r as getOAuthPageOrigin};
1
+ import{t as e}from"./kernel-worker-CqyRKXBm.js";const t=typeof chrome<`u`&&!!chrome?.runtime?.id;function n(){return t?o:typeof window>`u`?i:a}async function r(){if(typeof window<`u`)return{origin:window.location.origin,href:window.location.href};let t=e();if(!t)throw Error(`OAuth from worker context requires the panel-RPC bridge (no page-info available)`);let n=await t.call(`page-info`,void 0);return{origin:n.origin,href:n.href}}async function i(t){let n=e();if(!n)return console.error(`[oauth-service] panel-RPC client unavailable in worker`),null;try{return(await n.call(`oauth-popup`,{url:t},{timeoutMs:13e4})).redirectUrl}catch(e){return console.error(`[oauth-service] oauth-popup RPC failed:`,e instanceof Error?e.message:String(e)),null}}async function a(e){return new Promise(t=>{let n=window.open(e,`_blank`,`width=500,height=700,popup=yes`),r=!1,i=null,a=()=>{r||(r=!0,window.removeEventListener(`message`,o),clearTimeout(s),i&&clearInterval(i))},o=e=>{if(e.data?.type!==`oauth-callback`||e.origin!==window.location.origin||n&&e.source!==n)return;if(a(),e.data.error){console.error(`[oauth-service] CLI OAuth error:`,e.data.error),t(null);return}let r=e.data.redirectUrl;typeof r!=`string`&&r!=null||t(r??null)};window.addEventListener(`message`,o),(location.pathname.startsWith(`/electron`)||new URLSearchParams(location.search).get(`runtime`)===`electron-overlay`)&&(i=setInterval(async()=>{if(!r)try{let e=await fetch(`/api/oauth-result`);if(e.status===204)return;let n=await e.json();if(r)return;if(a(),n.error){console.error(`[oauth-service] Server relay OAuth error:`,n.error),t(null);return}t(n.redirectUrl??null)}catch(e){console.warn(`[oauth-service] Poll failed:`,e instanceof Error?e.message:String(e))}},1e3));let s=setTimeout(()=>{a();try{n?.close()}catch{}t(null)},12e4)})}async function o(e){return new Promise(t=>{let n=!1,r=()=>{n||(n=!0,chrome.runtime.onMessage.removeListener(i),clearTimeout(a))},i=e=>{if(e?.source===`service-worker`&&e?.payload?.type===`oauth-result`){if(r(),e.payload.error){console.error(`[oauth-service] Extension OAuth error:`,e.payload.error),t(null);return}t(e.payload.redirectUrl??null)}};chrome.runtime.onMessage.addListener(i),chrome.runtime.sendMessage({source:`panel`,payload:{type:`oauth-request`,providerId:`oauth`,authorizeUrl:e}}).catch(e=>{console.error(`[oauth-service] Failed to send OAuth request to service worker:`,e)});let a=setTimeout(()=>{r(),t(null)},12e4)})}export{n as createOAuthLauncher,r as getOAuthPageOrigin};
@@ -0,0 +1 @@
1
+ import{t as e}from"./logger-B-No_qN_.js";import{r as t}from"./tray-follower-status-DKq8RTLd.js";import{i as n}from"./index-Cv13fIWN.js";var r=e(`panel-transport`);function i(e){return typeof e==`object`&&!!e&&`source`in e&&`payload`in e}function a(){return{onMessage:e=>{let t=(t,n,r)=>(i(t)&&e(t),!1);return chrome.runtime.onMessage.addListener(t),()=>chrome.runtime.onMessage.removeListener(t)},send:e=>{chrome.runtime.sendMessage({source:`panel`,payload:e}).catch(e=>{r.error(`failed to send to offscreen`,{error:e instanceof Error?e.message:String(e)})})}}}var o=e(`offscreen-client`),s=class{eventListeners=new Set;callbacks;scoops=[];scoopStatuses=new Map;currentMessageId=new Map;ready=!1;stateRetryTimer=null;localFs=null;pendingClearAcks=new Map;transport;selectedScoopJid=null;locked=!1;constructor(e,t){this.callbacks=e,this.transport=t??a(),this.setupMessageListener()}setLocalFS(e){this.localFs=e}createAgentHandle(){return{sendMessage:(e,t,n)=>{if(!this.selectedScoopJid){this.emitToUI({type:`error`,error:`No scoop selected`});return}this.send({type:`user-message`,scoopJid:this.selectedScoopJid,text:e,attachments:n,messageId:t??`msg-${Date.now()}-${Math.random().toString(36).slice(2,8)}`})},onEvent:e=>(this.eventListeners.add(e),()=>this.eventListeners.delete(e)),stop:()=>{this.selectedScoopJid&&this.send({type:`abort`,scoopJid:this.selectedScoopJid})}}}getScoops(){return this.scoops}getScoop(e){return this.scoops.find(t=>t.jid===e)}isProcessing(e){return this.scoopStatuses.get(e)===`processing`}async registerScoop(e){if(!e.isCone)throw Error(`OffscreenClient.registerScoop is cone-only; use scoop_scoop for non-cone scoops`);this.scoops.find(t=>t.name===e.name)||(this.scoops.push(e),this.scoopStatuses.set(e.jid,`initializing`)),this.send({type:`cone-create`,name:e.name})}async unregisterScoop(e){this.send({type:`scoop-drop`,scoopJid:e}),this.scoops=this.scoops.filter(t=>t.jid!==e),this.scoopStatuses.delete(e)}createScoopTab(e){}async getGlobalMemory(){if(!this.localFs)return``;try{let e=await this.localFs.readFile(`/shared/CLAUDE.md`,{encoding:`utf-8`});return typeof e==`string`?e:new TextDecoder().decode(e)}catch{return``}}getScoopContext(e){if(this.localFs)return{getFS:()=>this.localFs}}getSharedFS(){return this.localFs}stopScoop(e){this.send({type:`abort`,scoopJid:e})}async clearQueuedMessages(e){}async deleteQueuedMessage(e,t){}updateModel(){this.send({type:`refresh-model`})}setLocked(e){this.locked=e}setScoopThinkingLevel(e,t){this.send({type:`set-thinking-level`,scoopJid:e,level:t})}async clearAllMessages(){let e=`clear-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,t=new Promise(t=>{this.pendingClearAcks.set(e,t)});this.send({type:`clear-chat`,requestId:e}),await Promise.race([t,new Promise(e=>setTimeout(e,5e3))]),this.pendingClearAcks.delete(e)}clearFilesystem(){this.send({type:`clear-filesystem`})}requestScoopMessages(e){this.send({type:`request-scoop-messages`,scoopJid:e})}requestState(){this.send({type:`request-state`});let e=0;this.stateRetryTimer=setInterval(()=>{if(e++,this.ready||e>20){this.stateRetryTimer&&=(clearInterval(this.stateRetryTimer),null);return}o.debug(`Retrying request-state`,{attempt:e}),this.send({type:`request-state`})},500)}isReady(){return this.ready}sprinkleOpHandler=null;sendSprinkleLick(e,t,n){this.send({type:`sprinkle-lick`,sprinkleName:e,body:t,targetScoop:n})}sendWebhookEvent(e,t,n){this.send({type:`lick-webhook-event`,webhookId:e,headers:t,body:n})}setSprinkleOpHandler(e){this.sprinkleOpHandler=e}sendRaw(e){this.send(e)}setupMessageListener(){this.transport.onMessage(e=>{if(e.source!==`offscreen`)return;let t=e.payload;t?.type===`sprinkle-op`&&this.sprinkleOpHandler?this.sprinkleOpHandler(t):this.handleOffscreenMessage(e.payload)})}handleOffscreenMessage(e){switch(e.type){case`offscreen-ready`:this.ready?(o.warn(`Offscreen restarted — re-requesting state`),this.ready=!1):o.info(`Offscreen engine ready`),this.send({type:`request-state`});break;case`agent-event`:this.handleAgentEvent(e);break;case`scoop-status`:this.handleScoopStatus(e);break;case`compaction-state`:this.callbacks.onCompactionStateChange?.(e.scoopJid,e.state);break;case`clear-chat-ack`:{let t=this.pendingClearAcks.get(e.requestId);t&&(this.pendingClearAcks.delete(e.requestId),t());break}case`scoop-created`:this.handleScoopCreated(e);break;case`scoop-list`:this.handleScoopList(e);break;case`state-snapshot`:this.handleStateSnapshot(e);break;case`error`:this.handleError(e);break;case`incoming-message`:this.handleIncomingMessage(e);break;case`scoop-messages-replaced`:{let t=e;this.callbacks.onScoopMessagesReplaced?.(t.scoopJid,t.messages);break}case`tray-runtime-status`:{let t=e;l(t.leader,t.follower);break}case`terminal-status`:case`terminal-output`:case`terminal-media-preview`:case`terminal-exit`:case`terminal-cleared`:for(let t of this.terminalEventListeners)try{t(e)}catch(e){o.error(`terminal event listener error`,{error:e instanceof Error?e.message:String(e)})}break}}terminalEventListeners=new Set;onTerminalEvent(e){return this.terminalEventListeners.add(e),()=>this.terminalEventListeners.delete(e)}handleAgentEvent(e){if(e.scoopJid===this.selectedScoopJid)switch(e.eventType){case`text_delta`:{let t=this.currentMessageId.get(e.scoopJid);t||(t=`scoop-${e.scoopJid}-${c()}`,this.currentMessageId.set(e.scoopJid,t),this.emitToUI({type:`message_start`,messageId:t})),this.emitToUI({type:`content_delta`,messageId:t,text:e.text??``});break}case`tool_start`:{let t=this.currentMessageId.get(e.scoopJid);t||(t=`scoop-${e.scoopJid}-${c()}`,this.currentMessageId.set(e.scoopJid,t),this.emitToUI({type:`message_start`,messageId:t})),this.emitToUI({type:`tool_use_start`,messageId:t,toolName:e.toolName??``,toolInput:e.toolInput});break}case`tool_end`:{let t=this.currentMessageId.get(e.scoopJid);t&&this.emitToUI({type:`tool_result`,messageId:t,toolName:e.toolName??``,result:e.toolResult??``,isError:e.isError});break}case`tool_ui`:{let t=this.currentMessageId.get(e.scoopJid);t||(t=`scoop-${e.scoopJid}-${c()}`,this.currentMessageId.set(e.scoopJid,t),this.emitToUI({type:`message_start`,messageId:t})),this.emitToUI({type:`tool_ui`,messageId:t,toolName:e.toolName??``,requestId:e.requestId??``,html:e.html??``});break}case`tool_ui_done`:{let t=this.currentMessageId.get(e.scoopJid);t&&this.emitToUI({type:`tool_ui_done`,messageId:t,requestId:e.requestId??``});break}case`response_done`:{let t=this.currentMessageId.get(e.scoopJid);t&&(this.emitToUI({type:`content_done`,messageId:t}),this.currentMessageId.delete(e.scoopJid));break}case`turn_end`:{let t=this.currentMessageId.get(e.scoopJid)??`done-${e.scoopJid}-${c()}`;this.currentMessageId.delete(e.scoopJid),this.emitToUI({type:`turn_end`,messageId:t});break}}}handleScoopStatus(e){this.scoopStatuses.set(e.scoopJid,e.status),this.callbacks.onStatusChange(e.scoopJid,e.status)}handleScoopCreated(e){let t=this.msgScoopToRegistered(e.scoop);this.scoops=this.scoops.filter(e=>e.name!==t.name||e.jid===t.jid),this.scoops.find(e=>e.jid===t.jid)||this.scoops.push(t),this.scoopStatuses.set(t.jid,e.scoop.status),this.callbacks.onScoopCreated(t)}handleScoopList(e){this.scoops=e.scoops.map(e=>this.msgScoopToRegistered(e));for(let t of e.scoops)this.scoopStatuses.set(t.jid,t.status);this.callbacks.onScoopListUpdate(e.scoops)}handleStateSnapshot(e){o.info(`Received state snapshot`,{scoopCount:e.scoops.length}),this.scoops=e.scoops.map(e=>this.msgScoopToRegistered(e));for(let t of e.scoops)this.scoopStatuses.set(t.jid,t.status);e.trayRuntimeStatus&&l(e.trayRuntimeStatus.leader,e.trayRuntimeStatus.follower);let t=!this.ready;t&&(this.ready=!0,this.stateRetryTimer&&=(clearInterval(this.stateRetryTimer),null)),this.callbacks.onScoopListUpdate(e.scoops),t&&this.callbacks.onReady?.()}handleError(e){e.scoopJid===this.selectedScoopJid&&this.emitToUI({type:`error`,error:e.error})}handleIncomingMessage(e){this.callbacks.onIncomingMessage(e.scoopJid,e.message)}msgScoopToRegistered(e){return{jid:e.jid,name:e.name,folder:e.folder,isCone:e.isCone,type:e.isCone?`cone`:`scoop`,requiresTrigger:!e.isCone,assistantLabel:e.assistantLabel,addedAt:new Date().toISOString(),...e.config?{config:{...e.config}}:{}}}emitToUI(e){for(let t of this.eventListeners)try{t(e)}catch(e){o.error(`Listener error`,{error:e instanceof Error?e.message:String(e)})}}send(e){if(this.locked){this.emitToUI({type:`error`,error:`This window is detached. Close it and use the detached tab.`});return}this.transport.send(e)}};function c(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}function l(e,r){n({state:e.state,error:e.error,reconnectAttempts:e.reconnectAttempts,session:e.session?{...e.session}:null}),t({state:r.state,joinUrl:r.joinUrl,trayId:r.trayId,error:r.error,lastError:r.lastError,reconnectAttempts:r.reconnectAttempts,attachAttempts:r.attachAttempts,lastAttachCode:r.lastAttachCode,connectingSince:r.connectingSince,lastPingTime:r.lastPingTime})}export{s as OffscreenClient};
@@ -1 +1 @@
1
- import{t as e}from"./logger-B-No_qN_.js";import{t}from"./index-DSq-sjeA.js";var n=[e=>`Nice to meet you, ${e}.`,e=>`Hello ${e} — glad you stopped by.`,e=>`Hey ${e}, welcome aboard.`,e=>`${e}! Pleasure to make your acquaintance.`],r=[`Nice to meet you, mysterious stranger — I'll respect the incognito.`,`Hello, anonymous traveler. You can always tell me your name later if you change your mind.`,`An unnamed visitor — intriguing. Whenever you'd like to introduce yourself, just say the word.`,`Hey there, ghost — happy to keep things first-name-optional. The door's always open if you decide to drop the cloak.`],i={work:[`Work mode — let's make today productive.`,`On the clock? Same. Let's chip away at it.`],school:[`School business — I love a good study session.`,`Hitting the books? Glad to ride along.`],personal:[`Personal project energy is the best kind.`,`Tinkering for yourself is how the good stuff happens.`],"side-project":[`Side projects keep the lights on creatively.`,`Two-job life — respect.`],exploring:[`Just poking around? Excellent. The best discoveries start there.`,`Exploration mode — no agenda, no pressure.`]},a={developer:[`I can write code, run shell commands, drive a real browser, and ship pages.`,`Code, terminals, browsers, repos — I live in all of them.`],designer:[`I can prototype layouts, generate assets, and walk page editors with you.`,`Pixels, components, screenshots — design ops are my jam.`],"content-creator":[`I can draft copy, edit, scrape references, and stitch publish-ready pages.`,`Words, structure, SEO, polish — say the topic and I'll get moving.`],marketer:[`I can audit funnels, scrape competitors, and stand up landing pages quickly.`,`Campaigns, analytics, creatives — plug me in and I'll go.`],"product-pm":[`I can summarise research, draft specs, and crunch competitive intel.`,`Briefs, roadmaps, comparisons — I take the boring half off your plate.`],founder:[`I can prototype landing pages, automate ops, and prep investor decks.`,`Idea → MVP → repeat. I'll do the legwork between coffee refills.`],student:[`I can read papers with you, draft notes, and turn lectures into outlines.`,`Studying together makes it bearable — let me handle the busywork.`],researcher:[`I can scrape sources, summarise findings, and keep a running bibliography.`,`Lit reviews, datasets, write-ups — I'm all in.`],other:[`I'm flexible — give me a task and I'll figure out the right tools.`,`Whatever the role, I can probably help. Tell me what's on the docket.`]},o=[`I can browse the web, run commands, write code, and automate the boring parts.`,`I'm comfortable with terminals, browsers, files, and a long backlog of skills.`],s=[`But to be honest, I'm not really an AI yet — I'm an empty shell. You'll need to help me become intelligent. Pick a model and I'll wake up:`,`Confession time: I can't actually think yet. Wire me up to an LLM and I'll start earning my keep:`,`Plot twist — there's no brain in here. Choose a provider so I can do more than read this script:`,`Truthfully? I'm a very polite placeholder until you give me a model. Help me out:`];function c(e,t){return e[Math.floor(t()*e.length)%e.length]}function l(e){return e.replace(/-/g,` `)}function u(e){if(e.length===0)return``;if(e.length===1)return e[0];if(e.length===2)return`${e[0]} and ${e[1]}`;let t=e[e.length-1];return`${e.slice(0,-1).join(`, `)}, and ${t}`}function d(e,t=Math.random){let a=(e.name||``).trim(),o=e.purpose?i[e.purpose]:void 0;return a?`${c(n,t)(a)}${o?` ${c(o,t)}`:``}`:`${c(r,t)}${o?` ${c(o,t)}`:``}`}function f(e,t=Math.random){let n=e.role&&a[e.role]?e.role:``,r=c(n?a[n]:o,t),i=(e.tasks??[]).slice(0,3).map(l);return`I'm sliccy. ${r}${i.length>0?` Especially handy for ${u(i)}.`:``} I'm an AI agent.`}function p(e,t=Math.random){return c(s,t)}function m(e,t=Math.random){return[d(e,t),f(e,t),p(e,t)]}var h={openai:{url:e=>`${(e??`https://api.openai.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},anthropic:{url:e=>`${(e??`https://api.anthropic.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({"x-api-key":e,"anthropic-version":`2023-06-01`})},groq:{url:e=>`${(e??`https://api.groq.com/openai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},cerebras:{url:e=>`${(e??`https://api.cerebras.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},mistral:{url:e=>`${(e??`https://api.mistral.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},"x-ai":{url:e=>`${(e??`https://api.x.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},deepseek:{url:e=>`${(e??`https://api.deepseek.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},openrouter:{url:e=>`${(e??`https://openrouter.ai/api`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},google:{url:e=>`${(e??`https://generativelanguage.googleapis.com`).replace(/\/$/,``)}/v1beta/models`,headers:()=>({})}};function g(e,t){if(e===401||e===403)return`Authentication failed — the key was rejected by the provider.`;if(e===404)return`Endpoint not found — check the base URL.`;if(e===429)return`Rate-limited — try again in a moment.`;if(e>=500)return`Provider returned a server error.`;let n=t.trim();return n?`${e}: ${n.slice(0,160)}`:`Provider responded with HTTP ${e}.`}async function _(e){let{provider:t,apiKey:n,baseUrl:r,signal:i}=e,a=e.fetchImpl??fetch,o=n.trim();if(!o)return{kind:`failed`,status:null,message:`API key is empty.`};let s=h[t];if(!s)return{kind:`skipped`,reason:`No live validation available for "${t}" — saving without testing.`};let c=s.url(r);if(t===`google`){let e=c.includes(`?`)?`&`:`?`;c=`${c}${e}key=${encodeURIComponent(o)}`}try{let e=await a(c,{method:`GET`,headers:s.headers(o),signal:i});if(e.ok)return{kind:`ok`};let t=``;try{t=await e.text()}catch{}return e.status===401||e.status,{kind:`failed`,status:e.status,message:g(e.status,t)}}catch(e){if(e?.name===`AbortError`)throw e;return{kind:`skipped`,reason:`Couldn't reach the provider (${e instanceof Error?e.message:String(e)}). Saving without live test — you can retry from Settings.`}}}var v=e(`onboarding-orchestrator`),y=class{deps;stage=`idle`;profile={};constructor(e){this.deps=e}getStage(){return this.stage}getProfile(){return{...this.profile}}handleFirstRun(){this.stage===`idle`&&(this.deps.postDipReference(`Welcome to SLICC — let's get you set up.`),this.deps.postDipReference(`![Welcome](/shared/sprinkles/welcome/welcome.shtml)`))}async handleOnboardingComplete(e){if(this.stage!==`idle`)return v.debug(`Ignoring duplicate onboarding-complete`,{stage:this.stage}),!0;this.profile=e??{},this.stage=`awaiting-connect`,t(this.deps.fs).catch(e=>v.warn(`recordWelcomed failed`,e)),this.persistProfile(this.profile).catch(e=>v.warn(`persistProfile failed`,e));let n=m(this.profile,this.deps.rand);for(let e of n)this.deps.postSystemMessage(e);return this.deps.postDipReference(`![Connect a model](/shared/sprinkles/welcome/connect-llm.shtml)`),!0}handleConnectReady(){if(this.stage===`complete`)return;let e=this.deps.getProviderCatalogue();this.deps.broadcastToDip({type:`slicc-providers`,providers:e.providers,models:e.models})}async handleConnectAttempt(e){if(this.stage===`complete`)return;this.stage=`connecting`;let{provider:t,apiKey:n,baseUrl:r,deployment:i,apiVersion:a,model:o}=e;if(!t||typeof n!=`string`||!n.trim()){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Provider and API key are required.`}),this.stage=`awaiting-connect`;return}let s=(()=>{try{return this.deps.getProviderCatalogue().providers.find(e=>e.id===t)}catch{return}})();if(s?.requiresDeployment&&!i?.trim()){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`${s.name} requires a deployment name.`}),this.stage=`awaiting-connect`;return}if(s?.requiresBaseUrl&&!r?.trim()){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`${s.name} requires a base URL.`}),this.stage=`awaiting-connect`;return}let c;try{c=await _({provider:t,apiKey:n.trim(),baseUrl:r??void 0,fetchImpl:this.deps.fetchImpl})}catch(e){v.warn(`validateApiKey threw`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Validation request was aborted.`}),this.stage=`awaiting-connect`;return}if(c.kind===`failed`){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:c.message}),this.stage=`awaiting-connect`;return}let l=o||null;if(!l)try{let e=this.deps.getProviderCatalogue().models?.[t]?.[0]?.id;e&&(l=e)}catch(e){v.warn(`Failed to resolve fallback model for provider`,{provider:t,err:e})}try{this.deps.saveAccount(t,n.trim(),r?.trim()||void 0,i?.trim()||void 0,a?.trim()||void 0),l&&this.deps.setSelectedModel(l)}catch(e){v.warn(`saveAccount failed`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Failed to save credentials locally.`}),this.stage=`awaiting-connect`;return}let u=c.kind===`skipped`?`Saved — ${c.reason}`:`Validated against the provider. Ready when you are.`;this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!0,kind:c.kind,note:u});let d=l&&this.deps.resolveModelLabel?.(t,l)?this.deps.resolveModelLabel?.(t,l):l||null;this.stage=`complete`,this.deps.fireFinalLick({action:`onboarding-complete-with-provider`,data:{profile:this.profile,provider:t,model:l??null,modelLabel:d,validation:c.kind}})}async handleOAuthAttempt(e){if(this.stage===`complete`)return;if(!this.deps.launchOAuth){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`OAuth login is not available in this runtime.`});return}this.stage=`connecting`;let t;try{t=await this.deps.launchOAuth(e.provider,e.baseUrl??null)}catch(e){v.warn(`launchOAuth threw`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:e instanceof Error?e.message:`Login was cancelled.`}),this.stage=`awaiting-connect`;return}if(!t.ok){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:t.message||`Login was cancelled.`}),this.stage=`awaiting-connect`;return}if(t.model)try{this.deps.setSelectedModel(t.model)}catch(e){v.warn(`setSelectedModel after OAuth failed`,e)}this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!0,kind:`ok`,note:t.message||`Logged in.`});let n=t.model&&this.deps.resolveModelLabel?.(e.provider,t.model)?this.deps.resolveModelLabel?.(e.provider,t.model):t.model??null;this.stage=`complete`,this.deps.fireFinalLick({action:`onboarding-complete-with-provider`,data:{profile:this.profile,provider:e.provider,model:t.model??null,modelLabel:n,validation:`oauth`}})}async persistProfile(e){let t=(e.name||`user`).toLowerCase().trim().replace(/[^a-z0-9]+/g,`-`).replace(/(^-+|-+$)/g,``)||`user`;await this.deps.fs.writeFile(`/home/${t}/.welcome.json`,JSON.stringify(e,null,2))}};export{y as OnboardingOrchestrator};
1
+ import{t as e}from"./logger-B-No_qN_.js";import{t}from"./index-Cv13fIWN.js";var n=[e=>`Nice to meet you, ${e}.`,e=>`Hello ${e} — glad you stopped by.`,e=>`Hey ${e}, welcome aboard.`,e=>`${e}! Pleasure to make your acquaintance.`],r=[`Nice to meet you, mysterious stranger — I'll respect the incognito.`,`Hello, anonymous traveler. You can always tell me your name later if you change your mind.`,`An unnamed visitor — intriguing. Whenever you'd like to introduce yourself, just say the word.`,`Hey there, ghost — happy to keep things first-name-optional. The door's always open if you decide to drop the cloak.`],i={work:[`Work mode — let's make today productive.`,`On the clock? Same. Let's chip away at it.`],school:[`School business — I love a good study session.`,`Hitting the books? Glad to ride along.`],personal:[`Personal project energy is the best kind.`,`Tinkering for yourself is how the good stuff happens.`],"side-project":[`Side projects keep the lights on creatively.`,`Two-job life — respect.`],exploring:[`Just poking around? Excellent. The best discoveries start there.`,`Exploration mode — no agenda, no pressure.`]},a={developer:[`I can write code, run shell commands, drive a real browser, and ship pages.`,`Code, terminals, browsers, repos — I live in all of them.`],designer:[`I can prototype layouts, generate assets, and walk page editors with you.`,`Pixels, components, screenshots — design ops are my jam.`],"content-creator":[`I can draft copy, edit, scrape references, and stitch publish-ready pages.`,`Words, structure, SEO, polish — say the topic and I'll get moving.`],marketer:[`I can audit funnels, scrape competitors, and stand up landing pages quickly.`,`Campaigns, analytics, creatives — plug me in and I'll go.`],"product-pm":[`I can summarise research, draft specs, and crunch competitive intel.`,`Briefs, roadmaps, comparisons — I take the boring half off your plate.`],founder:[`I can prototype landing pages, automate ops, and prep investor decks.`,`Idea → MVP → repeat. I'll do the legwork between coffee refills.`],student:[`I can read papers with you, draft notes, and turn lectures into outlines.`,`Studying together makes it bearable — let me handle the busywork.`],researcher:[`I can scrape sources, summarise findings, and keep a running bibliography.`,`Lit reviews, datasets, write-ups — I'm all in.`],other:[`I'm flexible — give me a task and I'll figure out the right tools.`,`Whatever the role, I can probably help. Tell me what's on the docket.`]},o=[`I can browse the web, run commands, write code, and automate the boring parts.`,`I'm comfortable with terminals, browsers, files, and a long backlog of skills.`],s=[`But to be honest, I'm not really an AI yet — I'm an empty shell. You'll need to help me become intelligent. Pick a model and I'll wake up:`,`Confession time: I can't actually think yet. Wire me up to an LLM and I'll start earning my keep:`,`Plot twist — there's no brain in here. Choose a provider so I can do more than read this script:`,`Truthfully? I'm a very polite placeholder until you give me a model. Help me out:`];function c(e,t){return e[Math.floor(t()*e.length)%e.length]}function l(e){return e.replace(/-/g,` `)}function u(e){if(e.length===0)return``;if(e.length===1)return e[0];if(e.length===2)return`${e[0]} and ${e[1]}`;let t=e[e.length-1];return`${e.slice(0,-1).join(`, `)}, and ${t}`}function d(e,t=Math.random){let a=(e.name||``).trim(),o=e.purpose?i[e.purpose]:void 0;return a?`${c(n,t)(a)}${o?` ${c(o,t)}`:``}`:`${c(r,t)}${o?` ${c(o,t)}`:``}`}function f(e,t=Math.random){let n=e.role&&a[e.role]?e.role:``,r=c(n?a[n]:o,t),i=(e.tasks??[]).slice(0,3).map(l);return`I'm sliccy. ${r}${i.length>0?` Especially handy for ${u(i)}.`:``} I'm an AI agent.`}function p(e,t=Math.random){return c(s,t)}function m(e,t=Math.random){return[d(e,t),f(e,t),p(e,t)]}var h={openai:{url:e=>`${(e??`https://api.openai.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},anthropic:{url:e=>`${(e??`https://api.anthropic.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({"x-api-key":e,"anthropic-version":`2023-06-01`})},groq:{url:e=>`${(e??`https://api.groq.com/openai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},cerebras:{url:e=>`${(e??`https://api.cerebras.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},mistral:{url:e=>`${(e??`https://api.mistral.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},"x-ai":{url:e=>`${(e??`https://api.x.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},deepseek:{url:e=>`${(e??`https://api.deepseek.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},openrouter:{url:e=>`${(e??`https://openrouter.ai/api`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},google:{url:e=>`${(e??`https://generativelanguage.googleapis.com`).replace(/\/$/,``)}/v1beta/models`,headers:()=>({})}};function g(e,t){if(e===401||e===403)return`Authentication failed — the key was rejected by the provider.`;if(e===404)return`Endpoint not found — check the base URL.`;if(e===429)return`Rate-limited — try again in a moment.`;if(e>=500)return`Provider returned a server error.`;let n=t.trim();return n?`${e}: ${n.slice(0,160)}`:`Provider responded with HTTP ${e}.`}async function _(e){let{provider:t,apiKey:n,baseUrl:r,signal:i}=e,a=e.fetchImpl??fetch,o=n.trim();if(!o)return{kind:`failed`,status:null,message:`API key is empty.`};let s=h[t];if(!s)return{kind:`skipped`,reason:`No live validation available for "${t}" — saving without testing.`};let c=s.url(r);if(t===`google`){let e=c.includes(`?`)?`&`:`?`;c=`${c}${e}key=${encodeURIComponent(o)}`}try{let e=await a(c,{method:`GET`,headers:s.headers(o),signal:i});if(e.ok)return{kind:`ok`};let t=``;try{t=await e.text()}catch{}return e.status===401||e.status,{kind:`failed`,status:e.status,message:g(e.status,t)}}catch(e){if(e?.name===`AbortError`)throw e;return{kind:`skipped`,reason:`Couldn't reach the provider (${e instanceof Error?e.message:String(e)}). Saving without live test — you can retry from Settings.`}}}var v=e(`onboarding-orchestrator`),y=class{deps;stage=`idle`;profile={};constructor(e){this.deps=e}getStage(){return this.stage}getProfile(){return{...this.profile}}handleFirstRun(){this.stage===`idle`&&(this.deps.postDipReference(`Welcome to SLICC — let's get you set up.`),this.deps.postDipReference(`![Welcome](/shared/sprinkles/welcome/welcome.shtml)`))}async handleOnboardingComplete(e){if(this.stage!==`idle`)return v.debug(`Ignoring duplicate onboarding-complete`,{stage:this.stage}),!0;this.profile=e??{},this.stage=`awaiting-connect`,t(this.deps.fs).catch(e=>v.warn(`recordWelcomed failed`,e)),this.persistProfile(this.profile).catch(e=>v.warn(`persistProfile failed`,e));let n=m(this.profile,this.deps.rand);for(let e of n)this.deps.postSystemMessage(e);return this.deps.postDipReference(`![Connect a model](/shared/sprinkles/welcome/connect-llm.shtml)`),!0}handleConnectReady(){if(this.stage===`complete`)return;let e=this.deps.getProviderCatalogue();this.deps.broadcastToDip({type:`slicc-providers`,providers:e.providers,models:e.models})}async handleConnectAttempt(e){if(this.stage===`complete`)return;this.stage=`connecting`;let{provider:t,apiKey:n,baseUrl:r,deployment:i,apiVersion:a,model:o}=e;if(!t||typeof n!=`string`||!n.trim()){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Provider and API key are required.`}),this.stage=`awaiting-connect`;return}let s=(()=>{try{return this.deps.getProviderCatalogue().providers.find(e=>e.id===t)}catch{return}})();if(s?.requiresDeployment&&!i?.trim()){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`${s.name} requires a deployment name.`}),this.stage=`awaiting-connect`;return}if(s?.requiresBaseUrl&&!r?.trim()){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`${s.name} requires a base URL.`}),this.stage=`awaiting-connect`;return}let c;try{c=await _({provider:t,apiKey:n.trim(),baseUrl:r??void 0,fetchImpl:this.deps.fetchImpl})}catch(e){v.warn(`validateApiKey threw`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Validation request was aborted.`}),this.stage=`awaiting-connect`;return}if(c.kind===`failed`){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:c.message}),this.stage=`awaiting-connect`;return}let l=o||null;if(!l)try{let e=this.deps.getProviderCatalogue().models?.[t]?.[0]?.id;e&&(l=e)}catch(e){v.warn(`Failed to resolve fallback model for provider`,{provider:t,err:e})}try{this.deps.saveAccount(t,n.trim(),r?.trim()||void 0,i?.trim()||void 0,a?.trim()||void 0),l&&this.deps.setSelectedModel(l)}catch(e){v.warn(`saveAccount failed`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Failed to save credentials locally.`}),this.stage=`awaiting-connect`;return}let u=c.kind===`skipped`?`Saved — ${c.reason}`:`Validated against the provider. Ready when you are.`;this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!0,kind:c.kind,note:u});let d=l&&this.deps.resolveModelLabel?.(t,l)?this.deps.resolveModelLabel?.(t,l):l||null;this.stage=`complete`,this.deps.fireFinalLick({action:`onboarding-complete-with-provider`,data:{profile:this.profile,provider:t,model:l??null,modelLabel:d,validation:c.kind}})}async handleOAuthAttempt(e){if(this.stage===`complete`)return;if(!this.deps.launchOAuth){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`OAuth login is not available in this runtime.`});return}this.stage=`connecting`;let t;try{t=await this.deps.launchOAuth(e.provider,e.baseUrl??null)}catch(e){v.warn(`launchOAuth threw`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:e instanceof Error?e.message:`Login was cancelled.`}),this.stage=`awaiting-connect`;return}if(!t.ok){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:t.message||`Login was cancelled.`}),this.stage=`awaiting-connect`;return}if(t.model)try{this.deps.setSelectedModel(t.model)}catch(e){v.warn(`setSelectedModel after OAuth failed`,e)}this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!0,kind:`ok`,note:t.message||`Logged in.`});let n=t.model&&this.deps.resolveModelLabel?.(e.provider,t.model)?this.deps.resolveModelLabel?.(e.provider,t.model):t.model??null;this.stage=`complete`,this.deps.fireFinalLick({action:`onboarding-complete-with-provider`,data:{profile:this.profile,provider:e.provider,model:t.model??null,modelLabel:n,validation:`oauth`}})}async persistProfile(e){let t=(e.name||`user`).toLowerCase().trim().replace(/[^a-z0-9]+/g,`-`).replace(/(^-+|-+$)/g,``)||`user`;await this.deps.fs.writeFile(`/home/${t}/.welcome.json`,JSON.stringify(e,null,2))}};export{y as OnboardingOrchestrator};
@@ -0,0 +1,28 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/magick-wasm-BbaIA46K.js","assets/index-Cv13fIWN.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-ca-nBW7U.js","assets/bedrock-camp-CqXHYC67.js","assets/env-api-keys-DxKb6C4Q.js","assets/simple-options-imi_RHvn.js","assets/json-parse-C5jSA6JB.js","assets/fs-CT7Y5NS0.js","assets/logger-B-No_qN_.js","assets/backend-local-mju0Ps5U.js","assets/mount-picker-popup-DJJfRF_c.js","assets/tool-ui-B3Bihlxa.js","assets/path-utils-d3qOVZOu.js","assets/tray-follower-status-DKq8RTLd.js","assets/mime-types-DL940yDZ.js","assets/mount-DqdX0aJz.js","assets/telemetry-B7l3TtVP.js","assets/index-eWuuouO-.css","assets/azure-openai-B8qTt0Fr.js","assets/openai-CRGaNv9i.js","assets/local-llm-DTDLm5Sb.js","assets/openai-completions-D5rB4vsV.js","assets/github-copilot-headers-B6Fvsk-Y.js","assets/headers-DkHU-pcw.js","assets/sanitize-unicode-BD2XKRoV.js","assets/adobe-DVwtzHxI.js","assets/oauth-service-B7as8KRE.js","assets/panel-rpc-f0zFUOaZ.js","assets/github-C1HESy2C.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./chunk-jRWAZmH_.js";import{t}from"./logger-B-No_qN_.js";import{t as n}from"./preload-helper-ca-nBW7U.js";import"./tool-ui-B3Bihlxa.js";import{a as r,i,r as a,t as o}from"./bedrock-camp-CqXHYC67.js";import{d as s,l as c,u as l}from"./simple-options-imi_RHvn.js";import{f as u,t as d,u as f}from"./tray-follower-status-DKq8RTLd.js";import{i as p}from"./telemetry-B7l3TtVP.js";function m(e){if(!Number.isFinite(e)||e<=0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${n>=10||r===0?Math.round(n):Math.round(n*10)/10} ${t[r]}`}function h(e){let t=e.mimeType||`application/octet-stream`;return`${e.name} (${t}, ${m(e.size)})`}function g(e,t=`The original file lives on a remote runtime and is not accessible here.`){return e?.length?e.map(e=>{if(!e.path)return{...e};let{path:n,...r}=e;return e.kind===`image`&&e.data||e.kind===`text`&&e.text!==void 0?r:{...r,error:r.error??t}}):[]}var _=t(`image-processor`),v=3932160,y=1568,b=new Set([`image/jpeg`,`image/png`,`image/gif`,`image/webp`]);function x(e){return b.has(e)}function S(e,t){try{if(t===`image/png`){if(e.length<32)return null;let t=atob(e.slice(0,32)),n=t.charCodeAt(16)<<24|t.charCodeAt(17)<<16|t.charCodeAt(18)<<8|t.charCodeAt(19),r=t.charCodeAt(20)<<24|t.charCodeAt(21)<<16|t.charCodeAt(22)<<8|t.charCodeAt(23);return n>0&&r>0?{width:n,height:r}:null}if(t===`image/gif`){if(e.length<16)return null;let t=atob(e.slice(0,16)),n=t.charCodeAt(6)|t.charCodeAt(7)<<8,r=t.charCodeAt(8)|t.charCodeAt(9)<<8;return n>0&&r>0?{width:n,height:r}:null}if(t===`image/jpeg`){let t=Math.min(21846*4,e.length),n=atob(e.slice(0,t));for(let e=0;e<n.length-8;e++)if(n.charCodeAt(e)===255){let t=n.charCodeAt(e+1);if(t===192||t===194){let t=n.charCodeAt(e+5)<<8|n.charCodeAt(e+6),r=n.charCodeAt(e+7)<<8|n.charCodeAt(e+8);return r>0&&t>0?{width:r,height:t}:null}}}}catch{}return null}async function C(e){if(!x(e.mimeType))return _.warn(`Unsupported image format`,{mimeType:e.mimeType}),{type:`text`,text:`[Image removed: unsupported format "${e.mimeType}". Supported: JPEG, PNG, GIF, WebP]`};let t=e.data.length,r=S(e.data,e.mimeType);if(!(t>5242880||r!==null&&(r.width>8e3||r.height>8e3)||r!==null&&Math.max(r.width,r.height)>1568))return e;_.info(`Image needs processing`,{base64Size:t,dimensions:r?`${r.width}x${r.height}`:`unknown`,reason:t>5242880?`size`:`dimensions`});let i,a;try{let e=await n(()=>import(`./magick-wasm-BbaIA46K.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]));i=e.getMagick,a=e.MIME_TO_MAGICK_FORMAT}catch(e){return _.error(`ImageMagick WASM module unavailable`,{error:e instanceof Error?e.message:String(e)}),{type:`text`,text:`[Image removed: resize service unavailable (ImageMagick WASM could not be loaded)]`}}let o;try{o=await i()}catch(e){return _.error(`ImageMagick WASM initialization failed`,{error:e instanceof Error?e.message:String(e)}),{type:`text`,text:`[Image removed: resize service unavailable (WASM init failed)]`}}try{let n=atob(e.data),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);let i={data:null,mime:e.mimeType};if(await o.ImageMagick.read(r,async t=>{let n=t.width,r=t.height,o=Math.max(n,r);if(o>1568){let e=y/o,i=Math.round(n*e),a=Math.round(r*e);t.resize(i,a),_.info(`Resized image`,{from:`${n}x${r}`,to:`${i}x${a}`})}let s=a[e.mimeType]||`JPEG`;t.write(s,e=>{i.data=new Uint8Array(e)}),i.data&&i.data.length>v&&s!==`JPEG`?(_.info(`Still over 5MB, compressing to JPEG q80`),t.quality=80,t.write(`JPEG`,e=>{i.data=new Uint8Array(e)}),i.mime=`image/jpeg`):i.data&&i.data.length>v&&(_.info(`Still over 5MB as JPEG, reducing quality to 60`),t.quality=60,t.write(`JPEG`,e=>{i.data=new Uint8Array(e)}))}),!i.data)return _.warn(`ImageMagick produced no output`),{type:`text`,text:`[Image removed: could not be processed (empty output from resize)]`};if(i.data.length>v)return _.warn(`Image still over 5MB after resize+compress`,{size:i.data.length}),{type:`text`,text:`[Image removed: still ${Math.round(i.data.length/1024/1024*10)/10}MB after resize and compression, exceeds 5MB API limit]`};let s=``;for(let e=0;e<i.data.length;e++)s+=String.fromCharCode(i.data[e]);let c=btoa(s);return _.info(`Image processed successfully`,{originalBase64:t,newBase64:c.length,mimeType:i.mime}),{type:`image`,data:c,mimeType:i.mime}}catch(n){return _.error(`Image data processing failed (corrupt or unreadable)`,{mimeType:e.mimeType,estimatedBytes:t,error:n instanceof Error?n.message:String(n)}),{type:`text`,text:`[Image removed: image data could not be processed (${n instanceof Error?n.message:`corrupt or unreadable`})]`}}}var w=`agent-sessions`,T=1,E=`sessions`;function D(){return new Promise((e,t)=>{let n=indexedDB.open(w,T);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(E)||e.createObjectStore(E,{keyPath:`id`})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var O=class{dbPromise=null;getDB(){return this.dbPromise||=D(),this.dbPromise}async save(e){let t=await this.getDB();return new Promise((n,r)=>{let i=t.transaction(E,`readwrite`).objectStore(E).put(e);i.onsuccess=()=>n(),i.onerror=()=>r(i.error)})}async load(e){let t=await this.getDB();return new Promise((n,r)=>{let i=t.transaction(E,`readonly`).objectStore(E).get(e);i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async delete(e){let t=await this.getDB();return new Promise((n,r)=>{let i=t.transaction(E,`readwrite`).objectStore(E).delete(e);i.onsuccess=()=>n(),i.onerror=()=>r(i.error)})}async list(){let e=await this.getDB();return new Promise((t,n)=>{let r=e.transaction(E,`readonly`).objectStore(E).getAll();r.onsuccess=()=>{t((r.result??[]).map(e=>({id:e.id,updatedAt:e.updatedAt})))},r.onerror=()=>n(r.error)})}async clearAll(){let e=await this.getDB();return new Promise((t,n)=>{let r=e.transaction(E,`readwrite`).objectStore(E).clear();r.onsuccess=()=>t(),r.onerror=()=>n(r.error)})}static newId(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}static createSession(e,t){let n=Date.now();return{id:e,messages:[],config:t,createdAt:n,updatedAt:n}}static updateMessages(e,t){return{...e,messages:t,updatedAt:Date.now()}}};t(`tool-adapter`),t(`context-compaction`);function k(e){let t=[];for(let n of e){let e=n;switch(e.role){case`user`:t.push(`<user>\n${A(e.content)}\n</user>`);break;case`assistant`:t.push(`<assistant>\n${A(e.content)}\n</assistant>`);break;case`toolResult`:{let n=e.toolName??`tool`;t.push(`<tool-result name="${n}">\n${A(e.content)}\n</tool-result>`);break}case`bashExecution`:t.push(`<bash>\n$ ${e.command??``}\n${e.output??``}\n</bash>`);break;case`branchSummary`:case`compactionSummary`:t.push(`<prior-summary>\n${e.summary??``}\n</prior-summary>`);break;default:t.push(`<${e.role}>\n${A(e.content)}\n</${e.role}>`)}}return t.join(`
3
+
4
+ `)}function A(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return``;let t=[];for(let n of e){let e=n;e.type===`text`&&e.text?t.push(e.text):e.type===`thinking`&&e.thinking?t.push(`[thinking] ${e.thinking}`):e.type===`toolCall`?t.push(`[tool-call ${e.name??`?`}] ${JSON.stringify(e.arguments??{})}`):e.type===`image`&&t.push(`[image]`)}return t.join(`
5
+ `)}var j=`From the conversation above, extract durable memories worth persisting to a global memory file shared across future sessions.
6
+
7
+ Focus on:
8
+ - User preferences, working style, opinions stated explicitly.
9
+ - Stable project facts (architecture decisions, conventions, constraints).
10
+ - Validated approaches the user accepted ("yes, exactly", "perfect"), not just corrections.
11
+ - External resources/links the user named.
12
+
13
+ DO NOT include:
14
+ - Ephemeral state (current task, in-progress work).
15
+ - Information already obvious from the codebase (file paths, function names, framework conventions).
16
+ - Generic restatements of what the conversation was about.
17
+
18
+ If nothing in the conversation is worth persisting, return exactly the single line:
19
+ NONE
20
+
21
+ Otherwise, output ONLY a markdown bullet list (one bullet per memory), no headers, no preamble, no follow-up. Each bullet is one line. Be specific. Prefer one fact per bullet over multi-clause sentences.`;function M(e){return`You are a context compaction assistant. You are shown the prefix of a conversation between a user and an AI coding assistant, and asked to produce either a structured summary, durable memory bullets, or a short title — depending on the user's instruction.
22
+
23
+ Do NOT continue the conversation. Do NOT answer questions inside the conversation. Output ONLY what the user asks for in the format specified.
24
+
25
+ <conversation>
26
+ ${e}
27
+ </conversation>`}async function N(e,t,n,i,a,o,s){let c=await r(e,{systemPrompt:n,messages:[{role:`user`,content:[{type:`text`,text:i}],timestamp:Date.now()}]},{maxTokens:a,apiKey:t,headers:o,signal:s});if(c.stopReason===`error`)throw Error(`Compaction call failed: ${c.errorMessage||`Unknown error`}`);return c.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
28
+ `).trim()}async function ee(e){let t=M(k(e.messages));return N(e.model,e.apiKey,t,e.instruction,e.maxTokens,e.headers,e.signal)}var te=j,ne=`Generate a short title (3 to 6 words) summarizing what this conversation was about. Output ONLY the title text — no quotes, no punctuation other than what belongs in the title, no preamble.`;function re(e,t){if(e.state===`inactive`&&t.state===`inactive`)return{kind:`hidden`};if(e.state===`leader`&&e.session?.joinUrl)return{kind:`leader-copy`,joinUrl:e.session.joinUrl,label:`Enable multi-browser sync`,caption:`Share this URL to connect more browsers.`};if(e.state!==`inactive`){let t=e.state===`connecting`?`Setting up multi-browser sync…`:e.state===`reconnecting`?`Reconnecting…`:`Sync service unreachable.`;return{kind:`leader-pending`,label:`Multi-browser sync`,caption:e.error??t}}return{kind:`follower`,label:`Multi-browser sync`,caption:t.error??t.lastError??ie(t.state)??`Mirroring another browser.`}}function ie(e){switch(e){case`connected`:return`Connected — mirroring another browser.`;case`connecting`:return`Connecting to the other browser…`;case`reconnecting`:return`Reconnecting…`;case`disconnected`:return`Disconnected from the other browser.`;default:return null}}function ae(e){let t=e.trim();if(!t)return`Paste a sync URL to continue.`;let n=null;try{n=new URL(t)}catch{return`That doesn’t look like a URL. Paste the full https://… link from the other browser.`}return n.protocol!==`https:`&&n.protocol!==`http:`?`Sync URLs must start with https://.`:n.pathname.includes(`/join/`)?`That sync URL is malformed. Re-copy it from the other browser and try again.`:`This URL is missing the /join/… capability. Use “Enable multi-browser sync” on the other browser.`}var oe=Object.assign({"/packages/dev-tools/providers.build.json":{include:[`*`],exclude:[]}})[`/packages/dev-tools/providers.build.json`]??{include:[`*`],exclude:[]};function se(e){let{include:t,exclude:n}=oe;return n.includes(`*`)||n.includes(e)?!1:!!(t.includes(`*`)||t.includes(e))}var ce=Object.assign({"./built-in/azure-ai-foundry.ts":()=>n(()=>import(`./azure-ai-foundry-C3Uy67aF.js`),[]),"./built-in/azure-openai.ts":()=>n(()=>import(`./azure-openai-B8qTt0Fr.js`),__vite__mapDeps([19,4,2,3,5,6,7,20])),"./built-in/bedrock-camp.ts":()=>n(()=>import(`./bedrock-camp-CqXHYC67.js`).then(e=>e.n),__vite__mapDeps([4,2,3,5,6,7])),"./built-in/local-llm.ts":()=>n(()=>import(`./local-llm-DTDLm5Sb.js`),__vite__mapDeps([21,4,2,3,5,6,7,22,23,24,25,20,9]))}),le=Object.assign({"/packages/webapp/providers/adobe.ts":()=>n(()=>import(`./adobe-DVwtzHxI.js`),__vite__mapDeps([26,3,4,2,5,6,7,27,28])),"/packages/webapp/providers/github.ts":()=>n(()=>import(`./github-C1HESy2C.js`),__vite__mapDeps([29,3,4,2,5,6,7,14,27,28]))}),P=new Map,F=null;function ue(){return F||(F=(async()=>{for(let[e,t]of Object.entries(ce)){let e=await t();e.config&&se(e.config.id)&&(P.set(e.config.id,e.config),e.register?.())}for(let[e,t]of Object.entries(le)){let e=await t();e.config&&(P.set(e.config.id,e.config),e.register?.())}})(),F)}function de(e){return P.get(e)}function fe(){return[...P.keys()]}[`ghp_`,`gho_`,`ghu_`,`ghs_`,`ghr_`,`github_pat_`,`sk-`,`pk-`,`xoxb-`,`xoxp-`,`xoxa-`,`xoxs-`,`AKIA`,`ABIA`,`ACCA`,`ASIA`,`sk-ant-`,`Bearer `].sort((e,t)=>t.length-e.length);var pe=`slicc_oauth_extra_domains`;function me(e){try{let t=e.getItem(pe);if(!t)return{};let n=JSON.parse(t);if(typeof n!=`object`||!n||Array.isArray(n))return{};let r={};for(let[e,t]of Object.entries(n)){if(typeof e!=`string`||!Array.isArray(t))continue;let n=t.filter(e=>typeof e==`string`&&e.length>0);n.length>0&&(r[e]=n)}return r}catch{return{}}}var he=e({addAccount:()=>q,applyProviderDefaults:()=>Se,clearAllSettings:()=>Re,describeInvalidJoinUrl:()=>ae,downloadProviders:()=>Le,exportProviders:()=>Ie,getAccounts:()=>G,getAllAvailableModels:()=>Ee,getApiKey:()=>Fe,getApiKeyForProvider:()=>Ae,getApiVersionForProvider:()=>Me,getAvailableProviders:()=>B,getBaseUrlForProvider:()=>Y,getDeploymentForProvider:()=>je,getExtraOAuthDomains:()=>De,getOAuthAccountInfo:()=>be,getProviderConfig:()=>V,getProviderModels:()=>U,getSelectedModelId:()=>X,getSelectedProvider:()=>Z,isModelHiddenFromPicker:()=>we,removeAccount:()=>J,resolveCurrentModel:()=>Q,resolveModelById:()=>ze,saveOAuthAccount:()=>Oe,setSelectedModelId:()=>Ne,showProviderSettings:()=>$}),I=c,L=l;function ge(){return typeof chrome<`u`&&!!chrome?.runtime?.id}var R=`slicc_accounts`,z=`selected-model`,_e=[`slicc_provider`,`slicc_api_key`,`slicc_base_url`,`anthropic_api_key`,`api_provider`,`azure_resource`,`bedrock_region`],ve=!1;function ye(){if(!ve){ve=!0;for(let e of _e)try{localStorage.removeItem(e)}catch{}}}function B(){let e=s().filter(se),t=fe();return[...new Set([...e,...t])]}function V(e){return de(e)||{id:e,name:e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),description:`${e} provider`,requiresApiKey:!0,requiresBaseUrl:!1}}function H(e,t){t.context_window!==void 0&&(e.contextWindow=t.context_window),t.max_tokens!==void 0&&(e.maxTokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),t.compat!==void 0&&(e.compat={...e.compat??{},...t.compat})}function U(e){try{if(e===`bedrock-camp`){let e=o(Y(`bedrock-camp`)),t=L(`amazon-bedrock`).filter(t=>i(t,e)),n=new Set(t.map(e=>e.id)),r=a().filter(t=>i(t,e)&&!n.has(t.id));return[...t,...r].map(e=>({...e,api:`bedrock-camp-converse`,provider:`bedrock-camp`}))}let t=V(e);if(t.getModelIds){let n;try{n=t.getModelIds()}catch(t){return W.error(`Provider getModelIds callback failed`,{providerId:e,error:t instanceof Error?t.message:String(t)}),[]}let r=new Map;for(let e of s())try{for(let t of L(e))r.set(t.id,t)}catch{}return n.map(n=>{let i=`${e}-${n.api===`openai`?`openai`:`anthropic`}`,a=r.get(n.id),o=a?{...a,api:i,provider:e}:{id:n.id,name:n.name??n.id,provider:e,api:i,baseUrl:``,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},inputCost:0,outputCost:0,cacheReadCost:0,cacheWriteCost:0,reasoning:!0},s=t.modelOverrides?.[n.id];return s&&H(o,s),H(o,n),o})}if(t.isOAuth){let n=L(`anthropic`),r=`${e}-anthropic`;return n.map(n=>{let i={...n,api:r,provider:e},a=t.modelOverrides?.[n.id];return a&&H(i,a),i})}return L(e===`azure-ai-foundry`?`anthropic`:e)}catch(t){return W.error(`Failed to load models`,{providerId:e,error:t instanceof Error?t.message:String(t)}),[]}}function be(e){let t=G().find(t=>t.providerId===e);if(!t?.accessToken)return null;let n=!!t.tokenExpiresAt&&Date.now()>t.tokenExpiresAt-6e4;return{token:t.accessToken,maskedValue:t.maskedValue,expiresAt:t.tokenExpiresAt,userName:t.userName,userAvatar:t.userAvatar,expired:n}}var xe=Object.assign({})[`/packages/webapp/providers.json`]??[],W=t(`provider-settings`);function Se(e=xe){if(e.length===0||G().length>0)return;let t=new Set(B());for(let n of e)if(!(!n.providerId||!n.apiKey)){if(!t.has(n.providerId)){W.warn(`Unknown provider "${n.providerId}" in providers.json — skipping`);continue}q(n.providerId,n.apiKey,n.baseUrl)}let n=e.find(e=>e.providerId&&e.apiKey&&t.has(e.providerId));n?.model&&!localStorage.getItem(z)&&localStorage.setItem(z,`${n.providerId}:${n.model}`)}var Ce=[/haiku/i];function we(e){return Ce.some(t=>t.test(e))}function Te(e){return e.filter(e=>!we(e.id))}function Ee(){let e=G();if(e.length===0)return[];let t=new Map;for(let n of e){if(t.has(n.providerId))continue;let e=Te(U(n.providerId));if(e.length===0)continue;let r=V(n.providerId),i={providerId:n.providerId,providerName:r.name,models:e};t.set(n.providerId,i)}return[...t.values()]}function G(){ye();let e=localStorage.getItem(R);if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`object`&&!!e&&typeof e.providerId==`string`&&typeof e.apiKey==`string`):[]}catch{return[]}}function De(e){return me(localStorage)[e]??[]}function K(e){localStorage.setItem(R,JSON.stringify(e))}function q(e,t,n,r,i){let a=G().filter(t=>t.providerId!==e),o={providerId:e,apiKey:t};n&&(o.baseUrl=n),r&&(o.deployment=r),i&&(o.apiVersion=i),a.push(o),K(a)}async function J(e){let t=typeof chrome<`u`&&!!chrome?.runtime?.id;try{if(t)await chrome.storage.local.remove([`oauth.${e}.token`,`oauth.${e}.token_DOMAINS`]);else{let t=await fetch(`/api/secrets/oauth/${e}`,{method:`DELETE`});!t.ok&&t.status!==404&&W.warn(`OAuth replica DELETE non-ok`,{providerId:e,status:t.status})}}catch(n){W.error(`OAuth replica removal failed`,{providerId:e,isExtension:t,error:n instanceof Error?n.message:String(n)})}K(G().filter(t=>t.providerId!==e));let n=localStorage.getItem(z)??``,r=n.indexOf(`:`);r>0&&n.slice(0,r)===e&&localStorage.removeItem(z)}async function Oe(e){let t=G().find(t=>t.providerId===e.providerId),n=G().filter(t=>t.providerId!==e.providerId);n.push({providerId:e.providerId,apiKey:``,accessToken:e.accessToken,refreshToken:e.refreshToken,tokenExpiresAt:e.tokenExpiresAt,userName:e.userName,userAvatar:e.userAvatar,baseUrl:e.baseUrl??t?.baseUrl}),K(n);let r=V(e.providerId)?.oauthTokenDomains??[],i=De(e.providerId),a=new Set,o=[];for(let e of[...r,...i]){let t=e.toLowerCase();a.has(t)||(a.add(t),o.push(e))}if(o.length===0)return;let s=typeof chrome<`u`&&!!chrome?.runtime?.id;try{if(s){await chrome.storage.local.set({[`oauth.${e.providerId}.token`]:e.accessToken,[`oauth.${e.providerId}.token_DOMAINS`]:o.join(`,`)});let t=await new Promise(t=>{chrome.runtime.sendMessage({type:`secrets.mask-oauth-token`,providerId:e.providerId},n=>{chrome.runtime.lastError&&W.error(`SW mask-oauth-token transport failed`,{providerId:e.providerId,error:chrome.runtime.lastError.message}),t(n??{})})});if(t.error&&W.warn(`SW mask-oauth-token returned error`,{providerId:e.providerId,error:t.error}),t.maskedValue){let n=G(),r=n.find(t=>t.providerId===e.providerId);r&&(r.maskedValue=t.maskedValue,K(n))}}else{let t=await fetch(`/api/secrets/oauth-update`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({providerId:e.providerId,accessToken:e.accessToken,domains:o})});if(t.ok){let n=await t.json(),r=G(),i=r.find(t=>t.providerId===e.providerId);i&&typeof n.maskedValue==`string`&&(i.maskedValue=n.maskedValue,K(r))}else W.warn(`OAuth replica POST non-ok`,{providerId:e.providerId,status:t.status})}}catch(t){W.error(`OAuth replica sync failed`,{providerId:e.providerId,isExtension:s,error:t instanceof Error?t.message:String(t)})}}var ke=`local`;function Ae(e){let t=G().find(t=>t.providerId===e);return t?t.accessToken||t.apiKey||(V(e).optionalApiKey?ke:null):null}function Y(e){return G().find(t=>t.providerId===e)?.baseUrl??null}function je(e){return G().find(t=>t.providerId===e)?.deployment??null}function Me(e){return G().find(t=>t.providerId===e)?.apiVersion??null}function X(){let e=localStorage.getItem(z)||``,t=e.indexOf(`:`);return t>=0?e.slice(t+1):e}function Ne(e){if(e.includes(`:`))localStorage.setItem(z,e);else{let t=Z();localStorage.setItem(z,`${t}:${e}`)}}function Pe(){return localStorage.getItem(z)||``}function Z(){let e=Pe(),t=e.indexOf(`:`);if(t>0)return e.slice(0,t);let n=G();return n.length>0?n[0].providerId:`anthropic`}function Fe(){return Ae(Z())}function Ie(){let e=G(),t=Z(),n=X();return e.map(e=>{let r={providerId:e.providerId,apiKey:e.apiKey};return e.baseUrl&&(r.baseUrl=e.baseUrl),e.providerId===t&&n&&(r.model=n),r})}function Le(){let e=JSON.stringify(Ie(),null,2),t=new Blob([e],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`providers.json`,r.click(),URL.revokeObjectURL(n)}async function Re(){let e=G();await Promise.allSettled(e.map(e=>J(e.providerId))),localStorage.removeItem(R),localStorage.removeItem(z);for(let e of _e)localStorage.removeItem(e)}function ze(e){if(!e)return Q();let t=Z(),n=Y(t);try{let r=V(t),i=I(r.isOAuth||t===`azure-ai-foundry`?`anthropic`:t===`bedrock-camp`?`amazon-bedrock`:t,e);if(!i?.id)throw Error(`Model ${e} not found`);let a=i;return r.isOAuth?a=U(t).find(t=>t.id===e)||{...a,api:`${t}-anthropic`,provider:t}:t===`bedrock-camp`&&(a={...a,api:`bedrock-camp-converse`,provider:`bedrock-camp`}),n&&(a={...a,baseUrl:n}),a}catch{return Q()}}function Q(){let e=Z(),t=X(),n=Y(e),r=U(e),i=V(e),a=i.defaultModelId?r.find(e=>e.id.toLowerCase().includes(i.defaultModelId.toLowerCase()))?.id:void 0,o=t||a||r[0]?.id||`claude-sonnet-4-6`;try{let t=V(e),i=t.isOAuth||e===`azure-ai-foundry`?`anthropic`:e===`bedrock-camp`?`amazon-bedrock`:e,a=I(i,o);if(!a?.id)throw Error(`Model ${o} not found in ${i} registry`);let s=a;return t.isOAuth?s=r.find(e=>e.id===o)||{...s,api:`${e}-anthropic`,provider:e}:e===`bedrock-camp`&&(s={...s,api:`bedrock-camp-converse`,provider:`bedrock-camp`}),n&&(s={...s,baseUrl:n}),s}catch{let e=r.find(e=>e.id===o);return e?n?{...e,baseUrl:n}:e:I(`anthropic`,`claude-sonnet-4-0`)}}function Be(e){return e.length<=10?`****`:e.slice(0,4)+`...`+e.slice(-4)}function Ve(e){let t=`http://www.w3.org/2000/svg`,n=document.createElementNS(t,`svg`);n.setAttribute(`width`,`14`),n.setAttribute(`height`,`14`),n.setAttribute(`viewBox`,`0 0 20 20`),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`1.5`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`);for(let r of e){let e=document.createElementNS(t,`path`);e.setAttribute(`d`,r),n.appendChild(e)}return n}var He={pen:[`M14.3 3.3a1.5 1.5 0 0 1 2.1 0l.3.3a1.5 1.5 0 0 1 0 2.1L7.7 14.8l-3.2.7.7-3.2z`],trash:[`M4 6h12`,`M8 6V4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2`,`M6 6v10a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V6`]};function $(e){return p(`button`),new Promise(t=>{let r=localStorage.getItem(R)??``,i=document.createElement(`div`);i.className=`dialog-overlay`;let a=document.createElement(`div`);a.className=`dialog`,a.style.cssText=`max-width: 480px; width: 90vw; padding: 32px;`,G().length>0?o():e?.autoJoinUrl?c(e.autoJoinUrl):e?.preferTrayJoin?l():s(),i.appendChild(a),document.body.appendChild(i);function o(){a.innerHTML=``;let e=document.createElement(`div`);e.className=`dialog__title`,e.textContent=`Accounts`,a.appendChild(e);let n=G(),c=`background: transparent; border: 1px solid var(--s2-border-subtle); color: var(--s2-content-secondary); border-radius: var(--s2-radius-s); padding: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: color 0.15s, border-color 0.15s;`;if(n.length===0){let e=document.createElement(`div`);e.className=`dialog__desc`,e.textContent=`No accounts configured.`,a.appendChild(e)}else{let e=document.createElement(`div`);e.style.cssText=`margin-bottom: 16px;`;for(let t of n){let n=V(t.providerId),r=document.createElement(`div`);r.style.cssText=`display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--s2-bg-layer-2); border-radius: var(--s2-radius-default); margin-bottom: 8px; border: 1px solid var(--s2-border-subtle);`;let i=document.createElement(`div`);i.style.cssText=`flex: 1; min-width: 0;`;let a=document.createElement(`div`);a.style.cssText=`font-size: 14px; font-weight: 600; color: var(--s2-content-default);`,a.textContent=n.name,i.appendChild(a);let l=document.createElement(`div`);l.style.cssText=`font-size: 11px; color: var(--s2-content-disabled); font-family: monospace; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`,t.userName?l.textContent=t.userName:t.accessToken?l.textContent=`Logged in`:l.textContent=Be(t.apiKey),t.baseUrl&&(l.textContent+=` • `+t.baseUrl),i.appendChild(l),r.appendChild(i);let u=document.createElement(`div`);u.style.cssText=`display: flex; gap: 4px; margin-left: 12px; flex-shrink: 0;`;let d=document.createElement(`button`);d.style.cssText=c,d.setAttribute(`aria-label`,`Edit account`),d.appendChild(Ve(He.pen)),d.addEventListener(`mouseenter`,()=>{d.style.color=`var(--s2-accent)`,d.style.borderColor=`var(--s2-accent)`}),d.addEventListener(`mouseleave`,()=>{d.style.color=`var(--s2-content-secondary)`,d.style.borderColor=`var(--s2-border-subtle)`}),d.addEventListener(`click`,()=>{s(t)}),u.appendChild(d);let f=document.createElement(`button`);f.style.cssText=c,f.setAttribute(`aria-label`,`Remove account`),f.appendChild(Ve(He.trash)),f.addEventListener(`mouseenter`,()=>{f.style.color=`var(--s2-negative)`,f.style.borderColor=`var(--s2-negative)`}),f.addEventListener(`mouseleave`,()=>{f.style.color=`var(--s2-content-secondary)`,f.style.borderColor=`var(--s2-border-subtle)`}),f.addEventListener(`click`,async()=>{await J(t.providerId),o()}),u.appendChild(f),r.appendChild(u),e.appendChild(r)}a.appendChild(e)}let u=document.createElement(`div`);u.style.cssText=`display: flex; gap: 8px;`;let p=document.createElement(`button`);p.className=n.length>0?`dialog__btn dialog__btn--secondary`:`dialog__btn`,p.style.flex=`1`,p.textContent=`Add Account`,p.addEventListener(`click`,()=>s()),u.appendChild(p);let m=document.createElement(`button`);m.className=`dialog__btn dialog__btn--secondary`,m.style.flex=`1`,m.textContent=`Export`,m.addEventListener(`click`,()=>Le()),u.appendChild(m),a.appendChild(u);let h=document.createElement(`hr`);h.style.cssText=`border: none; border-top: 1px solid var(--s2-border-subtle); margin: 16px 0;`,a.appendChild(h);let g=document.createElement(`div`);g.className=`dialog__desc`,g.style.cssText=`font-weight: 600; margin-bottom: 8px;`,g.textContent=`Tray`,a.appendChild(g);let _=d(),v=_.state!==`inactive`,y=f(window.localStorage);if(v||y){let e=document.createElement(`div`);e.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); margin-bottom: 8px;`,e.textContent=`Follower: ${v?_.state:`configured`}`,_.error&&(e.textContent+=` — ${_.error}`,e.style.color=`var(--slicc-cone)`),a.appendChild(e)}let b=document.createElement(`button`);b.className=`dialog__btn dialog__btn--secondary`,b.textContent=v||y?`Reconnect to other browser`:`Connect to another browser`,b.addEventListener(`click`,()=>l()),a.appendChild(b);let x=document.createElement(`hr`);x.style.cssText=`border: none; border-top: 1px solid var(--s2-border-subtle); margin: 16px 0;`,a.appendChild(x);let S=document.createElement(`button`);S.className=`dialog__btn`,S.textContent=`Get Started`,S.addEventListener(`click`,()=>{i.remove(),t((localStorage.getItem(R)??``)!==r)}),a.appendChild(S)}function s(e){a.innerHTML=``;let t=!!e,r=document.createElement(`div`);r.className=`dialog__title`,r.textContent=t?`Edit Account`:`Add Account`,a.appendChild(r);let i=document.createElement(`div`);i.className=`dialog__desc`,i.textContent=`Provider:`,a.appendChild(i);let s=document.createElement(`select`);if(s.className=`dialog__input`,s.style.marginBottom=`8px`,t){let t=V(e.providerId),n=document.createElement(`option`);n.value=e.providerId,n.textContent=t.name,s.appendChild(n),s.disabled=!0,s.style.opacity=`0.7`}else{let e=B(),t=new Set(G().map(e=>e.providerId)),n=[...e].sort((e,t)=>{let n=V(e).name,r=V(t).name;return n.localeCompare(r)});for(let e of n){if(t.has(e))continue;let n=V(e),r=document.createElement(`option`);r.value=e,r.textContent=n.name,s.appendChild(r)}}a.appendChild(s);let c=document.createElement(`div`);c.className=`dialog__desc`,c.style.cssText=`font-size: 12px; color: var(--s2-content-tertiary); margin-bottom: 16px; margin-top: -4px;`,a.appendChild(c);let u=document.createElement(`div`);u.style.cssText=`margin-bottom: 16px; display: none;`;let d=document.createElement(`button`);d.className=`dialog__btn`,d.textContent=`Login`,d.style.cssText=`width: 100%; margin-bottom: 8px;`,u.appendChild(d);let f=document.createElement(`div`);f.className=`dialog__desc`,f.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); text-align: center;`,u.appendChild(f),d.addEventListener(`click`,async()=>{let e=s.value;if(!e)return;let t=V(e);if(!t.onOAuthLogin)return;let r=G().some(t=>t.providerId===e),i=Y(e);if(t.requiresBaseUrl&&!v.value.trim()&&!i){f.textContent=`Base URL is required.`,f.style.color=`var(--slicc-cone)`,v.focus();return}t.requiresBaseUrl&&v.value.trim()&&q(e,``,v.value.trim()),f.textContent=`Opening login window...`;try{let{createOAuthLauncher:e}=await n(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-B7as8KRE.js`);return{createOAuthLauncher:e}},__vite__mapDeps([27,28,2])),r=e();await t.onOAuthLogin(r,o)}catch(t){if(!r)try{await J(e)}catch{}W.error(`OAuth login failed`,{providerId:e,error:t instanceof Error?t.message:String(t)}),f.textContent=`Login failed: ${t instanceof Error?t.message:String(t)}`}}),t&&e.userName&&(f.textContent=`Logged in as ${e.userName}`,d.textContent=`Re-login`),a.appendChild(u);let p=document.createElement(`div`),m=document.createElement(`div`);m.className=`dialog__desc`,p.appendChild(m);let h=document.createElement(`input`);h.className=`dialog__input`,h.type=`password`,h.autocomplete=`off`,h.spellcheck=!1,t&&(h.value=e.apiKey),p.appendChild(h),a.appendChild(p);let g=document.createElement(`div`),_=document.createElement(`div`);_.className=`dialog__desc`,_.textContent=`Base URL:`,g.appendChild(_);let v=document.createElement(`input`);v.className=`dialog__input`,v.type=`text`,v.autocomplete=`off`,v.spellcheck=!1,t&&e.baseUrl&&(v.value=e.baseUrl),g.appendChild(v);let y=document.createElement(`div`);y.className=`dialog__desc`,y.style.cssText=`font-size: 11px; color: var(--s2-content-secondary); margin-top: -12px; margin-bottom: 16px;`,g.appendChild(y),a.appendChild(g);let b=document.createElement(`div`);b.style.display=`none`;let x=document.createElement(`div`);x.className=`dialog__desc`,x.textContent=`Deployment:`,b.appendChild(x);let S=document.createElement(`input`);S.className=`dialog__input`,S.type=`text`,S.autocomplete=`off`,S.spellcheck=!1,t&&e.deployment&&(S.value=e.deployment),b.appendChild(S);let C=document.createElement(`div`);C.className=`dialog__desc`,C.style.cssText=`font-size: 11px; color: var(--s2-content-secondary); margin-top: -12px; margin-bottom: 16px;`,b.appendChild(C),a.appendChild(b);let w=document.createElement(`div`);w.style.display=`none`;let T=document.createElement(`div`);T.className=`dialog__desc`,T.textContent=`API Version:`,w.appendChild(T);let E=document.createElement(`input`);E.className=`dialog__input`,E.type=`text`,E.autocomplete=`off`,E.spellcheck=!1,t&&e.apiVersion&&(E.value=e.apiVersion),w.appendChild(E);let D=document.createElement(`div`);D.className=`dialog__desc`,D.style.cssText=`font-size: 11px; color: var(--s2-content-secondary); margin-top: -12px; margin-bottom: 16px;`,w.appendChild(D),a.appendChild(w);let O=document.createElement(`div`);O.style.cssText=`color: var(--slicc-cone); font-size: 12px; margin-bottom: 8px; display: none;`,a.appendChild(O);let k=document.createElement(`button`);k.className=`dialog__btn`,k.textContent=t?`Save`:`Add`;function A(){let e=s.value;if(!e)return;let t=V(e);if(c.textContent=t.description,t.isOAuth)u.style.display=``,p.style.display=`none`,g.style.display=t.requiresBaseUrl?``:`none`,t.requiresBaseUrl&&(v.placeholder=t.baseUrlPlaceholder||`https://...`,y.textContent=t.baseUrlDescription||``),d.textContent=`Login with ${t.name}`,k.style.display=`none`;else{u.style.display=`none`,m.textContent=`${t.requiresApiKey?`API Key`:`API Key (optional)`}${t.apiKeyEnvVar?` (${t.apiKeyEnvVar})`:``}:`,h.placeholder=t.apiKeyPlaceholder||`API key`;let e=t.requiresApiKey||t.optionalApiKey;p.style.display=e?``:`none`,v.placeholder=t.baseUrlPlaceholder||`https://...`,y.textContent=t.baseUrlDescription||``,g.style.display=t.requiresBaseUrl?``:`none`,k.style.display=``}t.requiresDeployment?(b.style.display=``,S.placeholder=t.deploymentPlaceholder||`deployment-name`,C.textContent=t.deploymentDescription||``):b.style.display=`none`,t.requiresApiVersion?(w.style.display=``,!E.value&&t.apiVersionDefault&&(E.value=t.apiVersionDefault),E.placeholder=t.apiVersionDefault||`api-version`,D.textContent=t.apiVersionDescription||``):w.style.display=`none`}s.addEventListener(`change`,()=>{O.style.display=`none`,A()}),A();function j(){let e=s.value;if(!e)return;let t=V(e);if(t.requiresApiKey&&h.value.trim().length<5){O.textContent=`API key is required (at least 5 characters).`,O.style.display=``,h.focus();return}if(t.requiresBaseUrl&&!v.value.trim()){O.textContent=`Base URL is required for this provider.`,O.style.display=``,v.focus();return}if(t.requiresDeployment&&!S.value.trim()){O.textContent=`Deployment name is required for this provider.`,O.style.display=``,S.focus();return}q(e,h.value.trim(),v.value.trim()||void 0,S.value.trim()||void 0,E.value.trim()||void 0),o()}k.addEventListener(`click`,j);let M=e=>{e.key===`Enter`&&j()};h.addEventListener(`keydown`,M),v.addEventListener(`keydown`,M),S.addEventListener(`keydown`,M),E.addEventListener(`keydown`,M),a.appendChild(k);let N=G().length>0;if(!t&&!N){let e=document.createElement(`button`);e.className=`dialog__btn dialog__btn--secondary`,e.style.marginTop=`8px`,e.textContent=`Connect to another browser`,e.addEventListener(`click`,()=>{l()}),a.appendChild(e)}else if(N){let e=document.createElement(`button`);e.className=`dialog__btn dialog__btn--secondary`,e.style.marginTop=`8px`,e.textContent=`Back`,e.addEventListener(`click`,()=>{o()}),a.appendChild(e)}requestAnimationFrame(()=>{let e=s.value;if(!e)return;let t=V(e);t.requiresApiKey?h.focus():t.requiresBaseUrl&&v.focus()})}function c(e){a.innerHTML=``;let n=document.createElement(`div`);n.className=`dialog__title`,n.textContent=`Connect this browser?`,a.appendChild(n);let r=document.createElement(`div`);r.className=`dialog__desc`,r.style.marginBottom=`12px`,r.textContent=`You’ve been invited to mirror another SLICC browser. Click below to start syncing.`,a.appendChild(r);let o=document.createElement(`div`);o.className=`dialog__desc`,o.style.cssText=`font-family: monospace; font-size: 11px; color: var(--s2-content-secondary); word-break: break-all; margin-bottom: 16px; padding: 8px; background: var(--s2-bg-secondary); border-radius: 4px;`,o.textContent=e.length>80?e.slice(0,40)+`…`+e.slice(-37):e,a.appendChild(o);let c=document.createElement(`div`);c.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); margin-bottom: 8px; display: none;`,a.appendChild(c);let l=document.createElement(`button`);l.className=`dialog__btn`,l.textContent=`Connect`,l.addEventListener(`click`,()=>{let n=u(window.localStorage,e);if(!n){c.textContent=`Invalid sync URL.`,c.style.display=``,c.style.color=`var(--slicc-cone)`;return}if(ge()){let e={type:`refresh-tray-runtime`,joinUrl:n.joinUrl,workerBaseUrl:n.workerBaseUrl};chrome.runtime.sendMessage({source:`panel`,payload:e}).catch(()=>{})}else window.dispatchEvent(new CustomEvent(`slicc:tray-join`,{detail:{joinUrl:n.joinUrl}}));c.textContent=`Connecting…`,c.style.display=``,c.style.color=`var(--s2-content-secondary)`,setTimeout(()=>{i.remove(),t(!1)},800)}),a.appendChild(l);let d=document.createElement(`button`);d.className=`dialog__btn dialog__btn--secondary`,d.style.marginTop=`8px`,d.textContent=`Set up an account instead`,d.addEventListener(`click`,()=>{s()}),a.appendChild(d)}function l(){a.innerHTML=``;let e=document.createElement(`div`);e.className=`dialog__title`,e.textContent=`Connect to another browser`,a.appendChild(e);let n=document.createElement(`div`);n.className=`dialog__desc`,n.style.marginBottom=`12px`,n.textContent=`Paste a multi-browser sync URL to mirror another SLICC browser.`,a.appendChild(n);let r=document.createElement(`details`);r.style.cssText=`margin-bottom: 12px; font-size: 12px; color: var(--s2-content-secondary);`;let o=document.createElement(`summary`);o.style.cssText=`cursor: pointer; user-select: none; color: var(--s2-content-secondary);`,o.textContent=`How do I get the sync URL?`,r.appendChild(o);let c=document.createElement(`div`);c.style.cssText=`margin-top: 8px; padding: 10px 12px; background: var(--s2-bg-layer-2); border-radius: var(--s2-radius-default); border: 1px solid var(--s2-border-subtle); line-height: 1.5;`;let l=document.createElement(`ol`);l.style.cssText=`margin: 0; padding-left: 20px;`;for(let e of[`On the other SLICC, click the avatar (top right).`,`Choose “Enable multi-browser sync” — the URL is copied automatically.`,`Paste it below. Both browsers must be on the same SLICC version.`]){let t=document.createElement(`li`);t.textContent=e,l.appendChild(t)}c.appendChild(l),r.appendChild(c),a.appendChild(r);let d=document.createElement(`div`);d.className=`dialog__desc`,d.textContent=`Sync URL:`,a.appendChild(d);let f=document.createElement(`input`);f.className=`dialog__input`,f.type=`text`,f.autocomplete=`off`,f.spellcheck=!1,f.placeholder=`https://www.sliccy.ai/join/<token>`,a.appendChild(f);let p=document.createElement(`div`);p.style.cssText=`color: var(--slicc-cone); font-size: 12px; margin-bottom: 8px; display: none;`,a.appendChild(p);let m=document.createElement(`div`);m.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); margin-bottom: 8px; display: none;`;let h=document.createElement(`button`);h.className=`dialog__btn`,h.textContent=`Connect`,h.addEventListener(`click`,()=>{let e=f.value.trim();if(!e){p.textContent=`Paste a sync URL to continue.`,p.style.display=``,f.focus();return}let n=u(window.localStorage,e);if(!n){p.textContent=ae(e),p.style.display=``,f.focus();return}if(ge()){let e={type:`refresh-tray-runtime`,joinUrl:n.joinUrl,workerBaseUrl:n.workerBaseUrl};chrome.runtime.sendMessage({source:`panel`,payload:e}).catch(()=>{})}else window.dispatchEvent(new CustomEvent(`slicc:tray-join`,{detail:{joinUrl:n.joinUrl}}));m.textContent=`Connecting…`,m.style.display=``,m.style.color=`var(--s2-content-secondary)`,setTimeout(()=>{i.remove(),t(!1)},800)}),a.appendChild(h),a.appendChild(m);let g=document.createElement(`button`);g.className=`dialog__btn dialog__btn--secondary`,g.style.marginTop=`8px`,g.textContent=`Back`,g.addEventListener(`click`,()=>{s()}),a.appendChild(g),f.addEventListener(`input`,()=>{p.style.display=`none`}),f.addEventListener(`keydown`,e=>{e.key===`Enter`&&h.click()}),requestAnimationFrame(()=>f.focus())}})}export{m as A,re as C,O as D,ee as E,g as M,x as O,ue as S,ne as T,ze as _,Fe as a,$ as b,je as c,U as d,X as f,Q as g,J as h,Ee as i,h as j,C as k,be as l,he as m,Re as n,Me as o,Z as p,G as r,Y as s,Se as t,V as u,Oe as v,te as w,de as x,Ne as y};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./chunk-jRWAZmH_.js";import{t}from"./logger-BHrAkMIS.js";import{n,r}from"./tool-ui-D9h6SJkp.js";import{a as i,c as a,i as o,r as s,s as c,t as l}from"./bedrock-camp-9aDiXDk5.js";import{d as u,l as d,u as f}from"./transform-messages-uhk4b6os.js";import{a as p,n as m,t as ee}from"./providers-B1u4aCVl.js";const te=`slicc.trayWorkerBaseUrl`,ne=`https://www.sliccy.ai`;let re={state:`inactive`,joinUrl:null,trayId:null,error:null,lastPingTime:null,reconnectAttempts:0,attachAttempts:0,lastAttachCode:null,connectingSince:null,lastError:null};function ie(){return{...re}}const h=new Set;function ae(e){return h.add(e),()=>{h.delete(e)}}async function oe(e,t,n,r,i,a){let o=[...e],s={...t,messages:[...t.messages,...e]};await r({type:`agent_start`}),await r({type:`turn_start`});for(let t of e)await r({type:`message_start`,message:t}),await r({type:`message_end`,message:t});return await g(s,o,n,i,r,a),o}async function se(e,t,n,r,i){if(e.messages.length===0)throw Error(`Cannot continue: no messages in context`);if(e.messages[e.messages.length-1].role===`assistant`)throw Error(`Cannot continue from message role: assistant`);let a=[],o={...e};return await n({type:`agent_start`}),await n({type:`turn_start`}),await g(o,a,t,r,n,i),a}async function g(e,t,n,r,i,a){let o=!0,s=await n.getSteeringMessages?.()||[];for(;;){let c=!0;for(;c||s.length>0;){if(o?o=!1:await i({type:`turn_start`}),s.length>0){for(let n of s)await i({type:`message_start`,message:n}),await i({type:`message_end`,message:n}),e.messages.push(n),t.push(n);s=[]}let l=await ce(e,n,r,i,a);if(t.push(l),l.stopReason===`error`||l.stopReason===`aborted`){await i({type:`turn_end`,message:l,toolResults:[]}),await i({type:`agent_end`,messages:t});return}let u=l.content.filter(e=>e.type===`toolCall`),d=[];if(c=!1,u.length>0){let a=await le(e,l,n,r,i);d.push(...a.messages),c=!a.terminate;for(let n of d)e.messages.push(n),t.push(n)}if(await i({type:`turn_end`,message:l,toolResults:d}),await n.shouldStopAfterTurn?.({message:l,toolResults:d,context:e,newMessages:t})){await i({type:`agent_end`,messages:t});return}s=await n.getSteeringMessages?.()||[]}let l=await n.getFollowUpMessages?.()||[];if(l.length>0){s=l;continue}break}await i({type:`agent_end`,messages:t})}async function ce(e,t,n,r,i){let o=e.messages;t.transformContext&&(o=await t.transformContext(o,n));let s=await t.convertToLlm(o),c={systemPrompt:e.systemPrompt,messages:s,tools:e.tools},l=i||a,u=(t.getApiKey?await t.getApiKey(t.model.provider):void 0)||t.apiKey,d=await l(t.model,c,{...t,apiKey:u,signal:n}),f=null,p=!1;for await(let t of d)switch(t.type){case`start`:f=t.partial,e.messages.push(f),p=!0,await r({type:`message_start`,message:{...f}});break;case`text_start`:case`text_delta`:case`text_end`:case`thinking_start`:case`thinking_delta`:case`thinking_end`:case`toolcall_start`:case`toolcall_delta`:case`toolcall_end`:f&&(f=t.partial,e.messages[e.messages.length-1]=f,await r({type:`message_update`,assistantMessageEvent:t,message:{...f}}));break;case`done`:case`error`:{let t=await d.result();return p?e.messages[e.messages.length-1]=t:e.messages.push(t),p||await r({type:`message_start`,message:{...t}}),await r({type:`message_end`,message:t}),t}}let m=await d.result();return p?e.messages[e.messages.length-1]=m:(e.messages.push(m),await r({type:`message_start`,message:{...m}})),await r({type:`message_end`,message:m}),m}async function le(e,t,n,r,i){let a=t.content.filter(e=>e.type===`toolCall`),o=a.some(t=>e.tools?.find(e=>e.name===t.name)?.executionMode===`sequential`);return n.toolExecution===`sequential`||o?ue(e,t,a,n,r,i):de(e,t,a,n,r,i)}async function ue(e,t,n,r,i,a){let o=[],s=[];for(let c of n){await a({type:`tool_execution_start`,toolCallId:c.id,toolName:c.name,args:c.arguments});let n=await pe(e,t,c,r,i),l;l=n.kind===`immediate`?{toolCall:c,result:n.result,isError:n.isError}:await he(e,t,n,await me(n,i,a),r,i),await y(l,a);let u=b(l);await x(u,a),o.push(l),s.push(u)}return{messages:s,terminate:_(o)}}async function de(e,t,n,r,i,a){let o=[];for(let s of n){await a({type:`tool_execution_start`,toolCallId:s.id,toolName:s.name,args:s.arguments});let n=await pe(e,t,s,r,i);if(n.kind===`immediate`){let e={toolCall:s,result:n.result,isError:n.isError};await y(e,a),o.push(e);continue}o.push(async()=>{let o=await he(e,t,n,await me(n,i,a),r,i);return await y(o,a),o})}let s=await Promise.all(o.map(e=>typeof e==`function`?e():Promise.resolve(e))),c=[];for(let e of s){let t=b(e);await x(t,a),c.push(t)}return{messages:c,terminate:_(s)}}function _(e){return e.length>0&&e.every(e=>e.result.terminate===!0)}function fe(e,t){if(!e.prepareArguments)return t;let n=e.prepareArguments(t.arguments);return n===t.arguments?t:{...t,arguments:n}}async function pe(e,t,n,r,a){let o=e.tools?.find(e=>e.name===n.name);if(!o)return{kind:`immediate`,result:v(`Tool ${n.name} not found`),isError:!0};try{let s=i(o,fe(o,n));if(r.beforeToolCall){let i=await r.beforeToolCall({assistantMessage:t,toolCall:n,args:s,context:e},a);if(i?.block)return{kind:`immediate`,result:v(i.reason||`Tool execution was blocked`),isError:!0}}return{kind:`prepared`,toolCall:n,tool:o,args:s}}catch(e){return{kind:`immediate`,result:v(e instanceof Error?e.message:String(e)),isError:!0}}}async function me(e,t,n){let r=[];try{let i=await e.tool.execute(e.toolCall.id,e.args,t,t=>{r.push(Promise.resolve(n({type:`tool_execution_update`,toolCallId:e.toolCall.id,toolName:e.toolCall.name,args:e.toolCall.arguments,partialResult:t})))});return await Promise.all(r),{result:i,isError:!1}}catch(e){return await Promise.all(r),{result:v(e instanceof Error?e.message:String(e)),isError:!0}}}async function he(e,t,n,r,i,a){let o=r.result,s=r.isError;if(i.afterToolCall)try{let r=await i.afterToolCall({assistantMessage:t,toolCall:n.toolCall,args:n.args,result:o,isError:s,context:e},a);r&&(o={content:r.content??o.content,details:r.details??o.details,terminate:r.terminate??o.terminate},s=r.isError??s)}catch(e){o=v(e instanceof Error?e.message:String(e)),s=!0}return{toolCall:n.toolCall,result:o,isError:s}}function v(e){return{content:[{type:`text`,text:e}],details:{}}}async function y(e,t){await t({type:`tool_execution_end`,toolCallId:e.toolCall.id,toolName:e.toolCall.name,result:e.result,isError:e.isError})}function b(e){return{role:`toolResult`,toolCallId:e.toolCall.id,toolName:e.toolCall.name,content:e.result.content,details:e.result.details,isError:e.isError,timestamp:Date.now()}}async function x(e,t){await t({type:`message_start`,message:e}),await t({type:`message_end`,message:e})}function ge(e){return e.filter(e=>e.role===`user`||e.role===`assistant`||e.role===`toolResult`)}const _e={input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},ve={id:`unknown`,name:`unknown`,api:`unknown`,provider:`unknown`,baseUrl:``,reasoning:!1,input:[],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:0,maxTokens:0};function ye(e){let t=e?.tools?.slice()??[],n=e?.messages?.slice()??[];return{systemPrompt:e?.systemPrompt??``,model:e?.model??ve,thinkingLevel:e?.thinkingLevel??`off`,get tools(){return t},set tools(e){t=e.slice()},get messages(){return n},set messages(e){n=e.slice()},isStreaming:!1,streamingMessage:void 0,pendingToolCalls:new Set,errorMessage:void 0}}var S=class{mode;messages=[];constructor(e){this.mode=e}enqueue(e){this.messages.push(e)}hasItems(){return this.messages.length>0}drain(){if(this.mode===`all`){let e=this.messages.slice();return this.messages=[],e}let e=this.messages[0];return e?(this.messages=this.messages.slice(1),[e]):[]}clear(){this.messages=[]}},be=class{_state;listeners=new Set;steeringQueue;followUpQueue;convertToLlm;transformContext;streamFn;getApiKey;onPayload;onResponse;beforeToolCall;afterToolCall;activeRun;sessionId;thinkingBudgets;transport;maxRetryDelayMs;toolExecution;constructor(e={}){this._state=ye(e.initialState),this.convertToLlm=e.convertToLlm??ge,this.transformContext=e.transformContext,this.streamFn=e.streamFn??a,this.getApiKey=e.getApiKey,this.onPayload=e.onPayload,this.onResponse=e.onResponse,this.beforeToolCall=e.beforeToolCall,this.afterToolCall=e.afterToolCall,this.steeringQueue=new S(e.steeringMode??`one-at-a-time`),this.followUpQueue=new S(e.followUpMode??`one-at-a-time`),this.sessionId=e.sessionId,this.thinkingBudgets=e.thinkingBudgets,this.transport=e.transport??`auto`,this.maxRetryDelayMs=e.maxRetryDelayMs,this.toolExecution=e.toolExecution??`parallel`}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}get state(){return this._state}set steeringMode(e){this.steeringQueue.mode=e}get steeringMode(){return this.steeringQueue.mode}set followUpMode(e){this.followUpQueue.mode=e}get followUpMode(){return this.followUpQueue.mode}steer(e){this.steeringQueue.enqueue(e)}followUp(e){this.followUpQueue.enqueue(e)}clearSteeringQueue(){this.steeringQueue.clear()}clearFollowUpQueue(){this.followUpQueue.clear()}clearAllQueues(){this.clearSteeringQueue(),this.clearFollowUpQueue()}hasQueuedMessages(){return this.steeringQueue.hasItems()||this.followUpQueue.hasItems()}get signal(){return this.activeRun?.abortController.signal}abort(){this.activeRun?.abortController.abort()}waitForIdle(){return this.activeRun?.promise??Promise.resolve()}reset(){this._state.messages=[],this._state.isStreaming=!1,this._state.streamingMessage=void 0,this._state.pendingToolCalls=new Set,this._state.errorMessage=void 0,this.clearFollowUpQueue(),this.clearSteeringQueue()}async prompt(e,t){if(this.activeRun)throw Error(`Agent is already processing a prompt. Use steer() or followUp() to queue messages, or wait for completion.`);let n=this.normalizePromptInput(e,t);await this.runPromptMessages(n)}async continue(){if(this.activeRun)throw Error(`Agent is already processing. Wait for completion before continuing.`);let e=this._state.messages[this._state.messages.length-1];if(!e)throw Error(`No messages to continue from`);if(e.role===`assistant`){let e=this.steeringQueue.drain();if(e.length>0){await this.runPromptMessages(e,{skipInitialSteeringPoll:!0});return}let t=this.followUpQueue.drain();if(t.length>0){await this.runPromptMessages(t);return}throw Error(`Cannot continue from message role: assistant`)}await this.runContinuation()}normalizePromptInput(e,t){if(Array.isArray(e))return e;if(typeof e!=`string`)return[e];let n=[{type:`text`,text:e}];return t&&t.length>0&&n.push(...t),[{role:`user`,content:n,timestamp:Date.now()}]}async runPromptMessages(e,t={}){await this.runWithLifecycle(async n=>{await oe(e,this.createContextSnapshot(),this.createLoopConfig(t),e=>this.processEvents(e),n,this.streamFn)})}async runContinuation(){await this.runWithLifecycle(async e=>{await se(this.createContextSnapshot(),this.createLoopConfig(),e=>this.processEvents(e),e,this.streamFn)})}createContextSnapshot(){return{systemPrompt:this._state.systemPrompt,messages:this._state.messages.slice(),tools:this._state.tools.slice()}}createLoopConfig(e={}){let t=e.skipInitialSteeringPoll===!0;return{model:this._state.model,reasoning:this._state.thinkingLevel===`off`?void 0:this._state.thinkingLevel,sessionId:this.sessionId,onPayload:this.onPayload,onResponse:this.onResponse,transport:this.transport,thinkingBudgets:this.thinkingBudgets,maxRetryDelayMs:this.maxRetryDelayMs,toolExecution:this.toolExecution,beforeToolCall:this.beforeToolCall,afterToolCall:this.afterToolCall,convertToLlm:this.convertToLlm,transformContext:this.transformContext,getApiKey:this.getApiKey,getSteeringMessages:async()=>t?(t=!1,[]):this.steeringQueue.drain(),getFollowUpMessages:async()=>this.followUpQueue.drain()}}async runWithLifecycle(e){if(this.activeRun)throw Error(`Agent is already processing.`);let t=new AbortController,n=()=>{},r=new Promise(e=>{n=e});this.activeRun={promise:r,resolve:n,abortController:t},this._state.isStreaming=!0,this._state.streamingMessage=void 0,this._state.errorMessage=void 0;try{await e(t.signal)}catch(e){await this.handleRunFailure(e,t.signal.aborted)}finally{this.finishRun()}}async handleRunFailure(e,t){let n={role:`assistant`,content:[{type:`text`,text:``}],api:this._state.model.api,provider:this._state.model.provider,model:this._state.model.id,usage:_e,stopReason:t?`aborted`:`error`,errorMessage:e instanceof Error?e.message:String(e),timestamp:Date.now()};this._state.messages.push(n),this._state.errorMessage=n.errorMessage,await this.processEvents({type:`agent_end`,messages:[n]})}finishRun(){this._state.isStreaming=!1,this._state.streamingMessage=void 0,this._state.pendingToolCalls=new Set,this.activeRun?.resolve(),this.activeRun=void 0}async processEvents(e){switch(e.type){case`message_start`:this._state.streamingMessage=e.message;break;case`message_update`:this._state.streamingMessage=e.message;break;case`message_end`:this._state.streamingMessage=void 0,this._state.messages.push(e.message);break;case`tool_execution_start`:{let t=new Set(this._state.pendingToolCalls);t.add(e.toolCallId),this._state.pendingToolCalls=t;break}case`tool_execution_end`:{let t=new Set(this._state.pendingToolCalls);t.delete(e.toolCallId),this._state.pendingToolCalls=t;break}case`turn_end`:e.message.role===`assistant`&&e.message.errorMessage&&(this._state.errorMessage=e.message.errorMessage);break;case`agent_end`:this._state.streamingMessage=void 0;break}let t=this.activeRun?.abortController.signal;if(!t)throw Error(`Agent listener invoked outside active run`);for(let n of this.listeners)await n(e,t)}};const C=`sessions`;function xe(){return new Promise((e,t)=>{let n=indexedDB.open(`agent-sessions`,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(C)||e.createObjectStore(C,{keyPath:`id`})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var Se=class{dbPromise=null;getDB(){return this.dbPromise||=xe(),this.dbPromise}async save(e){let t=await this.getDB();return new Promise((n,r)=>{let i=t.transaction(C,`readwrite`).objectStore(C).put(e);i.onsuccess=()=>n(),i.onerror=()=>r(i.error)})}async load(e){let t=await this.getDB();return new Promise((n,r)=>{let i=t.transaction(C,`readonly`).objectStore(C).get(e);i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async delete(e){let t=await this.getDB();return new Promise((n,r)=>{let i=t.transaction(C,`readwrite`).objectStore(C).delete(e);i.onsuccess=()=>n(),i.onerror=()=>r(i.error)})}async list(){let e=await this.getDB();return new Promise((t,n)=>{let r=e.transaction(C,`readonly`).objectStore(C).getAll();r.onsuccess=()=>{t((r.result??[]).map(e=>({id:e.id,updatedAt:e.updatedAt})))},r.onerror=()=>n(r.error)})}async clearAll(){let e=await this.getDB();return new Promise((t,n)=>{let r=e.transaction(C,`readwrite`).objectStore(C).clear();r.onsuccess=()=>t(),r.onerror=()=>n(r.error)})}static newId(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}static createSession(e,t){let n=Date.now();return{id:e,messages:[],config:t,createdAt:n,updatedAt:n}}static updateMessages(e,t){return{...e,messages:t,updatedAt:Date.now()}}};const w=t(`image-processor`),T=3932160,Ce=new Set([`image/jpeg`,`image/png`,`image/gif`,`image/webp`]);function we(e){return Ce.has(e)}function Te(e,t){try{if(t===`image/png`){if(e.length<32)return null;let t=atob(e.slice(0,32)),n=t.charCodeAt(16)<<24|t.charCodeAt(17)<<16|t.charCodeAt(18)<<8|t.charCodeAt(19),r=t.charCodeAt(20)<<24|t.charCodeAt(21)<<16|t.charCodeAt(22)<<8|t.charCodeAt(23);return n>0&&r>0?{width:n,height:r}:null}if(t===`image/gif`){if(e.length<16)return null;let t=atob(e.slice(0,16)),n=t.charCodeAt(6)|t.charCodeAt(7)<<8,r=t.charCodeAt(8)|t.charCodeAt(9)<<8;return n>0&&r>0?{width:n,height:r}:null}if(t===`image/jpeg`){let t=Math.min(21846*4,e.length),n=atob(e.slice(0,t));for(let e=0;e<n.length-8;e++)if(n.charCodeAt(e)===255){let t=n.charCodeAt(e+1);if(t===192||t===194){let t=n.charCodeAt(e+5)<<8|n.charCodeAt(e+6),r=n.charCodeAt(e+7)<<8|n.charCodeAt(e+8);return r>0&&t>0?{width:r,height:t}:null}}}}catch{}return null}async function Ee(e){if(!we(e.mimeType))return w.warn(`Unsupported image format`,{mimeType:e.mimeType}),{type:`text`,text:`[Image removed: unsupported format "${e.mimeType}". Supported: JPEG, PNG, GIF, WebP]`};let t=e.data.length,n=Te(e.data,e.mimeType);if(!(t>5242880||n!==null&&(n.width>8e3||n.height>8e3)||n!==null&&Math.max(n.width,n.height)>1568))return e;w.info(`Image needs processing`,{base64Size:t,dimensions:n?`${n.width}x${n.height}`:`unknown`,reason:t>5242880?`size`:`dimensions`});let r,i;try{let e=await import(`./magick-wasm-CTqVspRN.js`).then(e=>e.n);r=e.getMagick,i=e.MIME_TO_MAGICK_FORMAT}catch(e){return w.error(`ImageMagick WASM module unavailable`,{error:e instanceof Error?e.message:String(e)}),{type:`text`,text:`[Image removed: resize service unavailable (ImageMagick WASM could not be loaded)]`}}let a;try{a=await r()}catch(e){return w.error(`ImageMagick WASM initialization failed`,{error:e instanceof Error?e.message:String(e)}),{type:`text`,text:`[Image removed: resize service unavailable (WASM init failed)]`}}try{let n=atob(e.data),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);let o={data:null,mime:e.mimeType};if(await a.ImageMagick.read(r,async t=>{let n=t.width,r=t.height,a=Math.max(n,r);if(a>1568){let e=1568/a,i=Math.round(n*e),o=Math.round(r*e);t.resize(i,o),w.info(`Resized image`,{from:`${n}x${r}`,to:`${i}x${o}`})}let s=i[e.mimeType]||`JPEG`;t.write(s,e=>{o.data=new Uint8Array(e)}),o.data&&o.data.length>T&&s!==`JPEG`?(w.info(`Still over 5MB, compressing to JPEG q80`),t.quality=80,t.write(`JPEG`,e=>{o.data=new Uint8Array(e)}),o.mime=`image/jpeg`):o.data&&o.data.length>T&&(w.info(`Still over 5MB as JPEG, reducing quality to 60`),t.quality=60,t.write(`JPEG`,e=>{o.data=new Uint8Array(e)}))}),!o.data)return w.warn(`ImageMagick produced no output`),{type:`text`,text:`[Image removed: could not be processed (empty output from resize)]`};if(o.data.length>T)return w.warn(`Image still over 5MB after resize+compress`,{size:o.data.length}),{type:`text`,text:`[Image removed: still ${Math.round(o.data.length/1024/1024*10)/10}MB after resize and compression, exceeds 5MB API limit]`};let s=``;for(let e=0;e<o.data.length;e++)s+=String.fromCharCode(o.data[e]);let c=btoa(s);return w.info(`Image processed successfully`,{originalBase64:t,newBase64:c.length,mimeType:o.mime}),{type:`image`,data:c,mimeType:o.mime}}catch(n){return w.error(`Image data processing failed (corrupt or unreadable)`,{mimeType:e.mimeType,estimatedBytes:t,error:n instanceof Error?n.message:String(n)}),{type:`text`,text:`[Image removed: image data could not be processed (${n instanceof Error?n.message:`corrupt or unreadable`})]`}}}const De=t(`tool-adapter`),Oe=/<img:(data:(image\/[^;]+);base64,([^>]+))>/g;function E(e){let t=[],n=0;for(let r of e.matchAll(Oe)){let i=e.slice(n,r.index);i.trim()&&t.push({type:`text`,text:i.trimEnd()}),t.push({type:`image`,mimeType:r[2],data:r[3]}),n=r.index+r[0].length}let r=e.slice(n);return(r.trim()||t.length===0)&&t.push({type:`text`,text:r||e}),t}async function ke(e){let t=E(e),n=[];for(let e of t)e.type===`image`?n.push(await Ee(e)):n.push(e);return n}function Ae(e,t){return{name:e.name,label:e.name,description:e.description,parameters:e.inputSchema,async execute(i,a,o,s){let c;s&&(c=r({onUpdate:s,toolName:e.name,toolCallId:i}));let l=t?t.processManager.spawn({kind:`tool`,argv:[e.name,...Me(a)],owner:t.owner,ppid:t.getParentPid?.()}):null,u=null;l&&t&&o&&(o.aborted?t.processManager.signal(l.pid,`SIGINT`):o.addEventListener(`abort`,()=>t.processManager.signal(l.pid,`SIGINT`),{once:!0})),l&&t&&(u=t.processManager.onSignal((e,n)=>{e.pid!==l.pid||n!==`SIGKILL`||t.processManager.exit(l.pid,null)}));let d=l?l.abort.signal:o;try{let n=await e.execute(a??{},d),r;try{r=await ke(n.content)}catch(t){De.warn(`Image processing failed, falling back to raw content`,{tool:e.name,error:t instanceof Error?t.message:String(t)}),r=E(n.content)}return l&&t&&t.processManager.exit(l.pid,+!!n.isError),{content:r,details:{isError:n.isError}}}catch(e){throw l&&t&&t.processManager.exit(l.pid,l.abort.signal.aborted?null:1),e}finally{c&&n(c),u?.()}}}}function je(e,t){return e.map(e=>Ae(e,t))}function Me(e){if(typeof e!=`object`||!e)return[];let t=e;for(let e of[`command`,`file_path`,`path`,`pattern`,`url`,`key`,`name`,`query`,`message`]){let n=t[e];if(typeof n==`string`&&n.length>0)return[n]}for(let e of Object.values(t))if(typeof e==`string`&&e.length>0)return[e];return[]}const D={enabled:!0,reserveTokens:16384,keepRecentTokens:2e4};function Ne(e,t,n){return n.enabled?e>t-n.reserveTokens:!1}function O(e){let t=0;switch(e.role){case`user`:{let n=e.content;if(typeof n==`string`)t=n.length;else if(Array.isArray(n))for(let e of n)e.type===`text`&&e.text&&(t+=e.text.length);return Math.ceil(t/4)}case`assistant`:{let n=e;for(let e of n.content)e.type===`text`?t+=e.text.length:e.type===`thinking`?t+=e.thinking.length:e.type===`toolCall`&&(t+=e.name.length+JSON.stringify(e.arguments).length);return Math.ceil(t/4)}case`custom`:case`toolResult`:if(typeof e.content==`string`)t=e.content.length;else for(let n of e.content)n.type===`text`&&n.text&&(t+=n.text.length),n.type===`image`&&(t+=4800);return Math.ceil(t/4);case`bashExecution`:return t=e.command.length+e.output.length,Math.ceil(t/4);case`branchSummary`:case`compactionSummary`:return t=e.summary.length,Math.ceil(t/4)}return 0}const k=t(`context-compaction`);function A(e,t){return e.role===t}function j(e){let t=0;for(;t<e.length&&A(e[t],`toolResult`);){let n=e[t];k.warn(`Dropping orphaned toolResult (no preceding assistant message)`,{toolCallId:n.toolCallId}),t++}return t>0?e.slice(t):e}function Pe(e){let t=[];for(let n of e){let e=n;switch(e.role){case`user`:t.push(`<user>\n${M(e.content)}\n</user>`);break;case`assistant`:t.push(`<assistant>\n${M(e.content)}\n</assistant>`);break;case`toolResult`:{let n=e.toolName??`tool`;t.push(`<tool-result name="${n}">\n${M(e.content)}\n</tool-result>`);break}case`bashExecution`:t.push(`<bash>\n$ ${e.command??``}\n${e.output??``}\n</bash>`);break;case`branchSummary`:case`compactionSummary`:t.push(`<prior-summary>\n${e.summary??``}\n</prior-summary>`);break;default:t.push(`<${e.role}>\n${M(e.content)}\n</${e.role}>`)}}return t.join(`
1
+ import{r as e}from"./chunk-jRWAZmH_.js";import{t}from"./logger-BHrAkMIS.js";import{n,r}from"./tool-ui-D9h6SJkp.js";import{a as i,c as a,i as o,r as s,s as c,t as l}from"./bedrock-camp-9aDiXDk5.js";import{d as u,l as d,u as f}from"./transform-messages-uhk4b6os.js";import{a as p,n as m,t as ee}from"./providers-FGQY_gVN.js";const te=`slicc.trayWorkerBaseUrl`,ne=`https://www.sliccy.ai`;let re={state:`inactive`,joinUrl:null,trayId:null,error:null,lastPingTime:null,reconnectAttempts:0,attachAttempts:0,lastAttachCode:null,connectingSince:null,lastError:null};function ie(){return{...re}}const h=new Set;function ae(e){return h.add(e),()=>{h.delete(e)}}async function oe(e,t,n,r,i,a){let o=[...e],s={...t,messages:[...t.messages,...e]};await r({type:`agent_start`}),await r({type:`turn_start`});for(let t of e)await r({type:`message_start`,message:t}),await r({type:`message_end`,message:t});return await g(s,o,n,i,r,a),o}async function se(e,t,n,r,i){if(e.messages.length===0)throw Error(`Cannot continue: no messages in context`);if(e.messages[e.messages.length-1].role===`assistant`)throw Error(`Cannot continue from message role: assistant`);let a=[],o={...e};return await n({type:`agent_start`}),await n({type:`turn_start`}),await g(o,a,t,r,n,i),a}async function g(e,t,n,r,i,a){let o=!0,s=await n.getSteeringMessages?.()||[];for(;;){let c=!0;for(;c||s.length>0;){if(o?o=!1:await i({type:`turn_start`}),s.length>0){for(let n of s)await i({type:`message_start`,message:n}),await i({type:`message_end`,message:n}),e.messages.push(n),t.push(n);s=[]}let l=await ce(e,n,r,i,a);if(t.push(l),l.stopReason===`error`||l.stopReason===`aborted`){await i({type:`turn_end`,message:l,toolResults:[]}),await i({type:`agent_end`,messages:t});return}let u=l.content.filter(e=>e.type===`toolCall`),d=[];if(c=!1,u.length>0){let a=await le(e,l,n,r,i);d.push(...a.messages),c=!a.terminate;for(let n of d)e.messages.push(n),t.push(n)}if(await i({type:`turn_end`,message:l,toolResults:d}),await n.shouldStopAfterTurn?.({message:l,toolResults:d,context:e,newMessages:t})){await i({type:`agent_end`,messages:t});return}s=await n.getSteeringMessages?.()||[]}let l=await n.getFollowUpMessages?.()||[];if(l.length>0){s=l;continue}break}await i({type:`agent_end`,messages:t})}async function ce(e,t,n,r,i){let o=e.messages;t.transformContext&&(o=await t.transformContext(o,n));let s=await t.convertToLlm(o),c={systemPrompt:e.systemPrompt,messages:s,tools:e.tools},l=i||a,u=(t.getApiKey?await t.getApiKey(t.model.provider):void 0)||t.apiKey,d=await l(t.model,c,{...t,apiKey:u,signal:n}),f=null,p=!1;for await(let t of d)switch(t.type){case`start`:f=t.partial,e.messages.push(f),p=!0,await r({type:`message_start`,message:{...f}});break;case`text_start`:case`text_delta`:case`text_end`:case`thinking_start`:case`thinking_delta`:case`thinking_end`:case`toolcall_start`:case`toolcall_delta`:case`toolcall_end`:f&&(f=t.partial,e.messages[e.messages.length-1]=f,await r({type:`message_update`,assistantMessageEvent:t,message:{...f}}));break;case`done`:case`error`:{let t=await d.result();return p?e.messages[e.messages.length-1]=t:e.messages.push(t),p||await r({type:`message_start`,message:{...t}}),await r({type:`message_end`,message:t}),t}}let m=await d.result();return p?e.messages[e.messages.length-1]=m:(e.messages.push(m),await r({type:`message_start`,message:{...m}})),await r({type:`message_end`,message:m}),m}async function le(e,t,n,r,i){let a=t.content.filter(e=>e.type===`toolCall`),o=a.some(t=>e.tools?.find(e=>e.name===t.name)?.executionMode===`sequential`);return n.toolExecution===`sequential`||o?ue(e,t,a,n,r,i):de(e,t,a,n,r,i)}async function ue(e,t,n,r,i,a){let o=[],s=[];for(let c of n){await a({type:`tool_execution_start`,toolCallId:c.id,toolName:c.name,args:c.arguments});let n=await pe(e,t,c,r,i),l;l=n.kind===`immediate`?{toolCall:c,result:n.result,isError:n.isError}:await he(e,t,n,await me(n,i,a),r,i),await y(l,a);let u=b(l);await x(u,a),o.push(l),s.push(u)}return{messages:s,terminate:_(o)}}async function de(e,t,n,r,i,a){let o=[];for(let s of n){await a({type:`tool_execution_start`,toolCallId:s.id,toolName:s.name,args:s.arguments});let n=await pe(e,t,s,r,i);if(n.kind===`immediate`){let e={toolCall:s,result:n.result,isError:n.isError};await y(e,a),o.push(e);continue}o.push(async()=>{let o=await he(e,t,n,await me(n,i,a),r,i);return await y(o,a),o})}let s=await Promise.all(o.map(e=>typeof e==`function`?e():Promise.resolve(e))),c=[];for(let e of s){let t=b(e);await x(t,a),c.push(t)}return{messages:c,terminate:_(s)}}function _(e){return e.length>0&&e.every(e=>e.result.terminate===!0)}function fe(e,t){if(!e.prepareArguments)return t;let n=e.prepareArguments(t.arguments);return n===t.arguments?t:{...t,arguments:n}}async function pe(e,t,n,r,a){let o=e.tools?.find(e=>e.name===n.name);if(!o)return{kind:`immediate`,result:v(`Tool ${n.name} not found`),isError:!0};try{let s=i(o,fe(o,n));if(r.beforeToolCall){let i=await r.beforeToolCall({assistantMessage:t,toolCall:n,args:s,context:e},a);if(i?.block)return{kind:`immediate`,result:v(i.reason||`Tool execution was blocked`),isError:!0}}return{kind:`prepared`,toolCall:n,tool:o,args:s}}catch(e){return{kind:`immediate`,result:v(e instanceof Error?e.message:String(e)),isError:!0}}}async function me(e,t,n){let r=[];try{let i=await e.tool.execute(e.toolCall.id,e.args,t,t=>{r.push(Promise.resolve(n({type:`tool_execution_update`,toolCallId:e.toolCall.id,toolName:e.toolCall.name,args:e.toolCall.arguments,partialResult:t})))});return await Promise.all(r),{result:i,isError:!1}}catch(e){return await Promise.all(r),{result:v(e instanceof Error?e.message:String(e)),isError:!0}}}async function he(e,t,n,r,i,a){let o=r.result,s=r.isError;if(i.afterToolCall)try{let r=await i.afterToolCall({assistantMessage:t,toolCall:n.toolCall,args:n.args,result:o,isError:s,context:e},a);r&&(o={content:r.content??o.content,details:r.details??o.details,terminate:r.terminate??o.terminate},s=r.isError??s)}catch(e){o=v(e instanceof Error?e.message:String(e)),s=!0}return{toolCall:n.toolCall,result:o,isError:s}}function v(e){return{content:[{type:`text`,text:e}],details:{}}}async function y(e,t){await t({type:`tool_execution_end`,toolCallId:e.toolCall.id,toolName:e.toolCall.name,result:e.result,isError:e.isError})}function b(e){return{role:`toolResult`,toolCallId:e.toolCall.id,toolName:e.toolCall.name,content:e.result.content,details:e.result.details,isError:e.isError,timestamp:Date.now()}}async function x(e,t){await t({type:`message_start`,message:e}),await t({type:`message_end`,message:e})}function ge(e){return e.filter(e=>e.role===`user`||e.role===`assistant`||e.role===`toolResult`)}const _e={input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},ve={id:`unknown`,name:`unknown`,api:`unknown`,provider:`unknown`,baseUrl:``,reasoning:!1,input:[],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:0,maxTokens:0};function ye(e){let t=e?.tools?.slice()??[],n=e?.messages?.slice()??[];return{systemPrompt:e?.systemPrompt??``,model:e?.model??ve,thinkingLevel:e?.thinkingLevel??`off`,get tools(){return t},set tools(e){t=e.slice()},get messages(){return n},set messages(e){n=e.slice()},isStreaming:!1,streamingMessage:void 0,pendingToolCalls:new Set,errorMessage:void 0}}var S=class{mode;messages=[];constructor(e){this.mode=e}enqueue(e){this.messages.push(e)}hasItems(){return this.messages.length>0}drain(){if(this.mode===`all`){let e=this.messages.slice();return this.messages=[],e}let e=this.messages[0];return e?(this.messages=this.messages.slice(1),[e]):[]}clear(){this.messages=[]}},be=class{_state;listeners=new Set;steeringQueue;followUpQueue;convertToLlm;transformContext;streamFn;getApiKey;onPayload;onResponse;beforeToolCall;afterToolCall;activeRun;sessionId;thinkingBudgets;transport;maxRetryDelayMs;toolExecution;constructor(e={}){this._state=ye(e.initialState),this.convertToLlm=e.convertToLlm??ge,this.transformContext=e.transformContext,this.streamFn=e.streamFn??a,this.getApiKey=e.getApiKey,this.onPayload=e.onPayload,this.onResponse=e.onResponse,this.beforeToolCall=e.beforeToolCall,this.afterToolCall=e.afterToolCall,this.steeringQueue=new S(e.steeringMode??`one-at-a-time`),this.followUpQueue=new S(e.followUpMode??`one-at-a-time`),this.sessionId=e.sessionId,this.thinkingBudgets=e.thinkingBudgets,this.transport=e.transport??`auto`,this.maxRetryDelayMs=e.maxRetryDelayMs,this.toolExecution=e.toolExecution??`parallel`}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}get state(){return this._state}set steeringMode(e){this.steeringQueue.mode=e}get steeringMode(){return this.steeringQueue.mode}set followUpMode(e){this.followUpQueue.mode=e}get followUpMode(){return this.followUpQueue.mode}steer(e){this.steeringQueue.enqueue(e)}followUp(e){this.followUpQueue.enqueue(e)}clearSteeringQueue(){this.steeringQueue.clear()}clearFollowUpQueue(){this.followUpQueue.clear()}clearAllQueues(){this.clearSteeringQueue(),this.clearFollowUpQueue()}hasQueuedMessages(){return this.steeringQueue.hasItems()||this.followUpQueue.hasItems()}get signal(){return this.activeRun?.abortController.signal}abort(){this.activeRun?.abortController.abort()}waitForIdle(){return this.activeRun?.promise??Promise.resolve()}reset(){this._state.messages=[],this._state.isStreaming=!1,this._state.streamingMessage=void 0,this._state.pendingToolCalls=new Set,this._state.errorMessage=void 0,this.clearFollowUpQueue(),this.clearSteeringQueue()}async prompt(e,t){if(this.activeRun)throw Error(`Agent is already processing a prompt. Use steer() or followUp() to queue messages, or wait for completion.`);let n=this.normalizePromptInput(e,t);await this.runPromptMessages(n)}async continue(){if(this.activeRun)throw Error(`Agent is already processing. Wait for completion before continuing.`);let e=this._state.messages[this._state.messages.length-1];if(!e)throw Error(`No messages to continue from`);if(e.role===`assistant`){let e=this.steeringQueue.drain();if(e.length>0){await this.runPromptMessages(e,{skipInitialSteeringPoll:!0});return}let t=this.followUpQueue.drain();if(t.length>0){await this.runPromptMessages(t);return}throw Error(`Cannot continue from message role: assistant`)}await this.runContinuation()}normalizePromptInput(e,t){if(Array.isArray(e))return e;if(typeof e!=`string`)return[e];let n=[{type:`text`,text:e}];return t&&t.length>0&&n.push(...t),[{role:`user`,content:n,timestamp:Date.now()}]}async runPromptMessages(e,t={}){await this.runWithLifecycle(async n=>{await oe(e,this.createContextSnapshot(),this.createLoopConfig(t),e=>this.processEvents(e),n,this.streamFn)})}async runContinuation(){await this.runWithLifecycle(async e=>{await se(this.createContextSnapshot(),this.createLoopConfig(),e=>this.processEvents(e),e,this.streamFn)})}createContextSnapshot(){return{systemPrompt:this._state.systemPrompt,messages:this._state.messages.slice(),tools:this._state.tools.slice()}}createLoopConfig(e={}){let t=e.skipInitialSteeringPoll===!0;return{model:this._state.model,reasoning:this._state.thinkingLevel===`off`?void 0:this._state.thinkingLevel,sessionId:this.sessionId,onPayload:this.onPayload,onResponse:this.onResponse,transport:this.transport,thinkingBudgets:this.thinkingBudgets,maxRetryDelayMs:this.maxRetryDelayMs,toolExecution:this.toolExecution,beforeToolCall:this.beforeToolCall,afterToolCall:this.afterToolCall,convertToLlm:this.convertToLlm,transformContext:this.transformContext,getApiKey:this.getApiKey,getSteeringMessages:async()=>t?(t=!1,[]):this.steeringQueue.drain(),getFollowUpMessages:async()=>this.followUpQueue.drain()}}async runWithLifecycle(e){if(this.activeRun)throw Error(`Agent is already processing.`);let t=new AbortController,n=()=>{},r=new Promise(e=>{n=e});this.activeRun={promise:r,resolve:n,abortController:t},this._state.isStreaming=!0,this._state.streamingMessage=void 0,this._state.errorMessage=void 0;try{await e(t.signal)}catch(e){await this.handleRunFailure(e,t.signal.aborted)}finally{this.finishRun()}}async handleRunFailure(e,t){let n={role:`assistant`,content:[{type:`text`,text:``}],api:this._state.model.api,provider:this._state.model.provider,model:this._state.model.id,usage:_e,stopReason:t?`aborted`:`error`,errorMessage:e instanceof Error?e.message:String(e),timestamp:Date.now()};this._state.messages.push(n),this._state.errorMessage=n.errorMessage,await this.processEvents({type:`agent_end`,messages:[n]})}finishRun(){this._state.isStreaming=!1,this._state.streamingMessage=void 0,this._state.pendingToolCalls=new Set,this.activeRun?.resolve(),this.activeRun=void 0}async processEvents(e){switch(e.type){case`message_start`:this._state.streamingMessage=e.message;break;case`message_update`:this._state.streamingMessage=e.message;break;case`message_end`:this._state.streamingMessage=void 0,this._state.messages.push(e.message);break;case`tool_execution_start`:{let t=new Set(this._state.pendingToolCalls);t.add(e.toolCallId),this._state.pendingToolCalls=t;break}case`tool_execution_end`:{let t=new Set(this._state.pendingToolCalls);t.delete(e.toolCallId),this._state.pendingToolCalls=t;break}case`turn_end`:e.message.role===`assistant`&&e.message.errorMessage&&(this._state.errorMessage=e.message.errorMessage);break;case`agent_end`:this._state.streamingMessage=void 0;break}let t=this.activeRun?.abortController.signal;if(!t)throw Error(`Agent listener invoked outside active run`);for(let n of this.listeners)await n(e,t)}};const C=`sessions`;function xe(){return new Promise((e,t)=>{let n=indexedDB.open(`agent-sessions`,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(C)||e.createObjectStore(C,{keyPath:`id`})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var Se=class{dbPromise=null;getDB(){return this.dbPromise||=xe(),this.dbPromise}async save(e){let t=await this.getDB();return new Promise((n,r)=>{let i=t.transaction(C,`readwrite`).objectStore(C).put(e);i.onsuccess=()=>n(),i.onerror=()=>r(i.error)})}async load(e){let t=await this.getDB();return new Promise((n,r)=>{let i=t.transaction(C,`readonly`).objectStore(C).get(e);i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async delete(e){let t=await this.getDB();return new Promise((n,r)=>{let i=t.transaction(C,`readwrite`).objectStore(C).delete(e);i.onsuccess=()=>n(),i.onerror=()=>r(i.error)})}async list(){let e=await this.getDB();return new Promise((t,n)=>{let r=e.transaction(C,`readonly`).objectStore(C).getAll();r.onsuccess=()=>{t((r.result??[]).map(e=>({id:e.id,updatedAt:e.updatedAt})))},r.onerror=()=>n(r.error)})}async clearAll(){let e=await this.getDB();return new Promise((t,n)=>{let r=e.transaction(C,`readwrite`).objectStore(C).clear();r.onsuccess=()=>t(),r.onerror=()=>n(r.error)})}static newId(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}static createSession(e,t){let n=Date.now();return{id:e,messages:[],config:t,createdAt:n,updatedAt:n}}static updateMessages(e,t){return{...e,messages:t,updatedAt:Date.now()}}};const w=t(`image-processor`),T=3932160,Ce=new Set([`image/jpeg`,`image/png`,`image/gif`,`image/webp`]);function we(e){return Ce.has(e)}function Te(e,t){try{if(t===`image/png`){if(e.length<32)return null;let t=atob(e.slice(0,32)),n=t.charCodeAt(16)<<24|t.charCodeAt(17)<<16|t.charCodeAt(18)<<8|t.charCodeAt(19),r=t.charCodeAt(20)<<24|t.charCodeAt(21)<<16|t.charCodeAt(22)<<8|t.charCodeAt(23);return n>0&&r>0?{width:n,height:r}:null}if(t===`image/gif`){if(e.length<16)return null;let t=atob(e.slice(0,16)),n=t.charCodeAt(6)|t.charCodeAt(7)<<8,r=t.charCodeAt(8)|t.charCodeAt(9)<<8;return n>0&&r>0?{width:n,height:r}:null}if(t===`image/jpeg`){let t=Math.min(21846*4,e.length),n=atob(e.slice(0,t));for(let e=0;e<n.length-8;e++)if(n.charCodeAt(e)===255){let t=n.charCodeAt(e+1);if(t===192||t===194){let t=n.charCodeAt(e+5)<<8|n.charCodeAt(e+6),r=n.charCodeAt(e+7)<<8|n.charCodeAt(e+8);return r>0&&t>0?{width:r,height:t}:null}}}}catch{}return null}async function Ee(e){if(!we(e.mimeType))return w.warn(`Unsupported image format`,{mimeType:e.mimeType}),{type:`text`,text:`[Image removed: unsupported format "${e.mimeType}". Supported: JPEG, PNG, GIF, WebP]`};let t=e.data.length,n=Te(e.data,e.mimeType);if(!(t>5242880||n!==null&&(n.width>8e3||n.height>8e3)||n!==null&&Math.max(n.width,n.height)>1568))return e;w.info(`Image needs processing`,{base64Size:t,dimensions:n?`${n.width}x${n.height}`:`unknown`,reason:t>5242880?`size`:`dimensions`});let r,i;try{let e=await import(`./magick-wasm-CTqVspRN.js`).then(e=>e.n);r=e.getMagick,i=e.MIME_TO_MAGICK_FORMAT}catch(e){return w.error(`ImageMagick WASM module unavailable`,{error:e instanceof Error?e.message:String(e)}),{type:`text`,text:`[Image removed: resize service unavailable (ImageMagick WASM could not be loaded)]`}}let a;try{a=await r()}catch(e){return w.error(`ImageMagick WASM initialization failed`,{error:e instanceof Error?e.message:String(e)}),{type:`text`,text:`[Image removed: resize service unavailable (WASM init failed)]`}}try{let n=atob(e.data),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);let o={data:null,mime:e.mimeType};if(await a.ImageMagick.read(r,async t=>{let n=t.width,r=t.height,a=Math.max(n,r);if(a>1568){let e=1568/a,i=Math.round(n*e),o=Math.round(r*e);t.resize(i,o),w.info(`Resized image`,{from:`${n}x${r}`,to:`${i}x${o}`})}let s=i[e.mimeType]||`JPEG`;t.write(s,e=>{o.data=new Uint8Array(e)}),o.data&&o.data.length>T&&s!==`JPEG`?(w.info(`Still over 5MB, compressing to JPEG q80`),t.quality=80,t.write(`JPEG`,e=>{o.data=new Uint8Array(e)}),o.mime=`image/jpeg`):o.data&&o.data.length>T&&(w.info(`Still over 5MB as JPEG, reducing quality to 60`),t.quality=60,t.write(`JPEG`,e=>{o.data=new Uint8Array(e)}))}),!o.data)return w.warn(`ImageMagick produced no output`),{type:`text`,text:`[Image removed: could not be processed (empty output from resize)]`};if(o.data.length>T)return w.warn(`Image still over 5MB after resize+compress`,{size:o.data.length}),{type:`text`,text:`[Image removed: still ${Math.round(o.data.length/1024/1024*10)/10}MB after resize and compression, exceeds 5MB API limit]`};let s=``;for(let e=0;e<o.data.length;e++)s+=String.fromCharCode(o.data[e]);let c=btoa(s);return w.info(`Image processed successfully`,{originalBase64:t,newBase64:c.length,mimeType:o.mime}),{type:`image`,data:c,mimeType:o.mime}}catch(n){return w.error(`Image data processing failed (corrupt or unreadable)`,{mimeType:e.mimeType,estimatedBytes:t,error:n instanceof Error?n.message:String(n)}),{type:`text`,text:`[Image removed: image data could not be processed (${n instanceof Error?n.message:`corrupt or unreadable`})]`}}}const De=t(`tool-adapter`),Oe=/<img:(data:(image\/[^;]+);base64,([^>]+))>/g;function E(e){let t=[],n=0;for(let r of e.matchAll(Oe)){let i=e.slice(n,r.index);i.trim()&&t.push({type:`text`,text:i.trimEnd()}),t.push({type:`image`,mimeType:r[2],data:r[3]}),n=r.index+r[0].length}let r=e.slice(n);return(r.trim()||t.length===0)&&t.push({type:`text`,text:r||e}),t}async function ke(e){let t=E(e),n=[];for(let e of t)e.type===`image`?n.push(await Ee(e)):n.push(e);return n}function Ae(e,t){return{name:e.name,label:e.name,description:e.description,parameters:e.inputSchema,async execute(i,a,o,s){let c;s&&(c=r({onUpdate:s,toolName:e.name,toolCallId:i}));let l=t?t.processManager.spawn({kind:`tool`,argv:[e.name,...Me(a)],owner:t.owner,ppid:t.getParentPid?.()}):null,u=null;l&&t&&o&&(o.aborted?t.processManager.signal(l.pid,`SIGINT`):o.addEventListener(`abort`,()=>t.processManager.signal(l.pid,`SIGINT`),{once:!0})),l&&t&&(u=t.processManager.onSignal((e,n)=>{e.pid!==l.pid||n!==`SIGKILL`||t.processManager.exit(l.pid,null)}));let d=l?l.abort.signal:o;try{let n=await e.execute(a??{},d),r;try{r=await ke(n.content)}catch(t){De.warn(`Image processing failed, falling back to raw content`,{tool:e.name,error:t instanceof Error?t.message:String(t)}),r=E(n.content)}return l&&t&&t.processManager.exit(l.pid,+!!n.isError),{content:r,details:{isError:n.isError}}}catch(e){throw l&&t&&t.processManager.exit(l.pid,l.abort.signal.aborted?null:1),e}finally{c&&n(c),u?.()}}}}function je(e,t){return e.map(e=>Ae(e,t))}function Me(e){if(typeof e!=`object`||!e)return[];let t=e;for(let e of[`command`,`file_path`,`path`,`pattern`,`url`,`key`,`name`,`query`,`message`]){let n=t[e];if(typeof n==`string`&&n.length>0)return[n]}for(let e of Object.values(t))if(typeof e==`string`&&e.length>0)return[e];return[]}const D={enabled:!0,reserveTokens:16384,keepRecentTokens:2e4};function Ne(e,t,n){return n.enabled?e>t-n.reserveTokens:!1}function O(e){let t=0;switch(e.role){case`user`:{let n=e.content;if(typeof n==`string`)t=n.length;else if(Array.isArray(n))for(let e of n)e.type===`text`&&e.text&&(t+=e.text.length);return Math.ceil(t/4)}case`assistant`:{let n=e;for(let e of n.content)e.type===`text`?t+=e.text.length:e.type===`thinking`?t+=e.thinking.length:e.type===`toolCall`&&(t+=e.name.length+JSON.stringify(e.arguments).length);return Math.ceil(t/4)}case`custom`:case`toolResult`:if(typeof e.content==`string`)t=e.content.length;else for(let n of e.content)n.type===`text`&&n.text&&(t+=n.text.length),n.type===`image`&&(t+=4800);return Math.ceil(t/4);case`bashExecution`:return t=e.command.length+e.output.length,Math.ceil(t/4);case`branchSummary`:case`compactionSummary`:return t=e.summary.length,Math.ceil(t/4)}return 0}const k=t(`context-compaction`);function A(e,t){return e.role===t}function j(e){let t=0;for(;t<e.length&&A(e[t],`toolResult`);){let n=e[t];k.warn(`Dropping orphaned toolResult (no preceding assistant message)`,{toolCallId:n.toolCallId}),t++}return t>0?e.slice(t):e}function Pe(e){let t=[];for(let n of e){let e=n;switch(e.role){case`user`:t.push(`<user>\n${M(e.content)}\n</user>`);break;case`assistant`:t.push(`<assistant>\n${M(e.content)}\n</assistant>`);break;case`toolResult`:{let n=e.toolName??`tool`;t.push(`<tool-result name="${n}">\n${M(e.content)}\n</tool-result>`);break}case`bashExecution`:t.push(`<bash>\n$ ${e.command??``}\n${e.output??``}\n</bash>`);break;case`branchSummary`:case`compactionSummary`:t.push(`<prior-summary>\n${e.summary??``}\n</prior-summary>`);break;default:t.push(`<${e.role}>\n${M(e.content)}\n</${e.role}>`)}}return t.join(`
2
2
 
3
3
  `)}function M(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return``;let t=[];for(let n of e){let e=n;e.type===`text`&&e.text?t.push(e.text):e.type===`thinking`&&e.thinking?t.push(`[thinking] ${e.thinking}`):e.type===`toolCall`?t.push(`[tool-call ${e.name??`?`}] ${JSON.stringify(e.arguments??{})}`):e.type===`image`&&t.push(`[image]`)}return t.join(`
4
4
  `)}function Fe(e){return`You are a context compaction assistant. You are shown the prefix of a conversation between a user and an AI coding assistant, and asked to produce either a structured summary, durable memory bullets, or a short title — depending on the user's instruction.
@@ -1 +1 @@
1
- import{r as e}from"./chunk-jRWAZmH_.js";var t={include:[`*`],exclude:[]},n=e({getRegisteredProviderConfig:()=>u,getRegisteredProviderIds:()=>d,registerProviders:()=>l,shouldIncludeProvider:()=>i});const r=Object.assign({"/packages/dev-tools/providers.build.json":t})[`/packages/dev-tools/providers.build.json`]??{include:[`*`],exclude:[]};function i(e){let{include:t,exclude:n}=r;return n.includes(`*`)||n.includes(e)?!1:!!(t.includes(`*`)||t.includes(e))}const a=Object.assign({"./built-in/azure-ai-foundry.ts":()=>import(`./azure-ai-foundry-BitUTPkG.js`),"./built-in/azure-openai.ts":()=>import(`./azure-openai-DRDj59nu.js`),"./built-in/bedrock-camp.ts":()=>import(`./bedrock-camp-9aDiXDk5.js`).then(e=>e.n),"./built-in/local-llm.ts":()=>import(`./local-llm-DD6tVT9A.js`).then(e=>e.n)}),o=Object.assign({"/packages/webapp/providers/adobe.ts":()=>import(`./adobe-BAbfJ3VU.js`),"/packages/webapp/providers/github.ts":()=>import(`./github-DXq11u4_.js`)}),s=new Map;let c=null;function l(){return c||(c=(async()=>{for(let[e,t]of Object.entries(a)){let e=await t();e.config&&i(e.config.id)&&(s.set(e.config.id,e.config),e.register?.())}for(let[e,t]of Object.entries(o)){let e=await t();e.config&&(s.set(e.config.id,e.config),e.register?.())}})(),c)}function u(e){return s.get(e)}function d(){return[...s.keys()]}export{i as a,l as i,d as n,n as r,u as t};
1
+ import{r as e}from"./chunk-jRWAZmH_.js";var t={include:[`*`],exclude:[]},n=e({getRegisteredProviderConfig:()=>u,getRegisteredProviderIds:()=>d,registerProviders:()=>l,shouldIncludeProvider:()=>i});const r=Object.assign({"/packages/dev-tools/providers.build.json":t})[`/packages/dev-tools/providers.build.json`]??{include:[`*`],exclude:[]};function i(e){let{include:t,exclude:n}=r;return n.includes(`*`)||n.includes(e)?!1:!!(t.includes(`*`)||t.includes(e))}const a=Object.assign({"./built-in/azure-ai-foundry.ts":()=>import(`./azure-ai-foundry-BitUTPkG.js`),"./built-in/azure-openai.ts":()=>import(`./azure-openai-CAsn2pUF.js`),"./built-in/bedrock-camp.ts":()=>import(`./bedrock-camp-9aDiXDk5.js`).then(e=>e.n),"./built-in/local-llm.ts":()=>import(`./local-llm-Cy8fUfwX.js`).then(e=>e.n)}),o=Object.assign({"/packages/webapp/providers/adobe.ts":()=>import(`./adobe-VlJOhvPz.js`),"/packages/webapp/providers/github.ts":()=>import(`./github-CBcAkmch.js`)}),s=new Map;let c=null;function l(){return c||(c=(async()=>{for(let[e,t]of Object.entries(a)){let e=await t();e.config&&i(e.config.id)&&(s.set(e.config.id,e.config),e.register?.())}for(let[e,t]of Object.entries(o)){let e=await t();e.config&&(s.set(e.config.id,e.config),e.register?.())}})(),c)}function u(e){return s.get(e)}function d(){return[...s.keys()]}export{i as a,l as i,d as n,n as r,u as t};
@@ -1 +1 @@
1
- import{OffscreenClient as e}from"./offscreen-client-Rc4LkSrq.js";function t(e){let t=!1,n=()=>{t||(t=!0,typeof e.start==`function`&&e.start())};return{onMessage:t=>{let r=e=>{t(e.data)};return e.addEventListener(`message`,r),n(),()=>{e.removeEventListener(`message`,r)}},send:t=>{e.postMessage(t)}}}function n(e){let n=t(e);return{onMessage:e=>n.onMessage(e),send:e=>{n.send({source:`panel`,payload:e})}}}function r(e,n){let r=t(e),i=new Map,a=r.onMessage(async e=>{let t=e;if(t?.type){if(t.type===`cdp-cmd`){let t=e;try{let e=await n.send(t.method,t.params,t.sessionId);r.send({type:`cdp-response`,id:t.id,result:e})}catch(e){r.send({type:`cdp-response`,id:t.id,error:e instanceof Error?e.message:String(e)})}return}if(t.type===`cdp-subscribe`){let t=e;if(i.has(t.event))return;let a=e=>{r.send({type:`cdp-event`,method:t.event,params:e})};i.set(t.event,a),n.on(t.event,a);return}if(t.type===`cdp-unsubscribe`){let t=e,r=i.get(t.event);if(!r)return;i.delete(t.event),n.off(t.event,r);return}}});return()=>{a();for(let[e,t]of i)n.off(e,t);i.clear()}}function i(){let e={};if(typeof localStorage>`u`)return e;for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n===null)continue;let r=localStorage.getItem(n);r!==null&&(e[n]=r)}return e}function a(t){let{worker:i,realCdpTransport:a,callbacks:o}=t,s=t.readyTimeoutMs??3e4,c=t.localStorageSeed??{},l=new MessageChannel,u=new MessageChannel,d=new e(o,n(l.port1)),f=r(u.port1,a),p=null,m=new Promise((e,t)=>{let n=null,r=null;p=()=>{r!==null&&(l.port1.removeEventListener(`message`,r),r=null),n!==null&&(clearTimeout(n),n=null)},r=t=>{t.data?.type===`kernel-worker-ready`&&(p?.(),e())},l.port1.addEventListener(`message`,r),n=setTimeout(()=>{p?.(),t(Error(`Kernel worker did not signal ready within ${s}ms`))},s)}),h={type:`kernel-worker-init`,kernelPort:l.port2,cdpPort:u.port2,localStorageSeed:c,instanceId:t.instanceId};i.postMessage(h,[l.port2,u.port2]);let g=!1;return{client:d,ready:m,dispose(){if(!g){g=!0,p?.(),f();try{i.postMessage({type:`kernel-worker-shutdown`})}catch{}i.terminate(),l.port1.close(),u.port1.close()}}}}function o(e){return a({worker:e.workerUrl?new Worker(e.workerUrl,{type:`module`}):new Worker(new URL(`/assets/kernel-worker-CXKRu-lG.js`,``+import.meta.url),{type:`module`}),realCdpTransport:e.realCdpTransport,callbacks:e.callbacks,readyTimeoutMs:e.readyTimeoutMs,localStorageSeed:e.localStorageSeed??i(),instanceId:e.instanceId})}export{o as spawnKernelWorker};
1
+ import{OffscreenClient as e}from"./offscreen-client-NKbRDPeW.js";function t(e){let t=!1,n=()=>{t||(t=!0,typeof e.start==`function`&&e.start())};return{onMessage:t=>{let r=e=>{t(e.data)};return e.addEventListener(`message`,r),n(),()=>{e.removeEventListener(`message`,r)}},send:t=>{e.postMessage(t)}}}function n(e){let n=t(e);return{onMessage:e=>n.onMessage(e),send:e=>{n.send({source:`panel`,payload:e})}}}function r(e,n){let r=t(e),i=new Map,a=r.onMessage(async e=>{let t=e;if(t?.type){if(t.type===`cdp-cmd`){let t=e;try{let e=await n.send(t.method,t.params,t.sessionId);r.send({type:`cdp-response`,id:t.id,result:e})}catch(e){r.send({type:`cdp-response`,id:t.id,error:e instanceof Error?e.message:String(e)})}return}if(t.type===`cdp-subscribe`){let t=e;if(i.has(t.event))return;let a=e=>{r.send({type:`cdp-event`,method:t.event,params:e})};i.set(t.event,a),n.on(t.event,a);return}if(t.type===`cdp-unsubscribe`){let t=e,r=i.get(t.event);if(!r)return;i.delete(t.event),n.off(t.event,r);return}}});return()=>{a();for(let[e,t]of i)n.off(e,t);i.clear()}}function i(){let e={};if(typeof localStorage>`u`)return e;for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n===null)continue;let r=localStorage.getItem(n);r!==null&&(e[n]=r)}return e}function a(t){let{worker:i,realCdpTransport:a,callbacks:o}=t,s=t.readyTimeoutMs??3e4,c=t.localStorageSeed??{},l=new MessageChannel,u=new MessageChannel,d=new e(o,n(l.port1)),f=r(u.port1,a),p=null,m=new Promise((e,t)=>{let n=null,r=null;p=()=>{r!==null&&(l.port1.removeEventListener(`message`,r),r=null),n!==null&&(clearTimeout(n),n=null)},r=t=>{t.data?.type===`kernel-worker-ready`&&(p?.(),e())},l.port1.addEventListener(`message`,r),n=setTimeout(()=>{p?.(),t(Error(`Kernel worker did not signal ready within ${s}ms`))},s)}),h={type:`kernel-worker-init`,kernelPort:l.port2,cdpPort:u.port2,localStorageSeed:c,instanceId:t.instanceId};i.postMessage(h,[l.port2,u.port2]);let g=!1;return{client:d,ready:m,dispose(){if(!g){g=!0,p?.(),f();try{i.postMessage({type:`kernel-worker-shutdown`})}catch{}i.terminate(),l.port1.close(),u.port1.close()}}}}function o(e){return a({worker:e.workerUrl?new Worker(e.workerUrl,{type:`module`}):new Worker(new URL(`/assets/kernel-worker-CqyRKXBm.js`,``+import.meta.url),{type:`module`}),realCdpTransport:e.realCdpTransport,callbacks:e.callbacks,readyTimeoutMs:e.readyTimeoutMs,localStorageSeed:e.localStorageSeed??i(),instanceId:e.instanceId})}export{o as spawnKernelWorker};
@@ -0,0 +1 @@
1
+ var e=`tray`,t=`trayWorkerUrl`,n=`lead`;function r(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``,t.pathname!==`/`&&(t.pathname=t.pathname.replace(/\/+$/,``)||`/`);let n=t.toString();return n.endsWith(`/`)?n.slice(0,-1):n}catch{return null}}function i(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``;let n=t.toString(),i=t.pathname.split(`/`).filter(Boolean);if(i.length<2||i.at(-2)!==`join`)return null;let[a,o,...s]=decodeURIComponent(i.at(-1)).split(`.`);if(!a||!o||s.length>0)return null;i.splice(-2,2),t.pathname=i.length>0?`/${i.join(`/`)}`:`/`;let c=r(t.toString());return c?{workerBaseUrl:c,trayId:a,joinUrl:n}:null}catch{return null}}function a(r,i){let a=new URL(r);return a.searchParams.delete(t),a.searchParams.delete(n),a.searchParams.set(e,i),a.toString()}var o=`slicc.trayWorkerBaseUrl`,s=`slicc.trayJoinUrl`,c=`https://www.sliccy.ai`;function l(e,t){let n=r(e);if(!n)throw Error(`Invalid tray worker base URL: ${e}`);let i=t.replace(/^\/+/,``);return new URL(i,`${n}/`).toString()}function u(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``;let n=t.pathname.split(`/`).filter(Boolean),a=null;if(n.length>=2&&n.at(-2)===`tray`)a=decodeURIComponent(n.at(-1)),n.splice(-2,2),t.pathname=n.length>0?`/${n.join(`/`)}`:`/`;else if(n.length>=2&&n.at(-2)===`join`)return i(t.toString());let o=r(t.toString());return o?{workerBaseUrl:o,trayId:a,joinUrl:null}:null}catch{return null}}function d(e){let t=u(e);return t?.joinUrl?t:null}function f(e,t){let n=d(t);return n?(e.setItem(s,n.joinUrl),e.setItem(o,n.workerBaseUrl),n):null}function p(e){return!!d(e?.getItem(`slicc.trayJoinUrl`)??null)}function m(e,t){let n=r(e);if(!n)throw Error(`Invalid tray worker base URL: ${e}`);let i=t?.trim();return i?new URL(`tray/${encodeURIComponent(i)}`,`${n}/`).toString():n}function h(e,t,n){return a(e,m(t,n))}async function g(e){let t=v(e.locationHref);if(t)return e.storage&&(t.joinUrl&&e.storage.setItem(s,t.joinUrl),e.storage.setItem(o,t.workerBaseUrl)),t;let n=d(e.storage?.getItem(`slicc.trayJoinUrl`)??null);if(n)return e.storage&&e.storage.setItem(o,n.workerBaseUrl),n;let i=e.runtimeConfigFetcher?await y(e.runtimeConfigFetcher):null;if(i?.joinConfig)return e.storage&&(e.storage.setItem(s,i.joinConfig.joinUrl),e.storage.setItem(o,i.joinConfig.workerBaseUrl)),i.joinConfig;let a=i?.workerBaseUrl??null,c=r(e.storage?.getItem(`slicc.trayWorkerBaseUrl`)??null),l=r(e.envBaseUrl??null),u=r(e.defaultWorkerBaseUrl??null),f=a??c??l??u;return f?(e.storage&&e.storage.setItem(o,f),{workerBaseUrl:f,trayId:null,joinUrl:null}):null}async function _(e=fetch){try{let t=await e(`/api/runtime-config`,{cache:`no-store`});return t.ok?await t.json():null}catch{return null}}function v(a){try{let o=new URL(a),s=u(o.searchParams.get(e));if(s)return s;let c=u(o.searchParams.get(n));if(c)return c;let l=r(o.searchParams.get(t));return l?{workerBaseUrl:l,trayId:null,joinUrl:null}:i(a)||null}catch{return null}}async function y(e){let t=await e();if(!t)return null;let n=d(t.trayJoinUrl??null);return{workerBaseUrl:r(t.trayWorkerBaseUrl??null),joinConfig:n}}var b={state:`inactive`,joinUrl:null,trayId:null,error:null,lastPingTime:null,reconnectAttempts:0,attachAttempts:0,lastAttachCode:null,connectingSince:null,lastError:null};function x(){return{...b}}var S=new Set;function C(){if(S.size!==0)for(let e of[...S])try{e({...b})}catch{}}function w(e){b={...e},C()}function T(e){b={...b,lastPingTime:e},C()}export{s as a,l as c,g as d,f,c as i,_ as l,T as n,o,w as r,h as s,x as t,p as u};
@@ -1 +1 @@
1
- import{S as e,m as t}from"./db-DPvmo9md.js";const n=`slicc:last-seen-version`;function r(){return{version:`2.49.4`,releasedAt:`2026-05-16T20:38:06Z`}}async function i(){let e=await t(n);return e&&e.length>0?e:null}async function a(t){await e(n,t)}async function o(){let e=r(),t=await i();return t===null?(await a(e.version),{bundled:e,lastSeen:null,isUpgrade:!1}):t===e.version?{bundled:e,lastSeen:t,isUpgrade:!1}:{bundled:e,lastSeen:t,isUpgrade:!0}}async function s(e){await a(e)}export{o as detectUpgrade,s as recordVersionSeen};
1
+ import{S as e,m as t}from"./db-DPvmo9md.js";const n=`slicc:last-seen-version`;function r(){return{version:`2.50.0`,releasedAt:`2026-05-17T08:59:56Z`}}async function i(){let e=await t(n);return e&&e.length>0?e:null}async function a(t){await e(n,t)}async function o(){let e=r(),t=await i();return t===null?(await a(e.version),{bundled:e,lastSeen:null,isUpgrade:!1}):t===e.version?{bundled:e,lastSeen:t,isUpgrade:!1}:{bundled:e,lastSeen:t,isUpgrade:!0}}async function s(e){await a(e)}export{o as detectUpgrade,s as recordVersionSeen};