UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

35 lines (34 loc) • 1.3 kB
import { i as truncateWithMarker } from "./utf16-slice-CuDyEXgS.mjs"; import { N as deriveSessionName, a as compareProcessSessionStartOrder, h as listRunningSessions } from "./bash-process-registry-Dh1460VO.mjs"; //#region src/agents/bash-process-references.ts /** * Compact references for active background bash sessions. * These references are surfaced in agent context so follow-up turns can * reconnect to prior long-running work. */ const DEFAULT_ACTIVE_PROCESS_LIMIT = 8; const MAX_COMMAND_LABEL_CHARS = 140; /** List active background process sessions for one scope key, newest first. */ function listActiveProcessSessionReferences(e) { const t = e.scopeKey?.trim(); if (!t) return []; const n = Date.now(); return listRunningSessions().filter((e) => e.scopeKey === t).toSorted(compareProcessSessionStartOrder).slice(0, DEFAULT_ACTIVE_PROCESS_LIMIT).map((e) => ({ sessionId: e.id, status: "running", pid: e.pid, startedAt: e.startedAt, runtimeMs: Math.max(0, n - e.startedAt), cwd: e.cwd, command: e.command, name: truncateWithMarker(deriveSessionName(e.command) || e.command, MAX_COMMAND_LABEL_CHARS, { marker: "...", reserve: 3, trimEnd: false }), tail: e.tail, truncated: e.truncated })); } //#endregion export { listActiveProcessSessionReferences as t };