@feihan-im/openclaw-plugin 0.1.15 → 0.1.16

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/src/channel.ts CHANGED
@@ -5,12 +5,15 @@ import {
5
5
  createChatChannelPlugin,
6
6
  createChannelPluginBase,
7
7
  } from "openclaw/plugin-sdk/core";
8
+ import { createHybridChannelConfigBase } from "openclaw/plugin-sdk/channel-config-helpers";
8
9
  import type { OpenClawConfig } from "openclaw/plugin-sdk/core";
9
10
  import { listAccountIds, resolveAccountConfig } from "./config.js";
10
11
  import { sendText } from "./messaging/outbound.js";
11
12
  import { parseTarget } from "./targets.js";
12
13
  import type { FeihanAccountConfig } from "./types.js";
13
14
 
15
+ const BASE_FIELDS = ["appId", "appSecret", "backendUrl", "enabled", "enableEncryption", "requestTimeout"];
16
+
14
17
  export const base = createChannelPluginBase<FeihanAccountConfig>({
15
18
  id: "feihan",
16
19
 
@@ -28,37 +31,42 @@ export const base = createChannelPluginBase<FeihanAccountConfig>({
28
31
  },
29
32
 
30
33
  config: {
31
- listAccountIds: (cfg: OpenClawConfig) => listAccountIds(cfg),
32
- resolveAccount: (cfg: OpenClawConfig, accountId?: string | null) =>
33
- resolveAccountConfig(cfg, accountId ?? undefined),
34
- inspectAccount(cfg: OpenClawConfig, accountId?: string | null) {
35
- const resolved = resolveAccountConfig(cfg, accountId ?? undefined);
36
- const hasConfig = Boolean(
37
- resolved.appId && resolved.appSecret && resolved.backendUrl,
38
- );
39
- return {
40
- enabled: resolved.enabled,
41
- configured: hasConfig,
42
- tokenStatus: hasConfig ? "available" : "missing",
43
- };
44
- },
34
+ ...createHybridChannelConfigBase<FeihanAccountConfig>({
35
+ sectionKey: "feihan",
36
+ listAccountIds: (cfg) => listAccountIds(cfg),
37
+ resolveAccount: (cfg, accountId) =>
38
+ resolveAccountConfig(cfg, accountId ?? undefined),
39
+ defaultAccountId: () => "default",
40
+ inspectAccount(cfg, accountId) {
41
+ const resolved = resolveAccountConfig(cfg, accountId ?? undefined);
42
+ const hasConfig = Boolean(
43
+ resolved.appId && resolved.appSecret && resolved.backendUrl,
44
+ );
45
+ return {
46
+ enabled: resolved.enabled,
47
+ configured: hasConfig,
48
+ tokenStatus: hasConfig ? "available" : "missing",
49
+ };
50
+ },
51
+ clearBaseFields: BASE_FIELDS,
52
+ }),
45
53
  },
46
54
 
47
55
  setup: {
48
56
  validateInput: ({ input }) => {
49
57
  const missing: string[] = [];
50
- if (!input.appToken) missing.push("--app-token (App ID)");
51
- if (!input.token) missing.push("--token (App Secret)");
52
- if (!input.url) missing.push("--url (Backend URL)");
58
+ if (!input.appToken) missing.push("--app-token (App ID from Admin Console)");
59
+ if (!input.token) missing.push("--token (App Secret from Admin Console)");
60
+ if (!input.url) missing.push("--url (your Feihan server address)");
53
61
  if (missing.length > 0) {
54
62
  return [
55
63
  `Missing required flags: ${missing.join(", ")}`,
56
64
  "",
57
- "Either provide all flags:",
65
+ "Usage:",
58
66
  ` openclaw channels add --channel feihan --app-token <APP_ID> --token <APP_SECRET> --url <BACKEND_URL>`,
59
67
  "",
60
- "Or use the interactive wizard:",
61
- " openclaw channels add",
68
+ "You can find App ID and App Secret in:",
69
+ " Feihan Admin Console → Workplace → App Management → App Details",
62
70
  ].join("\n");
63
71
  }
64
72
  return null;
@@ -117,7 +125,8 @@ export const base = createChannelPluginBase<FeihanAccountConfig>({
117
125
  preferredEnvVar: "FEIHAN_APP_ID",
118
126
  envPrompt: "Use FEIHAN_APP_ID from environment?",
119
127
  keepPrompt: "Keep current App ID?",
120
- inputPrompt: "Enter your Feihan App ID:",
128
+ inputPrompt:
129
+ "Enter App ID (from Feihan Admin Console → Workplace → App Management → App Details):",
121
130
  inspect: ({ cfg, accountId }) => {
122
131
  const resolved = resolveAccountConfig(cfg, accountId ?? undefined);
123
132
  return {
@@ -133,7 +142,8 @@ export const base = createChannelPluginBase<FeihanAccountConfig>({
133
142
  preferredEnvVar: "FEIHAN_APP_SECRET",
134
143
  envPrompt: "Use FEIHAN_APP_SECRET from environment?",
135
144
  keepPrompt: "Keep current App Secret?",
136
- inputPrompt: "Enter your Feihan App Secret:",
145
+ inputPrompt:
146
+ "Enter App Secret (from the same App Details page, keep this value confidential):",
137
147
  inspect: ({ cfg, accountId }) => {
138
148
  const resolved = resolveAccountConfig(cfg, accountId ?? undefined);
139
149
  return {
@@ -145,11 +155,12 @@ export const base = createChannelPluginBase<FeihanAccountConfig>({
145
155
  {
146
156
  inputKey: "url",
147
157
  providerHint: "feihan",
148
- credentialLabel: "Backend URL",
158
+ credentialLabel: "Feihan Server URL",
149
159
  preferredEnvVar: "FEIHAN_BACKEND_URL",
150
160
  envPrompt: "Use FEIHAN_BACKEND_URL from environment?",
151
- keepPrompt: "Keep current Backend URL?",
152
- inputPrompt: "Enter your Feihan backend server URL:",
161
+ keepPrompt: "Keep current Feihan Server URL?",
162
+ inputPrompt:
163
+ "Enter your Feihan server address (e.g. http://192.168.10.10:21000):",
153
164
  inspect: ({ cfg, accountId }) => {
154
165
  const resolved = resolveAccountConfig(cfg, accountId ?? undefined);
155
166
  return {