@aka_openclaw_plugin/mychat 0.2.9 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as tryGetMychatRuntime, i as setMychatRuntime, n as init_runtime, t as getMychatRuntime } from "./runtime-CkiGSF1r.js";
|
|
2
|
-
import { t as mychatPlugin } from "./channel-
|
|
2
|
+
import { t as mychatPlugin } from "./channel-BKVWaJny.js";
|
|
3
3
|
//#region extensions/mychat/api.ts
|
|
4
4
|
init_runtime();
|
|
5
5
|
//#endregion
|
|
@@ -3,6 +3,9 @@ import { n as resolveMychatAccounts, t as resolveMychatAccount } from "./account
|
|
|
3
3
|
import { t as mychatConfigSchema } from "./config-schema-CjCqWPdP.js";
|
|
4
4
|
import { createChannelPluginBase, createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
|
|
5
5
|
import { createAccountStatusSink } from "openclaw/plugin-sdk/channel-lifecycle";
|
|
6
|
+
import { buildChannelInboundEventContext } from "openclaw/plugin-sdk/channel-inbound";
|
|
7
|
+
import { createReplyDispatcherWithTyping, dispatchInboundMessage, finalizeInboundContext } from "openclaw/plugin-sdk/reply-runtime";
|
|
8
|
+
import { resolveAgentRoute } from "openclaw/plugin-sdk/routing";
|
|
6
9
|
import WebSocket from "ws";
|
|
7
10
|
//#region extensions/mychat/src/logger.ts
|
|
8
11
|
const PREFIX = "mychat";
|
|
@@ -774,86 +777,86 @@ async function monitorMychatProvider(ctx) {
|
|
|
774
777
|
}
|
|
775
778
|
/** Dispatch an inbound message through the OpenClaw turn runtime. */
|
|
776
779
|
async function dispatchMychatInbound(ctx, httpClient, result) {
|
|
777
|
-
const {
|
|
780
|
+
const { cfg, account } = ctx;
|
|
778
781
|
const logger = ctx.log;
|
|
779
782
|
const prefix = mychatLogPrefix("dispatch");
|
|
780
|
-
const rt =
|
|
781
|
-
if (!rt?.turn?.run) {
|
|
782
|
-
logger?.error(`${prefix} channel.turn.run not available on runtime, cannot dispatch inbound messageId=${result.context.messageId}`);
|
|
783
|
-
return;
|
|
784
|
-
}
|
|
785
|
-
logger?.info(`${prefix} dispatching inbound messageId=${result.context.messageId} senderId=${result.context.senderId} conversationId=${result.context.conversationId}`);
|
|
783
|
+
const rt = getMychatRuntime();
|
|
786
784
|
const conversationId = result.context.conversationId ?? result.context.senderId;
|
|
787
785
|
const senderId = result.context.senderId;
|
|
788
786
|
const chatType = result.context.chatType;
|
|
789
|
-
const
|
|
790
|
-
|
|
787
|
+
const route = resolveAgentRoute({
|
|
788
|
+
cfg,
|
|
791
789
|
channel: "mychat",
|
|
792
790
|
accountId: account.accountId,
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
conversation: {
|
|
814
|
-
kind: chatType,
|
|
815
|
-
id: conversationId,
|
|
816
|
-
label: result.context.senderName ?? senderId,
|
|
817
|
-
routePeer: {
|
|
818
|
-
kind: chatType,
|
|
819
|
-
id: conversationId
|
|
820
|
-
}
|
|
821
|
-
},
|
|
822
|
-
route: {
|
|
823
|
-
agentId: void 0,
|
|
824
|
-
accountId: account.accountId
|
|
825
|
-
},
|
|
826
|
-
reply: {
|
|
827
|
-
to: `mychat:${conversationId}`,
|
|
828
|
-
originatingTo: `mychat:${conversationId}`
|
|
829
|
-
},
|
|
830
|
-
message: {
|
|
831
|
-
rawBody: input.rawText,
|
|
832
|
-
commandBody: input.textForCommands,
|
|
833
|
-
bodyForAgent: input.textForAgent,
|
|
834
|
-
envelopeFrom: result.context.senderName
|
|
835
|
-
}
|
|
836
|
-
});
|
|
837
|
-
return {
|
|
838
|
-
cfg,
|
|
839
|
-
channel: "mychat",
|
|
840
|
-
accountId: account.accountId,
|
|
841
|
-
ctxPayload: msgCtx,
|
|
842
|
-
dispatchReplyWithBufferedBlockDispatcher: rt.channel.reply.dispatchReplyWithBufferedBlockDispatcher,
|
|
843
|
-
delivery: { deliver: async (payload) => {
|
|
844
|
-
const text = payload.text?.trim();
|
|
845
|
-
if (!text) return;
|
|
846
|
-
const sendResult = await httpClient.sendMessage({
|
|
847
|
-
to: conversationId,
|
|
848
|
-
text,
|
|
849
|
-
type: chatType === "group" || chatType === "thread" ? chatType : "direct"
|
|
850
|
-
});
|
|
851
|
-
if (logger) logger.debug(`${prefix} reply sent to=${conversationId} ok=${Boolean(sendResult)}`);
|
|
852
|
-
} }
|
|
853
|
-
};
|
|
791
|
+
peer: {
|
|
792
|
+
kind: chatType,
|
|
793
|
+
id: conversationId
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
const ctxPayload = finalizeInboundContext(buildChannelInboundEventContext({
|
|
797
|
+
channel: "mychat",
|
|
798
|
+
accountId: account.accountId,
|
|
799
|
+
from: `mychat:user:${senderId}`,
|
|
800
|
+
sender: {
|
|
801
|
+
id: senderId,
|
|
802
|
+
name: result.context.senderName
|
|
803
|
+
},
|
|
804
|
+
conversation: {
|
|
805
|
+
kind: chatType,
|
|
806
|
+
id: conversationId,
|
|
807
|
+
label: result.context.senderName ?? senderId,
|
|
808
|
+
routePeer: {
|
|
809
|
+
kind: chatType,
|
|
810
|
+
id: conversationId
|
|
854
811
|
}
|
|
812
|
+
},
|
|
813
|
+
route: {
|
|
814
|
+
agentId: route.agentId,
|
|
815
|
+
accountId: account.accountId
|
|
816
|
+
},
|
|
817
|
+
reply: {
|
|
818
|
+
to: `mychat:${conversationId}`,
|
|
819
|
+
originatingTo: `mychat:${conversationId}`
|
|
820
|
+
},
|
|
821
|
+
message: {
|
|
822
|
+
rawBody: result.text,
|
|
823
|
+
bodyForAgent: result.text,
|
|
824
|
+
commandBody: result.text,
|
|
825
|
+
inboundEventKind: "user_request",
|
|
826
|
+
inboundHistory: void 0,
|
|
827
|
+
envelopeFrom: result.context.senderName
|
|
828
|
+
},
|
|
829
|
+
timestamp: result.context.timestamp,
|
|
830
|
+
media: result.media,
|
|
831
|
+
extra: {
|
|
832
|
+
MychatConversationId: conversationId,
|
|
833
|
+
MychatBotId: rt.mychat?.botSelf.botId
|
|
855
834
|
}
|
|
835
|
+
}));
|
|
836
|
+
const { dispatcher, replyOptions, markDispatchIdle, markRunComplete } = createReplyDispatcherWithTyping({
|
|
837
|
+
cfg,
|
|
838
|
+
agentId: route.agentId,
|
|
839
|
+
channel: "mychat",
|
|
840
|
+
accountId: account.accountId,
|
|
841
|
+
deliver: async (payload) => {
|
|
842
|
+
const text = payload.text?.trim();
|
|
843
|
+
if (!text) return;
|
|
844
|
+
const sendResult = await httpClient.sendMessage({
|
|
845
|
+
to: conversationId,
|
|
846
|
+
text,
|
|
847
|
+
type: chatType === "group" || chatType === "thread" ? chatType : "direct"
|
|
848
|
+
});
|
|
849
|
+
if (logger) logger.debug(`${prefix} reply sent to=${conversationId} ok=${Boolean(sendResult)}`);
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
await dispatchInboundMessage({
|
|
853
|
+
ctx: ctxPayload,
|
|
854
|
+
cfg,
|
|
855
|
+
dispatcher,
|
|
856
|
+
replyOptions: { ...replyOptions }
|
|
856
857
|
});
|
|
858
|
+
markRunComplete();
|
|
859
|
+
markDispatchIdle();
|
|
857
860
|
}
|
|
858
861
|
//#endregion
|
|
859
862
|
//#region extensions/mychat/src/shared.ts
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as mychatPlugin } from "./channel-
|
|
1
|
+
import { t as mychatPlugin } from "./channel-BKVWaJny.js";
|
|
2
2
|
export { mychatPlugin };
|