@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.
- package/LICENSE +21 -0
- package/README.md +132 -0
- package/dist/channel/account.d.ts +7 -0
- package/dist/channel/account.js +18 -0
- package/dist/channel/capabilities.d.ts +10 -0
- package/dist/channel/capabilities.js +11 -0
- package/dist/channel/host-adapter.d.ts +28 -0
- package/dist/channel/host-adapter.js +36 -0
- package/dist/channel/lifecycle.d.ts +18 -0
- package/dist/channel/lifecycle.js +28 -0
- package/dist/channel/plugin.d.ts +46 -0
- package/dist/channel/plugin.js +120 -0
- package/dist/channel/probe.d.ts +19 -0
- package/dist/channel/probe.js +149 -0
- package/dist/channel/resolve.d.ts +30 -0
- package/dist/channel/resolve.js +98 -0
- package/dist/channel/stream.d.ts +35 -0
- package/dist/channel/stream.js +127 -0
- package/dist/config/host-config-schema.d.ts +21 -0
- package/dist/config/host-config-schema.js +80 -0
- package/dist/config/loader.d.ts +7 -0
- package/dist/config/loader.js +38 -0
- package/dist/config/schema.d.ts +48 -0
- package/dist/config/schema.js +1 -0
- package/dist/errors/codes.d.ts +11 -0
- package/dist/errors/codes.js +10 -0
- package/dist/errors/exceptions.d.ts +7 -0
- package/dist/errors/exceptions.js +12 -0
- package/dist/inbound/mapper.d.ts +21 -0
- package/dist/inbound/mapper.js +22 -0
- package/dist/inbound/validator.d.ts +4 -0
- package/dist/inbound/validator.js +114 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +31 -0
- package/dist/mapping/conversation-mapper.d.ts +1 -0
- package/dist/mapping/conversation-mapper.js +3 -0
- package/dist/mapping/sender-mapper.d.ts +1 -0
- package/dist/mapping/sender-mapper.js +3 -0
- package/dist/mapping/thread-mapper.d.ts +1 -0
- package/dist/mapping/thread-mapper.js +7 -0
- package/dist/openclaw-entry.d.ts +276 -0
- package/dist/openclaw-entry.js +728 -0
- package/dist/outbound/client.d.ts +6 -0
- package/dist/outbound/client.js +1 -0
- package/dist/outbound/controller.d.ts +15 -0
- package/dist/outbound/controller.js +28 -0
- package/dist/outbound/http-client.d.ts +23 -0
- package/dist/outbound/http-client.js +150 -0
- package/dist/outbound/mapper.d.ts +29 -0
- package/dist/outbound/mapper.js +19 -0
- package/dist/outbound/mock-client.d.ts +18 -0
- package/dist/outbound/mock-client.js +26 -0
- package/dist/outbound/sender.d.ts +3 -0
- package/dist/outbound/sender.js +5 -0
- package/dist/protocol/attachments.d.ts +10 -0
- package/dist/protocol/attachments.js +56 -0
- package/dist/protocol/dto.d.ts +46 -0
- package/dist/protocol/dto.js +1 -0
- package/dist/protocol/serializer.d.ts +1 -0
- package/dist/protocol/serializer.js +3 -0
- package/dist/security/nonce-store.d.ts +30 -0
- package/dist/security/nonce-store.js +32 -0
- package/dist/security/signer.d.ts +10 -0
- package/dist/security/signer.js +20 -0
- package/dist/security/verifier.d.ts +2 -0
- package/dist/security/verifier.js +20 -0
- package/dist/setup-entry.d.ts +351 -0
- package/dist/setup-entry.js +73 -0
- package/dist/utils/json.d.ts +1 -0
- package/dist/utils/json.js +3 -0
- package/dist/utils/log.d.ts +1 -0
- package/dist/utils/log.js +3 -0
- package/dist/utils/time.d.ts +1 -0
- package/dist/utils/time.js +3 -0
- package/openclaw.config.schema.json +80 -0
- package/openclaw.plugin.json +175 -0
- package/package.json +72 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { ERROR_CODES } from "../errors/codes.js";
|
|
2
|
+
import { GenericHttpPluginError } from "../errors/exceptions.js";
|
|
3
|
+
import { normalizeAttachment } from "../protocol/attachments.js";
|
|
4
|
+
const CONVERSATION_TYPES = new Set(["dm", "group", "room", "ticket"]);
|
|
5
|
+
const SENDER_TYPES = new Set(["user", "bot", "system"]);
|
|
6
|
+
const ATTACHMENT_KINDS = new Set(["file", "image"]);
|
|
7
|
+
function isRecord(value) {
|
|
8
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
function requireNonEmptyString(value, field) {
|
|
11
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
12
|
+
throw new GenericHttpPluginError(ERROR_CODES.MISSING_REQUIRED_FIELD, `Field "${field}" must be a non-empty string.`, { field });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function validateOptionalString(value, field) {
|
|
16
|
+
if (value !== undefined && value !== null && typeof value !== "string") {
|
|
17
|
+
throw new GenericHttpPluginError(ERROR_CODES.INVALID_FIELD_FORMAT, `Field "${field}" must be a string when provided.`, { field });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function validateMetadata(value, field) {
|
|
21
|
+
if (value !== undefined && !isRecord(value)) {
|
|
22
|
+
throw new GenericHttpPluginError(ERROR_CODES.INVALID_FIELD_FORMAT, `Field "${field}" must be an object when provided.`, { field });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function validateConversation(conversation) {
|
|
26
|
+
if (!isRecord(conversation)) {
|
|
27
|
+
throw new GenericHttpPluginError(ERROR_CODES.MISSING_REQUIRED_FIELD, 'Field "conversation" must be an object.', { field: "conversation" });
|
|
28
|
+
}
|
|
29
|
+
requireNonEmptyString(conversation.conversationId, "conversation.conversationId");
|
|
30
|
+
requireNonEmptyString(conversation.type, "conversation.type");
|
|
31
|
+
if (!CONVERSATION_TYPES.has(conversation.type)) {
|
|
32
|
+
throw new GenericHttpPluginError(ERROR_CODES.INVALID_FIELD_FORMAT, 'Field "conversation.type" must be one of: dm, group, room, ticket.', { field: "conversation.type" });
|
|
33
|
+
}
|
|
34
|
+
validateOptionalString(conversation.title, "conversation.title");
|
|
35
|
+
validateMetadata(conversation.metadata, "conversation.metadata");
|
|
36
|
+
}
|
|
37
|
+
function validateSender(sender) {
|
|
38
|
+
if (!isRecord(sender)) {
|
|
39
|
+
throw new GenericHttpPluginError(ERROR_CODES.MISSING_REQUIRED_FIELD, 'Field "sender" must be an object.', { field: "sender" });
|
|
40
|
+
}
|
|
41
|
+
requireNonEmptyString(sender.id, "sender.id");
|
|
42
|
+
requireNonEmptyString(sender.type, "sender.type");
|
|
43
|
+
if (!SENDER_TYPES.has(sender.type)) {
|
|
44
|
+
throw new GenericHttpPluginError(ERROR_CODES.INVALID_FIELD_FORMAT, 'Field "sender.type" must be one of: user, bot, system.', { field: "sender.type" });
|
|
45
|
+
}
|
|
46
|
+
validateOptionalString(sender.name, "sender.name");
|
|
47
|
+
validateMetadata(sender.metadata, "sender.metadata");
|
|
48
|
+
}
|
|
49
|
+
function validateAttachment(attachment, index) {
|
|
50
|
+
if (!isRecord(attachment)) {
|
|
51
|
+
throw new GenericHttpPluginError(ERROR_CODES.INVALID_FIELD_FORMAT, `Field "message.attachments[${index}]" must be an object.`, { field: `message.attachments[${index}]` });
|
|
52
|
+
}
|
|
53
|
+
if (attachment.kind !== undefined &&
|
|
54
|
+
(typeof attachment.kind !== "string" ||
|
|
55
|
+
!ATTACHMENT_KINDS.has(attachment.kind))) {
|
|
56
|
+
throw new GenericHttpPluginError(ERROR_CODES.INVALID_FIELD_FORMAT, `Field "message.attachments[${index}].kind" must be one of: file, image.`, { field: `message.attachments[${index}].kind` });
|
|
57
|
+
}
|
|
58
|
+
validateOptionalString(attachment.id, `message.attachments[${index}].id`);
|
|
59
|
+
validateOptionalString(attachment.name, `message.attachments[${index}].name`);
|
|
60
|
+
validateOptionalString(attachment.contentType, `message.attachments[${index}].contentType`);
|
|
61
|
+
validateOptionalString(attachment.url, `message.attachments[${index}].url`);
|
|
62
|
+
validateOptionalString(attachment.contentBase64, `message.attachments[${index}].contentBase64`);
|
|
63
|
+
validateOptionalString(attachment.caption, `message.attachments[${index}].caption`);
|
|
64
|
+
validateOptionalString(attachment.altText, `message.attachments[${index}].altText`);
|
|
65
|
+
validateOptionalString(attachment.previewUrl, `message.attachments[${index}].previewUrl`);
|
|
66
|
+
if (attachment.sizeBytes !== undefined && typeof attachment.sizeBytes !== "number") {
|
|
67
|
+
throw new GenericHttpPluginError(ERROR_CODES.INVALID_FIELD_FORMAT, `Field "message.attachments[${index}].sizeBytes" must be a number when provided.`, { field: `message.attachments[${index}].sizeBytes` });
|
|
68
|
+
}
|
|
69
|
+
if ((attachment.url === undefined || attachment.url === "") &&
|
|
70
|
+
(attachment.contentBase64 === undefined || attachment.contentBase64 === "")) {
|
|
71
|
+
throw new GenericHttpPluginError(ERROR_CODES.INVALID_REQUEST, `Attachment "message.attachments[${index}]" must include either url or contentBase64.`, { field: `message.attachments[${index}]` });
|
|
72
|
+
}
|
|
73
|
+
normalizeAttachment(attachment);
|
|
74
|
+
validateMetadata(attachment.metadata, `message.attachments[${index}].metadata`);
|
|
75
|
+
}
|
|
76
|
+
function validateMessage(message) {
|
|
77
|
+
if (!isRecord(message)) {
|
|
78
|
+
throw new GenericHttpPluginError(ERROR_CODES.MISSING_REQUIRED_FIELD, 'Field "message" must be an object.', { field: "message" });
|
|
79
|
+
}
|
|
80
|
+
requireNonEmptyString(message.messageId, "message.messageId");
|
|
81
|
+
validateOptionalString(message.text, "message.text");
|
|
82
|
+
validateOptionalString(message.replyToMessageId, "message.replyToMessageId");
|
|
83
|
+
validateMetadata(message.metadata, "message.metadata");
|
|
84
|
+
if (message.attachments !== undefined) {
|
|
85
|
+
if (!Array.isArray(message.attachments)) {
|
|
86
|
+
throw new GenericHttpPluginError(ERROR_CODES.INVALID_FIELD_FORMAT, 'Field "message.attachments" must be an array when provided.', { field: "message.attachments" });
|
|
87
|
+
}
|
|
88
|
+
message.attachments.forEach((attachment, index) => validateAttachment(attachment, index));
|
|
89
|
+
}
|
|
90
|
+
if ((message.text === undefined || message.text === null || message.text === "") &&
|
|
91
|
+
(message.attachments === undefined || message.attachments.length === 0)) {
|
|
92
|
+
throw new GenericHttpPluginError(ERROR_CODES.INVALID_REQUEST, 'Field "message" must include non-empty text or at least one attachment.', { field: "message" });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function validateOccurredAt(occurredAt) {
|
|
96
|
+
validateOptionalString(occurredAt, "occurredAt");
|
|
97
|
+
if (typeof occurredAt === "string" && Number.isNaN(Date.parse(occurredAt))) {
|
|
98
|
+
throw new GenericHttpPluginError(ERROR_CODES.INVALID_FIELD_FORMAT, 'Field "occurredAt" must be a valid date-time string.', { field: "occurredAt" });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export function validateInboundMessage(request) {
|
|
102
|
+
if (!isRecord(request)) {
|
|
103
|
+
throw new GenericHttpPluginError(ERROR_CODES.INVALID_REQUEST, "Inbound message request must be an object.");
|
|
104
|
+
}
|
|
105
|
+
requireNonEmptyString(request.eventId, "eventId");
|
|
106
|
+
requireNonEmptyString(request.accountId, "accountId");
|
|
107
|
+
validateConversation(request.conversation);
|
|
108
|
+
validateOptionalString(request.threadId, "threadId");
|
|
109
|
+
validateSender(request.sender);
|
|
110
|
+
validateMessage(request.message);
|
|
111
|
+
validateOccurredAt(request.occurredAt);
|
|
112
|
+
validateOptionalString(request.idempotencyKey, "idempotencyKey");
|
|
113
|
+
validateMetadata(request.metadata, "metadata");
|
|
114
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { genericHttpChannelPlugin } from "./channel/plugin.js";
|
|
2
|
+
import { genericHttpHostConfigSchema } from "./config/host-config-schema.js";
|
|
3
|
+
import { openClawGenericHttpPluginEntry } from "./openclaw-entry.js";
|
|
4
|
+
export { createGenericHttpChannelLifecycle } from "./channel/lifecycle.js";
|
|
5
|
+
export type { GenericHttpChannelLifecycle, GenericHttpChannelLifecycleHandlers } from "./channel/lifecycle.js";
|
|
6
|
+
export { createGenericHttpHostAdapter } from "./channel/host-adapter.js";
|
|
7
|
+
export type { GenericHttpHostAdapter, GenericHttpHostAdapterHandlers } from "./channel/host-adapter.js";
|
|
8
|
+
export { createGenericHttpChannelPlugin, genericHttpChannelPlugin } from "./channel/plugin.js";
|
|
9
|
+
export { openClawGenericHttpChannelPlugin, openClawGenericHttpPluginEntry } from "./openclaw-entry.js";
|
|
10
|
+
export type { GenericHttpChannelPlugin, GenericHttpChannelPluginRuntimeOptions, GenericHttpChannelPluginStatus } from "./channel/plugin.js";
|
|
11
|
+
import { type GenericHttpHostAdapter, type GenericHttpHostAdapterHandlers } from "./channel/host-adapter.js";
|
|
12
|
+
import type { GenericHttpPluginConfig } from "./config/schema.js";
|
|
13
|
+
import type { GenericHttpChannelPluginRuntimeOptions } from "./channel/plugin.js";
|
|
14
|
+
export interface GenericHttpPluginChannelDescriptor {
|
|
15
|
+
name: "generic-http";
|
|
16
|
+
displayName: "Generic HTTP";
|
|
17
|
+
configSchemaFile: "./openclaw.config.schema.json";
|
|
18
|
+
}
|
|
19
|
+
export interface GenericHttpPluginRegistration {
|
|
20
|
+
pluginId: "openclaw-generic-http";
|
|
21
|
+
channelName: "generic-http";
|
|
22
|
+
defaultPlugin: typeof genericHttpChannelPlugin;
|
|
23
|
+
channels: [GenericHttpPluginChannelDescriptor];
|
|
24
|
+
configSchema: typeof genericHttpHostConfigSchema;
|
|
25
|
+
createHostAdapter(rawConfig: Partial<GenericHttpPluginConfig>, handlers: GenericHttpHostAdapterHandlers, options?: Omit<GenericHttpChannelPluginRuntimeOptions, "onInboundStreamMessage" | "onInboundStreamError">): GenericHttpHostAdapter;
|
|
26
|
+
}
|
|
27
|
+
export declare function registerPlugin(): GenericHttpPluginRegistration;
|
|
28
|
+
export declare function register(api: {
|
|
29
|
+
registerChannel: (registration: unknown) => void;
|
|
30
|
+
registrationMode?: string;
|
|
31
|
+
}): void;
|
|
32
|
+
export declare const activate: typeof register;
|
|
33
|
+
export default openClawGenericHttpPluginEntry;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { genericHttpChannelPlugin } from "./channel/plugin.js";
|
|
2
|
+
import { genericHttpHostConfigSchema } from "./config/host-config-schema.js";
|
|
3
|
+
import { openClawGenericHttpPluginEntry } from "./openclaw-entry.js";
|
|
4
|
+
export { createGenericHttpChannelLifecycle } from "./channel/lifecycle.js";
|
|
5
|
+
export { createGenericHttpHostAdapter } from "./channel/host-adapter.js";
|
|
6
|
+
export { createGenericHttpChannelPlugin, genericHttpChannelPlugin } from "./channel/plugin.js";
|
|
7
|
+
export { openClawGenericHttpChannelPlugin, openClawGenericHttpPluginEntry } from "./openclaw-entry.js";
|
|
8
|
+
import { createGenericHttpHostAdapter } from "./channel/host-adapter.js";
|
|
9
|
+
export function registerPlugin() {
|
|
10
|
+
return {
|
|
11
|
+
pluginId: "openclaw-generic-http",
|
|
12
|
+
channelName: "generic-http",
|
|
13
|
+
defaultPlugin: genericHttpChannelPlugin,
|
|
14
|
+
channels: [
|
|
15
|
+
{
|
|
16
|
+
name: "generic-http",
|
|
17
|
+
displayName: "Generic HTTP",
|
|
18
|
+
configSchemaFile: "./openclaw.config.schema.json"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
configSchema: genericHttpHostConfigSchema,
|
|
22
|
+
createHostAdapter(rawConfig, handlers, options) {
|
|
23
|
+
return createGenericHttpHostAdapter(rawConfig, handlers, options);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function register(api) {
|
|
28
|
+
openClawGenericHttpPluginEntry.register(api);
|
|
29
|
+
}
|
|
30
|
+
export const activate = register;
|
|
31
|
+
export default openClawGenericHttpPluginEntry;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mapConversationId(conversationId: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mapSenderId(senderId: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mapThreadId(threadId?: string | null): string | null;
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import type { GenericHttpPluginConfig } from "./config/schema.js";
|
|
2
|
+
type OpenClawConfigLike = {
|
|
3
|
+
channels?: Record<string, unknown>;
|
|
4
|
+
};
|
|
5
|
+
type OpenClawPluginApiLike = {
|
|
6
|
+
registrationMode?: string;
|
|
7
|
+
registerChannel: (registration: {
|
|
8
|
+
plugin: unknown;
|
|
9
|
+
} | unknown) => void;
|
|
10
|
+
};
|
|
11
|
+
type OpenClawGatewayContextLike = {
|
|
12
|
+
cfg: OpenClawConfigLike;
|
|
13
|
+
accountId: string;
|
|
14
|
+
account: GenericHttpResolvedAccount;
|
|
15
|
+
abortSignal: AbortSignal;
|
|
16
|
+
log?: {
|
|
17
|
+
info?: (message: string) => void;
|
|
18
|
+
error?: (message: string) => void;
|
|
19
|
+
};
|
|
20
|
+
setStatus: (next: Record<string, unknown>) => void;
|
|
21
|
+
channelRuntime?: unknown;
|
|
22
|
+
};
|
|
23
|
+
type ChannelAccountRuntimeLike = {
|
|
24
|
+
running?: boolean;
|
|
25
|
+
connected?: boolean;
|
|
26
|
+
lastStartAt?: number | null;
|
|
27
|
+
lastStopAt?: number | null;
|
|
28
|
+
lastError?: string | null;
|
|
29
|
+
lastInboundAt?: number | null;
|
|
30
|
+
lastOutboundAt?: number | null;
|
|
31
|
+
lastTransportActivityAt?: number | null;
|
|
32
|
+
probe?: unknown;
|
|
33
|
+
lastProbeAt?: number | null;
|
|
34
|
+
};
|
|
35
|
+
type GenericHttpResolvedAccount = {
|
|
36
|
+
accountId: string;
|
|
37
|
+
enabled: boolean;
|
|
38
|
+
name?: string;
|
|
39
|
+
configured: boolean;
|
|
40
|
+
config: GenericHttpPluginConfig["accounts"][string];
|
|
41
|
+
};
|
|
42
|
+
declare function normalizeTarget(raw: string): string | undefined;
|
|
43
|
+
export declare const openClawGenericHttpChannelPlugin: {
|
|
44
|
+
id: string;
|
|
45
|
+
meta: {
|
|
46
|
+
id: string;
|
|
47
|
+
label: string;
|
|
48
|
+
selectionLabel: string;
|
|
49
|
+
docsPath: string;
|
|
50
|
+
blurb: string;
|
|
51
|
+
};
|
|
52
|
+
capabilities: {
|
|
53
|
+
chatTypes: string[];
|
|
54
|
+
media: boolean;
|
|
55
|
+
threads: boolean;
|
|
56
|
+
};
|
|
57
|
+
reload: {
|
|
58
|
+
configPrefixes: string[];
|
|
59
|
+
};
|
|
60
|
+
configSchema: {
|
|
61
|
+
validate(value: unknown): {
|
|
62
|
+
ok: boolean;
|
|
63
|
+
errors: string[];
|
|
64
|
+
value?: undefined;
|
|
65
|
+
} | {
|
|
66
|
+
ok: boolean;
|
|
67
|
+
value: object;
|
|
68
|
+
errors?: undefined;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
config: {
|
|
72
|
+
listAccountIds(cfg: OpenClawConfigLike): string[];
|
|
73
|
+
resolveAccount(cfg: OpenClawConfigLike, accountId?: string | null): GenericHttpResolvedAccount;
|
|
74
|
+
defaultAccountId(cfg: OpenClawConfigLike): string;
|
|
75
|
+
isEnabled(account: GenericHttpResolvedAccount): boolean;
|
|
76
|
+
isConfigured(account: GenericHttpResolvedAccount): boolean;
|
|
77
|
+
describeAccount(account: GenericHttpResolvedAccount): {
|
|
78
|
+
accountId: string;
|
|
79
|
+
name: string | undefined;
|
|
80
|
+
enabled: boolean;
|
|
81
|
+
configured: boolean;
|
|
82
|
+
baseUrl: string;
|
|
83
|
+
};
|
|
84
|
+
setAccountEnabled(params: {
|
|
85
|
+
cfg: OpenClawConfigLike;
|
|
86
|
+
accountId: string;
|
|
87
|
+
enabled: boolean;
|
|
88
|
+
}): OpenClawConfigLike;
|
|
89
|
+
};
|
|
90
|
+
setup: {
|
|
91
|
+
resolveAccountId(params: {
|
|
92
|
+
cfg: OpenClawConfigLike;
|
|
93
|
+
accountId?: string;
|
|
94
|
+
}): string;
|
|
95
|
+
validateInput(params: {
|
|
96
|
+
input: {
|
|
97
|
+
baseUrl?: string;
|
|
98
|
+
url?: string;
|
|
99
|
+
token?: string;
|
|
100
|
+
secret?: string;
|
|
101
|
+
};
|
|
102
|
+
}): "baseUrl is required" | "baseUrl must be a valid absolute URL" | null;
|
|
103
|
+
applyAccountConfig(params: {
|
|
104
|
+
cfg: OpenClawConfigLike;
|
|
105
|
+
accountId: string;
|
|
106
|
+
input: {
|
|
107
|
+
baseUrl?: string;
|
|
108
|
+
url?: string;
|
|
109
|
+
token?: string;
|
|
110
|
+
secret?: string;
|
|
111
|
+
};
|
|
112
|
+
}): OpenClawConfigLike;
|
|
113
|
+
};
|
|
114
|
+
status: {
|
|
115
|
+
defaultRuntime: {
|
|
116
|
+
accountId: string;
|
|
117
|
+
running: boolean;
|
|
118
|
+
connected: boolean;
|
|
119
|
+
lastStartAt: null;
|
|
120
|
+
lastStopAt: null;
|
|
121
|
+
lastError: null;
|
|
122
|
+
lastInboundAt: null;
|
|
123
|
+
lastOutboundAt: null;
|
|
124
|
+
lastTransportActivityAt: null;
|
|
125
|
+
};
|
|
126
|
+
probeAccount(params: {
|
|
127
|
+
account: GenericHttpResolvedAccount;
|
|
128
|
+
cfg: OpenClawConfigLike;
|
|
129
|
+
}): Promise<import("./channel/probe.js").ProbeResult>;
|
|
130
|
+
buildAccountSnapshot(params: {
|
|
131
|
+
account: GenericHttpResolvedAccount;
|
|
132
|
+
runtime?: ChannelAccountRuntimeLike;
|
|
133
|
+
probe?: {
|
|
134
|
+
status?: string;
|
|
135
|
+
};
|
|
136
|
+
}): {
|
|
137
|
+
accountId: string;
|
|
138
|
+
name: string | undefined;
|
|
139
|
+
enabled: boolean;
|
|
140
|
+
configured: boolean;
|
|
141
|
+
baseUrl: string;
|
|
142
|
+
running: boolean;
|
|
143
|
+
connected: boolean;
|
|
144
|
+
lastStartAt: number | null;
|
|
145
|
+
lastStopAt: number | null;
|
|
146
|
+
lastError: string | null;
|
|
147
|
+
lastInboundAt: number | null;
|
|
148
|
+
lastOutboundAt: number | null;
|
|
149
|
+
lastTransportActivityAt: number | null;
|
|
150
|
+
probe: {
|
|
151
|
+
status?: string;
|
|
152
|
+
} | undefined;
|
|
153
|
+
lastProbeAt: number;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
gateway: {
|
|
157
|
+
startAccount(ctx: OpenClawGatewayContextLike): Promise<void>;
|
|
158
|
+
stopAccount(ctx: OpenClawGatewayContextLike): Promise<void>;
|
|
159
|
+
};
|
|
160
|
+
resolver: {
|
|
161
|
+
resolveTargets(params: {
|
|
162
|
+
cfg: OpenClawConfigLike;
|
|
163
|
+
accountId?: string | null;
|
|
164
|
+
inputs: string[];
|
|
165
|
+
kind: "user" | "group";
|
|
166
|
+
}): Promise<({
|
|
167
|
+
input: string;
|
|
168
|
+
resolved: boolean;
|
|
169
|
+
note: string;
|
|
170
|
+
id?: undefined;
|
|
171
|
+
name?: undefined;
|
|
172
|
+
} | {
|
|
173
|
+
input: string;
|
|
174
|
+
resolved: boolean;
|
|
175
|
+
id: string;
|
|
176
|
+
name: string;
|
|
177
|
+
note?: undefined;
|
|
178
|
+
})[]>;
|
|
179
|
+
};
|
|
180
|
+
messaging: {
|
|
181
|
+
targetPrefixes: string[];
|
|
182
|
+
normalizeTarget: typeof normalizeTarget;
|
|
183
|
+
parseExplicitTarget(params: {
|
|
184
|
+
raw: string;
|
|
185
|
+
}): {
|
|
186
|
+
to: string;
|
|
187
|
+
chatType: "group" | "direct" | "channel";
|
|
188
|
+
} | null;
|
|
189
|
+
inferTargetChatType(params: {
|
|
190
|
+
to: string;
|
|
191
|
+
}): "group" | "direct" | "channel" | undefined;
|
|
192
|
+
resolveOutboundSessionRoute(params: {
|
|
193
|
+
agentId: string;
|
|
194
|
+
accountId?: string | null;
|
|
195
|
+
target: string;
|
|
196
|
+
threadId?: string | number | null;
|
|
197
|
+
}): {
|
|
198
|
+
sessionKey: string;
|
|
199
|
+
baseSessionKey: string;
|
|
200
|
+
peer: {
|
|
201
|
+
kind: "group" | "direct" | "channel";
|
|
202
|
+
id: string;
|
|
203
|
+
};
|
|
204
|
+
chatType: "group" | "direct" | "channel";
|
|
205
|
+
from: string;
|
|
206
|
+
to: string;
|
|
207
|
+
threadId: string;
|
|
208
|
+
} | null;
|
|
209
|
+
resolveInboundSessionRoute(params: {
|
|
210
|
+
agentId: string;
|
|
211
|
+
accountId?: string | null;
|
|
212
|
+
conversationId: string;
|
|
213
|
+
conversationType: "dm" | "group" | "room" | "ticket";
|
|
214
|
+
threadId?: string | number | null;
|
|
215
|
+
}): {
|
|
216
|
+
sessionKey: string;
|
|
217
|
+
baseSessionKey: string;
|
|
218
|
+
peer: {
|
|
219
|
+
kind: "group" | "direct" | "channel";
|
|
220
|
+
id: string;
|
|
221
|
+
};
|
|
222
|
+
chatType: "group" | "direct" | "channel";
|
|
223
|
+
from: string;
|
|
224
|
+
to: string;
|
|
225
|
+
threadId: string;
|
|
226
|
+
} | null;
|
|
227
|
+
};
|
|
228
|
+
outbound: {
|
|
229
|
+
deliveryMode: string;
|
|
230
|
+
sendText(ctx: {
|
|
231
|
+
cfg: OpenClawConfigLike;
|
|
232
|
+
to: string;
|
|
233
|
+
text: string;
|
|
234
|
+
threadId?: string | number | null;
|
|
235
|
+
accountId?: string | null;
|
|
236
|
+
}): Promise<{
|
|
237
|
+
channel: string;
|
|
238
|
+
messageId: string;
|
|
239
|
+
conversationId: string;
|
|
240
|
+
timestamp: number;
|
|
241
|
+
meta: Record<string, unknown>;
|
|
242
|
+
}>;
|
|
243
|
+
sendMedia(ctx: {
|
|
244
|
+
cfg: OpenClawConfigLike;
|
|
245
|
+
to: string;
|
|
246
|
+
text: string;
|
|
247
|
+
mediaUrl?: string;
|
|
248
|
+
threadId?: string | number | null;
|
|
249
|
+
accountId?: string | null;
|
|
250
|
+
}): Promise<{
|
|
251
|
+
channel: string;
|
|
252
|
+
messageId: string;
|
|
253
|
+
conversationId: string;
|
|
254
|
+
timestamp: number;
|
|
255
|
+
meta: Record<string, unknown>;
|
|
256
|
+
}>;
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
export declare const openClawGenericHttpPluginEntry: {
|
|
260
|
+
id: string;
|
|
261
|
+
name: string;
|
|
262
|
+
description: string;
|
|
263
|
+
configSchema: {
|
|
264
|
+
validate(value: unknown): {
|
|
265
|
+
ok: boolean;
|
|
266
|
+
value: {};
|
|
267
|
+
errors?: undefined;
|
|
268
|
+
} | {
|
|
269
|
+
ok: boolean;
|
|
270
|
+
errors: string[];
|
|
271
|
+
value?: undefined;
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
register(api: OpenClawPluginApiLike): void;
|
|
275
|
+
};
|
|
276
|
+
export {};
|