@fontdo/5g-message 1.0.4 → 1.0.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.
- package/index.ts +26 -26
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -97,7 +97,7 @@ function resolveCustomIMAccount(
|
|
|
97
97
|
): CustomIMAccount {
|
|
98
98
|
const actualAccountId = accountId ?? DEFAULT_ACCOUNT_ID;
|
|
99
99
|
const channels = cfg.channels as Record<string, Record<string, unknown>> | undefined;
|
|
100
|
-
const customImChannel = channels?.["
|
|
100
|
+
const customImChannel = channels?.["fontdo-5g-message"] as Record<string, unknown> | undefined;
|
|
101
101
|
const accounts = customImChannel?.accounts as Record<string, Record<string, unknown>> | undefined;
|
|
102
102
|
const account = accounts?.[actualAccountId] as Record<string, unknown> | undefined;
|
|
103
103
|
|
|
@@ -126,7 +126,7 @@ function resolveCustomIMAccount(
|
|
|
126
126
|
|
|
127
127
|
function listCustomIMAccountIds(cfg: Record<string, unknown>): string[] {
|
|
128
128
|
const channels = cfg.channels as Record<string, Record<string, unknown>> | undefined;
|
|
129
|
-
const customImChannel = channels?.["
|
|
129
|
+
const customImChannel = channels?.["fontdo-5g-message"] as Record<string, unknown> | undefined;
|
|
130
130
|
const accounts = customImChannel?.accounts as Record<string, Record<string, unknown>> | undefined;
|
|
131
131
|
return accounts ? Object.keys(accounts) : [];
|
|
132
132
|
}
|
|
@@ -441,7 +441,7 @@ async function dispatchCustomIMMessage(params: {
|
|
|
441
441
|
try {
|
|
442
442
|
route = core.channel.routing.resolveAgentRoute({
|
|
443
443
|
cfg,
|
|
444
|
-
channel: "
|
|
444
|
+
channel: "fontdo-5g-message",
|
|
445
445
|
accountId: account.accountId,
|
|
446
446
|
peer: {
|
|
447
447
|
kind: isGroup ? "group" : "direct",
|
|
@@ -455,7 +455,7 @@ async function dispatchCustomIMMessage(params: {
|
|
|
455
455
|
}
|
|
456
456
|
|
|
457
457
|
// Build the message context
|
|
458
|
-
const customImFrom = `
|
|
458
|
+
const customImFrom = `fontdo-5g-message:${msg.sender}`;
|
|
459
459
|
const customImTo = isGroup ? `chat:${chatId}` : `user:${msg.sender}`;
|
|
460
460
|
|
|
461
461
|
// Format message envelope
|
|
@@ -481,13 +481,13 @@ async function dispatchCustomIMMessage(params: {
|
|
|
481
481
|
GroupSubject: isGroup ? chatId : undefined,
|
|
482
482
|
SenderName: msg.sender,
|
|
483
483
|
SenderId: msg.sender,
|
|
484
|
-
Provider: "
|
|
485
|
-
Surface: "
|
|
484
|
+
Provider: "fontdo-5g-message" as const,
|
|
485
|
+
Surface: "fontdo-5g-message" as const,
|
|
486
486
|
MessageSid: msg.messageId,
|
|
487
487
|
Timestamp: msg.timestamp,
|
|
488
488
|
WasMentioned: false,
|
|
489
489
|
CommandAuthorized: true,
|
|
490
|
-
OriginatingChannel: "
|
|
490
|
+
OriginatingChannel: "fontdo-5g-message" as const,
|
|
491
491
|
OriginatingTo: customImTo,
|
|
492
492
|
});
|
|
493
493
|
|
|
@@ -579,16 +579,16 @@ async function dispatchCustomIMMessage(params: {
|
|
|
579
579
|
// Channel Plugin Definition
|
|
580
580
|
// ============================================================================
|
|
581
581
|
|
|
582
|
-
export const
|
|
583
|
-
id: "
|
|
582
|
+
export const fontdo5GMessagePlugin: ChannelPlugin<CustomIMAccount> = {
|
|
583
|
+
id: "fontdo-5g-message",
|
|
584
584
|
|
|
585
585
|
meta: {
|
|
586
|
-
id: "
|
|
587
|
-
label: "
|
|
588
|
-
selectionLabel: "
|
|
589
|
-
docsPath: "/channels/
|
|
590
|
-
blurb: "
|
|
591
|
-
aliases: ["
|
|
586
|
+
id: "fontdo-5g-message",
|
|
587
|
+
label: "Fontdo 5G Message",
|
|
588
|
+
selectionLabel: "Fontdo 5G Message (WebSocket)",
|
|
589
|
+
docsPath: "/channels/fontdo-5g-message",
|
|
590
|
+
blurb: "Fontdo 5G 消息平台集成,通过 WebSocket JSON-RPC 2.0 协议",
|
|
591
|
+
aliases: ["fontdo", "5g", "5g-message"],
|
|
592
592
|
},
|
|
593
593
|
|
|
594
594
|
capabilities: {
|
|
@@ -601,7 +601,7 @@ export const customIMPlugin: ChannelPlugin<CustomIMAccount> = {
|
|
|
601
601
|
reply: true,
|
|
602
602
|
},
|
|
603
603
|
|
|
604
|
-
reload: { configPrefixes: ["channels.
|
|
604
|
+
reload: { configPrefixes: ["channels.fontdo-5g-message"] },
|
|
605
605
|
|
|
606
606
|
configSchema: {
|
|
607
607
|
schema: {
|
|
@@ -664,20 +664,20 @@ export const customIMPlugin: ChannelPlugin<CustomIMAccount> = {
|
|
|
664
664
|
...cfg,
|
|
665
665
|
channels: {
|
|
666
666
|
...cfg.channels,
|
|
667
|
-
"
|
|
668
|
-
...cfg.channels?.["
|
|
667
|
+
"fontdo-5g-message": {
|
|
668
|
+
...cfg.channels?.["fontdo-5g-message"],
|
|
669
669
|
enabled: true,
|
|
670
670
|
},
|
|
671
671
|
},
|
|
672
672
|
};
|
|
673
673
|
}
|
|
674
674
|
|
|
675
|
-
const customImCfg = cfg.channels?.["
|
|
675
|
+
const customImCfg = cfg.channels?.["fontdo-5g-message"] as Record<string, unknown> | undefined;
|
|
676
676
|
return {
|
|
677
677
|
...cfg,
|
|
678
678
|
channels: {
|
|
679
679
|
...cfg.channels,
|
|
680
|
-
"
|
|
680
|
+
"fontdo-5g-message": {
|
|
681
681
|
...customImCfg,
|
|
682
682
|
accounts: {
|
|
683
683
|
...(customImCfg?.accounts as Record<string, unknown>),
|
|
@@ -718,7 +718,7 @@ export const customIMPlugin: ChannelPlugin<CustomIMAccount> = {
|
|
|
718
718
|
throw new Error(`Custom IM account ${ctx.accountId} not configured`);
|
|
719
719
|
}
|
|
720
720
|
|
|
721
|
-
ctx.log?.info(`starting
|
|
721
|
+
ctx.log?.info(`starting fontdo-5g-message[${ctx.accountId}]`);
|
|
722
722
|
|
|
723
723
|
// Set initial status
|
|
724
724
|
ctx.setStatus({ accountId: ctx.accountId, connected: false });
|
|
@@ -779,7 +779,7 @@ export const customIMPlugin: ChannelPlugin<CustomIMAccount> = {
|
|
|
779
779
|
// Wait for either abort signal or connection close
|
|
780
780
|
return new Promise<{ stop: () => void }>((resolve) => {
|
|
781
781
|
const stopHandler = () => {
|
|
782
|
-
ctx.log?.info(`stopping
|
|
782
|
+
ctx.log?.info(`stopping fontdo-5g-message[${ctx.accountId}]`);
|
|
783
783
|
ctx.setStatus({ accountId: ctx.accountId, connected: false });
|
|
784
784
|
unregisterConnection(ctx.accountId);
|
|
785
785
|
client.disconnect();
|
|
@@ -857,15 +857,15 @@ export const customIMPlugin: ChannelPlugin<CustomIMAccount> = {
|
|
|
857
857
|
// ============================================================================
|
|
858
858
|
|
|
859
859
|
const plugin = {
|
|
860
|
-
id: "
|
|
861
|
-
name: "
|
|
862
|
-
description: "
|
|
860
|
+
id: "fontdo-5g-message",
|
|
861
|
+
name: "Fontdo 5G Message",
|
|
862
|
+
description: "Fontdo 5G 消息平台集成,通过 WebSocket JSON-RPC 2.0 协议",
|
|
863
863
|
configSchema: emptyPluginConfigSchema(),
|
|
864
864
|
|
|
865
865
|
register(api: OpenClawPluginApi) {
|
|
866
866
|
// Store the runtime for use in message dispatching
|
|
867
867
|
pluginRuntime = api.runtime;
|
|
868
|
-
api.registerChannel({ plugin:
|
|
868
|
+
api.registerChannel({ plugin: fontdo5GMessagePlugin });
|
|
869
869
|
},
|
|
870
870
|
};
|
|
871
871
|
|