UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

80 lines • 2.83 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 { LangfuseAccessor } from "../../accessor/langfuse.js"; import { HttpLangfuseTransport } from "../../core/langfuse/client.js"; import { read as langfuseRead } from "../../core/langfuse/read.js"; import { readdir as langfuseReaddir } from "../../core/langfuse/readdir.js"; import { stat as langfuseStat } from "../../core/langfuse/stat.js"; import { VFSName } from "../../types.js"; import { BaseVFS } from "../base.js"; import { LangfuseConfig } from "./config.js"; export const VFS_MD = `\`\`\`text {prefix} traces/ <trace-id>.json sessions/ <session-id>/ <trace-id>.json prompts/ <prompt-name>/ <version>.json datasets/ <dataset-name>/ items.jsonl runs/ <run-name>.jsonl \`\`\``; export class LangfuseVFS extends BaseVFS { handed = { stat: ['entry'], }; name = VFSName.LANGFUSE; cachesReads = true; vfsMd = VFS_MD; config; accessor; constructor(config) { super(); this.config = config; const transportOpts = { publicKey: config.publicKey, secretKey: config.secretKey, }; if (config.host !== undefined) transportOpts.host = config.host; if (config.timeout !== undefined) transportOpts.timeout = config.timeout; const accessorConfig = {}; if (config.defaultTraceLimit !== undefined) { accessorConfig.defaultTraceLimit = config.defaultTraceLimit; } if (config.defaultFromTimestamp !== undefined) { accessorConfig.defaultFromTimestamp = config.defaultFromTimestamp; } this.accessor = new LangfuseAccessor(new HttpLangfuseTransport(transportOpts), accessorConfig); } readdir(path) { return langfuseReaddir(this.accessor, path); } async read(path) { return langfuseRead(this.accessor, path); } stat(path, handed) { return langfuseStat(this.accessor, path, handed?.entry); } getState() { return Promise.resolve(this.configState(LangfuseConfig, this.config)); } } //# sourceMappingURL=langfuse.js.map