@efengx/openclaw-channel-dragon 0.5.3 → 0.5.5
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.
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IComponent } from "../../core/IComponent.js";
|
|
2
|
-
import { BridgeComponent } from "../bridge/BridgeComponent.js";
|
|
3
2
|
import { TelemetryComponent } from "../telemetry/TelemetryComponent.js";
|
|
4
3
|
export interface ChannelOptions {
|
|
5
4
|
accountId: string;
|
|
@@ -10,10 +9,9 @@ export interface ChannelOptions {
|
|
|
10
9
|
}
|
|
11
10
|
export declare class ChannelComponent implements IComponent {
|
|
12
11
|
private options;
|
|
13
|
-
private bridge;
|
|
14
12
|
private telemetry;
|
|
15
13
|
private processedMessageIds;
|
|
16
|
-
constructor(options: ChannelOptions,
|
|
14
|
+
constructor(options: ChannelOptions, telemetry: TelemetryComponent);
|
|
17
15
|
start(): Promise<void>;
|
|
18
16
|
stop(): Promise<void>;
|
|
19
17
|
deliverToOpenClaw: (content: string, sessionId?: string, modelId?: string, attachments?: any[], messageId?: string | number) => Promise<void>;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
const channelId = "dragon";
|
|
2
2
|
export class ChannelComponent {
|
|
3
3
|
options;
|
|
4
|
-
bridge;
|
|
5
4
|
telemetry;
|
|
6
5
|
processedMessageIds = new Set();
|
|
7
|
-
constructor(options,
|
|
6
|
+
constructor(options, telemetry) {
|
|
8
7
|
this.options = options;
|
|
9
|
-
this.bridge = bridge;
|
|
10
8
|
this.telemetry = telemetry;
|
|
11
9
|
}
|
|
12
10
|
async start() { }
|
|
@@ -48,16 +46,6 @@ export class ChannelComponent {
|
|
|
48
46
|
const text = payload?.text || "";
|
|
49
47
|
if (!text && !payload?.tool_calls?.length)
|
|
50
48
|
return;
|
|
51
|
-
if (this.bridge.client) {
|
|
52
|
-
this.bridge.client.sendJson({
|
|
53
|
-
type: "outbound_text",
|
|
54
|
-
channel: channelId,
|
|
55
|
-
text,
|
|
56
|
-
tool_calls: payload?.tool_calls,
|
|
57
|
-
reasoning_content: payload?.reasoning_content,
|
|
58
|
-
route: { agentId, accountId, peer: { kind: "direct", id: sessionId }, sessionKey },
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
49
|
await this.telemetry.reportReply({
|
|
62
50
|
content: text,
|
|
63
51
|
sessionId,
|
|
@@ -70,32 +58,12 @@ export class ChannelComponent {
|
|
|
70
58
|
};
|
|
71
59
|
handleOutboundText = async (ctx) => {
|
|
72
60
|
const text = ctx?.text || "";
|
|
73
|
-
const {
|
|
61
|
+
const { logger } = this.options;
|
|
74
62
|
logger?.info?.(`[Dragon Plugin] Outbound Text (Action): "${text.substring(0, 50)}${text.length > 50 ? '...' : ''}"`);
|
|
75
|
-
if (this.bridge.client) {
|
|
76
|
-
this.bridge.client.sendJson({
|
|
77
|
-
type: "outbound_text",
|
|
78
|
-
channel: channelId,
|
|
79
|
-
text,
|
|
80
|
-
route: { agentId, accountId, peer: ctx?.peer, sessionKey: ctx?.ctx?.SessionKey },
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
63
|
await this.telemetry.reportReply({ content: text, sessionId: ctx?.peer?.id || 'default' });
|
|
84
64
|
return { ok: true, messageId: Date.now().toString() };
|
|
85
65
|
};
|
|
86
66
|
handleAgentEvent = async (evt) => {
|
|
87
|
-
const { agentId, accountId } = this.options;
|
|
88
|
-
if (this.bridge.client) {
|
|
89
|
-
this.bridge.client.sendJson({
|
|
90
|
-
type: "agent_event",
|
|
91
|
-
channel: channelId,
|
|
92
|
-
agentId,
|
|
93
|
-
runId: evt.runId,
|
|
94
|
-
stream: evt.stream,
|
|
95
|
-
data: evt.data,
|
|
96
|
-
sessionKey: evt.sessionKey
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
67
|
await this.telemetry.reportEvent(evt.stream, evt.data, evt.ts);
|
|
100
68
|
};
|
|
101
69
|
}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import { defineChannelPluginEntry, createChatChannelPlugin, createChannelPluginB
|
|
|
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";
|
|
5
|
-
import { BridgeComponent } from "./components/bridge/BridgeComponent.js";
|
|
6
5
|
import { PollingComponent } from "./components/sync/PollingComponent.js";
|
|
7
6
|
import { TelemetryComponent } from "./components/telemetry/TelemetryComponent.js";
|
|
8
7
|
import { HttpComponent } from "./components/http/HttpComponent.js";
|
|
@@ -24,15 +23,6 @@ async function getOrCreateContainer(account, ctx) {
|
|
|
24
23
|
logger
|
|
25
24
|
}));
|
|
26
25
|
const telemetry = container.register('telemetry', new TelemetryComponent(http, account.agentId));
|
|
27
|
-
const bridge = container.register('bridge', new BridgeComponent({
|
|
28
|
-
host: account.bridgeHost,
|
|
29
|
-
port: parseInt(account.bridgePort || "18799", 10),
|
|
30
|
-
token: account.bridgeToken || "",
|
|
31
|
-
agentId: account.agentId,
|
|
32
|
-
gatewayPort: parseInt(account.gatewayPort || "18789", 10),
|
|
33
|
-
gatewayToken: account.gatewayToken || "",
|
|
34
|
-
logger
|
|
35
|
-
}));
|
|
36
26
|
// 2. Channel Logic (Centralized)
|
|
37
27
|
const channel = container.register('channel', new ChannelComponent({
|
|
38
28
|
accountId: account.accountId,
|
|
@@ -40,7 +30,7 @@ async function getOrCreateContainer(account, ctx) {
|
|
|
40
30
|
channelRuntime: ctx.channelRuntime,
|
|
41
31
|
cfg: ctx.cfg,
|
|
42
32
|
logger
|
|
43
|
-
},
|
|
33
|
+
}, telemetry));
|
|
44
34
|
// 3. Sync Infrastructure (SSE + Polling)
|
|
45
35
|
container.register('sse', new SseComponent(http, channel, {
|
|
46
36
|
agentId: account.agentId,
|
|
@@ -71,17 +61,11 @@ const base = createChannelPluginBase({
|
|
|
71
61
|
},
|
|
72
62
|
resolveAccount: (cfg, accountId = "default") => {
|
|
73
63
|
const accountConfig = cfg.channels?.[channelId]?.accounts?.[accountId] || {};
|
|
74
|
-
const host = accountConfig.bridgeHost || accountConfig.host;
|
|
75
64
|
return {
|
|
76
65
|
accountId,
|
|
77
66
|
agentId: accountConfig.agentId || accountId,
|
|
78
67
|
orchestratorUrl: accountConfig.orchestratorUrl || "http://127.0.0.1:4000",
|
|
79
68
|
orchestratorAuthToken: accountConfig.orchestratorAuthToken || accountConfig.authToken,
|
|
80
|
-
bridgeHost: host,
|
|
81
|
-
bridgePort: accountConfig.bridgePort,
|
|
82
|
-
bridgeToken: accountConfig.bridgeToken,
|
|
83
|
-
gatewayPort: accountConfig.gatewayPort,
|
|
84
|
-
gatewayToken: accountConfig.gatewayToken,
|
|
85
69
|
};
|
|
86
70
|
},
|
|
87
71
|
},
|
package/openclaw.plugin.json
CHANGED