@commit451/salamander 1.0.9 → 1.1.1
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/README.md +3 -16
- package/dist/commands/runner-selection.d.ts.map +1 -1
- package/dist/commands/runner-selection.js +4 -52
- package/dist/commands/runner-selection.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -1
- package/dist/services/api.d.ts +1 -0
- package/dist/services/api.d.ts.map +1 -1
- package/dist/services/api.js.map +1 -1
- package/dist/services/auth.d.ts +4 -6
- package/dist/services/auth.d.ts.map +1 -1
- package/dist/services/auth.js +85 -202
- package/dist/services/auth.js.map +1 -1
- package/dist/services/command-listener.d.ts +2 -0
- package/dist/services/command-listener.d.ts.map +1 -1
- package/dist/services/command-listener.js +54 -6
- package/dist/services/command-listener.js.map +1 -1
- package/dist/services/executor.d.ts.map +1 -1
- package/dist/services/executor.js +8 -1
- package/dist/services/executor.js.map +1 -1
- package/dist/services/runner.d.ts +1 -0
- package/dist/services/runner.d.ts.map +1 -1
- package/dist/services/runner.js +10 -6
- package/dist/services/runner.js.map +1 -1
- package/dist/services/user.d.ts.map +1 -1
- package/dist/services/user.js +0 -3
- package/dist/services/user.js.map +1 -1
- package/dist/types/runner.d.ts +0 -12
- package/dist/types/runner.d.ts.map +1 -1
- package/dist/utils/encryption.d.ts +0 -4
- package/dist/utils/encryption.d.ts.map +1 -1
- package/dist/utils/encryption.js +0 -7
- package/dist/utils/encryption.js.map +1 -1
- package/dist/utils/storage.d.ts +3 -8
- package/dist/utils/storage.d.ts.map +1 -1
- package/dist/utils/storage.js +5 -13
- package/dist/utils/storage.js.map +1 -1
- package/package.json +1 -1
package/dist/services/auth.js
CHANGED
|
@@ -4,17 +4,55 @@ import { createServer } from 'http';
|
|
|
4
4
|
import { URL } from 'url';
|
|
5
5
|
import { exec } from 'child_process';
|
|
6
6
|
import { promisify } from 'util';
|
|
7
|
-
import {
|
|
8
|
-
import { getAuth, GoogleAuthProvider, onAuthStateChanged, signInWithCredential } from 'firebase/auth';
|
|
7
|
+
import { getAuth, onAuthStateChanged, signInWithCustomToken } from 'firebase/auth';
|
|
9
8
|
import app from '../config/firebase.js';
|
|
10
9
|
const execAsync = promisify(exec);
|
|
11
10
|
const auth = getAuth(app);
|
|
12
11
|
export class AuthService {
|
|
13
12
|
static currentUser = null;
|
|
14
|
-
static customUserInfo = null;
|
|
15
13
|
static authStateInitialized = false;
|
|
16
14
|
static authStateReady = null;
|
|
17
|
-
static
|
|
15
|
+
static WEB_APP_URL = 'https://salamander.space';
|
|
16
|
+
static generateAuthResponseHTML(isSuccess, title, message) {
|
|
17
|
+
const headingColor = isSuccess ? '#10b981' : '#f87171';
|
|
18
|
+
return `
|
|
19
|
+
<!DOCTYPE html>
|
|
20
|
+
<html>
|
|
21
|
+
<head>
|
|
22
|
+
<title>${title}</title>
|
|
23
|
+
<style>
|
|
24
|
+
body {
|
|
25
|
+
background-color: #111827;
|
|
26
|
+
color: #f9fafb;
|
|
27
|
+
font-family: 'Fira Code', 'JetBrains Mono', monospace;
|
|
28
|
+
text-align: center;
|
|
29
|
+
padding: 50px;
|
|
30
|
+
margin: 0;
|
|
31
|
+
}
|
|
32
|
+
h1 { color: ${headingColor}; }
|
|
33
|
+
.logo {
|
|
34
|
+
width: 48px;
|
|
35
|
+
height: 48px;
|
|
36
|
+
margin: 0 auto 24px;
|
|
37
|
+
background: #ff6b35;
|
|
38
|
+
border-radius: 8px;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
font-size: 24px;
|
|
43
|
+
color: white;
|
|
44
|
+
font-weight: bold;
|
|
45
|
+
}
|
|
46
|
+
</style>
|
|
47
|
+
</head>
|
|
48
|
+
<body>
|
|
49
|
+
<div class="logo">S</div>
|
|
50
|
+
<h1>${title}</h1>
|
|
51
|
+
<p>${message}</p>
|
|
52
|
+
</body>
|
|
53
|
+
</html>
|
|
54
|
+
`;
|
|
55
|
+
}
|
|
18
56
|
static async openBrowser(url) {
|
|
19
57
|
const platform = process.platform;
|
|
20
58
|
let command;
|
|
@@ -23,7 +61,7 @@ export class AuthService {
|
|
|
23
61
|
command = `open "${url}"`;
|
|
24
62
|
break;
|
|
25
63
|
case 'win32':
|
|
26
|
-
command = `start "${url}"`;
|
|
64
|
+
command = `cmd /c start "" "${url}"`;
|
|
27
65
|
break;
|
|
28
66
|
default:
|
|
29
67
|
command = `xdg-open "${url}"`;
|
|
@@ -35,126 +73,48 @@ export class AuthService {
|
|
|
35
73
|
console.log(chalk.yellow(`⚠️ Could not open browser automatically. Please visit: ${url}`));
|
|
36
74
|
}
|
|
37
75
|
}
|
|
38
|
-
static async
|
|
76
|
+
static async startLocalServerForToken() {
|
|
39
77
|
return new Promise((resolve, reject) => {
|
|
40
78
|
const server = createServer();
|
|
41
|
-
let
|
|
42
|
-
let
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
79
|
+
let tokenResolve;
|
|
80
|
+
let tokenReject;
|
|
81
|
+
const tokenPromise = new Promise((res, rej) => {
|
|
82
|
+
tokenResolve = res;
|
|
83
|
+
tokenReject = rej;
|
|
46
84
|
});
|
|
47
85
|
server.on('request', (req, res) => {
|
|
48
86
|
if (req.url) {
|
|
49
87
|
const url = new URL(req.url, 'http://localhost:8080');
|
|
50
|
-
if (url.pathname === '/
|
|
51
|
-
const
|
|
88
|
+
if (url.pathname === '/auth-callback') {
|
|
89
|
+
const token = url.searchParams.get('token');
|
|
52
90
|
const error = url.searchParams.get('error');
|
|
53
91
|
if (error) {
|
|
54
92
|
res.writeHead(400, { 'Content-Type': 'text/html' });
|
|
55
|
-
res.end('
|
|
56
|
-
|
|
93
|
+
res.end(this.generateAuthResponseHTML(false, 'Authentication Failed', `Error: ${error}<br>You can close this window and try again.`));
|
|
94
|
+
tokenReject(new Error(`Authentication error: ${error}`));
|
|
57
95
|
return;
|
|
58
96
|
}
|
|
59
|
-
if (
|
|
97
|
+
if (token) {
|
|
60
98
|
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
61
|
-
res.end(
|
|
62
|
-
|
|
63
|
-
<html>
|
|
64
|
-
<head>
|
|
65
|
-
<title>Authentication Successful</title>
|
|
66
|
-
<style>
|
|
67
|
-
body {
|
|
68
|
-
background-color: #000000;
|
|
69
|
-
color: #ffffff;
|
|
70
|
-
font-family: Arial, sans-serif;
|
|
71
|
-
text-align: center;
|
|
72
|
-
padding: 50px;
|
|
73
|
-
margin: 0;
|
|
74
|
-
}
|
|
75
|
-
h1 {
|
|
76
|
-
font-size: 2.5em;
|
|
77
|
-
margin-bottom: 20px;
|
|
78
|
-
}
|
|
79
|
-
p {
|
|
80
|
-
font-size: 1.2em;
|
|
81
|
-
}
|
|
82
|
-
</style>
|
|
83
|
-
</head>
|
|
84
|
-
<body>
|
|
85
|
-
<h1>Authentication Successful!</h1>
|
|
86
|
-
<p>You can close this window and return to the CLI.</p>
|
|
87
|
-
</body>
|
|
88
|
-
</html>
|
|
89
|
-
`);
|
|
90
|
-
authCodeResolve(code);
|
|
99
|
+
res.end(this.generateAuthResponseHTML(true, 'Authentication Successful!', 'You can now close this window and return to the CLI.'));
|
|
100
|
+
tokenResolve(token);
|
|
91
101
|
}
|
|
92
102
|
else {
|
|
93
103
|
res.writeHead(400, { 'Content-Type': 'text/html' });
|
|
94
|
-
res.end('
|
|
95
|
-
|
|
104
|
+
res.end(this.generateAuthResponseHTML(false, 'Authentication Failed', 'No authentication token received.<br>You can close this window and try again.'));
|
|
105
|
+
tokenReject(new Error('No authentication token received'));
|
|
96
106
|
}
|
|
97
107
|
}
|
|
98
108
|
}
|
|
99
109
|
});
|
|
100
110
|
server.listen(8080, 'localhost', () => {
|
|
101
|
-
resolve({ server,
|
|
111
|
+
resolve({ server, tokenPromise });
|
|
102
112
|
});
|
|
103
113
|
server.on('error', (error) => {
|
|
104
114
|
reject(error);
|
|
105
115
|
});
|
|
106
116
|
});
|
|
107
117
|
}
|
|
108
|
-
static async exchangeCodeForTokens(code) {
|
|
109
|
-
const params = new URLSearchParams({
|
|
110
|
-
client_id: this.CLIENT_ID,
|
|
111
|
-
code,
|
|
112
|
-
grant_type: 'authorization_code',
|
|
113
|
-
redirect_uri: 'http://localhost:8080/oauth/callback',
|
|
114
|
-
});
|
|
115
|
-
const response = await fetch('https://oauth2.googleapis.com/token', {
|
|
116
|
-
method: 'POST',
|
|
117
|
-
headers: {
|
|
118
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
119
|
-
},
|
|
120
|
-
body: params.toString(),
|
|
121
|
-
});
|
|
122
|
-
if (!response.ok) {
|
|
123
|
-
const error = await response.text();
|
|
124
|
-
throw new Error(`Token exchange failed: ${error}`);
|
|
125
|
-
}
|
|
126
|
-
return await response.json();
|
|
127
|
-
}
|
|
128
|
-
static async refreshToken(refreshToken) {
|
|
129
|
-
const params = new URLSearchParams({
|
|
130
|
-
grant_type: 'refresh_token',
|
|
131
|
-
refresh_token: refreshToken,
|
|
132
|
-
client_id: this.CLIENT_ID,
|
|
133
|
-
});
|
|
134
|
-
const response = await fetch('https://oauth2.googleapis.com/token', {
|
|
135
|
-
method: 'POST',
|
|
136
|
-
headers: {
|
|
137
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
138
|
-
},
|
|
139
|
-
body: params.toString(),
|
|
140
|
-
});
|
|
141
|
-
if (!response.ok) {
|
|
142
|
-
const errorText = await response.text();
|
|
143
|
-
throw new Error(`Token refresh failed: ${response.status} ${errorText}`);
|
|
144
|
-
}
|
|
145
|
-
const tokens = await response.json();
|
|
146
|
-
// Sign in to Firebase with the new access token
|
|
147
|
-
const credential = GoogleAuthProvider.credential(null, tokens.access_token);
|
|
148
|
-
await signInWithCredential(auth, credential);
|
|
149
|
-
// Update stored tokens with new access token (refresh token may be the same)
|
|
150
|
-
const existingAuth = await loadAuth();
|
|
151
|
-
await saveAuth({
|
|
152
|
-
userId: existingAuth?.userId || '',
|
|
153
|
-
email: existingAuth?.email || '',
|
|
154
|
-
accessToken: tokens.access_token,
|
|
155
|
-
refreshToken: tokens.refresh_token || existingAuth?.refreshToken
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
118
|
static async initialize() {
|
|
159
119
|
if (this.authStateInitialized) {
|
|
160
120
|
// Wait for auth state to be ready if initialization is in progress
|
|
@@ -168,78 +128,23 @@ export class AuthService {
|
|
|
168
128
|
this.authStateReady = new Promise((resolve) => {
|
|
169
129
|
resolveAuthState = resolve;
|
|
170
130
|
});
|
|
171
|
-
// Try to restore from stored auth
|
|
172
|
-
const storedAuth = await loadAuth();
|
|
173
|
-
let authAttemptMade = false;
|
|
174
|
-
if (storedAuth?.userId && storedAuth.email && storedAuth.accessToken) {
|
|
175
|
-
authAttemptMade = true;
|
|
176
|
-
try {
|
|
177
|
-
// Try to restore Firebase session using stored access token
|
|
178
|
-
const credential = GoogleAuthProvider.credential(null, storedAuth.accessToken);
|
|
179
|
-
await signInWithCredential(auth, credential);
|
|
180
|
-
console.log(chalk.green('✅ Session restored from storage'));
|
|
181
|
-
}
|
|
182
|
-
catch (error) {
|
|
183
|
-
// Token might be expired, try refresh token if available
|
|
184
|
-
if (storedAuth.refreshToken) {
|
|
185
|
-
try {
|
|
186
|
-
await this.refreshToken(storedAuth.refreshToken);
|
|
187
|
-
console.log(chalk.green('✅ Session refreshed from storage'));
|
|
188
|
-
}
|
|
189
|
-
catch (refreshError) {
|
|
190
|
-
console.log(chalk.yellow('⚠️ Stored session expired, please sign in again'));
|
|
191
|
-
await clearAuth();
|
|
192
|
-
authAttemptMade = false;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
console.log(chalk.yellow('⚠️ Stored session expired, please sign in again'));
|
|
197
|
-
await clearAuth();
|
|
198
|
-
authAttemptMade = false;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
131
|
// Set up Firebase Auth state observer
|
|
203
132
|
onAuthStateChanged(auth, async (user) => {
|
|
204
133
|
if (user) {
|
|
205
134
|
this.currentUser = user;
|
|
206
|
-
if (!this.customUserInfo) {
|
|
207
|
-
this.customUserInfo = {
|
|
208
|
-
id: user.uid,
|
|
209
|
-
email: user.email || '',
|
|
210
|
-
name: user.displayName || user.email?.split('@')[0] || ''
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
// Only update user info in storage, preserve OAuth tokens if they exist
|
|
214
|
-
const existingAuth = await loadAuth();
|
|
215
|
-
await saveAuth({
|
|
216
|
-
userId: user.uid,
|
|
217
|
-
email: user.email || '',
|
|
218
|
-
accessToken: existingAuth?.accessToken || undefined,
|
|
219
|
-
refreshToken: existingAuth?.refreshToken || undefined
|
|
220
|
-
});
|
|
221
135
|
}
|
|
222
136
|
else {
|
|
223
137
|
// User signed out, clean up
|
|
224
138
|
this.currentUser = null;
|
|
225
|
-
this.customUserInfo = null;
|
|
226
|
-
await clearAuth();
|
|
227
139
|
}
|
|
228
140
|
// Resolve the auth state promise once we know the state
|
|
229
|
-
|
|
230
|
-
resolveAuthState();
|
|
231
|
-
resolveAuthState = null;
|
|
232
|
-
}
|
|
141
|
+
resolveAuthState();
|
|
233
142
|
});
|
|
234
143
|
this.authStateInitialized = true;
|
|
235
|
-
//
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
resolveAuthState();
|
|
240
|
-
}
|
|
241
|
-
}, 100);
|
|
242
|
-
}
|
|
144
|
+
// No session to restore, resolve after a short delay to allow Firebase auth state to settle
|
|
145
|
+
setTimeout(() => {
|
|
146
|
+
resolveAuthState();
|
|
147
|
+
}, 100);
|
|
243
148
|
// Wait for auth state to be determined
|
|
244
149
|
await this.authStateReady;
|
|
245
150
|
}
|
|
@@ -254,7 +159,7 @@ export class AuthService {
|
|
|
254
159
|
}
|
|
255
160
|
static async loginFlow() {
|
|
256
161
|
console.log(chalk.blue('\n🔐 Authentication Required'));
|
|
257
|
-
console.log('Please sign in
|
|
162
|
+
console.log('Please sign in to continue.\n');
|
|
258
163
|
try {
|
|
259
164
|
// Ensure auth state is initialized
|
|
260
165
|
await this.initialize();
|
|
@@ -264,46 +169,36 @@ export class AuthService {
|
|
|
264
169
|
return true;
|
|
265
170
|
}
|
|
266
171
|
const proceed = await input({
|
|
267
|
-
message: 'Press Enter to open
|
|
172
|
+
message: 'Press Enter to open sign-in in your browser, or type "q" to quit:',
|
|
268
173
|
default: '',
|
|
269
174
|
});
|
|
270
175
|
if (proceed.toLowerCase() === 'q') {
|
|
271
176
|
return false;
|
|
272
177
|
}
|
|
273
|
-
|
|
178
|
+
return await this.webAuthFlow();
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
static async webAuthFlow() {
|
|
185
|
+
try {
|
|
186
|
+
console.log(chalk.yellow('🌐 Please complete sign-in in your browser...\n'));
|
|
274
187
|
// Start local server to receive callback
|
|
275
|
-
const { server,
|
|
188
|
+
const { server, tokenPromise } = await this.startLocalServerForToken();
|
|
276
189
|
try {
|
|
277
|
-
// Create
|
|
278
|
-
const
|
|
279
|
-
authUrl
|
|
280
|
-
authUrl.searchParams.set('redirect_uri', 'http://localhost:8080/oauth/callback');
|
|
281
|
-
authUrl.searchParams.set('response_type', 'code');
|
|
282
|
-
authUrl.searchParams.set('scope', 'openid email profile');
|
|
283
|
-
authUrl.searchParams.set('access_type', 'offline');
|
|
284
|
-
authUrl.searchParams.set('prompt', 'consent');
|
|
190
|
+
// Create the auth URL - use main auth page with callback parameter
|
|
191
|
+
const redirectUrl = 'http://localhost:8080/auth-callback';
|
|
192
|
+
const authUrl = `${this.WEB_APP_URL}/#auth?callback=${encodeURIComponent(redirectUrl)}`;
|
|
285
193
|
// Open browser
|
|
286
|
-
await this.openBrowser(authUrl
|
|
287
|
-
console.log('
|
|
194
|
+
await this.openBrowser(authUrl);
|
|
195
|
+
console.log('');
|
|
288
196
|
// Wait for callback
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
console.log('Exchanging authorization code for tokens...');
|
|
293
|
-
const tokens = await this.exchangeCodeForTokens(authCode);
|
|
294
|
-
// Sign in to Firebase Auth using the Google OAuth token
|
|
295
|
-
const credential = GoogleAuthProvider.credential(null, tokens.access_token);
|
|
296
|
-
const userCredential = await signInWithCredential(auth, credential);
|
|
197
|
+
const customToken = await tokenPromise;
|
|
198
|
+
// Sign in to Firebase Auth using the custom token
|
|
199
|
+
const userCredential = await signInWithCustomToken(auth, customToken);
|
|
297
200
|
this.currentUser = userCredential.user;
|
|
298
|
-
|
|
299
|
-
await saveAuth({
|
|
300
|
-
userId: userCredential.user.uid,
|
|
301
|
-
email: userCredential.user.email || '',
|
|
302
|
-
accessToken: tokens.access_token,
|
|
303
|
-
refreshToken: tokens.refresh_token
|
|
304
|
-
});
|
|
305
|
-
console.log(chalk.green(`✅ Welcome ${userCredential.user.displayName || userCredential.user.email}!`));
|
|
306
|
-
console.log(chalk.green('✅ Login successful!'));
|
|
201
|
+
console.log(chalk.green('✅ Login successful!'));
|
|
307
202
|
return true;
|
|
308
203
|
}
|
|
309
204
|
finally {
|
|
@@ -311,20 +206,8 @@ export class AuthService {
|
|
|
311
206
|
}
|
|
312
207
|
}
|
|
313
208
|
catch (error) {
|
|
314
|
-
console.error(chalk.red('❌ Authentication failed:'), error.message);
|
|
315
209
|
return false;
|
|
316
210
|
}
|
|
317
211
|
}
|
|
318
|
-
static async signOut() {
|
|
319
|
-
try {
|
|
320
|
-
await auth.signOut();
|
|
321
|
-
// Firebase auth state observer will handle clearing user state
|
|
322
|
-
console.log(chalk.green('✅ Signed out successfully'));
|
|
323
|
-
}
|
|
324
|
-
catch (error) {
|
|
325
|
-
console.error(chalk.red('❌ Error signing out:'), error.message);
|
|
326
|
-
throw error;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
212
|
}
|
|
330
213
|
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/services/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACxC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,YAAY,EAAC,MAAM,MAAM,CAAC;AAClC,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AACnC,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/services/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACxC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,YAAY,EAAC,MAAM,MAAM,CAAC;AAClC,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AACnC,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAC,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAO,MAAM,eAAe,CAAC;AACvF,OAAO,GAAG,MAAM,uBAAuB,CAAC;AAExC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAElC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;AAE1B,MAAM,OAAO,WAAW;IACZ,MAAM,CAAC,WAAW,GAAgB,IAAI,CAAC;IACvC,MAAM,CAAC,oBAAoB,GAAY,KAAK,CAAC;IAC7C,MAAM,CAAC,cAAc,GAAyB,IAAI,CAAC;IAEnD,MAAM,CAAU,WAAW,GAAG,0BAA0B,CAAC;IAEzD,MAAM,CAAC,wBAAwB,CAAC,SAAkB,EAAE,KAAa,EAAE,OAAe;QACtF,MAAM,YAAY,GAAG,SAAS,CAA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,GAAG,MAAM,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAErE,IAAI,CAAC;gBACD,mEAAmE;gBACnE,MAAM,WAAW,GAAG,qCAAqC,CAAC;gBAC1D,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,WAAW,mBAAmB,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;gBAExF,eAAe;gBACf,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;gBAChC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAEhB,oBAAoB;gBACpB,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC;gBAEvC,kDAAkD;gBAClD,MAAM,cAAc,GAAG,MAAM,qBAAqB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;gBACtE,IAAI,CAAC,WAAW,GAAG,cAAc,CAAC,IAAI,CAAC;gBAEvC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;gBAEjD,OAAO,IAAI,CAAC;YAEhB,CAAC;oBAAS,CAAC;gBACP,MAAM,CAAC,KAAK,EAAE,CAAC;YACnB,CAAC;QAEL,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAClB,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC"}
|
|
@@ -2,7 +2,9 @@ import { Runner } from '../types/runner.js';
|
|
|
2
2
|
export declare class CommandListener {
|
|
3
3
|
private activeListeners;
|
|
4
4
|
private isShuttingDown;
|
|
5
|
+
private rl;
|
|
5
6
|
startListening(runner: Runner): Promise<void>;
|
|
7
|
+
private promptForUserCommand;
|
|
6
8
|
stopListening(runnerId: string): Promise<void>;
|
|
7
9
|
}
|
|
8
10
|
//# sourceMappingURL=command-listener.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-listener.d.ts","sourceRoot":"","sources":["../../src/services/command-listener.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command-listener.d.ts","sourceRoot":"","sources":["../../src/services/command-listener.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAO1C,qBAAa,eAAe;IACxB,OAAO,CAAC,eAAe,CAAsC;IAC7D,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,EAAE,CAAmC;IAEvC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YA2IrC,oBAAoB;IA8C5B,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAavD"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
+
import * as readline from 'readline/promises';
|
|
2
3
|
import { RunnerService } from './runner.js';
|
|
3
4
|
import { CommandExecutor } from './executor.js';
|
|
4
5
|
import { generateDeviceId } from '../utils/device.js';
|
|
5
6
|
import { EncryptionService } from '../utils/encryption.js';
|
|
6
|
-
import {
|
|
7
|
+
import { loadEncryption, saveEncryption } from '../utils/storage.js';
|
|
7
8
|
export class CommandListener {
|
|
8
9
|
activeListeners = new Map();
|
|
9
10
|
isShuttingDown = false;
|
|
11
|
+
rl = null;
|
|
10
12
|
async startListening(runner) {
|
|
11
13
|
if (this.activeListeners.has(runner.id)) {
|
|
12
14
|
console.log(chalk.yellow(`Already listening to runner "${runner.name}"`));
|
|
@@ -19,16 +21,15 @@ export class CommandListener {
|
|
|
19
21
|
}
|
|
20
22
|
// Generate or load encryption code
|
|
21
23
|
let encryptionCode;
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
24
|
-
encryptionCode =
|
|
24
|
+
const storedEncryption = await loadEncryption();
|
|
25
|
+
if (storedEncryption?.encryptionCode) {
|
|
26
|
+
encryptionCode = storedEncryption.encryptionCode;
|
|
25
27
|
}
|
|
26
28
|
else {
|
|
27
29
|
// Generate new random encryption code
|
|
28
30
|
encryptionCode = EncryptionService.generateRandomSecret();
|
|
29
31
|
// Save to storage
|
|
30
|
-
|
|
31
|
-
await saveAuth(updatedAuth);
|
|
32
|
+
await saveEncryption({ encryptionCode });
|
|
32
33
|
}
|
|
33
34
|
console.log(chalk.blue(`👂 Started listening for commands on runner "${runner.name}"`));
|
|
34
35
|
console.log(chalk.gray(` Directory: ${runner.directory}`));
|
|
@@ -47,6 +48,7 @@ export class CommandListener {
|
|
|
47
48
|
console.log('');
|
|
48
49
|
console.log(chalk.gray(` Press Ctrl+C to stop`));
|
|
49
50
|
console.log(chalk.gray(` Keep in mind, if your machine goes to sleep, it won't process commands`));
|
|
51
|
+
await this.promptForUserCommand(runner.id, encryptionCode);
|
|
50
52
|
const unsubscribe = RunnerService.listenToRunner(runner.id, async (updatedRunner) => {
|
|
51
53
|
if (!updatedRunner || this.isShuttingDown)
|
|
52
54
|
return;
|
|
@@ -79,6 +81,7 @@ export class CommandListener {
|
|
|
79
81
|
await RunnerService.updateRunnerAfterCommand(runner.id, encryptedOutput);
|
|
80
82
|
console.log(chalk.blue(`💌 Message sent`));
|
|
81
83
|
console.log(chalk.gray('Waiting for next command...'));
|
|
84
|
+
await this.promptForUserCommand(runner.id, encryptionCode);
|
|
82
85
|
}
|
|
83
86
|
catch (error) {
|
|
84
87
|
console.error(chalk.red(`❌ Error processing command: ${error.message}`));
|
|
@@ -99,6 +102,7 @@ export class CommandListener {
|
|
|
99
102
|
console.error(chalk.red('Failed to update runner with error result'));
|
|
100
103
|
}
|
|
101
104
|
console.log(chalk.gray('Waiting for next command...'));
|
|
105
|
+
await this.promptForUserCommand(runner.id, encryptionCode);
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
});
|
|
@@ -119,12 +123,56 @@ export class CommandListener {
|
|
|
119
123
|
process.on('uncaughtException', cleanup);
|
|
120
124
|
process.on('unhandledRejection', cleanup);
|
|
121
125
|
}
|
|
126
|
+
async promptForUserCommand(runnerId, encryptionCode) {
|
|
127
|
+
if (this.isShuttingDown)
|
|
128
|
+
return;
|
|
129
|
+
try {
|
|
130
|
+
// Create readline interface if it doesn't exist
|
|
131
|
+
if (!this.rl) {
|
|
132
|
+
this.rl = readline.createInterface({
|
|
133
|
+
input: process.stdin,
|
|
134
|
+
output: process.stdout,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
console.log(chalk.cyan('💬 You can also enter a command here (or press Ctrl+C to exit):'));
|
|
138
|
+
const userInput = await this.rl.question(chalk.green('> '));
|
|
139
|
+
// If user provided input, send it as a command
|
|
140
|
+
if (userInput && userInput.trim().length > 0) {
|
|
141
|
+
const command = userInput.trim();
|
|
142
|
+
console.log(chalk.cyan(`📤 Sending command: ${command}`));
|
|
143
|
+
// Encrypt the command
|
|
144
|
+
const encryptResult = EncryptionService.encrypt(command, encryptionCode);
|
|
145
|
+
const encryptedCommand = encryptResult.success ? encryptResult.encrypted : command;
|
|
146
|
+
// Create a user message in Firestore
|
|
147
|
+
await RunnerService.createMessage(runnerId, {
|
|
148
|
+
content: encryptedCommand,
|
|
149
|
+
senderName: '',
|
|
150
|
+
type: 'user',
|
|
151
|
+
});
|
|
152
|
+
// Update the runner with the pending command (this will trigger the listener)
|
|
153
|
+
await RunnerService.updateRunner(runnerId, encryptedCommand);
|
|
154
|
+
console.log(chalk.blue(`✅ Command submitted successfully`));
|
|
155
|
+
console.log(chalk.gray('Processing...'));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
// If the error is from Ctrl+C or shutdown, the process SIGINT handler will handle cleanup
|
|
160
|
+
if (!this.isShuttingDown) {
|
|
161
|
+
console.error(chalk.red(`❌ Error prompting for command: ${error.message}`));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
122
165
|
async stopListening(runnerId) {
|
|
123
166
|
const unsubscribe = this.activeListeners.get(runnerId);
|
|
124
167
|
if (unsubscribe) {
|
|
125
168
|
unsubscribe();
|
|
126
169
|
this.activeListeners.delete(runnerId);
|
|
127
170
|
}
|
|
171
|
+
// Close readline interface if it exists
|
|
172
|
+
if (this.rl) {
|
|
173
|
+
this.rl.close();
|
|
174
|
+
this.rl = null;
|
|
175
|
+
}
|
|
128
176
|
}
|
|
129
177
|
}
|
|
130
178
|
//# sourceMappingURL=command-listener.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-listener.js","sourceRoot":"","sources":["../../src/services/command-listener.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"command-listener.js","sourceRoot":"","sources":["../../src/services/command-listener.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAC,cAAc,EAAE,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAEnE,MAAM,OAAO,eAAe;IAChB,eAAe,GAA4B,IAAI,GAAG,EAAE,CAAC;IACrD,cAAc,GAAG,KAAK,CAAC;IACvB,EAAE,GAA8B,IAAI,CAAC;IAE7C,KAAK,CAAC,cAAc,CAAC,MAAc;QAC/B,IAAI,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;YACtC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,gCAAgC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;YAC1E,OAAO;QACX,CAAC;QAED,gCAAgC;QAChC,MAAM,QAAQ,GAAG,gBAAgB,EAAE,CAAC;QACpC,IAAI,MAAM,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YAChC,MAAM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;YAChB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;QACnB,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/services/executor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,MAAM,EAAa,MAAM,oBAAoB,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,eAAe;WACX,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAiCpF,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAsBnC,OAAO,CAAC,MAAM,CAAC,gBAAgB;
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/services/executor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,MAAM,EAAa,MAAM,oBAAoB,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,eAAe;WACX,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAiCpF,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAsBnC,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAwB/B,OAAO,CAAC,MAAM,CAAC,WAAW;CAY7B"}
|
|
@@ -60,7 +60,14 @@ export class CommandExecutor {
|
|
|
60
60
|
case RunnerType.GEMINI:
|
|
61
61
|
return `gemini -p "${escapedInput}" --yolo`;
|
|
62
62
|
case RunnerType.CODEX:
|
|
63
|
-
|
|
63
|
+
// codex exec "whats my name" --skip-git-repo-check --full-auto --json
|
|
64
|
+
// {"type":"thread.started","thread_id":"0199b81e-5536-7ca0-95f8-95d394c52ade"}
|
|
65
|
+
// {"type":"turn.started"}
|
|
66
|
+
// {"type":"item.completed","item":{"id":"item_0","type":"reasoning","text":"**Handling missing information**"}}
|
|
67
|
+
// {"type":"item.completed","item":{"id":"item_1","type":"agent_message","text":"I’m not sure—I don’t have that information."}}
|
|
68
|
+
// {"type":"turn.completed","usage":{"input_tokens":2570,"cached_input_tokens":2048,"output_tokens":17}}
|
|
69
|
+
// we would need to parse the item.completed event with type == agent_message and then get the text from that
|
|
70
|
+
return `codex exec "${escapedInput}" --experimental-json --full-auto --skip-git-repo-check resume "0199b82c-b9ac-70d0-8f09-567cf6554a8a"`;
|
|
64
71
|
}
|
|
65
72
|
}
|
|
66
73
|
static getToolName(runnerType) {
|