@xfey/tutti 0.1.8 → 0.1.9
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.
|
@@ -6,36 +6,56 @@ const DEFAULT_BASE_URL = "https://api.openai.com/v1";
|
|
|
6
6
|
const HIDE_CURSOR = "\u001B[?25l";
|
|
7
7
|
const SHOW_CURSOR = "\u001B[?25h";
|
|
8
8
|
const CLEAR = "\u001B[2J\u001B[H";
|
|
9
|
+
const DIVIDER = "----------------------------------------------------------------";
|
|
9
10
|
function fieldLine(options) {
|
|
10
|
-
const marker = options.active ? ">" : " ";
|
|
11
11
|
const value = options.secret && options.value.length > 0 ? "*".repeat(options.value.length) : options.value;
|
|
12
|
-
return
|
|
12
|
+
return `> ${options.label}: ${value} _`;
|
|
13
|
+
}
|
|
14
|
+
function renderProviderField(state) {
|
|
15
|
+
if (state.step === "base-url") {
|
|
16
|
+
return [
|
|
17
|
+
"Step 1 of 2 - Base URL",
|
|
18
|
+
"Enter the base URL for your OpenAI-compatible provider.",
|
|
19
|
+
"",
|
|
20
|
+
fieldLine({
|
|
21
|
+
label: "Base URL",
|
|
22
|
+
value: state.baseUrl,
|
|
23
|
+
}),
|
|
24
|
+
"",
|
|
25
|
+
"Press Enter to continue. Press Ctrl-C to cancel.",
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
return [
|
|
29
|
+
"Step 2 of 2 - API Key",
|
|
30
|
+
`Base URL: ${state.baseUrl}`,
|
|
31
|
+
"",
|
|
32
|
+
"Enter the API key for this provider. It will be stored only in the machine-local Tutti credential store.",
|
|
33
|
+
"",
|
|
34
|
+
fieldLine({
|
|
35
|
+
label: "API Key",
|
|
36
|
+
value: state.apiKey,
|
|
37
|
+
secret: true,
|
|
38
|
+
}),
|
|
39
|
+
"",
|
|
40
|
+
"Press Enter to validate. Press Esc to edit the base URL. Press Ctrl-C to cancel.",
|
|
41
|
+
];
|
|
13
42
|
}
|
|
14
43
|
function renderProviderForm(options) {
|
|
15
|
-
const instruction = options.state.step === "base-url"
|
|
16
|
-
? "Enter the provider base URL, then press Enter."
|
|
17
|
-
: "Enter the API key, then press Enter to validate. Press Esc to edit the base URL.";
|
|
18
44
|
const lines = [
|
|
19
45
|
CLEAR,
|
|
20
46
|
HIDE_CURSOR,
|
|
21
47
|
renderTuttiTerminalLogo({ tty: options.tty === true }),
|
|
22
48
|
"",
|
|
23
49
|
"Provider setup",
|
|
50
|
+
DIVIDER,
|
|
51
|
+
"Tutti uses an OpenAI-compatible Responses API provider.",
|
|
52
|
+
"The base URL should expose POST /responses under the entered URL.",
|
|
53
|
+
`Default example: ${DEFAULT_BASE_URL}`,
|
|
54
|
+
DIVIDER,
|
|
24
55
|
"",
|
|
25
56
|
`Project: ${options.projectName}`,
|
|
26
|
-
`${instruction} Press Ctrl-C to cancel.`,
|
|
27
57
|
"",
|
|
28
|
-
|
|
29
|
-
active: options.state.step === "base-url",
|
|
30
|
-
label: "Base URL",
|
|
31
|
-
value: options.state.baseUrl,
|
|
32
|
-
}),
|
|
33
|
-
fieldLine({
|
|
34
|
-
active: options.state.step === "api-key",
|
|
35
|
-
label: "API Key",
|
|
36
|
-
value: options.state.apiKey,
|
|
37
|
-
secret: true,
|
|
38
|
-
}),
|
|
58
|
+
...renderProviderField(options.state),
|
|
39
59
|
"",
|
|
40
60
|
];
|
|
41
61
|
if (options.state.error !== undefined) {
|
|
@@ -114,12 +134,6 @@ async function readProviderForm(options) {
|
|
|
114
134
|
reject(new Error("Provider setup cancelled"));
|
|
115
135
|
return;
|
|
116
136
|
}
|
|
117
|
-
if (key.name === "tab") {
|
|
118
|
-
state.step = state.step === "base-url" ? "api-key" : "base-url";
|
|
119
|
-
state.error = undefined;
|
|
120
|
-
render();
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
137
|
if (key.name === "return") {
|
|
124
138
|
if (state.step === "base-url") {
|
|
125
139
|
if (state.baseUrl.trim() === "") {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const RESET = "\u001B[0m";
|
|
2
|
-
const ACTION_STRONG = "\u001B[38;2;8;121;95m";
|
|
3
1
|
// Static Braille rendering of docs/design/Tutti.png, generated from the alpha mask.
|
|
4
2
|
const TUTTI_BRAILLE_LOGO = [
|
|
5
3
|
" ⣀⣤⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⡄ ⣠⣶⣶⣦ ⢀⣤⣶⣶⣄",
|
|
@@ -12,16 +10,10 @@ const TUTTI_BRAILLE_LOGO = [
|
|
|
12
10
|
" ⢰⣿⣿⣿⠃ ⣿⣿⣿⣴⣿⣿⣿⣇⣀⣴⣿⣿⣿⣿⣄⣀⣠⣾⣿⣿⣧⣀⣀⣀⣴⣿⣿⣿",
|
|
13
11
|
" ⠸⣿⣿⡿ ⠹⣿⣿⡿⠃⠻⣿⣿⣿⠟⠋⠈⠻⣿⣿⣿⡿⠛⠙⠿⣿⣿⣿⣿⠟⣿⣿⡿",
|
|
14
12
|
].join("\n");
|
|
15
|
-
function supportsColor(options) {
|
|
16
|
-
return options.color !== false && process.env.NO_COLOR === undefined;
|
|
17
|
-
}
|
|
18
13
|
export function renderTuttiTerminalLogo(options = {}) {
|
|
19
14
|
if (options.tty !== true) {
|
|
20
15
|
return "Tutti";
|
|
21
16
|
}
|
|
22
|
-
|
|
23
|
-
return TUTTI_BRAILLE_LOGO;
|
|
24
|
-
}
|
|
25
|
-
return `${ACTION_STRONG}${TUTTI_BRAILLE_LOGO}${RESET}`;
|
|
17
|
+
return TUTTI_BRAILLE_LOGO;
|
|
26
18
|
}
|
|
27
19
|
//# sourceMappingURL=terminal-logo.js.map
|