mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-10 05:20:45 +08:00
feat: add unified IM access policies
This commit is contained in:
parent
075d2713c1
commit
840e5aa857
89 changed files with 5573 additions and 1676 deletions
32
src/channels/shared/command-permission.mjs
Normal file
32
src/channels/shared/command-permission.mjs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { isBatchInputCommand } from './batch-input.mjs';
|
||||
import { isCompactCommand } from './compact-command.mjs';
|
||||
import { isControlCommand } from './control-command.mjs';
|
||||
import { isHistoryCommand } from './history-command.mjs';
|
||||
import { isModelCommand } from './model-command.mjs';
|
||||
import { isPresetCommand } from './preset-command.mjs';
|
||||
import { isWorkspaceCommand } from './workspace-command.mjs';
|
||||
|
||||
const SIMPLE_TEXT_COMMANDS = new Set(['/help', '/status', '/new']);
|
||||
|
||||
/**
|
||||
* Match only commands that the shared bridges already execute locally.
|
||||
* Unknown slash-prefixed text remains an ordinary prompt.
|
||||
*/
|
||||
export function isSharedLocalCommand(text, {
|
||||
hasImages = false,
|
||||
hasFiles = false,
|
||||
} = {}) {
|
||||
if (typeof text !== 'string') return false;
|
||||
const command = text.trim();
|
||||
if (!command) return false;
|
||||
if (isBatchInputCommand(command) || isHistoryCommand(command)) return true;
|
||||
if (!hasFiles && (
|
||||
isControlCommand(command)
|
||||
|| isModelCommand(command)
|
||||
|| isPresetCommand(command)
|
||||
)) return true;
|
||||
if (hasImages || hasFiles) return false;
|
||||
return SIMPLE_TEXT_COMMANDS.has(command.toLowerCase())
|
||||
|| isWorkspaceCommand(command)
|
||||
|| isCompactCommand(command);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue