@causyne/agent 1.20.73 → 1.20.75
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/agentLoop.js +28 -1
- package/src/agentLoop.ts +28 -1
- package/src/assets/logo.png +0 -0
- package/src/auth/openrouterAuth.js +412 -109
- package/src/auth/openrouterAuth.ts +416 -113
- package/src/browser/causyneBrowser.js +34 -17
- package/src/browser/causyneBrowser.ts +35 -17
- package/src/providers/openrouter.js +42 -1
- package/src/providers/openrouter.ts +43 -1
- package/src/tools/sysRun.js +24 -2
- package/src/tools/sysRun.ts +19 -2
- package/src/tools/toolSelfRepair.js +32 -2
- package/src/tools/toolSelfRepair.ts +26 -2
|
@@ -102,7 +102,7 @@ export function getLogoBuffer() {
|
|
|
102
102
|
const candidates = [
|
|
103
103
|
path.resolve(currentDir, '../assets/logo.png'),
|
|
104
104
|
path.resolve(currentDir, '../../assets/logo.png'),
|
|
105
|
-
path.resolve(currentDir, '
|
|
105
|
+
path.resolve(currentDir, '../../src/assets/logo.png'),
|
|
106
106
|
path.resolve(process.cwd(), 'src/assets/logo.png'),
|
|
107
107
|
path.resolve(process.cwd(), 'assets/logo.png')
|
|
108
108
|
];
|
|
@@ -124,43 +124,112 @@ export function getLogoBase64() {
|
|
|
124
124
|
const buf = getLogoBuffer();
|
|
125
125
|
return buf ? buf.toString('base64') : '';
|
|
126
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');
|
|
127
198
|
/**
|
|
128
199
|
* Render a professional branded HTML response page for OpenRouter OAuth callbacks
|
|
129
|
-
* following the exact visual style and design language of causyne.com.
|
|
200
|
+
* following the exact visual style, typography, and design language of causyne.com.
|
|
130
201
|
*/
|
|
131
202
|
export function renderAuthPage(options) {
|
|
132
203
|
const isSuccess = options.status === 'success';
|
|
133
|
-
const base64Logo = getLogoBase64();
|
|
134
|
-
const logoSrc = base64Logo ? `data:image/png;base64,${base64Logo}` : '/logo.png';
|
|
135
204
|
const badgeHtml = isSuccess
|
|
136
|
-
? '<div
|
|
137
|
-
'
|
|
138
|
-
'
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
'
|
|
142
|
-
'padding:5px 14px;border-radius:4px;font-size:12px;font-family:\'SF Mono\',Menlo,monospace;font-weight:600;margin-bottom:20px;">' +
|
|
143
|
-
'✕ 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>';
|
|
144
211
|
const title = options.title || (isSuccess ? 'OpenRouter Account Authorized' : 'Authorization Error');
|
|
145
212
|
const defaultMsg = isSuccess
|
|
146
213
|
? 'Your OpenRouter account is now authorized and connected to Causyne Agent. You can close this window and return to your terminal.'
|
|
147
214
|
: 'The authorization flow could not be completed.';
|
|
148
215
|
const message = options.message || defaultMsg;
|
|
149
216
|
const contentBox = isSuccess
|
|
150
|
-
? '<div
|
|
151
|
-
'
|
|
152
|
-
'
|
|
153
|
-
'<
|
|
154
|
-
'<span style="color:#9da697;">Provider</span>' +
|
|
155
|
-
'<span style="color:#e4e8e0;font-weight:600;">OpenRouter</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>' +
|
|
156
221
|
'</div>' +
|
|
157
|
-
'<div style="
|
|
158
|
-
'<span
|
|
159
|
-
`<span
|
|
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>` +
|
|
160
225
|
'</div>' +
|
|
161
|
-
'<div style="
|
|
162
|
-
'<span
|
|
163
|
-
'<span style="color:#9da697;">
|
|
226
|
+
'<div class="meta-row" style="margin-bottom:8px;">' +
|
|
227
|
+
'<span class="meta-label">Routing Tier</span>' +
|
|
228
|
+
'<span class="meta-val" style="color:#9da697;">Community Free Inference (Zero Cost)</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>' +
|
|
164
233
|
'</div>' +
|
|
165
234
|
'</div>'
|
|
166
235
|
: '<div style="background:#191c19;border:1px solid rgba(239,83,80,0.25);' +
|
|
@@ -178,16 +247,12 @@ export function renderAuthPage(options) {
|
|
|
178
247
|
'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>' +
|
|
179
248
|
'</div>';
|
|
180
249
|
const actionButton = isSuccess
|
|
181
|
-
? '<button id="return-btn" onclick="returnToTerminal()"
|
|
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;">' +
|
|
250
|
+
? '<button id="return-btn" class="btn-primary" onclick="returnToTerminal()">' +
|
|
184
251
|
'Return to Terminal</button>' +
|
|
185
|
-
'<div id="return-hint"
|
|
252
|
+
'<div id="return-hint" class="return-hint">' +
|
|
186
253
|
'Authentication complete. You can close this browser tab (⌘W / Ctrl+W) and switch back to your terminal.' +
|
|
187
254
|
'</div>'
|
|
188
|
-
: '<button onclick="window.close()"
|
|
189
|
-
'padding:10px 22px;border-radius:4px;font-size:13px;font-weight:600;cursor:pointer;' +
|
|
190
|
-
'font-family:\'SF Mono\',Menlo,monospace;">' +
|
|
255
|
+
: '<button class="btn-secondary" onclick="window.close()">' +
|
|
191
256
|
'Close Window</button>';
|
|
192
257
|
return `<!DOCTYPE html>
|
|
193
258
|
<html lang="en">
|
|
@@ -195,77 +260,268 @@ export function renderAuthPage(options) {
|
|
|
195
260
|
<meta charset="utf-8">
|
|
196
261
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
197
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">
|
|
198
266
|
<style>
|
|
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
|
+
}
|
|
199
281
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
200
282
|
body {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
283
|
+
background-color: var(--bg);
|
|
284
|
+
color: var(--text-primary);
|
|
285
|
+
font-family: var(--font-mono);
|
|
204
286
|
min-height: 100vh;
|
|
205
287
|
display: flex;
|
|
206
|
-
|
|
207
|
-
justify-content:
|
|
208
|
-
padding:
|
|
288
|
+
flex-direction: column;
|
|
289
|
+
justify-content: space-between;
|
|
290
|
+
padding: 0 32px;
|
|
291
|
+
-webkit-font-smoothing: antialiased;
|
|
209
292
|
}
|
|
210
|
-
.
|
|
211
|
-
max-width:
|
|
293
|
+
.page {
|
|
294
|
+
max-width: var(--max-w);
|
|
212
295
|
width: 100%;
|
|
213
|
-
|
|
296
|
+
margin: 0 auto;
|
|
214
297
|
}
|
|
215
|
-
.header {
|
|
298
|
+
.site-header {
|
|
299
|
+
padding: 40px 0 32px;
|
|
216
300
|
display: flex;
|
|
217
301
|
align-items: center;
|
|
218
|
-
justify-content:
|
|
302
|
+
justify-content: space-between;
|
|
303
|
+
border-bottom: 1px solid var(--border);
|
|
304
|
+
}
|
|
305
|
+
.brand {
|
|
306
|
+
display: inline-flex;
|
|
307
|
+
align-items: center;
|
|
219
308
|
gap: 14px;
|
|
220
|
-
|
|
309
|
+
text-decoration: none;
|
|
221
310
|
}
|
|
222
|
-
.logo {
|
|
223
|
-
width:
|
|
224
|
-
height:
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
.brand-
|
|
228
|
-
font-family: -
|
|
229
|
-
font-size:
|
|
230
|
-
font-weight:
|
|
231
|
-
letter-spacing:
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
font-family:
|
|
246
|
-
font-size:
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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;
|
|
321
|
+
text-transform: uppercase;
|
|
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;
|
|
370
|
+
font-weight: 700;
|
|
371
|
+
line-height: 1.18;
|
|
372
|
+
letter-spacing: -0.02em;
|
|
373
|
+
color: var(--text-primary);
|
|
374
|
+
margin-bottom: 20px;
|
|
375
|
+
}
|
|
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);
|
|
254
403
|
border-radius: 8px;
|
|
255
404
|
padding: 32px 28px;
|
|
256
405
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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;
|
|
260
430
|
font-weight: 700;
|
|
431
|
+
color: var(--text-primary);
|
|
261
432
|
margin-bottom: 10px;
|
|
262
|
-
letter-spacing: -0.
|
|
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;
|
|
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;
|
|
263
457
|
}
|
|
264
|
-
|
|
265
|
-
|
|
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;
|
|
266
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;
|
|
267
505
|
line-height: 1.6;
|
|
268
|
-
|
|
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);
|
|
269
525
|
}
|
|
270
526
|
</style>
|
|
271
527
|
<script>
|
|
@@ -287,22 +543,55 @@ export function renderAuthPage(options) {
|
|
|
287
543
|
</script>
|
|
288
544
|
</head>
|
|
289
545
|
<body>
|
|
290
|
-
<div class="
|
|
291
|
-
<
|
|
292
|
-
<
|
|
293
|
-
|
|
294
|
-
<
|
|
295
|
-
|
|
296
|
-
|
|
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>
|
|
297
588
|
</div>
|
|
298
|
-
</
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
<
|
|
302
|
-
<
|
|
303
|
-
|
|
304
|
-
${actionButton}
|
|
305
|
-
</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>
|
|
306
595
|
</div>
|
|
307
596
|
</body>
|
|
308
597
|
</html>`;
|
|
@@ -383,18 +672,32 @@ export async function startLoopbackAuth(options = {}) {
|
|
|
383
672
|
}
|
|
384
673
|
return;
|
|
385
674
|
}
|
|
386
|
-
//
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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
|
+
}
|
|
398
701
|
}
|
|
399
702
|
}
|
|
400
703
|
catch (err) {
|