feat: add OpenClaw interactive-handler adapter / 新增 OpenClaw interactive-handler adapter

This commit is contained in:
Alice (OpenClaw)
2026-05-14 08:37:30 +08:00
parent 6282667297
commit 9ce2b09f71
2 changed files with 98 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
import { persistOpenClawReplyEndState } from "./openclaw-state-file.ts"
import { buildTelegramCallbackResolution } from "../runtime/openclaw-telegram-callback-actions.ts"
import { normalizeTelegramCallback } from "../core/callback-contract.ts"
export type OpenClawTelegramInteractiveContext = {
callback: {
data: string
messageId: string
chatId: string
}
conversationId: string
sessionKey: string | null
callbackId: string
respond: {
editButtons: (input: { buttons: { text: string; callback_data: string }[][] }) => Promise<void> | void
reply: (input: { text: string }) => Promise<void> | void
}
}
export async function handleOpenClawTelegramReplyEndInteraction(baseDir: string, ctx: OpenClawTelegramInteractiveContext): Promise<boolean> {
const normalized = normalizeTelegramCallback({
callbackData: ctx.callback.data,
conversationId: ctx.conversationId,
sessionKey: ctx.sessionKey,
sourceMessageId: ctx.callback.messageId,
sourceCallbackId: ctx.callbackId,
timestamp: new Date().toISOString(),
})
if (!normalized) {
return false
}
persistOpenClawReplyEndState(baseDir, normalized)
const resolution = buildTelegramCallbackResolution(normalized.choice)
await ctx.respond.editButtons({ buttons: resolution.buttons })
await ctx.respond.reply({ text: resolution.acknowledgement })
return true
}