UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

56 lines • 2.09 kB
// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. ========= // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ========= Copyright 2026 @ Strukto.AI All Rights Reserved. ========= // Condition -> the name the interpreter's own errno table knows it by. // Identity except for mirage's own conditions: the interpreter calls // "attribute not set" ENODATA and a lost conditional write ESTALE. const CONDITION_KEY = { EBADF: 'EBADF', ENOENT: 'ENOENT', ENOTDIR: 'ENOTDIR', EISDIR: 'EISDIR', EEXIST: 'EEXIST', EACCES: 'EACCES', EPERM: 'EPERM', ENOTEMPTY: 'ENOTEMPTY', EXDEV: 'EXDEV', ENOTSUP: 'ENOTSUP', ELOOP: 'ELOOP', EINVAL: 'EINVAL', EIO: 'EIO', EBUSY: 'EBUSY', EROFS: 'EROFS', EFBIG: 'EFBIG', EDQUOT: 'EDQUOT', EPIPE: 'EPIPE', NO_XATTR: 'ENODATA', STALE_WRITE: 'ESTALE', }; /** * Build the error a guest syscall should fail with. * * Both halves come from the running interpreter: the constructor so the * kernel recognizes it as an errno rather than a crash, and the number * so it is musl's and not a literal that happens to be right on Linux. * A name this build's table does not define answers EIO rather than * ErrnoError(undefined). * * Args: * host: the Emscripten FS namespace supplying `ErrnoError`. * codes: that interpreter's errno table (`pyodide.ERRNO_CODES`). * code: name of the condition to report. */ export function errnoError(host, codes, code) { return new host.ErrnoError(codes[CONDITION_KEY[code]] ?? codes.EIO); } //# sourceMappingURL=errors.js.map