-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
67 lines (61 loc) · 1.79 KB
/
index.js
File metadata and controls
67 lines (61 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
import {
buildKleinanzeigenApprovalDescription,
createKleinanzeigenTools,
OPTIONAL_TOOL_NAMES,
resolveApprovalToolNames,
} from "./src/tools.js";
function createCommandRunner(runtime) {
const runCommandWithTimeout = runtime?.system?.runCommandWithTimeout;
if (typeof runCommandWithTimeout !== "function") {
return undefined;
}
return (argv, options = {}) =>
runCommandWithTimeout(argv, {
cwd: options.cwd,
env: options.env,
timeoutMs: options.timeoutMs ?? 120000,
});
}
export default definePluginEntry({
id: "kleinclaw",
name: "KleinClaw",
description:
"Kleinanzeigen helper tools for a local kleinanzeigen-bot setup with redacted output.",
register(api) {
const pluginConfig = {
...(api.pluginConfig ?? {}),
commandRunner: createCommandRunner(api.runtime),
};
const tools = createKleinanzeigenTools(pluginConfig);
const approvalToolNames = resolveApprovalToolNames(pluginConfig);
for (const tool of tools) {
api.registerTool(
tool,
OPTIONAL_TOOL_NAMES.has(tool.name) ? { optional: true } : undefined,
);
}
api.on(
"before_tool_call",
(event) => {
if (!approvalToolNames.has(event.toolName)) {
return;
}
return {
requireApproval: {
title: "Run Kleinanzeigen local operation",
description: buildKleinanzeigenApprovalDescription({
toolName: event.toolName,
params: event.params,
config: pluginConfig,
}),
severity: "warning",
timeoutMs: 120000,
timeoutBehavior: "deny",
},
};
},
{ priority: 80, timeoutMs: 5000 },
);
},
});