@whykusanagi/corrupted-theme 0.1.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.
- package/CHANGELOG.md +339 -0
- package/Dockerfile +32 -0
- package/LICENSE +21 -0
- package/README.md +399 -0
- package/docker-entrypoint.sh +48 -0
- package/docs/COMPONENTS_REFERENCE.md +659 -0
- package/examples/.env.example +100 -0
- package/examples/button.html +436 -0
- package/examples/card.html +678 -0
- package/examples/form.html +555 -0
- package/examples/index.html +520 -0
- package/examples/layout.html +507 -0
- package/examples/nikke-team-builder.html +580 -0
- package/examples/showcase-complete.html +1071 -0
- package/examples/showcase.html +502 -0
- package/package.json +70 -0
- package/scripts/celeste-proxy-server.js +99 -0
- package/scripts/static-server.js +113 -0
- package/src/css/animations.css +649 -0
- package/src/css/components.css +1441 -0
- package/src/css/glassmorphism.css +217 -0
- package/src/css/nikke-utilities.css +530 -0
- package/src/css/theme.css +478 -0
- package/src/css/typography.css +198 -0
- package/src/css/utilities.css +239 -0
- package/src/css/variables.css +73 -0
- package/src/lib/celeste-proxy.js +215 -0
- package/src/lib/celeste-widget.js +1089 -0
- package/src/lib/corrupted-text.js +193 -0
- package/src/lib/corruption-loading.js +405 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/* utilities.css — Utility classes for spacing, sizing, opacity, etc */
|
|
2
|
+
|
|
3
|
+
/* ========== SPACING UTILITIES ========== */
|
|
4
|
+
|
|
5
|
+
.m-0 { margin: 0; }
|
|
6
|
+
.m-xs { margin: var(--spacing-xs); }
|
|
7
|
+
.m-sm { margin: var(--spacing-sm); }
|
|
8
|
+
.m-md { margin: var(--spacing-md); }
|
|
9
|
+
.m-lg { margin: var(--spacing-lg); }
|
|
10
|
+
.m-xl { margin: var(--spacing-xl); }
|
|
11
|
+
.m-2xl { margin: var(--spacing-2xl); }
|
|
12
|
+
|
|
13
|
+
.mx-auto { margin-left: auto; margin-right: auto; }
|
|
14
|
+
.my-auto { margin-top: auto; margin-bottom: auto; }
|
|
15
|
+
|
|
16
|
+
.mt-0 { margin-top: 0; }
|
|
17
|
+
.mt-xs { margin-top: var(--spacing-xs); }
|
|
18
|
+
.mt-sm { margin-top: var(--spacing-sm); }
|
|
19
|
+
.mt-md { margin-top: var(--spacing-md); }
|
|
20
|
+
.mt-lg { margin-top: var(--spacing-lg); }
|
|
21
|
+
.mt-xl { margin-top: var(--spacing-xl); }
|
|
22
|
+
.mt-2xl { margin-top: var(--spacing-2xl); }
|
|
23
|
+
|
|
24
|
+
.mb-0 { margin-bottom: 0; }
|
|
25
|
+
.mb-xs { margin-bottom: var(--spacing-xs); }
|
|
26
|
+
.mb-sm { margin-bottom: var(--spacing-sm); }
|
|
27
|
+
.mb-md { margin-bottom: var(--spacing-md); }
|
|
28
|
+
.mb-lg { margin-bottom: var(--spacing-lg); }
|
|
29
|
+
.mb-xl { margin-bottom: var(--spacing-xl); }
|
|
30
|
+
.mb-2xl { margin-bottom: var(--spacing-2xl); }
|
|
31
|
+
|
|
32
|
+
.p-0 { padding: 0; }
|
|
33
|
+
.p-xs { padding: var(--spacing-xs); }
|
|
34
|
+
.p-sm { padding: var(--spacing-sm); }
|
|
35
|
+
.p-md { padding: var(--spacing-md); }
|
|
36
|
+
.p-lg { padding: var(--spacing-lg); }
|
|
37
|
+
.p-xl { padding: var(--spacing-xl); }
|
|
38
|
+
.p-2xl { padding: var(--spacing-2xl); }
|
|
39
|
+
|
|
40
|
+
.pt-md { padding-top: var(--spacing-md); }
|
|
41
|
+
.pb-md { padding-bottom: var(--spacing-md); }
|
|
42
|
+
.px-md { padding-left: var(--spacing-md); padding-right: var(--spacing-md); }
|
|
43
|
+
.py-md { padding-top: var(--spacing-md); padding-bottom: var(--spacing-md); }
|
|
44
|
+
|
|
45
|
+
/* ========== DISPLAY UTILITIES ========== */
|
|
46
|
+
|
|
47
|
+
.block { display: block; }
|
|
48
|
+
.inline { display: inline; }
|
|
49
|
+
.inline-block { display: inline-block; }
|
|
50
|
+
.flex { display: flex; }
|
|
51
|
+
.grid { display: grid; }
|
|
52
|
+
.hidden { display: none; }
|
|
53
|
+
.visible { visibility: visible; }
|
|
54
|
+
|
|
55
|
+
.flex-center {
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.flex-between {
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: space-between;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.flex-col {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.items-center { align-items: center; }
|
|
73
|
+
.justify-center { justify-content: center; }
|
|
74
|
+
.justify-between { justify-content: space-between; }
|
|
75
|
+
.justify-end { justify-content: flex-end; }
|
|
76
|
+
|
|
77
|
+
.gap-sm { gap: var(--spacing-sm); }
|
|
78
|
+
.gap-md { gap: var(--spacing-md); }
|
|
79
|
+
.gap-lg { gap: var(--spacing-lg); }
|
|
80
|
+
|
|
81
|
+
/* ========== OPACITY UTILITIES ========== */
|
|
82
|
+
|
|
83
|
+
.opacity-0 { opacity: 0; }
|
|
84
|
+
.opacity-25 { opacity: 0.25; }
|
|
85
|
+
.opacity-50 { opacity: 0.5; }
|
|
86
|
+
.opacity-75 { opacity: 0.75; }
|
|
87
|
+
.opacity-100 { opacity: 1; }
|
|
88
|
+
|
|
89
|
+
/* ========== TEXT UTILITIES ========== */
|
|
90
|
+
|
|
91
|
+
.text-left { text-align: left; }
|
|
92
|
+
.text-center { text-align: center; }
|
|
93
|
+
.text-right { text-align: right; }
|
|
94
|
+
|
|
95
|
+
.font-sm { font-size: 0.875rem; }
|
|
96
|
+
.font-base { font-size: 1rem; }
|
|
97
|
+
.font-lg { font-size: 1.125rem; }
|
|
98
|
+
.font-xl { font-size: 1.25rem; }
|
|
99
|
+
|
|
100
|
+
.font-normal { font-weight: 400; }
|
|
101
|
+
.font-semi { font-weight: 600; }
|
|
102
|
+
.font-bold { font-weight: 700; }
|
|
103
|
+
|
|
104
|
+
.text-primary { color: var(--text); }
|
|
105
|
+
.text-secondary { color: var(--text-secondary); }
|
|
106
|
+
.text-muted { color: var(--text-muted); }
|
|
107
|
+
.text-accent { color: var(--accent); }
|
|
108
|
+
|
|
109
|
+
.uppercase { text-transform: uppercase; }
|
|
110
|
+
.lowercase { text-transform: lowercase; }
|
|
111
|
+
.capitalize { text-transform: capitalize; }
|
|
112
|
+
|
|
113
|
+
.underline { text-decoration: underline; }
|
|
114
|
+
.no-underline { text-decoration: none; }
|
|
115
|
+
|
|
116
|
+
.line-clamp-1 {
|
|
117
|
+
overflow: hidden;
|
|
118
|
+
text-overflow: ellipsis;
|
|
119
|
+
white-space: nowrap;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.line-clamp-2 {
|
|
123
|
+
display: -webkit-box;
|
|
124
|
+
-webkit-line-clamp: 2;
|
|
125
|
+
-webkit-box-orient: vertical;
|
|
126
|
+
overflow: hidden;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.line-clamp-3 {
|
|
130
|
+
display: -webkit-box;
|
|
131
|
+
-webkit-line-clamp: 3;
|
|
132
|
+
-webkit-box-orient: vertical;
|
|
133
|
+
overflow: hidden;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* ========== WIDTH & HEIGHT UTILITIES ========== */
|
|
137
|
+
|
|
138
|
+
.w-full { width: 100%; }
|
|
139
|
+
.h-full { height: 100%; }
|
|
140
|
+
.w-auto { width: auto; }
|
|
141
|
+
.h-auto { height: auto; }
|
|
142
|
+
|
|
143
|
+
.min-h-screen { min-height: 100vh; }
|
|
144
|
+
.max-w-xs { max-width: 20rem; }
|
|
145
|
+
.max-w-sm { max-width: 24rem; }
|
|
146
|
+
.max-w-md { max-width: 28rem; }
|
|
147
|
+
.max-w-lg { max-width: 32rem; }
|
|
148
|
+
.max-w-xl { max-width: 36rem; }
|
|
149
|
+
.max-w-2xl { max-width: 42rem; }
|
|
150
|
+
.max-w-4xl { max-width: 56rem; }
|
|
151
|
+
.max-w-6xl { max-width: 72rem; }
|
|
152
|
+
|
|
153
|
+
.container-sm { max-width: 640px; margin: 0 auto; }
|
|
154
|
+
.container-md { max-width: 768px; margin: 0 auto; }
|
|
155
|
+
.container-lg { max-width: 1024px; margin: 0 auto; }
|
|
156
|
+
.container-xl { max-width: 1280px; margin: 0 auto; }
|
|
157
|
+
|
|
158
|
+
/* ========== POSITION UTILITIES ========== */
|
|
159
|
+
|
|
160
|
+
.relative { position: relative; }
|
|
161
|
+
.absolute { position: absolute; }
|
|
162
|
+
.fixed { position: fixed; }
|
|
163
|
+
.sticky { position: sticky; }
|
|
164
|
+
|
|
165
|
+
.top-0 { top: 0; }
|
|
166
|
+
.bottom-0 { bottom: 0; }
|
|
167
|
+
.left-0 { left: 0; }
|
|
168
|
+
.right-0 { right: 0; }
|
|
169
|
+
|
|
170
|
+
.inset-0 { inset: 0; }
|
|
171
|
+
|
|
172
|
+
.z-0 { z-index: var(--z-base); }
|
|
173
|
+
.z-10 { z-index: 10; }
|
|
174
|
+
.z-50 { z-index: 50; }
|
|
175
|
+
.z-navbar { z-index: var(--z-navbar); }
|
|
176
|
+
.z-modal { z-index: var(--z-modal); }
|
|
177
|
+
|
|
178
|
+
/* ========== BORDER RADIUS UTILITIES ========== */
|
|
179
|
+
|
|
180
|
+
.rounded-none { border-radius: 0; }
|
|
181
|
+
.rounded-sm { border-radius: var(--radius-sm); }
|
|
182
|
+
.rounded-md { border-radius: var(--radius-md); }
|
|
183
|
+
.rounded-lg { border-radius: var(--radius-lg); }
|
|
184
|
+
.rounded-xl { border-radius: var(--radius-xl); }
|
|
185
|
+
.rounded-2xl { border-radius: var(--radius-2xl); }
|
|
186
|
+
.rounded-full { border-radius: 9999px; }
|
|
187
|
+
|
|
188
|
+
/* ========== BACKGROUND UTILITIES ========== */
|
|
189
|
+
|
|
190
|
+
.bg-primary { background-color: var(--bg); }
|
|
191
|
+
.bg-secondary { background-color: var(--bg-secondary); }
|
|
192
|
+
.bg-glass { background-color: var(--glass); }
|
|
193
|
+
.bg-glass-light { background-color: var(--glass-light); }
|
|
194
|
+
.bg-accent-light {
|
|
195
|
+
background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/* ========== BORDER UTILITIES ========== */
|
|
199
|
+
|
|
200
|
+
.border { border: 1px solid var(--border); }
|
|
201
|
+
.border-t { border-top: 1px solid var(--border); }
|
|
202
|
+
.border-b { border-bottom: 1px solid var(--border); }
|
|
203
|
+
.border-l { border-left: 1px solid var(--border); }
|
|
204
|
+
.border-r { border-right: 1px solid var(--border); }
|
|
205
|
+
|
|
206
|
+
.border-accent { border-color: var(--accent); }
|
|
207
|
+
.border-light { border-color: var(--border-light); }
|
|
208
|
+
|
|
209
|
+
/* ========== OVERFLOW UTILITIES ========== */
|
|
210
|
+
|
|
211
|
+
.overflow-hidden { overflow: hidden; }
|
|
212
|
+
.overflow-auto { overflow: auto; }
|
|
213
|
+
.overflow-x-auto { overflow-x: auto; }
|
|
214
|
+
.overflow-y-auto { overflow-y: auto; }
|
|
215
|
+
|
|
216
|
+
/* ========== OBJECT-FIT UTILITIES ========== */
|
|
217
|
+
|
|
218
|
+
.object-cover { object-fit: cover; }
|
|
219
|
+
.object-contain { object-fit: contain; }
|
|
220
|
+
|
|
221
|
+
/* ========== RESPONSIVENESS ========== */
|
|
222
|
+
|
|
223
|
+
@media screen and (max-width: 768px) {
|
|
224
|
+
/* Stack flexbox on mobile */
|
|
225
|
+
.flex-responsive {
|
|
226
|
+
flex-direction: column;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/* Adjust padding on smaller screens */
|
|
230
|
+
.p-md { padding: var(--spacing-sm); }
|
|
231
|
+
.px-md { padding-left: var(--spacing-sm); padding-right: var(--spacing-sm); }
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* ========== PRINT UTILITIES ========== */
|
|
235
|
+
|
|
236
|
+
@media print {
|
|
237
|
+
.hidden-print { display: none !important; }
|
|
238
|
+
.visible-print { display: block !important; }
|
|
239
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/* variables.css — Core CSS Variables for Corrupted Theme */
|
|
2
|
+
/* These are the foundation colors and design tokens */
|
|
3
|
+
|
|
4
|
+
:root {
|
|
5
|
+
/* ========== PRIMARY COLORS ========== */
|
|
6
|
+
--accent: #d94f90; /* Main pink accent */
|
|
7
|
+
--accent-light: #e86ca8; /* Lighter pink for hover states */
|
|
8
|
+
--accent-dark: #b61b70; /* Darker pink for depth */
|
|
9
|
+
|
|
10
|
+
/* ========== BACKGROUNDS ========== */
|
|
11
|
+
--bg: #0a0a0a; /* Pure black base */
|
|
12
|
+
--bg-secondary: #0f0f1a; /* Deep purple-black */
|
|
13
|
+
--overlay: rgba(0, 0, 0, 0.85); /* Dark overlay */
|
|
14
|
+
|
|
15
|
+
/* ========== GLASS MORPHISM EFFECTS ========== */
|
|
16
|
+
--glass: rgba(20, 12, 40, 0.7); /* Frosted glass (dark) */
|
|
17
|
+
--glass-light: rgba(28, 18, 48, 0.5); /* Frosted glass (light) */
|
|
18
|
+
--glass-darker: rgba(10, 5, 20, 0.6); /* Darker glass for code blocks */
|
|
19
|
+
|
|
20
|
+
/* ========== BORDERS & DIVIDERS ========== */
|
|
21
|
+
--border: #3a2555; /* Primary border color */
|
|
22
|
+
--border-light: #5a4575; /* Lighter border for emphasis */
|
|
23
|
+
|
|
24
|
+
/* ========== TEXT COLORS ========== */
|
|
25
|
+
--text: #f5f1f8; /* Primary text */
|
|
26
|
+
--text-secondary: #b8afc8; /* Secondary text */
|
|
27
|
+
--text-muted: #7a7085; /* Muted/disabled text */
|
|
28
|
+
|
|
29
|
+
/* ========== GRADIENTS ========== */
|
|
30
|
+
--gradient-accent: linear-gradient(135deg, #d94f90 0%, #b61b70 100%);
|
|
31
|
+
--gradient-purple: linear-gradient(135deg, #8b5cf6 0%, #d94f90 100%);
|
|
32
|
+
|
|
33
|
+
/* ========== SPACING SCALE ========== */
|
|
34
|
+
--spacing-xs: 0.25rem; /* 4px */
|
|
35
|
+
--spacing-sm: 0.5rem; /* 8px */
|
|
36
|
+
--spacing-md: 1rem; /* 16px */
|
|
37
|
+
--spacing-lg: 1.5rem; /* 24px */
|
|
38
|
+
--spacing-xl: 2rem; /* 32px */
|
|
39
|
+
--spacing-2xl: 3rem; /* 48px */
|
|
40
|
+
|
|
41
|
+
/* ========== BORDER RADIUS ========== */
|
|
42
|
+
--radius-sm: 4px;
|
|
43
|
+
--radius-md: 8px;
|
|
44
|
+
--radius-lg: 12px;
|
|
45
|
+
--radius-xl: 16px;
|
|
46
|
+
--radius-2xl: 20px;
|
|
47
|
+
|
|
48
|
+
/* ========== TRANSITIONS ========== */
|
|
49
|
+
--transition: 0.3s ease; /* Standard transition (alias for transition-normal) */
|
|
50
|
+
--transition-fast: 0.15s ease; /* Fast transition for interactive elements */
|
|
51
|
+
--transition-normal: 0.3s ease; /* Normal transition */
|
|
52
|
+
--transition-slow: 0.5s ease; /* Slow transition */
|
|
53
|
+
--transition-easing: cubic-bezier(0.34, 1.56, 0.64, 1); /* Custom easing */
|
|
54
|
+
|
|
55
|
+
/* ========== Z-INDEX SCALE ========== */
|
|
56
|
+
--z-negative: -2;
|
|
57
|
+
--z-background: -1;
|
|
58
|
+
--z-base: 0;
|
|
59
|
+
--z-elevated: 1;
|
|
60
|
+
--z-navbar: 500;
|
|
61
|
+
--z-modal: 1000;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Reset defaults for consistency */
|
|
65
|
+
* {
|
|
66
|
+
box-sizing: border-box;
|
|
67
|
+
margin: 0;
|
|
68
|
+
padding: 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
html {
|
|
72
|
+
scroll-behavior: smooth;
|
|
73
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Celeste API Proxy - Shared logic for local dev and Cloudflare Workers
|
|
3
|
+
* Handles secure proxying of Celeste API requests
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Build messages array from request data
|
|
8
|
+
*/
|
|
9
|
+
function buildMessages(requestData) {
|
|
10
|
+
const messages = [];
|
|
11
|
+
const { message, system_prompt, history } = requestData;
|
|
12
|
+
|
|
13
|
+
// Add system prompt if provided
|
|
14
|
+
if (system_prompt) {
|
|
15
|
+
messages.push({
|
|
16
|
+
role: 'system',
|
|
17
|
+
content: system_prompt
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Add conversation history
|
|
22
|
+
if (Array.isArray(history)) {
|
|
23
|
+
for (const histMsg of history) {
|
|
24
|
+
if (histMsg.sender === 'user') {
|
|
25
|
+
messages.push({
|
|
26
|
+
role: 'user',
|
|
27
|
+
content: histMsg.text || ''
|
|
28
|
+
});
|
|
29
|
+
} else if (histMsg.sender === 'celeste') {
|
|
30
|
+
messages.push({
|
|
31
|
+
role: 'assistant',
|
|
32
|
+
content: histMsg.text || ''
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Add current message
|
|
39
|
+
if (message) {
|
|
40
|
+
messages.push({
|
|
41
|
+
role: 'user',
|
|
42
|
+
content: message.trim()
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return messages;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Handle proxy request - works in both Node.js and Cloudflare Workers
|
|
51
|
+
*/
|
|
52
|
+
export async function handleProxyRequest(request, env) {
|
|
53
|
+
try {
|
|
54
|
+
// Validate required environment variables
|
|
55
|
+
const agentKey = env.CELESTE_AGENT_KEY || env.CELESTE_API_KEY;
|
|
56
|
+
const agentId = env.CELESTE_AGENT_ID;
|
|
57
|
+
const agentBaseUrl = env.CELESTE_AGENT_BASE_URL;
|
|
58
|
+
|
|
59
|
+
if (!agentKey || !agentId || !agentBaseUrl) {
|
|
60
|
+
return new Response(
|
|
61
|
+
JSON.stringify({ error: 'Proxy configuration missing' }),
|
|
62
|
+
{
|
|
63
|
+
status: 500,
|
|
64
|
+
headers: {
|
|
65
|
+
'Content-Type': 'application/json',
|
|
66
|
+
'Access-Control-Allow-Origin': '*'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Handle CORS preflight
|
|
73
|
+
if (request.method === 'OPTIONS') {
|
|
74
|
+
return new Response(null, {
|
|
75
|
+
status: 204,
|
|
76
|
+
headers: {
|
|
77
|
+
'Access-Control-Allow-Origin': '*',
|
|
78
|
+
'Access-Control-Allow-Methods': 'POST, OPTIONS',
|
|
79
|
+
'Access-Control-Allow-Headers': 'Content-Type'
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Only allow POST
|
|
85
|
+
if (request.method !== 'POST') {
|
|
86
|
+
return new Response(
|
|
87
|
+
JSON.stringify({ error: 'Method not allowed' }),
|
|
88
|
+
{
|
|
89
|
+
status: 405,
|
|
90
|
+
headers: {
|
|
91
|
+
'Content-Type': 'application/json',
|
|
92
|
+
'Access-Control-Allow-Origin': '*'
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Parse request body
|
|
99
|
+
let requestData;
|
|
100
|
+
try {
|
|
101
|
+
requestData = await request.json();
|
|
102
|
+
} catch (e) {
|
|
103
|
+
return new Response(
|
|
104
|
+
JSON.stringify({ error: 'Invalid JSON in request body' }),
|
|
105
|
+
{
|
|
106
|
+
status: 400,
|
|
107
|
+
headers: {
|
|
108
|
+
'Content-Type': 'application/json',
|
|
109
|
+
'Access-Control-Allow-Origin': '*'
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Validate message
|
|
116
|
+
if (!requestData.message || !requestData.message.trim()) {
|
|
117
|
+
return new Response(
|
|
118
|
+
JSON.stringify({ error: 'Message required' }),
|
|
119
|
+
{
|
|
120
|
+
status: 400,
|
|
121
|
+
headers: {
|
|
122
|
+
'Content-Type': 'application/json',
|
|
123
|
+
'Access-Control-Allow-Origin': '*'
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Build messages array
|
|
130
|
+
const messages = buildMessages(requestData);
|
|
131
|
+
|
|
132
|
+
// Call Celeste API
|
|
133
|
+
const celesteUrl = `${agentBaseUrl}/api/v1/chat/completions`;
|
|
134
|
+
const celesteResponse = await fetch(celesteUrl, {
|
|
135
|
+
method: 'POST',
|
|
136
|
+
headers: {
|
|
137
|
+
'Content-Type': 'application/json',
|
|
138
|
+
'Authorization': `Bearer ${agentKey}`
|
|
139
|
+
},
|
|
140
|
+
body: JSON.stringify({
|
|
141
|
+
model: 'gpt-4o-mini',
|
|
142
|
+
messages: messages,
|
|
143
|
+
max_tokens: 400,
|
|
144
|
+
temperature: 0.7,
|
|
145
|
+
stream: false
|
|
146
|
+
})
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// Handle Celeste API errors
|
|
150
|
+
if (celesteResponse.status === 401) {
|
|
151
|
+
return new Response(
|
|
152
|
+
JSON.stringify({ error: 'Authentication failed - invalid API key' }),
|
|
153
|
+
{
|
|
154
|
+
status: 401,
|
|
155
|
+
headers: {
|
|
156
|
+
'Content-Type': 'application/json',
|
|
157
|
+
'Access-Control-Allow-Origin': '*'
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (celesteResponse.status === 503) {
|
|
164
|
+
return new Response(
|
|
165
|
+
JSON.stringify({ error: 'Celeste service is currently unavailable' }),
|
|
166
|
+
{
|
|
167
|
+
status: 503,
|
|
168
|
+
headers: {
|
|
169
|
+
'Content-Type': 'application/json',
|
|
170
|
+
'Access-Control-Allow-Origin': '*'
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (!celesteResponse.ok) {
|
|
177
|
+
return new Response(
|
|
178
|
+
JSON.stringify({ error: `API error: ${celesteResponse.status}` }),
|
|
179
|
+
{
|
|
180
|
+
status: celesteResponse.status,
|
|
181
|
+
headers: {
|
|
182
|
+
'Content-Type': 'application/json',
|
|
183
|
+
'Access-Control-Allow-Origin': '*'
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Return successful response
|
|
190
|
+
const celesteData = await celesteResponse.json();
|
|
191
|
+
return new Response(JSON.stringify(celesteData), {
|
|
192
|
+
status: 200,
|
|
193
|
+
headers: {
|
|
194
|
+
'Content-Type': 'application/json',
|
|
195
|
+
'Access-Control-Allow-Origin': '*',
|
|
196
|
+
'Access-Control-Allow-Methods': 'POST, OPTIONS',
|
|
197
|
+
'Access-Control-Allow-Headers': 'Content-Type'
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
} catch (error) {
|
|
202
|
+
console.error('Proxy error:', error);
|
|
203
|
+
return new Response(
|
|
204
|
+
JSON.stringify({ error: 'Internal server error' }),
|
|
205
|
+
{
|
|
206
|
+
status: 500,
|
|
207
|
+
headers: {
|
|
208
|
+
'Content-Type': 'application/json',
|
|
209
|
+
'Access-Control-Allow-Origin': '*'
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|