@causyne/agent 1.20.71 → 1.20.73
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/package.json +1 -1
- package/src/assets/logo.png +0 -0
- package/src/auth/openrouterAuth.js +129 -69
- package/src/auth/openrouterAuth.ts +130 -70
- package/src/commands.js +25 -2
- package/src/dynamicCatalogue.js +9 -35
- package/src/dynamicCatalogue.ts +8 -35
- package/src/tui/consoleGuard.js +33 -0
- package/src/tui/consoleGuard.ts +34 -0
- package/src/tui/modelPicker.js +67 -33
- package/src/tui/modelPicker.ts +74 -35
- package/src/tui/stage.js +6 -1
- package/src/tui/stageSurface.js +13 -10
package/package.json
CHANGED
package/src/assets/logo.png
CHANGED
|
Binary file
|
|
@@ -94,14 +94,22 @@ export async function exchangeCodeForApiKey(code, codeVerifier, fetchFn = fetch)
|
|
|
94
94
|
return apiKey;
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
|
-
* Retrieve the Causyne Agent emblem logo as
|
|
97
|
+
* Retrieve the Causyne Agent emblem logo encoded as Base64.
|
|
98
98
|
*/
|
|
99
99
|
export function getLogoBuffer() {
|
|
100
100
|
try {
|
|
101
101
|
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
const candidates = [
|
|
103
|
+
path.resolve(currentDir, '../assets/logo.png'),
|
|
104
|
+
path.resolve(currentDir, '../../assets/logo.png'),
|
|
105
|
+
path.resolve(currentDir, '../../../public/assets/logo-200.png'),
|
|
106
|
+
path.resolve(process.cwd(), 'src/assets/logo.png'),
|
|
107
|
+
path.resolve(process.cwd(), 'assets/logo.png')
|
|
108
|
+
];
|
|
109
|
+
for (const candidate of candidates) {
|
|
110
|
+
if (fs.existsSync(candidate)) {
|
|
111
|
+
return fs.readFileSync(candidate);
|
|
112
|
+
}
|
|
105
113
|
}
|
|
106
114
|
}
|
|
107
115
|
catch {
|
|
@@ -117,60 +125,69 @@ export function getLogoBase64() {
|
|
|
117
125
|
return buf ? buf.toString('base64') : '';
|
|
118
126
|
}
|
|
119
127
|
/**
|
|
120
|
-
* Render a professional branded HTML response page for OpenRouter OAuth callbacks
|
|
128
|
+
* Render a professional branded HTML response page for OpenRouter OAuth callbacks
|
|
129
|
+
* following the exact visual style and design language of causyne.com.
|
|
121
130
|
*/
|
|
122
131
|
export function renderAuthPage(options) {
|
|
123
132
|
const isSuccess = options.status === 'success';
|
|
124
133
|
const base64Logo = getLogoBase64();
|
|
125
134
|
const logoSrc = base64Logo ? `data:image/png;base64,${base64Logo}` : '/logo.png';
|
|
126
135
|
const badgeHtml = isSuccess
|
|
127
|
-
? '<div style="display:inline-flex;align-items:center;gap:
|
|
128
|
-
'background:rgba(
|
|
129
|
-
'padding:
|
|
136
|
+
? '<div style="display:inline-flex;align-items:center;gap:6px;' +
|
|
137
|
+
'background:rgba(157,240,40,0.12);border:1px solid rgba(157,240,40,0.35);color:#9df028;' +
|
|
138
|
+
'padding:5px 14px;border-radius:4px;font-size:12px;font-family:\'SF Mono\',Menlo,monospace;font-weight:600;margin-bottom:20px;">' +
|
|
130
139
|
'✓ Connected Successfully</div>'
|
|
131
|
-
: '<div style="display:inline-flex;align-items:center;gap:
|
|
132
|
-
'background:rgba(239,
|
|
133
|
-
'padding:
|
|
140
|
+
: '<div style="display:inline-flex;align-items:center;gap:6px;' +
|
|
141
|
+
'background:rgba(239,83,80,0.12);border:1px solid rgba(239,83,80,0.35);color:#ef5350;' +
|
|
142
|
+
'padding:5px 14px;border-radius:4px;font-size:12px;font-family:\'SF Mono\',Menlo,monospace;font-weight:600;margin-bottom:20px;">' +
|
|
134
143
|
'✕ Authorization Failed</div>';
|
|
135
144
|
const title = options.title || (isSuccess ? 'OpenRouter Account Authorized' : 'Authorization Error');
|
|
136
145
|
const defaultMsg = isSuccess
|
|
137
|
-
? 'Your OpenRouter account
|
|
146
|
+
? 'Your OpenRouter account is now authorized and connected to Causyne Agent. You can close this window and return to your terminal.'
|
|
138
147
|
: 'The authorization flow could not be completed.';
|
|
139
148
|
const message = options.message || defaultMsg;
|
|
140
149
|
const contentBox = isSuccess
|
|
141
|
-
? '<div style="background
|
|
142
|
-
'border-radius:
|
|
143
|
-
'font-size:
|
|
144
|
-
'<div style="display:flex;justify-content:space-between;margin-bottom:
|
|
145
|
-
'<span style="color:#
|
|
150
|
+
? '<div style="background:#191c19;border:1px solid rgba(255,255,255,0.07);' +
|
|
151
|
+
'border-radius:6px;padding:14px 18px;margin-bottom:24px;text-align:left;font-family:\'SF Mono\',Menlo,Monaco,Consolas,monospace;' +
|
|
152
|
+
'font-size:12px;line-height:1.7;color:#e4e8e0;">' +
|
|
153
|
+
'<div style="display:flex;justify-content:space-between;margin-bottom:6px;">' +
|
|
154
|
+
'<span style="color:#9da697;">Provider</span>' +
|
|
155
|
+
'<span style="color:#e4e8e0;font-weight:600;">OpenRouter</span>' +
|
|
156
|
+
'</div>' +
|
|
157
|
+
'<div style="display:flex;justify-content:space-between;margin-bottom:6px;">' +
|
|
158
|
+
'<span style="color:#9da697;">Active Model</span>' +
|
|
146
159
|
`<span style="color:#9df028;font-weight:600;">${options.model || OPENROUTER_FREE_MODEL}</span>` +
|
|
147
160
|
'</div>' +
|
|
148
161
|
'<div style="display:flex;justify-content:space-between;">' +
|
|
149
|
-
'<span style="color:#
|
|
150
|
-
'<span style="color:#
|
|
162
|
+
'<span style="color:#9da697;">Privacy Guard</span>' +
|
|
163
|
+
'<span style="color:#9da697;">provider.data_collection = "deny"</span>' +
|
|
151
164
|
'</div>' +
|
|
152
165
|
'</div>'
|
|
153
|
-
: '<div style="background
|
|
154
|
-
'border-radius:
|
|
155
|
-
`text-align:left;">${options.errorDetail || 'An unexpected error occurred during authorization.'}</div>` +
|
|
156
|
-
'<div style="background
|
|
157
|
-
'border-radius:
|
|
158
|
-
'<div style="color:#
|
|
159
|
-
'<ol style="color:#
|
|
160
|
-
'<li>Return to your terminal and select OpenRouter in the FREE tab
|
|
161
|
-
'<li>Or
|
|
162
|
-
'style="color:#
|
|
166
|
+
: '<div style="background:#191c19;border:1px solid rgba(239,83,80,0.25);' +
|
|
167
|
+
'border-radius:6px;padding:14px;color:#fca5a5;font-size:13px;line-height:1.6;margin-bottom:20px;' +
|
|
168
|
+
`text-align:left;font-family:\'SF Mono\',Menlo,monospace;">${options.errorDetail || 'An unexpected error occurred during authorization.'}</div>` +
|
|
169
|
+
'<div style="background:#191c19;border:1px solid rgba(255,255,255,0.07);' +
|
|
170
|
+
'border-radius:6px;padding:16px;margin-bottom:24px;text-align:left;font-size:13px;">' +
|
|
171
|
+
'<div style="color:#e4e8e0;font-weight:600;margin-bottom:8px;">Recommended Solutions:</div>' +
|
|
172
|
+
'<ol style="color:#9da697;line-height:1.6;margin:0;padding-left:18px;">' +
|
|
173
|
+
'<li>Return to your terminal and select OpenRouter in the FREE tab to retry.</li>' +
|
|
174
|
+
'<li>Or obtain a free API key at <a href="https://openrouter.ai/keys" target="_blank" ' +
|
|
175
|
+
'style="color:#9df028;text-decoration:none;">openrouter.ai/keys</a> and connect directly via:</li>' +
|
|
163
176
|
'</ol>' +
|
|
164
|
-
'<pre style="background:#
|
|
165
|
-
'font-size:12px;margin-top:10px;overflow-x:auto;">causyne config set providerKeys.openrouter <your-key></pre>' +
|
|
177
|
+
'<pre style="background:#141714;color:#9df028;padding:10px 14px;border-radius:4px;font-family:\'SF Mono\',Menlo,monospace;' +
|
|
178
|
+
'font-size:12px;margin-top:10px;border:1px solid rgba(255,255,255,0.07);overflow-x:auto;">causyne config set providerKeys.openrouter <your-key></pre>' +
|
|
166
179
|
'</div>';
|
|
167
180
|
const actionButton = isSuccess
|
|
168
|
-
? '<button onclick="
|
|
169
|
-
'padding:
|
|
181
|
+
? '<button id="return-btn" onclick="returnToTerminal()" style="background:#9df028;color:#141714;border:none;' +
|
|
182
|
+
'padding:11px 26px;border-radius:4px;font-size:13px;font-weight:700;cursor:pointer;' +
|
|
183
|
+
'font-family:\'SF Mono\',Menlo,monospace;letter-spacing:0.5px;transition:background 0.15s ease;">' +
|
|
170
184
|
'Return to Terminal</button>' +
|
|
171
|
-
'<div style="font-size:12px;color:#
|
|
172
|
-
|
|
173
|
-
'
|
|
185
|
+
'<div id="return-hint" style="font-size:12px;color:#60685b;margin-top:14px;line-height:1.5;">' +
|
|
186
|
+
'Authentication complete. You can close this browser tab (⌘W / Ctrl+W) and switch back to your terminal.' +
|
|
187
|
+
'</div>'
|
|
188
|
+
: '<button onclick="window.close()" style="background:#202421;color:#e4e8e0;border:1px solid rgba(255,255,255,0.15);' +
|
|
189
|
+
'padding:10px 22px;border-radius:4px;font-size:13px;font-weight:600;cursor:pointer;' +
|
|
190
|
+
'font-family:\'SF Mono\',Menlo,monospace;">' +
|
|
174
191
|
'Close Window</button>';
|
|
175
192
|
return `<!DOCTYPE html>
|
|
176
193
|
<html lang="en">
|
|
@@ -179,11 +196,11 @@ export function renderAuthPage(options) {
|
|
|
179
196
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
180
197
|
<title>Causyne Agent Connected Successfully</title>
|
|
181
198
|
<style>
|
|
182
|
-
|
|
199
|
+
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
183
200
|
body {
|
|
184
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
185
|
-
background: #
|
|
186
|
-
color: #
|
|
201
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
202
|
+
background-color: #141714;
|
|
203
|
+
color: #e4e8e0;
|
|
187
204
|
min-height: 100vh;
|
|
188
205
|
display: flex;
|
|
189
206
|
align-items: center;
|
|
@@ -191,7 +208,7 @@ export function renderAuthPage(options) {
|
|
|
191
208
|
padding: 24px;
|
|
192
209
|
}
|
|
193
210
|
.container {
|
|
194
|
-
max-width:
|
|
211
|
+
max-width: 500px;
|
|
195
212
|
width: 100%;
|
|
196
213
|
text-align: center;
|
|
197
214
|
}
|
|
@@ -199,53 +216,75 @@ export function renderAuthPage(options) {
|
|
|
199
216
|
display: flex;
|
|
200
217
|
align-items: center;
|
|
201
218
|
justify-content: center;
|
|
202
|
-
gap:
|
|
203
|
-
margin-bottom:
|
|
219
|
+
gap: 14px;
|
|
220
|
+
margin-bottom: 24px;
|
|
204
221
|
}
|
|
205
222
|
.logo {
|
|
206
|
-
width:
|
|
207
|
-
height:
|
|
223
|
+
width: 40px;
|
|
224
|
+
height: 40px;
|
|
208
225
|
object-fit: contain;
|
|
209
|
-
border-radius: 12px;
|
|
210
|
-
filter: drop-shadow(0 4px 16px rgba(157, 240, 40, 0.3));
|
|
211
226
|
}
|
|
212
227
|
.brand-title {
|
|
213
|
-
font-family:
|
|
214
|
-
font-size:
|
|
228
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
229
|
+
font-size: 20px;
|
|
215
230
|
font-weight: 800;
|
|
216
231
|
letter-spacing: 1.5px;
|
|
217
|
-
color: #
|
|
232
|
+
color: #e4e8e0;
|
|
218
233
|
line-height: 1.2;
|
|
234
|
+
text-align: left;
|
|
219
235
|
}
|
|
220
236
|
.brand-subtitle {
|
|
237
|
+
font-family: 'SF Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
221
238
|
font-size: 11px;
|
|
222
|
-
color: #
|
|
223
|
-
letter-spacing:
|
|
224
|
-
text-transform: uppercase;
|
|
239
|
+
color: #9da697;
|
|
240
|
+
letter-spacing: 0.5px;
|
|
225
241
|
margin-top: 2px;
|
|
226
242
|
text-align: left;
|
|
227
243
|
}
|
|
244
|
+
.brand-slogan {
|
|
245
|
+
font-family: 'SF Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
246
|
+
font-size: 11px;
|
|
247
|
+
color: #60685b;
|
|
248
|
+
margin-top: 1px;
|
|
249
|
+
text-align: left;
|
|
250
|
+
}
|
|
228
251
|
.card {
|
|
229
|
-
background:
|
|
230
|
-
border: 1px solid rgba(
|
|
231
|
-
border-radius:
|
|
232
|
-
padding:
|
|
233
|
-
box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
|
|
234
|
-
backdrop-filter: blur(16px);
|
|
252
|
+
background: #202421;
|
|
253
|
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
254
|
+
border-radius: 8px;
|
|
255
|
+
padding: 32px 28px;
|
|
235
256
|
}
|
|
236
257
|
h1 {
|
|
237
|
-
color: #
|
|
238
|
-
font-size:
|
|
258
|
+
color: #e4e8e0;
|
|
259
|
+
font-size: 19px;
|
|
239
260
|
font-weight: 700;
|
|
240
|
-
margin-bottom:
|
|
261
|
+
margin-bottom: 10px;
|
|
262
|
+
letter-spacing: -0.2px;
|
|
241
263
|
}
|
|
242
264
|
p {
|
|
243
|
-
color: #
|
|
244
|
-
font-size:
|
|
265
|
+
color: #9da697;
|
|
266
|
+
font-size: 13px;
|
|
245
267
|
line-height: 1.6;
|
|
246
|
-
margin-bottom:
|
|
268
|
+
margin-bottom: 22px;
|
|
247
269
|
}
|
|
248
270
|
</style>
|
|
271
|
+
<script>
|
|
272
|
+
function returnToTerminal() {
|
|
273
|
+
try {
|
|
274
|
+
window.open('', '_self', '');
|
|
275
|
+
window.close();
|
|
276
|
+
} catch (e) {}
|
|
277
|
+
var btn = document.getElementById('return-btn');
|
|
278
|
+
if (btn) {
|
|
279
|
+
btn.textContent = '✓ Ready! Switch to Terminal';
|
|
280
|
+
btn.style.background = '#8ea954';
|
|
281
|
+
}
|
|
282
|
+
var hint = document.getElementById('return-hint');
|
|
283
|
+
if (hint) {
|
|
284
|
+
hint.innerHTML = '<span style="color:#B5D66A;font-weight:600;">Authentication complete!</span> Switch back to your terminal window (Cmd+Tab / Alt+Tab). You can close this tab (Cmd+W / Ctrl+W).';
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
</script>
|
|
249
288
|
</head>
|
|
250
289
|
<body>
|
|
251
290
|
<div class="container">
|
|
@@ -253,7 +292,8 @@ export function renderAuthPage(options) {
|
|
|
253
292
|
<img src="${logoSrc}" alt="Causyne Agent Logo" class="logo" />
|
|
254
293
|
<div>
|
|
255
294
|
<div class="brand-title">CAUSYNE <span style="color:#9df028;">AGENT</span></div>
|
|
256
|
-
<div class="brand-subtitle">
|
|
295
|
+
<div class="brand-subtitle">Agentic AI Harness</div>
|
|
296
|
+
<div class="brand-slogan">From intention to meaningful progress.</div>
|
|
257
297
|
</div>
|
|
258
298
|
</div>
|
|
259
299
|
<div class="card">
|
|
@@ -449,10 +489,30 @@ export function disconnectOpenRouter(store = { loadConfig, saveConfig }) {
|
|
|
449
489
|
};
|
|
450
490
|
delete providerKeys['openrouter'];
|
|
451
491
|
currentConfig.providerKeys = providerKeys;
|
|
492
|
+
if (process.env.OPENROUTER_API_KEY) {
|
|
493
|
+
delete process.env.OPENROUTER_API_KEY;
|
|
494
|
+
}
|
|
452
495
|
if (currentConfig.provider === 'openrouter') {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
496
|
+
if (providerKeys['deepseek']) {
|
|
497
|
+
currentConfig.provider = 'deepseek';
|
|
498
|
+
currentConfig.model = 'deepseek-chat';
|
|
499
|
+
currentConfig.apiKey = providerKeys['deepseek'];
|
|
500
|
+
}
|
|
501
|
+
else if (providerKeys['anthropic']) {
|
|
502
|
+
currentConfig.provider = 'anthropic';
|
|
503
|
+
currentConfig.model = 'claude-3-7-sonnet';
|
|
504
|
+
currentConfig.apiKey = providerKeys['anthropic'];
|
|
505
|
+
}
|
|
506
|
+
else if (providerKeys['openai']) {
|
|
507
|
+
currentConfig.provider = 'openai';
|
|
508
|
+
currentConfig.model = 'gpt-4o';
|
|
509
|
+
currentConfig.apiKey = providerKeys['openai'];
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
currentConfig.provider = 'antigravity';
|
|
513
|
+
currentConfig.model = 'Gemini 3.8 Flash (Low)';
|
|
514
|
+
currentConfig.apiKey = '';
|
|
515
|
+
}
|
|
456
516
|
}
|
|
457
517
|
store.saveConfig(currentConfig);
|
|
458
518
|
return currentConfig;
|
|
@@ -129,14 +129,22 @@ export async function exchangeCodeForApiKey(
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
|
-
* Retrieve the Causyne Agent emblem logo as
|
|
132
|
+
* Retrieve the Causyne Agent emblem logo encoded as Base64.
|
|
133
133
|
*/
|
|
134
134
|
export function getLogoBuffer(): Buffer | null {
|
|
135
135
|
try {
|
|
136
136
|
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
const candidates = [
|
|
138
|
+
path.resolve(currentDir, '../assets/logo.png'),
|
|
139
|
+
path.resolve(currentDir, '../../assets/logo.png'),
|
|
140
|
+
path.resolve(currentDir, '../../../public/assets/logo-200.png'),
|
|
141
|
+
path.resolve(process.cwd(), 'src/assets/logo.png'),
|
|
142
|
+
path.resolve(process.cwd(), 'assets/logo.png')
|
|
143
|
+
];
|
|
144
|
+
for (const candidate of candidates) {
|
|
145
|
+
if (fs.existsSync(candidate)) {
|
|
146
|
+
return fs.readFileSync(candidate);
|
|
147
|
+
}
|
|
140
148
|
}
|
|
141
149
|
} catch {
|
|
142
150
|
// Ignore read errors
|
|
@@ -161,7 +169,8 @@ export interface RenderAuthPageOptions {
|
|
|
161
169
|
}
|
|
162
170
|
|
|
163
171
|
/**
|
|
164
|
-
* Render a professional branded HTML response page for OpenRouter OAuth callbacks
|
|
172
|
+
* Render a professional branded HTML response page for OpenRouter OAuth callbacks
|
|
173
|
+
* following the exact visual style and design language of causyne.com.
|
|
165
174
|
*/
|
|
166
175
|
export function renderAuthPage(options: RenderAuthPageOptions): string {
|
|
167
176
|
const isSuccess = options.status === 'success';
|
|
@@ -169,56 +178,64 @@ export function renderAuthPage(options: RenderAuthPageOptions): string {
|
|
|
169
178
|
const logoSrc = base64Logo ? `data:image/png;base64,${base64Logo}` : '/logo.png';
|
|
170
179
|
|
|
171
180
|
const badgeHtml = isSuccess
|
|
172
|
-
? '<div style="display:inline-flex;align-items:center;gap:
|
|
173
|
-
'background:rgba(
|
|
174
|
-
'padding:
|
|
181
|
+
? '<div style="display:inline-flex;align-items:center;gap:6px;' +
|
|
182
|
+
'background:rgba(157,240,40,0.12);border:1px solid rgba(157,240,40,0.35);color:#9df028;' +
|
|
183
|
+
'padding:5px 14px;border-radius:4px;font-size:12px;font-family:\'SF Mono\',Menlo,monospace;font-weight:600;margin-bottom:20px;">' +
|
|
175
184
|
'✓ Connected Successfully</div>'
|
|
176
|
-
: '<div style="display:inline-flex;align-items:center;gap:
|
|
177
|
-
'background:rgba(239,
|
|
178
|
-
'padding:
|
|
185
|
+
: '<div style="display:inline-flex;align-items:center;gap:6px;' +
|
|
186
|
+
'background:rgba(239,83,80,0.12);border:1px solid rgba(239,83,80,0.35);color:#ef5350;' +
|
|
187
|
+
'padding:5px 14px;border-radius:4px;font-size:12px;font-family:\'SF Mono\',Menlo,monospace;font-weight:600;margin-bottom:20px;">' +
|
|
179
188
|
'✕ Authorization Failed</div>';
|
|
180
189
|
|
|
181
190
|
const title = options.title || (isSuccess ? 'OpenRouter Account Authorized' : 'Authorization Error');
|
|
182
191
|
const defaultMsg = isSuccess
|
|
183
|
-
? 'Your OpenRouter account
|
|
192
|
+
? 'Your OpenRouter account is now authorized and connected to Causyne Agent. You can close this window and return to your terminal.'
|
|
184
193
|
: 'The authorization flow could not be completed.';
|
|
185
194
|
const message = options.message || defaultMsg;
|
|
186
195
|
|
|
187
196
|
const contentBox = isSuccess
|
|
188
|
-
? '<div style="background
|
|
189
|
-
'border-radius:
|
|
190
|
-
'font-size:
|
|
191
|
-
'<div style="display:flex;justify-content:space-between;margin-bottom:
|
|
192
|
-
'<span style="color:#
|
|
197
|
+
? '<div style="background:#191c19;border:1px solid rgba(255,255,255,0.07);' +
|
|
198
|
+
'border-radius:6px;padding:14px 18px;margin-bottom:24px;text-align:left;font-family:\'SF Mono\',Menlo,Monaco,Consolas,monospace;' +
|
|
199
|
+
'font-size:12px;line-height:1.7;color:#e4e8e0;">' +
|
|
200
|
+
'<div style="display:flex;justify-content:space-between;margin-bottom:6px;">' +
|
|
201
|
+
'<span style="color:#9da697;">Provider</span>' +
|
|
202
|
+
'<span style="color:#e4e8e0;font-weight:600;">OpenRouter</span>' +
|
|
203
|
+
'</div>' +
|
|
204
|
+
'<div style="display:flex;justify-content:space-between;margin-bottom:6px;">' +
|
|
205
|
+
'<span style="color:#9da697;">Active Model</span>' +
|
|
193
206
|
`<span style="color:#9df028;font-weight:600;">${options.model || OPENROUTER_FREE_MODEL}</span>` +
|
|
194
207
|
'</div>' +
|
|
195
208
|
'<div style="display:flex;justify-content:space-between;">' +
|
|
196
|
-
'<span style="color:#
|
|
197
|
-
'<span style="color:#
|
|
209
|
+
'<span style="color:#9da697;">Privacy Guard</span>' +
|
|
210
|
+
'<span style="color:#9da697;">provider.data_collection = "deny"</span>' +
|
|
198
211
|
'</div>' +
|
|
199
212
|
'</div>'
|
|
200
|
-
: '<div style="background
|
|
201
|
-
'border-radius:
|
|
202
|
-
`text-align:left;">${options.errorDetail || 'An unexpected error occurred during authorization.'}</div>` +
|
|
203
|
-
'<div style="background
|
|
204
|
-
'border-radius:
|
|
205
|
-
'<div style="color:#
|
|
206
|
-
'<ol style="color:#
|
|
207
|
-
'<li>Return to your terminal and select OpenRouter in the FREE tab
|
|
208
|
-
'<li>Or
|
|
209
|
-
'style="color:#
|
|
213
|
+
: '<div style="background:#191c19;border:1px solid rgba(239,83,80,0.25);' +
|
|
214
|
+
'border-radius:6px;padding:14px;color:#fca5a5;font-size:13px;line-height:1.6;margin-bottom:20px;' +
|
|
215
|
+
`text-align:left;font-family:\'SF Mono\',Menlo,monospace;">${options.errorDetail || 'An unexpected error occurred during authorization.'}</div>` +
|
|
216
|
+
'<div style="background:#191c19;border:1px solid rgba(255,255,255,0.07);' +
|
|
217
|
+
'border-radius:6px;padding:16px;margin-bottom:24px;text-align:left;font-size:13px;">' +
|
|
218
|
+
'<div style="color:#e4e8e0;font-weight:600;margin-bottom:8px;">Recommended Solutions:</div>' +
|
|
219
|
+
'<ol style="color:#9da697;line-height:1.6;margin:0;padding-left:18px;">' +
|
|
220
|
+
'<li>Return to your terminal and select OpenRouter in the FREE tab to retry.</li>' +
|
|
221
|
+
'<li>Or obtain a free API key at <a href="https://openrouter.ai/keys" target="_blank" ' +
|
|
222
|
+
'style="color:#9df028;text-decoration:none;">openrouter.ai/keys</a> and connect directly via:</li>' +
|
|
210
223
|
'</ol>' +
|
|
211
|
-
'<pre style="background:#
|
|
212
|
-
'font-size:12px;margin-top:10px;overflow-x:auto;">causyne config set providerKeys.openrouter <your-key></pre>' +
|
|
224
|
+
'<pre style="background:#141714;color:#9df028;padding:10px 14px;border-radius:4px;font-family:\'SF Mono\',Menlo,monospace;' +
|
|
225
|
+
'font-size:12px;margin-top:10px;border:1px solid rgba(255,255,255,0.07);overflow-x:auto;">causyne config set providerKeys.openrouter <your-key></pre>' +
|
|
213
226
|
'</div>';
|
|
214
227
|
|
|
215
228
|
const actionButton = isSuccess
|
|
216
|
-
? '<button onclick="
|
|
217
|
-
'padding:
|
|
229
|
+
? '<button id="return-btn" onclick="returnToTerminal()" style="background:#9df028;color:#141714;border:none;' +
|
|
230
|
+
'padding:11px 26px;border-radius:4px;font-size:13px;font-weight:700;cursor:pointer;' +
|
|
231
|
+
'font-family:\'SF Mono\',Menlo,monospace;letter-spacing:0.5px;transition:background 0.15s ease;">' +
|
|
218
232
|
'Return to Terminal</button>' +
|
|
219
|
-
'<div style="font-size:12px;color:#
|
|
220
|
-
|
|
221
|
-
'
|
|
233
|
+
'<div id="return-hint" style="font-size:12px;color:#60685b;margin-top:14px;line-height:1.5;">' +
|
|
234
|
+
'Authentication complete. You can close this browser tab (⌘W / Ctrl+W) and switch back to your terminal.' +
|
|
235
|
+
'</div>'
|
|
236
|
+
: '<button onclick="window.close()" style="background:#202421;color:#e4e8e0;border:1px solid rgba(255,255,255,0.15);' +
|
|
237
|
+
'padding:10px 22px;border-radius:4px;font-size:13px;font-weight:600;cursor:pointer;' +
|
|
238
|
+
'font-family:\'SF Mono\',Menlo,monospace;">' +
|
|
222
239
|
'Close Window</button>';
|
|
223
240
|
|
|
224
241
|
return `<!DOCTYPE html>
|
|
@@ -228,11 +245,11 @@ export function renderAuthPage(options: RenderAuthPageOptions): string {
|
|
|
228
245
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
229
246
|
<title>Causyne Agent Connected Successfully</title>
|
|
230
247
|
<style>
|
|
231
|
-
|
|
248
|
+
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
232
249
|
body {
|
|
233
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
234
|
-
background: #
|
|
235
|
-
color: #
|
|
250
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
251
|
+
background-color: #141714;
|
|
252
|
+
color: #e4e8e0;
|
|
236
253
|
min-height: 100vh;
|
|
237
254
|
display: flex;
|
|
238
255
|
align-items: center;
|
|
@@ -240,7 +257,7 @@ export function renderAuthPage(options: RenderAuthPageOptions): string {
|
|
|
240
257
|
padding: 24px;
|
|
241
258
|
}
|
|
242
259
|
.container {
|
|
243
|
-
max-width:
|
|
260
|
+
max-width: 500px;
|
|
244
261
|
width: 100%;
|
|
245
262
|
text-align: center;
|
|
246
263
|
}
|
|
@@ -248,53 +265,75 @@ export function renderAuthPage(options: RenderAuthPageOptions): string {
|
|
|
248
265
|
display: flex;
|
|
249
266
|
align-items: center;
|
|
250
267
|
justify-content: center;
|
|
251
|
-
gap:
|
|
252
|
-
margin-bottom:
|
|
268
|
+
gap: 14px;
|
|
269
|
+
margin-bottom: 24px;
|
|
253
270
|
}
|
|
254
271
|
.logo {
|
|
255
|
-
width:
|
|
256
|
-
height:
|
|
272
|
+
width: 40px;
|
|
273
|
+
height: 40px;
|
|
257
274
|
object-fit: contain;
|
|
258
|
-
border-radius: 12px;
|
|
259
|
-
filter: drop-shadow(0 4px 16px rgba(157, 240, 40, 0.3));
|
|
260
275
|
}
|
|
261
276
|
.brand-title {
|
|
262
|
-
font-family:
|
|
263
|
-
font-size:
|
|
277
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
278
|
+
font-size: 20px;
|
|
264
279
|
font-weight: 800;
|
|
265
280
|
letter-spacing: 1.5px;
|
|
266
|
-
color: #
|
|
281
|
+
color: #e4e8e0;
|
|
267
282
|
line-height: 1.2;
|
|
283
|
+
text-align: left;
|
|
268
284
|
}
|
|
269
285
|
.brand-subtitle {
|
|
286
|
+
font-family: 'SF Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
270
287
|
font-size: 11px;
|
|
271
|
-
color: #
|
|
272
|
-
letter-spacing:
|
|
273
|
-
text-transform: uppercase;
|
|
288
|
+
color: #9da697;
|
|
289
|
+
letter-spacing: 0.5px;
|
|
274
290
|
margin-top: 2px;
|
|
275
291
|
text-align: left;
|
|
276
292
|
}
|
|
293
|
+
.brand-slogan {
|
|
294
|
+
font-family: 'SF Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
295
|
+
font-size: 11px;
|
|
296
|
+
color: #60685b;
|
|
297
|
+
margin-top: 1px;
|
|
298
|
+
text-align: left;
|
|
299
|
+
}
|
|
277
300
|
.card {
|
|
278
|
-
background:
|
|
279
|
-
border: 1px solid rgba(
|
|
280
|
-
border-radius:
|
|
281
|
-
padding:
|
|
282
|
-
box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
|
|
283
|
-
backdrop-filter: blur(16px);
|
|
301
|
+
background: #202421;
|
|
302
|
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
303
|
+
border-radius: 8px;
|
|
304
|
+
padding: 32px 28px;
|
|
284
305
|
}
|
|
285
306
|
h1 {
|
|
286
|
-
color: #
|
|
287
|
-
font-size:
|
|
307
|
+
color: #e4e8e0;
|
|
308
|
+
font-size: 19px;
|
|
288
309
|
font-weight: 700;
|
|
289
|
-
margin-bottom:
|
|
310
|
+
margin-bottom: 10px;
|
|
311
|
+
letter-spacing: -0.2px;
|
|
290
312
|
}
|
|
291
313
|
p {
|
|
292
|
-
color: #
|
|
293
|
-
font-size:
|
|
314
|
+
color: #9da697;
|
|
315
|
+
font-size: 13px;
|
|
294
316
|
line-height: 1.6;
|
|
295
|
-
margin-bottom:
|
|
317
|
+
margin-bottom: 22px;
|
|
296
318
|
}
|
|
297
319
|
</style>
|
|
320
|
+
<script>
|
|
321
|
+
function returnToTerminal() {
|
|
322
|
+
try {
|
|
323
|
+
window.open('', '_self', '');
|
|
324
|
+
window.close();
|
|
325
|
+
} catch (e) {}
|
|
326
|
+
var btn = document.getElementById('return-btn');
|
|
327
|
+
if (btn) {
|
|
328
|
+
btn.textContent = '✓ Ready! Switch to Terminal';
|
|
329
|
+
btn.style.background = '#8ea954';
|
|
330
|
+
}
|
|
331
|
+
var hint = document.getElementById('return-hint');
|
|
332
|
+
if (hint) {
|
|
333
|
+
hint.innerHTML = '<span style="color:#B5D66A;font-weight:600;">Authentication complete!</span> Switch back to your terminal window (Cmd+Tab / Alt+Tab). You can close this tab (Cmd+W / Ctrl+W).';
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
</script>
|
|
298
337
|
</head>
|
|
299
338
|
<body>
|
|
300
339
|
<div class="container">
|
|
@@ -302,7 +341,8 @@ export function renderAuthPage(options: RenderAuthPageOptions): string {
|
|
|
302
341
|
<img src="${logoSrc}" alt="Causyne Agent Logo" class="logo" />
|
|
303
342
|
<div>
|
|
304
343
|
<div class="brand-title">CAUSYNE <span style="color:#9df028;">AGENT</span></div>
|
|
305
|
-
<div class="brand-subtitle">
|
|
344
|
+
<div class="brand-subtitle">Agentic AI Harness</div>
|
|
345
|
+
<div class="brand-slogan">From intention to meaningful progress.</div>
|
|
306
346
|
</div>
|
|
307
347
|
</div>
|
|
308
348
|
<div class="card">
|
|
@@ -531,7 +571,9 @@ export function saveOpenRouterKey(
|
|
|
531
571
|
/**
|
|
532
572
|
* Disconnect OpenRouter credentials from local vault.
|
|
533
573
|
*/
|
|
534
|
-
export function disconnectOpenRouter(
|
|
574
|
+
export function disconnectOpenRouter(
|
|
575
|
+
store: { loadConfig(): any; saveConfig(cfg: any): void } = { loadConfig, saveConfig }
|
|
576
|
+
): Record<string, any> {
|
|
535
577
|
const currentConfig = store.loadConfig() || {};
|
|
536
578
|
const providerKeys = {
|
|
537
579
|
...(currentConfig.providerKeys && typeof currentConfig.providerKeys === 'object' ? currentConfig.providerKeys : {})
|
|
@@ -540,10 +582,28 @@ export function disconnectOpenRouter(store: { loadConfig(): any; saveConfig(cfg:
|
|
|
540
582
|
delete providerKeys['openrouter'];
|
|
541
583
|
currentConfig.providerKeys = providerKeys;
|
|
542
584
|
|
|
585
|
+
if (process.env.OPENROUTER_API_KEY) {
|
|
586
|
+
delete process.env.OPENROUTER_API_KEY;
|
|
587
|
+
}
|
|
588
|
+
|
|
543
589
|
if (currentConfig.provider === 'openrouter') {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
590
|
+
if (providerKeys['deepseek']) {
|
|
591
|
+
currentConfig.provider = 'deepseek';
|
|
592
|
+
currentConfig.model = 'deepseek-chat';
|
|
593
|
+
currentConfig.apiKey = providerKeys['deepseek'];
|
|
594
|
+
} else if (providerKeys['anthropic']) {
|
|
595
|
+
currentConfig.provider = 'anthropic';
|
|
596
|
+
currentConfig.model = 'claude-3-7-sonnet';
|
|
597
|
+
currentConfig.apiKey = providerKeys['anthropic'];
|
|
598
|
+
} else if (providerKeys['openai']) {
|
|
599
|
+
currentConfig.provider = 'openai';
|
|
600
|
+
currentConfig.model = 'gpt-4o';
|
|
601
|
+
currentConfig.apiKey = providerKeys['openai'];
|
|
602
|
+
} else {
|
|
603
|
+
currentConfig.provider = 'antigravity';
|
|
604
|
+
currentConfig.model = 'Gemini 3.8 Flash (Low)';
|
|
605
|
+
currentConfig.apiKey = '';
|
|
606
|
+
}
|
|
547
607
|
}
|
|
548
608
|
|
|
549
609
|
store.saveConfig(currentConfig);
|