Ground bot dialogue and add bounded conversational follow-ups
Core tests / core (push) Successful in 45s

This commit is contained in:
Codex
2026-09-24 19:23:03 +08:00
parent 132bf75f9d
commit d573ae2345
6 changed files with 56 additions and 17 deletions
+8 -5
View File
@@ -1,7 +1,7 @@
export type ConversationChannel='say'|'whisper';
export type ConversationRequest={
socialTurn?:0|1;
socialTurn?:0|1|2|3;
id:string;
createdAt:string;
speakerName:string;
@@ -90,7 +90,7 @@ export async function leaseConversation(db:D1Database):Promise<ConversationReque
if(updated.meta.changes!==1)return null;
return {
socialTurn:row.channel==='social-start'?0:row.channel==='social-reply'?1:undefined,
socialTurn:row.channel==='social-start'?0:row.channel==='social-reply'?1:row.channel==='social-turn-2'?2:row.channel==='social-turn-3'?3:undefined,
id:row.id,
createdAt:row.created_at,
speakerName:row.speaker_name,
@@ -162,9 +162,12 @@ export async function queueSocialEncounter(db:D1Database,payload:Record<string,u
}
export async function queueSocialReply(db:D1Database,request:ConversationRequest,botName:string,reply:string){
if(request.socialTurn!==0)return;
if(request.socialTurn===undefined||request.socialTurn>=3||Date.now()-Date.parse(request.createdAt)>120_000)return;
// A farewell ends the encounter instead of forcing another response.
if(request.socialTurn>0&&/\b(bye|goodbye|see you|see ya|catch you later)\b/i.test(reply))return;
const channel=request.socialTurn===0?'social-reply':`social-turn-${request.socialTurn+1}`;
await db.prepare(`INSERT OR IGNORE INTO conversation_requests
(id,created_at,speaker_name,message,channel,zone_name,receiver,selected_player,nearby_bots,status,attempts)
VALUES (?,?,?,?,'social-reply',?,?,?,?,'pending',0)`)
.bind(request.id+':reply',new Date().toISOString(),botName,reply,request.zoneName,request.speakerName,request.speakerName,botName).run();
VALUES (?,?,?,?,?,?,?,?,?,'pending',0)`)
.bind(request.id+':reply',request.createdAt,botName,reply,channel,request.zoneName,request.speakerName,request.speakerName,botName).run();
}