sliccy 2.52.2 → 2.53.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 (41) hide show
  1. package/README.md +1 -1
  2. package/dist/node-server/index.js +64 -3
  3. package/dist/node-server/links-middleware.d.ts +24 -0
  4. package/dist/node-server/links-middleware.js +116 -0
  5. package/dist/ui/assets/{adobe-DPVj3u69.js → adobe-Ce4pGa6k.js} +1 -1
  6. package/dist/ui/assets/{adobe-BacdiaRI.js → adobe-CpY266Zc.js} +2 -2
  7. package/dist/ui/assets/{agent-bridge-C_Lf31Mc.js → agent-bridge-DGLDgqPE.js} +1 -1
  8. package/dist/ui/assets/{agent-message-to-chat-cYbNmTB0.js → agent-message-to-chat-ySHRDnOA.js} +1 -1
  9. package/dist/ui/assets/{azure-openai-DBoypzu4.js → azure-openai-7f0I1c2g.js} +1 -1
  10. package/dist/ui/assets/{azure-openai-GlKf0g8j.js → azure-openai-CqN5Wyf8.js} +1 -1
  11. package/dist/ui/assets/{cdp-BBp30x_7.js → cdp-C1mctqQQ.js} +3 -3
  12. package/dist/ui/assets/{chat-fixture-C_aYWFQ3.js → chat-fixture-B4ajo0MH.js} +1 -1
  13. package/dist/ui/assets/cost-command-De1m63Hp.js +1 -0
  14. package/dist/ui/assets/{es-YGqOEedH.js → es-CdoilK6E.js} +1 -1
  15. package/dist/ui/assets/{fs-DMLZk5ri.js → fs-BSEneDlc.js} +2 -2
  16. package/dist/ui/assets/{fs-CnFxqHi_.js → fs-D0XzcKxU.js} +1 -1
  17. package/dist/ui/assets/{github-B4zYlF3O.js → github-DvH9BDfk.js} +2 -2
  18. package/dist/ui/assets/{github-C6uaGWDq.js → github-ET50AuxZ.js} +1 -1
  19. package/dist/ui/assets/{index-WEr7axlJ.js → index-ZLv5StNy.js} +5 -5
  20. package/dist/ui/assets/{kernel-worker-BTlv8Daj.js → kernel-worker-UTlIe_KM.js} +996 -944
  21. package/dist/ui/assets/{local-llm-BeAS1wcq.js → local-llm-BeFRU84A.js} +1 -1
  22. package/dist/ui/assets/{local-llm-DYU-ke-D.js → local-llm-DnhS4Nc8.js} +1 -1
  23. package/dist/ui/assets/{magick-wasm-Bngjoiz2.js → magick-wasm-BCZpZeyl.js} +1 -1
  24. package/dist/ui/assets/{mount-VeVY46fd.js → mount-BRCe8J-8.js} +1 -1
  25. package/dist/ui/assets/{mount-CoIoFtIr.js → mount-vDUPSYAA.js} +2 -2
  26. package/dist/ui/assets/{nuke-command-BA1b-Wzd.js → nuke-command-BvSSDKyh.js} +1 -1
  27. package/dist/ui/assets/{oauth-bootstrap-C3293rGW.js → oauth-bootstrap-qeeH1muA.js} +1 -1
  28. package/dist/ui/assets/{oauth-service-nTW8BUoF.js → oauth-service-CP7_knvf.js} +1 -1
  29. package/dist/ui/assets/{oauth-service-BdI2dhUI.js → oauth-service-sgmdLPuV.js} +1 -1
  30. package/dist/ui/assets/{offscreen-client-BOfZponz.js → offscreen-client-BPqEe2hm.js} +1 -1
  31. package/dist/ui/assets/{onboarding-orchestrator-Cl8JaKUD.js → onboarding-orchestrator-BWrouEJg.js} +1 -1
  32. package/dist/ui/assets/{provider-settings-Q6epwg_s.js → provider-settings-BHwoEn-1.js} +3 -3
  33. package/dist/ui/assets/{provider-settings-BbHwYeGO.js → provider-settings-CNtqy5Bx.js} +1 -1
  34. package/dist/ui/assets/{providers-Cba37y95.js → providers-CR2KVBJC.js} +1 -1
  35. package/dist/ui/assets/{spawn-DXTDMocx.js → spawn-koTNaVLy.js} +1 -1
  36. package/dist/ui/assets/{upgrade-detection-DXpN7gYV.js → upgrade-detection-eWV10cS4.js} +1 -1
  37. package/dist/ui/electron-overlay-entry.js +3 -3
  38. package/dist/ui/index.html +4 -4
  39. package/dist/ui/packages/webapp/index.html +4 -4
  40. package/package.json +2 -2
  41. package/dist/ui/assets/cost-command-B6BonHqk.js +0 -1
package/README.md CHANGED
@@ -52,7 +52,7 @@ SLICC is for you if:
52
52
 
53
53
  - **Launch an agent from the CLI and let it work in the browser it controls.** Start one command, open the workspace, and give the agent shell tools, files, and live browser access in one place.
54
54
  - **Automate repetitive workflows in authenticated web apps.** Use browser automation, page inspection, screenshots, storage access, and scripted tab control where your logged-in browser session already has the context.
55
- - **Hand work off from another coding agent into your live browser session.** Open any URL whose response carries an `x-slicc` header (the tray-hub `/handoff?msg=...` endpoint is a convenience) and SLICC prompts you to approve the action inside the Chat tab.
55
+ - **Hand work off from another coding agent into your live browser session.** Open any URL whose response carries an RFC 8288 `Link` header with a SLICC handoff or upskill rel (the tray-hub `/handoff?handoff=...` / `?upskill=...` endpoint is a convenience) and SLICC prompts you to approve the action inside the Chat tab.
56
56
  - **Solve technical tasks with practical tools.** Reach for `bash`, `git`, `grep`, `node`, `python`, previews, and browser automation when the job is bigger than text generation.
57
57
  - **Add visual and file context directly in chat.** Drop images or files onto the workspace, or use the paperclip button. Dropped `.skill` archives still install into `/workspace/skills`.
58
58
  - **Delegate parallel work to scoops.** Split tasks into isolated sub-agents with their own sandboxes and context, then let the main agent coordinate the results.
@@ -23,6 +23,7 @@ import { OauthSecretStore } from './secrets/oauth-secret-store.js';
23
23
  import { handleDaSignAndForward, handleS3SignAndForward } from './secrets/sign-and-forward.js';
24
24
  import { readOrCreateSessionId } from './secrets/session-id-file.js';
25
25
  import { FETCH_PROXY_SKIP_HEADERS } from './fetch-proxy-headers.js';
26
+ import { buildLocalApiDescriptor, sliccLinksMiddleware } from './links-middleware.js';
26
27
  const __dirname = fileURLToPath(new URL('.', import.meta.url));
27
28
  const PROJECT_ROOT = resolve(__dirname, '..', '..');
28
29
  const RUNTIME_FLAGS = parseCliRuntimeFlags(process.argv.slice(2));
@@ -533,6 +534,8 @@ async function main() {
533
534
  }
534
535
  const app = express();
535
536
  app.use(requestLogger);
537
+ // Append SLICC's standard RFC 8288 Link header set on every /api/* response.
538
+ app.use(sliccLinksMiddleware());
536
539
  // ---------------------------------------------------------------------------
537
540
  // Lick system — WebSocket bridge for webhooks/crontasks (all logic in browser)
538
541
  // ---------------------------------------------------------------------------
@@ -683,6 +686,24 @@ async function main() {
683
686
  trayJoinUrl: discoveredTrayJoinUrl ?? null,
684
687
  });
685
688
  });
689
+ // Localhost API descriptor — the discoverable surface advertised by the
690
+ // `service-desc` Link rel. Matches the cloudflare-worker's
691
+ // `/.well-known/api-catalog` in shape but is scoped to the local CLI.
692
+ app.get('/api', (req, res) => {
693
+ const host = req.headers.host ?? `localhost:${SERVE_PORT}`;
694
+ res.json(buildLocalApiDescriptor(host));
695
+ });
696
+ // Public health document — advertised via the `status` rel (RFC 8631) in
697
+ // the standard Link header set so any consumer that walks the rels can
698
+ // probe liveness without hard-coding a path.
699
+ app.get('/api/status', (_req, res) => {
700
+ res.set('Cache-Control', 'no-store');
701
+ res.json({
702
+ status: 'ok',
703
+ service: 'slicc-node-server',
704
+ timestamp: new Date().toISOString(),
705
+ });
706
+ });
686
707
  // Tray status API — forwards to browser to get leader tray join info
687
708
  app.get('/api/tray-status', async (_req, res) => {
688
709
  try {
@@ -809,17 +830,57 @@ async function main() {
809
830
  // is installed. External tools (e.g. the slicc-handoff helper) post here
810
831
  // so a handoff reaches the cone regardless of which browser profile the
811
832
  // user is currently driving.
833
+ //
834
+ // The payload mirrors the parsed RFC 8288 `Link` form used by the
835
+ // observers: `verb` ∈ {handoff, upskill}, `target` is the resolved URL,
836
+ // `instruction` is optional free-form prose (handoff verb).
812
837
  app.post('/api/handoff', (req, res) => {
813
838
  const payload = req.body;
814
- if (typeof payload?.sliccHeader !== 'string' || payload.sliccHeader.length === 0) {
815
- res.status(400).json({ error: 'sliccHeader is required (non-empty string)' });
839
+ if (typeof payload?.sliccHeader === 'string') {
840
+ res.status(400).json({
841
+ error: 'The legacy `sliccHeader` payload was removed; post `{ verb, target, instruction? }` instead. See docs/slicc-handoff.md.',
842
+ });
843
+ return;
844
+ }
845
+ if (payload?.verb !== 'handoff' && payload?.verb !== 'upskill') {
846
+ res.status(400).json({ error: 'verb must be "handoff" or "upskill"' });
847
+ return;
848
+ }
849
+ if (typeof payload.target !== 'string' || payload.target.length === 0) {
850
+ res.status(400).json({ error: 'target is required (non-empty string)' });
851
+ return;
852
+ }
853
+ if (payload.instruction != null && typeof payload.instruction !== 'string') {
854
+ res.status(400).json({ error: 'instruction must be a string when provided' });
855
+ return;
856
+ }
857
+ // `branch` / `path` mirror the upskill rel's Link params and are
858
+ // ignored on the handoff verb (its target is the page itself, not a
859
+ // repo). Reject the wrong-shape combo loudly so emitters notice
860
+ // rather than silently dropping the scope.
861
+ if (payload.branch != null && typeof payload.branch !== 'string') {
862
+ res.status(400).json({ error: 'branch must be a string when provided' });
863
+ return;
864
+ }
865
+ if (payload.path != null && typeof payload.path !== 'string') {
866
+ res.status(400).json({ error: 'path must be a string when provided' });
867
+ return;
868
+ }
869
+ if (payload.verb === 'handoff' && (payload.branch != null || payload.path != null)) {
870
+ res.status(400).json({ error: 'branch and path are only valid with verb="upskill"' });
816
871
  return;
817
872
  }
818
873
  broadcastLickEvent({
819
874
  type: 'navigate_event',
820
- sliccHeader: payload.sliccHeader,
875
+ verb: payload.verb,
876
+ target: payload.target,
877
+ instruction: typeof payload.instruction === 'string' ? payload.instruction : undefined,
821
878
  url: typeof payload.url === 'string' && payload.url.length > 0 ? payload.url : 'about:handoff',
822
879
  title: typeof payload.title === 'string' ? payload.title : undefined,
880
+ branch: typeof payload.branch === 'string' && payload.branch.length > 0
881
+ ? payload.branch
882
+ : undefined,
883
+ path: typeof payload.path === 'string' && payload.path.length > 0 ? payload.path : undefined,
823
884
  timestamp: new Date().toISOString(),
824
885
  });
825
886
  res.json({ ok: true });
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Express middleware: append SLICC's standard RFC 8288 `Link` header set to
3
+ * every local `/api/*` response that describes a SLICC capability. Mirrors
4
+ * `applySliccLinks` in the cloudflare-worker so any SLICC HTTP surface
5
+ * advertises the same discoverable capabilities.
6
+ *
7
+ * Skipped for `/api/fetch-proxy`: that endpoint is a transparent CORS-bypass
8
+ * relay, so injecting localhost discovery rels there would pollute downstream
9
+ * `discover` consumers with bogus self-referential links. Also bails out if
10
+ * an earlier middleware already flushed response headers.
11
+ */
12
+ import type { NextFunction, Request, Response } from 'express';
13
+ /**
14
+ * Returns Express middleware that appends Link entries on every `/api/*`
15
+ * response except `/api/fetch-proxy` (a transparent relay). Uses `res.append`
16
+ * so existing Link headers survive intact.
17
+ */
18
+ export declare function sliccLinksMiddleware(): (req: Request, res: Response, next: NextFunction) => void;
19
+ /**
20
+ * Build the `GET /api` descriptor — a minimal JSON catalog of localhost
21
+ * endpoints. Mirrors what the cloudflare-worker's `/.well-known/api-catalog`
22
+ * does for the public surface, but scoped to the local CLI server.
23
+ */
24
+ export declare function buildLocalApiDescriptor(host: string): unknown;
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Express middleware: append SLICC's standard RFC 8288 `Link` header set to
3
+ * every local `/api/*` response that describes a SLICC capability. Mirrors
4
+ * `applySliccLinks` in the cloudflare-worker so any SLICC HTTP surface
5
+ * advertises the same discoverable capabilities.
6
+ *
7
+ * Skipped for `/api/fetch-proxy`: that endpoint is a transparent CORS-bypass
8
+ * relay, so injecting localhost discovery rels there would pollute downstream
9
+ * `discover` consumers with bogus self-referential links. Also bails out if
10
+ * an earlier middleware already flushed response headers.
11
+ */
12
+ const SLICC_BASE_REL = (origin) => [
13
+ `<${origin}/api>; rel="service-desc"; type="application/json"`,
14
+ `<https://github.com/ai-ecoverse/slicc>; rel="service-doc"`,
15
+ `<${origin}/api/status>; rel="status"; type="application/json"`,
16
+ `<https://github.com/ai-ecoverse/slicc#readme>; rel="terms-of-service"`,
17
+ ];
18
+ /**
19
+ * Returns Express middleware that appends Link entries on every `/api/*`
20
+ * response except `/api/fetch-proxy` (a transparent relay). Uses `res.append`
21
+ * so existing Link headers survive intact.
22
+ */
23
+ export function sliccLinksMiddleware() {
24
+ return (req, res, next) => {
25
+ if (res.headersSent) {
26
+ next();
27
+ return;
28
+ }
29
+ if (!req.path.startsWith('/api/') && req.path !== '/api') {
30
+ next();
31
+ return;
32
+ }
33
+ // `/api/fetch-proxy` and anything mounted underneath it relays a third-
34
+ // party response verbatim — adding our own rels would mislead clients
35
+ // that parse Link headers (e.g. the `discover` shell command).
36
+ if (req.path === '/api/fetch-proxy' || req.path.startsWith('/api/fetch-proxy/')) {
37
+ next();
38
+ return;
39
+ }
40
+ const host = req.headers.host;
41
+ if (!host) {
42
+ next();
43
+ return;
44
+ }
45
+ // The CLI server is always plaintext on localhost.
46
+ const origin = `http://${host}`;
47
+ for (const value of SLICC_BASE_REL(origin)) {
48
+ res.append('Link', value);
49
+ }
50
+ next();
51
+ };
52
+ }
53
+ /**
54
+ * Build the `GET /api` descriptor — a minimal JSON catalog of localhost
55
+ * endpoints. Mirrors what the cloudflare-worker's `/.well-known/api-catalog`
56
+ * does for the public surface, but scoped to the local CLI server.
57
+ */
58
+ export function buildLocalApiDescriptor(host) {
59
+ const origin = `http://${host}`;
60
+ return {
61
+ service: 'slicc-node-server',
62
+ description: 'Localhost server for SLICC standalone (CLI/Electron). State lives in the browser; this surface relays webhooks, signs S3/DA mount requests, and handles cross-agent handoffs.',
63
+ endpoints: [
64
+ {
65
+ anchor: `${origin}/api/runtime-config`,
66
+ method: 'GET',
67
+ description: 'Runtime config for the served webapp.',
68
+ },
69
+ {
70
+ anchor: `${origin}/api/status`,
71
+ method: 'GET',
72
+ description: 'Public health document (RFC 8631 status rel). Returns JSON `{ status, service, timestamp }`.',
73
+ },
74
+ {
75
+ anchor: `${origin}/api/tray-status`,
76
+ method: 'GET',
77
+ description: 'Tray hub connection status.',
78
+ },
79
+ {
80
+ anchor: `${origin}/api/webhooks`,
81
+ method: 'GET|POST',
82
+ description: 'List or create webhooks.',
83
+ },
84
+ {
85
+ anchor: `${origin}/api/crontasks`,
86
+ method: 'GET|POST',
87
+ description: 'List or create crontasks.',
88
+ },
89
+ {
90
+ anchor: `${origin}/api/handoff`,
91
+ method: 'POST',
92
+ description: 'Profile-independent cross-agent handoff. POST `{ verb: "handoff" | "upskill", target, instruction? }`.',
93
+ },
94
+ {
95
+ anchor: `${origin}/api/secrets`,
96
+ method: 'GET',
97
+ description: 'List secrets defined in the .env file.',
98
+ },
99
+ {
100
+ anchor: `${origin}/api/s3-sign-and-forward`,
101
+ method: 'POST',
102
+ description: 'SigV4-sign and forward an S3 request.',
103
+ },
104
+ {
105
+ anchor: `${origin}/api/da-sign-and-forward`,
106
+ method: 'POST',
107
+ description: 'IMS-token-sign and forward a DA request.',
108
+ },
109
+ {
110
+ anchor: `${origin}/api/fetch-proxy`,
111
+ method: 'ANY',
112
+ description: 'CORS-bypass fetch proxy.',
113
+ },
114
+ ],
115
+ };
116
+ }
@@ -1 +1 @@
1
- import{a as e,f as t,t as n}from"./provider-settings-BbHwYeGO.js";import{d as r,f as i,l as a,p as o,u as s}from"./bedrock-camp-CWcpoTdM.js";import{d as c,o as l,u}from"./transform-messages-uhk4b6os.js";import{t as d}from"./kernel-worker-BTlv8Daj.js";import{getOAuthPageOrigin as f}from"./oauth-service-nTW8BUoF.js";const p=Object.assign({"/packages/webapp/providers/adobe-config.json":{proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`}})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function m(){let t=e(`adobe`);if(t)return t.replace(/\/$/,``);if(p.proxyEndpoint)return p.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}const h=new Map,g=new Map;async function _(e){let t=h.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[M]:`2.52.2`}});if(t.ok){let n=await t.json();return h.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}let n={};return h.set(e,n),n}function v(e){let t=e.clientId||p.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function y(e){return e.scopes||p.scopes}function b(e){return e.imsEnvironment||p.imsEnvironment||`prod`}const x={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function S(e){return x[e??p.imsEnvironment??`prod`]??x.prod}const C=typeof chrome<`u`&&!!chrome?.runtime?.id;function w(){return n().find(e=>e.providerId===`adobe`)}async function T(e,t){try{let n=await fetch(`${S(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function E(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10)}:null}const D={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!p.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`],getModelIds:()=>{let e=e=>{let t={id:e.id,name:e.name??e.id},n=g.get(e.id);return n?.api&&(t.api=n.api),n?.context_window!==void 0&&(t.context_window=n.context_window),n?.max_tokens!==void 0&&(t.max_tokens=n.max_tokens),n?.reasoning!==void 0&&(t.reasoning=n.reasoning),n?.input&&(t.input=n.input),/haiku/i.test(e.id)&&(t.compat={supportsEagerToolInputStreaming:!1}),t};for(let t of V.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id}));try{localStorage.setItem(`slicc-adobe-models`,JSON.stringify(n))}catch{}return n}for(let t of h.values())if(t.models?.length)return t.models.map(e);try{let e=localStorage.getItem(`slicc-adobe-models`);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,n)=>{let r=m(),i=await _(r),a=v(i),o=y(i),s=b(i),c=C?null:await f(),l=C?p.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:p.redirectUri??`${c.origin}/auth/callback`,u=C?void 0:btoa(JSON.stringify({port:parseInt(new URL(c.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),d=u?JSON.parse(atob(u)).nonce:null,h=new URLSearchParams({client_id:a,scope:o,response_type:`token`,redirect_uri:l});u&&h.set(`state`,u);let g=await e(`${S(s)}/ims/authorize/v2?${h}`);if(!g)return;if(d&&g)try{if(new URL(g).searchParams.get(`nonce`)!==d){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let x=E(g);if(!x){console.error(`[adobe] Could not extract token from redirect URL`);return}let w=await T(x.accessToken,s);await t({providerId:`adobe`,accessToken:x.accessToken,tokenExpiresAt:Date.now()+x.expiresIn*1e3,userName:w.name,userAvatar:w.avatar,baseUrl:p.proxyEndpoint?void 0:r}),await H().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),n()},onOAuthLogout:async()=>{let e=w();if(e?.accessToken)try{let t=h.values().next().value??{},n=t.clientId||p.clientId,r=b(t);if(n){let t=await fetch(`${S(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await t({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>w()?.accessToken?j():null};let O=null;async function k(){let e=w();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);try{let e=await j();if(e)return e}catch(e){console.warn(`[adobe] Silent renewal failed:`,e instanceof Error?e.message:String(e))}let t=w();if((t?.tokenExpiresAt??0)-Date.now()>0&&t?.accessToken)return t.accessToken;throw Error(`Adobe session expired — please log in again`)}function A(){let e=w();return e?.tokenExpiresAt?Date.now()>e.tokenExpiresAt-6e4:!0}async function j(){return typeof window>`u`?null:O||(O=(async()=>{try{let e=m(),n=await _(e),r=v(n),i=y(n),a=b(n),o=C?p.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:p.redirectUri??`${window.location.origin}/auth/callback`,s=C?void 0:btoa(JSON.stringify({port:parseInt(new URL(window.location.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),c=s?JSON.parse(atob(s)).nonce:null,l=new URLSearchParams({client_id:r,scope:i,response_type:`token`,redirect_uri:o,prompt:`none`});s&&l.set(`state`,s);let u=`${S(a)}/ims/authorize/v2?${l}`,{createOAuthLauncher:d}=await import(`./oauth-service-nTW8BUoF.js`),f=await d()(u);if(!f)return null;if(c&&f)try{if(new URL(f).searchParams.get(`nonce`)!==c)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),null}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let h=E(f);if(!h)return null;let g=w();return await t({providerId:`adobe`,accessToken:h.accessToken,tokenExpiresAt:Date.now()+h.expiresIn*1e3,userName:g?.userName,userAvatar:g?.userAvatar,baseUrl:p.proxyEndpoint?void 0:e}),console.log(`[adobe] Token renewed silently`),await H().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),h.accessToken}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}finally{O=null}})(),O)}const M=`X-Slicc-Version`;function N(e){let t={};if(e.headers)for(let[n,r]of Object.entries(e.headers))n.toLowerCase()!==`x-slicc-version`&&(t[n]=r);return t[M]=`2.52.2`,{...e,headers:t}}const P=new Set;function F(e,t){if(e.headers){for(let t of Object.keys(e.headers))if(t.toLowerCase()===`x-session-id`)return e}return P.has(t)||(P.add(t),console.warn(`[adobe] Missing X-Session-Id from ${t} — using daily fallback. Attach an X-Session-Id header at the call site (see scoop-context.ts streamWithSessionId or docs/pitfalls.md).`)),{...e,headers:{...e.headers??{},"X-Session-Id":d(`adobe-provider-fallback`)}}}function I(){P.clear()}function L(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const R=(e,t,n={})=>{let r=l();return(async()=>{try{let i=await k();if(String(e.api).includes(`openai`)){let a=s({...e,baseUrl:`${m()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,N(F({...n,apiKey:i},`streamAdobe[openai]`)));for await(let e of a)r.push(e)}else{let o=a({...e,baseUrl:m(),api:`anthropic-messages`},t,N(F({...n,apiKey:i},`streamAdobe[anthropic]`)));for await(let e of o)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(L(e,t)),r.end()}})(),r},z=(e,t,n)=>{let a=l();return(async()=>{try{let o=await k();if(String(e.api).includes(`openai`)){let r=i({...e,baseUrl:`${m()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,N(F({...n,apiKey:o},`streamSimpleAdobe[openai]`)));for await(let e of r)a.push(e)}else{let i=r({...e,baseUrl:m(),api:`anthropic-messages`},t,N(F({...n,apiKey:o},`streamSimpleAdobe[anthropic]`)));for await(let e of i)a.push(e)}a.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),a.push(L(e,t)),a.end()}})(),a};async function B(){try{let e=await k(),t=m(),n=await fetch(`${t}/v1/models`,{headers:{Authorization:`Bearer ${e}`,[M]:`2.52.2`}});if(n.ok){let e=await n.json();if(e.data?.length){for(let t of e.data){let e={id:t.id,name:t.name};t.api!==void 0&&(e.api=t.api),t.context_window!==void 0&&(e.context_window=t.context_window),t.max_tokens!==void 0&&(e.max_tokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),g.set(t.id,e)}let n=new Map;for(let e of c())try{for(let t of u(e))n.set(t.id,t)}catch{}return e.data.map(e=>{let r=n.get(e.id),i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`;return r?{...r,provider:`adobe`,api:i}:{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:t,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}})}}else console.warn(`[adobe] Proxy /v1/models returned ${n.status}, falling back to Anthropic models`)}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return u(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}const V=new Map;async function H(){let e=m(),t=V.get(e);if(t)return t;let n=await B();return V.set(e,n),n}function U(){o({api:`adobe-anthropic`,stream:R,streamSimple:z}),o({api:`adobe-openai`,stream:R,streamSimple:z})}export{I as __resetAdobeSessionIdWarningCacheForTests,D as config,H as getAdobeModels,k as getValidAccessToken,A as isTokenExpired,U as register};
1
+ import{a as e,f as t,t as n}from"./provider-settings-CNtqy5Bx.js";import{d as r,f as i,l as a,p as o,u as s}from"./bedrock-camp-CWcpoTdM.js";import{d as c,o as l,u}from"./transform-messages-uhk4b6os.js";import{t as d}from"./kernel-worker-UTlIe_KM.js";import{getOAuthPageOrigin as f}from"./oauth-service-CP7_knvf.js";const p=Object.assign({"/packages/webapp/providers/adobe-config.json":{proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`}})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function m(){let t=e(`adobe`);if(t)return t.replace(/\/$/,``);if(p.proxyEndpoint)return p.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}const h=new Map,g=new Map;async function _(e){let t=h.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[M]:`2.53.0`}});if(t.ok){let n=await t.json();return h.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}let n={};return h.set(e,n),n}function v(e){let t=e.clientId||p.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function y(e){return e.scopes||p.scopes}function b(e){return e.imsEnvironment||p.imsEnvironment||`prod`}const x={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function S(e){return x[e??p.imsEnvironment??`prod`]??x.prod}const C=typeof chrome<`u`&&!!chrome?.runtime?.id;function w(){return n().find(e=>e.providerId===`adobe`)}async function T(e,t){try{let n=await fetch(`${S(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function E(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10)}:null}const D={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!p.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`],getModelIds:()=>{let e=e=>{let t={id:e.id,name:e.name??e.id},n=g.get(e.id);return n?.api&&(t.api=n.api),n?.context_window!==void 0&&(t.context_window=n.context_window),n?.max_tokens!==void 0&&(t.max_tokens=n.max_tokens),n?.reasoning!==void 0&&(t.reasoning=n.reasoning),n?.input&&(t.input=n.input),/haiku/i.test(e.id)&&(t.compat={supportsEagerToolInputStreaming:!1}),t};for(let t of V.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id}));try{localStorage.setItem(`slicc-adobe-models`,JSON.stringify(n))}catch{}return n}for(let t of h.values())if(t.models?.length)return t.models.map(e);try{let e=localStorage.getItem(`slicc-adobe-models`);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,n)=>{let r=m(),i=await _(r),a=v(i),o=y(i),s=b(i),c=C?null:await f(),l=C?p.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:p.redirectUri??`${c.origin}/auth/callback`,u=C?void 0:btoa(JSON.stringify({port:parseInt(new URL(c.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),d=u?JSON.parse(atob(u)).nonce:null,h=new URLSearchParams({client_id:a,scope:o,response_type:`token`,redirect_uri:l});u&&h.set(`state`,u);let g=await e(`${S(s)}/ims/authorize/v2?${h}`);if(!g)return;if(d&&g)try{if(new URL(g).searchParams.get(`nonce`)!==d){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let x=E(g);if(!x){console.error(`[adobe] Could not extract token from redirect URL`);return}let w=await T(x.accessToken,s);await t({providerId:`adobe`,accessToken:x.accessToken,tokenExpiresAt:Date.now()+x.expiresIn*1e3,userName:w.name,userAvatar:w.avatar,baseUrl:p.proxyEndpoint?void 0:r}),await H().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),n()},onOAuthLogout:async()=>{let e=w();if(e?.accessToken)try{let t=h.values().next().value??{},n=t.clientId||p.clientId,r=b(t);if(n){let t=await fetch(`${S(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await t({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>w()?.accessToken?j():null};let O=null;async function k(){let e=w();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);try{let e=await j();if(e)return e}catch(e){console.warn(`[adobe] Silent renewal failed:`,e instanceof Error?e.message:String(e))}let t=w();if((t?.tokenExpiresAt??0)-Date.now()>0&&t?.accessToken)return t.accessToken;throw Error(`Adobe session expired — please log in again`)}function A(){let e=w();return e?.tokenExpiresAt?Date.now()>e.tokenExpiresAt-6e4:!0}async function j(){return typeof window>`u`?null:O||(O=(async()=>{try{let e=m(),n=await _(e),r=v(n),i=y(n),a=b(n),o=C?p.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:p.redirectUri??`${window.location.origin}/auth/callback`,s=C?void 0:btoa(JSON.stringify({port:parseInt(new URL(window.location.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),c=s?JSON.parse(atob(s)).nonce:null,l=new URLSearchParams({client_id:r,scope:i,response_type:`token`,redirect_uri:o,prompt:`none`});s&&l.set(`state`,s);let u=`${S(a)}/ims/authorize/v2?${l}`,{createOAuthLauncher:d}=await import(`./oauth-service-CP7_knvf.js`),f=await d()(u);if(!f)return null;if(c&&f)try{if(new URL(f).searchParams.get(`nonce`)!==c)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),null}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let h=E(f);if(!h)return null;let g=w();return await t({providerId:`adobe`,accessToken:h.accessToken,tokenExpiresAt:Date.now()+h.expiresIn*1e3,userName:g?.userName,userAvatar:g?.userAvatar,baseUrl:p.proxyEndpoint?void 0:e}),console.log(`[adobe] Token renewed silently`),await H().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),h.accessToken}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}finally{O=null}})(),O)}const M=`X-Slicc-Version`;function N(e){let t={};if(e.headers)for(let[n,r]of Object.entries(e.headers))n.toLowerCase()!==`x-slicc-version`&&(t[n]=r);return t[M]=`2.53.0`,{...e,headers:t}}const P=new Set;function F(e,t){if(e.headers){for(let t of Object.keys(e.headers))if(t.toLowerCase()===`x-session-id`)return e}return P.has(t)||(P.add(t),console.warn(`[adobe] Missing X-Session-Id from ${t} — using daily fallback. Attach an X-Session-Id header at the call site (see scoop-context.ts streamWithSessionId or docs/pitfalls.md).`)),{...e,headers:{...e.headers??{},"X-Session-Id":d(`adobe-provider-fallback`)}}}function I(){P.clear()}function L(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const R=(e,t,n={})=>{let r=l();return(async()=>{try{let i=await k();if(String(e.api).includes(`openai`)){let a=s({...e,baseUrl:`${m()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,N(F({...n,apiKey:i},`streamAdobe[openai]`)));for await(let e of a)r.push(e)}else{let o=a({...e,baseUrl:m(),api:`anthropic-messages`},t,N(F({...n,apiKey:i},`streamAdobe[anthropic]`)));for await(let e of o)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(L(e,t)),r.end()}})(),r},z=(e,t,n)=>{let a=l();return(async()=>{try{let o=await k();if(String(e.api).includes(`openai`)){let r=i({...e,baseUrl:`${m()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,N(F({...n,apiKey:o},`streamSimpleAdobe[openai]`)));for await(let e of r)a.push(e)}else{let i=r({...e,baseUrl:m(),api:`anthropic-messages`},t,N(F({...n,apiKey:o},`streamSimpleAdobe[anthropic]`)));for await(let e of i)a.push(e)}a.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),a.push(L(e,t)),a.end()}})(),a};async function B(){try{let e=await k(),t=m(),n=await fetch(`${t}/v1/models`,{headers:{Authorization:`Bearer ${e}`,[M]:`2.53.0`}});if(n.ok){let e=await n.json();if(e.data?.length){for(let t of e.data){let e={id:t.id,name:t.name};t.api!==void 0&&(e.api=t.api),t.context_window!==void 0&&(e.context_window=t.context_window),t.max_tokens!==void 0&&(e.max_tokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),g.set(t.id,e)}let n=new Map;for(let e of c())try{for(let t of u(e))n.set(t.id,t)}catch{}return e.data.map(e=>{let r=n.get(e.id),i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`;return r?{...r,provider:`adobe`,api:i}:{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:t,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}})}}else console.warn(`[adobe] Proxy /v1/models returned ${n.status}, falling back to Anthropic models`)}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return u(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}const V=new Map;async function H(){let e=m(),t=V.get(e);if(t)return t;let n=await B();return V.set(e,n),n}function U(){o({api:`adobe-anthropic`,stream:R,streamSimple:z}),o({api:`adobe-openai`,stream:R,streamSimple:z})}export{I as __resetAdobeSessionIdWarningCacheForTests,D as config,H as getAdobeModels,k as getValidAccessToken,A as isTokenExpired,U as register};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/oauth-service-BdI2dhUI.js","assets/index-WEr7axlJ.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-ca-nBW7U.js","assets/provider-settings-Q6epwg_s.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-BHB_tqYb.js","assets/fs-DMLZk5ri.js","assets/backend-local-D-jeTNnr.js","assets/mount-picker-popup-DJJfRF_c.js","assets/path-utils-d3qOVZOu.js","assets/mime-types-DL940yDZ.js","assets/mount-CoIoFtIr.js","assets/index-eWuuouO-.css"])))=>i.map(i=>d[i]);
2
- import{r as e,s as t,v as n}from"./provider-settings-Q6epwg_s.js";import{t as r}from"./preload-helper-ca-nBW7U.js";import{c as i,l as a,o,s,u as c}from"./bedrock-camp-CqXHYC67.js";import{d as l,o as u,u as d}from"./simple-options-imi_RHvn.js";import{o as f}from"./index-WEr7axlJ.js";import{getOAuthPageOrigin as p}from"./oauth-service-BdI2dhUI.js";var m=Object.assign({"/packages/webapp/providers/adobe-config.json":{proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`}})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function h(){let e=t(`adobe`);if(e)return e.replace(/\/$/,``);if(m.proxyEndpoint)return m.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}var g=new Map,_=new Map;async function v(e){let t=g.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[N]:`2.52.2`}});if(t.ok){let n=await t.json();return g.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}let n={};return g.set(e,n),n}function y(e){let t=e.clientId||m.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function b(e){return e.scopes||m.scopes}function x(e){return e.imsEnvironment||m.imsEnvironment||`prod`}var S={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function C(e){return S[e??m.imsEnvironment??`prod`]??S.prod}var w=typeof chrome<`u`&&!!chrome?.runtime?.id;function T(){return e().find(e=>e.providerId===`adobe`)}async function E(e,t){try{let n=await fetch(`${C(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function D(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10)}:null}var O={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!m.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`],getModelIds:()=>{let e=e=>{let t={id:e.id,name:e.name??e.id},n=_.get(e.id);return n?.api&&(t.api=n.api),n?.context_window!==void 0&&(t.context_window=n.context_window),n?.max_tokens!==void 0&&(t.max_tokens=n.max_tokens),n?.reasoning!==void 0&&(t.reasoning=n.reasoning),n?.input&&(t.input=n.input),/haiku/i.test(e.id)&&(t.compat={supportsEagerToolInputStreaming:!1}),t};for(let t of U.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id}));try{localStorage.setItem(`slicc-adobe-models`,JSON.stringify(n))}catch{}return n}for(let t of g.values())if(t.models?.length)return t.models.map(e);try{let e=localStorage.getItem(`slicc-adobe-models`);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,t)=>{let r=h(),i=await v(r),a=y(i),o=b(i),s=x(i),c=w?null:await p(),l=w?m.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:m.redirectUri??`${c.origin}/auth/callback`,u=w?void 0:btoa(JSON.stringify({port:parseInt(new URL(c.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),d=u?JSON.parse(atob(u)).nonce:null,f=new URLSearchParams({client_id:a,scope:o,response_type:`token`,redirect_uri:l});u&&f.set(`state`,u);let g=await e(`${C(s)}/ims/authorize/v2?${f}`);if(!g)return;if(d&&g)try{if(new URL(g).searchParams.get(`nonce`)!==d){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let _=D(g);if(!_){console.error(`[adobe] Could not extract token from redirect URL`);return}let S=await E(_.accessToken,s);await n({providerId:`adobe`,accessToken:_.accessToken,tokenExpiresAt:Date.now()+_.expiresIn*1e3,userName:S.name,userAvatar:S.avatar,baseUrl:m.proxyEndpoint?void 0:r}),await W().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),t()},onOAuthLogout:async()=>{let e=T();if(e?.accessToken)try{let t=g.values().next().value??{},n=t.clientId||m.clientId,r=x(t);if(n){let t=await fetch(`${C(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await n({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>T()?.accessToken?M():null},k=null;async function A(){let e=T();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);try{let e=await M();if(e)return e}catch(e){console.warn(`[adobe] Silent renewal failed:`,e instanceof Error?e.message:String(e))}let t=T();if((t?.tokenExpiresAt??0)-Date.now()>0&&t?.accessToken)return t.accessToken;throw Error(`Adobe session expired — please log in again`)}function j(){let e=T();return e?.tokenExpiresAt?Date.now()>e.tokenExpiresAt-6e4:!0}async function M(){return typeof window>`u`?null:k||(k=(async()=>{try{let e=h(),t=await v(e),i=y(t),a=b(t),o=x(t),s=w?m.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:m.redirectUri??`${window.location.origin}/auth/callback`,c=w?void 0:btoa(JSON.stringify({port:parseInt(new URL(window.location.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),l=c?JSON.parse(atob(c)).nonce:null,u=new URLSearchParams({client_id:i,scope:a,response_type:`token`,redirect_uri:s,prompt:`none`});c&&u.set(`state`,c);let d=`${C(o)}/ims/authorize/v2?${u}`,{createOAuthLauncher:f}=await r(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-BdI2dhUI.js`);return{createOAuthLauncher:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])),p=await f()(d);if(!p)return null;if(l&&p)try{if(new URL(p).searchParams.get(`nonce`)!==l)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),null}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let g=D(p);if(!g)return null;let _=T();return await n({providerId:`adobe`,accessToken:g.accessToken,tokenExpiresAt:Date.now()+g.expiresIn*1e3,userName:_?.userName,userAvatar:_?.userAvatar,baseUrl:m.proxyEndpoint?void 0:e}),console.log(`[adobe] Token renewed silently`),await W().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),g.accessToken}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}finally{k=null}})(),k)}var N=`X-Slicc-Version`;function P(e){let t={},n=N.toLowerCase();if(e.headers)for(let[r,i]of Object.entries(e.headers))r.toLowerCase()!==n&&(t[r]=i);return t[N]=`2.52.2`,{...e,headers:t}}var F=`adobe-provider-fallback`,I=new Set;function L(e,t){if(e.headers){for(let t of Object.keys(e.headers))if(t.toLowerCase()===`x-session-id`)return e}return I.has(t)||(I.add(t),console.warn(`[adobe] Missing X-Session-Id from ${t} — using daily fallback. Attach an X-Session-Id header at the call site (see scoop-context.ts streamWithSessionId or docs/pitfalls.md).`)),{...e,headers:{...e.headers??{},"X-Session-Id":f(F)}}}function R(){I.clear()}function z(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}var B=(e,t,n={})=>{let r=u();return(async()=>{try{let i=await A();if(String(e.api).includes(`openai`)){let a=s({...e,baseUrl:`${h()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,P(L({...n,apiKey:i},`streamAdobe[openai]`)));for await(let e of a)r.push(e)}else{let a=o({...e,baseUrl:h(),api:`anthropic-messages`},t,P(L({...n,apiKey:i},`streamAdobe[anthropic]`)));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(z(e,t)),r.end()}})(),r},V=(e,t,n)=>{let r=u();return(async()=>{try{let o=await A();if(String(e.api).includes(`openai`)){let i=a({...e,baseUrl:`${h()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,P(L({...n,apiKey:o},`streamSimpleAdobe[openai]`)));for await(let e of i)r.push(e)}else{let a=i({...e,baseUrl:h(),api:`anthropic-messages`},t,P(L({...n,apiKey:o},`streamSimpleAdobe[anthropic]`)));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(z(e,t)),r.end()}})(),r};async function H(){try{let e=await A(),t=h(),n=await fetch(`${t}/v1/models`,{headers:{Authorization:`Bearer ${e}`,[N]:`2.52.2`}});if(n.ok){let e=await n.json();if(e.data?.length){for(let t of e.data){let e={id:t.id,name:t.name};t.api!==void 0&&(e.api=t.api),t.context_window!==void 0&&(e.context_window=t.context_window),t.max_tokens!==void 0&&(e.max_tokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),_.set(t.id,e)}let n=new Map;for(let e of l())try{for(let t of d(e))n.set(t.id,t)}catch{}return e.data.map(e=>{let r=n.get(e.id),i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`;return r?{...r,provider:`adobe`,api:i}:{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:t,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}})}}else console.warn(`[adobe] Proxy /v1/models returned ${n.status}, falling back to Anthropic models`)}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return d(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}var U=new Map;async function W(){let e=h(),t=U.get(e);if(t)return t;let n=await H();return U.set(e,n),n}function G(){c({api:`adobe-anthropic`,stream:B,streamSimple:V}),c({api:`adobe-openai`,stream:B,streamSimple:V})}export{R as __resetAdobeSessionIdWarningCacheForTests,O as config,W as getAdobeModels,A as getValidAccessToken,j as isTokenExpired,G as register};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/oauth-service-sgmdLPuV.js","assets/index-ZLv5StNy.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-ca-nBW7U.js","assets/provider-settings-BHwoEn-1.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-BHB_tqYb.js","assets/fs-BSEneDlc.js","assets/backend-local-D-jeTNnr.js","assets/mount-picker-popup-DJJfRF_c.js","assets/path-utils-d3qOVZOu.js","assets/mime-types-DL940yDZ.js","assets/mount-vDUPSYAA.js","assets/index-eWuuouO-.css"])))=>i.map(i=>d[i]);
2
+ import{r as e,s as t,v as n}from"./provider-settings-BHwoEn-1.js";import{t as r}from"./preload-helper-ca-nBW7U.js";import{c as i,l as a,o,s,u as c}from"./bedrock-camp-CqXHYC67.js";import{d as l,o as u,u as d}from"./simple-options-imi_RHvn.js";import{o as f}from"./index-ZLv5StNy.js";import{getOAuthPageOrigin as p}from"./oauth-service-sgmdLPuV.js";var m=Object.assign({"/packages/webapp/providers/adobe-config.json":{proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`}})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function h(){let e=t(`adobe`);if(e)return e.replace(/\/$/,``);if(m.proxyEndpoint)return m.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}var g=new Map,_=new Map;async function v(e){let t=g.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[N]:`2.53.0`}});if(t.ok){let n=await t.json();return g.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}let n={};return g.set(e,n),n}function y(e){let t=e.clientId||m.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function b(e){return e.scopes||m.scopes}function x(e){return e.imsEnvironment||m.imsEnvironment||`prod`}var S={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function C(e){return S[e??m.imsEnvironment??`prod`]??S.prod}var w=typeof chrome<`u`&&!!chrome?.runtime?.id;function T(){return e().find(e=>e.providerId===`adobe`)}async function E(e,t){try{let n=await fetch(`${C(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function D(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10)}:null}var O={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!m.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`],getModelIds:()=>{let e=e=>{let t={id:e.id,name:e.name??e.id},n=_.get(e.id);return n?.api&&(t.api=n.api),n?.context_window!==void 0&&(t.context_window=n.context_window),n?.max_tokens!==void 0&&(t.max_tokens=n.max_tokens),n?.reasoning!==void 0&&(t.reasoning=n.reasoning),n?.input&&(t.input=n.input),/haiku/i.test(e.id)&&(t.compat={supportsEagerToolInputStreaming:!1}),t};for(let t of U.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id}));try{localStorage.setItem(`slicc-adobe-models`,JSON.stringify(n))}catch{}return n}for(let t of g.values())if(t.models?.length)return t.models.map(e);try{let e=localStorage.getItem(`slicc-adobe-models`);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,t)=>{let r=h(),i=await v(r),a=y(i),o=b(i),s=x(i),c=w?null:await p(),l=w?m.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:m.redirectUri??`${c.origin}/auth/callback`,u=w?void 0:btoa(JSON.stringify({port:parseInt(new URL(c.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),d=u?JSON.parse(atob(u)).nonce:null,f=new URLSearchParams({client_id:a,scope:o,response_type:`token`,redirect_uri:l});u&&f.set(`state`,u);let g=await e(`${C(s)}/ims/authorize/v2?${f}`);if(!g)return;if(d&&g)try{if(new URL(g).searchParams.get(`nonce`)!==d){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let _=D(g);if(!_){console.error(`[adobe] Could not extract token from redirect URL`);return}let S=await E(_.accessToken,s);await n({providerId:`adobe`,accessToken:_.accessToken,tokenExpiresAt:Date.now()+_.expiresIn*1e3,userName:S.name,userAvatar:S.avatar,baseUrl:m.proxyEndpoint?void 0:r}),await W().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),t()},onOAuthLogout:async()=>{let e=T();if(e?.accessToken)try{let t=g.values().next().value??{},n=t.clientId||m.clientId,r=x(t);if(n){let t=await fetch(`${C(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await n({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>T()?.accessToken?M():null},k=null;async function A(){let e=T();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);try{let e=await M();if(e)return e}catch(e){console.warn(`[adobe] Silent renewal failed:`,e instanceof Error?e.message:String(e))}let t=T();if((t?.tokenExpiresAt??0)-Date.now()>0&&t?.accessToken)return t.accessToken;throw Error(`Adobe session expired — please log in again`)}function j(){let e=T();return e?.tokenExpiresAt?Date.now()>e.tokenExpiresAt-6e4:!0}async function M(){return typeof window>`u`?null:k||(k=(async()=>{try{let e=h(),t=await v(e),i=y(t),a=b(t),o=x(t),s=w?m.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:m.redirectUri??`${window.location.origin}/auth/callback`,c=w?void 0:btoa(JSON.stringify({port:parseInt(new URL(window.location.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),l=c?JSON.parse(atob(c)).nonce:null,u=new URLSearchParams({client_id:i,scope:a,response_type:`token`,redirect_uri:s,prompt:`none`});c&&u.set(`state`,c);let d=`${C(o)}/ims/authorize/v2?${u}`,{createOAuthLauncher:f}=await r(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-sgmdLPuV.js`);return{createOAuthLauncher:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])),p=await f()(d);if(!p)return null;if(l&&p)try{if(new URL(p).searchParams.get(`nonce`)!==l)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),null}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let g=D(p);if(!g)return null;let _=T();return await n({providerId:`adobe`,accessToken:g.accessToken,tokenExpiresAt:Date.now()+g.expiresIn*1e3,userName:_?.userName,userAvatar:_?.userAvatar,baseUrl:m.proxyEndpoint?void 0:e}),console.log(`[adobe] Token renewed silently`),await W().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),g.accessToken}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}finally{k=null}})(),k)}var N=`X-Slicc-Version`;function P(e){let t={},n=N.toLowerCase();if(e.headers)for(let[r,i]of Object.entries(e.headers))r.toLowerCase()!==n&&(t[r]=i);return t[N]=`2.53.0`,{...e,headers:t}}var F=`adobe-provider-fallback`,I=new Set;function L(e,t){if(e.headers){for(let t of Object.keys(e.headers))if(t.toLowerCase()===`x-session-id`)return e}return I.has(t)||(I.add(t),console.warn(`[adobe] Missing X-Session-Id from ${t} — using daily fallback. Attach an X-Session-Id header at the call site (see scoop-context.ts streamWithSessionId or docs/pitfalls.md).`)),{...e,headers:{...e.headers??{},"X-Session-Id":f(F)}}}function R(){I.clear()}function z(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}var B=(e,t,n={})=>{let r=u();return(async()=>{try{let i=await A();if(String(e.api).includes(`openai`)){let a=s({...e,baseUrl:`${h()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,P(L({...n,apiKey:i},`streamAdobe[openai]`)));for await(let e of a)r.push(e)}else{let a=o({...e,baseUrl:h(),api:`anthropic-messages`},t,P(L({...n,apiKey:i},`streamAdobe[anthropic]`)));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(z(e,t)),r.end()}})(),r},V=(e,t,n)=>{let r=u();return(async()=>{try{let o=await A();if(String(e.api).includes(`openai`)){let i=a({...e,baseUrl:`${h()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,P(L({...n,apiKey:o},`streamSimpleAdobe[openai]`)));for await(let e of i)r.push(e)}else{let a=i({...e,baseUrl:h(),api:`anthropic-messages`},t,P(L({...n,apiKey:o},`streamSimpleAdobe[anthropic]`)));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(z(e,t)),r.end()}})(),r};async function H(){try{let e=await A(),t=h(),n=await fetch(`${t}/v1/models`,{headers:{Authorization:`Bearer ${e}`,[N]:`2.53.0`}});if(n.ok){let e=await n.json();if(e.data?.length){for(let t of e.data){let e={id:t.id,name:t.name};t.api!==void 0&&(e.api=t.api),t.context_window!==void 0&&(e.context_window=t.context_window),t.max_tokens!==void 0&&(e.max_tokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),_.set(t.id,e)}let n=new Map;for(let e of l())try{for(let t of d(e))n.set(t.id,t)}catch{}return e.data.map(e=>{let r=n.get(e.id),i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`;return r?{...r,provider:`adobe`,api:i}:{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:t,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}})}}else console.warn(`[adobe] Proxy /v1/models returned ${n.status}, falling back to Anthropic models`)}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return d(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}var U=new Map;async function W(){let e=h(),t=U.get(e);if(t)return t;let n=await H();return U.set(e,n),n}function G(){c({api:`adobe-anthropic`,stream:B,streamSimple:V}),c({api:`adobe-openai`,stream:B,streamSimple:V})}export{R as __resetAdobeSessionIdWarningCacheForTests,O as config,W as getAdobeModels,A as getValidAccessToken,j as isTokenExpired,G as register};
@@ -1 +1 @@
1
- import{t as e}from"./logger-B-No_qN_.js";import"./provider-settings-Q6epwg_s.js";var t=e(`agent-bridge`),n=`__slicc_agent`,r=`agent-spawn-request`;function i(){let e={spawn(e){return new Promise((t,n)=>{let i=globalThis.chrome?.runtime;if(!i||typeof i.sendMessage!=`function`){n(Error(`agent: chrome.runtime.sendMessage not available`));return}let a=e=>{let r=i.lastError;if(r){n(Error(r.message??`chrome.runtime error`));return}if(e==null){n(Error(`agent: empty response from offscreen bridge`));return}let a=e;if(!a.ok){n(Error(a.error??`agent: offscreen bridge error`));return}if(!a.result){n(Error(`agent: offscreen bridge returned no result`));return}t(a.result)};try{i.sendMessage({source:`panel`,payload:{type:r,options:e}},a)}catch(e){n(e instanceof Error?e:Error(String(e)))}})}};return globalThis[n]=e,t.info(`agent bridge proxy published on globalThis.__slicc_agent`),e}export{i as publishAgentBridgeProxy};
1
+ import{t as e}from"./logger-B-No_qN_.js";import"./provider-settings-BHwoEn-1.js";var t=e(`agent-bridge`),n=`__slicc_agent`,r=`agent-spawn-request`;function i(){let e={spawn(e){return new Promise((t,n)=>{let i=globalThis.chrome?.runtime;if(!i||typeof i.sendMessage!=`function`){n(Error(`agent: chrome.runtime.sendMessage not available`));return}let a=e=>{let r=i.lastError;if(r){n(Error(r.message??`chrome.runtime error`));return}if(e==null){n(Error(`agent: empty response from offscreen bridge`));return}let a=e;if(!a.ok){n(Error(a.error??`agent: offscreen bridge error`));return}if(!a.result){n(Error(`agent: offscreen bridge returned no result`));return}t(a.result)};try{i.sendMessage({source:`panel`,payload:{type:r,options:e}},a)}catch(e){n(e instanceof Error?e:Error(String(e)))}})}};return globalThis[n]=e,t.info(`agent bridge proxy published on globalThis.__slicc_agent`),e}export{i as publishAgentBridgeProxy};
@@ -1,4 +1,4 @@
1
- import{a as e}from"./kernel-worker-BTlv8Daj.js";const t=new Set([`webhook`,`cron`,`sprinkle`,`fswatch`,`session-reload`,`navigate`,`upgrade`,`scoop-notify`,`scoop-idle`,`scoop-wait`]);function n(e){return e!=null&&t.has(e)}function r(t,n={}){let{source:r=`cone`,idSeed:c=d,hiddenToolNames:l=e}=n,f=[],h=null,g=new Set;for(let e of t){if(i(e)){let t=s(e.content);if(t.length===0)continue;let n=p(t);for(let t of n){if(t.body.length===0&&t.sender==null)continue;let n=t.sender?m(t.sender):null,r={id:c(),role:`user`,content:t.body,timestamp:e.timestamp};n&&(r.source=`lick`,r.channel=n),f.push(r)}h=null;continue}if(a(e)){let t=s(e.content),n=u(e),i=[];for(let e of n)l.has(e.name)?g.add(e.id):i.push(e);let a={id:c(),role:`assistant`,content:t,timestamp:e.timestamp,source:r};i.length>0&&(a.toolCalls=i),f.push(a),h=a;continue}if(o(e)){if(g.has(e.toolCallId))continue;let t=h?.toolCalls?.find(t=>t.id===e.toolCallId);if(!t)continue;t.result=s(e.content),t.isError=e.isError;continue}}return f}function i(e){return e.role===`user`}function a(e){return e.role===`assistant`}function o(e){return e.role===`toolResult`}function s(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return``;let t=[];for(let n of e)c(n)&&t.push(n.text);return t.join(``)}function c(e){return e.type===`text`}function l(e){return e.type===`toolCall`}function u(e){if(!Array.isArray(e.content))return[];let t=[];for(let n of e.content)l(n)&&t.push({id:n.id,name:n.name,input:n.arguments});return t}function d(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}function f(e){if(!e.startsWith(`[`))return null;let n=e.indexOf(`] `);if(n<=0||e.lastIndexOf(`
1
+ import{a as e}from"./kernel-worker-UTlIe_KM.js";const t=new Set([`webhook`,`cron`,`sprinkle`,`fswatch`,`session-reload`,`navigate`,`upgrade`,`scoop-notify`,`scoop-idle`,`scoop-wait`]);function n(e){return e!=null&&t.has(e)}function r(t,n={}){let{source:r=`cone`,idSeed:c=d,hiddenToolNames:l=e}=n,f=[],h=null,g=new Set;for(let e of t){if(i(e)){let t=s(e.content);if(t.length===0)continue;let n=p(t);for(let t of n){if(t.body.length===0&&t.sender==null)continue;let n=t.sender?m(t.sender):null,r={id:c(),role:`user`,content:t.body,timestamp:e.timestamp};n&&(r.source=`lick`,r.channel=n),f.push(r)}h=null;continue}if(a(e)){let t=s(e.content),n=u(e),i=[];for(let e of n)l.has(e.name)?g.add(e.id):i.push(e);let a={id:c(),role:`assistant`,content:t,timestamp:e.timestamp,source:r};i.length>0&&(a.toolCalls=i),f.push(a),h=a;continue}if(o(e)){if(g.has(e.toolCallId))continue;let t=h?.toolCalls?.find(t=>t.id===e.toolCallId);if(!t)continue;t.result=s(e.content),t.isError=e.isError;continue}}return f}function i(e){return e.role===`user`}function a(e){return e.role===`assistant`}function o(e){return e.role===`toolResult`}function s(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return``;let t=[];for(let n of e)c(n)&&t.push(n.text);return t.join(``)}function c(e){return e.type===`text`}function l(e){return e.type===`toolCall`}function u(e){if(!Array.isArray(e.content))return[];let t=[];for(let n of e.content)l(n)&&t.push({id:n.id,name:n.name,input:n.arguments});return t}function d(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}function f(e){if(!e.startsWith(`[`))return null;let n=e.indexOf(`] `);if(n<=0||e.lastIndexOf(`
2
2
  `,n)!==-1)return null;let r=e.slice(n+2);if(r.startsWith(`User: `))return{sender:`User`,body:r.slice(6)};for(let e of t){let t=`${e}:`;if(!r.startsWith(t))continue;let n=r.indexOf(`
3
3
  `),i=n===-1?r.length:n,a=r.slice(0,i),o=-1,s=a.indexOf(`[`,t.length);if(s>t.length&&(o=a.lastIndexOf(`: `,s)),o<t.length&&(o=r.indexOf(`: `,t.length)),!(o<0||o>=i))return{sender:r.slice(0,o),body:r.slice(o+2)}}let i=r.indexOf(`
4
4
  `),a=i===-1?r.length:i,o=r.indexOf(`: `);if(o<=0||o>=a)return null;let s=r.slice(0,o);return s.includes(`
@@ -1 +1 @@
1
- import{c as e,o as t}from"./provider-settings-Q6epwg_s.js";import{u as n}from"./bedrock-camp-CqXHYC67.js";import{i as r,n as i,o as a,s as o}from"./simple-options-imi_RHvn.js";import{t as s}from"./openai-CRGaNv9i.js";var c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let t=e(c);if(!t)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let n=t.split(`,`).map(e=>e.trim()).filter(Boolean);return n.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:n.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=r(e.messages,t,d),i=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)i.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});i.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),r=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));r.length?i.push({role:`assistant`,content:n||null,tool_calls:r}):i.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;i.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return i}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}var g=(e,n,r={})=>{let i=a();return(async()=>{let a={role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let u=r.apiKey;if(!u)throw Error(`Azure API key is required`);let d=e.baseUrl;if(!d)throw Error(`Azure endpoint is required`);let g=e.id,_={};e.headers&&Object.assign(_,e.headers),r.headers&&Object.assign(_,r.headers);let v=t(c)||l,y=new s({endpoint:d.replace(/\/+$/,``),apiKey:u,deployment:g,apiVersion:v,dangerouslyAllowBrowser:!0,defaultHeaders:_}),b=[...n.systemPrompt?[{role:`system`,content:n.systemPrompt}]:[],...f(n,e)],x=p(n.tools),S=await y.chat.completions.create({model:g,messages:b,stream:!0,stream_options:{include_usage:!0},...r.maxTokens?{max_completion_tokens:r.maxTokens}:{},...r.temperature===void 0?{}:{temperature:r.temperature},...x?{tools:x}:{}});i.push({type:`start`,partial:a});for await(let t of S){t.usage&&(a.usage.input=t.usage.prompt_tokens??0,a.usage.output=t.usage.completion_tokens??0,a.usage.totalTokens=t.usage.total_tokens??0,o(e,a.usage));for(let e of t.choices??[]){let t=e.delta;if(t){if(t.content){let{block:e,index:n}=m(a);e.text===``&&i.push({type:`text_start`,contentIndex:n,partial:a}),e.text+=t.content,i.push({type:`text_delta`,contentIndex:n,delta:t.content,partial:a})}if(t.tool_calls)for(let e of t.tool_calls){let t=e.id?h(a,e.id):void 0;if(!t&&e.id&&(t={type:`toolCall`,id:e.id,name:e.function?.name??``,arguments:{},_partialJson:``},a.content.push(t),i.push({type:`toolcall_start`,contentIndex:a.content.length-1,partial:a})),t&&e.function?.arguments){t._partialJson+=e.function.arguments;try{t.arguments=JSON.parse(t._partialJson)}catch{}i.push({type:`toolcall_delta`,contentIndex:a.content.indexOf(t),delta:e.function.arguments,partial:a})}}e.finish_reason&&(a.stopReason=e.finish_reason===`tool_calls`?`toolUse`:e.finish_reason===`length`?`length`:`stop`)}}}for(let e of a.content){let t=a.content.indexOf(e);if(e.type===`toolCall`){let n=e;try{n.arguments=JSON.parse(n._partialJson||`{}`)}catch{}delete n._partialJson,i.push({type:`toolcall_end`,contentIndex:t,toolCall:e,partial:a})}else e.type===`text`&&i.push({type:`text_end`,contentIndex:t,content:e.text,partial:a})}i.push({type:`done`,reason:a.stopReason,message:a}),i.end()}catch(e){a.stopReason=r.signal?.aborted?`aborted`:`error`,a.errorMessage=e instanceof Error?e.message:JSON.stringify(e),i.push({type:`error`,reason:a.stopReason,error:a}),i.end()}})(),i},_=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`Azure API key is required`);return g(e,t,{...i(e,n,r)})};function v(){n({api:`azure-openai-anthropic`,stream:g,streamSimple:_})}export{u as config,v as register};
1
+ import{c as e,o as t}from"./provider-settings-BHwoEn-1.js";import{u as n}from"./bedrock-camp-CqXHYC67.js";import{i as r,n as i,o as a,s as o}from"./simple-options-imi_RHvn.js";import{t as s}from"./openai-CRGaNv9i.js";var c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let t=e(c);if(!t)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let n=t.split(`,`).map(e=>e.trim()).filter(Boolean);return n.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:n.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=r(e.messages,t,d),i=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)i.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});i.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),r=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));r.length?i.push({role:`assistant`,content:n||null,tool_calls:r}):i.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;i.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return i}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}var g=(e,n,r={})=>{let i=a();return(async()=>{let a={role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let u=r.apiKey;if(!u)throw Error(`Azure API key is required`);let d=e.baseUrl;if(!d)throw Error(`Azure endpoint is required`);let g=e.id,_={};e.headers&&Object.assign(_,e.headers),r.headers&&Object.assign(_,r.headers);let v=t(c)||l,y=new s({endpoint:d.replace(/\/+$/,``),apiKey:u,deployment:g,apiVersion:v,dangerouslyAllowBrowser:!0,defaultHeaders:_}),b=[...n.systemPrompt?[{role:`system`,content:n.systemPrompt}]:[],...f(n,e)],x=p(n.tools),S=await y.chat.completions.create({model:g,messages:b,stream:!0,stream_options:{include_usage:!0},...r.maxTokens?{max_completion_tokens:r.maxTokens}:{},...r.temperature===void 0?{}:{temperature:r.temperature},...x?{tools:x}:{}});i.push({type:`start`,partial:a});for await(let t of S){t.usage&&(a.usage.input=t.usage.prompt_tokens??0,a.usage.output=t.usage.completion_tokens??0,a.usage.totalTokens=t.usage.total_tokens??0,o(e,a.usage));for(let e of t.choices??[]){let t=e.delta;if(t){if(t.content){let{block:e,index:n}=m(a);e.text===``&&i.push({type:`text_start`,contentIndex:n,partial:a}),e.text+=t.content,i.push({type:`text_delta`,contentIndex:n,delta:t.content,partial:a})}if(t.tool_calls)for(let e of t.tool_calls){let t=e.id?h(a,e.id):void 0;if(!t&&e.id&&(t={type:`toolCall`,id:e.id,name:e.function?.name??``,arguments:{},_partialJson:``},a.content.push(t),i.push({type:`toolcall_start`,contentIndex:a.content.length-1,partial:a})),t&&e.function?.arguments){t._partialJson+=e.function.arguments;try{t.arguments=JSON.parse(t._partialJson)}catch{}i.push({type:`toolcall_delta`,contentIndex:a.content.indexOf(t),delta:e.function.arguments,partial:a})}}e.finish_reason&&(a.stopReason=e.finish_reason===`tool_calls`?`toolUse`:e.finish_reason===`length`?`length`:`stop`)}}}for(let e of a.content){let t=a.content.indexOf(e);if(e.type===`toolCall`){let n=e;try{n.arguments=JSON.parse(n._partialJson||`{}`)}catch{}delete n._partialJson,i.push({type:`toolcall_end`,contentIndex:t,toolCall:e,partial:a})}else e.type===`text`&&i.push({type:`text_end`,contentIndex:t,content:e.text,partial:a})}i.push({type:`done`,reason:a.stopReason,message:a}),i.end()}catch(e){a.stopReason=r.signal?.aborted?`aborted`:`error`,a.errorMessage=e instanceof Error?e.message:JSON.stringify(e),i.push({type:`error`,reason:a.stopReason,error:a}),i.end()}})(),i},_=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`Azure API key is required`);return g(e,t,{...i(e,n,r)})};function v(){n({api:`azure-openai-anthropic`,stream:g,streamSimple:_})}export{u as config,v as register};
@@ -1 +1 @@
1
- import{i as e,o as t}from"./provider-settings-BbHwYeGO.js";import{p as n}from"./bedrock-camp-CWcpoTdM.js";import{o as r,r as i,s as a,t as o}from"./transform-messages-uhk4b6os.js";import{t as s}from"./openai-D6Fs9zDM.js";const c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let e=t(c);if(!e)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let n=e.split(`,`).map(e=>e.trim()).filter(Boolean);return n.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:n.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=o(e.messages,t,d),r=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)r.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});r.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),i=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));i.length?r.push({role:`assistant`,content:n||null,tool_calls:i}):r.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;r.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return r}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}const g=(t,n,i={})=>{let o=r();return(async()=>{let r={role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,model:t.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let u=i.apiKey;if(!u)throw Error(`Azure API key is required`);let d=t.baseUrl;if(!d)throw Error(`Azure endpoint is required`);let g=t.id,_={};t.headers&&Object.assign(_,t.headers),i.headers&&Object.assign(_,i.headers);let v=e(c)||l,y=new s({endpoint:d.replace(/\/+$/,``),apiKey:u,deployment:g,apiVersion:v,dangerouslyAllowBrowser:!0,defaultHeaders:_}),b=[...n.systemPrompt?[{role:`system`,content:n.systemPrompt}]:[],...f(n,t)],x=p(n.tools),S=await y.chat.completions.create({model:g,messages:b,stream:!0,stream_options:{include_usage:!0},...i.maxTokens?{max_completion_tokens:i.maxTokens}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...x?{tools:x}:{}});o.push({type:`start`,partial:r});for await(let e of S){e.usage&&(r.usage.input=e.usage.prompt_tokens??0,r.usage.output=e.usage.completion_tokens??0,r.usage.totalTokens=e.usage.total_tokens??0,a(t,r.usage));for(let t of e.choices??[]){let e=t.delta;if(e){if(e.content){let{block:t,index:n}=m(r);t.text===``&&o.push({type:`text_start`,contentIndex:n,partial:r}),t.text+=e.content,o.push({type:`text_delta`,contentIndex:n,delta:e.content,partial:r})}if(e.tool_calls)for(let t of e.tool_calls){let e=t.id?h(r,t.id):void 0;if(!e&&t.id&&(e={type:`toolCall`,id:t.id,name:t.function?.name??``,arguments:{},_partialJson:``},r.content.push(e),o.push({type:`toolcall_start`,contentIndex:r.content.length-1,partial:r})),e&&t.function?.arguments){e._partialJson+=t.function.arguments;try{e.arguments=JSON.parse(e._partialJson)}catch{}o.push({type:`toolcall_delta`,contentIndex:r.content.indexOf(e),delta:t.function.arguments,partial:r})}}t.finish_reason&&(r.stopReason=t.finish_reason===`tool_calls`?`toolUse`:t.finish_reason===`length`?`length`:`stop`)}}}for(let e of r.content){let t=r.content.indexOf(e);if(e.type===`toolCall`){let n=e;try{n.arguments=JSON.parse(n._partialJson||`{}`)}catch{}delete n._partialJson,o.push({type:`toolcall_end`,contentIndex:t,toolCall:e,partial:r})}else e.type===`text`&&o.push({type:`text_end`,contentIndex:t,content:e.text,partial:r})}o.push({type:`done`,reason:r.stopReason,message:r}),o.end()}catch(e){r.stopReason=i.signal?.aborted?`aborted`:`error`,r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:r.stopReason,error:r}),o.end()}})(),o},_=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`Azure API key is required`);return g(e,t,{...i(e,n,r)})};function v(){n({api:`azure-openai-anthropic`,stream:g,streamSimple:_})}export{u as config,v as register};
1
+ import{i as e,o as t}from"./provider-settings-CNtqy5Bx.js";import{p as n}from"./bedrock-camp-CWcpoTdM.js";import{o as r,r as i,s as a,t as o}from"./transform-messages-uhk4b6os.js";import{t as s}from"./openai-D6Fs9zDM.js";const c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let e=t(c);if(!e)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let n=e.split(`,`).map(e=>e.trim()).filter(Boolean);return n.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:n.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=o(e.messages,t,d),r=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)r.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});r.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),i=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));i.length?r.push({role:`assistant`,content:n||null,tool_calls:i}):r.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;r.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return r}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}const g=(t,n,i={})=>{let o=r();return(async()=>{let r={role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,model:t.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let u=i.apiKey;if(!u)throw Error(`Azure API key is required`);let d=t.baseUrl;if(!d)throw Error(`Azure endpoint is required`);let g=t.id,_={};t.headers&&Object.assign(_,t.headers),i.headers&&Object.assign(_,i.headers);let v=e(c)||l,y=new s({endpoint:d.replace(/\/+$/,``),apiKey:u,deployment:g,apiVersion:v,dangerouslyAllowBrowser:!0,defaultHeaders:_}),b=[...n.systemPrompt?[{role:`system`,content:n.systemPrompt}]:[],...f(n,t)],x=p(n.tools),S=await y.chat.completions.create({model:g,messages:b,stream:!0,stream_options:{include_usage:!0},...i.maxTokens?{max_completion_tokens:i.maxTokens}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...x?{tools:x}:{}});o.push({type:`start`,partial:r});for await(let e of S){e.usage&&(r.usage.input=e.usage.prompt_tokens??0,r.usage.output=e.usage.completion_tokens??0,r.usage.totalTokens=e.usage.total_tokens??0,a(t,r.usage));for(let t of e.choices??[]){let e=t.delta;if(e){if(e.content){let{block:t,index:n}=m(r);t.text===``&&o.push({type:`text_start`,contentIndex:n,partial:r}),t.text+=e.content,o.push({type:`text_delta`,contentIndex:n,delta:e.content,partial:r})}if(e.tool_calls)for(let t of e.tool_calls){let e=t.id?h(r,t.id):void 0;if(!e&&t.id&&(e={type:`toolCall`,id:t.id,name:t.function?.name??``,arguments:{},_partialJson:``},r.content.push(e),o.push({type:`toolcall_start`,contentIndex:r.content.length-1,partial:r})),e&&t.function?.arguments){e._partialJson+=t.function.arguments;try{e.arguments=JSON.parse(e._partialJson)}catch{}o.push({type:`toolcall_delta`,contentIndex:r.content.indexOf(e),delta:t.function.arguments,partial:r})}}t.finish_reason&&(r.stopReason=t.finish_reason===`tool_calls`?`toolUse`:t.finish_reason===`length`?`length`:`stop`)}}}for(let e of r.content){let t=r.content.indexOf(e);if(e.type===`toolCall`){let n=e;try{n.arguments=JSON.parse(n._partialJson||`{}`)}catch{}delete n._partialJson,o.push({type:`toolcall_end`,contentIndex:t,toolCall:e,partial:r})}else e.type===`text`&&o.push({type:`text_end`,contentIndex:t,content:e.text,partial:r})}o.push({type:`done`,reason:r.stopReason,message:r}),o.end()}catch(e){r.stopReason=i.signal?.aborted?`aborted`:`error`,r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:r.stopReason,error:r}),o.end()}})(),o},_=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`Azure API key is required`);return g(e,t,{...i(e,n,r)})};function v(){n({api:`azure-openai-anthropic`,stream:g,streamSimple:_})}export{u as config,v as register};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/magick-wasm-Bngjoiz2.js","assets/index-WEr7axlJ.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-ca-nBW7U.js","assets/provider-settings-Q6epwg_s.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-BHB_tqYb.js","assets/fs-DMLZk5ri.js","assets/backend-local-D-jeTNnr.js","assets/mount-picker-popup-DJJfRF_c.js","assets/path-utils-d3qOVZOu.js","assets/mime-types-DL940yDZ.js","assets/mount-CoIoFtIr.js","assets/index-eWuuouO-.css"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./logger-B-No_qN_.js";import{t}from"./preload-helper-ca-nBW7U.js";import"./index-WEr7axlJ.js";var n=e(`cdp`),r=class{ws=null;nextId=1;pending=new Map;listeners=new Map;_state=`disconnected`;get state(){return this._state}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);if(!e?.url)throw Error(`CDPClient.connect() requires a WebSocket URL`);let{url:t,timeout:r=5e3}=e;return this._state=`connecting`,new Promise((e,i)=>{let a=setTimeout(()=>{this.cleanup(),i(Error(`CDP connection timed out after ${r}ms`))},r);try{this.ws=new WebSocket(t)}catch(e){clearTimeout(a),this._state=`disconnected`,i(e);return}this.ws.onopen=()=>{clearTimeout(a),this._state=`connected`,n.info(`Connected`,{url:t}),e()},this.ws.onerror=e=>{clearTimeout(a),this._state===`connecting`&&(n.error(`Connection failed`,{url:t}),this.cleanup(),i(Error(`CDP WebSocket connection failed`)))},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onclose=()=>{this.handleClose()}})}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.close()),this.cleanup(),n.info(`Disconnected`)}async send(e,t,r,i=3e4){if(this._state!==`connected`||!this.ws)throw Error(`CDP client is not connected`);let a=this.nextId++,o={id:a,method:e};return t&&(o.params=t),r&&(o.sessionId=r),n.debug(`Send`,{method:e,id:a,sessionId:r}),new Promise((t,n)=>{let r=setTimeout(()=>{this.pending.delete(a),n(Error(`CDP command timed out after ${i}ms: ${e}`))},i);this.pending.set(a,{resolve:e=>{clearTimeout(r),t(e)},reject:e=>{clearTimeout(r),n(e)}}),this.ws.send(JSON.stringify(o))})}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e))}once(e,t=3e4){return new Promise((n,r)=>{let i=setTimeout(()=>{this.off(e,a),r(Error(`Timed out waiting for event: ${e}`))},t),a=t=>{clearTimeout(i),this.off(e,a),n(t)};this.on(e,a)})}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(`id`in t&&typeof t.id==`number`){let e=t;n.debug(`Response`,{id:e.id,hasError:!!e.error});let r=this.pending.get(e.id);r&&(this.pending.delete(e.id),e.error?(n.error(`Command error`,{id:e.id,code:e.error.code,message:e.error.message}),r.reject(Error(`CDP error: ${e.error.message} (${e.error.code})`))):r.resolve(e.result??{}));return}if(`method`in t){let e=t;n.debug(`Event`,{method:e.method,sessionId:e.sessionId});let r=this.listeners.get(e.method);if(r){let t=e.sessionId?{...e.params,sessionId:e.sessionId}:e.params??{};for(let e of r)try{e(t)}catch{}}}}handleClose(){n.error(`Connection closed unexpectedly`,{pendingCommands:this.pending.size});for(let[,e]of this.pending)e.reject(Error(`CDP connection closed`));this.cleanup()}cleanup(){this.ws=null,this._state=`disconnected`,this.pending.clear()}};function i(e,t=``){if(e==null)return t;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)??t}catch{return String(e)}}var a=`(function() {
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/magick-wasm-BCZpZeyl.js","assets/index-ZLv5StNy.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-ca-nBW7U.js","assets/provider-settings-BHwoEn-1.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-BHB_tqYb.js","assets/fs-BSEneDlc.js","assets/backend-local-D-jeTNnr.js","assets/mount-picker-popup-DJJfRF_c.js","assets/path-utils-d3qOVZOu.js","assets/mime-types-DL940yDZ.js","assets/mount-vDUPSYAA.js","assets/index-eWuuouO-.css"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./logger-B-No_qN_.js";import{t}from"./preload-helper-ca-nBW7U.js";import"./index-ZLv5StNy.js";var n=e(`cdp`),r=class{ws=null;nextId=1;pending=new Map;listeners=new Map;_state=`disconnected`;get state(){return this._state}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);if(!e?.url)throw Error(`CDPClient.connect() requires a WebSocket URL`);let{url:t,timeout:r=5e3}=e;return this._state=`connecting`,new Promise((e,i)=>{let a=setTimeout(()=>{this.cleanup(),i(Error(`CDP connection timed out after ${r}ms`))},r);try{this.ws=new WebSocket(t)}catch(e){clearTimeout(a),this._state=`disconnected`,i(e);return}this.ws.onopen=()=>{clearTimeout(a),this._state=`connected`,n.info(`Connected`,{url:t}),e()},this.ws.onerror=e=>{clearTimeout(a),this._state===`connecting`&&(n.error(`Connection failed`,{url:t}),this.cleanup(),i(Error(`CDP WebSocket connection failed`)))},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onclose=()=>{this.handleClose()}})}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.close()),this.cleanup(),n.info(`Disconnected`)}async send(e,t,r,i=3e4){if(this._state!==`connected`||!this.ws)throw Error(`CDP client is not connected`);let a=this.nextId++,o={id:a,method:e};return t&&(o.params=t),r&&(o.sessionId=r),n.debug(`Send`,{method:e,id:a,sessionId:r}),new Promise((t,n)=>{let r=setTimeout(()=>{this.pending.delete(a),n(Error(`CDP command timed out after ${i}ms: ${e}`))},i);this.pending.set(a,{resolve:e=>{clearTimeout(r),t(e)},reject:e=>{clearTimeout(r),n(e)}}),this.ws.send(JSON.stringify(o))})}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e))}once(e,t=3e4){return new Promise((n,r)=>{let i=setTimeout(()=>{this.off(e,a),r(Error(`Timed out waiting for event: ${e}`))},t),a=t=>{clearTimeout(i),this.off(e,a),n(t)};this.on(e,a)})}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(`id`in t&&typeof t.id==`number`){let e=t;n.debug(`Response`,{id:e.id,hasError:!!e.error});let r=this.pending.get(e.id);r&&(this.pending.delete(e.id),e.error?(n.error(`Command error`,{id:e.id,code:e.error.code,message:e.error.message}),r.reject(Error(`CDP error: ${e.error.message} (${e.error.code})`))):r.resolve(e.result??{}));return}if(`method`in t){let e=t;n.debug(`Event`,{method:e.method,sessionId:e.sessionId});let r=this.listeners.get(e.method);if(r){let t=e.sessionId?{...e.params,sessionId:e.sessionId}:e.params??{};for(let e of r)try{e(t)}catch{}}}}handleClose(){n.error(`Connection closed unexpectedly`,{pendingCommands:this.pending.size});for(let[,e]of this.pending)e.reject(Error(`CDP connection closed`));this.cleanup()}cleanup(){this.ws=null,this._state=`disconnected`,this.pending.clear()}};function i(e,t=``){if(e==null)return t;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)??t}catch{return String(e)}}var a=`(function() {
3
3
  'use strict';
4
4
 
5
5
  // ===== DOM Utilities =====
@@ -869,7 +869,7 @@ import{t as e}from"./logger-B-No_qN_.js";import{t}from"./preload-helper-ca-nBW7U
869
869
  } catch(e) {
870
870
  return { role: 'RootWebArea', name: '', description: 'Error: ' + (e.message || String(e)) };
871
871
  }
872
- })()`,o=`ws://localhost:5710/cdp`,s=e(`browser-api`);function c(e=typeof window<`u`?window.location:null){return e?.host?`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}/cdp`:o}var l=class{client;localClient;sessionId=null;attachedTargetId=null;trayTargetProvider=null;remoteTargetInfo=null;_frameContextCache=new Map;_tabLock=Promise.resolve();_onSessionChange;handleJavaScriptDialogOpening=async e=>{let t=typeof e.sessionId==`string`?e.sessionId:this.sessionId;if(t)try{await this.client.send(`Page.handleJavaScriptDialog`,{accept:!1},t,5e3),s.warn(`Auto-dismissed unexpected JavaScript dialog`,{sessionId:t,type:e.type,message:e.message,url:e.url})}catch(e){s.warn(`Failed to auto-dismiss JavaScript dialog`,{sessionId:t,error:e instanceof Error?e.message:String(e)})}};constructor(e){this.client=e??new r,this.localClient=this.client,this.addDialogListener(this.client)}getTransport(){return this.client}setSessionChangeCallback(e){this._onSessionChange=e}getSessionId(){return this.sessionId}getAttachedTargetId(){return this.attachedTargetId}async withTab(e,t){let n,r=new Promise(e=>{n=e}),i=this._tabLock;this._tabLock=r,await i;try{return await t(await this.attachToPage(e))}finally{n()}}setTrayTargetProvider(e){this.trayTargetProvider=e}async listAllTargets(){let e=await this.listPages();if(!this.trayTargetProvider)return e;let t=!this.remoteTargetInfo,n=new Set(e.map(e=>e.targetId)),r=this.trayTargetProvider.getTargets().filter(e=>!t||!(e.runtimeId===`leader`&&n.has(e.localTargetId))).map(e=>({targetId:e.targetId,title:e.title,url:e.url}));return[...e,...r]}async connect(e){await this.client.connect({url:e?.url??c(),timeout:e?.timeout})}async createPage(e){return await this.ensureConnected(),await this.ensureLocalConnected(),(await this.localClient.send(`Target.createTarget`,{url:e??`about:blank`,background:!0})).targetId}async createRemotePage(e,t){if(!this.trayTargetProvider?.openRemoteTab)throw Error(`Remote tab opening not available (no tray target provider)`);return this.trayTargetProvider.openRemoteTab(e,t??`about:blank`)}async closePage(e){if(await this.ensureConnected(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);try{await t.send(`Target.closeTarget`,{targetId:r})}finally{this.trayTargetProvider.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(n,r)}this.attachedTargetId===e&&(this.remoteTargetInfo&&=(this.setClient(this.localClient),null),this.sessionId=null,this.attachedTargetId=null);return}}await this.localClient.send(`Target.closeTarget`,{targetId:e}),this.attachedTargetId===e&&(this.sessionId=null,this.attachedTargetId=null)}disconnect(){this.sessionId=null,this.attachedTargetId=null,this.client.disconnect()}async listPages(){return await this.ensureConnected(),await this.ensureLocalConnected(),((await this.localClient.send(`Target.getTargets`)).targetInfos??[]).filter(e=>e.type===`page`).map(e=>({targetId:e.targetId,title:e.title,url:e.url,...e.active?{active:!0}:{}}))}async attachToPage(e){if(await this.ensureConnected(),this.sessionId&&this.attachedTargetId===e)return this.sessionId;if(this._frameContextCache.clear(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);this.setClient(t),this.remoteTargetInfo={runtimeId:n,localTargetId:r};let i=await this.client.send(`Target.attachToTarget`,{targetId:r,flatten:!0});return this.sessionId=i.sessionId,this.attachedTargetId=e,await this.client.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.client),this.sessionId}}this.remoteTargetInfo&&=(this.trayTargetProvider?.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),null),await this.ensureLocalConnected();let t=await this.localClient.send(`Target.attachToTarget`,{targetId:e,flatten:!0});return this.sessionId=t.sessionId,this.attachedTargetId=e,await this.localClient.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.localClient),this.sessionId}async detach(){if(this.sessionId){try{await this.client.send(`Target.detachFromTarget`,{sessionId:this.sessionId})}catch{}this.remoteTargetInfo&&this.trayTargetProvider?.removeRemoteTransport&&(this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),this.remoteTargetInfo=null),this.sessionId=null,this.attachedTargetId=null}}async navigate(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Page.enable`,{},this.sessionId);let t=this.client.once(`Page.loadEventFired`);await this.client.send(`Page.navigate`,{url:e},this.sessionId),await t}async screenshot(e){await this.ensureConnected(),this.ensureAttached();try{let n={format:e?.format??`png`,captureBeyondViewport:!0};if(e?.quality!==void 0&&(n.quality=e.quality),e?.clip||e?.fullPage){let t=0,r=0;try{await this.client.send(`Runtime.enable`,{},this.sessionId);let e=await this.client.send(`Runtime.evaluate`,{expression:`JSON.stringify({ w: window.innerWidth, h: document.documentElement.scrollHeight })`,returnByValue:!0},this.sessionId),n=JSON.parse(e.result?.value??`{}`);t=n.w??0,r=n.h??0}catch{}e?.clip?n.clip={...e.clip,scale:e.clip.scale??1}:n.clip={x:0,y:0,width:t||1280,height:r||800,scale:1}}let r;try{r=await this.client.send(`Page.captureScreenshot`,n,this.sessionId)}catch{await this.client.send(`Page.bringToFront`,{},this.sessionId),r=await this.client.send(`Page.captureScreenshot`,n,this.sessionId)}let i=r.data;if(e?.maxWidth)try{let{getMagick:n}=await t(async()=>{let{getMagick:e}=await import(`./magick-wasm-Bngjoiz2.js`);return{getMagick:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])),r=await n(),a=atob(i),o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);let s=8e3,c=!1;await r.ImageMagick.read(o,async t=>{let n=Math.min(e.maxWidth,s),r=Math.max(t.width,t.height);if(t.width>n||r>s){let e=Math.min(n/t.width,s/r);t.resize(Math.round(t.width*e),Math.round(t.height*e)),c=!0}c&&t.write(`PNG`,e=>{let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);i=btoa(t)})})}catch(e){console.warn(`[browser-api] Screenshot maxWidth resize failed, returning original`,e)}return i}finally{}}async evaluate(e,t){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Runtime.enable`,{},this.sessionId);let n=await this.client.send(`Runtime.evaluate`,{expression:e,awaitPromise:t?.awaitPromise??!0,returnByValue:t?.returnByValue??!0},this.sessionId),r=n.exceptionDetails;if(r){let e=r.exception?.description??r.text;throw Error(`Evaluation failed: ${e}`)}return n.result.value}async click(e){await this.ensureConnected(),this.ensureAttached();let t=await this.boundingBox(e);if(!t)throw Error(`Element not found: ${e}`);let n=t.x+t.width/2,r=t.y+t.height/2;await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:n,y:r,button:`left`,clickCount:1},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:n,y:r,button:`left`,clickCount:1},this.sessionId)}async type(e){await this.ensureConnected(),this.ensureAttached();for(let t of e)await this.client.send(`Input.dispatchKeyEvent`,{type:`keyDown`,text:t},this.sessionId),await this.client.send(`Input.dispatchKeyEvent`,{type:`keyUp`,text:t},this.sessionId)}async waitForSelector(e,t){await this.ensureConnected(),this.ensureAttached();let n=t?.timeout??3e4,r=t?.interval??100,i=Date.now();for(;Date.now()-i<n;){if(await this.evaluate(`!!document.querySelector(${JSON.stringify(e)})`))return;await new Promise(e=>setTimeout(e,r))}throw Error(`waitForSelector timed out after ${n}ms: ${e}`)}async getAccessibilityTree(){await this.ensureConnected(),this.ensureAttached();let e=await this.evaluate(a,{awaitPromise:!1,returnByValue:!0});return!e||typeof e!=`object`?{role:`RootWebArea`,name:``}:u(e)}async clickByBackendNodeId(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`DOM.enable`,{},this.sessionId),await this.client.send(`Runtime.enable`,{},this.sessionId);let t=(await this.client.send(`DOM.resolveNode`,{backendNodeId:e},this.sessionId)).object;if(!t?.objectId)throw Error(`Could not resolve backend node ${e} to a DOM element`);let n=(await this.client.send(`Runtime.callFunctionOn`,{objectId:t.objectId,functionDeclaration:`function() {
872
+ })()`,o=`ws://localhost:5710/cdp`,s=e(`browser-api`);function c(e=typeof window<`u`?window.location:null){return e?.host?`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}/cdp`:o}var l=class{client;localClient;sessionId=null;attachedTargetId=null;trayTargetProvider=null;remoteTargetInfo=null;_frameContextCache=new Map;_tabLock=Promise.resolve();_onSessionChange;handleJavaScriptDialogOpening=async e=>{let t=typeof e.sessionId==`string`?e.sessionId:this.sessionId;if(t)try{await this.client.send(`Page.handleJavaScriptDialog`,{accept:!1},t,5e3),s.warn(`Auto-dismissed unexpected JavaScript dialog`,{sessionId:t,type:e.type,message:e.message,url:e.url})}catch(e){s.warn(`Failed to auto-dismiss JavaScript dialog`,{sessionId:t,error:e instanceof Error?e.message:String(e)})}};constructor(e){this.client=e??new r,this.localClient=this.client,this.addDialogListener(this.client)}getTransport(){return this.client}setSessionChangeCallback(e){this._onSessionChange=e}getSessionId(){return this.sessionId}getAttachedTargetId(){return this.attachedTargetId}async withTab(e,t){let n,r=new Promise(e=>{n=e}),i=this._tabLock;this._tabLock=r,await i;try{return await t(await this.attachToPage(e))}finally{n()}}setTrayTargetProvider(e){this.trayTargetProvider=e}async listAllTargets(){let e=await this.listPages();if(!this.trayTargetProvider)return e;let t=!this.remoteTargetInfo,n=new Set(e.map(e=>e.targetId)),r=this.trayTargetProvider.getTargets().filter(e=>!t||!(e.runtimeId===`leader`&&n.has(e.localTargetId))).map(e=>({targetId:e.targetId,title:e.title,url:e.url}));return[...e,...r]}async connect(e){await this.client.connect({url:e?.url??c(),timeout:e?.timeout})}async createPage(e){return await this.ensureConnected(),await this.ensureLocalConnected(),(await this.localClient.send(`Target.createTarget`,{url:e??`about:blank`,background:!0})).targetId}async createRemotePage(e,t){if(!this.trayTargetProvider?.openRemoteTab)throw Error(`Remote tab opening not available (no tray target provider)`);return this.trayTargetProvider.openRemoteTab(e,t??`about:blank`)}async closePage(e){if(await this.ensureConnected(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);try{await t.send(`Target.closeTarget`,{targetId:r})}finally{this.trayTargetProvider.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(n,r)}this.attachedTargetId===e&&(this.remoteTargetInfo&&=(this.setClient(this.localClient),null),this.sessionId=null,this.attachedTargetId=null);return}}await this.localClient.send(`Target.closeTarget`,{targetId:e}),this.attachedTargetId===e&&(this.sessionId=null,this.attachedTargetId=null)}disconnect(){this.sessionId=null,this.attachedTargetId=null,this.client.disconnect()}async listPages(){return await this.ensureConnected(),await this.ensureLocalConnected(),((await this.localClient.send(`Target.getTargets`)).targetInfos??[]).filter(e=>e.type===`page`).map(e=>({targetId:e.targetId,title:e.title,url:e.url,...e.active?{active:!0}:{}}))}async attachToPage(e){if(await this.ensureConnected(),this.sessionId&&this.attachedTargetId===e)return this.sessionId;if(this._frameContextCache.clear(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);this.setClient(t),this.remoteTargetInfo={runtimeId:n,localTargetId:r};let i=await this.client.send(`Target.attachToTarget`,{targetId:r,flatten:!0});return this.sessionId=i.sessionId,this.attachedTargetId=e,await this.client.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.client),this.sessionId}}this.remoteTargetInfo&&=(this.trayTargetProvider?.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),null),await this.ensureLocalConnected();let t=await this.localClient.send(`Target.attachToTarget`,{targetId:e,flatten:!0});return this.sessionId=t.sessionId,this.attachedTargetId=e,await this.localClient.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.localClient),this.sessionId}async detach(){if(this.sessionId){try{await this.client.send(`Target.detachFromTarget`,{sessionId:this.sessionId})}catch{}this.remoteTargetInfo&&this.trayTargetProvider?.removeRemoteTransport&&(this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),this.remoteTargetInfo=null),this.sessionId=null,this.attachedTargetId=null}}async navigate(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Page.enable`,{},this.sessionId);let t=this.client.once(`Page.loadEventFired`);await this.client.send(`Page.navigate`,{url:e},this.sessionId),await t}async screenshot(e){await this.ensureConnected(),this.ensureAttached();try{let n={format:e?.format??`png`,captureBeyondViewport:!0};if(e?.quality!==void 0&&(n.quality=e.quality),e?.clip||e?.fullPage){let t=0,r=0;try{await this.client.send(`Runtime.enable`,{},this.sessionId);let e=await this.client.send(`Runtime.evaluate`,{expression:`JSON.stringify({ w: window.innerWidth, h: document.documentElement.scrollHeight })`,returnByValue:!0},this.sessionId),n=JSON.parse(e.result?.value??`{}`);t=n.w??0,r=n.h??0}catch{}e?.clip?n.clip={...e.clip,scale:e.clip.scale??1}:n.clip={x:0,y:0,width:t||1280,height:r||800,scale:1}}let r;try{r=await this.client.send(`Page.captureScreenshot`,n,this.sessionId)}catch{await this.client.send(`Page.bringToFront`,{},this.sessionId),r=await this.client.send(`Page.captureScreenshot`,n,this.sessionId)}let i=r.data;if(e?.maxWidth)try{let{getMagick:n}=await t(async()=>{let{getMagick:e}=await import(`./magick-wasm-BCZpZeyl.js`);return{getMagick:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])),r=await n(),a=atob(i),o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);let s=8e3,c=!1;await r.ImageMagick.read(o,async t=>{let n=Math.min(e.maxWidth,s),r=Math.max(t.width,t.height);if(t.width>n||r>s){let e=Math.min(n/t.width,s/r);t.resize(Math.round(t.width*e),Math.round(t.height*e)),c=!0}c&&t.write(`PNG`,e=>{let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);i=btoa(t)})})}catch(e){console.warn(`[browser-api] Screenshot maxWidth resize failed, returning original`,e)}return i}finally{}}async evaluate(e,t){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Runtime.enable`,{},this.sessionId);let n=await this.client.send(`Runtime.evaluate`,{expression:e,awaitPromise:t?.awaitPromise??!0,returnByValue:t?.returnByValue??!0},this.sessionId),r=n.exceptionDetails;if(r){let e=r.exception?.description??r.text;throw Error(`Evaluation failed: ${e}`)}return n.result.value}async click(e){await this.ensureConnected(),this.ensureAttached();let t=await this.boundingBox(e);if(!t)throw Error(`Element not found: ${e}`);let n=t.x+t.width/2,r=t.y+t.height/2;await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:n,y:r,button:`left`,clickCount:1},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:n,y:r,button:`left`,clickCount:1},this.sessionId)}async type(e){await this.ensureConnected(),this.ensureAttached();for(let t of e)await this.client.send(`Input.dispatchKeyEvent`,{type:`keyDown`,text:t},this.sessionId),await this.client.send(`Input.dispatchKeyEvent`,{type:`keyUp`,text:t},this.sessionId)}async waitForSelector(e,t){await this.ensureConnected(),this.ensureAttached();let n=t?.timeout??3e4,r=t?.interval??100,i=Date.now();for(;Date.now()-i<n;){if(await this.evaluate(`!!document.querySelector(${JSON.stringify(e)})`))return;await new Promise(e=>setTimeout(e,r))}throw Error(`waitForSelector timed out after ${n}ms: ${e}`)}async getAccessibilityTree(){await this.ensureConnected(),this.ensureAttached();let e=await this.evaluate(a,{awaitPromise:!1,returnByValue:!0});return!e||typeof e!=`object`?{role:`RootWebArea`,name:``}:u(e)}async clickByBackendNodeId(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`DOM.enable`,{},this.sessionId),await this.client.send(`Runtime.enable`,{},this.sessionId);let t=(await this.client.send(`DOM.resolveNode`,{backendNodeId:e},this.sessionId)).object;if(!t?.objectId)throw Error(`Could not resolve backend node ${e} to a DOM element`);let n=(await this.client.send(`Runtime.callFunctionOn`,{objectId:t.objectId,functionDeclaration:`function() {
873
873
  this.scrollIntoView({ block: 'center', inline: 'center' });
874
874
  const r = this.getBoundingClientRect();
875
875
  return { x: r.x, y: r.y, width: r.width, height: r.height };
@@ -12,7 +12,7 @@ drwxr-xr-x 2 user user 4096 Jan 01 10:00 src`},{id:`fx-tc-err`,name:`edit_file`,
12
12
 
13
13
  - Brand colors now live in /shared/tokens/brand.css
14
14
  - Release notes ship on Wednesdays
15
- `},result:`Global memory updated successfully.`}]}),n.push({id:`fx-delegation-1`,role:`user`,content:"**[Instructions from sliccy]**\n\nRead `/workspace/README.md` and extract the install steps into `/shared/install.md`.",timestamp:r(4),source:`delegation`,channel:`delegation`}),n.push({id:`fx-assistant-delegated`,role:`assistant`,content:"Extracted the install steps. Wrote them to `/shared/install.md`. The section covers prerequisites, npm install, and the dev server launch.",timestamp:r(4.4),source:`cone`}),n.push({id:`fx-lick-webhook`,role:`user`,content:"[Webhook Event: github-push]\n```json\n"+JSON.stringify({ref:`refs/heads/main`,repository:{full_name:`example/repo`},head_commit:{message:`fix(ui): tighten button contrast in dark mode`}},null,2)+"\n```",timestamp:r(6),source:`lick`,channel:`webhook`}),n.push({id:`fx-lick-cron`,role:`user`,content:"[Cron Event: daily-digest]\n```json\n"+JSON.stringify({time:new Date(r(8)).toISOString()},null,2)+"\n```",timestamp:r(8),source:`lick`,channel:`cron`}),n.push({id:`fx-lick-sprinkle`,role:`user`,content:"[Sprinkle Event: welcome]\n```json\n"+JSON.stringify({action:`onboarding-complete`,data:{mountWorkspace:!0}},null,2)+"\n```",timestamp:r(10),source:`lick`,channel:`sprinkle`}),n.push({id:`fx-lick-fswatch`,role:`user`,content:"[File Watch Event: src-watch]\n```json\n"+JSON.stringify({changes:[{type:`modified`,path:`/workspace/src/app.ts`},{type:`created`,path:`/workspace/src/utils.ts`}]},null,2)+"\n```",timestamp:r(12),source:`lick`,channel:`fswatch`}),n.push({id:`fx-lick-navigate`,role:`user`,content:"[Navigate Event: https://www.sliccy.ai/handoff?msg=handoff%3Ademo]\n```json\n"+JSON.stringify({url:`https://www.sliccy.ai/handoff?msg=handoff%3Ademo`,sliccHeader:`handoff:demo`,title:`Handoff`},null,2)+"\n```",timestamp:r(14),source:`lick`,channel:`navigate`}),n.push({id:`fx-lick-session-reload`,role:`user`,content:`[Session Reload: mount-recovery]
15
+ `},result:`Global memory updated successfully.`}]}),n.push({id:`fx-delegation-1`,role:`user`,content:"**[Instructions from sliccy]**\n\nRead `/workspace/README.md` and extract the install steps into `/shared/install.md`.",timestamp:r(4),source:`delegation`,channel:`delegation`}),n.push({id:`fx-assistant-delegated`,role:`assistant`,content:"Extracted the install steps. Wrote them to `/shared/install.md`. The section covers prerequisites, npm install, and the dev server launch.",timestamp:r(4.4),source:`cone`}),n.push({id:`fx-lick-webhook`,role:`user`,content:"[Webhook Event: github-push]\n```json\n"+JSON.stringify({ref:`refs/heads/main`,repository:{full_name:`example/repo`},head_commit:{message:`fix(ui): tighten button contrast in dark mode`}},null,2)+"\n```",timestamp:r(6),source:`lick`,channel:`webhook`}),n.push({id:`fx-lick-cron`,role:`user`,content:"[Cron Event: daily-digest]\n```json\n"+JSON.stringify({time:new Date(r(8)).toISOString()},null,2)+"\n```",timestamp:r(8),source:`lick`,channel:`cron`}),n.push({id:`fx-lick-sprinkle`,role:`user`,content:"[Sprinkle Event: welcome]\n```json\n"+JSON.stringify({action:`onboarding-complete`,data:{mountWorkspace:!0}},null,2)+"\n```",timestamp:r(10),source:`lick`,channel:`sprinkle`}),n.push({id:`fx-lick-fswatch`,role:`user`,content:"[File Watch Event: src-watch]\n```json\n"+JSON.stringify({changes:[{type:`modified`,path:`/workspace/src/app.ts`},{type:`created`,path:`/workspace/src/utils.ts`}]},null,2)+"\n```",timestamp:r(12),source:`lick`,channel:`fswatch`}),n.push({id:`fx-lick-navigate`,role:`user`,content:"[Navigate Event: https://www.sliccy.ai/handoff?handoff=demo]\n```json\n"+JSON.stringify({url:`https://www.sliccy.ai/handoff?handoff=demo`,verb:`handoff`,target:`https://www.sliccy.ai/handoff?handoff=demo`,instruction:`demo`,title:`Handoff`},null,2)+"\n```",timestamp:r(14),source:`lick`,channel:`navigate`}),n.push({id:`fx-lick-session-reload`,role:`user`,content:`[Session Reload: mount-recovery]
16
16
 
17
17
  A previously-mounted directory needs to be reauthorized:
18
18
 
@@ -0,0 +1 @@
1
+ import"./index-ZLv5StNy.js";function e(e){}export{e as registerSessionCostsProvider};