feat(csm): bootstrap discussion callback flow
This commit is contained in:
55
plugin/core/discussion-state.ts
Normal file
55
plugin/core/discussion-state.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
export type DiscussionStatus = "active" | "closed";
|
||||
|
||||
export type DiscussionMetadata = {
|
||||
mode: "discussion";
|
||||
discussionChannelId: string;
|
||||
originChannelId: string;
|
||||
initiatorAgentId: string;
|
||||
initiatorSessionId: 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;
|
||||
}
|
||||
Reference in New Issue
Block a user