UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

110 lines (109 loc) • 4.17 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 { TrelloAccessor } from "../../accessor/trello.js"; import { HttpTrelloTransport } from "../../core/trello/client.js"; import { TrelloConfig } from "../../core/trello/config.js"; import { read as trelloRead } from "../../core/trello/read.js"; import { readdir as trelloReaddir } from "../../core/trello/readdir.js"; import { filesContaining as trelloFilesContaining } from "../../core/trello/search.js"; import { stat as trelloStat } from "../../core/trello/stat.js"; import { VFSName } from "../../types.js"; import { BaseVFS } from "../base.js"; export const VFS_MD = `\`\`\`text {prefix} workspaces/ <workspace-name>__<workspace-id>/ workspace.json boards/ <board-name>__<board-id>/ board.json members/ <full-name>__<member-id>.json labels/ <label-name>__<label-id>.json lists/ <list-name>__<list-id>/ list.json cards/ <card-name>__<card-id>/ card.json comments.jsonl \`\`\` - \`ls\` directories first to discover exact names. - To act on boards and cards (list boards, members, lists, labels, cards and comments; create, update, move, assign, label and comment on cards), use the \`trello\` CLI if installed (\`trello --help\`).`; export class TrelloVFS extends BaseVFS { handed = { readdir: ['entry'], read: ['parent'], stat: ['entry'], }; name = VFSName.TRELLO; cachesReads = true; vfsMd = VFS_MD; wholeWordSearch = true; config; accessor; // Trello's search answers for cards; comments and the board's other files // are always read. searchable = [ 'workspaces/*/boards/*/lists/*/cards/*/card.json', ]; constructor(config) { super(); this.config = config; const transportOpts = { apiKey: config.apiKey, apiToken: config.apiToken, }; if (config.baseUrl !== undefined) transportOpts.baseUrl = config.baseUrl; if (config.timeout !== undefined) transportOpts.timeout = config.timeout; const accessorOpts = { capped: () => this.walkLimit >= 0 }; if (config.workspaceId !== undefined) accessorOpts.workspaceId = config.workspaceId; if (config.boardIds !== undefined) accessorOpts.boardIds = config.boardIds; this.accessor = new TrelloAccessor(new HttpTrelloTransport(transportOpts), accessorOpts); } /** * Whether this VFS answers `name`; with no walk limit it reads every * file rather than ask the service's search. */ supports(name) { if (name === 'files_containing' && this.walkLimit < 0) return false; return super.supports(name); } filesContaining(path, text, opts) { if (!opts.wholeWord || this.walkLimit < 0) return Promise.resolve(null); return trelloFilesContaining(this.accessor, text, [path]); } readdir(path, handed) { return trelloReaddir(this.accessor, path, handed?.entry); } async read(path, handed) { return trelloRead(this.accessor, path, null, handed?.parent); } stat(path, handed) { return trelloStat(this.accessor, path, handed?.entry); } getState() { return Promise.resolve(this.configState(TrelloConfig, this.config)); } } //# sourceMappingURL=trello.js.map