mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 10:20:45 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
117
openclaw/extensions/telegram/src/interactive-dispatch.ts
Normal file
117
openclaw/extensions/telegram/src/interactive-dispatch.ts
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
import {
|
||||
createInteractiveConversationBindingHelpers,
|
||||
dispatchPluginInteractiveHandler,
|
||||
type PluginConversationBinding,
|
||||
type PluginConversationBindingRequestParams,
|
||||
type PluginConversationBindingRequestResult,
|
||||
type PluginInteractiveRegistration,
|
||||
} from "openclaw/plugin-sdk/plugin-runtime";
|
||||
|
||||
export type TelegramInteractiveButtons = Array<
|
||||
Array<{ text: string; callback_data: string; style?: "danger" | "success" | "primary" }>
|
||||
>;
|
||||
|
||||
export type TelegramInteractiveHandlerContext = {
|
||||
channel: "telegram";
|
||||
accountId: string;
|
||||
callbackId: string;
|
||||
conversationId: string;
|
||||
parentConversationId?: string;
|
||||
senderId?: string;
|
||||
senderUsername?: string;
|
||||
threadId?: number;
|
||||
isGroup: boolean;
|
||||
isForum: boolean;
|
||||
auth: {
|
||||
isAuthorizedSender: boolean;
|
||||
};
|
||||
callback: {
|
||||
data: string;
|
||||
namespace: string;
|
||||
payload: string;
|
||||
messageId: number;
|
||||
chatId: string;
|
||||
messageText?: string;
|
||||
};
|
||||
respond: {
|
||||
reply: (params: { text: string; buttons?: TelegramInteractiveButtons }) => Promise<void>;
|
||||
editMessage: (params: { text: string; buttons?: TelegramInteractiveButtons }) => Promise<void>;
|
||||
editButtons: (params: { buttons: TelegramInteractiveButtons }) => Promise<void>;
|
||||
clearButtons: () => Promise<void>;
|
||||
deleteMessage: () => Promise<void>;
|
||||
};
|
||||
requestConversationBinding: (
|
||||
params?: PluginConversationBindingRequestParams,
|
||||
) => Promise<PluginConversationBindingRequestResult>;
|
||||
detachConversationBinding: () => Promise<{ removed: boolean }>;
|
||||
getCurrentConversationBinding: () => Promise<PluginConversationBinding | null>;
|
||||
};
|
||||
|
||||
export type TelegramInteractiveHandlerRegistration = PluginInteractiveRegistration<
|
||||
TelegramInteractiveHandlerContext,
|
||||
"telegram"
|
||||
>;
|
||||
|
||||
export type TelegramInteractiveDispatchContext = Omit<
|
||||
TelegramInteractiveHandlerContext,
|
||||
| "callback"
|
||||
| "respond"
|
||||
| "channel"
|
||||
| "requestConversationBinding"
|
||||
| "detachConversationBinding"
|
||||
| "getCurrentConversationBinding"
|
||||
> & {
|
||||
callbackMessage: {
|
||||
messageId: number;
|
||||
chatId: string;
|
||||
messageText?: string;
|
||||
};
|
||||
};
|
||||
|
||||
export async function dispatchTelegramPluginInteractiveHandler(params: {
|
||||
data: string;
|
||||
callbackId: string;
|
||||
ctx: TelegramInteractiveDispatchContext;
|
||||
respond: {
|
||||
reply: (params: { text: string; buttons?: TelegramInteractiveButtons }) => Promise<void>;
|
||||
editMessage: (params: { text: string; buttons?: TelegramInteractiveButtons }) => Promise<void>;
|
||||
editButtons: (params: { buttons: TelegramInteractiveButtons }) => Promise<void>;
|
||||
clearButtons: () => Promise<void>;
|
||||
deleteMessage: () => Promise<void>;
|
||||
};
|
||||
onMatched?: () => Promise<void> | void;
|
||||
}) {
|
||||
return await dispatchPluginInteractiveHandler<TelegramInteractiveHandlerRegistration>({
|
||||
channel: "telegram",
|
||||
data: params.data,
|
||||
dedupeId: params.callbackId,
|
||||
onMatched: params.onMatched,
|
||||
invoke: ({ registration, namespace, payload }) => {
|
||||
const { callbackMessage, ...handlerContext } = params.ctx;
|
||||
return registration.handler({
|
||||
...handlerContext,
|
||||
channel: "telegram",
|
||||
callback: {
|
||||
data: params.data,
|
||||
namespace,
|
||||
payload,
|
||||
messageId: callbackMessage.messageId,
|
||||
chatId: callbackMessage.chatId,
|
||||
messageText: callbackMessage.messageText,
|
||||
},
|
||||
respond: params.respond,
|
||||
...createInteractiveConversationBindingHelpers({
|
||||
registration,
|
||||
senderId: handlerContext.senderId,
|
||||
conversation: {
|
||||
channel: "telegram",
|
||||
accountId: handlerContext.accountId,
|
||||
conversationId: handlerContext.conversationId,
|
||||
parentConversationId: handlerContext.parentConversationId,
|
||||
threadId: handlerContext.threadId,
|
||||
},
|
||||
}),
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue