@efengx/openclaw-channel-dragon 0.5.19 → 0.5.20
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.
|
@@ -15,6 +15,9 @@ export declare class ChannelComponent implements IComponent {
|
|
|
15
15
|
constructor(options: ChannelOptions, telemetry: TelemetryComponent);
|
|
16
16
|
start(): Promise<void>;
|
|
17
17
|
stop(): Promise<void>;
|
|
18
|
+
private normalizeSessionSegment;
|
|
19
|
+
private resolveOpenClawAgentId;
|
|
20
|
+
private buildOpenClawSessionKey;
|
|
18
21
|
private stringifyProgressDetail;
|
|
19
22
|
deliverToOpenClaw: (content: string, sessionId?: string, modelId?: string, attachments?: any[], messageId?: string | number) => Promise<void>;
|
|
20
23
|
handleOutboundText: (ctx: any) => Promise<{
|
|
@@ -10,6 +10,29 @@ export class ChannelComponent {
|
|
|
10
10
|
}
|
|
11
11
|
async start() { }
|
|
12
12
|
async stop() { }
|
|
13
|
+
normalizeSessionSegment(value, fallback) {
|
|
14
|
+
const raw = String(value || '').trim().toLowerCase();
|
|
15
|
+
const normalized = raw
|
|
16
|
+
.replace(/[^a-z0-9_-]+/g, '-')
|
|
17
|
+
.replace(/^-+/, '')
|
|
18
|
+
.replace(/-+$/, '')
|
|
19
|
+
.slice(0, 64);
|
|
20
|
+
return normalized || fallback;
|
|
21
|
+
}
|
|
22
|
+
resolveOpenClawAgentId() {
|
|
23
|
+
const agents = this.options.cfg?.agents?.list;
|
|
24
|
+
if (Array.isArray(agents)) {
|
|
25
|
+
const selected = agents.find((agent) => agent?.default)?.id || agents[0]?.id;
|
|
26
|
+
return this.normalizeSessionSegment(selected, 'main');
|
|
27
|
+
}
|
|
28
|
+
return 'main';
|
|
29
|
+
}
|
|
30
|
+
buildOpenClawSessionKey(agentId, sessionId) {
|
|
31
|
+
const openClawAgentId = this.resolveOpenClawAgentId();
|
|
32
|
+
const dragonAgentId = this.normalizeSessionSegment(agentId, 'agent');
|
|
33
|
+
const workbenchSessionId = this.normalizeSessionSegment(sessionId, 'default');
|
|
34
|
+
return `agent:${openClawAgentId}:dragon:direct:${dragonAgentId}:${workbenchSessionId}`;
|
|
35
|
+
}
|
|
13
36
|
stringifyProgressDetail(value, maxLength = 240) {
|
|
14
37
|
if (typeof value === 'string') {
|
|
15
38
|
const text = value.trim();
|
|
@@ -41,12 +64,12 @@ export class ChannelComponent {
|
|
|
41
64
|
if (typeof replyDispatcher !== 'function')
|
|
42
65
|
return;
|
|
43
66
|
const { accountId, agentId, cfg, logger } = this.options;
|
|
44
|
-
const sessionKey =
|
|
67
|
+
const sessionKey = this.buildOpenClawSessionKey(agentId, sessionId);
|
|
45
68
|
const previous = this.sessionQueues.get(sessionKey) || Promise.resolve();
|
|
46
69
|
const current = previous
|
|
47
70
|
.catch(() => { })
|
|
48
71
|
.then(async () => {
|
|
49
|
-
logger?.info?.(`[Dragon Plugin] Sending to OpenClaw: "${content.substring(0, 50)}${content.length > 50 ? '...' : ''}" [
|
|
72
|
+
logger?.info?.(`[Dragon Plugin] Sending to OpenClaw: "${content.substring(0, 50)}${content.length > 50 ? '...' : ''}" [WorkbenchSession: ${sessionId}] [OpenClawSessionKey: ${sessionKey}]`);
|
|
50
73
|
const progress = (payload) => this.telemetry.reportProgress({
|
|
51
74
|
sessionId,
|
|
52
75
|
msgId: replyMsgId,
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const dragonChannelPluginVersion = "0.5.
|
|
1
|
+
export declare const dragonChannelPluginVersion = "0.5.20";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const dragonChannelPluginVersion = "0.5.
|
|
1
|
+
export const dragonChannelPluginVersion = "0.5.20";
|
package/openclaw.plugin.json
CHANGED