@ozaiya/openclaw-channel 0.1.0

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.
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Minimal type stubs for openclaw/plugin-sdk.
3
+ *
4
+ * These stubs cover only the APIs used by this package so that tsc can
5
+ * type-check and build without installing the full openclaw package (133 MB).
6
+ * The real types are provided at runtime by the openclaw peer dependency.
7
+ */
8
+ declare module "openclaw/plugin-sdk" {
9
+ /** OpenClaw global config object passed to plugin callbacks. */
10
+ export interface OpenClawConfig {
11
+ channels?: Record<string, unknown>;
12
+ [key: string]: unknown;
13
+ }
14
+
15
+ /** Agent tool exposed by a channel plugin. */
16
+ export interface ChannelAgentTool {
17
+ label: string;
18
+ name: string;
19
+ ownerOnly?: boolean;
20
+ description: string;
21
+ parameters: unknown;
22
+ execute: (
23
+ toolCallId: string,
24
+ args: unknown,
25
+ ) => Promise<{ content: Array<{ type: string; text: string }> }>;
26
+ }
27
+
28
+ /** Factory that returns agent tools given config. */
29
+ export type ChannelAgentToolFactory = (ctx: {
30
+ cfg: OpenClawConfig;
31
+ }) => ChannelAgentTool[];
32
+
33
+ /**
34
+ * Channel plugin interface (structural, permissive).
35
+ * Full type-checking is provided by the real openclaw package at runtime.
36
+ */
37
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
38
+ export interface ChannelPlugin<_T = unknown> {}
39
+
40
+ /** OpenClaw PluginRuntime — channel dispatch APIs available after registration. */
41
+ export interface PluginRuntime {
42
+ channel: {
43
+ routing: {
44
+ resolveAgentRoute(opts: {
45
+ cfg: OpenClawConfig;
46
+ channel: string;
47
+ accountId: string;
48
+ peer: { kind: string; id: string };
49
+ }): { agentId: string; sessionKey: string; accountId: string };
50
+ };
51
+ session: {
52
+ resolveStorePath(
53
+ a: undefined,
54
+ b: { agentId: string },
55
+ ): unknown;
56
+ readSessionUpdatedAt(opts: {
57
+ storePath: unknown;
58
+ sessionKey: string;
59
+ }): unknown;
60
+ recordInboundSession(opts: {
61
+ storePath: unknown;
62
+ sessionKey: string;
63
+ ctx: unknown;
64
+ onRecordError: (err: unknown) => void;
65
+ }): Promise<void>;
66
+ };
67
+ reply: {
68
+ resolveEnvelopeFormatOptions(cfg: OpenClawConfig): unknown;
69
+ formatAgentEnvelope(opts: {
70
+ channel: string;
71
+ from: string;
72
+ timestamp: number;
73
+ previousTimestamp: unknown;
74
+ envelope: unknown;
75
+ body: string;
76
+ }): string;
77
+ finalizeInboundContext(ctx: Record<string, unknown>): unknown;
78
+ dispatchReplyWithBufferedBlockDispatcher(opts: {
79
+ ctx: unknown;
80
+ cfg: OpenClawConfig;
81
+ dispatcherOptions: {
82
+ deliver: (payload: { text?: string }, info: unknown) => Promise<void>;
83
+ onError: (err: unknown) => void;
84
+ };
85
+ }): Promise<void>;
86
+ };
87
+ };
88
+ }
89
+
90
+ /** API passed to plugin.register() by OpenClaw. */
91
+ export interface OpenClawPluginApi {
92
+ runtime: PluginRuntime;
93
+ registerChannel(opts: { plugin: unknown }): void;
94
+ }
95
+
96
+ /** Register an HTTP route handled by this plugin. Returns an unregister function. */
97
+ export function registerPluginHttpRoute(opts: {
98
+ path: string;
99
+ auth: string;
100
+ replaceExisting?: boolean;
101
+ pluginId: string;
102
+ source: string;
103
+ log?: (msg: string) => void;
104
+ handler: unknown;
105
+ }): () => void;
106
+
107
+ /** Returns an empty Zod/TypeBox schema for plugins with no config. */
108
+ export function emptyPluginConfigSchema(): unknown;
109
+ }