@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
36 lines • 1.68 kB
JavaScript
// ========= 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. =========
import { enoent } from "../../errors/fs.js";
import { makeRead } from "../hierarchy/read.js";
import { messageJsonBytes } from "./messages.js";
import { detectScope } from "./scope.js";
async function readMessage(accessor, _match, path, entry) {
if (entry === null)
throw enoent(path);
const raw = await accessor.gmail.getMessageRaw(String(entry.extra.message_id));
return messageJsonBytes(raw);
}
async function readAttachment(accessor, match, path, entry) {
// The message id decodes from the attachment dir's `subject__id`
// segment; the attachment id only exists in the listing, so the row
// stays the proof of existence AND the id source.
if (entry === null)
throw enoent(path);
return accessor.gmail.getAttachment(match.slots.message_id ?? '', String(entry.extra.attachment_id));
}
export const read = makeRead(detectScope, {
message: readMessage,
attachment: readAttachment,
});
//# sourceMappingURL=read.js.map