(
ownerWorkspaceId: string,
options: { statuses?: readonly WorkspaceTurnTaskStatus[] } = {}
)
| 161 | } |
| 162 | |
| 163 | async listWorkspaceTurns( |
| 164 | ownerWorkspaceId: string, |
| 165 | options: { statuses?: readonly WorkspaceTurnTaskStatus[] } = {} |
| 166 | ): Promise<WorkspaceTurnTaskHandleRecord[]> { |
| 167 | assert(ownerWorkspaceId.trim().length > 0, "listWorkspaceTurns requires ownerWorkspaceId"); |
| 168 | const dir = this.getOwnerHandleDir(ownerWorkspaceId); |
| 169 | let entries: string[]; |
| 170 | try { |
| 171 | entries = await fsPromises.readdir(dir); |
| 172 | } catch (error) { |
| 173 | if (isErrnoWithCode(error, "ENOENT")) return []; |
| 174 | throw error; |
| 175 | } |
| 176 | |
| 177 | const statuses = options.statuses != null ? new Set(options.statuses) : null; |
| 178 | const records = await Promise.all( |
| 179 | entries |
| 180 | .filter((entry) => entry.endsWith(".json")) |
| 181 | .map((entry) => entry.slice(0, -".json".length)) |
| 182 | .filter(isWorkspaceTurnTaskId) |
| 183 | .map((handleId) => this.readWorkspaceTurnFile(ownerWorkspaceId, handleId)) |
| 184 | ); |
| 185 | return records |
| 186 | .filter((record): record is WorkspaceTurnTaskHandleRecord => { |
| 187 | if (record == null) return false; |
| 188 | return statuses == null || statuses.has(record.status); |
| 189 | }) |
| 190 | .sort((a, b) => a.createdAt.localeCompare(b.createdAt)); |
| 191 | } |
| 192 | |
| 193 | async listAllWorkspaceTurns( |
| 194 | options: { statuses?: readonly WorkspaceTurnTaskStatus[] } = {} |
no test coverage detected