@causyne/agent 1.20.72 → 1.20.74

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.
@@ -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 a binary buffer if available.
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 assetPath = path.resolve(currentDir, '../assets/logo.png');
103
- if (fs.existsSync(assetPath)) {
104
- return fs.readFileSync(assetPath);
102
+ const candidates = [
103
+ path.resolve(currentDir, '../assets/logo.png'),
104
+ path.resolve(currentDir, '../../assets/logo.png'),
105
+ path.resolve(currentDir, '../../src/assets/logo.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 {
@@ -116,61 +124,135 @@ export function getLogoBase64() {
116
124
  const buf = getLogoBuffer();
117
125
  return buf ? buf.toString('base64') : '';
118
126
  }
127
+ const CAUSYNE_LOGO_SVG = [
128
+ '<svg class="brand-logo" viewBox="312 272 628 695" width="34" height="34" role="img" aria-label="Causyne Logo">',
129
+ '<title>Causyne</title>',
130
+ '<path fill="#fff" fill-rule="evenodd" d="M619 957C596 952 563 933 555 919C549 90',
131
+ '8 543 905 530 905C526 905 520 905 517 905C511 905 498 902 492 899C487 896 433 86',
132
+ '3 396 841C345 811 332 798 325 767C321 752 321 713 325 708C332 699 333 688 328 67',
133
+ '6C321 661 322 662 322 574C322 494 322 494 325 485C332 464 351 444 367 442C380 44',
134
+ '1 387 433 391 418C394 401 403 390 422 380C427 377 453 362 479 348C505 334 540 31',
135
+ '4 558 304C575 295 591 286 593 286C609 280 623 280 637 283C657 288 691 310 696 32',
136
+ '2C702 334 716 339 730 335C739 332 754 335 766 342C775 347 834 382 866 401C905 42',
137
+ '4 918 438 925 465C929 478 929 566 925 570C919 579 919 589 925 602C932 617 932 61',
138
+ '8 932 689C932 752 932 752 930 761C923 787 902 807 881 808C869 808 861 815 857 82',
139
+ '7C851 845 846 850 815 867C805 873 781 886 762 897C657 956 657 956 643 958C634 95',
140
+ '9 627 959 619 957ZM651 945C658 942 676 932 756 887C776 876 800 863 810 857C832 8',
141
+ '45 835 843 839 838C845 831 849 818 847 813C843 796 865 783 879 794C890 802 913 7',
142
+ '82 919 758C921 751 921 747 921 689C921 613 921 613 908 596C898 584 901 566 914 5',
143
+ '63C917 563 917 563 917 518C916 464 915 459 900 440C891 428 891 428 800 374C744 3',
144
+ '42 739 340 720 350C701 360 687 352 687 330C687 324 679 316 660 305C640 294 636 2',
145
+ '93 620 293C603 292 600 294 563 314C545 324 510 344 484 358C458 372 432 387 427 3',
146
+ '90C405 402 399 413 403 432C406 447 393 459 378 455C367 452 361 454 350 464C332 4',
147
+ '83 332 481 332 575C332 668 332 664 345 682C354 696 350 712 337 715L333 715L333 7',
148
+ '36C334 764 337 775 347 790C358 806 356 805 462 867C512 897 516 899 534 891C545 8',
149
+ '86 553 887 560 893C564 897 567 905 565 910C564 916 571 923 590 934C615 948 632 9',
150
+ '51 651 945Z"/>',
151
+ '<g fill="#fff" stroke="#fff" stroke-width="9.0" stroke-linejoin="round">',
152
+ '<path fill-rule="evenodd" d="M620 949C599 944 566 924 563 915C562 908 564 904 61',
153
+ '2 859C656 816 657 815 684 786C712 754 715 750 725 723C740 681 745 670 751 659C75',
154
+ '4 652 757 646 758 646C760 646 768 659 788 696C795 708 808 731 818 748C848 801 85',
155
+ '1 809 849 821C846 837 841 842 811 859C801 865 777 878 758 889C677 934 659 944 65',
156
+ '2 947C643 950 628 951 620 949ZM510 895C500 893 504 895 400 833C351 804 340 793 3',
157
+ '33 765C331 756 330 716 332 714C332 713 337 715 345 718C371 728 400 735 468 747C5',
158
+ '09 754 516 754 602 754C666 754 678 754 678 755C678 758 661 775 575 859C538 895 5',
159
+ '29 900 510 895ZM881 798C877 796 870 788 865 779C856 764 822 704 797 660C784 638 ',
160
+ '769 612 763 601C721 531 710 510 711 510C712 509 727 511 734 513C742 516 812 541 ',
161
+ '830 547C886 569 916 592 922 619C924 631 924 749 921 759C916 781 893 803 881 798Z',
162
+ 'M462 720C392 706 390 706 374 700C348 691 337 681 332 661C329 648 330 498 333 487',
163
+ 'C340 468 358 451 371 451C376 451 385 459 392 471C394 475 407 498 422 522C436 547',
164
+ ' 454 578 462 592C471 607 488 637 502 659C539 723 543 729 543 730C543 734 529 732',
165
+ ' 462 720ZM488 585C479 571 477 568 428 484C422 472 415 460 412 456C392 422 396 40',
166
+ '4 426 388C431 385 457 370 483 356C509 342 544 322 562 312C599 291 602 290 620 29',
167
+ '1C637 291 641 292 661 303C691 320 695 328 682 344C676 352 671 356 612 418C592 43',
168
+ '8 568 463 559 473C551 484 541 495 538 499C530 507 526 516 520 536C511 567 499 59',
169
+ '7 496 597C496 597 492 592 488 585Z"/>',
170
+ '<path d="M908 559C885 543 853 528 797 508C741 489 744 489 650 489C589 489 580 48',
171
+ '9 580 488C580 486 642 422 687 376C720 343 728 339 749 345C756 347 775 357 861 40',
172
+ '8C898 430 908 441 916 466C919 474 920 565 918 565C917 565 913 562 908 559Z"/>',
173
+ '</g>',
174
+ '<path fill="#3a3f47" fill-rule="evenodd" d="M620 949C599 944 566 924 563 915C562',
175
+ ' 908 564 904 612 859C656 816 657 815 684 786C712 754 715 750 725 723C740 681 745',
176
+ ' 670 751 659C754 652 757 646 758 646C760 646 768 659 788 696C795 708 808 731 818',
177
+ ' 748C848 801 851 809 849 821C846 837 841 842 811 859C801 865 777 878 758 889C677',
178
+ ' 934 659 944 652 947C643 950 628 951 620 949ZM510 895C500 893 504 895 400 833C35',
179
+ '1 804 340 793 333 765C331 756 330 716 332 714C332 713 337 715 345 718C371 728 40',
180
+ '0 735 468 747C509 754 516 754 602 754C666 754 678 754 678 755C678 758 661 775 57',
181
+ '5 859C538 895 529 900 510 895ZM881 798C877 796 870 788 865 779C856 764 822 704 7',
182
+ '97 660C784 638 769 612 763 601C721 531 710 510 711 510C712 509 727 511 734 513C7',
183
+ '42 516 812 541 830 547C886 569 916 592 922 619C924 631 924 749 921 759C916 781 8',
184
+ '93 803 881 798ZM462 720C392 706 390 706 374 700C348 691 337 681 332 661C329 648 ',
185
+ '330 498 333 487C340 468 358 451 371 451C376 451 385 459 392 471C394 475 407 498 ',
186
+ '422 522C436 547 454 578 462 592C471 607 488 637 502 659C539 723 543 729 543 730C',
187
+ '543 734 529 732 462 720ZM488 585C479 571 477 568 428 484C422 472 415 460 412 456',
188
+ 'C392 422 396 404 426 388C431 385 457 370 483 356C509 342 544 322 562 312C599 291',
189
+ ' 602 290 620 291C637 291 641 292 661 303C691 320 695 328 682 344C676 352 671 356',
190
+ ' 612 418C592 438 568 463 559 473C551 484 541 495 538 499C530 507 526 516 520 536',
191
+ 'C511 567 499 597 496 597C496 597 492 592 488 585Z"/>',
192
+ '<path fill="#b6e06f" d="M908 559C885 543 853 528 797 508C741 489 744 489 650 489',
193
+ 'C589 489 580 489 580 488C580 486 642 422 687 376C720 343 728 339 749 345C756 347',
194
+ ' 775 357 861 408C898 430 908 441 916 466C919 474 920 565 918 565C917 565 913 562',
195
+ ' 908 559Z"/>',
196
+ '</svg>'
197
+ ].join('\n');
119
198
  /**
120
- * Render a professional branded HTML response page for OpenRouter OAuth callbacks.
199
+ * Render a professional branded HTML response page for OpenRouter OAuth callbacks
200
+ * following the exact visual style, typography, and design language of causyne.com.
121
201
  */
122
202
  export function renderAuthPage(options) {
123
203
  const isSuccess = options.status === 'success';
124
- const base64Logo = getLogoBase64();
125
- const logoSrc = base64Logo ? `data:image/png;base64,${base64Logo}` : '/logo.png';
126
204
  const badgeHtml = isSuccess
127
- ? '<div style="display:inline-flex;align-items:center;gap:8px;' +
128
- 'background:rgba(46,160,67,0.15);border:1px solid #2ea043;color:#3fb950;' +
129
- 'padding:6px 18px;border-radius:24px;font-size:13px;font-weight:600;margin-bottom:20px;">' +
130
- '✓ Connected Successfully</div>'
131
- : '<div style="display:inline-flex;align-items:center;gap:8px;' +
132
- 'background:rgba(239,68,68,0.15);border:1px solid #ef4444;color:#f87171;' +
133
- 'padding:6px 18px;border-radius:24px;font-size:13px;font-weight:600;margin-bottom:20px;">' +
134
- '✕ Authorization Failed</div>';
205
+ ? '<div class="panel-badge success">' +
206
+ '<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"/></svg>' +
207
+ '<span>Connected Successfully</span></div>'
208
+ : '<div class="panel-badge error">' +
209
+ '<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"/></svg>' +
210
+ '<span>Authorization Failed</span></div>';
135
211
  const title = options.title || (isSuccess ? 'OpenRouter Account Authorized' : 'Authorization Error');
136
212
  const defaultMsg = isSuccess
137
- ? 'Your OpenRouter account has been connected to Causyne Agent. You can now close this tab and return to your terminal.'
213
+ ? 'Your OpenRouter account is now authorized and connected to Causyne Agent. You can close this window and return to your terminal.'
138
214
  : 'The authorization flow could not be completed.';
139
215
  const message = options.message || defaultMsg;
140
216
  const contentBox = isSuccess
141
- ? '<div style="background:rgba(255,255,255,0.03);border:1px solid rgba(255,255,255,0.08);' +
142
- 'border-radius:10px;padding:14px 18px;margin-bottom:28px;text-align:left;font-family:monospace;' +
143
- 'font-size:13px;color:#cbd5e1;">' +
144
- '<div style="display:flex;justify-content:space-between;margin-bottom:8px;">' +
145
- '<span style="color:#64748b;">Active Model</span>' +
146
- `<span style="color:#9df028;font-weight:600;">${options.model || OPENROUTER_FREE_MODEL}</span>` +
217
+ ? '<div class="meta-box">' +
218
+ '<div class="meta-row" style="margin-bottom:8px;">' +
219
+ '<span class="meta-label">Provider</span>' +
220
+ '<span class="meta-val">OpenRouter</span>' +
221
+ '</div>' +
222
+ '<div class="meta-row" style="margin-bottom:8px;">' +
223
+ '<span class="meta-label">Active Model</span>' +
224
+ `<span class="meta-val lime">${options.model || OPENROUTER_FREE_MODEL}</span>` +
147
225
  '</div>' +
148
- '<div style="display:flex;justify-content:space-between;">' +
149
- '<span style="color:#64748b;">Privacy Guard</span>' +
150
- '<span style="color:#38bdf8;">provider.data_collection = &quot;deny&quot;</span>' +
226
+ '<div class="meta-row" style="margin-bottom:8px;">' +
227
+ '<span class="meta-label">Privacy Guard</span>' +
228
+ '<span class="meta-val" style="color:#9da697;">provider.data_collection = &quot;deny&quot;</span>' +
229
+ '</div>' +
230
+ '<div class="meta-row">' +
231
+ '<span class="meta-label">Protocol</span>' +
232
+ '<span class="meta-val" style="color:#9da697;">OAuth 2.0 PKCE (S256)</span>' +
151
233
  '</div>' +
152
234
  '</div>'
153
- : '<div style="background:rgba(239,68,68,0.08);border:1px solid rgba(239,68,68,0.25);' +
154
- 'border-radius:10px;padding:14px;color:#fca5a5;font-size:13px;line-height:1.5;margin-bottom:20px;' +
155
- `text-align:left;">${options.errorDetail || 'An unexpected error occurred during authorization.'}</div>` +
156
- '<div style="background:rgba(255,255,255,0.03);border:1px solid rgba(255,255,255,0.08);' +
157
- 'border-radius:10px;padding:16px;margin-bottom:24px;text-align:left;">' +
158
- '<div style="color:#ffffff;font-size:13px;font-weight:600;margin-bottom:8px;">Recommended Solutions:</div>' +
159
- '<ol style="color:#94a3b8;font-size:13px;line-height:1.6;margin:0;padding-left:18px;">' +
160
- '<li>Return to your terminal and select OpenRouter in the FREE tab again to retry.</li>' +
161
- '<li>Or create a free API key at <a href="https://openrouter.ai/keys" target="_blank" ' +
162
- 'style="color:#38bdf8;text-decoration:none;">openrouter.ai/keys</a> and configure it via:</li>' +
235
+ : '<div style="background:#191c19;border:1px solid rgba(239,83,80,0.25);' +
236
+ 'border-radius:6px;padding:14px;color:#fca5a5;font-size:13px;line-height:1.6;margin-bottom:20px;' +
237
+ `text-align:left;font-family:\'SF Mono\',Menlo,monospace;">${options.errorDetail || 'An unexpected error occurred during authorization.'}</div>` +
238
+ '<div style="background:#191c19;border:1px solid rgba(255,255,255,0.07);' +
239
+ 'border-radius:6px;padding:16px;margin-bottom:24px;text-align:left;font-size:13px;">' +
240
+ '<div style="color:#e4e8e0;font-weight:600;margin-bottom:8px;">Recommended Solutions:</div>' +
241
+ '<ol style="color:#9da697;line-height:1.6;margin:0;padding-left:18px;">' +
242
+ '<li>Return to your terminal and select OpenRouter in the FREE tab to retry.</li>' +
243
+ '<li>Or obtain a free API key at <a href="https://openrouter.ai/keys" target="_blank" ' +
244
+ 'style="color:#9df028;text-decoration:none;">openrouter.ai/keys</a> and connect directly via:</li>' +
163
245
  '</ol>' +
164
- '<pre style="background:#05070a;color:#9df028;padding:10px 14px;border-radius:6px;font-family:monospace;' +
165
- 'font-size:12px;margin-top:10px;overflow-x:auto;">causyne config set providerKeys.openrouter &lt;your-key&gt;</pre>' +
246
+ '<pre style="background:#141714;color:#9df028;padding:10px 14px;border-radius:4px;font-family:\'SF Mono\',Menlo,monospace;' +
247
+ 'font-size:12px;margin-top:10px;border:1px solid rgba(255,255,255,0.07);overflow-x:auto;">causyne config set providerKeys.openrouter &lt;your-key&gt;</pre>' +
166
248
  '</div>';
167
249
  const actionButton = isSuccess
168
- ? '<button onclick="window.close()" style="background:#9df028;color:#080b11;border:none;' +
169
- 'padding:12px 28px;border-radius:8px;font-size:14px;font-weight:700;cursor:pointer;font-family:inherit;">' +
250
+ ? '<button id="return-btn" class="btn-primary" onclick="returnToTerminal()">' +
170
251
  'Return to Terminal</button>' +
171
- '<div style="font-size:12px;color:#64748b;margin-top:14px;">You can safely close this browser window.</div>'
172
- : '<button onclick="window.close()" style="background:#334155;color:#f8fafc;border:none;' +
173
- 'padding:10px 24px;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;font-family:inherit;">' +
252
+ '<div id="return-hint" class="return-hint">' +
253
+ 'Authentication complete. You can close this browser tab (⌘W / Ctrl+W) and switch back to your terminal.' +
254
+ '</div>'
255
+ : '<button class="btn-secondary" onclick="window.close()">' +
174
256
  'Close Window</button>';
175
257
  return `<!DOCTYPE html>
176
258
  <html lang="en">
@@ -178,91 +260,338 @@ export function renderAuthPage(options) {
178
260
  <meta charset="utf-8">
179
261
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
180
262
  <title>Causyne Agent Connected Successfully</title>
263
+ <link rel="preconnect" href="https://fonts.googleapis.com">
264
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
265
+ <link href="https://fonts.googleapis.com/css2?family=Exo+2:ital,wght@0,400;0,600;0,700;0,800;1,400&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
181
266
  <style>
182
- * { box-sizing: border-box; margin: 0; padding: 0; }
267
+ :root {
268
+ --bg: #141714;
269
+ --bg-subtle: #191c19;
270
+ --charcoal: #202421;
271
+ --lime: #B5D66A;
272
+ --lime-bright: #9df028;
273
+ --text-primary: #e4e8e0;
274
+ --text-secondary: #9da697;
275
+ --text-dim: #60685b;
276
+ --border: rgba(255, 255, 255, 0.07);
277
+ --font-display: 'Exo 2', system-ui, -apple-system, sans-serif;
278
+ --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Monaco, Consolas, monospace;
279
+ --max-w: 1100px;
280
+ }
281
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
183
282
  body {
184
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
185
- background: #080b11 radial-gradient(circle at 50% 20%, #152238 0%, #080b11 75%);
186
- color: #c9d1d9;
283
+ background-color: var(--bg);
284
+ color: var(--text-primary);
285
+ font-family: var(--font-mono);
187
286
  min-height: 100vh;
188
287
  display: flex;
189
- align-items: center;
190
- justify-content: center;
191
- padding: 24px;
288
+ flex-direction: column;
289
+ justify-content: space-between;
290
+ padding: 0 32px;
291
+ -webkit-font-smoothing: antialiased;
192
292
  }
193
- .container {
194
- max-width: 540px;
293
+ .page {
294
+ max-width: var(--max-w);
195
295
  width: 100%;
196
- text-align: center;
296
+ margin: 0 auto;
197
297
  }
198
- .header {
298
+ .site-header {
299
+ padding: 40px 0 32px;
199
300
  display: flex;
200
301
  align-items: center;
201
- justify-content: center;
202
- gap: 16px;
203
- margin-bottom: 28px;
302
+ justify-content: space-between;
303
+ border-bottom: 1px solid var(--border);
304
+ }
305
+ .brand {
306
+ display: inline-flex;
307
+ align-items: center;
308
+ gap: 14px;
309
+ text-decoration: none;
204
310
  }
205
- .logo {
206
- width: 52px;
207
- height: 52px;
208
- object-fit: contain;
209
- border-radius: 12px;
210
- filter: drop-shadow(0 4px 16px rgba(157, 240, 40, 0.3));
211
- }
212
- .brand-title {
213
- font-family: "JetBrains Mono", SFMono-Regular, Menlo, Consolas, monospace;
214
- font-size: 24px;
215
- font-weight: 800;
216
- letter-spacing: 1.5px;
217
- color: #ffffff;
218
- line-height: 1.2;
219
- }
220
- .brand-subtitle {
221
- font-size: 11px;
222
- color: #8a99a8;
223
- letter-spacing: 1px;
311
+ .brand-logo {
312
+ width: 36px;
313
+ height: 36px;
314
+ flex-shrink: 0;
315
+ }
316
+ .brand-wordmark {
317
+ font-family: var(--font-display);
318
+ font-size: 1.15rem;
319
+ font-weight: 700;
320
+ letter-spacing: 0.16em;
224
321
  text-transform: uppercase;
225
- margin-top: 2px;
226
- text-align: left;
227
- }
228
- .card {
229
- background: rgba(18, 25, 38, 0.95);
230
- border: 1px solid rgba(157, 240, 40, 0.22);
231
- border-radius: 16px;
232
- padding: 36px 32px;
233
- box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
234
- backdrop-filter: blur(16px);
235
- }
236
- h1 {
237
- color: #ffffff;
238
- font-size: 21px;
322
+ color: var(--text-primary);
323
+ }
324
+ .site-nav {
325
+ display: inline-flex;
326
+ align-items: center;
327
+ gap: 10px;
328
+ }
329
+ .nav-link {
330
+ display: inline-flex;
331
+ align-items: center;
332
+ gap: 8px;
333
+ padding: 7px 14px;
334
+ font-family: var(--font-mono);
335
+ font-size: 0.82rem;
336
+ font-weight: 500;
337
+ color: var(--text-secondary);
338
+ background: rgba(255, 255, 255, 0.02);
339
+ border: 1px solid var(--border);
340
+ border-radius: 4px;
341
+ text-decoration: none;
342
+ transition: all 0.18s ease;
343
+ line-height: 1;
344
+ }
345
+ .nav-link:hover {
346
+ color: var(--text-primary);
347
+ border-color: rgba(255, 255, 255, 0.22);
348
+ background: rgba(255, 255, 255, 0.06);
349
+ }
350
+ .nav-icon { display: block; }
351
+ .nav-icon.github-icon { color: var(--text-primary); }
352
+ .nav-icon.npm-icon { color: #ea2039; }
353
+
354
+ .content {
355
+ padding: 60px 0 72px;
356
+ }
357
+ .hero-grid {
358
+ display: grid;
359
+ grid-template-columns: 1.1fr 1fr;
360
+ gap: 56px;
361
+ align-items: start;
362
+ }
363
+ @media (max-width: 860px) {
364
+ .hero-grid { grid-template-columns: 1fr; gap: 36px; }
365
+ body { padding: 0 20px; }
366
+ }
367
+ .hero-title {
368
+ font-family: var(--font-display);
369
+ font-size: 2.35rem;
239
370
  font-weight: 700;
240
- margin-bottom: 12px;
371
+ line-height: 1.18;
372
+ letter-spacing: -0.02em;
373
+ color: var(--text-primary);
374
+ margin-bottom: 20px;
241
375
  }
242
- p {
243
- color: #94a3b8;
244
- font-size: 14px;
245
- line-height: 1.6;
376
+ .hero-lead {
377
+ font-family: var(--font-mono);
378
+ font-size: 0.95rem;
379
+ line-height: 1.76;
380
+ color: var(--text-secondary);
381
+ margin-bottom: 28px;
382
+ }
383
+ .hero-slogan {
384
+ font-family: var(--font-mono);
385
+ font-size: 0.82rem;
386
+ color: var(--text-dim);
387
+ display: flex;
388
+ align-items: center;
389
+ gap: 8px;
390
+ }
391
+ .hero-slogan::before {
392
+ content: '';
393
+ display: inline-block;
394
+ width: 7px;
395
+ height: 7px;
396
+ border-radius: 50%;
397
+ background: var(--lime);
398
+ }
399
+
400
+ .autonomy-panel {
401
+ background: var(--charcoal);
402
+ border: 1px solid var(--border);
403
+ border-radius: 8px;
404
+ padding: 32px 28px;
405
+ }
406
+ .panel-badge {
407
+ display: inline-flex;
408
+ align-items: center;
409
+ gap: 8px;
410
+ padding: 6px 14px;
411
+ border-radius: 4px;
412
+ font-family: var(--font-mono);
413
+ font-size: 12px;
414
+ font-weight: 600;
415
+ margin-bottom: 20px;
416
+ }
417
+ .panel-badge.success {
418
+ background: rgba(157, 240, 40, 0.12);
419
+ border: 1px solid rgba(157, 240, 40, 0.35);
420
+ color: #9df028;
421
+ }
422
+ .panel-badge.error {
423
+ background: rgba(239, 83, 80, 0.12);
424
+ border: 1px solid rgba(239, 83, 80, 0.35);
425
+ color: #ef5350;
426
+ }
427
+ .panel-heading {
428
+ font-family: var(--font-display);
429
+ font-size: 1.25rem;
430
+ font-weight: 700;
431
+ color: var(--text-primary);
432
+ margin-bottom: 10px;
433
+ letter-spacing: -0.01em;
434
+ }
435
+ .panel-message {
436
+ font-family: var(--font-mono);
437
+ font-size: 0.85rem;
438
+ line-height: 1.68;
439
+ color: var(--text-secondary);
440
+ margin-bottom: 22px;
441
+ }
442
+ .meta-box {
443
+ background: var(--bg-subtle);
444
+ border: 1px solid var(--border);
445
+ border-radius: 6px;
446
+ padding: 16px 18px;
246
447
  margin-bottom: 24px;
448
+ font-family: var(--font-mono);
449
+ font-size: 12px;
450
+ line-height: 1.8;
451
+ color: var(--text-primary);
452
+ }
453
+ .meta-row {
454
+ display: flex;
455
+ justify-content: space-between;
456
+ align-items: center;
457
+ }
458
+ .meta-label { color: var(--text-secondary); }
459
+ .meta-val { color: var(--text-primary); font-weight: 500; }
460
+ .meta-val.lime { color: var(--lime-bright); font-weight: 600; }
461
+
462
+ .btn-primary {
463
+ display: inline-flex;
464
+ align-items: center;
465
+ justify-content: center;
466
+ width: 100%;
467
+ background: var(--lime-bright);
468
+ color: #141714;
469
+ border: none;
470
+ padding: 13px 24px;
471
+ border-radius: 4px;
472
+ font-size: 13px;
473
+ font-weight: 700;
474
+ font-family: var(--font-mono);
475
+ letter-spacing: 0.5px;
476
+ cursor: pointer;
477
+ transition: background 0.15s ease;
478
+ }
479
+ .btn-primary:hover {
480
+ background: #c8e682;
481
+ }
482
+ .btn-secondary {
483
+ display: inline-flex;
484
+ align-items: center;
485
+ justify-content: center;
486
+ width: 100%;
487
+ background: var(--charcoal);
488
+ color: var(--text-primary);
489
+ border: 1px solid rgba(255, 255, 255, 0.15);
490
+ padding: 12px 22px;
491
+ border-radius: 4px;
492
+ font-size: 13px;
493
+ font-weight: 600;
494
+ font-family: var(--font-mono);
495
+ cursor: pointer;
496
+ }
497
+ .btn-secondary:hover {
498
+ border-color: rgba(255, 255, 255, 0.3);
499
+ }
500
+ .return-hint {
501
+ font-family: var(--font-mono);
502
+ font-size: 11.5px;
503
+ color: var(--text-dim);
504
+ margin-top: 14px;
505
+ line-height: 1.6;
506
+ text-align: center;
507
+ }
508
+
509
+ .site-footer {
510
+ padding: 28px 0 36px;
511
+ border-top: 1px solid var(--border);
512
+ font-family: var(--font-mono);
513
+ font-size: 0.8rem;
514
+ color: var(--text-dim);
515
+ display: flex;
516
+ justify-content: space-between;
517
+ align-items: center;
518
+ }
519
+ .site-footer a {
520
+ color: var(--text-dim);
521
+ text-decoration: none;
522
+ }
523
+ .site-footer a:hover {
524
+ color: var(--lime);
247
525
  }
248
526
  </style>
527
+ <script>
528
+ function returnToTerminal() {
529
+ try {
530
+ window.open('', '_self', '');
531
+ window.close();
532
+ } catch (e) {}
533
+ var btn = document.getElementById('return-btn');
534
+ if (btn) {
535
+ btn.textContent = '✓ Ready! Switch to Terminal';
536
+ btn.style.background = '#8ea954';
537
+ }
538
+ var hint = document.getElementById('return-hint');
539
+ if (hint) {
540
+ 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).';
541
+ }
542
+ }
543
+ </script>
249
544
  </head>
250
545
  <body>
251
- <div class="container">
252
- <div class="header">
253
- <img src="${logoSrc}" alt="Causyne Agent Logo" class="logo" />
254
- <div>
255
- <div class="brand-title">CAUSYNE <span style="color:#9df028;">AGENT</span></div>
256
- <div class="brand-subtitle">Autonomous AI Harness</div>
546
+ <div class="page">
547
+ <header class="site-header">
548
+ <div class="brand">
549
+ ${CAUSYNE_LOGO_SVG}
550
+ <span class="brand-wordmark">CAUSYNE <span style="color:#9df028;">AGENT</span></span>
551
+ </div>
552
+ <nav class="site-nav" aria-label="Project links">
553
+ <a href="https://github.com/ikbal-causyne/causyne-agent" class="nav-link" target="_blank" rel="noopener noreferrer" title="Causyne Agent on GitHub">
554
+ <svg class="nav-icon github-icon" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true">
555
+ <path fill="currentColor" d="M8 0C3.58 0 0 3.64 0 8.13c0 3.59 2.29 6.64 5.47 7.71.4.08.55-.18.55-.39 0-.19-.01-.83-.01-1.5-2.01.38-2.53-.5-2.69-.96-.09-.23-.48-.96-.82-1.15-.28-.15-.68-.53-.01-.54.63-.01 1.08.59 1.23.83.72 1.23 1.87.88 2.33.67.07-.53.28-.88.51-1.08-1.78-.21-3.64-.91-3.64-4.02 0-.89.31-1.62.82-2.19-.08-.2-.36-1.04.08-2.16 0 0 .67-.22 2.2.84A7.44 7.44 0 0 1 8 3.88c.68 0 1.36.09 2 .28 1.53-1.06 2.2-.84 2.2-.84.44 1.12.16 1.96.08 2.16.51.57.82 1.3.82 2.19 0 3.12-1.87 3.81-3.65 4.02.29.25.54.74.54 1.51 0 1.09-.01 1.97-.01 2.25 0 .21.15.47.55.39A8.09 8.09 0 0 0 16 8.13C16 3.64 12.42 0 8 0Z"/>
556
+ </svg>
557
+ <span>GitHub</span>
558
+ </a>
559
+ <a href="https://www.npmjs.com/package/@causyne/agent" class="nav-link" target="_blank" rel="noopener noreferrer" title="Causyne Agent on npm">
560
+ <svg class="nav-icon npm-icon" viewBox="0 0 780 250" width="34" height="11" aria-hidden="true">
561
+ <path fill="currentColor" d="M240,250h100v-50h100V0H240V250z M340,50h50v100h-50V50z M480,0v200h100V50h50v150h50V50h50v150h50V0H480z M0,200h100V50h50v150h50V0H0V200z"/>
562
+ </svg>
563
+ </a>
564
+ </nav>
565
+ </header>
566
+
567
+ <main class="content">
568
+ <div class="hero-grid">
569
+ <div>
570
+ <h1 class="hero-title">${isSuccess ? 'Account connected.' : 'Authorization error.'}</h1>
571
+ <p class="hero-lead">
572
+ ${isSuccess
573
+ ? 'OpenRouter Free inference endpoint is now authorized for Causyne Agent. You can close this browser tab and return to your terminal session.'
574
+ : (options.message || 'The authorization flow could not be completed.')}
575
+ </p>
576
+ <div class="hero-slogan">
577
+ <span>Causyne Agent · Agentic AI Harness · From intention to meaningful progress.</span>
578
+ </div>
579
+ </div>
580
+
581
+ <aside class="autonomy-panel" aria-label="Authorization details">
582
+ ${badgeHtml}
583
+ <div class="panel-heading">${title}</div>
584
+ <p class="panel-message">${message}</p>
585
+ ${contentBox}
586
+ ${actionButton}
587
+ </aside>
257
588
  </div>
258
- </div>
259
- <div class="card">
260
- ${badgeHtml}
261
- <h1>${title}</h1>
262
- <p>${message}</p>
263
- ${contentBox}
264
- ${actionButton}
265
- </div>
589
+ </main>
590
+
591
+ <footer class="site-footer">
592
+ <span>Causyne Agent is in development.</span>
593
+ <a href="https://causyne.com" target="_blank" rel="noopener noreferrer">causyne.com</a>
594
+ </footer>
266
595
  </div>
267
596
  </body>
268
597
  </html>`;
@@ -343,18 +672,32 @@ export async function startLoopbackAuth(options = {}) {
343
672
  }
344
673
  return;
345
674
  }
346
- // Send friendly HTML response to user's browser
347
- res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
348
- res.end(renderAuthPage({
349
- status: 'success',
350
- model: OPENROUTER_FREE_MODEL
351
- }));
352
- // Perform token exchange
353
- const apiKey = await exchangeCodeForApiKey(code, pkce.codeVerifier, fetchFn);
354
- if (!resolved) {
355
- resolved = true;
356
- setTimeout(cleanup, 1200);
357
- resolve({ apiKey });
675
+ // Perform token exchange first before confirming success to the browser
676
+ try {
677
+ const apiKey = await exchangeCodeForApiKey(code, pkce.codeVerifier, fetchFn);
678
+ res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
679
+ res.end(renderAuthPage({
680
+ status: 'success',
681
+ model: OPENROUTER_FREE_MODEL
682
+ }));
683
+ if (!resolved) {
684
+ resolved = true;
685
+ setTimeout(cleanup, 1200);
686
+ resolve({ apiKey });
687
+ }
688
+ }
689
+ catch (exchangeErr) {
690
+ res.writeHead(400, { 'Content-Type': 'text/html; charset=utf-8' });
691
+ res.end(renderAuthPage({
692
+ status: 'error',
693
+ title: 'OpenRouter Token Exchange Failed',
694
+ errorDetail: exchangeErr?.message || 'Could not complete token exchange with OpenRouter.'
695
+ }));
696
+ if (!resolved) {
697
+ resolved = true;
698
+ cleanup();
699
+ reject(exchangeErr);
700
+ }
358
701
  }
359
702
  }
360
703
  catch (err) {