@mastra/core
Version:
147 lines (146 loc) • 5.38 kB
JavaScript
// src/workspace/errors.ts
var WorkspaceError = class extends Error {
code;
workspaceId;
constructor(message, code, workspaceId) {
super(message);
this.code = code;
this.workspaceId = workspaceId;
this.name = "WorkspaceError";
}
};
var WorkspaceNotAvailableError = class extends WorkspaceError {
constructor() {
super("Workspace not available. Ensure the agent has a workspace configured.", "NO_WORKSPACE");
this.name = "WorkspaceNotAvailableError";
}
};
var FilesystemNotAvailableError = class extends WorkspaceError {
constructor() {
super("Workspace does not have a filesystem configured", "NO_FILESYSTEM");
this.name = "FilesystemNotAvailableError";
}
};
var SandboxNotAvailableError = class extends WorkspaceError {
constructor(message) {
super(message ?? "Workspace does not have a sandbox configured", "NO_SANDBOX");
this.name = "SandboxNotAvailableError";
}
};
var SandboxFeatureNotSupportedError = class extends WorkspaceError {
constructor(feature) {
super(`Sandbox does not support ${feature}`, "FEATURE_NOT_SUPPORTED");
this.name = "SandboxFeatureNotSupportedError";
}
};
var SearchNotAvailableError = class extends WorkspaceError {
constructor() {
super("Workspace does not have search configured (enable bm25, or provide a vectorStore with an embedder or one that generates embeddings itself)", "NO_SEARCH");
this.name = "SearchNotAvailableError";
}
};
var WorkspaceNotReadyError = class extends WorkspaceError {
constructor(workspaceId, status) {
super(`Workspace is not ready (status: ${status})`, "NOT_READY", workspaceId);
this.name = "WorkspaceNotReadyError";
}
};
var WorkspaceReadOnlyError = class extends WorkspaceError {
constructor(operation) {
super(`Workspace is in read-only mode. Cannot perform: ${operation}`, "READ_ONLY");
this.name = "WorkspaceReadOnlyError";
}
};
var FilesystemError = class extends Error {
code;
path;
constructor(message, code, path) {
super(message);
this.code = code;
this.path = path;
this.name = "FilesystemError";
}
};
var FileNotFoundError = class extends FilesystemError {
constructor(path) {
super(`File not found: ${path}`, "ENOENT", path);
this.name = "FileNotFoundError";
}
};
var DirectoryNotFoundError = class extends FilesystemError {
constructor(path) {
super(`Directory not found: ${path}`, "ENOENT", path);
this.name = "DirectoryNotFoundError";
}
};
var FileExistsError = class extends FilesystemError {
constructor(path) {
super(`File already exists: ${path}`, "EEXIST", path);
this.name = "FileExistsError";
}
};
var IsDirectoryError = class extends FilesystemError {
constructor(path) {
super(`Path is a directory: ${path}`, "EISDIR", path);
this.name = "IsDirectoryError";
}
};
var NotDirectoryError = class extends FilesystemError {
constructor(path) {
super(`Path is not a directory: ${path}`, "ENOTDIR", path);
this.name = "NotDirectoryError";
}
};
/**
* Thrown by a filesystem's optional native `grep()` capability when the
* requested pattern can't be executed natively (e.g., JS regex syntax the
* provider's search engine doesn't support). Callers catch this and fall
* back to the host-side walk-and-read implementation.
*/
var UnsupportedGrepPatternError = class extends FilesystemError {
constructor(pattern, reason) {
super(`Unsupported grep pattern: ${pattern}${reason ? ` (${reason})` : ""}`, "EUNSUPPORTED_PATTERN", pattern);
this.name = "UnsupportedGrepPatternError";
}
};
var DirectoryNotEmptyError = class extends FilesystemError {
constructor(path) {
super(`Directory not empty: ${path}`, "ENOTEMPTY", path);
this.name = "DirectoryNotEmptyError";
}
};
var PermissionError = class extends FilesystemError {
operation;
constructor(path, operation) {
super(`Permission denied: ${operation} on ${path}`, "EACCES", path);
this.operation = operation;
this.name = "PermissionError";
}
};
var FileReadRequiredError = class extends FilesystemError {
constructor(path, reason) {
super(reason, "EREAD_REQUIRED", path);
this.name = "FileReadRequiredError";
}
};
var StaleFileError = class extends FilesystemError {
expectedMtime;
actualMtime;
constructor(path, expectedMtime, actualMtime) {
super(`File was modified externally: ${path} (expected mtime ${expectedMtime.toISOString()}, actual ${actualMtime.toISOString()})`, "ESTALE", path);
this.expectedMtime = expectedMtime;
this.actualMtime = actualMtime;
this.name = "StaleFileError";
}
};
/**
* Error thrown when a filesystem operation is attempted before initialization.
*/
var FilesystemNotReadyError = class extends FilesystemError {
constructor(id) {
super(`Filesystem "${id}" is not ready. Call init() first or use ensureReady().`, "ENOTREADY", id);
this.name = "FilesystemNotReadyError";
}
};
export { WorkspaceError as _, FileReadRequiredError as a, WorkspaceReadOnlyError as b, FilesystemNotReadyError as c, PermissionError as d, SandboxFeatureNotSupportedError as f, UnsupportedGrepPatternError as g, StaleFileError as h, FileNotFoundError as i, IsDirectoryError as l, SearchNotAvailableError as m, DirectoryNotFoundError as n, FilesystemError as o, SandboxNotAvailableError as p, FileExistsError as r, FilesystemNotAvailableError as s, DirectoryNotEmptyError as t, NotDirectoryError as u, WorkspaceNotAvailableError as v, WorkspaceNotReadyError as y };
//# sourceMappingURL=errors-CzFYpCHw.js.map