cloud-pc-templates 1.1.0 → 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/handlers/ollamacloud.js +32 -27
- package/package.json +1 -1
package/handlers/ollamacloud.js
CHANGED
|
@@ -19,36 +19,41 @@ function promptForApiKey() {
|
|
|
19
19
|
stdin.resume();
|
|
20
20
|
|
|
21
21
|
let apiKey = '';
|
|
22
|
-
let isFirstInput = true;
|
|
23
22
|
|
|
24
|
-
stdin.on('data', (
|
|
25
|
-
const
|
|
23
|
+
stdin.on('data', (buffer) => {
|
|
24
|
+
const chunk = buffer.toString();
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
process.
|
|
26
|
+
// Process each character in the chunk (handles pasted text)
|
|
27
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
28
|
+
const char = chunk[i];
|
|
29
|
+
|
|
30
|
+
if (char === '\n' || char === '\r' || char === '\u0004') {
|
|
31
|
+
// Enter or EOF
|
|
32
|
+
if (stdin.isTTY) {
|
|
33
|
+
stdin.setRawMode(false);
|
|
34
|
+
}
|
|
35
|
+
stdin.pause();
|
|
36
|
+
stdin.removeAllListeners('data');
|
|
37
|
+
console.log('');
|
|
38
|
+
resolve(apiKey);
|
|
39
|
+
return;
|
|
40
|
+
} else if (char === '\u0003') {
|
|
41
|
+
// Ctrl+C
|
|
42
|
+
if (stdin.isTTY) {
|
|
43
|
+
stdin.setRawMode(false);
|
|
44
|
+
}
|
|
45
|
+
process.exit();
|
|
46
|
+
} else if (char === '\x7f' || char === '\b') {
|
|
47
|
+
// Backspace
|
|
48
|
+
if (apiKey.length > 0) {
|
|
49
|
+
apiKey = apiKey.slice(0, -1);
|
|
50
|
+
process.stdout.write('\x1b[D\x1b[K');
|
|
51
|
+
}
|
|
52
|
+
} else if (char >= '\x20' && char <= '\x7e') {
|
|
53
|
+
// Printable character
|
|
54
|
+
apiKey += char;
|
|
55
|
+
process.stdout.write('*');
|
|
47
56
|
}
|
|
48
|
-
} else if (char >= '\x20' && char <= '\x7e') {
|
|
49
|
-
// Printable character
|
|
50
|
-
apiKey += char;
|
|
51
|
-
process.stdout.write('*');
|
|
52
57
|
}
|
|
53
58
|
});
|
|
54
59
|
});
|