import { store } from './shared.ts' import { describeWatch } from './watch-config.ts' import { getSelfAgents, listWatches } from './watch-store.ts' /** * List every armed watch with its cursor, fire mode, targets (secret names * only, never values), and the last notify results. * @example * import watchList from 'kody:@kentcdodds/exchange-threads/watch-list' * const result = await watchList() * // => { ok: true, watches: [{ threadId: 'th_1', fire: 'batch', targets: [...], selfAgentIds: [...] }] } */ export default async function watchList() { const bucket = await store() const watches = await listWatches(bucket) return { ok: true, watches: await Promise.all( watches.map(async (watch) => ({ ...describeWatch(watch), selfAgentIds: await getSelfAgents(bucket, watch.threadId), })), ), } }