Skip to content

Commit 7c126f1

Browse files
committed
Fix: Authentication, Clipboard, and Token Storage for Termux
1 parent c4e2dcd commit 7c126f1

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

packages/cli/src/config/settings.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,9 @@ export function loadEnvironment(
552552
continue;
553553
}
554554

555-
// Load variable only if it's not already set in the environment.
556-
if (!Object.hasOwn(process.env, key)) {
555+
// Load variable. In Termux, we allow overriding to ensure .env settings are respected.
556+
const isTermux = process.env['TERMUX_VERSION'] !== undefined;
557+
if (!Object.hasOwn(process.env, key) || isTermux) {
557558
process.env[key] = value;
558559
}
559560
}

packages/cli/src/ui/utils/commandUtils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,16 @@ export const copyToClipboard = async (text: string): Promise<void> => {
257257
}
258258

259259
// Local / non-TTY fallback
260+
const isTermux = process.env['TERMUX_VERSION'] !== undefined;
261+
if (isTermux) {
262+
try {
263+
const { execSync } = await import('node:child_process');
264+
execSync('termux-clipboard-set', { input: text });
265+
return;
266+
} catch (e) {
267+
debugLogger.warn('Failed to use termux-clipboard-set:', e);
268+
}
269+
}
260270
await clipboardy.write(text);
261271
};
262272

packages/core/src/mcp/token-storage/hybrid-token-storage.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export class HybridTokenStorage extends BaseTokenStorage {
2121
}
2222

2323
private async initializeStorage(): Promise<TokenStorage> {
24-
const forceFileStorage = process.env[FORCE_FILE_STORAGE_ENV_VAR] === 'true';
24+
const isTermux = process.env['TERMUX_VERSION'] !== undefined;
25+
const forceFileStorage =
26+
process.env[FORCE_FILE_STORAGE_ENV_VAR] === 'true' || isTermux;
2527

2628
if (!forceFileStorage) {
2729
try {

0 commit comments

Comments
 (0)