@meller/tokentalos 1.0.1 → 1.0.4

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/api/setup.js CHANGED
@@ -38,7 +38,15 @@ export async function runSetup() {
38
38
  console.log(chalk.gray('This wizard will configure your Database, Collector (API), and Dashboard.'));
39
39
  console.log(chalk.white('\n [Collector]: ') + chalk.gray('The ingestion endpoint that receives and analyzes LLM data.'));
40
40
  console.log(chalk.white(' [Dashboard]: ') + chalk.gray('The visual interface for monitoring your AI performance.\n'));
41
-
41
+
42
+ // Load previous configuration if it exists to use as defaults
43
+ let previousAnswers = {};
44
+ if (await fs.pathExists(CONFIG_PATH)) {
45
+ try {
46
+ previousAnswers = await fs.readJson(CONFIG_PATH);
47
+ } catch (e) { /* ignore */ }
48
+ }
49
+
42
50
  const answers = await inquirer.prompt([
43
51
  // --- DATABASE SECTION ---
44
52
  {
@@ -115,11 +123,28 @@ export async function runSetup() {
115
123
  when: (ans) => ans.enableCollector,
116
124
  validate: (input) => !isNaN(parseInt(input)) || 'Please enter a valid port number',
117
125
  },
118
- // ... safety and intelligence ...
126
+
127
+ // --- DASHBOARD SECTION ---
128
+ {
129
+ type: 'confirm',
130
+ name: 'enableDashboard',
131
+ message: chalk.magenta('DASHBOARD: ') + 'Enable web interface?',
132
+ default: true,
133
+ },
134
+ {
135
+ type: 'input',
136
+ name: 'dashboardPort',
137
+ message: ' Dashboard Port:',
138
+ default: 8060,
139
+ when: (ans) => ans.enableDashboard,
140
+ validate: (input) => !isNaN(parseInt(input)) || 'Please enter a valid port number',
141
+ },
142
+
143
+ // --- LLM CONFIGURATION (Common) ---
119
144
  {
120
145
  type: 'list',
121
146
  name: 'llmProvider',
122
- message: ' LLM provider for OPV/Analysis:',
147
+ message: chalk.yellow('LLM CONFIG: ') + 'Select provider for OPV/Analysis/Ingest:',
123
148
  choices: [
124
149
  { name: 'Gemini (via ADC/Vertex)', value: 'gemini' },
125
150
  { name: 'Anthropic', value: 'anthropic' },
@@ -127,7 +152,7 @@ export async function runSetup() {
127
152
  { name: 'Skip / Configure Later', value: 'none' },
128
153
  ],
129
154
  default: 'none',
130
- when: (ans) => ans.enableCollector,
155
+ when: (ans) => ans.enableCollector || ans.enableDashboard,
131
156
  },
132
157
  {
133
158
  type: 'input',
@@ -139,26 +164,48 @@ export async function runSetup() {
139
164
  if (ans.llmProvider === 'openai') return 'gpt-4o-mini';
140
165
  return 'none';
141
166
  },
142
- when: (ans) => ans.enableCollector && ans.llmProvider !== 'none',
167
+ when: (ans) => (ans.enableCollector || ans.enableDashboard) && ans.llmProvider !== 'none',
143
168
  },
144
169
  {
145
170
  type: 'input',
146
171
  name: 'location',
147
172
  message: ' LLM Model Location:',
148
173
  default: (ans) => ans.llmProvider === 'gemini' ? 'global' : 'us-central1',
149
- when: (ans) => ans.enableCollector && ans.llmProvider !== 'none',
174
+ when: (ans) => (ans.enableCollector || ans.enableDashboard) && ans.llmProvider !== 'none',
175
+ },
176
+ {
177
+ type: 'list',
178
+ name: 'geminiAuthType',
179
+ message: ' Gemini Authentication Method:',
180
+ choices: [
181
+ { name: 'Application Default Credentials (ADC)', value: 'adc' },
182
+ { name: 'API Key', value: 'apikey' }
183
+ ],
184
+ when: (ans) => (ans.enableCollector || ans.enableDashboard) && ans.llmProvider === 'gemini',
185
+ default: (ans) => previousAnswers?.geminiAuthType || 'adc',
150
186
  },
151
187
  {
152
188
  type: 'input',
153
189
  name: 'gcpProjectId',
154
- message: ' Google Cloud Project ID (required for Vertex AI/ADC):',
155
- when: (ans) => ans.enableCollector && ans.llmProvider === 'gemini',
190
+ message: ' Google Cloud Project ID (required for ADC):',
191
+ when: (ans) => (ans.enableCollector || ans.enableDashboard) && ans.llmProvider === 'gemini' && ans.geminiAuthType === 'adc',
192
+ default: (ans) => previousAnswers?.gcpProjectId || '',
156
193
  validate: (input) => input.length > 0 || 'Project ID is required for Vertex AI',
157
194
  },
195
+ {
196
+ type: 'input',
197
+ name: 'geminiApiKey',
198
+ message: ' Gemini API Key:',
199
+ when: (ans) => (ans.enableCollector || ans.enableDashboard) && ans.llmProvider === 'gemini' && ans.geminiAuthType === 'apikey',
200
+ default: (ans) => previousAnswers?.geminiApiKey || '',
201
+ validate: (input) => input.length > 0 || 'API Key is required',
202
+ },
203
+
204
+ // --- SAFETY FEATURES (Collector Only) ---
158
205
  {
159
206
  type: 'checkbox',
160
207
  name: 'formattingFeatures',
161
- message: ' Select Safety features:',
208
+ message: chalk.green('SAFETY: ') + 'Select active guard features:',
162
209
  choices: [
163
210
  { name: 'Compress (Lossless compression)', value: 'compress', checked: true },
164
211
  { name: 'Neutralize (XML wrapping)', value: 'neutralize', checked: true },
@@ -207,31 +254,17 @@ export async function runSetup() {
207
254
  when: (ans) => ans.enableCollector,
208
255
  },
209
256
 
210
- // --- DASHBOARD SECTION ---
211
- {
212
- type: 'confirm',
213
- name: 'enableDashboard',
214
- message: chalk.magenta('DASHBOARD: ') + 'Enable web interface?',
215
- default: true,
216
- },
217
- {
218
- type: 'input',
219
- name: 'dashboardPort',
220
- message: ' Dashboard Port:',
221
- default: 8060,
222
- when: (ans) => ans.enableDashboard,
223
- validate: (input) => !isNaN(parseInt(input)) || 'Please enter a valid port number',
224
- },
257
+ // --- ANALYTICS FEATURES (Dashboard Only) ---
225
258
  {
226
259
  type: 'checkbox',
227
260
  name: 'intelligenceFeatures',
228
- message: ' Select Analytics features:',
261
+ message: chalk.magenta('ANALYTICS: ') + 'Select Dashboard features:',
229
262
  choices: [
230
263
  { name: 'Semantic Caching', value: 'cache', checked: true },
231
264
  { name: 'OPV (Reasoning Analysis)', value: 'opv', checked: true },
232
265
  { name: 'Explain Plan (Heuristic Detection)', value: 'explain', checked: true },
233
266
  ],
234
- when: (ans) => ans.enableDashboard && ans.llmProvider !== 'none',
267
+ when: (ans) => ans.enableDashboard,
235
268
  },
236
269
  {
237
270
  type: 'checkbox',
@@ -242,6 +275,12 @@ export async function runSetup() {
242
275
  { name: 'Anthropic', value: 'anthropic', checked: true },
243
276
  { name: 'Gemini', value: 'gemini', checked: true },
244
277
  { name: 'DeepSeek', value: 'deepseek', checked: true },
278
+ { name: 'Mistral', value: 'mistral', checked: true },
279
+ { name: 'Meta', value: 'meta', checked: false },
280
+ { name: 'Amazon', value: 'amazon', checked: false },
281
+ { name: 'Alibaba', value: 'alibaba', checked: false },
282
+ { name: 'xAI', value: 'xai', checked: false },
283
+ { name: 'Cohere', value: 'cohere', checked: false },
245
284
  ],
246
285
  when: (ans) => ans.enableDashboard,
247
286
  },
@@ -263,9 +302,9 @@ export async function runSetup() {
263
302
 
264
303
  // Save config
265
304
  await fs.writeJson(CONFIG_PATH, answers, { spaces: 2 });
266
-
305
+
267
306
  console.log(chalk.green.bold(`\n✅ Setup complete! Configuration saved to ${CONFIG_PATH}`));
268
-
307
+
269
308
  if (answers.enableCollector) {
270
309
  console.log(chalk.white(`\n Collector (API) will run on port: `) + chalk.green.bold(answers.gatewayPort));
271
310
  console.log(chalk.gray(` Endpoint: http://localhost:${answers.gatewayPort}/api/v1`));
@@ -275,7 +314,7 @@ export async function runSetup() {
275
314
  console.log(chalk.white(`\n Dashboard will run on port: `) + chalk.magenta.bold(answers.dashboardPort));
276
315
  console.log(chalk.gray(` URL: http://localhost:${answers.dashboardPort}`));
277
316
  }
278
-
317
+
279
318
  if (answers.llmProvider === 'none') {
280
319
  console.log(chalk.yellow(`\nNotice: OPV and AI Analysis are currently disabled.\n`));
281
320
  }
package/bin/tokentalos.js CHANGED
@@ -19,7 +19,7 @@ const getPidFile = (service) => path.join(process.cwd(), `.tokentalos-${service
19
19
  program
20
20
  .name('tokentalos')
21
21
  .description('Standalone LLM Token Usage Analyzer and Proxy')
22
- .version('0.1.0');
22
+ .version('1.0.2');
23
23
 
24
24
  program
25
25
  .command('setup')
@@ -24,14 +24,17 @@ export class LLMGateway {
24
24
  async getVertex() {
25
25
  if (!this.clients.vertex) {
26
26
  const location = this.config.location || process.env.GCP_REGION || 'us-central1';
27
- let project = process.env.GOOGLE_CLOUD_PROJECT || process.env.GCLOUD_PROJECT || this.config.gcpProjectId || this.config.project;
27
+ let project = this.config.gcpProjectId || this.config.project || process.env.GOOGLE_CLOUD_PROJECT || process.env.GCLOUD_PROJECT;
28
28
 
29
29
  if (!project) {
30
30
  try {
31
31
  // Try to auto-detect project ID from ADC
32
32
  project = await this.auth.getProjectId();
33
+ if (project) {
34
+ console.log(`[TokenTalos] Auto-detected Project ID from ADC: ${project}`);
35
+ }
33
36
  } catch (e) {
34
- // Ignore auth errors here
37
+ console.warn(`[TokenTalos] Failed to auto-detect Project ID: ${e.message}`);
35
38
  }
36
39
  }
37
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meller/tokentalos",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "Token Talos: The ORM for LLMs. A standalone gateway and library for cost-optimized, secure, and tracked prompt orchestration.",
5
5
  "type": "module",
6
6
  "publishConfig": {