@causyne/agent 1.20.72 → 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 +106 -66
- package/src/auth/openrouterAuth.ts +106 -66
- package/src/tui/consoleGuard.js +33 -0
- package/src/tui/consoleGuard.ts +34 -0
- package/src/tui/modelPicker.js +21 -14
- package/src/tui/modelPicker.ts +21 -14
- 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">
|
|
@@ -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">
|
package/src/tui/consoleGuard.js
CHANGED
|
@@ -10,6 +10,23 @@ const originalConsole = {
|
|
|
10
10
|
const originalStderrWrite = process.stderr?.write
|
|
11
11
|
? process.stderr.write.bind(process.stderr)
|
|
12
12
|
: null;
|
|
13
|
+
const originalStdoutWrite = process.stdout?.write
|
|
14
|
+
? process.stdout.write.bind(process.stdout)
|
|
15
|
+
: null;
|
|
16
|
+
let stageInternalWriting = false;
|
|
17
|
+
/**
|
|
18
|
+
* Run a write operation with permission to write to stdout during Stage sessions.
|
|
19
|
+
*/
|
|
20
|
+
export function runWithStageWrite(fn) {
|
|
21
|
+
const prev = stageInternalWriting;
|
|
22
|
+
stageInternalWriting = true;
|
|
23
|
+
try {
|
|
24
|
+
return fn();
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
stageInternalWriting = prev;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
13
30
|
export function isAnyStageReservedOnStdout() {
|
|
14
31
|
if (stageMouseSessionDepth > 0 && process.stdout?.isTTY) {
|
|
15
32
|
return true;
|
|
@@ -50,6 +67,22 @@ function ensureConsoleGuardInstalled() {
|
|
|
50
67
|
return originalStderrWrite(chunk, encodingOrCb, cb);
|
|
51
68
|
});
|
|
52
69
|
}
|
|
70
|
+
if (originalStdoutWrite && process.stdout) {
|
|
71
|
+
process.stdout.write = ((chunk, encodingOrCb, cb) => {
|
|
72
|
+
if (isAnyStageReservedOnStdout() && !stageInternalWriting) {
|
|
73
|
+
// Prevent rogue unmanaged writes from emitting bare newlines that scroll the stage
|
|
74
|
+
const text = String(chunk ?? '');
|
|
75
|
+
if (text.includes('\n')) {
|
|
76
|
+
if (typeof encodingOrCb === 'function')
|
|
77
|
+
encodingOrCb();
|
|
78
|
+
else if (typeof cb === 'function')
|
|
79
|
+
cb();
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return originalStdoutWrite(chunk, encodingOrCb, cb);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
53
86
|
}
|
|
54
87
|
/**
|
|
55
88
|
* Track TUI Stage open/close lifecycle so raw console writes cannot corrupt the composer box.
|
package/src/tui/consoleGuard.ts
CHANGED
|
@@ -23,6 +23,25 @@ const originalStderrWrite = process.stderr?.write
|
|
|
23
23
|
? process.stderr.write.bind(process.stderr)
|
|
24
24
|
: null;
|
|
25
25
|
|
|
26
|
+
const originalStdoutWrite = process.stdout?.write
|
|
27
|
+
? process.stdout.write.bind(process.stdout)
|
|
28
|
+
: null;
|
|
29
|
+
|
|
30
|
+
let stageInternalWriting = false;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Run a write operation with permission to write to stdout during Stage sessions.
|
|
34
|
+
*/
|
|
35
|
+
export function runWithStageWrite<T>(fn: () => T): T {
|
|
36
|
+
const prev = stageInternalWriting;
|
|
37
|
+
stageInternalWriting = true;
|
|
38
|
+
try {
|
|
39
|
+
return fn();
|
|
40
|
+
} finally {
|
|
41
|
+
stageInternalWriting = prev;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
26
45
|
export function isAnyStageReservedOnStdout(): boolean {
|
|
27
46
|
if (stageMouseSessionDepth > 0 && process.stdout?.isTTY) {
|
|
28
47
|
return true;
|
|
@@ -64,6 +83,21 @@ function ensureConsoleGuardInstalled(): void {
|
|
|
64
83
|
return (originalStderrWrite as (...a: unknown[]) => boolean)(chunk, encodingOrCb, cb);
|
|
65
84
|
}) as typeof process.stderr.write;
|
|
66
85
|
}
|
|
86
|
+
|
|
87
|
+
if (originalStdoutWrite && process.stdout) {
|
|
88
|
+
process.stdout.write = ((chunk: unknown, encodingOrCb?: unknown, cb?: unknown): boolean => {
|
|
89
|
+
if (isAnyStageReservedOnStdout() && !stageInternalWriting) {
|
|
90
|
+
// Prevent rogue unmanaged writes from emitting bare newlines that scroll the stage
|
|
91
|
+
const text = String(chunk ?? '');
|
|
92
|
+
if (text.includes('\n')) {
|
|
93
|
+
if (typeof encodingOrCb === 'function') (encodingOrCb as () => void)();
|
|
94
|
+
else if (typeof cb === 'function') (cb as () => void)();
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return (originalStdoutWrite as (...a: unknown[]) => boolean)(chunk, encodingOrCb, cb);
|
|
99
|
+
}) as typeof process.stdout.write;
|
|
100
|
+
}
|
|
67
101
|
}
|
|
68
102
|
|
|
69
103
|
/**
|
package/src/tui/modelPicker.js
CHANGED
|
@@ -10,17 +10,19 @@ import { paint, bold, dim, GLYPHS } from './theme.js';
|
|
|
10
10
|
import { fuzzyFilter } from './selectList.js';
|
|
11
11
|
import { loadConfig, saveConfig } from '../config.js';
|
|
12
12
|
import { startLoopbackAuth, saveOpenRouterKey, disconnectOpenRouter } from '../auth/openrouterAuth.js';
|
|
13
|
+
import { setTransientNotice } from './consoleGuard.js';
|
|
13
14
|
import { getAvailableProvidersOverview, resolveAvailableProvidersOverview, resolveAvailableModels } from '../dynamicCatalogue.js';
|
|
14
|
-
async function showConfiguringAnimation(providerLabel) {
|
|
15
|
-
if (
|
|
15
|
+
async function showConfiguringAnimation(providerLabel, promptHost) {
|
|
16
|
+
if (promptHost && typeof promptHost.scheduleDraw === 'function') {
|
|
17
|
+
promptHost.notice = `Configuring ${providerLabel} in secure local vault…`;
|
|
18
|
+
promptHost.scheduleDraw();
|
|
19
|
+
await new Promise(r => setTimeout(r, 120));
|
|
20
|
+
promptHost.notice = `✓ ${providerLabel} credentials saved.`;
|
|
21
|
+
promptHost.scheduleDraw();
|
|
16
22
|
return;
|
|
17
|
-
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
18
|
-
const text = `Configuring ${providerLabel} in secure local vault…`;
|
|
19
|
-
for (let i = 0; i < 5; i++) {
|
|
20
|
-
const f = frames[i % frames.length];
|
|
21
|
-
process.stdout.write(`\r \x1b[36m${f}\x1b[0m ${text}`);
|
|
22
|
-
await new Promise(r => setTimeout(r, 60));
|
|
23
23
|
}
|
|
24
|
+
if (!process.stdout.isTTY)
|
|
25
|
+
return;
|
|
24
26
|
process.stdout.write(`\r\x1b[K \x1b[32m✓\x1b[0m ${providerLabel} credentials saved.\n`);
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
@@ -536,10 +538,7 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
536
538
|
if (!cleanInput) {
|
|
537
539
|
// User pressed Enter on empty placeholder: run OAuth PKCE loopback flow!
|
|
538
540
|
try {
|
|
539
|
-
|
|
540
|
-
process.stdout.write('\r \x1b[36m●\x1b[0m Opening browser for OpenRouter OAuth authorization…\n');
|
|
541
|
-
process.stdout.write(' \x1b[90mWaiting for authorization on 127.0.0.1 (timeout: 120s)…\x1b[0m\n');
|
|
542
|
-
}
|
|
541
|
+
setTransientNotice(prompt, '● Opening browser for OpenRouter OAuth authorization… (Waiting on 127.0.0.1)', 120_000);
|
|
543
542
|
const { apiKey } = await startLoopbackAuth({ timeoutMs: 120_000, openBrowser: true });
|
|
544
543
|
saveOpenRouterKey(apiKey, { setAsActive: true, store });
|
|
545
544
|
const updatedConfig = store.loadConfig();
|
|
@@ -550,9 +549,17 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
550
549
|
}
|
|
551
550
|
}
|
|
552
551
|
notifyPrompt('openrouter', target.modelId);
|
|
552
|
+
setTransientNotice(prompt, `✓ Connected to OpenRouter successfully! Using OpenRouter Free / ${target.modelId}.`, 5000);
|
|
553
|
+
if (prompt.surface?.stage) {
|
|
554
|
+
prompt.surface.stage.invalidate();
|
|
555
|
+
}
|
|
556
|
+
if (typeof prompt.scheduleDraw === 'function') {
|
|
557
|
+
prompt.scheduleDraw();
|
|
558
|
+
}
|
|
553
559
|
return `✓ Connected to OpenRouter successfully! Now using OpenRouter Free / ${target.modelId}.`;
|
|
554
560
|
}
|
|
555
561
|
catch (err) {
|
|
562
|
+
setTransientNotice(prompt, `✕ OpenRouter authorization failed: ${err?.message || err}`, 6000);
|
|
556
563
|
return (`✕ OpenRouter authorization failed: ${err?.message || err}\n\n` +
|
|
557
564
|
`Solutions:\n` +
|
|
558
565
|
`1. Check that your browser can open local URLs (http://127.0.0.1).\n` +
|
|
@@ -562,7 +569,7 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
562
569
|
}
|
|
563
570
|
}
|
|
564
571
|
// User pasted an API key
|
|
565
|
-
await showConfiguringAnimation('OpenRouter');
|
|
572
|
+
await showConfiguringAnimation('OpenRouter', prompt);
|
|
566
573
|
saveOpenRouterKey(cleanInput, { setAsActive: true, store });
|
|
567
574
|
const updatedConfig = store.loadConfig();
|
|
568
575
|
if (options.loop) {
|
|
@@ -628,7 +635,7 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
628
635
|
return `Cancelled. An API key is required to use ${target.providerLabel} / ${target.modelId}. Model was not changed.`;
|
|
629
636
|
}
|
|
630
637
|
const cleanKey = enteredKey.trim();
|
|
631
|
-
await showConfiguringAnimation(target.providerLabel);
|
|
638
|
+
await showConfiguringAnimation(target.providerLabel, prompt);
|
|
632
639
|
config['provider'] = target.providerId;
|
|
633
640
|
config['model'] = target.modelId;
|
|
634
641
|
config['apiKey'] = cleanKey;
|
package/src/tui/modelPicker.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { paint, bold, dim, GLYPHS } from './theme.js';
|
|
|
11
11
|
import { fuzzyFilter } from './selectList.js';
|
|
12
12
|
import { loadConfig, saveConfig } from '../config.js';
|
|
13
13
|
import { startLoopbackAuth, saveOpenRouterKey, disconnectOpenRouter } from '../auth/openrouterAuth.js';
|
|
14
|
+
import { setTransientNotice } from './consoleGuard.js';
|
|
14
15
|
import {
|
|
15
16
|
getAvailableProvidersOverview,
|
|
16
17
|
resolveAvailableProvidersOverview,
|
|
@@ -66,15 +67,16 @@ export interface BuildModelPickerOptions {
|
|
|
66
67
|
maxAcpPerPeer?: number | undefined;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
async function showConfiguringAnimation(providerLabel: string): Promise<void> {
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
async function showConfiguringAnimation(providerLabel: string, promptHost?: any): Promise<void> {
|
|
71
|
+
if (promptHost && typeof promptHost.scheduleDraw === 'function') {
|
|
72
|
+
promptHost.notice = `Configuring ${providerLabel} in secure local vault…`;
|
|
73
|
+
promptHost.scheduleDraw();
|
|
74
|
+
await new Promise(r => setTimeout(r, 120));
|
|
75
|
+
promptHost.notice = `✓ ${providerLabel} credentials saved.`;
|
|
76
|
+
promptHost.scheduleDraw();
|
|
77
|
+
return;
|
|
77
78
|
}
|
|
79
|
+
if (!process.stdout.isTTY) return;
|
|
78
80
|
process.stdout.write(`\r\x1b[K \x1b[32m✓\x1b[0m ${providerLabel} credentials saved.\n`);
|
|
79
81
|
}
|
|
80
82
|
|
|
@@ -647,10 +649,7 @@ export async function runInteractiveModelPicker(
|
|
|
647
649
|
if (!cleanInput) {
|
|
648
650
|
// User pressed Enter on empty placeholder: run OAuth PKCE loopback flow!
|
|
649
651
|
try {
|
|
650
|
-
|
|
651
|
-
process.stdout.write('\r \x1b[36m●\x1b[0m Opening browser for OpenRouter OAuth authorization…\n');
|
|
652
|
-
process.stdout.write(' \x1b[90mWaiting for authorization on 127.0.0.1 (timeout: 120s)…\x1b[0m\n');
|
|
653
|
-
}
|
|
652
|
+
setTransientNotice(prompt as any, '● Opening browser for OpenRouter OAuth authorization… (Waiting on 127.0.0.1)', 120_000);
|
|
654
653
|
const { apiKey } = await startLoopbackAuth({ timeoutMs: 120_000, openBrowser: true });
|
|
655
654
|
saveOpenRouterKey(apiKey, { setAsActive: true, store });
|
|
656
655
|
|
|
@@ -662,8 +661,16 @@ export async function runInteractiveModelPicker(
|
|
|
662
661
|
}
|
|
663
662
|
}
|
|
664
663
|
notifyPrompt('openrouter', target.modelId);
|
|
664
|
+
setTransientNotice(prompt as any, `✓ Connected to OpenRouter successfully! Using OpenRouter Free / ${target.modelId}.`, 5000);
|
|
665
|
+
if ((prompt as any).surface?.stage) {
|
|
666
|
+
(prompt as any).surface.stage.invalidate();
|
|
667
|
+
}
|
|
668
|
+
if (typeof (prompt as any).scheduleDraw === 'function') {
|
|
669
|
+
(prompt as any).scheduleDraw();
|
|
670
|
+
}
|
|
665
671
|
return `✓ Connected to OpenRouter successfully! Now using OpenRouter Free / ${target.modelId}.`;
|
|
666
672
|
} catch (err: any) {
|
|
673
|
+
setTransientNotice(prompt as any, `✕ OpenRouter authorization failed: ${err?.message || err}`, 6000);
|
|
667
674
|
return (
|
|
668
675
|
`✕ OpenRouter authorization failed: ${err?.message || err}\n\n` +
|
|
669
676
|
`Solutions:\n` +
|
|
@@ -676,7 +683,7 @@ export async function runInteractiveModelPicker(
|
|
|
676
683
|
}
|
|
677
684
|
|
|
678
685
|
// User pasted an API key
|
|
679
|
-
await showConfiguringAnimation('OpenRouter');
|
|
686
|
+
await showConfiguringAnimation('OpenRouter', prompt);
|
|
680
687
|
saveOpenRouterKey(cleanInput, { setAsActive: true, store });
|
|
681
688
|
const updatedConfig = store.loadConfig();
|
|
682
689
|
if (options.loop) {
|
|
@@ -747,7 +754,7 @@ export async function runInteractiveModelPicker(
|
|
|
747
754
|
}
|
|
748
755
|
|
|
749
756
|
const cleanKey = enteredKey.trim();
|
|
750
|
-
await showConfiguringAnimation(target.providerLabel);
|
|
757
|
+
await showConfiguringAnimation(target.providerLabel, prompt);
|
|
751
758
|
|
|
752
759
|
config['provider'] = target.providerId;
|
|
753
760
|
config['model'] = target.modelId;
|
package/src/tui/stage.js
CHANGED
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
// Pure Node: no dependency, no shell.
|
|
34
34
|
|
|
35
35
|
import { visibleWidth, truncate } from './text.js';
|
|
36
|
+
import { runWithStageWrite } from './consoleGuard.js';
|
|
36
37
|
|
|
37
38
|
// Below this the band cannot hold a viewport plus an input box plus a footer,
|
|
38
39
|
// and a cramped stage is worse than honest scrollback. The fallback is not a
|
|
@@ -133,7 +134,11 @@ export class Stage {
|
|
|
133
134
|
write(text) {
|
|
134
135
|
if (!text) return;
|
|
135
136
|
this.stats.bytes += text.length;
|
|
136
|
-
|
|
137
|
+
if (typeof runWithStageWrite === 'function') {
|
|
138
|
+
runWithStageWrite(() => this.out.write(text));
|
|
139
|
+
} else {
|
|
140
|
+
this.out.write(text);
|
|
141
|
+
}
|
|
137
142
|
}
|
|
138
143
|
|
|
139
144
|
/**
|
package/src/tui/stageSurface.js
CHANGED
|
@@ -392,9 +392,6 @@ export class StageSurface {
|
|
|
392
392
|
* the contract in transcript.js.
|
|
393
393
|
*/
|
|
394
394
|
commit(kind, produce, meta = null) {
|
|
395
|
-
if (kind === 'error' || kind === 'turn' || kind === 'approval') {
|
|
396
|
-
this.stage.invalidate();
|
|
397
|
-
}
|
|
398
395
|
return this.transcript.append({ kind, produce, meta });
|
|
399
396
|
}
|
|
400
397
|
|
|
@@ -441,17 +438,23 @@ export class StageSurface {
|
|
|
441
438
|
// entered from Home occupies the available height at every terminal width.
|
|
442
439
|
// Its short transcript is placed next to the input below.
|
|
443
440
|
const contentRows = this.transcript.height(contentWidth);
|
|
444
|
-
const
|
|
441
|
+
const minFloor = contentRows > 0 ? MIN_VIEWPORT_ROWS : 0;
|
|
442
|
+
const neededWithFloor = Math.min(this.stage.maxHeight, block.length + minFloor);
|
|
443
|
+
const desired = Math.max(
|
|
444
|
+
sessionStageHeight(this.stage.maxHeight, block.length, contentRows, this.fullSession || caret?.inline),
|
|
445
|
+
neededWithFloor
|
|
446
|
+
);
|
|
445
447
|
if (desired > this.stage.height) this.stage.grow(desired - this.stage.height);
|
|
446
448
|
|
|
447
449
|
const height = this.stage.height;
|
|
448
450
|
|
|
449
|
-
//
|
|
450
|
-
//
|
|
451
|
-
//
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
451
|
+
// The prompt may not eat the whole band — but only once there is a
|
|
452
|
+
// transcript for it to eat. Trim from the TOP when it would: the status
|
|
453
|
+
// footer and the caret row are the last rows and the ones worth keeping,
|
|
454
|
+
// and an input box that has scrolled its own oldest row off is a smaller lie
|
|
455
|
+
// than a transcript that has vanished.
|
|
456
|
+
const floor = contentRows > 0 ? MIN_VIEWPORT_ROWS : 0;
|
|
457
|
+
const maxBlock = Math.max(1, height - floor);
|
|
455
458
|
if (block.length > maxBlock) {
|
|
456
459
|
const cut = block.length - maxBlock;
|
|
457
460
|
block = block.slice(cut);
|