mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 08:03:39 +00:00
feat(coding-agent): add Android/Termux support
- Make @mariozechner/clipboard an optional dependency - Lazy-load clipboard module with graceful fallback - Add Termux clipboard support via termux-clipboard-set - Skip image clipboard on Termux (not supported) fixes #1164
This commit is contained in:
parent
bc3fda518d
commit
cb850676e7
3 changed files with 33 additions and 4 deletions
|
|
@ -39,7 +39,6 @@
|
|||
"prepublishOnly": "npm run clean && npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mariozechner/clipboard": "^0.3.2",
|
||||
"@mariozechner/jiti": "^2.6.2",
|
||||
"@mariozechner/pi-agent-core": "^0.50.9",
|
||||
"@mariozechner/pi-ai": "^0.50.9",
|
||||
|
|
@ -56,6 +55,9 @@
|
|||
"proper-lockfile": "^4.1.2",
|
||||
"yaml": "^2.8.2"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@mariozechner/clipboard": "^0.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/diff": "^7.0.2",
|
||||
"@types/ms": "^2.1.0",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,22 @@
|
|||
import Clipboard from "@mariozechner/clipboard";
|
||||
import { spawnSync } from "child_process";
|
||||
import { createRequire } from "module";
|
||||
|
||||
import { loadPhoton } from "./photon.js";
|
||||
|
||||
type ClipboardModule = {
|
||||
hasImage: () => boolean;
|
||||
getImageBinary: () => Promise<Array<number>>;
|
||||
};
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
let Clipboard: ClipboardModule | null = null;
|
||||
|
||||
try {
|
||||
Clipboard = require("@mariozechner/clipboard") as ClipboardModule;
|
||||
} catch {
|
||||
Clipboard = null;
|
||||
}
|
||||
|
||||
export type ClipboardImage = {
|
||||
bytes: Uint8Array;
|
||||
mimeType: string;
|
||||
|
|
@ -168,12 +182,16 @@ export async function readClipboardImage(options?: {
|
|||
const env = options?.env ?? process.env;
|
||||
const platform = options?.platform ?? process.platform;
|
||||
|
||||
if (env.TERMUX_VERSION) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let image: ClipboardImage | null = null;
|
||||
|
||||
if (platform === "linux" && isWaylandSession(env)) {
|
||||
image = readClipboardImageViaWlPaste() ?? readClipboardImageViaXclip();
|
||||
} else {
|
||||
if (!Clipboard.hasImage()) {
|
||||
if (!Clipboard || !Clipboard.hasImage()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,16 @@ export function copyToClipboard(text: string): void {
|
|||
} else if (p === "win32") {
|
||||
execSync("clip", options);
|
||||
} else {
|
||||
// Linux - try wl-copy for Wayland, fall back to xclip/xsel for X11
|
||||
// Linux. Try Termux, Wayland, or X11 clipboard tools.
|
||||
if (process.env.TERMUX_VERSION) {
|
||||
try {
|
||||
execSync("termux-clipboard-set", options);
|
||||
return;
|
||||
} catch {
|
||||
// Fall back to Wayland or X11 tools.
|
||||
}
|
||||
}
|
||||
|
||||
const isWayland = isWaylandSession();
|
||||
if (isWayland) {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue