37 lines
1.8 KiB
JavaScript
37 lines
1.8 KiB
JavaScript
// IDE Remote: what a device may do. DENY BY DEFAULT: a command that is not listed here answers {ok:false, error:'denied'}.
|
|
// Pure data (no DOM, no imports): a node test (ide/tests/remote-allow.test.mjs) checks that every name below is a command the IDE registers.
|
|
// Never remote: file.write / create / delete / rename, git commit / push / reset..., run.start, tool.install, settings, MCP / agent / plugins, update.*.
|
|
|
|
const CLAUDE = ['claude.send', 'claude.stop', 'claude.stopAll', 'claude.status', 'claude.history.list', 'claude.history.read'];
|
|
const TERMINAL = ['terminal.open', 'terminal.write', 'terminal.resize', 'terminal.close'];
|
|
|
|
/** Commands per scope (registered in ide/src/Ide.php and games/ide/src/Main.php). */
|
|
export const REMOTE_ALLOW = {
|
|
claude: CLAUDE,
|
|
terminal: TERMINAL,
|
|
all: [...CLAUDE, ...TERMINAL, 'file.read', 'files.list', 'git.status', 'project.info'],
|
|
};
|
|
|
|
/** Commands the host answers itself (not PHP commands): the late joiner's state. */
|
|
export const REMOTE_VIRTUAL = ['snap'];
|
|
|
|
/** The IDE's events forwarded per scope (same names and payloads as backend.on). */
|
|
export const REMOTE_EVENTS = {
|
|
claude: ['claude.event', 'claude.exit'],
|
|
terminal: ['terminal.output', 'terminal.exit'],
|
|
all: ['claude.event', 'claude.exit', 'terminal.output', 'terminal.exit', 'run.output'],
|
|
};
|
|
|
|
/** The live streams ("panels") a device may subscribe to, per scope, and the events each one carries. */
|
|
export const REMOTE_PANELS = {
|
|
claude: ['claude.event', 'claude.exit'],
|
|
terminal: ['terminal.output', 'terminal.exit'],
|
|
run: ['run.output'],
|
|
};
|
|
export const REMOTE_PANELS_OF = { claude: ['claude'], terminal: ['terminal'], all: ['claude', 'terminal', 'run'] };
|
|
|
|
export const SCOPES = ['claude', 'terminal', 'all'];
|
|
|
|
export function isAllowed(scope, name) {
|
|
return !!REMOTE_ALLOW[scope] && REMOTE_ALLOW[scope].includes(name);
|
|
}
|