Skip to content

armgit / Orkas

Public Imported from GitHub
0

Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.

2.0 KB
Raw Blame
// Shared renderer policy for actions offered on produced/workspace files.
// Main-process handlers still validate every request; this module keeps the
// Files tab, produced-file footer, and preview header from advertising actions
// that the matching backend contract will reject.
(function initFileOperationPolicy(root) {
  const textExts = new Set([
    '.md', '.markdown', '.txt', '.csv', '.tsv', '.jsonl', '.ndjson', '.rst', '.tex', '.srt', '.vtt', '.json', '.yaml', '.yml', '.log',
    '.html', '.htm', '.xml', '.toml', '.ini', '.conf',
    '.py', '.pyi', '.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs',
    '.sh', '.bash', '.zsh', '.ps1', '.cmd', '.bat', '.rb', '.go', '.rs', '.java', '.kt',
    '.c', '.cpp', '.cc', '.h', '.hpp', '.css', '.scss', '.less',
    '.sql', '.graphql', '.gql',
  ]);
  const chatTextExts = textExts;
  const imageExts = new Set(['.png', '.jpg', '.jpeg', '.webp', '.gif']);
  const videoExts = new Set(['.mp4', '.webm', '.mov', '.m4v', '.ogv']);
  const audioExts = new Set(['.mp3', '.wav', '.ogg', '.opus', '.m4a', '.aac', '.flac']);
  const officeExts = new Set(['.docx', '.docm', '.xlsx', '.xlsm', '.xls', '.pptx', '.pptm']);
  const libraryExts = new Set([...textExts, ...imageExts, ...officeExts, '.pdf']);
  const chatExts = new Set([
    ...chatTextExts, ...imageExts, ...videoExts, ...audioExts, ...officeExts, '.pdf', '.zip',
  ]);

  function extensionOf(name) {
    const base = String(name || '').split(/[\\/]/).pop() || '';
    const index = base.lastIndexOf('.');
    return index >= 0 ? base.slice(index).toLowerCase() : '';
  }

  function canAddToChat(name) {
    return chatExts.has(extensionOf(name));
  }

  function canAddToLibrary(name, options = {}) {
    const ext = extensionOf(name);
    return libraryExts.has(ext) || (options.projectScoped === true && videoExts.has(ext));
  }

  const policy = Object.freeze({ extensionOf, canAddToChat, canAddToLibrary });
  if (root) root.FileOperationPolicy = policy;
  if (typeof module !== 'undefined' && module.exports) module.exports = policy;
})(typeof window !== 'undefined' ? window : null);