@lotics/cli 0.8.0 → 0.10.0
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 +9 -9
- package/dist/src/cli.js +81 -68
- package/dist/src/client.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,27 +25,27 @@ The CLI checks for updates once per day and prompts when a new version is availa
|
|
|
25
25
|
|
|
26
26
|
## Authentication
|
|
27
27
|
|
|
28
|
-
**`lotics signup`** — Creates a new Lotics account, organization, workspace, and API key in one step. Sends a magic link email so you can access the web app.
|
|
28
|
+
**`lotics auth signup`** — Creates a new Lotics account, organization, workspace, and API key in one step. Sends a magic link email so you can access the web app.
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
lotics signup
|
|
32
|
-
lotics signup
|
|
31
|
+
lotics auth signup # interactive prompts
|
|
32
|
+
lotics auth signup a@b.com --name "Agent" # non-interactive
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
**`lotics
|
|
35
|
+
**`lotics auth web`** — Send a magic link email to access the web app (requires prior signup or setup).
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
|
-
lotics
|
|
38
|
+
lotics auth web
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
**`lotics
|
|
41
|
+
**`lotics auth api-key`** — Saves an existing API key directly (e.g. one created in the Lotics web app).
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
lotics
|
|
45
|
-
lotics
|
|
44
|
+
lotics auth api-key # interactive prompt
|
|
45
|
+
lotics auth api-key ltk_... # non-interactive
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
API key is saved to `~/.lotics/config.json`. Run `lotics logout` to remove saved credentials.
|
|
48
|
+
API key is saved to `~/.lotics/config.json`. Run `lotics auth logout` to remove saved credentials.
|
|
49
49
|
|
|
50
50
|
Auth priority: `--api-key` flag > `LOTICS_API_KEY` env > `~/.lotics/config.json`.
|
|
51
51
|
|
package/dist/src/cli.js
CHANGED
|
@@ -15,23 +15,11 @@ Lotics is an AI-powered operations platform. Through this CLI you can:
|
|
|
15
15
|
- Create and manage apps, knowledge docs, and files
|
|
16
16
|
|
|
17
17
|
AUTHENTICATION
|
|
18
|
-
lotics
|
|
19
|
-
lotics
|
|
20
|
-
lotics setup [api_key] Save an existing API key (e.g. from the web app)
|
|
21
|
-
lotics whoami Show the email of the current account
|
|
22
|
-
lotics logout Remove saved credentials
|
|
23
|
-
|
|
24
|
-
Signup flags:
|
|
25
|
-
--email <email> Email (required; prompted if omitted)
|
|
26
|
-
--name <name> Display name (defaults to email prefix)
|
|
27
|
-
--timezone <timezone> Workspace timezone (defaults to UTC, e.g. Asia/Ho_Chi_Minh)
|
|
28
|
-
|
|
29
|
-
Signup sends a magic link email so you can access the Lotics web app.
|
|
30
|
-
Use lotics login to request a new magic link at any time.
|
|
31
|
-
Setup priority: --api-key flag > LOTICS_API_KEY env > saved config.
|
|
18
|
+
lotics auth Show auth help
|
|
19
|
+
lotics auth signup <email> Create account (run "lotics auth" for details)
|
|
32
20
|
|
|
33
21
|
USAGE
|
|
34
|
-
1. lotics signup
|
|
22
|
+
1. lotics auth signup <email> Create account or authenticate
|
|
35
23
|
2. lotics workspace Check current workspace (auto-selects if only one)
|
|
36
24
|
3. lotics tools List available tools by category
|
|
37
25
|
4. lotics tools <name> Show tool description and full input schema
|
|
@@ -81,6 +69,23 @@ STDIN
|
|
|
81
69
|
|
|
82
70
|
echo '{"table_id":"tbl_..."}' | lotics run query_records`);
|
|
83
71
|
}
|
|
72
|
+
function printAuthHelp() {
|
|
73
|
+
console.log(`Authentication commands:
|
|
74
|
+
|
|
75
|
+
lotics auth signup <email> Create account, org, workspace, and API key
|
|
76
|
+
lotics auth api-key [key] Save an existing API key (e.g. from the web app)
|
|
77
|
+
lotics auth web Send a magic link email to access the web app
|
|
78
|
+
lotics auth whoami Show the email of the current account
|
|
79
|
+
lotics auth logout Remove saved credentials
|
|
80
|
+
|
|
81
|
+
Signup flags:
|
|
82
|
+
--name <name> Display name (defaults to email prefix)
|
|
83
|
+
--timezone <timezone> Workspace timezone (defaults to UTC, e.g. Asia/Ho_Chi_Minh)
|
|
84
|
+
|
|
85
|
+
Signup sends a magic link email so you can access the Lotics web app.
|
|
86
|
+
Use lotics auth web to request a new magic link at any time.
|
|
87
|
+
Auth priority: --api-key flag > LOTICS_API_KEY env > saved config.`);
|
|
88
|
+
}
|
|
84
89
|
function parseArgs(argv) {
|
|
85
90
|
const flags = {
|
|
86
91
|
json: false,
|
|
@@ -88,7 +93,6 @@ function parseArgs(argv) {
|
|
|
88
93
|
output: undefined,
|
|
89
94
|
as: undefined,
|
|
90
95
|
apiKey: undefined,
|
|
91
|
-
email: undefined,
|
|
92
96
|
name: undefined,
|
|
93
97
|
timezone: undefined,
|
|
94
98
|
version: false,
|
|
@@ -118,9 +122,6 @@ function parseArgs(argv) {
|
|
|
118
122
|
case "--api-key":
|
|
119
123
|
flags.apiKey = argv[++i];
|
|
120
124
|
break;
|
|
121
|
-
case "--email":
|
|
122
|
-
flags.email = argv[++i];
|
|
123
|
-
break;
|
|
124
125
|
case "--name":
|
|
125
126
|
flags.name = argv[++i];
|
|
126
127
|
break;
|
|
@@ -183,10 +184,10 @@ async function publicPost(path, body) {
|
|
|
183
184
|
const data = await response.json();
|
|
184
185
|
return { ok: response.ok, status: response.status, data };
|
|
185
186
|
}
|
|
186
|
-
async function handleSignup(flags) {
|
|
187
|
-
const email =
|
|
187
|
+
async function handleSignup(positionalEmail, flags) {
|
|
188
|
+
const email = positionalEmail ?? (process.stdin.isTTY ? await prompt("Email: ") : "");
|
|
188
189
|
if (!email) {
|
|
189
|
-
console.error("Email is required.
|
|
190
|
+
console.error("Email is required. Usage: lotics auth signup <email>");
|
|
190
191
|
process.exit(1);
|
|
191
192
|
}
|
|
192
193
|
const name = flags.name ?? (process.stdin.isTTY ? await prompt("Name (enter to use email): ") : undefined);
|
|
@@ -198,7 +199,7 @@ async function handleSignup(flags) {
|
|
|
198
199
|
const { ok, status, data } = await publicPost("/v1/cli/signup", body);
|
|
199
200
|
if (!ok) {
|
|
200
201
|
if (status === 409) {
|
|
201
|
-
console.error("An account with this email already exists. Use: lotics
|
|
202
|
+
console.error("An account with this email already exists. Use: lotics auth api-key");
|
|
202
203
|
}
|
|
203
204
|
else if (status === 429) {
|
|
204
205
|
console.error("Too many signup attempts. Try again later.");
|
|
@@ -218,7 +219,7 @@ async function handleSignup(flags) {
|
|
|
218
219
|
console.error(`Account created. You can now use the CLI.`);
|
|
219
220
|
console.error(` Email: ${data.email}`);
|
|
220
221
|
console.error(`\nCheck your email for a magic link to access the Lotics web app.`);
|
|
221
|
-
console.error(`Run "lotics
|
|
222
|
+
console.error(`Run "lotics auth web" to request a new link at any time.`);
|
|
222
223
|
}
|
|
223
224
|
async function handleSetup(providedKey) {
|
|
224
225
|
const apiKey = providedKey ?? await prompt("Enter your API key: ");
|
|
@@ -260,7 +261,7 @@ async function handleSetup(providedKey) {
|
|
|
260
261
|
function requireClient(flags) {
|
|
261
262
|
const auth = resolveAuth(flags);
|
|
262
263
|
if (!auth) {
|
|
263
|
-
console.error('Not authenticated. Run "lotics
|
|
264
|
+
console.error('Not authenticated. Run "lotics auth signup" or set LOTICS_API_KEY.');
|
|
264
265
|
process.exit(1);
|
|
265
266
|
}
|
|
266
267
|
const config = loadConfig();
|
|
@@ -334,51 +335,58 @@ async function main() {
|
|
|
334
335
|
console.log(VERSION);
|
|
335
336
|
return;
|
|
336
337
|
}
|
|
337
|
-
// ---
|
|
338
|
-
if (command === "
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}
|
|
342
|
-
if (command === "setup") {
|
|
343
|
-
await handleSetup(subcommand ?? flags.apiKey);
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
if (command === "whoami") {
|
|
347
|
-
const config = loadConfig();
|
|
348
|
-
if (config?.email) {
|
|
349
|
-
console.log(config.email);
|
|
338
|
+
// --- lotics auth <subcommand> ---
|
|
339
|
+
if (command === "auth") {
|
|
340
|
+
if (subcommand === "signup") {
|
|
341
|
+
await handleSignup(toolArgs, flags);
|
|
350
342
|
return;
|
|
351
343
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
console.error('Not authenticated. Run "lotics setup" or set LOTICS_API_KEY.');
|
|
356
|
-
process.exit(1);
|
|
344
|
+
if (subcommand === "api-key") {
|
|
345
|
+
await handleSetup(toolArgs ?? flags.apiKey);
|
|
346
|
+
return;
|
|
357
347
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
348
|
+
if (subcommand === "whoami") {
|
|
349
|
+
const config = loadConfig();
|
|
350
|
+
if (config?.email) {
|
|
351
|
+
console.log(config.email);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
// No email cached — try fetching from API
|
|
355
|
+
const auth = resolveAuth(flags);
|
|
356
|
+
if (!auth) {
|
|
357
|
+
console.error('Not authenticated. Run "lotics auth signup" or set LOTICS_API_KEY.');
|
|
358
|
+
process.exit(1);
|
|
359
|
+
}
|
|
360
|
+
const client = new LoticsClient({ apiKey: auth.apiKey });
|
|
361
|
+
try {
|
|
362
|
+
const info = await client.whoami();
|
|
363
|
+
// Cache for next time
|
|
364
|
+
const existing = loadConfig() ?? {};
|
|
365
|
+
saveConfig({ ...existing, email: info.email });
|
|
366
|
+
console.log(info.email);
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
370
|
+
console.error(`Failed to fetch account info: ${message}`);
|
|
371
|
+
process.exit(1);
|
|
372
|
+
}
|
|
373
|
+
return;
|
|
370
374
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
375
|
+
if (subcommand === "logout") {
|
|
376
|
+
deleteConfig();
|
|
377
|
+
console.error("Logged out. Credentials removed.");
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
if (subcommand === "web") {
|
|
381
|
+
const client = requireClient(flags);
|
|
382
|
+
const { email } = await client.login();
|
|
383
|
+
console.error(`Magic link sent to ${email}. Check your email to access the Lotics web app.`);
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (subcommand) {
|
|
387
|
+
console.error(`Unknown auth subcommand: ${subcommand}\n`);
|
|
388
|
+
}
|
|
389
|
+
printAuthHelp();
|
|
382
390
|
return;
|
|
383
391
|
}
|
|
384
392
|
// --- Validate command before auth ---
|
|
@@ -554,8 +562,13 @@ async function main() {
|
|
|
554
562
|
// Always request text format so model_output is available; --json only affects CLI output
|
|
555
563
|
const result = await client.execute(toolName, args, { format: "text", timeoutMs });
|
|
556
564
|
if (result.error) {
|
|
557
|
-
|
|
558
|
-
|
|
565
|
+
if (flags.json) {
|
|
566
|
+
console.log(JSON.stringify({ error: result.error }, null, 2));
|
|
567
|
+
}
|
|
568
|
+
else {
|
|
569
|
+
console.error(result.error);
|
|
570
|
+
console.error(`\nHint: run "lotics tools ${toolName}" to see the expected input schema.`);
|
|
571
|
+
}
|
|
559
572
|
process.exit(1);
|
|
560
573
|
}
|
|
561
574
|
if (flags.json) {
|
package/dist/src/client.js
CHANGED