57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
export type DiscussionStatus = "active" | "closed";
|
|
|
|
export type DiscussionMetadata = {
|
|
mode: "discussion";
|
|
discussionChannelId: string;
|
|
originChannelId: string;
|
|
initiatorAgentId: string;
|
|
initiatorSessionId: string;
|
|
initiatorWorkspaceRoot?: string;
|
|
discussGuide: string;
|
|
status: DiscussionStatus;
|
|
createdAt: string;
|
|
completedAt?: string;
|
|
summaryPath?: string;
|
|
idleReminderSent?: boolean;
|
|
};
|
|
|
|
const discussionByChannelId = new Map<string, DiscussionMetadata>();
|
|
|
|
export function createDiscussion(metadata: DiscussionMetadata): DiscussionMetadata {
|
|
discussionByChannelId.set(metadata.discussionChannelId, metadata);
|
|
return metadata;
|
|
}
|
|
|
|
export function getDiscussion(channelId: string): DiscussionMetadata | undefined {
|
|
return discussionByChannelId.get(channelId);
|
|
}
|
|
|
|
export function isDiscussionChannel(channelId: string): boolean {
|
|
return discussionByChannelId.has(channelId);
|
|
}
|
|
|
|
export function isDiscussionClosed(channelId: string): boolean {
|
|
return discussionByChannelId.get(channelId)?.status === "closed";
|
|
}
|
|
|
|
export function markDiscussionIdleReminderSent(channelId: string): void {
|
|
const rec = discussionByChannelId.get(channelId);
|
|
if (!rec) return;
|
|
rec.idleReminderSent = true;
|
|
}
|
|
|
|
export function clearDiscussionIdleReminderSent(channelId: string): void {
|
|
const rec = discussionByChannelId.get(channelId);
|
|
if (!rec) return;
|
|
rec.idleReminderSent = false;
|
|
}
|
|
|
|
export function closeDiscussion(channelId: string, summaryPath: string): DiscussionMetadata | undefined {
|
|
const rec = discussionByChannelId.get(channelId);
|
|
if (!rec) return undefined;
|
|
rec.status = "closed";
|
|
rec.summaryPath = summaryPath;
|
|
rec.completedAt = new Date().toISOString();
|
|
return rec;
|
|
}
|