@mitsein-ai/cli 0.1.5 → 0.1.6
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/dist/index.js +53 -53
- package/package.json +1 -1
- package/src/commands/auth.ts +40 -1
- package/src/commands/thread.ts +1 -1
package/package.json
CHANGED
package/src/commands/auth.ts
CHANGED
|
@@ -80,9 +80,47 @@ export function registerAuth(program: Command): void {
|
|
|
80
80
|
setJsonMode(Boolean(g.json));
|
|
81
81
|
void opts.endpoint;
|
|
82
82
|
const profile = opts.profile ?? 'default';
|
|
83
|
+
|
|
84
|
+
// Check env token first (MITSEIN_TOKEN or --token)
|
|
85
|
+
if (g.token) {
|
|
86
|
+
// Try to parse dev token format: #{"userid":"...", ...}
|
|
87
|
+
const raw = g.token.startsWith('#') ? g.token.slice(1) : g.token;
|
|
88
|
+
try {
|
|
89
|
+
const parsed = JSON.parse(raw) as Record<string, string>;
|
|
90
|
+
emit(
|
|
91
|
+
{
|
|
92
|
+
email: parsed.email ?? 'unknown',
|
|
93
|
+
user_id: parsed.userid ?? 'unknown',
|
|
94
|
+
username: parsed.username ?? 'unknown',
|
|
95
|
+
source: 'env/flag',
|
|
96
|
+
profile,
|
|
97
|
+
},
|
|
98
|
+
(payload) => {
|
|
99
|
+
const d = payload as Record<string, string>;
|
|
100
|
+
consola.success(`Logged in as ${d.email}`);
|
|
101
|
+
consola.log(` User ID: ${d.user_id}`);
|
|
102
|
+
consola.log(` Username: ${d.username}`);
|
|
103
|
+
consola.log(` Source: ${d.source}`);
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
return;
|
|
107
|
+
} catch {
|
|
108
|
+
// Not a parseable dev token, show raw info
|
|
109
|
+
emit(
|
|
110
|
+
{ token: '***', source: 'env/flag', profile },
|
|
111
|
+
(payload) => {
|
|
112
|
+
const d = payload as Record<string, string>;
|
|
113
|
+
consola.success('Authenticated via token');
|
|
114
|
+
consola.log(` Source: ${d.source}`);
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
83
121
|
const oauthPath = getOauthPath(profile);
|
|
84
122
|
if (!existsSync(oauthPath)) {
|
|
85
|
-
throw new CliError('Not logged in. Run `mitsein auth login
|
|
123
|
+
throw new CliError('Not logged in. Run `mitsein auth login` or set MITSEIN_TOKEN.', ExitCode.USAGE_ERROR);
|
|
86
124
|
}
|
|
87
125
|
const data = JSON.parse(readFileSync(oauthPath, 'utf8')) as Record<string, string>;
|
|
88
126
|
emit(
|
|
@@ -91,6 +129,7 @@ export function registerAuth(program: Command): void {
|
|
|
91
129
|
user_id: data.user_id ?? 'unknown',
|
|
92
130
|
profile,
|
|
93
131
|
endpoint: data.endpoint ?? '',
|
|
132
|
+
source: 'profile',
|
|
94
133
|
},
|
|
95
134
|
(payload) => {
|
|
96
135
|
const d = payload as Record<string, string>;
|
package/src/commands/thread.ts
CHANGED
|
@@ -73,7 +73,7 @@ export function registerThread(program: Command): void {
|
|
|
73
73
|
timeoutSec: httpTimeoutSec(g),
|
|
74
74
|
debug: g.debug,
|
|
75
75
|
});
|
|
76
|
-
const result = await client.post('/api/
|
|
76
|
+
const result = await client.post('/api/threads', { title: title ?? '' });
|
|
77
77
|
emit(result);
|
|
78
78
|
})
|
|
79
79
|
);
|