@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
64 lines • 3.02 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 { ContentType } from "../../types.js";
import { INT_JSON, JSON_NAME, JSONL_NAME } from "../hierarchy/codec.js";
import { Slot, Scope, makeDetectScope } from "../hierarchy/scope.js";
export const TOP_LEVEL_DIRS = ['traces', 'sessions', 'prompts', 'datasets'];
// One description of the tree: readdir, stat and read all classify through it,
// so they cannot disagree about what a path means.
export const SCOPES = [
new Scope({ kind: 'traces', segments: ['traces'], probed: false }),
new Scope({
kind: 'trace',
segments: ['traces', new Slot('trace_id', JSON_NAME)],
leaf: true,
filetype: ContentType.JSON,
}),
new Scope({ kind: 'sessions', segments: ['sessions'], probed: false }),
new Scope({ kind: 'session', segments: ['sessions', new Slot('session_id')] }),
new Scope({
kind: 'session_trace',
segments: ['sessions', new Slot('session_id'), new Slot('trace_id', JSON_NAME)],
leaf: true,
filetype: ContentType.JSON,
}),
new Scope({ kind: 'prompts', segments: ['prompts'], probed: false }),
new Scope({ kind: 'prompt', segments: ['prompts', new Slot('prompt_name')] }),
// A version that is not a plain ASCII integer cannot name a prompt version,
// so it fails the scope match and reads as ENOENT instead of an int() crash
// (python) or a digit-prefix guess (typescript).
new Scope({
kind: 'prompt_version',
segments: ['prompts', new Slot('prompt_name'), new Slot('version', INT_JSON)],
leaf: true,
filetype: ContentType.JSON,
}),
new Scope({ kind: 'datasets', segments: ['datasets'], probed: false }),
new Scope({ kind: 'dataset', segments: ['datasets', new Slot('dataset_name')] }),
new Scope({
kind: 'dataset_items',
segments: ['datasets', new Slot('dataset_name'), 'items.jsonl'],
leaf: true,
filetype: ContentType.TEXT,
}),
new Scope({ kind: 'runs', segments: ['datasets', new Slot('dataset_name'), 'runs'] }),
new Scope({
kind: 'dataset_run',
segments: ['datasets', new Slot('dataset_name'), 'runs', new Slot('run_name', JSONL_NAME)],
leaf: true,
filetype: ContentType.TEXT,
}),
];
export const detectScope = makeDetectScope(SCOPES);
//# sourceMappingURL=scope.js.map