@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
56 lines • 2.69 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. =========
// What `exec >&-` leaves a stream pointing at: a closed descriptor whose
// writes drop. bash fails them with `Bad file descriptor`; mirage has no
// descriptor to fail, a documented divergence.
export const CLOSED = '';
// What a dup names when it copies one of the terminal's own streams
// (`exec 2>&1`, `exec 1>&2`, `exec 1>&0`): the target, not the role, so a
// later rebinding of the copied descriptor does not move the copy.
// Distinct from every path (a virtual path starts with `/`) and from
// CLOSED.
export const TO_STDIN = '&0';
export const TO_STDOUT = '&1';
export const TO_STDERR = '&2';
// What `exec 1<f` binds a stream to: the file's read end, `<` then the
// virtual path. Distinct from a path (which starts with `/`), from CLOSED
// and from the terminal streams. A dup copies it with its offset (`exec
// 0<&1` reads on where fd 1 stopped), a transient `<&1` reads it, and a
// write to it fails as one to stdin's end does.
export const OPEN_FOR_READING = '<';
// What `exec 3<>f` binds a descriptor to: the file opened for reading and
// writing, `<>` then the virtual path. It starts with OPEN_FOR_READING, so
// every reader of a descriptor reads this one too.
export const OPEN_FOR_READ_WRITE = '<>';
// The session fields an `exec` redirect line binds, put back as one
// unit when a later redirect on the line fails.
export const EXEC_STREAM_FIELDS = [
'execStdout',
'execStdoutAppend',
'execStdoutInput',
'execStderr',
'execStderrAppend',
'execStderrInput',
'execStdin',
'execStdinUnreadable',
'execStdinIdentity',
];
// The `exec` binding of each standard output stream with no `exec`
// redirect in force: what a statement's own redirect of the stream holds it
// at while the statement runs.
export const EXEC_STREAM_UNBOUND = {
1: { execStdout: null, execStdoutAppend: false, execStdoutInput: null },
2: { execStderr: null, execStderrAppend: false, execStderrInput: null },
};
//# sourceMappingURL=constants.js.map