ocsmarttools 0.1.2
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/CHANGELOG.md +35 -0
- package/README.md +169 -0
- package/openclaw.plugin.json +48 -0
- package/package.json +33 -0
- package/src/commands/chat.ts +123 -0
- package/src/commands/cli.ts +130 -0
- package/src/commands/operations.ts +370 -0
- package/src/index.ts +70 -0
- package/src/lib/bootstrap.ts +114 -0
- package/src/lib/invoke.ts +202 -0
- package/src/lib/metrics-store.ts +177 -0
- package/src/lib/plugin-config.ts +143 -0
- package/src/lib/refs.ts +68 -0
- package/src/lib/result-shaper.ts +237 -0
- package/src/lib/result-store.ts +72 -0
- package/src/lib/tool-catalog.ts +339 -0
- package/src/tools/tool-batch.ts +374 -0
- package/src/tools/tool-dispatch.ts +157 -0
- package/src/tools/tool-result-get.ts +65 -0
- package/src/tools/tool-search.ts +72 -0
- package/src/types/openclaw-plugin-sdk.d.ts +78 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
declare module "openclaw/plugin-sdk" {
|
|
2
|
+
export type OpenClawConfig = Record<string, unknown>;
|
|
3
|
+
|
|
4
|
+
export type PluginRuntime = {
|
|
5
|
+
config: {
|
|
6
|
+
loadConfig: () => OpenClawConfig;
|
|
7
|
+
writeConfigFile: (cfg: OpenClawConfig) => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
system: {
|
|
10
|
+
runCommandWithTimeout: (
|
|
11
|
+
argv: string[],
|
|
12
|
+
options: number | { timeoutMs: number; cwd?: string },
|
|
13
|
+
) => Promise<{
|
|
14
|
+
stdout: string;
|
|
15
|
+
stderr: string;
|
|
16
|
+
code: number | null;
|
|
17
|
+
signal: NodeJS.Signals | null;
|
|
18
|
+
killed: boolean;
|
|
19
|
+
termination: string;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type AnyAgentTool = {
|
|
25
|
+
name: string;
|
|
26
|
+
label?: string;
|
|
27
|
+
description: string;
|
|
28
|
+
parameters: unknown;
|
|
29
|
+
execute: (toolCallId: string, params: Record<string, unknown>) => Promise<unknown>;
|
|
30
|
+
ownerOnly?: boolean;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type OpenClawPluginToolContext = {
|
|
34
|
+
sandboxed?: boolean;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type OpenClawPluginApi = {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
version?: string;
|
|
41
|
+
config: OpenClawConfig;
|
|
42
|
+
pluginConfig?: Record<string, unknown>;
|
|
43
|
+
runtime: PluginRuntime;
|
|
44
|
+
logger: {
|
|
45
|
+
info: (message: string) => void;
|
|
46
|
+
warn: (message: string) => void;
|
|
47
|
+
error: (message: string) => void;
|
|
48
|
+
debug?: (message: string) => void;
|
|
49
|
+
};
|
|
50
|
+
registerTool: (
|
|
51
|
+
tool: AnyAgentTool | ((ctx: OpenClawPluginToolContext) => AnyAgentTool | AnyAgentTool[] | null),
|
|
52
|
+
opts?: { optional?: boolean; name?: string; names?: string[] },
|
|
53
|
+
) => void;
|
|
54
|
+
registerCommand: (command: {
|
|
55
|
+
name: string;
|
|
56
|
+
description: string;
|
|
57
|
+
acceptsArgs?: boolean;
|
|
58
|
+
requireAuth?: boolean;
|
|
59
|
+
handler: (ctx: { args?: string; channel: string; config: OpenClawConfig }) =>
|
|
60
|
+
| Promise<{ text: string }>
|
|
61
|
+
| { text: string };
|
|
62
|
+
}) => void;
|
|
63
|
+
registerCli: (
|
|
64
|
+
registrar: (ctx: { program: import("commander").Command; config: OpenClawConfig }) => void,
|
|
65
|
+
opts?: { commands?: string[] },
|
|
66
|
+
) => void;
|
|
67
|
+
registerService: (service: {
|
|
68
|
+
id: string;
|
|
69
|
+
start: () => void | Promise<void>;
|
|
70
|
+
stop?: () => void | Promise<void>;
|
|
71
|
+
}) => void;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export function jsonResult(payload: unknown): {
|
|
75
|
+
content: Array<{ type: "text"; text: string }>;
|
|
76
|
+
details: unknown;
|
|
77
|
+
};
|
|
78
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"types": ["node"]
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*.ts", "src/**/*.d.ts"]
|
|
14
|
+
}
|