@elvatis_com/elvatis-mcp 0.2.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.
Files changed (60) hide show
  1. package/.env.example +61 -0
  2. package/LICENSE +190 -0
  3. package/README.md +471 -0
  4. package/dist/config.d.ts +39 -0
  5. package/dist/config.d.ts.map +1 -0
  6. package/dist/config.js +45 -0
  7. package/dist/config.js.map +1 -0
  8. package/dist/index.d.ts +18 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +146 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/spawn.d.ts +12 -0
  13. package/dist/spawn.d.ts.map +1 -0
  14. package/dist/spawn.js +55 -0
  15. package/dist/spawn.js.map +1 -0
  16. package/dist/ssh.d.ts +28 -0
  17. package/dist/ssh.d.ts.map +1 -0
  18. package/dist/ssh.js +171 -0
  19. package/dist/ssh.js.map +1 -0
  20. package/dist/tools/codex.d.ts +61 -0
  21. package/dist/tools/codex.d.ts.map +1 -0
  22. package/dist/tools/codex.js +63 -0
  23. package/dist/tools/codex.js.map +1 -0
  24. package/dist/tools/cron.d.ts +58 -0
  25. package/dist/tools/cron.d.ts.map +1 -0
  26. package/dist/tools/cron.js +88 -0
  27. package/dist/tools/cron.js.map +1 -0
  28. package/dist/tools/gemini.d.ts +75 -0
  29. package/dist/tools/gemini.d.ts.map +1 -0
  30. package/dist/tools/gemini.js +72 -0
  31. package/dist/tools/gemini.js.map +1 -0
  32. package/dist/tools/help.d.ts +31 -0
  33. package/dist/tools/help.d.ts.map +1 -0
  34. package/dist/tools/help.js +39 -0
  35. package/dist/tools/help.js.map +1 -0
  36. package/dist/tools/home.d.ts +108 -0
  37. package/dist/tools/home.d.ts.map +1 -0
  38. package/dist/tools/home.js +141 -0
  39. package/dist/tools/home.js.map +1 -0
  40. package/dist/tools/local-llm.d.ts +115 -0
  41. package/dist/tools/local-llm.d.ts.map +1 -0
  42. package/dist/tools/local-llm.js +123 -0
  43. package/dist/tools/local-llm.js.map +1 -0
  44. package/dist/tools/memory.d.ts +52 -0
  45. package/dist/tools/memory.d.ts.map +1 -0
  46. package/dist/tools/memory.js +92 -0
  47. package/dist/tools/memory.js.map +1 -0
  48. package/dist/tools/openclaw.d.ts +88 -0
  49. package/dist/tools/openclaw.d.ts.map +1 -0
  50. package/dist/tools/openclaw.js +119 -0
  51. package/dist/tools/openclaw.js.map +1 -0
  52. package/dist/tools/routing-rules.d.ts +21 -0
  53. package/dist/tools/routing-rules.d.ts.map +1 -0
  54. package/dist/tools/routing-rules.js +149 -0
  55. package/dist/tools/routing-rules.js.map +1 -0
  56. package/dist/tools/splitter.d.ts +49 -0
  57. package/dist/tools/splitter.d.ts.map +1 -0
  58. package/dist/tools/splitter.js +375 -0
  59. package/dist/tools/splitter.js.map +1 -0
  60. package/package.json +54 -0
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Local LLM sub-agent tool.
3
+ *
4
+ * Talks to any OpenAI-compatible local server:
5
+ * - LM Studio (default: http://localhost:1234/v1)
6
+ * - Ollama (http://localhost:11434/v1)
7
+ * - llama.cpp server (http://localhost:8080/v1)
8
+ * - Any server exposing POST /v1/chat/completions
9
+ *
10
+ * No API key required. No external dependencies (uses Node 18+ built-in fetch).
11
+ *
12
+ * Use cases:
13
+ * - Simple classification, formatting, extraction, rewriting
14
+ * - Free and private (no data leaves the machine)
15
+ * - Fast for small tasks (3B-8B models respond in 1-5 seconds)
16
+ * - Offload cheap work from paid APIs
17
+ */
18
+ import { z } from 'zod';
19
+ import { Config } from '../config.js';
20
+ export declare const localLlmRunSchema: z.ZodObject<{
21
+ prompt: z.ZodString;
22
+ system: z.ZodOptional<z.ZodString>;
23
+ model: z.ZodOptional<z.ZodString>;
24
+ endpoint: z.ZodOptional<z.ZodString>;
25
+ temperature: z.ZodOptional<z.ZodNumber>;
26
+ max_tokens: z.ZodOptional<z.ZodNumber>;
27
+ timeout_seconds: z.ZodDefault<z.ZodNumber>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ prompt: string;
30
+ timeout_seconds: number;
31
+ temperature?: number | undefined;
32
+ model?: string | undefined;
33
+ system?: string | undefined;
34
+ endpoint?: string | undefined;
35
+ max_tokens?: number | undefined;
36
+ }, {
37
+ prompt: string;
38
+ temperature?: number | undefined;
39
+ timeout_seconds?: number | undefined;
40
+ model?: string | undefined;
41
+ system?: string | undefined;
42
+ endpoint?: string | undefined;
43
+ max_tokens?: number | undefined;
44
+ }>;
45
+ interface ChatCompletionResponse {
46
+ id?: string;
47
+ choices: Array<{
48
+ message: {
49
+ role: string;
50
+ content: string;
51
+ };
52
+ finish_reason: string;
53
+ }>;
54
+ model?: string;
55
+ usage?: {
56
+ prompt_tokens: number;
57
+ completion_tokens: number;
58
+ total_tokens: number;
59
+ };
60
+ }
61
+ export declare function handleLocalLlmRun(args: {
62
+ prompt: string;
63
+ system?: string;
64
+ model?: string;
65
+ endpoint?: string;
66
+ temperature?: number;
67
+ max_tokens?: number;
68
+ timeout_seconds: number;
69
+ }, config: Config): Promise<{
70
+ success: boolean;
71
+ error: string;
72
+ hint: string;
73
+ raw?: undefined;
74
+ response?: undefined;
75
+ model?: undefined;
76
+ endpoint?: undefined;
77
+ finish_reason?: undefined;
78
+ usage?: undefined;
79
+ } | {
80
+ success: boolean;
81
+ error: string;
82
+ hint?: undefined;
83
+ raw?: undefined;
84
+ response?: undefined;
85
+ model?: undefined;
86
+ endpoint?: undefined;
87
+ finish_reason?: undefined;
88
+ usage?: undefined;
89
+ } | {
90
+ success: boolean;
91
+ error: string;
92
+ raw: ChatCompletionResponse;
93
+ hint?: undefined;
94
+ response?: undefined;
95
+ model?: undefined;
96
+ endpoint?: undefined;
97
+ finish_reason?: undefined;
98
+ usage?: undefined;
99
+ } | {
100
+ success: boolean;
101
+ response: string;
102
+ model: string;
103
+ endpoint: string;
104
+ finish_reason: string;
105
+ usage: {
106
+ prompt_tokens: number;
107
+ completion_tokens: number;
108
+ total_tokens: number;
109
+ } | undefined;
110
+ error?: undefined;
111
+ hint?: undefined;
112
+ raw?: undefined;
113
+ }>;
114
+ export {};
115
+ //# sourceMappingURL=local-llm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-llm.d.ts","sourceRoot":"","sources":["../../src/tools/local-llm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAItC,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;EAwB5B,CAAC;AAIH,UAAU,sBAAsB;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,KAAK,CAAC;QACb,OAAO,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;QAC3C,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC,CAAC;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE;QACN,aAAa,EAAE,MAAM,CAAC;QACtB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAID,wBAAsB,iBAAiB,CACrC,IAAI,EAAE;IACJ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB,EACD,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAlBG,MAAM;2BACF,MAAM;sBACX,MAAM;;;;;GA4GvB"}
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ /**
3
+ * Local LLM sub-agent tool.
4
+ *
5
+ * Talks to any OpenAI-compatible local server:
6
+ * - LM Studio (default: http://localhost:1234/v1)
7
+ * - Ollama (http://localhost:11434/v1)
8
+ * - llama.cpp server (http://localhost:8080/v1)
9
+ * - Any server exposing POST /v1/chat/completions
10
+ *
11
+ * No API key required. No external dependencies (uses Node 18+ built-in fetch).
12
+ *
13
+ * Use cases:
14
+ * - Simple classification, formatting, extraction, rewriting
15
+ * - Free and private (no data leaves the machine)
16
+ * - Fast for small tasks (3B-8B models respond in 1-5 seconds)
17
+ * - Offload cheap work from paid APIs
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.localLlmRunSchema = void 0;
21
+ exports.handleLocalLlmRun = handleLocalLlmRun;
22
+ const zod_1 = require("zod");
23
+ // --- Schema ---
24
+ exports.localLlmRunSchema = zod_1.z.object({
25
+ prompt: zod_1.z.string().describe('Prompt or question to send to the local LLM.'),
26
+ system: zod_1.z.string().optional().describe('Optional system message to set the LLM\'s behavior.'),
27
+ model: zod_1.z.string().optional().describe('Model identifier as shown in LM Studio / Ollama (e.g. "deepseek-r1-0528-qwen3-8b", "phi-4-mini"). ' +
28
+ 'Omit to use the server\'s currently loaded model or LOCAL_LLM_MODEL env var.'),
29
+ endpoint: zod_1.z.string().optional().describe('Override the local LLM endpoint URL (e.g. "http://localhost:11434/v1" for Ollama). ' +
30
+ 'Omit to use LOCAL_LLM_ENDPOINT env var or default (http://localhost:1234/v1 for LM Studio).'),
31
+ temperature: zod_1.z.number().min(0).max(2).optional().describe('Sampling temperature (0 = deterministic, higher = more creative). Default: server default.'),
32
+ max_tokens: zod_1.z.number().min(1).max(32768).optional().describe('Maximum tokens to generate. Default: server default.'),
33
+ timeout_seconds: zod_1.z.number().min(5).max(300).default(60).describe('Max seconds to wait for a response.'),
34
+ });
35
+ // --- Handler ---
36
+ async function handleLocalLlmRun(args, config) {
37
+ const endpoint = args.endpoint
38
+ ?? config.localLlmEndpoint
39
+ ?? 'http://localhost:1234/v1';
40
+ const model = args.model ?? config.localLlmModel ?? '';
41
+ const url = `${endpoint.replace(/\/+$/, '')}/chat/completions`;
42
+ const messages = [];
43
+ if (args.system) {
44
+ messages.push({ role: 'system', content: args.system });
45
+ }
46
+ messages.push({ role: 'user', content: args.prompt });
47
+ const body = { messages };
48
+ if (model)
49
+ body['model'] = model;
50
+ if (args.temperature !== undefined)
51
+ body['temperature'] = args.temperature;
52
+ if (args.max_tokens !== undefined)
53
+ body['max_tokens'] = args.max_tokens;
54
+ let response;
55
+ try {
56
+ response = await fetch(url, {
57
+ method: 'POST',
58
+ headers: { 'Content-Type': 'application/json' },
59
+ body: JSON.stringify(body),
60
+ signal: AbortSignal.timeout(args.timeout_seconds * 1000),
61
+ });
62
+ }
63
+ catch (err) {
64
+ const msg = err instanceof Error ? err.message : String(err);
65
+ const isTimeout = msg.includes('abort') || msg.includes('timeout');
66
+ const isRefused = msg.includes('ECONNREFUSED') || msg.includes('fetch failed');
67
+ if (isRefused) {
68
+ return {
69
+ success: false,
70
+ error: `Could not connect to local LLM at ${url}`,
71
+ hint: 'Start your local LLM server first:\n'
72
+ + ' LM Studio: open the app, load a model, enable "Local Server"\n'
73
+ + ' Ollama: run `ollama serve` then `ollama run <model>`\n'
74
+ + ' llama.cpp: run `llama-server -m model.gguf --port 8080`',
75
+ };
76
+ }
77
+ if (isTimeout) {
78
+ return {
79
+ success: false,
80
+ error: `Local LLM timed out after ${args.timeout_seconds}s`,
81
+ hint: 'The model may be too large for your hardware, or still loading. Try a smaller model or increase timeout_seconds.',
82
+ };
83
+ }
84
+ return { success: false, error: msg };
85
+ }
86
+ if (!response.ok) {
87
+ const text = await response.text().catch(() => '');
88
+ return {
89
+ success: false,
90
+ error: `Local LLM returned HTTP ${response.status}: ${text.substring(0, 500)}`,
91
+ };
92
+ }
93
+ let data;
94
+ try {
95
+ data = (await response.json());
96
+ }
97
+ catch {
98
+ return {
99
+ success: false,
100
+ error: 'Local LLM returned invalid JSON. Check the server logs.',
101
+ };
102
+ }
103
+ let content = data.choices?.[0]?.message?.content ?? '';
104
+ // Reasoning models (Deepseek R1, Phi 4 Reasoning, etc.) wrap their chain-of-thought
105
+ // in <think>...</think> tags. Strip those to get the actual answer.
106
+ content = content.replace(/<think>[\s\S]*?<\/think>/g, '').trim();
107
+ if (!content) {
108
+ return {
109
+ success: false,
110
+ error: 'Local LLM returned an empty response.',
111
+ raw: data,
112
+ };
113
+ }
114
+ return {
115
+ success: true,
116
+ response: content,
117
+ model: data.model ?? model ?? 'unknown',
118
+ endpoint,
119
+ finish_reason: data.choices[0]?.finish_reason,
120
+ usage: data.usage,
121
+ };
122
+ }
123
+ //# sourceMappingURL=local-llm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-llm.js","sourceRoot":"","sources":["../../src/tools/local-llm.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAmDH,8CAsGC;AAvJD,6BAAwB;AAGxB,iBAAiB;AAEJ,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CACzB,8CAA8C,CAC/C;IACD,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CACpC,qDAAqD,CACtD;IACD,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CACnC,oGAAoG;QACpG,8EAA8E,CAC/E;IACD,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CACtC,qFAAqF;QACrF,6FAA6F,CAC9F;IACD,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CACvD,4FAA4F,CAC7F;IACD,UAAU,EAAE,OAAC,CAAC,MAAM,EAA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+ * Files live at: ~/.openclaw/workspace/memory/YYYY-MM-DD.md
5
+ * This replaces the previous local-filesystem implementation because the
6
+ * canonical memory store is on the OpenClaw server, not on the Windows client.
7
+ */
8
+ import { z } from 'zod';
9
+ import { Config } from '../config.js';
10
+ export declare const memoryWriteSchema: z.ZodObject<{
11
+ note: z.ZodString;
12
+ category: z.ZodOptional<z.ZodString>;
13
+ }, "strip", z.ZodTypeAny, {
14
+ note: string;
15
+ category?: string | undefined;
16
+ }, {
17
+ note: string;
18
+ category?: string | undefined;
19
+ }>;
20
+ export declare const memoryReadTodaySchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
21
+ export declare const memorySearchSchema: z.ZodObject<{
22
+ query: z.ZodString;
23
+ days: z.ZodDefault<z.ZodNumber>;
24
+ }, "strip", z.ZodTypeAny, {
25
+ query: string;
26
+ days: number;
27
+ }, {
28
+ query: string;
29
+ days?: number | undefined;
30
+ }>;
31
+ export declare function handleMemoryWrite(args: {
32
+ note: string;
33
+ category?: string;
34
+ }, config: Config): Promise<{
35
+ success: boolean;
36
+ file: string;
37
+ }>;
38
+ export declare function handleMemoryReadToday(_args: Record<string, never>, config: Config): Promise<{
39
+ content: string;
40
+ date: string;
41
+ }>;
42
+ export declare function handleMemorySearch(args: {
43
+ query: string;
44
+ days: number;
45
+ }, config: Config): Promise<{
46
+ results: {
47
+ date: string;
48
+ excerpt: string;
49
+ }[];
50
+ query: string;
51
+ }>;
52
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/tools/memory.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAOtC,eAAO,MAAM,iBAAiB;;;;;;;;;EAG5B,CAAC;AAEH,eAAO,MAAM,qBAAqB,gDAAe,CAAC;AAElD,eAAO,MAAM,kBAAkB;;;;;;;;;EAG7B,CAAC;AAmBH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,MAAM;;;GAQhG;AAED,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM;;;GAQvF;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,MAAM;;cAkB/D,MAAM;iBAAW,MAAM;;;GAqBrD"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ /**
3
+ * Memory tools — reads and writes daily memory logs on the OpenClaw server via SSH.
4
+ *
5
+ * Files live at: ~/.openclaw/workspace/memory/YYYY-MM-DD.md
6
+ * This replaces the previous local-filesystem implementation because the
7
+ * canonical memory store is on the OpenClaw server, not on the Windows client.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.memorySearchSchema = exports.memoryReadTodaySchema = exports.memoryWriteSchema = void 0;
11
+ exports.handleMemoryWrite = handleMemoryWrite;
12
+ exports.handleMemoryReadToday = handleMemoryReadToday;
13
+ exports.handleMemorySearch = handleMemorySearch;
14
+ const zod_1 = require("zod");
15
+ const ssh_js_1 = require("../ssh.js");
16
+ const MEMORY_DIR = '~/.openclaw/workspace/memory';
17
+ // --- Schemas ---
18
+ exports.memoryWriteSchema = zod_1.z.object({
19
+ note: zod_1.z.string().describe('The note to save'),
20
+ category: zod_1.z.string().optional().describe('Optional category/tag, e.g. "decision", "todo", "context"'),
21
+ });
22
+ exports.memoryReadTodaySchema = zod_1.z.object({});
23
+ exports.memorySearchSchema = zod_1.z.object({
24
+ query: zod_1.z.string().describe('Search term'),
25
+ days: zod_1.z.number().min(1).max(90).default(14).describe('How many days back to search (default: 14)'),
26
+ });
27
+ // --- Helpers ---
28
+ function toSshCfg(config) {
29
+ return {
30
+ host: config.sshHost,
31
+ port: config.sshPort,
32
+ username: config.sshUser,
33
+ keyPath: config.sshKeyPath,
34
+ };
35
+ }
36
+ function getTodayDate() {
37
+ return new Date().toISOString().split('T')[0];
38
+ }
39
+ // --- Handlers ---
40
+ async function handleMemoryWrite(args, config) {
41
+ const today = getTodayDate();
42
+ const file = `${MEMORY_DIR}/${today}.md`;
43
+ const timestamp = new Date().toISOString().replace('T', ' ').substring(0, 16);
44
+ const tag = args.category ? ` [${args.category}]` : '';
45
+ const entry = `\n## ${timestamp}${tag}\n${args.note}\n`;
46
+ await (0, ssh_js_1.sshAppendFile)(toSshCfg(config), file, entry);
47
+ return { success: true, file: `${today}.md` };
48
+ }
49
+ async function handleMemoryReadToday(_args, config) {
50
+ const today = getTodayDate();
51
+ const file = `${MEMORY_DIR}/${today}.md`;
52
+ const content = await (0, ssh_js_1.sshReadFile)(toSshCfg(config), file);
53
+ return {
54
+ content: content.trim() || '(no entries today yet)',
55
+ date: today,
56
+ };
57
+ }
58
+ async function handleMemorySearch(args, config) {
59
+ const cfg = toSshCfg(config);
60
+ const escaped = args.query.replace(/'/g, "'\\''");
61
+ // Single SSH call: list recent files, grep all of them at once, and format
62
+ // output with filenames so we can extract date + excerpt per file.
63
+ // This avoids N+1 SSH connections (which was the main reliability issue).
64
+ const output = await (0, ssh_js_1.sshExec)(cfg, `files=$(ls ${MEMORY_DIR}/*.md 2>/dev/null | sort -r | head -${args.days}) && `
65
+ + `[ -n "$files" ] && grep -i -H -m1 -A2 -B1 '${escaped}' $files 2>/dev/null || true`, 20000);
66
+ if (!output.trim())
67
+ return { results: [], query: args.query };
68
+ // Parse grep -H output: each block is separated by "--" lines,
69
+ // lines are prefixed with "filepath:content" or "filepath-content" (context lines).
70
+ const results = [];
71
+ const blocks = output.split(/^--$/m);
72
+ for (const block of blocks) {
73
+ const trimmed = block.trim();
74
+ if (!trimmed)
75
+ continue;
76
+ // Extract date from first line's file path (e.g. /path/2026-03-30.md:...)
77
+ const dateMatch = trimmed.match(/(\d{4}-\d{2}-\d{2})\.md[:\-]/);
78
+ if (!dateMatch)
79
+ continue;
80
+ // Strip file path prefixes from each line for clean excerpt
81
+ const excerpt = trimmed
82
+ .split('\n')
83
+ .map(line => line.replace(/^.*\.md[:\-]/, ''))
84
+ .join('\n')
85
+ .trim();
86
+ if (excerpt) {
87
+ results.push({ date: dateMatch[1], excerpt });
88
+ }
89
+ }
90
+ return { results, query: args.query };
91
+ }
92
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/tools/memory.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAuCH,8CAQC;AAED,sDAQC;AAED,gDAuCC;AAhGD,6BAAwB;AAExB,sCAA2E;AAE3E,MAAM,UAAU,GAAG,8BAA8B,CAAC;AAElD,kBAAkB;AAEL,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;IAC7C,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2DAA2D,CAAC;CACtG,CAAC,CAAC;AAEU,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAErC,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IACzC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC;IACzC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,4CAA4C,CAAC;CACnG,CAAC,CAAC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,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;aAC7C,IAAI,CAAC,IAAI,CAAC;aACV,IAAI,EAAE,CAAC;QACV,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;AACxC,CAAC"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * OpenClaw sub-agent orchestration tools.
3
+ *
4
+ * Architecture:
5
+ * Claude Desktop (MCP client)
6
+ * -> elvatis-mcp (this server)
7
+ * -> SSH to OpenClaw server
8
+ * -> openclaw CLI (runs task with all installed plugins)
9
+ * -> response streamed back
10
+ *
11
+ * This pattern avoids re-implementing OpenClaw's plugins in MCP.
12
+ * Instead, we delegate to OpenClaw, which already has everything installed:
13
+ * trading tools, custom workflows, WhatsApp integration, etc.
14
+ *
15
+ * Required env var on the server: OPENCLAW_CLI_CMD (default: "openclaw chat")
16
+ * Adjust to match your OpenClaw installation's actual CLI syntax.
17
+ */
18
+ import { z } from 'zod';
19
+ import { Config } from '../config.js';
20
+ export declare const openclawRunSchema: z.ZodObject<{
21
+ prompt: z.ZodString;
22
+ agent: z.ZodOptional<z.ZodString>;
23
+ timeout_seconds: z.ZodDefault<z.ZodNumber>;
24
+ }, "strip", z.ZodTypeAny, {
25
+ prompt: string;
26
+ timeout_seconds: number;
27
+ agent?: string | undefined;
28
+ }, {
29
+ prompt: string;
30
+ agent?: string | undefined;
31
+ timeout_seconds?: number | undefined;
32
+ }>;
33
+ export declare const openclawStatusSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
34
+ export declare const openclawPluginsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
35
+ /**
36
+ * Run a prompt through the OpenClaw agent via SSH.
37
+ *
38
+ * Uses: openclaw agents send --message "<prompt>" --local --timeout <seconds>
39
+ * --local : bypasses the WebSocket Gateway, runs the embedded runtime directly.
40
+ * Perfect for SSH-based calls — no gateway connection needed.
41
+ * --timeout: how long the CLI waits for the agent turn to complete.
42
+ *
43
+ * The agent has access to all installed plugins (trading, home, etc.)
44
+ * and all configured LLM backends (claude, gpt, gemini).
45
+ *
46
+ * If this fails:
47
+ * 1. Check `openclaw --version` on the server (agents send requires 0.x+)
48
+ * 2. Check `openclaw doctor` for config issues
49
+ * 3. Confirm the openclaw binary is on PATH: `which openclaw`
50
+ */
51
+ export declare function handleOpenclawRun(args: {
52
+ prompt: string;
53
+ agent?: string;
54
+ timeout_seconds: number;
55
+ }, config: Config): Promise<{
56
+ success: boolean;
57
+ response: string;
58
+ agent: string;
59
+ error?: undefined;
60
+ hint?: undefined;
61
+ } | {
62
+ success: boolean;
63
+ error: string;
64
+ hint: string;
65
+ response?: undefined;
66
+ agent?: undefined;
67
+ }>;
68
+ /**
69
+ * Get OpenClaw daemon status and basic info.
70
+ */
71
+ export declare function handleOpenclawStatus(_args: Record<string, never>, config: Config): Promise<{
72
+ process: string;
73
+ server_uptime: string;
74
+ openclaw_version: string;
75
+ ssh_host: string;
76
+ default_agent: string;
77
+ }>;
78
+ /**
79
+ * List installed OpenClaw plugins.
80
+ * CLI: openclaw plugins list (compact inventory)
81
+ * For details on one plugin: openclaw plugins inspect <id>
82
+ */
83
+ export declare function handleOpenclawPlugins(_args: Record<string, never>, config: Config): Promise<{
84
+ list: string;
85
+ status: string | undefined;
86
+ note: string;
87
+ }>;
88
+ //# sourceMappingURL=openclaw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openclaw.d.ts","sourceRoot":"","sources":["../../src/tools/openclaw.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAKtC,eAAO,MAAM,iBAAiB;;;;;;;;;;;;EAI5B,CAAC;AAEH,eAAO,MAAM,oBAAoB,gDAAe,CAAC;AAEjD,eAAO,MAAM,qBAAqB,gDAAe,CAAC;AAelD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,EACjE,MAAM,EAAE,MAAM;;;;;;;;;;;;GAuBf;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM;;;;;;GAiBtF;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM;;;;GAavF"}
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ /**
3
+ * OpenClaw sub-agent orchestration tools.
4
+ *
5
+ * Architecture:
6
+ * Claude Desktop (MCP client)
7
+ * -> elvatis-mcp (this server)
8
+ * -> SSH to OpenClaw server
9
+ * -> openclaw CLI (runs task with all installed plugins)
10
+ * -> response streamed back
11
+ *
12
+ * This pattern avoids re-implementing OpenClaw's plugins in MCP.
13
+ * Instead, we delegate to OpenClaw, which already has everything installed:
14
+ * trading tools, custom workflows, WhatsApp integration, etc.
15
+ *
16
+ * Required env var on the server: OPENCLAW_CLI_CMD (default: "openclaw chat")
17
+ * Adjust to match your OpenClaw installation's actual CLI syntax.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.openclawPluginsSchema = exports.openclawStatusSchema = exports.openclawRunSchema = void 0;
21
+ exports.handleOpenclawRun = handleOpenclawRun;
22
+ exports.handleOpenclawStatus = handleOpenclawStatus;
23
+ exports.handleOpenclawPlugins = handleOpenclawPlugins;
24
+ const zod_1 = require("zod");
25
+ const ssh_js_1 = require("../ssh.js");
26
+ // --- Schemas ---
27
+ exports.openclawRunSchema = zod_1.z.object({
28
+ prompt: zod_1.z.string().describe('Task or question to send to the OpenClaw AI agent. It has access to all installed plugins (trading, home, memory, etc.).'),
29
+ agent: zod_1.z.string().optional().describe('Optional: name of a specific OpenClaw agent to use (e.g. "ops", "trading"). Omit to use the default agent.'),
30
+ timeout_seconds: zod_1.z.number().min(5).max(300).default(60).describe('Max seconds to wait for the agent response'),
31
+ });
32
+ exports.openclawStatusSchema = zod_1.z.object({});
33
+ exports.openclawPluginsSchema = zod_1.z.object({});
34
+ // --- Helpers ---
35
+ function toSshCfg(config) {
36
+ return {
37
+ host: config.sshHost,
38
+ port: config.sshPort,
39
+ username: config.sshUser,
40
+ keyPath: config.sshKeyPath,
41
+ };
42
+ }
43
+ // --- Handlers ---
44
+ /**
45
+ * Run a prompt through the OpenClaw agent via SSH.
46
+ *
47
+ * Uses: openclaw agents send --message "<prompt>" --local --timeout <seconds>
48
+ * --local : bypasses the WebSocket Gateway, runs the embedded runtime directly.
49
+ * Perfect for SSH-based calls — no gateway connection needed.
50
+ * --timeout: how long the CLI waits for the agent turn to complete.
51
+ *
52
+ * The agent has access to all installed plugins (trading, home, etc.)
53
+ * and all configured LLM backends (claude, gpt, gemini).
54
+ *
55
+ * If this fails:
56
+ * 1. Check `openclaw --version` on the server (agents send requires 0.x+)
57
+ * 2. Check `openclaw doctor` for config issues
58
+ * 3. Confirm the openclaw binary is on PATH: `which openclaw`
59
+ */
60
+ async function handleOpenclawRun(args, config) {
61
+ const cfg = toSshCfg(config);
62
+ // Escape double quotes in the prompt to prevent shell injection
63
+ const safePrompt = args.prompt.replace(/"/g, '\\"');
64
+ const agentName = args.agent ?? config.openclawDefaultAgent;
65
+ const agentFlag = agentName ? ` --agent ${agentName}` : '';
66
+ const cmd = `openclaw agents send --message "${safePrompt}"${agentFlag} --local --timeout ${args.timeout_seconds}`;
67
+ try {
68
+ const output = await (0, ssh_js_1.sshExec)(cfg, cmd, (args.timeout_seconds + 10) * 1000);
69
+ return {
70
+ success: true,
71
+ response: output.trim(),
72
+ agent: args.agent ?? 'default',
73
+ };
74
+ }
75
+ catch (err) {
76
+ return {
77
+ success: false,
78
+ error: String(err),
79
+ hint: 'Check: `openclaw doctor` on the server, or try `openclaw agents send --help` for correct flags.',
80
+ };
81
+ }
82
+ }
83
+ /**
84
+ * Get OpenClaw daemon status and basic info.
85
+ */
86
+ async function handleOpenclawStatus(_args, config) {
87
+ const cfg = toSshCfg(config);
88
+ // Check if the openclaw process is running
89
+ const processCheck = await (0, ssh_js_1.sshExec)(cfg, `pgrep -a openclaw 2>/dev/null || echo "(not found)"`).catch(() => '(ssh error)');
90
+ // Get uptime info
91
+ const uptime = await (0, ssh_js_1.sshExec)(cfg, 'uptime').catch(() => '(unavailable)');
92
+ // Get OpenClaw version if available
93
+ const version = await (0, ssh_js_1.sshExec)(cfg, 'openclaw --version 2>/dev/null || openclaw version 2>/dev/null || echo "(unknown)"').catch(() => '(unavailable)');
94
+ return {
95
+ process: processCheck.trim(),
96
+ server_uptime: uptime.trim(),
97
+ openclaw_version: version.trim(),
98
+ ssh_host: config.sshHost,
99
+ default_agent: config.openclawDefaultAgent ?? '(default)',
100
+ };
101
+ }
102
+ /**
103
+ * List installed OpenClaw plugins.
104
+ * CLI: openclaw plugins list (compact inventory)
105
+ * For details on one plugin: openclaw plugins inspect <id>
106
+ */
107
+ async function handleOpenclawPlugins(_args, config) {
108
+ const cfg = toSshCfg(config);
109
+ const [listOutput, statusOutput] = await Promise.all([
110
+ (0, ssh_js_1.sshExec)(cfg, 'openclaw plugins list 2>&1').catch(err => `(error: ${err})`),
111
+ (0, ssh_js_1.sshExec)(cfg, 'openclaw plugins status 2>&1').catch(() => ''),
112
+ ]);
113
+ return {
114
+ list: listOutput.trim(),
115
+ status: statusOutput.trim() || undefined,
116
+ note: 'Use `openclaw plugins inspect <id>` for details on a specific plugin',
117
+ };
118
+ }
119
+ //# sourceMappingURL=openclaw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openclaw.js","sourceRoot":"","sources":["../../src/tools/openclaw.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AA+CH,8CAyBC;AAKD,oDAiBC;AAOD,sDAaC;AAhHD,6BAAwB;AAExB,sCAA4D;AAE5D,kBAAkB;AAEL,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0HAA0H,CAAC;IACvJ,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,4GAA4G,CAAC;IACnJ,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,4CAA4C,CAAC;CAC/G,CAAC,CAAC;AAEU,QAAA,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEpC,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAElD,kBAAkB;AAElB,SAAS,QAAQ,CAAC,MAAc;IAC9B,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,OAAO;QACpB,IAAI,EAAE,MAAM,CAAC,OAAO;QACpB,QAAQ,EAAE,MAAM,CAAC,OAAO;QACxB,OAAO,EAAE,MAAM,CAAC,UAAU;KAC3B,CAAC;AACJ,CAAC;AAED,mBAAmB;AAEnB;;;;;;;;;;;;;;;GAeG;AACI,KAAK,UAAU,iBAAiB,CACrC,IAAiE,EACjE,MAAc;IAEd,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC7B,gEAA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C,CAAC;IACzE,oCAAoC;IACpC,MAAM,OAAO,GAAG,MAAM,IAAA,gBAAO,EAAC,GAAG,EAAE,oFAAoF,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;IAEtJ,OAAO;QACL,OAAO,EAAE,YAAY,CAAC,IAAI,EAAE;QAC5B,aAAa,EAAE,MAAM,CAAC,IAAI,EAAE;QAC5B,gBAAgB,EAAE,OAAO,CAAC,IAAI,EAAE;QAChC,QAAQ,EAAE,MAAM,CAAC,OAAO;QACxB,aAAa,EAAE,MAAM,CAAC,oBAAoB,IAAI,WAAW;KAC1D,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,qBAAqB,CAAC,KAA4B,EAAE,MAAc;IACtF,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IAE7B,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACnD,IAAA,gBAAO,EAAC,GAAG,EAAE,4BAA4B,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,WAAW,GAAG,GAAG,CAAC;QAC1E,IAAA,gBAAO,EAAC,GAAG,EAAE,8BAA8B,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;KAC7D,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE;QACvB,MAAM,EAAE,YAAY,CAAC,IAAI,EAAE,IAAI,SAAS;QACxC,IAAI,EAAE,sEAAsE;KAC7E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Shared routing rules and constants used by mcp_help and prompt_split.
3
+ *
4
+ * Extracted so both tools operate from the same knowledge base.
5
+ */
6
+ export interface RoutingRule {
7
+ tool: string;
8
+ keywords: string[];
9
+ reason: string;
10
+ }
11
+ export declare const ROUTING_RULES: RoutingRule[];
12
+ /** Score routing rules against a text. Returns matches sorted by score (highest first). */
13
+ export declare function matchRules(text: string): Array<{
14
+ tool: string;
15
+ reason: string;
16
+ score: number;
17
+ }>;
18
+ /** Known single-call tool names (for validation in prompt_split). */
19
+ export declare const KNOWN_AGENTS: Set<string>;
20
+ export declare const ROUTING_GUIDE: string;
21
+ //# sourceMappingURL=routing-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing-rules.d.ts","sourceRoot":"","sources":["../../src/tools/routing-rules.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,aAAa,EAAE,WAAW,EA6DtC,CAAC;AAEF,2FAA2F;AAC3F,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAa/F;AAED,qEAAqE;AACrE,eAAO,MAAM,YAAY,aAMvB,CAAC;AAEH,eAAO,MAAM,aAAa,QAuDlB,CAAC"}