UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

18 lines (17 loc) • 1.02 kB
import { createSnapshotFrameSeat } from "./snapshot-frame-seat.js"; export function workspaceSnapshotOf(facts) { const active = facts.worktreeSessionRef?.current; return { cwd: facts.cwdRef?.current ?? facts.root, root: facts.root, ...(active !== undefined ? { entered: { dir: active.worktreeDir, ...(active.entered === true ? { byPath: true } : {}) } } : {}), ...(facts.session !== undefined ? { session: facts.session } : {}), ...(facts.declaration !== undefined ? { declaration: facts.declaration } : {}), ...(facts.directories !== undefined && facts.directories.length > 0 ? { directories: facts.directories } : {}), ...(facts.project !== undefined ? { project: { id: facts.project.id, source: facts.project.source } } : {}), remote: facts.remote, }; } export function createWorkspaceFrameSeat(facts) { return facts === undefined ? { subscribe: () => { }, observe: () => { } } : createSnapshotFrameSeat(() => workspaceSnapshotOf(facts)); }