ruflo 3.6.27 → 3.6.29

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 (31) hide show
  1. package/package.json +1 -1
  2. package/src/ruvocal/.claude-flow/daemon-state.json +135 -0
  3. package/src/ruvocal/.claude-flow/data/pending-insights.jsonl +0 -25
  4. package/src/ruvocal/.claude-flow/data/ranked-context.json +5 -0
  5. package/src/ruvocal/.claude-flow/logs/daemon.log +31 -0
  6. package/src/ruvocal/.claude-flow/logs/headless/audit_1777949411822_juxau0_prompt.log +989 -0
  7. package/src/ruvocal/.claude-flow/logs/headless/audit_1777949411822_juxau0_result.log +67 -0
  8. package/src/ruvocal/.claude-flow/logs/headless/audit_1777950042278_jvj5xq_prompt.log +989 -0
  9. package/src/ruvocal/.claude-flow/logs/headless/audit_1777950042278_jvj5xq_result.log +93 -0
  10. package/src/ruvocal/.claude-flow/logs/headless/optimize_1777949531823_yt5yc2_prompt.log +1498 -0
  11. package/src/ruvocal/.claude-flow/logs/headless/optimize_1777949531823_yt5yc2_result.log +93 -0
  12. package/src/ruvocal/.claude-flow/logs/headless/testgaps_1777949771821_elw1j4_prompt.log +1498 -0
  13. package/src/ruvocal/.claude-flow/logs/headless/testgaps_1777949771821_elw1j4_result.log +100 -0
  14. package/src/ruvocal/.claude-flow/metrics/codebase-map.json +11 -0
  15. package/src/ruvocal/.claude-flow/metrics/consolidation.json +6 -0
  16. package/src/ruvocal/.claude-flow/sessions/current.json +13 -0
  17. package/src/ruvocal/.swarm/attestation.db +0 -0
  18. package/src/ruvocal/.swarm/hnsw.index +0 -0
  19. package/src/ruvocal/.swarm/hnsw.metadata.json +1 -0
  20. package/src/ruvocal/.swarm/memory.db +0 -0
  21. package/src/ruvocal/.swarm/schema.sql +305 -0
  22. package/src/ruvocal/src/lib/components/chat/ChatWindow.svelte +8 -8
  23. package/src/ruvocal/src/lib/server/mcp/clientPool.spec.ts +175 -0
  24. package/src/ruvocal/src/lib/server/mcp/clientPool.ts +0 -0
  25. package/src/ruvocal/src/lib/server/textGeneration/index.ts +1 -0
  26. package/src/ruvocal/src/lib/server/textGeneration/mcp/runMcpFlow.ts +10 -1
  27. package/src/ruvocal/src/lib/server/textGeneration/types.ts +3 -1
  28. package/src/ruvocal/src/routes/api/v2/user/settings/+server.ts +7 -0
  29. package/src/ruvocal/src/routes/conversation/[id]/+page.svelte +4 -0
  30. package/src/ruvocal/src/routes/conversation/[id]/+server.ts +4 -0
  31. package/src/ruvocal/src/routes/settings/(nav)/+server.ts +6 -0
@@ -0,0 +1,989 @@
1
+ [2026-05-05T03:00:42.345Z] PROMPT
2
+ ============================================================
3
+ Analyze this codebase for security vulnerabilities:
4
+ - Check for hardcoded secrets (API keys, passwords)
5
+ - Identify SQL injection risks
6
+ - Find XSS vulnerabilities
7
+ - Check for insecure dependencies
8
+ - Identify authentication/authorization issues
9
+
10
+ Provide a JSON report with:
11
+ {
12
+ "vulnerabilities": [{ "severity": "high|medium|low", "file": "...", "line": N, "description": "..." }],
13
+ "riskScore": 0-100,
14
+ "recommendations": ["..."]
15
+ }
16
+
17
+ ## Codebase Context
18
+
19
+ --- .husky/lint-stage-config.js ---
20
+ export default {
21
+ "*.{js,jsx,ts,tsx}": ["prettier --write", "eslint --fix", "eslint"],
22
+ "*.json": ["prettier --write"],
23
+ };
24
+
25
+
26
+ --- .svelte-kit/adapter-node/_app/immutable/workers/markdownWorker-C-YfesBE.js (truncated) ---
27
+ (function(){"use strict";class Je{constructor(e,t,a){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=e,this.start=t,this.end=a}static range(e,t){return t?!e||!e.loc||!t.loc||e.loc.lexer!==t.loc.lexer?null:new Je(e.loc.lexer,e.loc.start,t.loc.end):e&&e.loc}}class it{constructor(e,t){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=e,this.loc=t}range(e,t){return new it(t,Je.range(this,e))}}class R{constructor(e,t){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var a="KaTeX parse error: "+e,n,i,u=t&&t.loc;if(u&&u.start<=u.end){var o=u.lexer.input;n=u.start,i=u.end,n===o.length?a+=" at end of input: ":a+=" at position "+(n+1)+": ";var c=o.slice(n,i).replace(/[^]/g,"$&̲"),h;n>15?h="…"+o.slice(n-15,n):h=o.slice(0,n);var m;i+15<o.length?m=o.slice(i,i+15)+"…":m=o.slice(i),a+=h+c+m}var p=new Error(a);return p.name="ParseError",p.__proto__=R.prototype,p.position=n,n!=null&&i!=null&&(p.length=i-n),p.rawMessage=e,p}}R.prototype.__proto__=Error.prototype;var Iu=function(e,t){return e.indexOf(t)!==-1},Ou=function(e,t){return e===void 0?t:e},Ru=/([A-Z])/g,zu=function(e){return e.replace(Ru,"-$1").toLowerCase()},Cu={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},Du=/[&><"']/g;function Bu(r){return String(r).replace(Du,e=>Cu[e])}var $a=function r(e){return e.type==="ordgroup"||e.type==="color"?e.body.length===1?r(e.body[0]):e:e.type==="font"?r(e.body):e},Lu=function(e){var t=$a(e);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},qu=function(e){if(!e)throw new Error("Expected non-null, but got "+String(e));return e},$u=function(e){var t=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(e);return t?t[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():"_relative"},Z={contains:Iu,deflt:Ou,escape:Bu,hyphenate:zu,getBaseElem:$a,isCharacterBox:Lu,protocolFromUrl:$u},z0={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:r=>"#"+r},macros:{type:"object",cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(r,e)=>(e.push(r),e)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:r=>Math.max(0,r),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:r=>Math.max(0,r),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:r=>Math.max(0,r),cli:"-e, --max-expand <n>",cliProcessor:r=>r==="Infinity"?1/0:parseInt(r)},globalGroup:{type:"boolean",cli:!1}};function Pu(r){if(r.default)return r.default;var e=r.type,t=Array.isArray(e)?e[0]:e;if(typeof t!="string")return t.enum[0];switch(t){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}class kr{constructor(e){this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.
28
+
29
+ --- .svelte-kit/adapter-node/chunks/APIClient.js ---
30
+ import { b as base } from "./server.js";
31
+ import "./url.js";
32
+ import "@sveltejs/kit/internal/server";
33
+ import "./root.js";
34
+ import superjson from "superjson";
35
+ import ObjectId from "bson-objectid";
36
+ superjson.registerCustom(
37
+ {
38
+ isApplicable: (value) => {
39
+ if (typeof value !== "string" && ObjectId.isValid(value)) {
40
+ const str = value.toString();
41
+ return /^[0-9a-fA-F]{24}$/.test(str);
42
+ }
43
+ return false;
44
+ },
45
+ serialize: (value) => value.toString(),
46
+ deserialize: (value) => new ObjectId(value)
47
+ },
48
+ "ObjectId"
49
+ );
50
+ async function apiCall(fetcher, url, method, body, query) {
51
+ const u = new URL(url);
52
+ if (query) {
53
+ for (const [k, v] of Object.entries(query)) {
54
+ if (v !== void 0 && v !== null) {
55
+ u.searchParams.set(k, String(v));
56
+ }
57
+ }
58
+ }
59
+ const init = { method };
60
+ if (body !== void 0 && body !== null) {
61
+ init.headers = { "Content-Type": "application/json" };
62
+ init.body = JSON.stringify(body);
63
+ }
64
+ const res = await fetcher(u.toString(), init);
65
+ if (!res.ok) {
66
+ let errorBody;
67
+ try {
68
+ errorBody = await res.json();
69
+ } catch {
70
+ errorBody = await res.text().catch(() => res.statusText);
71
+ }
72
+ return { data: null, error: errorBody, status: res.status };
73
+ }
74
+ const text = await res.text();
75
+ if (!text) {
76
+ return { data: null, error: null, status: res.status };
77
+ }
78
+ return { data: text, error: null, status: res.status };
79
+ }
80
+ function endpoint(fetcher, baseUrl) {
81
+ return {
82
+ get(opts) {
83
+ return apiCall(fetcher, baseUrl, "GET", void 0, opts?.query);
84
+ },
85
+ post(body) {
86
+ return apiCall(fetcher, baseUrl, "POST", body);
87
+ },
88
+ patch(body) {
89
+ return apiCall(fetcher, baseUrl, "PATCH", body);
90
+ },
91
+ delete() {
92
+ return apiCall(fetcher, baseUrl, "DELETE");
93
+ }
94
+ };
95
+ }
96
+ function useAPIClient({
97
+ fetch: customFetch,
98
+ origin
99
+ } = {}) {
100
+ const fetcher = customFetch ?? globalThis.fetch;
101
+ const baseUrl = `${origin ?? `http://localhost:5173`}${base}/api/v2`;
102
+ return {
103
+ conversations: Object.assign(
104
+ // client.conversations({ id: "..." }) — returns endpoint for /conversations/:id
105
+ (params) => ({
106
+ ...endpoint(fetcher, `${baseUrl}/conversations/${params.id}`),
107
+ message: (msgParams) => endpoint(fetcher, `${baseUrl}/conversations/${params.id}/message/${msgParams.messageId}`)
108
+ }),
109
+ // client.conversations.get(), .delete()
110
+ {
111
+ ...endpoint(fetcher, `${baseUrl}/conversations`),
112
+ "import-share": endpoint(fetcher, `${baseUrl}/conversations/import-share`)
113
+ }
114
+ ),
115
+ user: {
116
+ ...endpoint(fetcher, `${baseUrl}/user`),
117
+ settings: endpoint(fetcher, `${baseUrl}/user/settings`),
118
+ reports: endpoint(fetcher, `${baseUrl}/user/reports`),
119
+ "billing-orgs": endpoint(fetcher, `${baseUrl}/user/billing-orgs`)
120
+ },
121
+ models: {
122
+ ...endpoint(fetcher, `${baseUrl}/models`),
123
+ old: endpoint(fetcher, `${baseUrl}/models/old`),
124
+ refresh: endpoint(fetcher, `${baseUrl}/models/refresh`)
125
+ },
126
+ "public-config": endpoint(fetcher, `${baseUrl}/public-config`),
127
+ "feature-flags": endpoint(fetcher, `${baseUrl}/feature-flags`),
128
+ debug: {
129
+ config: endpoint(fetcher, `${baseUrl}/debug/config`),
130
+ refresh: endpoint(fetcher, `${baseUrl}/debug/refresh`)
131
+ },
132
+ export: endpoint(fetcher, `${baseUrl}/export`)
133
+ };
134
+ }
135
+ function handleResponse(response) {
136
+ if (response.error) {
137
+ throw new Error(JSON.stringify(response.error));
138
+ }
139
+ if (response.data === null) {
140
+ return null;
141
+ }
142
+ return superjson.parse(
143
+ typeof response.data === "string" ? response.data : JSON.stringify(response.data)
144
+ );
145
+ }
146
+ export {
147
+ handleResponse as h,
148
+ useAPIClient as u
149
+ };
150
+
151
+
152
+ --- .svelte-kit/adapter-node/chunks/IconCheap.js ---
153
+ import { i as attr_class, p as clsx } from "./root.js";
154
+ function IconFast($$renderer, $$props) {
155
+ let { classNames = "" } = $$props;
156
+ $$renderer.push(`<svg${attr_class(clsx(classNames))} width="1em" height="1em" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 2a4 4 0 1 0 0 8 4 4 0 0 0 0-8Zm0 .8A3.2 3.2 0 0 1 9.2 6c0 .96-.4 1.8-1.08 2.4-.56-.52-1.32-.8-2.12-.8s-1.52.28-2.12.8A3.15 3.15 0 0 1 2.8 6 3.2 3.2 0 0 1 6 2.8Zm-.8.8a.4.4 0 1 0 0 .8.4.4 0 0 0 0-.8Zm1.6 0a.4.4 0 1 0 0 .8.4.4 0 0 0 0-.8Zm1.236 1.176c-.052 0-.1.012-.156.024l-1.28.528-.108.044a.807.807 0 0 0-1.053.059.796.796 0 0 0-.008 1.13.796.796 0 0 0 .869.179.81.81 0 0 0 .5-.628l.092-.04 1.288-.52.008-.004a.4.4 0 0 0-.152-.772ZM4 4.8a.4.4 0 1 0 0 .8.4.4 0 0 0 0-.8Z" fill="currentColor"></path></svg>`);
157
+ }
158
+ function IconCheap($$renderer, $$props) {
159
+ let { classNames = "" } = $$props;
160
+ $$renderer.push(`<svg${attr_class(clsx(classNames))} width="1em" height="1em" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 7.778a.856.856 0 0 1-.628-.261.858.858 0 0 1-.26-.628c-.001-.245.086-.454.26-.628A.861.861 0 0 1 6 6c.244 0 .453.087.628.261a.852.852 0 0 1 .26.628.867.867 0 0 1-.26.628.844.844 0 0 1-.628.26Zm-2.056-4h4.112l.566-1.134a.423.423 0 0 0-.017-.433A.42.42 0 0 0 8.222 2H3.778c-.17 0-.298.07-.383.211a.424.424 0 0 0-.017.433l.566 1.134ZM4.4 10h3.2c.667 0 1.233-.231 1.7-.694.467-.463.7-1.032.7-1.706 0-.281-.048-.556-.144-.822a2.404 2.404 0 0 0-.412-.722L8.29 4.666H3.71l-1.155 1.39a2.404 2.404 0 0 0-.412.722C2.048 7.044 2 7.318 2 7.6c0 .674.232 1.243.695 1.706.463.463 1.031.694 1.705.694Z" fill="currentColor"></path></svg>`);
161
+ }
162
+ export {
163
+ IconFast as I,
164
+ IconCheap as a
165
+ };
166
+
167
+
168
+ --- .svelte-kit/adapter-node/chunks/IconOmni.js (truncated) ---
169
+ import { i as attr_class, j as stringify } from "./root.js";
170
+ function IconOmni($$renderer, $$props) {
171
+ let { classNames = "" } = $$props;
172
+ $$renderer.push(`<svg${attr_class(`${stringify(classNames)} hidden dark:inline`)} width="1em" height="1em" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.97736 12.1813C6.25011 12.516 6.57428 12.8946 6.98029 13.2741C5.89251 13.8066 4.44063 14.1305 2.34747 14.1306V12.7272C4.02144 12.7272 5.15855 12.5026 5.97736 12.1813ZM10.0789 6.00458C10.3483 6.3067 10.6247 6.56949 10.9725 6.79364C11.5911 7.19216 12.4914 7.49774 14.0526 7.49774V8.90204C12.4915 8.90204 11.5911 9.20765 10.9725 9.60614C10.6249 9.83013 10.3481 10.0924 10.0789 10.3942C9.78258 10.1597 9.52333 9.87047 9.21271 9.48798C9.18183 9.44996 9.14961 9.40984 9.11603 9.36786C9.42491 9.03403 9.77986 8.70638 10.2127 8.42743C10.3378 8.34683 10.4686 8.27118 10.6053 8.19989C10.4686 8.12858 10.3378 8.05297 10.2127 7.97235C9.77958 7.69322 9.42506 7.365 9.11603 7.03094C9.1494 6.98922 9.18201 6.9496 9.21271 6.9118C9.52349 6.52912 9.78237 6.2392 10.0789 6.00458ZM2.34747 2.26923C4.44032 2.26927 5.89256 2.59232 6.98029 3.12469C6.57429 3.50414 6.25012 3.8828 5.97736 4.21747C5.15858 3.89631 4.02115 3.67356 2.34747 3.67352V2.26923Z" fill="url(#paint0_linear_3699_582)"></path><path d="M14.052 3.67331C12.0512 3.67337 10.8161 3.98917 9.97647 4.41441C9.14382 4.83623 8.63688 5.39533 8.12318 6.02791C7.62178 6.64535 7.06413 7.40735 6.18741 7.97235C6.06225 8.053 5.93137 8.12889 5.79462 8.20022C5.93144 8.27158 6.06219 8.34739 6.18741 8.42808C7.06422 8.99314 7.62174 9.75505 8.12318 10.3725C8.6369 11.0051 9.14374 11.5642 9.97647 11.986C10.8161 12.4113 12.0512 12.7271 14.052 12.7271V14.1312C11.9098 14.1311 10.4387 13.7932 9.34279 13.2382C8.24007 12.6797 7.58149 11.9313 7.03377 11.2569C6.47365 10.5671 6.07238 10.0218 5.42786 9.60647C4.80925 9.20786 3.90875 8.90226 2.34735 8.90226V7.49818C3.90859 7.49818 4.80926 7.19251 5.42786 6.79397C6.07232 6.37865 6.47373 5.83323 7.03377 5.14358C7.58147 4.46911 8.24014 3.72078 9.34279 3.16224C10.4387 2.60722 11.9098 2.26929 14.052 2.26923V3.67331Z" fill="url(#paint1_linear_3699_582)"></path><defs><linearGradient id="paint0_linear_3699_582" x1="10.2846" y1="8.06294" x2="-0.714687" y2="8.06294" gradientUnits="userSpaceOnUse"><stop stop-color="white"></stop><stop offset="1" stop-color="white" stop-opacity="0"></stop></linearGradient><linearGradient id="paint1_linear_3699_582" x1="1.34749" y1="8.06326" x2="14.273" y2="8.06326" gradientUnits="userSpaceOnUse"><stop stop-color="white" stop-opacity="0"></stop><stop offset="1" stop-color="white"></stop></linearGradient></defs></svg><svg${attr_class(`${stringify(classNames)} inline dark:hidden`)} width="1em" height="1em" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.97723 12.3813C6.24999 12.716 6.57417 13.0946 6.98016 13.4741C5.89247 14.0066 4.44119 14.3305 2.34833 14.3306V12.9272C4.02198 12.9272 5.1585 12.7025 5.97723 12.3813ZM10.0788 6.20459C10.3481 6.50673 10.6245 6.76948 10.9724 6.99365C11.5909 7.39219 12.4912 7.69774 14.0524 7.69775V9.10205C12.4913 9.10207 11.5909 9.40765 10.9724 9.80615C10.6248 10.0302 10.348 10.2924 10.0788 10.5942C9.78249 10.3597 9.52319 10.0704 9.21259 9.68799C9.18171 9.64997 9.14949 9.60986 9.11591 9.56787C9.42481 9.23402 9.77972 8.9064 10.2126 8.62744C10.3377 8.54682 10.4685 8.47121 10.6052 8.3999C10.4685 8.32859 10.3377 8.25299 10.2126 8.17236C9.77943 7.89322 9.42495 7.56504 9.11591 7.23096C9.1493 7.18921 9.18187 7.14963 9.21259 7.11182C9.52337 6.72913 9.78226 6.43921 10.0788 6.20459ZM2.34833 2.46924C4.44088 2.46933 5.89252 2.7924 6.98016 3.32471C6.57418 3.70415 6.25 4.08282 5.97723 4.41748C5.15853 4.09637 4.0217 3.87361 2.34833 3.87354V2.46924Z" fill="url(#paint0_linear_3699_575)"></path><path d="M14.052 3.87332C12.0512 3.87338 10.8161 4.18918 9.97647 4.61442C9.14382 5.03624 8.63688 5.59534 8.12318 6.22792C7.62178 6.84536 7.06413 7.60736 6.18741 8.17236C6.06225 8.25301 5.93137 8.3289 5.79462 8.40023C5.93144 8.47159 6.06219 8.5474 6.18741 8.62809C7.06422 9.19316 7.62174 9.95506 8.12318 10.5725C8.6369 11.2051 9.14374 11.7642 9.97647 12.186C10.8161 12.6113 12.0512 12.9271 14.052 12.9271V14.3312C11.9098 14.3312 10.4387 13.9932 9.34279 13.4382C8.24007 12.8797 7.58149 12.1313 7.03377 11.4569C6.47365 10.7671 6.07238 10.2218 5.42786 9.80648C4.80925 9.40788 3.90875 9.10227 2.34735 9.10227V7.69819C3.90859 7.69819 4.80926 7.39252 5.42786 6.99398C6.07232 6.57866 6.47373 6.03324 7.03377 5.34359C7.58147 4.66913 8.24014 3.92079 9.34279 3.36225C10.4387 2.80724 11.9098 2.4693 14.052 2.46924V3.87332Z" fill="url(#paint1_linear_3699_575)"></path><defs><linearGradient id="paint0_linear_3699_575" x1="10.2848" y1="8.26295" x2="-0.713577" y2="8.26295" gradientUnits="userSpaceOnUse"><stop></stop><stop offset="1" stop-opacity="0"></stop></linearGradient><linearGradient id="paint1_linear_3699_575" x1="1.34749" y1="8.26327" x2="14.273" y2="8.26327" gradientUnits="userSpaceOnUse"><stop stop-opacity="0"></st
173
+
174
+ --- .svelte-kit/adapter-node/chunks/IconPro.js ---
175
+ import { w as writable } from "./index.js";
176
+ import { i as attr_class, h as attr, j as stringify } from "./root.js";
177
+ const isPro = writable(null);
178
+ function IconPro($$renderer, $$props) {
179
+ $$renderer.component(($$renderer2) => {
180
+ let { classNames = "" } = $$props;
181
+ const gradientId = `gradient-${Math.random().toString(36).slice(2, 9)}`;
182
+ $$renderer2.push(`<svg${attr_class(`text-gray-500 ${stringify(classNames)}`)} xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" role="img" width="1em" height="1em" viewBox="0 0 12 12"><defs><linearGradient${attr("id", gradientId)} x1="3.371" y1="3.43" x2="8.141" y2="8.9" gradientUnits="userSpaceOnUse"><stop stop-color="#FF0789"></stop><stop offset=".63" stop-color="#21DE75"></stop><stop offset="1" stop-color="#FF8D00"></stop></linearGradient></defs><path d="M6.481 1.26c0 1.55.67 2.58 1.5 3.24.86.68 1.9 1 2.58 1.07v.86a5.3 5.3 0 0 0-2.57 1.07 3.95 3.95 0 0 0-1.51 3.24h-.96c0-1.55-.67-2.58-1.5-3.24a5.3 5.3 0 0 0-2.58-1.07v-.86a5.3 5.3 0 0 0 2.57-1.07 3.95 3.95 0 0 0 1.51-3.24h.96Z"${attr("fill", `url(#${stringify(gradientId)})`)}></path></svg>`);
183
+ });
184
+ }
185
+ export {
186
+ IconPro as I,
187
+ isPro as i
188
+ };
189
+
190
+
191
+ --- .svelte-kit/adapter-node/chunks/MessageUpdate.js ---
192
+ var MessageUpdateType = /* @__PURE__ */ ((MessageUpdateType2) => {
193
+ MessageUpdateType2["Status"] = "status";
194
+ MessageUpdateType2["Title"] = "title";
195
+ MessageUpdateType2["Tool"] = "tool";
196
+ MessageUpdateType2["Stream"] = "stream";
197
+ MessageUpdateType2["File"] = "file";
198
+ MessageUpdateType2["FinalAnswer"] = "finalAnswer";
199
+ MessageUpdateType2["Reasoning"] = "reasoning";
200
+ MessageUpdateType2["RouterMetadata"] = "routerMetadata";
201
+ MessageUpdateType2["AutopilotStep"] = "autopilotStep";
202
+ return MessageUpdateType2;
203
+ })(MessageUpdateType || {});
204
+ var MessageUpdateStatus = /* @__PURE__ */ ((MessageUpdateStatus2) => {
205
+ MessageUpdateStatus2["Started"] = "started";
206
+ MessageUpdateStatus2["Error"] = "error";
207
+ MessageUpdateStatus2["Finished"] = "finished";
208
+ MessageUpdateStatus2["KeepAlive"] = "keepAlive";
209
+ return MessageUpdateStatus2;
210
+ })(MessageUpdateStatus || {});
211
+ var MessageToolUpdateType = /* @__PURE__ */ ((MessageToolUpdateType2) => {
212
+ MessageToolUpdateType2["Call"] = "call";
213
+ MessageToolUpdateType2["Result"] = "result";
214
+ MessageToolUpdateType2["Error"] = "error";
215
+ MessageToolUpdateType2["ETA"] = "eta";
216
+ MessageToolUpdateType2["Progress"] = "progress";
217
+ return MessageToolUpdateType2;
218
+ })(MessageToolUpdateType || {});
219
+ var MessageReasoningUpdateType = /* @__PURE__ */ ((MessageReasoningUpdateType2) => {
220
+ MessageReasoningUpdateType2["Stream"] = "stream";
221
+ MessageReasoningUpdateType2["Status"] = "status";
222
+ return MessageReasoningUpdateType2;
223
+ })(MessageReasoningUpdateType || {});
224
+ export {
225
+ MessageUpdateType as M,
226
+ MessageToolUpdateType as a,
227
+ MessageReasoningUpdateType as b,
228
+ MessageUpdateStatus as c
229
+ };
230
+
231
+
232
+ --- .svelte-kit/adapter-node/chunks/Modal.js ---
233
+ import { i as attr_class, p as clsx } from "./root.js";
234
+ import { o as onDestroy } from "./index-server.js";
235
+ import "clsx";
236
+ import { C as Close } from "./close.js";
237
+ function Portal($$renderer, $$props) {
238
+ $$renderer.component(($$renderer2) => {
239
+ let { children } = $$props;
240
+ onDestroy(() => {
241
+ });
242
+ $$renderer2.push(`<div class="contents" hidden="">`);
243
+ children?.($$renderer2);
244
+ $$renderer2.push(`<!----></div>`);
245
+ });
246
+ }
247
+ function Modal($$renderer, $$props) {
248
+ $$renderer.component(($$renderer2) => {
249
+ let {
250
+ width = "max-w-sm",
251
+ children,
252
+ closeButton = false,
253
+ disableFly = false,
254
+ closeOnBackdrop = true,
255
+ onclose
256
+ } = $$props;
257
+ onDestroy(() => {
258
+ return;
259
+ });
260
+ Portal($$renderer2, {
261
+ children: ($$renderer3) => {
262
+ $$renderer3.push(`<div role="presentation" tabindex="-1" class="fixed inset-0 z-40 flex items-center justify-center bg-black/80 backdrop-blur-sm dark:bg-black/50">`);
263
+ if (disableFly) {
264
+ $$renderer3.push("<!--[-->");
265
+ $$renderer3.push(`<div role="dialog" tabindex="-1"${attr_class(clsx([
266
+ "scrollbar-custom relative mx-auto max-h-[95dvh] max-w-[90dvw] overflow-y-auto overflow-x-hidden rounded-2xl bg-white shadow-2xl outline-none dark:bg-gray-800 dark:text-gray-200",
267
+ width
268
+ ]))}>`);
269
+ if (closeButton) {
270
+ $$renderer3.push("<!--[-->");
271
+ $$renderer3.push(`<button class="absolute right-4 top-4 z-50">`);
272
+ Close($$renderer3, { class: "size-6 text-gray-700 dark:text-gray-300" });
273
+ $$renderer3.push(`<!----></button>`);
274
+ } else {
275
+ $$renderer3.push("<!--[!-->");
276
+ }
277
+ $$renderer3.push(`<!--]--> `);
278
+ children?.($$renderer3);
279
+ $$renderer3.push(`<!----></div>`);
280
+ } else {
281
+ $$renderer3.push("<!--[!-->");
282
+ $$renderer3.push(`<div role="dialog" tabindex="-1"${attr_class(clsx([
283
+ "scrollbar-custom relative mx-auto max-h-[95dvh] max-w-[90dvw] overflow-y-auto overflow-x-hidden rounded-2xl bg-white shadow-2xl outline-none dark:bg-gray-800 dark:text-gray-200",
284
+ width
285
+ ]))}>`);
286
+ if (closeButton) {
287
+ $$renderer3.push("<!--[-->");
288
+ $$renderer3.push(`<button class="absolute right-4 top-4 z-50">`);
289
+ Close($$renderer3, { class: "size-6 text-gray-700 dark:text-gray-300" });
290
+ $$renderer3.push(`<!----></button>`);
291
+ } else {
292
+ $$renderer3.push("<!--[!-->");
293
+ }
294
+ $$renderer3.push(`<!--]--> `);
295
+ children?.($$renderer3);
296
+ $$renderer3.push(`<!----></div>`);
297
+ }
298
+ $$renderer3.push(`<!--]--></div>`);
299
+ }
300
+ });
301
+ });
302
+ }
303
+ export {
304
+ Modal as M
305
+ };
306
+
307
+
308
+ --- .svelte-kit/adapter-node/chunks/PublicConfig.svelte.js ---
309
+ import "clsx";
310
+ import { E as getContext } from "./root.js";
311
+ import "./client2.js";
312
+ import { b as base } from "./server.js";
313
+ import "./url.js";
314
+ import "@sveltejs/kit/internal/server";
315
+ class PublicConfigManager {
316
+ #configStore = {};
317
+ constructor(initialConfig) {
318
+ this.init = this.init.bind(this);
319
+ this.getPublicConfig = this.getPublicConfig.bind(this);
320
+ if (initialConfig) {
321
+ this.init(initialConfig);
322
+ }
323
+ }
324
+ init(publicConfig) {
325
+ this.#configStore = publicConfig;
326
+ }
327
+ get(key) {
328
+ return this.#configStore[key];
329
+ }
330
+ getPublicConfig() {
331
+ return this.#configStore;
332
+ }
333
+ get isHuggingChat() {
334
+ return this.#configStore.PUBLIC_APP_ASSETS === "huggingchat";
335
+ }
336
+ get assetPath() {
337
+ const origin = this.#configStore.PUBLIC_ORIGIN || "";
338
+ return origin + base + "/" + (this.#configStore.PUBLIC_APP_ASSETS || "chatui");
339
+ }
340
+ }
341
+ function getConfigManager(initialConfig) {
342
+ const publicConfigManager = new PublicConfigManager(initialConfig);
343
+ const publicConfig = new Proxy(publicConfigManager, {
344
+ get(target, prop) {
345
+ if (prop in target) {
346
+ return Reflect.get(target, prop);
347
+ }
348
+ if (typeof prop === "string") {
349
+ return target.get(prop);
350
+ }
351
+ return void 0;
352
+ },
353
+ set(target, prop, value, receiver) {
354
+ if (prop in target) {
355
+ return Reflect.set(target, prop, value, receiver);
356
+ }
357
+ return false;
358
+ }
359
+ });
360
+ return publicConfig;
361
+ }
362
+ const publicConfigTransporter = {
363
+ encode: (value) => value instanceof PublicConfigManager ? JSON.stringify(value.getPublicConfig()) : false,
364
+ decode: (value) => getConfigManager(JSON.parse(value))
365
+ };
366
+ const usePublicConfig = () => getContext("publicConfig");
367
+ export {
368
+ getConfigManager as g,
369
+ publicConfigTransporter as p,
370
+ usePublicConfig as u
371
+ };
372
+
373
+
374
+ --- .svelte-kit/adapter-node/chunks/Settings.js ---
375
+ import { d as defaultModel } from "./models.js";
376
+ const DEFAULT_SETTINGS = {
377
+ shareConversationsWithModelAuthors: true,
378
+ activeModel: defaultModel.id,
379
+ customPrompts: {},
380
+ multimodalOverrides: {},
381
+ toolsOverrides: {},
382
+ hidePromptExamples: {},
383
+ providerOverrides: {},
384
+ streamingMode: "smooth",
385
+ directPaste: false,
386
+ hapticsEnabled: true,
387
+ autopilotEnabled: true,
388
+ autopilotMaxSteps: 10
389
+ };
390
+ export {
391
+ DEFAULT_SETTINGS as D
392
+ };
393
+
394
+
395
+ --- .svelte-kit/adapter-node/chunks/Switch.js ---
396
+ import { h as attr, o as bind_props } from "./root.js";
397
+ function Switch($$renderer, $$props) {
398
+ $$renderer.component(($$renderer2) => {
399
+ let { checked = void 0, name } = $$props;
400
+ $$renderer2.push(`<input${attr("checked", checked, true)} type="checkbox"${attr("name", name)} class="peer pointer-events-none absolute opacity-0"/> <div${attr("aria-checked", checked)} aria-roledescription="switch" aria-label="switch" role="switch" tabindex="0" class="relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full bg-gray-300 p-1 shadow-inner ring-gray-400 peer-checked:bg-blue-600 hover:bg-gray-400 peer-checked:hover:bg-blue-600 focus-visible:ring focus-visible:ring-offset-1 dark:bg-gray-600 dark:ring-gray-700 dark:hover:bg-gray-500 dark:peer-checked:hover:bg-blue-600 peer-checked:[&amp;>div]:translate-x-3.5"><div class="h-3.5 w-3.5 rounded-full bg-white shadow-sm transition-transform"></div></div>`);
401
+ bind_props($$props, { checked });
402
+ });
403
+ }
404
+ export {
405
+ Switch as S
406
+ };
407
+
408
+
409
+ --- .svelte-kit/adapter-node/chunks/UrlDependency.js ---
410
+ var UrlDependency = /* @__PURE__ */ ((UrlDependency2) => {
411
+ UrlDependency2["ConversationList"] = "conversation:list";
412
+ UrlDependency2["Conversation"] = "conversation:id";
413
+ return UrlDependency2;
414
+ })(UrlDependency || {});
415
+ export {
416
+ UrlDependency as U
417
+ };
418
+
419
+
420
+ --- .svelte-kit/adapter-node/chunks/abortRegistry.js ---
421
+ import { l as logger } from "./logger.js";
422
+ class AbortRegistry {
423
+ constructor() {
424
+ this.controllers = /* @__PURE__ */ new Map();
425
+ }
426
+ static getInstance() {
427
+ if (!AbortRegistry.instance) {
428
+ AbortRegistry.instance = new AbortRegistry();
429
+ }
430
+ return AbortRegistry.instance;
431
+ }
432
+ register(conversationId, controller) {
433
+ const key = conversationId.toString();
434
+ let set = this.controllers.get(key);
435
+ if (!set) {
436
+ set = /* @__PURE__ */ new Set();
437
+ this.controllers.set(key, set);
438
+ }
439
+ set.add(controller);
440
+ controller.signal.addEventListener(
441
+ "abort",
442
+ () => {
443
+ this.unregister(key, controller);
444
+ },
445
+ { once: true }
446
+ );
447
+ }
448
+ abort(conversationId) {
449
+ const set = this.controllers.get(conversationId);
450
+ if (!set?.size) return;
451
+ logger.debug({ conversationId }, "Aborting active generation via AbortRegistry");
452
+ for (const controller of set) {
453
+ if (!controller.signal.aborted) {
454
+ controller.abort();
455
+ }
456
+ }
457
+ this.controllers.delete(conversationId);
458
+ }
459
+ unregister(conversationId, controller) {
460
+ const set = this.controllers.get(conversationId);
461
+ if (!set) return;
462
+ set.delete(controller);
463
+ if (set.size === 0) {
464
+ this.controllers.delete(conversationId);
465
+ }
466
+ }
467
+ }
468
+ export {
469
+ AbortRegistry as A
470
+ };
471
+
472
+
473
+ --- .svelte-kit/adapter-node/chunks/addSibling.js ---
474
+ import { v4 } from "uuid";
475
+ function addChildren(conv, message, parentId) {
476
+ if (conv.messages.length === 0) {
477
+ const messageId2 = v4();
478
+ conv.rootMessageId = messageId2;
479
+ conv.messages.push({
480
+ ...message,
481
+ ancestors: [],
482
+ id: messageId2
483
+ });
484
+ return messageId2;
485
+ }
486
+ if (!parentId) {
487
+ throw new Error("You need to specify a parentId if this is not the first message");
488
+ }
489
+ const messageId = v4();
490
+ if (!conv.rootMessageId) {
491
+ if (!!parentId && parentId !== conv.messages[conv.messages.length - 1].id) {
492
+ throw new Error("This is a legacy conversation, you can only append to the last message");
493
+ }
494
+ conv.messages.push({ ...message, id: messageId });
495
+ return messageId;
496
+ }
497
+ const ancestors = [...conv.messages.find((m) => m.id === parentId)?.ancestors ?? [], parentId];
498
+ conv.messages.push({
499
+ ...message,
500
+ ancestors,
501
+ id: messageId,
502
+ children: []
503
+ });
504
+ const parent = conv.messages.find((m) => m.id === parentId);
505
+ if (parent) {
506
+ if (parent.children) {
507
+ parent.children.push(messageId);
508
+ } else parent.children = [messageId];
509
+ }
510
+ return messageId;
511
+ }
512
+ function addSibling(conv, message, siblingId) {
513
+ if (conv.messages.length === 0) {
514
+ throw new Error("Cannot add a sibling to an empty conversation");
515
+ }
516
+ if (!conv.rootMessageId) {
517
+ throw new Error("Cannot add a sibling to a legacy conversation");
518
+ }
519
+ const sibling = conv.messages.find((m) => m.id === siblingId);
520
+ if (!sibling) {
521
+ throw new Error("The sibling message doesn't exist");
522
+ }
523
+ if (!sibling.ancestors || sibling.ancestors?.length === 0) {
524
+ throw new Error("The sibling message is the root message, therefore we can't add a sibling");
525
+ }
526
+ const messageId = v4();
527
+ conv.messages.push({
528
+ ...message,
529
+ id: messageId,
530
+ ancestors: sibling.ancestors,
531
+ children: []
532
+ });
533
+ const nearestAncestorId = sibling.ancestors[sibling.ancestors.length - 1];
534
+ const nearestAncestor = conv.messages.find((m) => m.id === nearestAncestorId);
535
+ if (nearestAncestor) {
536
+ if (nearestAncestor.children) {
537
+ nearestAncestor.children.push(messageId);
538
+ } else nearestAncestor.children = [messageId];
539
+ }
540
+ return messageId;
541
+ }
542
+ export {
543
+ addSibling as a,
544
+ addChildren as b
545
+ };
546
+
547
+
548
+ --- .svelte-kit/adapter-node/chunks/adminToken.js ---
549
+ import { c as config } from "./config.js";
550
+ import { l as logger } from "./logger.js";
551
+ import { v4 } from "uuid";
552
+ class AdminTokenManager {
553
+ constructor() {
554
+ this.token = config.ADMIN_TOKEN || v4();
555
+ this.adminSessions = [];
556
+ }
557
+ get enabled() {
558
+ return config.ADMIN_CLI_LOGIN === "true";
559
+ }
560
+ isAdmin(sessionId) {
561
+ if (!this.enabled) return false;
562
+ return this.adminSessions.includes(sessionId);
563
+ }
564
+ checkToken(token, sessionId) {
565
+ if (!this.enabled) return false;
566
+ if (token === this.token) {
567
+ logger.info(`[ADMIN] Token validated`);
568
+ this.adminSessions.push(sessionId);
569
+ this.token = config.ADMIN_TOKEN || v4();
570
+ return true;
571
+ }
572
+ return false;
573
+ }
574
+ removeSession(sessionId) {
575
+ this.adminSessions = this.adminSessions.filter((id) => id !== sessionId);
576
+ }
577
+ displayToken() {
578
+ if (!this.enabled || config.ADMIN_TOKEN) return;
579
+ let port = process.env.PORT ? parseInt(process.env.PORT) : process.argv.includes("--port") ? parseInt(process.argv[process.argv.indexOf("--port") + 1]) : void 0;
580
+ if (!port) {
581
+ const mode = process.argv.find((arg) => arg === "preview" || arg === "dev");
582
+ if (mode === "preview") {
583
+ port = 4173;
584
+ } else if (mode === "dev") {
585
+ port = 5173;
586
+ } else {
587
+ port = 3e3;
588
+ }
589
+ }
590
+ const url = (config.PUBLIC_ORIGIN || `http://localhost:${port}`) + "?token=";
591
+ logger.info(`[ADMIN] You can login with ${url + this.token}`);
592
+ }
593
+ }
594
+ const adminTokenManager = new AdminTokenManager();
595
+ export {
596
+ adminTokenManager as a
597
+ };
598
+
599
+
600
+ --- .svelte-kit/adapter-node/chunks/apiToken.js ---
601
+ import { c as config } from "./config.js";
602
+ function getApiToken(locals) {
603
+ if (config.USE_USER_TOKEN === "true") {
604
+ if (!locals?.token) {
605
+ throw new Error("User token not found");
606
+ }
607
+ return locals.token;
608
+ }
609
+ return config.OPENAI_API_KEY || config.HF_TOKEN;
610
+ }
611
+ export {
612
+ getApiToken as g
613
+ };
614
+
615
+
616
+ --- .svelte-kit/adapter-node/chunks/arrow-up-right.js ---
617
+ import { f as sanitize_props, g as attributes } from "./root.js";
618
+ import { h as html } from "./html.js";
619
+ function Arrow_up_right($$renderer, $$props) {
620
+ const $$sanitized_props = sanitize_props($$props);
621
+ $$renderer.push(`<svg${attributes(
622
+ {
623
+ viewBox: "0 0 32 32",
624
+ width: "1.2em",
625
+ height: "1.2em",
626
+ ...$$sanitized_props
627
+ },
628
+ void 0,
629
+ void 0,
630
+ void 0,
631
+ 3
632
+ )}>${html(`<path fill="currentColor" d="M10 6v2h12.59L6 24.59L7.41 26L24 9.41V22h2V6z"/>`)}</svg>`);
633
+ }
634
+ export {
635
+ Arrow_up_right as A
636
+ };
637
+
638
+
639
+ --- .svelte-kit/adapter-node/chunks/auth.js (truncated) ---
640
+ import { generators, Issuer, custom } from "openid-client";
641
+ import { addHours, subMinutes, addWeeks, differenceInMinutes } from "date-fns";
642
+ import { c as config, S as Semaphores } from "./config.js";
643
+ import { z } from "zod";
644
+ import { redirect } from "@sveltejs/kit";
645
+ import { collections } from "./database.js";
646
+ import JSON5 from "json5";
647
+ import { l as logger } from "./logger.js";
648
+ import { ObjectId } from "mongodb";
649
+ import { a as adminTokenManager } from "./adminToken.js";
650
+ import { b as base } from "./server.js";
651
+ import "./url.js";
652
+ import "@sveltejs/kit/internal/server";
653
+ import "./root.js";
654
+ import { a as acquireLock, r as releaseLock, i as isDBLocked } from "./lock.js";
655
+ async function sha256(input) {
656
+ const utf8 = new TextEncoder().encode(input);
657
+ const hashBuffer = await crypto.subtle.digest("SHA-256", utf8);
658
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
659
+ const hashHex = hashArray.map((bytes) => bytes.toString(16).padStart(2, "0")).join("");
660
+ return hashHex;
661
+ }
662
+ const stringWithDefault = (value) => z.string().default(value).transform((el) => el ? el : value);
663
+ const OIDConfig = z.object({
664
+ CLIENT_ID: stringWithDefault(config.OPENID_CLIENT_ID),
665
+ CLIENT_SECRET: stringWithDefault(config.OPENID_CLIENT_SECRET),
666
+ PROVIDER_URL: stringWithDefault(config.OPENID_PROVIDER_URL),
667
+ SCOPES: stringWithDefault(config.OPENID_SCOPES),
668
+ NAME_CLAIM: stringWithDefault(config.OPENID_NAME_CLAIM).refine(
669
+ (el) => !["preferred_username", "email", "picture", "sub"].includes(el),
670
+ { message: "nameClaim cannot be one of the restricted keys." }
671
+ ),
672
+ TOLERANCE: stringWithDefault(config.OPENID_TOLERANCE),
673
+ RESOURCE: stringWithDefault(config.OPENID_RESOURCE),
674
+ ID_TOKEN_SIGNED_RESPONSE_ALG: z.string().optional()
675
+ }).parse(JSON5.parse(config.OPENID_CONFIG || "{}"));
676
+ const loginEnabled = !!OIDConfig.CLIENT_ID;
677
+ const sameSite = z.enum(["lax", "none", "strict"]).default(config.ALLOW_INSECURE_COOKIES === "true" ? "lax" : "none").parse(config.COOKIE_SAMESITE === "" ? void 0 : config.COOKIE_SAMESITE);
678
+ const secure = z.boolean().default(!(config.ALLOW_INSECURE_COOKIES === "true")).parse(config.COOKIE_SECURE === "" ? void 0 : config.COOKIE_SECURE === "true");
679
+ function sanitizeReturnPath(path) {
680
+ if (!path) {
681
+ return void 0;
682
+ }
683
+ if (path.startsWith("//")) {
684
+ return void 0;
685
+ }
686
+ if (!path.startsWith("/")) {
687
+ return void 0;
688
+ }
689
+ return path;
690
+ }
691
+ function refreshSessionCookie(cookies, sessionId) {
692
+ cookies.set(config.COOKIE_NAME, sessionId, {
693
+ path: "/",
694
+ // So that it works inside the space's iframe
695
+ sameSite,
696
+ secure,
697
+ httpOnly: true,
698
+ expires: addWeeks(/* @__PURE__ */ new Date(), 2)
699
+ });
700
+ }
701
+ async function findUser(sessionId, coupledCookieHash, url) {
702
+ const session = await collections.sessions.findOne({ sessionId });
703
+ if (!session) {
704
+ return { user: null, invalidateSession: false };
705
+ }
706
+ if (coupledCookieHash && session.coupledCookieHash !== coupledCookieHash) {
707
+ return { user: null, invalidateSession: true };
708
+ }
709
+ if (session.oauth?.token && session.oauth.refreshToken) {
710
+ if (differenceInMinutes(session.oauth.token.expiresAt, /* @__PURE__ */ new Date()) < 5) {
711
+ const lockKey = `${Semaphores.OAUTH_TOKEN_REFRESH}:${sessionId}`;
712
+ const lockId = await acquireLock(lockKey);
713
+ if (lockId) {
714
+ try {
715
+ const newTokenSet = await refreshOAuthToken(
716
+ { redirectURI: `${config.PUBLIC_ORIGIN}${base}/login/callback` },
717
+ session.oauth.refreshToken,
718
+ url
719
+ );
720
+ if (!newTokenSet || !newTokenSet.access_token) {
721
+ return { user: null, invalidateSession: true };
722
+ }
723
+ const updatedOAuth = tokenSetToSessionOauth(newTokenSet);
724
+ if (!updatedOAuth) {
725
+ return { user: null, invalidateSession: true };
726
+ }
727
+ await collections.sessions.updateOne(
728
+ { sessionId },
729
+ {
730
+ $set: {
731
+ oauth: updatedOAuth,
732
+ updatedAt: /* @__PURE__ */ new Date()
733
+ }
734
+ }
735
+ );
736
+ session.oauth = updatedOAuth;
737
+ } catch (err) {
738
+ logger.error(err, "Error during token refresh:");
739
+ return { user: null, invalidateSession: true };
740
+ } finally {
741
+ await releaseLock(lockKey, lockId);
742
+ }
743
+ } else if (/* @__PURE__ */ new Date() > session.oauth.token.expiresAt) {
744
+ let attempts = 0;
745
+ do {
746
+ await new Promise((resolve) => setTimeout(resolve, 200));
747
+ attempts++;
748
+ if (attempts > 20) {
749
+ return { user: null, invalidateSession: true };
750
+ }
751
+ } while (await isDBLocked(lockKey));
752
+ const updatedSession = await collections.sessions.findOne({ sessionId });
753
+ if (!updatedSession || updatedSession.oauth?.token === session.oauth.token) {
754
+ return { user: null, invalidateSession: true };
755
+ }
756
+ session.oauth = updatedSession.oauth;
757
+ }
758
+ }
759
+ }
760
+ return {
761
+ user: await collectio
762
+
763
+ --- .svelte-kit/adapter-node/chunks/buildSubtree.js ---
764
+ function isMessageId(id) {
765
+ return id.split("-").length === 5;
766
+ }
767
+ function buildSubtree(conv, id) {
768
+ if (!conv.rootMessageId) {
769
+ if (conv.messages.length === 0) return [];
770
+ const index = conv.messages.findIndex((m) => m.id === id);
771
+ if (index === -1) throw new Error("Message not found");
772
+ return conv.messages.slice(0, index + 1);
773
+ } else {
774
+ const message = conv.messages.find((m) => m.id === id);
775
+ if (!message) throw new Error("Message not found");
776
+ return [
777
+ ...message.ancestors?.map((ancestorId) => {
778
+ const ancestor = conv.messages.find((m) => m.id === ancestorId);
779
+ if (!ancestor) throw new Error("Ancestor not found");
780
+ return ancestor;
781
+ }) ?? [],
782
+ message
783
+ ];
784
+ }
785
+ }
786
+ export {
787
+ buildSubtree as b,
788
+ isMessageId as i
789
+ };
790
+
791
+
792
+ --- .svelte-kit/adapter-node/chunks/chevron-down.js (truncated) ---
793
+ import { I as ATTACHMENT_KEY, l as derived, J as hasContext, E as getContext, z as setContext, K as run, L as getAllContexts, M as on, G as spread_props, f as sanitize_props, g as attributes, i as attr_class, e as escape_html, j as stringify, p as clsx$1 } from "./root.js";
794
+ import { t as tick, m as mount, u as unmount, o as onDestroy } from "./index-server.js";
795
+ import { clsx } from "clsx";
796
+ import { computePosition, offset, shift, flip, size, arrow, hide, limitShift } from "@floating-ui/dom";
797
+ import parse from "style-to-object";
798
+ import { isTabbable, tabbable, isFocusable, focusable } from "tabbable";
799
+ import { h as html } from "./html.js";
800
+ function createAttachmentKey() {
801
+ return Symbol(ATTACHMENT_KEY);
802
+ }
803
+ const SvelteMap = globalThis.Map;
804
+ function createSubscriber(_) {
805
+ return () => {
806
+ };
807
+ }
808
+ function isFunction$1(value) {
809
+ return typeof value === "function";
810
+ }
811
+ function isObject(value) {
812
+ return value !== null && typeof value === "object";
813
+ }
814
+ const CLASS_VALUE_PRIMITIVE_TYPES = ["string", "number", "bigint", "boolean"];
815
+ function isClassValue(value) {
816
+ if (value === null || value === void 0)
817
+ return true;
818
+ if (CLASS_VALUE_PRIMITIVE_TYPES.includes(typeof value))
819
+ return true;
820
+ if (Array.isArray(value))
821
+ return value.every((item) => isClassValue(item));
822
+ if (typeof value === "object") {
823
+ if (Object.getPrototypeOf(value) !== Object.prototype)
824
+ return false;
825
+ return true;
826
+ }
827
+ return false;
828
+ }
829
+ const BoxSymbol = Symbol("box");
830
+ const isWritableSymbol = Symbol("is-writable");
831
+ function boxWith(getter, setter) {
832
+ const derived$1 = derived(getter);
833
+ if (setter) {
834
+ return {
835
+ [BoxSymbol]: true,
836
+ [isWritableSymbol]: true,
837
+ get current() {
838
+ return derived$1();
839
+ },
840
+ set current(v) {
841
+ setter(v);
842
+ }
843
+ };
844
+ }
845
+ return {
846
+ [BoxSymbol]: true,
847
+ get current() {
848
+ return getter();
849
+ }
850
+ };
851
+ }
852
+ function isBox(value) {
853
+ return isObject(value) && BoxSymbol in value;
854
+ }
855
+ function isWritableBox(value) {
856
+ return isBox(value) && isWritableSymbol in value;
857
+ }
858
+ function boxFrom(value) {
859
+ if (isBox(value)) return value;
860
+ if (isFunction$1(value)) return boxWith(value);
861
+ return simpleBox(value);
862
+ }
863
+ function boxFlatten(boxes) {
864
+ return Object.entries(boxes).reduce(
865
+ (acc, [key, b]) => {
866
+ if (!isBox(b)) {
867
+ return Object.assign(acc, { [key]: b });
868
+ }
869
+ if (isWritableBox(b)) {
870
+ Object.defineProperty(acc, key, {
871
+ get() {
872
+ return b.current;
873
+ },
874
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
875
+ set(v) {
876
+ b.current = v;
877
+ }
878
+ });
879
+ } else {
880
+ Object.defineProperty(acc, key, {
881
+ get() {
882
+ return b.current;
883
+ }
884
+ });
885
+ }
886
+ return acc;
887
+ },
888
+ {}
889
+ );
890
+ }
891
+ function toReadonlyBox(b) {
892
+ if (!isWritableBox(b)) return b;
893
+ return {
894
+ [BoxSymbol]: true,
895
+ get current() {
896
+ return b.current;
897
+ }
898
+ };
899
+ }
900
+ function simpleBox(initialValue) {
901
+ let current = initialValue;
902
+ return {
903
+ [BoxSymbol]: true,
904
+ [isWritableSymbol]: true,
905
+ get current() {
906
+ return current;
907
+ },
908
+ set current(v) {
909
+ current = v;
910
+ }
911
+ };
912
+ }
913
+ function box(initialValue) {
914
+ let current = initialValue;
915
+ return {
916
+ [BoxSymbol]: true,
917
+ [isWritableSymbol]: true,
918
+ get current() {
919
+ return current;
920
+ },
921
+ set current(v) {
922
+ current = v;
923
+ }
924
+ };
925
+ }
926
+ box.from = boxFrom;
927
+ box.with = boxWith;
928
+ box.flatten = boxFlatten;
929
+ box.readonly = toReadonlyBox;
930
+ box.isBox = isBox;
931
+ box.isWritableBox = isWritableBox;
932
+ function composeHandlers(...handlers) {
933
+ return function(e) {
934
+ for (const handler of handlers) {
935
+ if (!handler)
936
+ continue;
937
+ if (e.defaultPrevented)
938
+ return;
939
+ if (typeof handler === "function") {
940
+ handler.call(this, e);
941
+ } else {
942
+ handler.current?.call(this, e);
943
+ }
944
+ }
945
+ };
946
+ }
947
+ const NUMBER_CHAR_RE = /\d/;
948
+ const STR_SPLITTERS = ["-", "_", "/", "."];
949
+ function isUppercase(char = "") {
950
+ if (NUMBER_CHAR_RE.test(char))
951
+ return void 0;
952
+ return char !== char.toLowerCase();
953
+ }
954
+ function splitByCase(str) {
955
+ const parts = [];
956
+ let buff = "";
957
+ let previousUpper;
958
+ let previousSplitter;
959
+ for (const char of str) {
960
+ const isSplitter = STR_SPLITTERS.includes(char);
961
+ if (isSplitter === true) {
962
+ parts.push(buff);
963
+ buff = "";
964
+ previousUpper = void 0;
965
+ continue;
966
+ }
967
+ const isUpper = isUppercase(char);
968
+ if (previousSplitter === false) {
969
+ if (previousUpper === false && isUpper === true) {
970
+ parts.push(buff);
971
+ buff = char;
972
+ previousUpper = isUpper;
973
+ continue;
974
+ }
975
+ if (previousUpper === true && isUpper === false && buff.length > 1) {
976
+ const lastChar = buff.at(-1);
977
+ parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
978
+ buff = lastChar + char;
979
+ previousUpper = isUpper;
980
+ continue;
981
+ }
982
+ }
983
+ buff += char;
984
+ previousUpper = isUpper;
985
+ previousSplitte
986
+
987
+ ## Instructions
988
+
989
+ Analyze the above codebase context and provide your response following the format specified in the task.