@buz-extensions/buz 1.0.0-beta.1 → 1.0.0-beta.2
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 +57 -21
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -1,24 +1,57 @@
|
|
|
1
1
|
import type { ChannelPlugin, OpenClawPluginApi } from "openclaw/plugin-sdk/line";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
buildCatchallMultiAccountChannelSchema,
|
|
4
|
+
buildChannelConfigSchema,
|
|
5
|
+
emptyPluginConfigSchema,
|
|
6
|
+
} from "openclaw/plugin-sdk/line";
|
|
4
7
|
import { z } from "zod";
|
|
5
8
|
|
|
6
|
-
const BuzAccountSchema = z
|
|
7
|
-
.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.partial();
|
|
9
|
+
const BuzAccountSchema = z.object({
|
|
10
|
+
enabled: z.boolean().optional(),
|
|
11
|
+
name: z.string().optional(),
|
|
12
|
+
serverAddress: z.string().optional(),
|
|
13
|
+
secretKey: z.string().optional(),
|
|
14
|
+
});
|
|
13
15
|
|
|
14
|
-
const BuzConfigSchema =
|
|
15
|
-
.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const BuzConfigSchema = buildCatchallMultiAccountChannelSchema(BuzAccountSchema).extend({
|
|
17
|
+
enabled: z.boolean().optional(),
|
|
18
|
+
name: z.string().optional(),
|
|
19
|
+
serverAddress: z.string().optional(),
|
|
20
|
+
secretKey: z.string().optional(),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const buzChannelConfigSchema = buildChannelConfigSchema(BuzConfigSchema);
|
|
24
|
+
buzChannelConfigSchema.uiHints = {
|
|
25
|
+
enabled: { label: "Enabled" },
|
|
26
|
+
name: { label: "Name" },
|
|
27
|
+
serverAddress: {
|
|
28
|
+
label: "Host Address",
|
|
29
|
+
placeholder: "grpc.buz.ai:443",
|
|
30
|
+
help: "buz gRPC server host:port",
|
|
31
|
+
},
|
|
32
|
+
secretKey: {
|
|
33
|
+
label: "Secret Key",
|
|
34
|
+
sensitive: true,
|
|
35
|
+
help: "IM secret key used to authenticate with buz",
|
|
36
|
+
},
|
|
37
|
+
defaultAccount: {
|
|
38
|
+
label: "Default Account",
|
|
39
|
+
advanced: true,
|
|
40
|
+
},
|
|
41
|
+
accounts: {
|
|
42
|
+
label: "Custom entries",
|
|
43
|
+
},
|
|
44
|
+
"accounts.*.enabled": { label: "Enabled" },
|
|
45
|
+
"accounts.*.name": { label: "Name" },
|
|
46
|
+
"accounts.*.serverAddress": {
|
|
47
|
+
label: "Host Address",
|
|
48
|
+
placeholder: "grpc.buz.ai:443",
|
|
49
|
+
},
|
|
50
|
+
"accounts.*.secretKey": {
|
|
51
|
+
label: "Secret Key",
|
|
52
|
+
sensitive: true,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
22
55
|
|
|
23
56
|
export const buzChannelPlugin = {
|
|
24
57
|
id: "buz",
|
|
@@ -35,7 +68,7 @@ export const buzChannelPlugin = {
|
|
|
35
68
|
threads: true,
|
|
36
69
|
media: false,
|
|
37
70
|
},
|
|
38
|
-
configSchema:
|
|
71
|
+
configSchema: buzChannelConfigSchema,
|
|
39
72
|
config: {
|
|
40
73
|
listAccountIds: (cfg: any) => {
|
|
41
74
|
const accounts = cfg?.channels?.["buz"]?.accounts || {};
|
|
@@ -50,6 +83,7 @@ export const buzChannelPlugin = {
|
|
|
50
83
|
id === "default"
|
|
51
84
|
? {
|
|
52
85
|
enabled: channelConfig.enabled,
|
|
86
|
+
name: channelConfig.name,
|
|
53
87
|
serverAddress: channelConfig.serverAddress,
|
|
54
88
|
secretKey: channelConfig.secretKey,
|
|
55
89
|
}
|
|
@@ -60,7 +94,7 @@ export const buzChannelPlugin = {
|
|
|
60
94
|
|
|
61
95
|
return {
|
|
62
96
|
accountId: id,
|
|
63
|
-
name: `buz (${id})`,
|
|
97
|
+
name: accountConfig.name || `buz (${id})`,
|
|
64
98
|
enabled: accountConfig.enabled !== false,
|
|
65
99
|
serverAddress: accountConfig.serverAddress,
|
|
66
100
|
secretKey: accountConfig.secretKey,
|
|
@@ -74,6 +108,7 @@ export const buzChannelPlugin = {
|
|
|
74
108
|
name: account.name,
|
|
75
109
|
enabled: account.enabled,
|
|
76
110
|
configured: Boolean(account.configured),
|
|
111
|
+
serverAddress: account.serverAddress,
|
|
77
112
|
}),
|
|
78
113
|
},
|
|
79
114
|
messaging: {
|
|
@@ -89,8 +124,8 @@ export const buzChannelPlugin = {
|
|
|
89
124
|
{
|
|
90
125
|
id: "serverAddress",
|
|
91
126
|
type: "text",
|
|
92
|
-
label: "
|
|
93
|
-
placeholder: "
|
|
127
|
+
label: "Host Address",
|
|
128
|
+
placeholder: "grpc.buz.ai:443",
|
|
94
129
|
},
|
|
95
130
|
{
|
|
96
131
|
id: "secretKey",
|
|
@@ -152,6 +187,7 @@ export const buzChannelPlugin = {
|
|
|
152
187
|
lastStartAt: runtime?.lastStartAt ?? null,
|
|
153
188
|
lastStopAt: runtime?.lastStopAt ?? null,
|
|
154
189
|
mode: "grpc",
|
|
190
|
+
serverAddress: account.serverAddress,
|
|
155
191
|
...(runtime?.lastError ? { lastError: runtime.lastError } : {}),
|
|
156
192
|
...(runtime?.lastInboundAt ? { lastInboundAt: runtime.lastInboundAt } : {}),
|
|
157
193
|
...(runtime?.lastOutboundAt ? { lastOutboundAt: runtime.lastOutboundAt } : {}),
|