@efengx/openclaw-channel-dragon 0.5.25 → 0.5.27

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineChannelPluginEntry, createChatChannelPlugin, createChannelPluginBase } from "openclaw/plugin-sdk/core";
1
+ import { defineChannelPluginEntry, createChatChannelPlugin, createChannelPluginBase, buildChannelOutboundSessionRoute } from "openclaw/plugin-sdk/core";
2
2
  import { createRawChannelSendResultAdapter } from "openclaw/plugin-sdk/channel-send-result";
3
3
  import * as InfraRuntime from "openclaw/plugin-sdk/infra-runtime";
4
4
  import { ServiceContainer } from "./core/ServiceContainer.js";
@@ -86,6 +86,101 @@ const plugin = createChatChannelPlugin({
86
86
  });
87
87
  }
88
88
  },
89
+ messaging: {
90
+ targetPrefixes: ["dragon-workbench", "dragon"],
91
+ normalizeTarget: (raw) => {
92
+ let target = raw || "";
93
+ for (const prefix of ["dragon-workbench-", "dragon-workbench:", "dragon-", "dragon:"]) {
94
+ if (target.startsWith(prefix)) {
95
+ target = target.substring(prefix.length);
96
+ }
97
+ }
98
+ return target ? `dragon-workbench-${target}` : "";
99
+ },
100
+ resolveOutboundSessionRoute: (params) => {
101
+ let target = params.target || "";
102
+ for (const prefix of ["dragon-workbench-", "dragon-workbench:", "dragon-", "dragon:"]) {
103
+ if (target.startsWith(prefix)) {
104
+ target = target.substring(prefix.length);
105
+ }
106
+ }
107
+ if (!target)
108
+ return null;
109
+ return buildChannelOutboundSessionRoute({
110
+ cfg: params.cfg,
111
+ agentId: params.agentId,
112
+ channel: channelId,
113
+ accountId: params.accountId,
114
+ peer: {
115
+ kind: "direct",
116
+ id: target
117
+ },
118
+ chatType: "direct",
119
+ from: `dragon-workbench-${target}`,
120
+ to: `dragon-workbench-${target}`
121
+ });
122
+ },
123
+ targetResolver: {
124
+ looksLikeId: (raw) => {
125
+ return raw.startsWith("dragon-workbench-") || raw.startsWith("session-");
126
+ },
127
+ hint: "<sessionId>",
128
+ resolveTarget: async ({ input }) => {
129
+ let sessionId = input;
130
+ for (const prefix of ["dragon-workbench-", "dragon-workbench:", "dragon-", "dragon:"]) {
131
+ if (sessionId.startsWith(prefix)) {
132
+ sessionId = sessionId.substring(prefix.length);
133
+ }
134
+ }
135
+ return {
136
+ to: `dragon-workbench-${sessionId}`,
137
+ kind: "direct",
138
+ display: `Dragon Workbench User (${sessionId})`,
139
+ source: "normalized"
140
+ };
141
+ }
142
+ }
143
+ },
144
+ actions: {
145
+ describeMessageTool: ({ cfg, accountId }) => {
146
+ return { actions: ["send"] };
147
+ },
148
+ handleAction: async (ctx) => {
149
+ const { action, params, cfg, accountId } = ctx;
150
+ if (action === "send") {
151
+ const account = base.config.resolveAccount(cfg, accountId);
152
+ const container = await getOrCreateContainer(account, ctx);
153
+ const channel = container.get('channel');
154
+ let target = params.to || params.target || ctx.toolContext?.currentChannelId || "default";
155
+ for (const prefix of ["dragon-workbench-", "dragon-workbench:", "dragon-", "dragon:"]) {
156
+ if (target.startsWith(prefix)) {
157
+ target = target.substring(prefix.length);
158
+ }
159
+ }
160
+ const sessionId = target || "default";
161
+ let text = params.message || params.text || "";
162
+ const media = params.media || params.mediaUrl || params.path || params.filePath || params.fileUrl;
163
+ if (media && typeof media === 'string') {
164
+ const mediaLine = `MEDIA: ${media}`;
165
+ if (!text.includes(mediaLine)) {
166
+ text = text ? `${text}\n${mediaLine}` : mediaLine;
167
+ }
168
+ }
169
+ const result = await channel.handleOutboundText({
170
+ text,
171
+ peer: { id: sessionId }
172
+ });
173
+ return {
174
+ ok: result.ok,
175
+ ...result.messageId ? { messageId: result.messageId } : {},
176
+ didSendViaMessagingTool: true,
177
+ messagingToolSentTexts: [text],
178
+ messagingToolSentTargets: [target]
179
+ };
180
+ }
181
+ throw new Error(`Action "${action}" is not supported by the dragon channel plugin.`);
182
+ }
183
+ }
89
184
  },
90
185
  outbound: {
91
186
  attachedResults: createRawChannelSendResultAdapter({
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const dragonChannelPluginVersion = "0.5.25";
1
+ export declare const dragonChannelPluginVersion = "0.5.27";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const dragonChannelPluginVersion = "0.5.25";
1
+ export const dragonChannelPluginVersion = "0.5.27";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@efengx/openclaw-channel-dragon",
3
- "version": "0.5.25",
3
+ "version": "0.5.27",
4
4
  "description": "Dragon workbench channel for OpenClaw",
5
5
  "author": "feng xiang <ofengx@gmail.com>",
6
6
  "type": "module",