@pipes.bot/pipes-bot-channel 0.1.2 → 0.1.4

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/package.json CHANGED
@@ -1,19 +1,17 @@
1
1
  {
2
2
  "name": "@pipes.bot/pipes-bot-channel",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "WhatsApp channel via PipesBot managed proxy (OpenClaw plugin)",
5
5
  "type": "module",
6
6
  "main": "index.ts",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "ws": "^8.18.0",
10
- "zod": "^4.0.0"
9
+ "ws": "^8.18.0"
11
10
  },
12
11
  "devDependencies": {
13
12
  "@types/ws": "^8.5.13",
14
13
  "openclaw": "*",
15
- "typescript": "^5.0.0",
16
- "zod": "^4.0.0"
14
+ "typescript": "^5.0.0"
17
15
  },
18
16
  "openclaw": {
19
17
  "extensions": ["./index.ts"]
package/src/channel.ts CHANGED
@@ -1,18 +1,38 @@
1
- import type { ChannelPlugin } from "openclaw/plugin-sdk";
2
- import { buildChannelConfigSchema } from "openclaw/plugin-sdk";
3
- import { z } from "zod";
1
+ import type { ChannelPlugin, ChannelSetupInput, OpenClawConfig } from "openclaw/plugin-sdk";
4
2
  import { getConnectionStatus } from "./status-store.js";
5
3
 
6
- const PipesBotConfigSchema = z.object({
7
- apiKey: z.string().optional(),
8
- });
4
+ const CHANNEL_KEY = "pipes-bot-channel";
5
+
6
+ function getChannelConfig(cfg: OpenClawConfig): Record<string, unknown> {
7
+ return ((cfg.channels as Record<string, unknown>)?.[CHANNEL_KEY] ?? {}) as Record<string, unknown>;
8
+ }
9
+
10
+ export function resolveApiKey(cfg: OpenClawConfig): string | undefined {
11
+ const channelCfg = getChannelConfig(cfg);
12
+ const key = channelCfg.apiKey as string | undefined;
13
+ return key && key.startsWith("pk_") ? key : undefined;
14
+ }
9
15
 
10
16
  export const pipesBotChannelPlugin: ChannelPlugin = {
11
- id: "pipes-bot-channel",
12
- configSchema: buildChannelConfigSchema(PipesBotConfigSchema),
17
+ id: CHANNEL_KEY,
18
+ configSchema: {
19
+ schema: {
20
+ type: "object",
21
+ properties: {
22
+ apiKey: { type: "string" },
23
+ },
24
+ },
25
+ uiHints: {
26
+ apiKey: {
27
+ label: "PipesBot API Key",
28
+ sensitive: true,
29
+ placeholder: "pk_...",
30
+ },
31
+ },
32
+ },
13
33
 
14
34
  meta: {
15
- id: "pipes-bot-channel",
35
+ id: CHANNEL_KEY,
16
36
  label: "PipesBot (WhatsApp)",
17
37
  selectionLabel: "PipesBot (WhatsApp)",
18
38
  docsPath: "/docs/channels/pipes-bot",
@@ -26,8 +46,30 @@ export const pipesBotChannelPlugin: ChannelPlugin = {
26
46
 
27
47
  config: {
28
48
  listAccountIds: () => ["default"],
29
- resolveAccount: () => ({ apiKey: "configured" }),
30
- isConfigured: () => true,
49
+ resolveAccount: (cfg) => {
50
+ const apiKey = resolveApiKey(cfg);
51
+ return { apiKey, configured: Boolean(apiKey) };
52
+ },
53
+ isConfigured: (account) => account.configured,
54
+ },
55
+
56
+ setup: {
57
+ resolveAccountId: () => "default",
58
+ applyAccountConfig: ({ cfg, input }) => {
59
+ const setupInput = input as ChannelSetupInput & { apiKey?: string };
60
+ const base = getChannelConfig(cfg);
61
+ return {
62
+ ...cfg,
63
+ channels: {
64
+ ...cfg.channels,
65
+ [CHANNEL_KEY]: {
66
+ ...base,
67
+ enabled: true,
68
+ ...(setupInput.apiKey ? { apiKey: setupInput.apiKey } : {}),
69
+ },
70
+ },
71
+ } as OpenClawConfig;
72
+ },
31
73
  },
32
74
 
33
75
  status: {
package/src/service.ts CHANGED
@@ -5,6 +5,7 @@ import { isPipesBotReplyStatus } from "./types.js";
5
5
  import { handleReplyStatus, trackOutboundReply } from "./outbound.js";
6
6
  import { getPipesBotRuntime } from "./runtime.js";
7
7
  import { updateConnectionStatus } from "./status-store.js";
8
+ import { resolveApiKey } from "./channel.js";
8
9
  import type { ConnectionState } from "./connection.js";
9
10
 
10
11
  export function createPipesBotService(): OpenClawPluginService {
@@ -14,10 +15,7 @@ export function createPipesBotService(): OpenClawPluginService {
14
15
  id: "pipes-bot-channel",
15
16
 
16
17
  start(ctx: OpenClawPluginServiceContext): void {
17
- const pluginConfig = ctx.config.plugins?.entries?.["pipes-bot-channel"]
18
- ?.config as { apiKey?: string } | undefined;
19
-
20
- const apiKey = pluginConfig?.apiKey;
18
+ const apiKey = resolveApiKey(ctx.config);
21
19
 
22
20
  if (!apiKey || !apiKey.startsWith("pk_")) {
23
21
  ctx.logger.error(