This build was committed by a bot.

This commit is contained in:
github-actions[bot]
2026-02-18 22:55:20 +00:00
parent 762a4a66c3
commit aa78f7929c
3 changed files with 5 additions and 89 deletions

View File

@@ -131,51 +131,6 @@ const buildBody = () => {
}
return b;
};
async function streamLocal(body, onDelta, signal) {
const { USER: USER2, localDemoReply: localDemoReply2 } = window;
const apiKey = USER2.apiKeyOpenRouter;
if (!apiKey) {
onDelta(localDemoReply2(), true);
return;
}
try {
const r = await fetch("https://openrouter.ai/api/v1/chat/completions", { method: "POST", headers: { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json", "HTTP-Referer": "https://sune.chat", "X-Title": "Sune" }, body: JSON.stringify(body), signal });
if (!r.ok) throw new Error(`HTTP ${r.status}`);
const reader = r.body.getReader(), dec = new TextDecoder();
let buf = "";
while (true) {
const { done, value } = await reader.read();
if (done) break;
buf += dec.decode(value, { stream: true });
const lines = buf.split("\n");
buf = lines.pop();
for (const line of lines) {
if (line.startsWith("data: ")) {
const d = line.slice(6);
if (d === "[DONE]") {
onDelta("", true);
return;
}
try {
const j = JSON.parse(d);
const delta = j.choices?.[0]?.delta?.content || "";
const reasoning = j.choices?.[0]?.delta?.reasoning;
const imgs = j.choices?.[0]?.delta?.images;
if (reasoning && body.reasoning?.exclude !== true) onDelta(reasoning, false);
if (delta) onDelta(delta, false);
if (imgs) onDelta("", false, imgs);
} catch {
}
}
}
}
onDelta("", true);
} catch (e) {
if (e.name !== "AbortError") onDelta(`
Error: ${e.message}`, true);
}
}
async function streamORP(body, onDelta, streamId) {
const { USER: USER2, SUNE: SUNE2, state: state2, gid: gid2, cacheStore: cacheStore2 } = window;
const model = SUNE2.model, provider = model.startsWith("oai:") ? "openai" : model.startsWith("g:") ? "google" : model.startsWith("cla:") ? "claude" : model.startsWith("cf:") ? "cloudflare" : model.startsWith("or:") ? "openrouter" : USER2.provider;
@@ -228,15 +183,7 @@ async function streamORP(body, onDelta, streamId) {
return { ok: true, rid: r.rid };
}
async function streamChat(onDelta, streamId) {
const { USER: USER2, state: state2 } = window;
const body = buildBody();
if (!USER2.donor) {
const c = new AbortController();
state2.controller = c;
await streamLocal(body, onDelta, c.signal);
state2.controller = null;
return { ok: true, rid: null };
}
return await streamORP(body, onDelta, streamId);
}
(() => {
@@ -249,8 +196,8 @@ async function streamChat(onDelta, streamId) {
o != k && ((k = o) ? (history.pushState({ k: 1 }, ""), addEventListener("popstate", f)) : (removeEventListener("popstate", f), history.state?.k && history.back()));
};
})();
const DEFAULT_MODEL = "google/gemini-3-pro-preview", DEFAULT_API_KEY = "";
const el = window.el = Object.fromEntries(["topbar", "chat", "messages", "composer", "input", "sendBtn", "suneBtnTop", "suneModal", "suneURL", "settingsForm", "closeSettings", "cancelSettings", "tabModel", "tabPrompt", "tabScript", "panelModel", "panelPrompt", "panelScript", "set_model", "set_temperature", "set_top_p", "set_top_k", "set_frequency_penalty", "set_repetition_penalty", "set_min_p", "set_top_a", "set_verbosity", "set_reasoning_effort", "set_system_prompt", "set_hide_composer", "set_include_thoughts", "set_json_output", "set_img_output", "set_aspect_ratio", "set_image_size", "aspectRatioContainer", "set_ignore_master_prompt", "deleteSuneBtn", "sidebarLeft", "sidebarOverlayLeft", "sidebarBtnLeft", "suneList", "newSuneBtn", "userMenuBtn", "userMenu", "accountSettingsOption", "sunesImportOption", "sunesExportOption", "threadsImportOption", "importInput", "sidebarBtnRight", "sidebarRight", "sidebarOverlayRight", "threadList", "closeThreads", "threadPopover", "sunePopover", "footer", "attachBtn", "attachBadge", "fileInput", "htmlEditor", "extensionHtmlEditor", "jsonSchemaEditor", "htmlTab_index", "htmlTab_extension", "suneHtml", "accountSettingsModal", "accountSettingsForm", "closeAccountSettings", "cancelAccountSettings", "set_master_prompt", "set_provider", "set_api_key_or", "set_api_key_oai", "set_api_key_g", "set_api_key_claude", "set_api_key_cf", "set_title_model", "copySystemPrompt", "pasteSystemPrompt", "copyHTML", "pasteHTML", "accountTabGeneral", "accountTabAPI", "accountPanelGeneral", "accountPanelAPI", "set_gh_token", "gcpSAInput", "gcpSAUploadBtn", "importAccountSettings", "exportAccountSettings", "importAccountSettingsInput", "accountTabUser", "accountPanelUser", "set_user_name", "userAvatarPreview", "setUserAvatarBtn", "userAvatarInput", "set_donor", "threadRepoInput", "threadBackBtn", "threadFolderBtn", "threadSyncBtn"].map((id) => [id, $("#" + id)[0]]));
const DEFAULT_API_KEY = "";
const el = window.el = Object.fromEntries(["topbar", "chat", "messages", "composer", "input", "sendBtn", "suneBtnTop", "suneModal", "suneURL", "settingsForm", "closeSettings", "cancelSettings", "tabModel", "tabPrompt", "tabScript", "panelModel", "panelPrompt", "panelScript", "set_model", "set_temperature", "set_top_p", "set_top_k", "set_frequency_penalty", "set_repetition_penalty", "set_min_p", "set_top_a", "set_verbosity", "set_reasoning_effort", "set_system_prompt", "set_hide_composer", "set_include_thoughts", "set_json_output", "set_img_output", "set_aspect_ratio", "set_image_size", "aspectRatioContainer", "set_ignore_master_prompt", "deleteSuneBtn", "sidebarLeft", "sidebarOverlayLeft", "sidebarBtnLeft", "suneList", "newSuneBtn", "userMenuBtn", "userMenu", "accountSettingsOption", "sunesImportOption", "sunesExportOption", "threadsImportOption", "importInput", "sidebarBtnRight", "sidebarRight", "sidebarOverlayRight", "threadList", "closeThreads", "threadPopover", "sunePopover", "footer", "attachBtn", "attachBadge", "fileInput", "htmlEditor", "extensionHtmlEditor", "jsonSchemaEditor", "htmlTab_index", "htmlTab_extension", "suneHtml", "accountSettingsModal", "accountSettingsForm", "closeAccountSettings", "cancelAccountSettings", "set_master_prompt", "set_provider", "set_api_key_or", "set_api_key_oai", "set_api_key_g", "set_api_key_claude", "set_api_key_cf", "set_title_model", "copySystemPrompt", "pasteSystemPrompt", "copyHTML", "pasteHTML", "accountTabGeneral", "accountTabAPI", "accountPanelGeneral", "accountPanelAPI", "set_gh_token", "gcpSAInput", "gcpSAUploadBtn", "importAccountSettings", "exportAccountSettings", "importAccountSettingsInput", "accountTabUser", "accountPanelUser", "set_user_name", "userAvatarPreview", "setUserAvatarBtn", "userAvatarInput", "threadRepoInput", "threadBackBtn", "threadFolderBtn", "threadSyncBtn"].map((id) => [id, $("#" + id)[0]]));
const icons = () => window.lucide && lucide.createIcons();
const haptic = () => /android/i.test(navigator.userAgent) && navigator.vibrate?.(1);
const clamp = (v, min, max) => Math.max(min, Math.min(max, v)), num = (v, d) => v == null || v === "" || isNaN(+v) ? d : +v, int = (v, d) => v == null || v === "" || isNaN(parseInt(v)) ? d : parseInt(v), gid = () => Math.random().toString(36).slice(2, 9), esc = (s) => String(s).replace(/[&<>'"`]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;", "`": "&#96;" })[c]), positionPopover = (a, p) => {
@@ -315,8 +262,6 @@ const su = { key: "sunes_v1", activeKey: "active_sune_id", load() {
}, setActiveId(id) {
localStorage.setItem(this.activeKey, id || "");
} };
const defaultSettings = { model: DEFAULT_MODEL, temperature: "", top_p: "", top_k: "", frequency_penalty: "", repetition_penalty: "", min_p: "", top_a: "", verbosity: "", reasoning_effort: "default", system_prompt: "", html: "", extension_html: "<sune src='https://raw.githubusercontent.com/sune-org/store/refs/heads/main/sync.sune' private></sune>", hide_composer: false, include_thoughts: false, json_output: false, img_output: false, aspect_ratio: "1:1", image_size: "1K", ignore_master_prompt: false, json_schema: "" };
const makeSune = (p = {}) => ({ id: p.id || gid(), name: p.name?.trim() || "Default", pinned: !!p.pinned, avatar: p.avatar || "", url: p.url || "", updatedAt: p.updatedAt || Date.now(), settings: Object.assign({}, defaultSettings, p.settings || {}), storage: p.storage || {} });
let sunes = (su.load() || []).map(makeSune);
const SUNE = window.SUNE = new Proxy({ get list() {
return sunes;
@@ -636,9 +581,7 @@ function setBtnSend() {
icons();
b.onclick = null;
}
function localDemoReply() {
return "Tip: open the sidebar → Account & Backup to set your API key.";
}
const localDemoReply = () => "Tip: open the sidebar → Account & Backup to set your API key.";
const titleFrom = (t) => {
if (!t) return "Untitled";
const s = typeof t === "string" ? t : Array.isArray(t) ? partsToText({ content: t }) : "Untitled";
@@ -1403,10 +1346,6 @@ const USER = window.USER = { log: async (s) => {
return localStorage.getItem("master_prompt") || "Always respond using markdown.";
}, set masterPrompt(v) {
localStorage.setItem("master_prompt", v || "");
}, get donor() {
return localStorage.getItem("user_donor") !== "false";
}, set donor(v) {
localStorage.setItem("user_donor", String(!!v));
}, get titleModel() {
return localStorage.getItem("title_model") ?? "or:amazon/nova-micro-v1";
}, set titleModel(v) {
@@ -1579,20 +1518,6 @@ function openAccountSettings() {
el.set_user_name.value = USER.name;
el.userAvatarPreview.src = USER.avatar || "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";
el.userAvatarPreview.classList.toggle("bg-gray-200", !USER.avatar);
el.set_donor.checked = USER.donor;
const updateProv = () => {
const d = el.set_donor.checked;
Array.from(el.set_provider.options).forEach((o) => {
if (o.value !== "openrouter") {
o.disabled = !d;
if (!d) o.hidden = true;
else o.hidden = false;
}
});
if (!d && el.set_provider.value !== "openrouter") el.set_provider.value = "openrouter";
};
updateProv();
el.set_donor.onchange = updateProv;
showAccountTab("General");
el.accountSettingsModal.classList.remove("hidden");
}
@@ -1620,7 +1545,6 @@ $(el.accountSettingsForm).on("submit", (e) => {
USER.titleModel = String(el.set_title_model.value || "").trim();
USER.githubToken = String(el.set_gh_token.value || "").trim();
USER.name = String(el.set_user_name.value || "").trim();
USER.donor = el.set_donor.checked;
closeAccountSettings();
});
el.gcpSAUploadBtn.onclick = () => el.gcpSAInput.click();
@@ -1687,7 +1611,6 @@ el.importAccountSettingsInput.onchange = async (e) => {
};
const getBubbleById = (id) => el.messages.querySelector(`.msg-bubble[data-mid="${CSS.escape(id)}"]`);
async function syncActiveThread() {
if (!USER.donor) return false;
const id = THREAD.getLastAssistantMessageId();
if (!id) return false;
if (await cacheStore.getItem(id) === "done") {

9
dist/index.html vendored
View File

@@ -15,7 +15,7 @@
<script type="module" crossorigin src="/assets/index-BTLTjBAR.js"></script>
<script type="module" crossorigin src="/assets/index-Dkva_nfv.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CLEI5Rwr.css">
<link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
<body class="bg-white text-gray-900 selection:bg-black/10" x-data @click.window="if($event.target.closest('button')) haptic(); if(!document.getElementById('threadPopover').contains($event.target)&&!$event.target.closest('[data-thread-menu]')) hideThreadPopover(); if(!document.getElementById('sunePopover').contains($event.target)&&!$event.target.closest('[data-sune-menu]')) hideSunePopover(); if(!document.getElementById('userMenu').contains($event.target)&&!document.getElementById('userMenuBtn').contains($event.target)) document.getElementById('userMenu').classList.add('hidden')">
@@ -172,13 +172,6 @@
<div><label class="block text-gray-700 font-medium mb-1">Provider</label><select id="set_provider" class="w-full rounded-xl border border-gray-300 px-3 py-2"><option value="openrouter">OpenRouter</option><option value="openai">OpenAI</option><option value="google">Google</option><option value="claude">Claude</option></select><p class="mt-1 text-xs text-gray-500">Or you can prefix model names with or:, oai:, g:, or cla: to override.</p></div>
<div><label class="block text-gray-700 font-medium mb-1">Master Prompt</label><textarea id="set_master_prompt" rows="6" class="w-full rounded-xl border border-gray-300 px-3 py-2" placeholder="Applies to all sunes on this device"></textarea><p class="mt-1 text-xs text-gray-500">Stored locally.</p></div>
<div><label class="block text-gray-700 font-medium mb-1">Model preference for titles</label><input id="set_title_model" type="text" class="w-full rounded-xl border border-gray-300 px-3 py-2" placeholder="or:google/gemma-3-12b-it"/><p class="mt-1 text-xs text-gray-500">Used for auto-generating thread titles.</p></div>
<div class="flex items-start gap-3">
<input id="set_donor" type="checkbox" class="mt-0.5 h-4 w-4 rounded border-gray-300 text-black focus:ring-black">
<div class="text-sm">
<label for="set_donor" class="font-medium text-gray-700">Using Proxy (recommended)</label>
<p class="text-xs text-gray-500">When enabled, streams go through a proxy which makes it possible to background the mobile app or tab while streaming and not lose your chat upon foregrounding.</p>
</div>
</div>
</div>
<div id="accountPanelAPI" class="p-4 hidden"><div class="grid grid-cols-2 gap-x-4 gap-y-4"><div><label class="block text-gray-700 font-medium mb-1">OpenRouter Key</label><div class="relative"><input id="set_api_key_or" type="password" class="w-full rounded-xl border border-gray-300 px-3 py-2 pr-10" placeholder="sk-or-..."><button type="button" data-reveal-for="set_api_key_or" class="absolute inset-y-0 right-0 px-3 flex items-center text-gray-400 hover:text-gray-600"><i data-lucide="eye" class="h-4 w-4"></i></button></div><p class="mt-1 text-xs text-gray-500">Use: <code>USER.apiKeyOpenRouter</code></p></div><div><label class="block text-gray-700 font-medium mb-1">OpenAI Key</label><div class="relative"><input id="set_api_key_oai" type="password" class="w-full rounded-xl border border-gray-300 px-3 py-2 pr-10" placeholder="sk-..."><button type="button" data-reveal-for="set_api_key_oai" class="absolute inset-y-0 right-0 px-3 flex items-center text-gray-400 hover:text-gray-600"><i data-lucide="eye" class="h-4 w-4"></i></button></div><p class="mt-1 text-xs text-gray-500">Use: <code>USER.apiKeyOpenAI</code></p></div><div><label class="block text-gray-700 font-medium mb-1">Google Key</label><div class="relative"><input id="set_api_key_g" type="password" class="w-full rounded-xl border border-gray-300 px-3 py-2 pr-10" placeholder="AIza..."><button type="button" data-reveal-for="set_api_key_g" class="absolute inset-y-0 right-0 px-3 flex items-center text-gray-400 hover:text-gray-600"><i data-lucide="eye" class="h-4 w-4"></i></button></div><p class="mt-1 text-xs text-gray-500">Gemini/Studio. Use: <code>USER.apiKeyGoogle</code></p></div><div><label class="block text-gray-700 font-medium mb-1">Claude Key</label><div class="relative"><input id="set_api_key_claude" type="password" class="w-full rounded-xl border border-gray-300 px-3 py-2 pr-10" placeholder="sk-ant-..."><button type="button" data-reveal-for="set_api_key_claude" class="absolute inset-y-0 right-0 px-3 flex items-center text-gray-400 hover:text-gray-600"><i data-lucide="eye" class="h-4 w-4"></i></button></div><p class="mt-1 text-xs text-gray-500">Use: <code>USER.apiKeyClaude</code></p></div><div><label class="block text-gray-700 font-medium mb-1">Cloudflare Token</label><div class="relative"><input id="set_api_key_cf" type="password" class="w-full rounded-xl border border-gray-300 px-3 py-2 pr-10" placeholder="..."><button type="button" data-reveal-for="set_api_key_cf" class="absolute inset-y-0 right-0 px-3 flex items-center text-gray-400 hover:text-gray-600"><i data-lucide="eye" class="h-4 w-4"></i></button></div><p class="mt-1 text-xs text-gray-500">Not used. Use: <code>USER.apiKeyCloudflare</code></p></div><div><label class="block text-gray-700 font-medium mb-1">Github Token</label><div class="relative"><input id="set_gh_token" type="password" class="w-full rounded-xl border border-gray-300 px-3 py-2 pr-10" placeholder="ghp_..."><button type="button" data-reveal-for="set_gh_token" class="absolute inset-y-0 right-0 px-3 flex items-center text-gray-400 hover:text-gray-600"><i data-lucide="eye" class="h-4 w-4"></i></button></div><p class="mt-1 text-xs text-gray-500">Use: <code>USER.githubToken</code></p></div><div><label class="block text-gray-700 font-medium mb-1">GCP Service Acct</label><input id="gcpSAInput" type="file" class="hidden" accept="application/json,.json"><button type="button" id="gcpSAUploadBtn" class="w-full text-left rounded-xl border border-gray-300 bg-white px-3 py-2 text-sm hover:bg-gray-50 truncate">Upload .json</button><p class="mt-1 text-xs text-gray-500">Use: <code>USER.gcpSA</code></p></div></div></div>
<div id="accountPanelUser" class="p-4 space-y-4 hidden">

2
dist/sw.js vendored
View File

@@ -1 +1 @@
if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didnt register its module`);return e}));self.define=(n,r)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(s[t])return;let c={};const o=e=>i(e,t),d={module:{uri:t},exports:c,require:o};s[t]=Promise.all(n.map(e=>d[e]||o(e))).then(e=>(r(...e),c))}}define(["./workbox-8c29f6e4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"6664ab7471fc7c3d2d7c674cc9d0cf2c"},{url:"assets/index-CLEI5Rwr.css",revision:null},{url:"assets/index-BTLTjBAR.js",revision:null},{url:"manifest.webmanifest",revision:"7a6c5c6ab9cb5d3605d21df44c6b17a2"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});
if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didnt register its module`);return e}));self.define=(n,r)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(s[t])return;let o={};const c=e=>i(e,t),l={module:{uri:t},exports:o,require:c};s[t]=Promise.all(n.map(e=>l[e]||c(e))).then(e=>(r(...e),o))}}define(["./workbox-8c29f6e4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"b6cdcb38154ab75f93f9aac3652388ac"},{url:"assets/index-Dkva_nfv.js",revision:null},{url:"assets/index-CLEI5Rwr.css",revision:null},{url:"manifest.webmanifest",revision:"7a6c5c6ab9cb5d3605d21df44c6b17a2"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});