@kittymi/openclaw-generic-http 0.1.3

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.
Files changed (77) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +132 -0
  3. package/dist/channel/account.d.ts +7 -0
  4. package/dist/channel/account.js +18 -0
  5. package/dist/channel/capabilities.d.ts +10 -0
  6. package/dist/channel/capabilities.js +11 -0
  7. package/dist/channel/host-adapter.d.ts +28 -0
  8. package/dist/channel/host-adapter.js +36 -0
  9. package/dist/channel/lifecycle.d.ts +18 -0
  10. package/dist/channel/lifecycle.js +28 -0
  11. package/dist/channel/plugin.d.ts +46 -0
  12. package/dist/channel/plugin.js +120 -0
  13. package/dist/channel/probe.d.ts +19 -0
  14. package/dist/channel/probe.js +149 -0
  15. package/dist/channel/resolve.d.ts +30 -0
  16. package/dist/channel/resolve.js +98 -0
  17. package/dist/channel/stream.d.ts +35 -0
  18. package/dist/channel/stream.js +127 -0
  19. package/dist/config/host-config-schema.d.ts +21 -0
  20. package/dist/config/host-config-schema.js +80 -0
  21. package/dist/config/loader.d.ts +7 -0
  22. package/dist/config/loader.js +38 -0
  23. package/dist/config/schema.d.ts +48 -0
  24. package/dist/config/schema.js +1 -0
  25. package/dist/errors/codes.d.ts +11 -0
  26. package/dist/errors/codes.js +10 -0
  27. package/dist/errors/exceptions.d.ts +7 -0
  28. package/dist/errors/exceptions.js +12 -0
  29. package/dist/inbound/mapper.d.ts +21 -0
  30. package/dist/inbound/mapper.js +22 -0
  31. package/dist/inbound/validator.d.ts +4 -0
  32. package/dist/inbound/validator.js +114 -0
  33. package/dist/index.d.ts +33 -0
  34. package/dist/index.js +31 -0
  35. package/dist/mapping/conversation-mapper.d.ts +1 -0
  36. package/dist/mapping/conversation-mapper.js +3 -0
  37. package/dist/mapping/sender-mapper.d.ts +1 -0
  38. package/dist/mapping/sender-mapper.js +3 -0
  39. package/dist/mapping/thread-mapper.d.ts +1 -0
  40. package/dist/mapping/thread-mapper.js +7 -0
  41. package/dist/openclaw-entry.d.ts +276 -0
  42. package/dist/openclaw-entry.js +728 -0
  43. package/dist/outbound/client.d.ts +6 -0
  44. package/dist/outbound/client.js +1 -0
  45. package/dist/outbound/controller.d.ts +15 -0
  46. package/dist/outbound/controller.js +28 -0
  47. package/dist/outbound/http-client.d.ts +23 -0
  48. package/dist/outbound/http-client.js +150 -0
  49. package/dist/outbound/mapper.d.ts +29 -0
  50. package/dist/outbound/mapper.js +19 -0
  51. package/dist/outbound/mock-client.d.ts +18 -0
  52. package/dist/outbound/mock-client.js +26 -0
  53. package/dist/outbound/sender.d.ts +3 -0
  54. package/dist/outbound/sender.js +5 -0
  55. package/dist/protocol/attachments.d.ts +10 -0
  56. package/dist/protocol/attachments.js +56 -0
  57. package/dist/protocol/dto.d.ts +46 -0
  58. package/dist/protocol/dto.js +1 -0
  59. package/dist/protocol/serializer.d.ts +1 -0
  60. package/dist/protocol/serializer.js +3 -0
  61. package/dist/security/nonce-store.d.ts +30 -0
  62. package/dist/security/nonce-store.js +32 -0
  63. package/dist/security/signer.d.ts +10 -0
  64. package/dist/security/signer.js +20 -0
  65. package/dist/security/verifier.d.ts +2 -0
  66. package/dist/security/verifier.js +20 -0
  67. package/dist/setup-entry.d.ts +351 -0
  68. package/dist/setup-entry.js +73 -0
  69. package/dist/utils/json.d.ts +1 -0
  70. package/dist/utils/json.js +3 -0
  71. package/dist/utils/log.d.ts +1 -0
  72. package/dist/utils/log.js +3 -0
  73. package/dist/utils/time.d.ts +1 -0
  74. package/dist/utils/time.js +3 -0
  75. package/openclaw.config.schema.json +80 -0
  76. package/openclaw.plugin.json +175 -0
  77. package/package.json +72 -0
@@ -0,0 +1,351 @@
1
+ export interface GenericHttpSetupFieldDescriptor {
2
+ key: string;
3
+ title: string;
4
+ required: boolean;
5
+ description: string;
6
+ secret?: boolean;
7
+ }
8
+ export interface GenericHttpSetupStepDescriptor {
9
+ id: string;
10
+ title: string;
11
+ description: string;
12
+ }
13
+ export interface GenericHttpSetupRegistration {
14
+ pluginId: "openclaw-generic-http";
15
+ channelName: "generic-http";
16
+ title: string;
17
+ summary: string;
18
+ configSchemaFile: "./openclaw.config.schema.json";
19
+ accountFields: GenericHttpSetupFieldDescriptor[];
20
+ steps: GenericHttpSetupStepDescriptor[];
21
+ }
22
+ export declare function registerSetup(): GenericHttpSetupRegistration;
23
+ export declare const genericHttpSetupEntry: {
24
+ plugin: {
25
+ id: string;
26
+ meta: {
27
+ id: string;
28
+ label: string;
29
+ selectionLabel: string;
30
+ docsPath: string;
31
+ blurb: string;
32
+ };
33
+ capabilities: {
34
+ chatTypes: string[];
35
+ media: boolean;
36
+ threads: boolean;
37
+ };
38
+ reload: {
39
+ configPrefixes: string[];
40
+ };
41
+ configSchema: {
42
+ validate(value: unknown): {
43
+ ok: boolean;
44
+ errors: string[];
45
+ value?: undefined;
46
+ } | {
47
+ ok: boolean;
48
+ value: object;
49
+ errors?: undefined;
50
+ };
51
+ };
52
+ config: {
53
+ listAccountIds(cfg: {
54
+ channels?: Record<string, unknown>;
55
+ }): string[];
56
+ resolveAccount(cfg: {
57
+ channels?: Record<string, unknown>;
58
+ }, accountId?: string | null): {
59
+ accountId: string;
60
+ enabled: boolean;
61
+ name?: string;
62
+ configured: boolean;
63
+ config: import("./config/schema.js").GenericHttpPluginConfig["accounts"][string];
64
+ };
65
+ defaultAccountId(cfg: {
66
+ channels?: Record<string, unknown>;
67
+ }): string;
68
+ isEnabled(account: {
69
+ accountId: string;
70
+ enabled: boolean;
71
+ name?: string;
72
+ configured: boolean;
73
+ config: import("./config/schema.js").GenericHttpPluginConfig["accounts"][string];
74
+ }): boolean;
75
+ isConfigured(account: {
76
+ accountId: string;
77
+ enabled: boolean;
78
+ name?: string;
79
+ configured: boolean;
80
+ config: import("./config/schema.js").GenericHttpPluginConfig["accounts"][string];
81
+ }): boolean;
82
+ describeAccount(account: {
83
+ accountId: string;
84
+ enabled: boolean;
85
+ name?: string;
86
+ configured: boolean;
87
+ config: import("./config/schema.js").GenericHttpPluginConfig["accounts"][string];
88
+ }): {
89
+ accountId: string;
90
+ name: string | undefined;
91
+ enabled: boolean;
92
+ configured: boolean;
93
+ baseUrl: string;
94
+ };
95
+ setAccountEnabled(params: {
96
+ cfg: {
97
+ channels?: Record<string, unknown>;
98
+ };
99
+ accountId: string;
100
+ enabled: boolean;
101
+ }): {
102
+ channels?: Record<string, unknown>;
103
+ };
104
+ };
105
+ setup: {
106
+ resolveAccountId(params: {
107
+ cfg: {
108
+ channels?: Record<string, unknown>;
109
+ };
110
+ accountId?: string;
111
+ }): string;
112
+ validateInput(params: {
113
+ input: {
114
+ baseUrl?: string;
115
+ url?: string;
116
+ token?: string;
117
+ secret?: string;
118
+ };
119
+ }): "baseUrl is required" | "baseUrl must be a valid absolute URL" | null;
120
+ applyAccountConfig(params: {
121
+ cfg: {
122
+ channels?: Record<string, unknown>;
123
+ };
124
+ accountId: string;
125
+ input: {
126
+ baseUrl?: string;
127
+ url?: string;
128
+ token?: string;
129
+ secret?: string;
130
+ };
131
+ }): {
132
+ channels?: Record<string, unknown>;
133
+ };
134
+ };
135
+ status: {
136
+ defaultRuntime: {
137
+ accountId: string;
138
+ running: boolean;
139
+ connected: boolean;
140
+ lastStartAt: null;
141
+ lastStopAt: null;
142
+ lastError: null;
143
+ lastInboundAt: null;
144
+ lastOutboundAt: null;
145
+ lastTransportActivityAt: null;
146
+ };
147
+ probeAccount(params: {
148
+ account: {
149
+ accountId: string;
150
+ enabled: boolean;
151
+ name?: string;
152
+ configured: boolean;
153
+ config: import("./config/schema.js").GenericHttpPluginConfig["accounts"][string];
154
+ };
155
+ cfg: {
156
+ channels?: Record<string, unknown>;
157
+ };
158
+ }): Promise<import("./channel/probe.js").ProbeResult>;
159
+ buildAccountSnapshot(params: {
160
+ account: {
161
+ accountId: string;
162
+ enabled: boolean;
163
+ name?: string;
164
+ configured: boolean;
165
+ config: import("./config/schema.js").GenericHttpPluginConfig["accounts"][string];
166
+ };
167
+ runtime?: {
168
+ running?: boolean;
169
+ connected?: boolean;
170
+ lastStartAt?: number | null;
171
+ lastStopAt?: number | null;
172
+ lastError?: string | null;
173
+ lastInboundAt?: number | null;
174
+ lastOutboundAt?: number | null;
175
+ lastTransportActivityAt?: number | null;
176
+ probe?: unknown;
177
+ lastProbeAt?: number | null;
178
+ };
179
+ probe?: {
180
+ status?: string;
181
+ };
182
+ }): {
183
+ accountId: string;
184
+ name: string | undefined;
185
+ enabled: boolean;
186
+ configured: boolean;
187
+ baseUrl: string;
188
+ running: boolean;
189
+ connected: boolean;
190
+ lastStartAt: number | null;
191
+ lastStopAt: number | null;
192
+ lastError: string | null;
193
+ lastInboundAt: number | null;
194
+ lastOutboundAt: number | null;
195
+ lastTransportActivityAt: number | null;
196
+ probe: {
197
+ status?: string;
198
+ } | undefined;
199
+ lastProbeAt: number;
200
+ };
201
+ };
202
+ gateway: {
203
+ startAccount(ctx: {
204
+ cfg: {
205
+ channels?: Record<string, unknown>;
206
+ };
207
+ accountId: string;
208
+ account: {
209
+ accountId: string;
210
+ enabled: boolean;
211
+ name?: string;
212
+ configured: boolean;
213
+ config: import("./config/schema.js").GenericHttpPluginConfig["accounts"][string];
214
+ };
215
+ abortSignal: AbortSignal;
216
+ log?: {
217
+ info?: (message: string) => void;
218
+ error?: (message: string) => void;
219
+ };
220
+ setStatus: (next: Record<string, unknown>) => void;
221
+ channelRuntime?: unknown;
222
+ }): Promise<void>;
223
+ stopAccount(ctx: {
224
+ cfg: {
225
+ channels?: Record<string, unknown>;
226
+ };
227
+ accountId: string;
228
+ account: {
229
+ accountId: string;
230
+ enabled: boolean;
231
+ name?: string;
232
+ configured: boolean;
233
+ config: import("./config/schema.js").GenericHttpPluginConfig["accounts"][string];
234
+ };
235
+ abortSignal: AbortSignal;
236
+ log?: {
237
+ info?: (message: string) => void;
238
+ error?: (message: string) => void;
239
+ };
240
+ setStatus: (next: Record<string, unknown>) => void;
241
+ channelRuntime?: unknown;
242
+ }): Promise<void>;
243
+ };
244
+ resolver: {
245
+ resolveTargets(params: {
246
+ cfg: {
247
+ channels?: Record<string, unknown>;
248
+ };
249
+ accountId?: string | null;
250
+ inputs: string[];
251
+ kind: "user" | "group";
252
+ }): Promise<({
253
+ input: string;
254
+ resolved: boolean;
255
+ note: string;
256
+ id?: undefined;
257
+ name?: undefined;
258
+ } | {
259
+ input: string;
260
+ resolved: boolean;
261
+ id: string;
262
+ name: string;
263
+ note?: undefined;
264
+ })[]>;
265
+ };
266
+ messaging: {
267
+ targetPrefixes: string[];
268
+ normalizeTarget: (raw: string) => string | undefined;
269
+ parseExplicitTarget(params: {
270
+ raw: string;
271
+ }): {
272
+ to: string;
273
+ chatType: "group" | "direct" | "channel";
274
+ } | null;
275
+ inferTargetChatType(params: {
276
+ to: string;
277
+ }): "group" | "direct" | "channel" | undefined;
278
+ resolveOutboundSessionRoute(params: {
279
+ agentId: string;
280
+ accountId?: string | null;
281
+ target: string;
282
+ threadId?: string | number | null;
283
+ }): {
284
+ sessionKey: string;
285
+ baseSessionKey: string;
286
+ peer: {
287
+ kind: "group" | "direct" | "channel";
288
+ id: string;
289
+ };
290
+ chatType: "group" | "direct" | "channel";
291
+ from: string;
292
+ to: string;
293
+ threadId: string;
294
+ } | null;
295
+ resolveInboundSessionRoute(params: {
296
+ agentId: string;
297
+ accountId?: string | null;
298
+ conversationId: string;
299
+ conversationType: "dm" | "group" | "room" | "ticket";
300
+ threadId?: string | number | null;
301
+ }): {
302
+ sessionKey: string;
303
+ baseSessionKey: string;
304
+ peer: {
305
+ kind: "group" | "direct" | "channel";
306
+ id: string;
307
+ };
308
+ chatType: "group" | "direct" | "channel";
309
+ from: string;
310
+ to: string;
311
+ threadId: string;
312
+ } | null;
313
+ };
314
+ outbound: {
315
+ deliveryMode: string;
316
+ sendText(ctx: {
317
+ cfg: {
318
+ channels?: Record<string, unknown>;
319
+ };
320
+ to: string;
321
+ text: string;
322
+ threadId?: string | number | null;
323
+ accountId?: string | null;
324
+ }): Promise<{
325
+ channel: string;
326
+ messageId: string;
327
+ conversationId: string;
328
+ timestamp: number;
329
+ meta: Record<string, unknown>;
330
+ }>;
331
+ sendMedia(ctx: {
332
+ cfg: {
333
+ channels?: Record<string, unknown>;
334
+ };
335
+ to: string;
336
+ text: string;
337
+ mediaUrl?: string;
338
+ threadId?: string | number | null;
339
+ accountId?: string | null;
340
+ }): Promise<{
341
+ channel: string;
342
+ messageId: string;
343
+ conversationId: string;
344
+ timestamp: number;
345
+ meta: Record<string, unknown>;
346
+ }>;
347
+ };
348
+ };
349
+ registerSetup: typeof registerSetup;
350
+ };
351
+ export default genericHttpSetupEntry;
@@ -0,0 +1,73 @@
1
+ import { openClawGenericHttpChannelPlugin } from "./openclaw-entry.js";
2
+ export function registerSetup() {
3
+ return {
4
+ pluginId: "openclaw-generic-http",
5
+ channelName: "generic-http",
6
+ title: "Generic HTTP Channel Setup",
7
+ summary: "Configure a bridge/relay account, wire third-party webhooks into bridge ingress, and consume inbound events through stream polling.",
8
+ configSchemaFile: "./openclaw.config.schema.json",
9
+ accountFields: [
10
+ {
11
+ key: "baseUrl",
12
+ title: "Bridge Base URL",
13
+ required: true,
14
+ description: "Base URL of the bridge or relay service that exposes health, probe, stream, resolve, and outbound endpoints."
15
+ },
16
+ {
17
+ key: "apiKey",
18
+ title: "API Key",
19
+ required: false,
20
+ description: "Optional shared credential sent on signed requests when the bridge requires API key authentication.",
21
+ secret: true
22
+ },
23
+ {
24
+ key: "signingSecret",
25
+ title: "Signing Secret",
26
+ required: false,
27
+ description: "Shared secret used to sign stream, probe, resolve, and outbound requests from the plugin.",
28
+ secret: true
29
+ },
30
+ {
31
+ key: "inboundSecret",
32
+ title: "Inbound Secret",
33
+ required: false,
34
+ description: "Optional dedicated secret used by the bridge when validating third-party webhook ingress.",
35
+ secret: true
36
+ },
37
+ {
38
+ key: "outboundSecret",
39
+ title: "Outbound Secret",
40
+ required: false,
41
+ description: "Optional dedicated secret used when outbound message signing is separated from other transport signing.",
42
+ secret: true
43
+ }
44
+ ],
45
+ steps: [
46
+ {
47
+ id: "configure-account",
48
+ title: "Configure bridge account",
49
+ description: "Add at least one account with baseUrl and the shared credentials required by the bridge or relay."
50
+ },
51
+ {
52
+ id: "wire-webhook-ingress",
53
+ title: "Wire webhook ingress",
54
+ description: "Send third-party inbound events to POST /webhooks/inbound/messages on the bridge instead of calling a local OpenClaw URL."
55
+ },
56
+ {
57
+ id: "activate-stream-ingress",
58
+ title: "Activate stream ingress",
59
+ description: "Let the host activate the plugin so it can poll GET /stream/inbound and acknowledge processed messages through POST /stream/acks."
60
+ },
61
+ {
62
+ id: "verify-outbound-delivery",
63
+ title: "Verify outbound delivery",
64
+ description: "Confirm the bridge accepts POST /outbound/messages and that the external system returns successful delivery responses."
65
+ }
66
+ ]
67
+ };
68
+ }
69
+ export const genericHttpSetupEntry = {
70
+ plugin: openClawGenericHttpChannelPlugin,
71
+ registerSetup
72
+ };
73
+ export default genericHttpSetupEntry;
@@ -0,0 +1 @@
1
+ export declare function parseJson<T>(value: string): T;
@@ -0,0 +1,3 @@
1
+ export function parseJson(value) {
2
+ return JSON.parse(value);
3
+ }
@@ -0,0 +1 @@
1
+ export declare function logInfo(message: string): void;
@@ -0,0 +1,3 @@
1
+ export function logInfo(message) {
2
+ console.log(message);
3
+ }
@@ -0,0 +1 @@
1
+ export declare function nowEpochSeconds(): number;
@@ -0,0 +1,3 @@
1
+ export function nowEpochSeconds() {
2
+ return Math.floor(Date.now() / 1000);
3
+ }
@@ -0,0 +1,80 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "type": "object",
4
+ "title": "Generic HTTP Channel Config",
5
+ "description": "Configuration for the OpenClaw generic HTTP channel plugin using bridge/relay webhook and stream ingress.",
6
+ "properties": {
7
+ "enabled": {
8
+ "type": "boolean",
9
+ "title": "Enabled",
10
+ "description": "Whether the generic HTTP channel is enabled.",
11
+ "default": false
12
+ },
13
+ "defaultAccount": {
14
+ "type": "string",
15
+ "title": "Default Account",
16
+ "description": "Default account ID used when the host does not specify one."
17
+ },
18
+ "accounts": {
19
+ "type": "object",
20
+ "title": "Accounts",
21
+ "description": "Per-account bridge and outbound transport settings.",
22
+ "additionalProperties": {
23
+ "type": "object",
24
+ "properties": {
25
+ "baseUrl": {
26
+ "type": "string",
27
+ "format": "uri",
28
+ "title": "Bridge Base URL",
29
+ "description": "Bridge or relay base URL used for probe, resolve, stream ingress, and outbound delivery."
30
+ },
31
+ "apiKey": {
32
+ "type": "string",
33
+ "title": "API Key",
34
+ "description": "Optional shared credential for bridge authentication."
35
+ },
36
+ "signingSecret": {
37
+ "type": "string",
38
+ "title": "Signing Secret",
39
+ "description": "Shared secret used for signing outbound and stream transport requests."
40
+ },
41
+ "inboundSecret": {
42
+ "type": "string",
43
+ "title": "Inbound Secret",
44
+ "description": "Optional dedicated secret for inbound webhook validation on the bridge side."
45
+ },
46
+ "outboundSecret": {
47
+ "type": "string",
48
+ "title": "Outbound Secret",
49
+ "description": "Optional dedicated secret for outbound signing when outbound trust is split from inbound."
50
+ },
51
+ "connectTimeoutMillis": {
52
+ "type": "number",
53
+ "minimum": 0,
54
+ "title": "Connect Timeout (ms)",
55
+ "description": "HTTP connect timeout in milliseconds.",
56
+ "default": 5000
57
+ },
58
+ "readTimeoutMillis": {
59
+ "type": "number",
60
+ "minimum": 0,
61
+ "title": "Read Timeout (ms)",
62
+ "description": "HTTP read timeout in milliseconds.",
63
+ "default": 10000
64
+ },
65
+ "maxRetries": {
66
+ "type": "number",
67
+ "minimum": 0,
68
+ "title": "Max Retries",
69
+ "description": "Maximum retry count for retryable outbound HTTP failures.",
70
+ "default": 0
71
+ }
72
+ },
73
+ "required": ["baseUrl"],
74
+ "additionalProperties": false
75
+ }
76
+ }
77
+ },
78
+ "required": ["enabled", "defaultAccount", "accounts"],
79
+ "additionalProperties": false
80
+ }