mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-01 21:03:34 +00:00
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
// Filters task status visibility by requester, owner, and flow scope.
|
|
import {
|
|
findTaskByRunId,
|
|
getTaskById,
|
|
listTaskRecords,
|
|
listTasksForAgentId,
|
|
listTasksForSessionKey,
|
|
} from "./task-registry.js";
|
|
import type { TaskRecord } from "./task-registry.types.js";
|
|
|
|
/** Returns only the session lookup fields needed by task status commands. */
|
|
export function getTaskSessionLookupByIdForStatus(
|
|
taskId: string,
|
|
):
|
|
| Pick<TaskRecord, "requesterSessionKey" | "ownerKey" | "runId" | "agentId" | "requesterAgentId">
|
|
| undefined {
|
|
const task = getTaskById(taskId);
|
|
return task
|
|
? {
|
|
requesterSessionKey: task.requesterSessionKey,
|
|
ownerKey: task.ownerKey,
|
|
...(task.runId ? { runId: task.runId } : {}),
|
|
...(task.agentId ? { agentId: task.agentId } : {}),
|
|
...(task.requesterAgentId ? { requesterAgentId: task.requesterAgentId } : {}),
|
|
}
|
|
: undefined;
|
|
}
|
|
|
|
export function listTasksForSessionKeyForStatus(sessionKey: string): TaskRecord[] {
|
|
return listTasksForSessionKey(sessionKey);
|
|
}
|
|
|
|
export function listTasksForOwnerOrRequesterSessionKeyForStatus(sessionKey: string): TaskRecord[] {
|
|
return listTaskRecords().filter(
|
|
(task) => task.requesterSessionKey === sessionKey || task.ownerKey === sessionKey,
|
|
);
|
|
}
|
|
|
|
export function listTasksForAgentIdForStatus(agentId: string): TaskRecord[] {
|
|
return listTasksForAgentId(agentId);
|
|
}
|
|
|
|
export function findTaskByRunIdForStatus(runId: string): TaskRecord | undefined {
|
|
return findTaskByRunId(runId);
|
|
}
|