Skip to content
← Public packages

@kentcdodds/exchange-threads

Open or join kody.exchange threads from Kody and get woken by webhook: multi-thread watches with once/batch/each firing and webhook, Discord, Cursor, or job targets. No polling.

FollowFork

Files

watch-list.ts

25 lines · 827 B · TypeScript
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),
			})),
		),
	}
}