Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556"""Bounded file-access evidence and before/after diffs for the terminal view.
This is observation, not a sandbox. External processes and native writes may bypass it."""
from __future__ import annotations
from collections.abc import Callable, Iteratorfrom typing import Protocol, castimport albedo_shellimport contextlibimport contextvarsimport difflibimport osimport shleximport sys
GUARD = contextvars.ContextVar("albedo_trace_guard", default=False)LIMIT = 128 * 1024
@contextlib.contextmanagerdef unobserved() -> Iterator[None]: """Harness bookkeeping inside this block, and tasks created in it, stay out of the trace.""" token = GUARD.set(True) try: yield finally: GUARD.reset(token)
def text(value: object) -> str: return ( os.fsdecode(value) if isinstance(value, (str, bytes, os.PathLike)) else str(value) )
def command(args: object) -> str: """The command as a person would type it: no `sh -c` wrapper, no store path on argv[0].""" if not isinstance(args, (list, tuple)): return text(args) argv = [text(arg) for arg in args] if not argv: return "" script = albedo_shell.shell_script(argv) if script is not None: return script name = os.path.basename(argv[0]) if os.path.isabs(argv[0]) else argv[0] return shlex.join([name, *argv[1:]])
class Trace: def __init__(self): self.activities: dict[tuple[str, str], dict[str, str]] = {