@kookapp/clawdbot-plugin 1.0.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.
- package/LICENSE +21 -0
- package/README.md +128 -0
- package/dist/index.js +4428 -0
- package/index.d.ts +10 -0
- package/index.d.ts.map +1 -0
- package/index.js +15 -0
- package/index.js.map +1 -0
- package/package.json +47 -0
- package/src/channel.ts +746 -0
- package/src/clawdbot.plugin.json +11 -0
- package/src/index.ts +18 -0
- package/src/plugin-sdk.d.ts +78 -0
- package/src/runtime.ts +14 -0
- package/tsconfig.json +26 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ClawdbotPluginApi } from "clawdbot/plugin-sdk";
|
|
2
|
+
import { emptyPluginConfigSchema } from "clawdbot/plugin-sdk";
|
|
3
|
+
|
|
4
|
+
import { kookPlugin } from "./channel.js";
|
|
5
|
+
import { setKookRuntime } from "./runtime.js";
|
|
6
|
+
|
|
7
|
+
const plugin = {
|
|
8
|
+
id: "kook",
|
|
9
|
+
name: "Kook",
|
|
10
|
+
description: "Kook channel plugin",
|
|
11
|
+
configSchema: emptyPluginConfigSchema(),
|
|
12
|
+
register(api: ClawdbotPluginApi) {
|
|
13
|
+
setKookRuntime(api.runtime);
|
|
14
|
+
api.registerChannel({ plugin: kookPlugin });
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default plugin;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Type declarations for clawdbot/plugin-sdk
|
|
2
|
+
// These are minimal type definitions for building the plugin
|
|
3
|
+
|
|
4
|
+
declare module 'clawdbot/plugin-sdk' {
|
|
5
|
+
export interface PluginRuntime {
|
|
6
|
+
runtime: string;
|
|
7
|
+
config: {
|
|
8
|
+
loadConfig(): Record<string, unknown>;
|
|
9
|
+
};
|
|
10
|
+
channel: {
|
|
11
|
+
routing: {
|
|
12
|
+
resolveAgentRoute(params: {
|
|
13
|
+
cfg: Record<string, unknown>;
|
|
14
|
+
channel: string;
|
|
15
|
+
accountId: string;
|
|
16
|
+
teamId?: string;
|
|
17
|
+
peer: { kind: string; id: string };
|
|
18
|
+
}): { sessionKey: string; agentId?: string; accountId: string };
|
|
19
|
+
};
|
|
20
|
+
reply: {
|
|
21
|
+
finalizeInboundContext(params: Record<string, unknown>): Record<string, unknown>;
|
|
22
|
+
createReplyDispatcherWithTyping(params: Record<string, unknown>): {
|
|
23
|
+
dispatcher: unknown;
|
|
24
|
+
replyOptions: Record<string, unknown>;
|
|
25
|
+
markDispatchIdle(): void;
|
|
26
|
+
};
|
|
27
|
+
dispatchReplyFromConfig(params: Record<string, unknown>): Promise<void>;
|
|
28
|
+
resolveHumanDelayConfig(cfg: Record<string, unknown>, agentId?: string): number;
|
|
29
|
+
};
|
|
30
|
+
text: {
|
|
31
|
+
resolveTextChunkLimit(cfg: Record<string, unknown>, channel: string, accountId: string, options?: Record<string, unknown>): number;
|
|
32
|
+
resolveMarkdownTableMode(cfg: Record<string, unknown>, channel: string, accountId: string): Record<string, unknown>;
|
|
33
|
+
chunkMarkdownTextWithMode(text: string, limit: number, mode: Record<string, unknown>): string[];
|
|
34
|
+
hasControlCommand(text: string, cfg: Record<string, unknown>): boolean;
|
|
35
|
+
};
|
|
36
|
+
debounce: {
|
|
37
|
+
resolveInboundDebounceMs(cfg: Record<string, unknown>, channel: string): number;
|
|
38
|
+
createInboundDebouncer(options: Record<string, unknown>): unknown;
|
|
39
|
+
};
|
|
40
|
+
discord?: {
|
|
41
|
+
messageActions: {
|
|
42
|
+
listActions(ctx: unknown): unknown;
|
|
43
|
+
extractToolSend(ctx: unknown): unknown;
|
|
44
|
+
handleAction(ctx: unknown): Promise<void>;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
error?(message: string, ...args: unknown[]): void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface ClawdbotConfig {
|
|
52
|
+
channels?: Record<string, unknown>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ReplyPayload {
|
|
56
|
+
text?: string;
|
|
57
|
+
mediaUrl?: string;
|
|
58
|
+
mediaUrls?: string[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function emptyPluginConfigSchema(): Record<string, unknown>;
|
|
62
|
+
|
|
63
|
+
export const DEFAULT_ACCOUNT_ID: string;
|
|
64
|
+
|
|
65
|
+
export function applyAccountNameToChannelSection(params: Record<string, unknown>): Record<string, unknown>;
|
|
66
|
+
|
|
67
|
+
export function deleteAccountFromConfigSection(params: Record<string, unknown>): Record<string, unknown>;
|
|
68
|
+
|
|
69
|
+
export function setAccountEnabledInConfigSection(params: Record<string, unknown>): Record<string, unknown>;
|
|
70
|
+
|
|
71
|
+
export function migrateBaseNameToDefaultAccount(params: Record<string, unknown>): Record<string, unknown>;
|
|
72
|
+
|
|
73
|
+
export function normalizeAccountId(accountId: string): string;
|
|
74
|
+
|
|
75
|
+
export function formatPairingApproveHint(channel: string): string;
|
|
76
|
+
|
|
77
|
+
export function buildChannelConfigSchema(schema: Record<string, unknown>): Record<string, unknown>;
|
|
78
|
+
}
|
package/src/runtime.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PluginRuntime } from "clawdbot/plugin-sdk";
|
|
2
|
+
|
|
3
|
+
let runtime: PluginRuntime | null = null;
|
|
4
|
+
|
|
5
|
+
export function setKookRuntime(next: PluginRuntime) {
|
|
6
|
+
runtime = next;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function getKookRuntime(): PluginRuntime {
|
|
10
|
+
if (!runtime) {
|
|
11
|
+
throw new Error("Kook runtime not initialized");
|
|
12
|
+
}
|
|
13
|
+
return runtime;
|
|
14
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"strict": false,
|
|
10
|
+
"noEmit": false,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"declarationMap": true,
|
|
16
|
+
"sourceMap": true,
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
"isolatedModules": true,
|
|
19
|
+
"noUnusedLocals": false,
|
|
20
|
+
"noUnusedParameters": false,
|
|
21
|
+
"allowSyntheticDefaultImports": true,
|
|
22
|
+
"baseUrl": "."
|
|
23
|
+
},
|
|
24
|
+
"include": ["src/**/*"],
|
|
25
|
+
"exclude": ["node_modules", "dist"]
|
|
26
|
+
}
|