waveterm/frontend/util/platformutil.ts
Mike Sawka 6a173a6227
working on more terminal context (#2444)
* add automatic OSC 7 support to bash and zsh
* add new wave OSC 16162 (planck length) to get up-to-date shell
information into blockrtinfo. currently implemented only for zsh. bash
will not support as rich of data as zsh, but we'll be able to do some.
* new rtinfo will be used to provide better context for AI in the
future, and to make sure AI is running safe commands.
* added a small local machine description to tab context (so AI knows
we're running on MacOS, Linux, or Windows)
2025-10-17 12:19:40 -07:00

39 lines
1,008 B
TypeScript

// Copyright 2025, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
export const PlatformMacOS = "darwin";
export const PlatformWindows = "win32";
export let PLATFORM: NodeJS.Platform = PlatformMacOS;
export function setPlatform(platform: NodeJS.Platform) {
PLATFORM = platform;
}
export function isMacOS(): boolean {
return PLATFORM == PlatformMacOS;
}
export function isWindows(): boolean {
return PLATFORM == PlatformWindows;
}
export function makeNativeLabel(isDirectory: boolean) {
let managerName: string;
if (!isDirectory) {
managerName = "Default Application";
} else if (PLATFORM === PlatformMacOS) {
managerName = "Finder";
} else if (PLATFORM == PlatformWindows) {
managerName = "Explorer";
} else {
managerName = "File Manager";
}
let fileAction: string;
if (isDirectory) {
fileAction = "Reveal";
} else {
fileAction = "Open File";
}
return `${fileAction} in ${managerName}`;
}