@brianli/kimaki 0.4.72-brianli.2 → 0.4.72-brianli.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/dist/cli.js +23 -9
- package/package.json +1 -1
- package/src/cli.ts +24 -9
package/dist/cli.js
CHANGED
|
@@ -761,20 +761,34 @@ async function run({ restart, addChannels, useWorktrees, enableVoiceChannels, })
|
|
|
761
761
|
// 1. KIMAKI_BOT_TOKEN env var (headless/CI deployments)
|
|
762
762
|
// 2. Saved credentials in the database
|
|
763
763
|
// 3. Interactive setup wizard (first-time users)
|
|
764
|
-
// App ID is
|
|
764
|
+
// App ID comes from auth mode env or is derived from token (base64 first segment).
|
|
765
765
|
const { appId, token, isQuickStart } = await (async () => {
|
|
766
766
|
const envBot = getBotToken({ allowDatabase: false });
|
|
767
767
|
const existingBot = getBotToken({ preferEnv: false });
|
|
768
|
-
// 1. Env var takes precedence (headless deployments)
|
|
769
|
-
if (envBot && !forceSetup) {
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
768
|
+
// 1. Env var/auth mode takes precedence (headless deployments)
|
|
769
|
+
if (envBot && (!forceSetup || envBot.source === 'auth')) {
|
|
770
|
+
if (forceSetup && envBot.source === 'auth') {
|
|
771
|
+
cliLogger.log('Auth mode enabled; skipping interactive setup (--restart ignored)');
|
|
772
|
+
}
|
|
773
|
+
const resolvedAppId = envBot.appId || appIdFromToken(envBot.token);
|
|
774
|
+
if (!resolvedAppId) {
|
|
775
|
+
cliLogger.error(envBot.source === 'auth'
|
|
776
|
+
? 'Auth mode requires KIMAKI_APP_ID when using KIMAKI_GUILD_ID/KIMAKI_PRIVATE_KEY.'
|
|
777
|
+
: 'Could not derive Application ID from KIMAKI_BOT_TOKEN. The token appears malformed.');
|
|
773
778
|
process.exit(EXIT_NO_RESTART);
|
|
774
779
|
}
|
|
775
|
-
await setBotToken(
|
|
776
|
-
|
|
777
|
-
|
|
780
|
+
await setBotToken(resolvedAppId, envBot.token);
|
|
781
|
+
if (envBot.source === 'auth') {
|
|
782
|
+
cliLogger.log(`Using auth mode credentials (App ID: ${resolvedAppId})`);
|
|
783
|
+
}
|
|
784
|
+
else {
|
|
785
|
+
cliLogger.log(`Using KIMAKI_BOT_TOKEN env var (App ID: ${resolvedAppId})`);
|
|
786
|
+
}
|
|
787
|
+
return {
|
|
788
|
+
appId: resolvedAppId,
|
|
789
|
+
token: envBot.token,
|
|
790
|
+
isQuickStart: !addChannels,
|
|
791
|
+
};
|
|
778
792
|
}
|
|
779
793
|
// 2. Saved credentials in the database
|
|
780
794
|
if (existingBot && !forceSetup) {
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -1121,7 +1121,7 @@ async function run({
|
|
|
1121
1121
|
// 1. KIMAKI_BOT_TOKEN env var (headless/CI deployments)
|
|
1122
1122
|
// 2. Saved credentials in the database
|
|
1123
1123
|
// 3. Interactive setup wizard (first-time users)
|
|
1124
|
-
// App ID is
|
|
1124
|
+
// App ID comes from auth mode env or is derived from token (base64 first segment).
|
|
1125
1125
|
const { appId, token, isQuickStart } = await (async (): Promise<{
|
|
1126
1126
|
appId: string
|
|
1127
1127
|
token: string
|
|
@@ -1130,18 +1130,33 @@ async function run({
|
|
|
1130
1130
|
const envBot = getBotToken({ allowDatabase: false })
|
|
1131
1131
|
const existingBot = getBotToken({ preferEnv: false })
|
|
1132
1132
|
|
|
1133
|
-
// 1. Env var takes precedence (headless deployments)
|
|
1134
|
-
if (envBot && !forceSetup) {
|
|
1135
|
-
|
|
1136
|
-
|
|
1133
|
+
// 1. Env var/auth mode takes precedence (headless deployments)
|
|
1134
|
+
if (envBot && (!forceSetup || envBot.source === 'auth')) {
|
|
1135
|
+
if (forceSetup && envBot.source === 'auth') {
|
|
1136
|
+
cliLogger.log('Auth mode enabled; skipping interactive setup (--restart ignored)')
|
|
1137
|
+
}
|
|
1138
|
+
const resolvedAppId = envBot.appId || appIdFromToken(envBot.token)
|
|
1139
|
+
if (!resolvedAppId) {
|
|
1137
1140
|
cliLogger.error(
|
|
1138
|
-
|
|
1141
|
+
envBot.source === 'auth'
|
|
1142
|
+
? 'Auth mode requires KIMAKI_APP_ID when using KIMAKI_GUILD_ID/KIMAKI_PRIVATE_KEY.'
|
|
1143
|
+
: 'Could not derive Application ID from KIMAKI_BOT_TOKEN. The token appears malformed.',
|
|
1139
1144
|
)
|
|
1140
1145
|
process.exit(EXIT_NO_RESTART)
|
|
1141
1146
|
}
|
|
1142
|
-
await setBotToken(
|
|
1143
|
-
|
|
1144
|
-
|
|
1147
|
+
await setBotToken(resolvedAppId, envBot.token)
|
|
1148
|
+
if (envBot.source === 'auth') {
|
|
1149
|
+
cliLogger.log(`Using auth mode credentials (App ID: ${resolvedAppId})`)
|
|
1150
|
+
} else {
|
|
1151
|
+
cliLogger.log(
|
|
1152
|
+
`Using KIMAKI_BOT_TOKEN env var (App ID: ${resolvedAppId})`,
|
|
1153
|
+
)
|
|
1154
|
+
}
|
|
1155
|
+
return {
|
|
1156
|
+
appId: resolvedAppId,
|
|
1157
|
+
token: envBot.token,
|
|
1158
|
+
isQuickStart: !addChannels,
|
|
1159
|
+
}
|
|
1145
1160
|
}
|
|
1146
1161
|
|
|
1147
1162
|
// 2. Saved credentials in the database
|