UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

72 lines (71 loc) • 3.15 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. ========= import { firstLines as notionFirstLines, readStream as notionStream, } from "../../core/notion/read.js"; import { readdir as notionReaddir } from "../../core/notion/readdir.js"; import { stat as notionStat } from "../../core/notion/stat.js"; import {} from "../../io/types.js"; import { BaseVFS } from "../base.js"; export const VFS_MD = `\`\`\`text {prefix} pages/ # the page tree <page-title>__<page-id>/ page.json <child-page-title>__<child-id>/ page.json databases/ # shared databases <database-title>__<database-id>/ database.json <data-source-title>__<data-source-id>/ data_source.json rows.jsonl \`\`\` - \`page.json\` holds the page's metadata, its body rendered as Markdown and its raw blocks (nested blocks under \`children\`). - A database is a container plus one or more data sources. \`database.json\` holds the container's identity and its \`data_sources\` stubs, \`data_source.json\` the typed property schema, and \`rows.jsonl\` the rows, one JSON line each: the row page's \`page.json\` without the body, plus \`path\`, that \`page.json\`'s path below the data source directory. Row directories are not listed; open one by its path. - Titles are sanitized. Don't construct paths: \`ls\` the parent directory, or take a row's \`path\` from \`rows.jsonl\`. - \`ntn\` takes ids as positional operands, not flags: \`ntn pages get <page-id>\`, \`ntn datasources query <data-source-id>\`, \`ntn datasources resolve <database-id>\`.`; /** * Notion's functions over its accessor, which the node and browser * packages build over their own transport. */ export class NotionVFS extends BaseVFS { handed = { readdir: ['entry', 'parent'], read: ['parent'], firstLines: ['parent'], stat: ['entry', 'parent'], }; readdir(path, handed) { return notionReaddir(this.accessor, path, handed?.entry, handed?.parent); } // eslint-disable-next-line @typescript-eslint/require-await async read(path, handed) { return notionStream(this.accessor, path, handed?.parent); } firstLines(path, n, handed) { return notionFirstLines(this.accessor, path, n, handed?.parent); } stat(path, handed) { return notionStat(this.accessor, path, handed?.entry, handed?.parent); } } //# sourceMappingURL=notion.js.map