resolveInboxPath (resolve.ts)

clawwork · packages/desktop/src/main/inbox/resolve.ts · typescript · Apache-2.0
email, tag:path-resolution, tag:inbox-management, tag:directory-prep

Resolves inbox file path from app data dir, preparing directory for email storage.

// Source: https://github.com/clawwork-ai/clawwork | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { realpathSync } from 'fs';
import { open, realpath } from 'fs/promises';
import { resolve, sep } from 'path';

interface InboxPathInfo {
  base: string;
  full: string;
  inboxDir: string;
}

function isWithin(parent: string, child: string): boolean {
  return child === parent || child.startsWith(`${parent}${sep}`);
}

function parseInboxPath(workspacePath: string, localPath: string): InboxPathInfo | null {
  if (!localPath) return null;
  const base = resolve(workspacePath);
  const full = resolve(base, localPath);
  if (!isWithin(base, full)) return null;
  const relative =

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key