zhitalk 0.0.0 → 0.0.3

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 (83) hide show
  1. package/CLAUDE.md +98 -0
  2. package/README.md +36 -1
  3. package/dist/agent/agent.d.ts +24 -0
  4. package/dist/agent/agent.js +345 -0
  5. package/dist/agent/cli.d.ts +1 -0
  6. package/dist/agent/cli.js +185 -0
  7. package/dist/agent/colors.d.ts +19 -0
  8. package/dist/agent/colors.js +81 -0
  9. package/dist/agent/commands.d.ts +7 -0
  10. package/dist/agent/commands.js +69 -0
  11. package/dist/agent/config.d.ts +38 -0
  12. package/dist/agent/config.js +116 -0
  13. package/dist/agent/context.d.ts +3 -0
  14. package/dist/agent/context.js +107 -0
  15. package/dist/agent/db.d.ts +21 -0
  16. package/dist/agent/db.js +159 -0
  17. package/dist/agent/hooks.d.ts +27 -0
  18. package/dist/agent/hooks.js +115 -0
  19. package/dist/agent/mcp/client.d.ts +25 -0
  20. package/dist/agent/mcp/client.js +113 -0
  21. package/dist/agent/mcp/index.d.ts +4 -0
  22. package/dist/agent/mcp/index.js +27 -0
  23. package/dist/agent/mcp/wrapper.d.ts +7 -0
  24. package/dist/agent/mcp/wrapper.js +25 -0
  25. package/dist/agent/model.d.ts +5 -0
  26. package/dist/agent/model.js +31 -0
  27. package/dist/agent/permission/dangerous-path.json +115 -0
  28. package/dist/agent/permission/exec.d.ts +11 -0
  29. package/dist/agent/permission/exec.js +34 -0
  30. package/dist/agent/permission/is-dangerous-path.d.ts +1 -0
  31. package/dist/agent/permission/is-dangerous-path.js +53 -0
  32. package/dist/agent/permission/is-safe-domains.d.ts +1 -0
  33. package/dist/agent/permission/is-safe-domains.js +142 -0
  34. package/dist/agent/permission/network.d.ts +8 -0
  35. package/dist/agent/permission/network.js +14 -0
  36. package/dist/agent/permission/read.d.ts +9 -0
  37. package/dist/agent/permission/read.js +17 -0
  38. package/dist/agent/permission/util.d.ts +11 -0
  39. package/dist/agent/permission/util.js +160 -0
  40. package/dist/agent/permission/write.d.ts +11 -0
  41. package/dist/agent/permission/write.js +21 -0
  42. package/dist/agent/prompt.d.ts +1 -0
  43. package/dist/agent/prompt.js +50 -0
  44. package/dist/agent/skills.d.ts +8 -0
  45. package/dist/agent/skills.js +91 -0
  46. package/dist/agent/tools/agent_tool.d.ts +3 -0
  47. package/dist/agent/tools/agent_tool.js +44 -0
  48. package/dist/agent/tools/exec_tool.d.ts +3 -0
  49. package/dist/agent/tools/exec_tool.js +28 -0
  50. package/dist/agent/tools/load_skill_tool.d.ts +3 -0
  51. package/dist/agent/tools/load_skill_tool.js +15 -0
  52. package/dist/agent/tools/memory_create_tool.d.ts +6 -0
  53. package/dist/agent/tools/memory_create_tool.js +37 -0
  54. package/dist/agent/tools/memory_delete_tool.d.ts +3 -0
  55. package/dist/agent/tools/memory_delete_tool.js +28 -0
  56. package/dist/agent/tools/memory_retrieve_tool.d.ts +4 -0
  57. package/dist/agent/tools/memory_retrieve_tool.js +24 -0
  58. package/dist/agent/tools/profile_update_tool.d.ts +3 -0
  59. package/dist/agent/tools/profile_update_tool.js +50 -0
  60. package/dist/agent/tools/read_file_tool.d.ts +3 -0
  61. package/dist/agent/tools/read_file_tool.js +16 -0
  62. package/dist/agent/tools/run_js_tool.d.ts +3 -0
  63. package/dist/agent/tools/run_js_tool.js +36 -0
  64. package/dist/agent/tools/run_py_tool.d.ts +3 -0
  65. package/dist/agent/tools/run_py_tool.js +27 -0
  66. package/dist/agent/tools/search.d.ts +3 -0
  67. package/dist/agent/tools/search.js +10 -0
  68. package/dist/agent/tools/web_fetch_tool.d.ts +3 -0
  69. package/dist/agent/tools/web_fetch_tool.js +33 -0
  70. package/dist/agent/tools/web_search_tool.d.ts +3 -0
  71. package/dist/agent/tools/web_search_tool.js +38 -0
  72. package/dist/agent/tools/write_file_tool.d.ts +4 -0
  73. package/dist/agent/tools/write_file_tool.js +15 -0
  74. package/dist/agent/tools.d.ts +8 -0
  75. package/dist/agent/tools.js +193 -0
  76. package/dist/agent/utils.d.ts +2 -0
  77. package/dist/agent/utils.js +30 -0
  78. package/dist/index.d.ts +2 -0
  79. package/dist/index.js +72 -0
  80. package/dist/install.d.ts +1 -0
  81. package/dist/install.js +108 -0
  82. package/package.json +43 -6
  83. package/index.js +0 -1
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.agentTool = agentTool;
37
+ async function agentTool({ prompt }) {
38
+ if (!prompt || !prompt.trim()) {
39
+ return 'Error: prompt is empty.';
40
+ }
41
+ // 动态 import 避免循环依赖:agent.ts -> tools.ts -> agent_tool.ts -> agent.ts
42
+ const { runSubAgent } = await Promise.resolve().then(() => __importStar(require('../agent')));
43
+ return runSubAgent(prompt.trim());
44
+ }
@@ -0,0 +1,3 @@
1
+ export declare function execTool({ command }: {
2
+ command: string;
3
+ }): Promise<string>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.execTool = execTool;
4
+ const child_process_1 = require("child_process");
5
+ const util_1 = require("util");
6
+ const execAsync = (0, util_1.promisify)(child_process_1.exec);
7
+ async function execTool({ command }) {
8
+ const trimmed = command.trim();
9
+ if (!trimmed) {
10
+ return 'Error: command is empty.';
11
+ }
12
+ if (trimmed.includes('..')) {
13
+ return 'Error: parent directory references (..) are not allowed.';
14
+ }
15
+ const spaceIdx = trimmed.indexOf(' ');
16
+ const args = spaceIdx > 0 ? trimmed.slice(spaceIdx) : '';
17
+ const absolutePathMatch = args.match(/(?:^|\s)(\/[^ ]+)/);
18
+ if (absolutePathMatch) {
19
+ return `Error: absolute paths are not allowed: "${absolutePathMatch[1]}"`;
20
+ }
21
+ try {
22
+ const { stdout, stderr } = await execAsync(trimmed, { cwd: process.cwd(), timeout: 30000 });
23
+ return stdout || stderr || 'Command executed successfully with no output.';
24
+ }
25
+ catch (err) {
26
+ return `Error: ${err.message}`;
27
+ }
28
+ }
@@ -0,0 +1,3 @@
1
+ export declare function loadSkillTool({ name }: {
2
+ name: string;
3
+ }): Promise<string>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadSkillTool = loadSkillTool;
4
+ const skills_1 = require("../skills");
5
+ async function loadSkillTool({ name }) {
6
+ const trimmed = name.trim();
7
+ if (!trimmed) {
8
+ return 'Error: skill name is empty.';
9
+ }
10
+ const content = (0, skills_1.loadSkill)(trimmed);
11
+ if (!content) {
12
+ return `Error: skill "${trimmed}" not found.`;
13
+ }
14
+ return content;
15
+ }
@@ -0,0 +1,6 @@
1
+ export declare function memoryCreateTool({ type, content, keywords, importance, }: {
2
+ type: string;
3
+ content: string;
4
+ keywords?: string[];
5
+ importance?: number;
6
+ }, config?: any): Promise<string>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.memoryCreateTool = memoryCreateTool;
7
+ const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
8
+ const db_1 = require("../db");
9
+ const VALID_TYPES = ['fact', 'event', 'preference', 'skill'];
10
+ async function memoryCreateTool({ type, content, keywords, importance, }, config) {
11
+ if (!VALID_TYPES.includes(type)) {
12
+ return `Error: type must be one of ${VALID_TYPES.join(', ')}.`;
13
+ }
14
+ const trimmed = content?.trim();
15
+ if (!trimmed) {
16
+ return 'Error: content is required.';
17
+ }
18
+ const importanceValue = importance ?? 3;
19
+ if (importanceValue < 1 || importanceValue > 5) {
20
+ return 'Error: importance must be between 1 and 5.';
21
+ }
22
+ const sessionId = config?.configurable?.thread_id ?? 'default-session';
23
+ const keywordsJson = keywords && keywords.length > 0 ? JSON.stringify(keywords) : null;
24
+ const db = new better_sqlite3_1.default(db_1.DB_PATH);
25
+ try {
26
+ const stmt = db.prepare(`INSERT INTO memory (type, content, keywords, importance, session_id)
27
+ VALUES (?, ?, ?, ?, ?)`);
28
+ stmt.run(type, trimmed, keywordsJson, importanceValue, sessionId);
29
+ return 'Memory saved successfully.';
30
+ }
31
+ catch (err) {
32
+ return `Error: ${err.message}`;
33
+ }
34
+ finally {
35
+ db.close();
36
+ }
37
+ }
@@ -0,0 +1,3 @@
1
+ export declare function memoryDeleteTool({ id, }: {
2
+ id: number;
3
+ }, _config?: any): Promise<string>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.memoryDeleteTool = memoryDeleteTool;
7
+ const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
8
+ const db_1 = require("../db");
9
+ async function memoryDeleteTool({ id, }, _config) {
10
+ if (!Number.isFinite(id) || id <= 0) {
11
+ return 'Error: id must be a positive integer.';
12
+ }
13
+ const db = new better_sqlite3_1.default(db_1.DB_PATH);
14
+ try {
15
+ const existing = db.prepare('SELECT 1 FROM memory WHERE id = ?').get(id);
16
+ if (!existing) {
17
+ return `Error: no memory found with id ${id}.`;
18
+ }
19
+ db.prepare('DELETE FROM memory WHERE id = ?').run(id);
20
+ return `Memory ${id} deleted successfully.`;
21
+ }
22
+ catch (err) {
23
+ return `Error: ${err.message}`;
24
+ }
25
+ finally {
26
+ db.close();
27
+ }
28
+ }
@@ -0,0 +1,4 @@
1
+ export declare function memoryRetrieveTool({ query, limit, }: {
2
+ query: string[];
3
+ limit?: number;
4
+ }, config?: any): Promise<string>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.memoryRetrieveTool = memoryRetrieveTool;
4
+ const db_1 = require("../db");
5
+ async function memoryRetrieveTool({ query, limit, }, config) {
6
+ const trimmedQueries = query?.map((q) => q.trim()).filter((q) => q.length > 0);
7
+ if (!trimmedQueries || trimmedQueries.length === 0) {
8
+ return 'Error: query is required.';
9
+ }
10
+ const limitValue = limit ?? 10;
11
+ if (limitValue < 1 || limitValue > 50) {
12
+ return 'Error: limit must be between 1 and 50.';
13
+ }
14
+ try {
15
+ const results = (0, db_1.searchMemories)(trimmedQueries, limitValue);
16
+ if (results.length === 0) {
17
+ return 'No relevant memories found.';
18
+ }
19
+ return JSON.stringify(results);
20
+ }
21
+ catch (err) {
22
+ return `Error: ${err.message}`;
23
+ }
24
+ }
@@ -0,0 +1,3 @@
1
+ export declare function profileUpdateTool({ profile_info, }: {
2
+ profile_info: string;
3
+ }): Promise<string>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.profileUpdateTool = profileUpdateTool;
4
+ const promises_1 = require("fs/promises");
5
+ const path_1 = require("path");
6
+ const config_1 = require("../config");
7
+ function getProfilePaths() {
8
+ const dir = (0, path_1.resolve)(config_1.WORKSPACE_DIR, '.data');
9
+ return { dir, path: (0, path_1.resolve)(dir, 'profile.md') };
10
+ }
11
+ function generateBackupFilename() {
12
+ const dt = Date.now();
13
+ const random = Math.random().toString(36).slice(2, 8);
14
+ return `profile.${dt}-${random}.md`;
15
+ }
16
+ async function profileUpdateTool({ profile_info, }) {
17
+ if (!profile_info || profile_info.trim().length === 0) {
18
+ return 'Error: profile_info is empty.';
19
+ }
20
+ const { dir: profileDir, path: profilePath } = getProfilePaths();
21
+ try {
22
+ let existingContent = '';
23
+ let fileExists = false;
24
+ try {
25
+ existingContent = await (0, promises_1.readFile)(profilePath, 'utf-8');
26
+ fileExists = true;
27
+ }
28
+ catch (err) {
29
+ if (err.code !== 'ENOENT') {
30
+ return `Error reading existing profile: ${err.message}`;
31
+ }
32
+ }
33
+ const normalizedNew = profile_info.trim();
34
+ const normalizedExisting = existingContent.trim();
35
+ if (fileExists && normalizedNew === normalizedExisting) {
36
+ return 'Profile is already up to date. No changes made.';
37
+ }
38
+ await (0, promises_1.mkdir)(profileDir, { recursive: true });
39
+ if (fileExists) {
40
+ const backupFilename = generateBackupFilename();
41
+ const backupPath = (0, path_1.resolve)(profileDir, backupFilename);
42
+ await (0, promises_1.copyFile)(profilePath, backupPath);
43
+ }
44
+ await (0, promises_1.writeFile)(profilePath, profile_info, 'utf-8');
45
+ return `Profile updated successfully. File: ${profilePath}${fileExists ? ' (backup created)' : ''}`;
46
+ }
47
+ catch (err) {
48
+ return `Error: ${err.message}`;
49
+ }
50
+ }
@@ -0,0 +1,3 @@
1
+ export declare function readFileTool({ filepath }: {
2
+ filepath: string;
3
+ }): Promise<string>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readFileTool = readFileTool;
4
+ const promises_1 = require("fs/promises");
5
+ async function readFileTool({ filepath }) {
6
+ try {
7
+ const content = await (0, promises_1.readFile)(filepath, 'utf-8');
8
+ return content;
9
+ }
10
+ catch (err) {
11
+ if (err.code === 'ENOENT') {
12
+ return 'Error: file not found.';
13
+ }
14
+ return `Error: ${err.message}`;
15
+ }
16
+ }
@@ -0,0 +1,3 @@
1
+ export declare function runJsTool({ code }: {
2
+ code: string;
3
+ }): Promise<string>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runJsTool = runJsTool;
4
+ const child_process_1 = require("child_process");
5
+ async function runJsTool({ code }) {
6
+ if (!code.trim()) {
7
+ return 'Error: code is empty.';
8
+ }
9
+ return new Promise((resolve) => {
10
+ const child = (0, child_process_1.spawn)('node', ['--input-type=module'], {
11
+ env: { ...process.env, NO_COLOR: '1', FORCE_COLOR: '0' },
12
+ });
13
+ let stdout = '';
14
+ let stderr = '';
15
+ child.stdout.on('data', (chunk) => {
16
+ stdout += chunk;
17
+ });
18
+ child.stderr.on('data', (chunk) => {
19
+ stderr += chunk;
20
+ });
21
+ child.on('close', (code) => {
22
+ if (code !== 0) {
23
+ resolve(`Error: ${stderr.trim() || 'unknown error'}`);
24
+ }
25
+ else {
26
+ const output = stdout || stderr;
27
+ resolve(output.trim() ? output : 'Code executed successfully with no output.');
28
+ }
29
+ });
30
+ child.on('error', (err) => {
31
+ resolve(`Error: ${err.message}`);
32
+ });
33
+ child.stdin.write(code);
34
+ child.stdin.end();
35
+ });
36
+ }
@@ -0,0 +1,3 @@
1
+ export declare function runPyTool({ code }: {
2
+ code: string;
3
+ }): Promise<string>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runPyTool = runPyTool;
4
+ const child_process_1 = require("child_process");
5
+ const util_1 = require("util");
6
+ const execAsync = (0, util_1.promisify)(child_process_1.exec);
7
+ async function runPyTool({ code }) {
8
+ const trimmed = code.trim();
9
+ if (!trimmed) {
10
+ return 'Error: code is empty.';
11
+ }
12
+ try {
13
+ await execAsync('python3 --version', { timeout: 5000 });
14
+ }
15
+ catch {
16
+ return 'Error: Python3 is not installed on this system. Please install Python3 to execute Python code.';
17
+ }
18
+ const base64Code = Buffer.from(trimmed).toString('base64');
19
+ const command = `python3 -c "import base64; exec(base64.b64decode('${base64Code}').decode('utf-8'))"`;
20
+ try {
21
+ const { stdout, stderr } = await execAsync(command, { cwd: process.cwd(), timeout: 30000 });
22
+ return stdout || stderr || 'Code executed successfully with no output.';
23
+ }
24
+ catch (err) {
25
+ return `Error: ${err.message}`;
26
+ }
27
+ }
@@ -0,0 +1,3 @@
1
+ export declare function search({ query }: {
2
+ query: string;
3
+ }): Promise<string>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.search = search;
4
+ async function search({ query }) {
5
+ if (query.toLowerCase().includes('sf') ||
6
+ query.toLowerCase().includes('san francisco')) {
7
+ return "It's 60 degrees and foggy.";
8
+ }
9
+ return "It's 90 degrees and sunny.";
10
+ }
@@ -0,0 +1,3 @@
1
+ export declare function webFetchTool({ url }: {
2
+ url: string;
3
+ }): Promise<string>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.webFetchTool = webFetchTool;
4
+ const MAX_LENGTH = 8000;
5
+ async function webFetchTool({ url }) {
6
+ const trimmed = url.trim();
7
+ if (!trimmed) {
8
+ return 'Error: url is empty.';
9
+ }
10
+ try {
11
+ const response = await fetch(trimmed, {
12
+ headers: {
13
+ 'User-Agent': 'Mozilla/5.0 (compatible; ZhitalkBot/1.0)',
14
+ },
15
+ signal: AbortSignal.timeout(10000),
16
+ });
17
+ if (!response.ok) {
18
+ return `Error: HTTP ${response.status} ${response.statusText}`;
19
+ }
20
+ const text = await response.text();
21
+ if (text.length > MAX_LENGTH) {
22
+ return text.slice(0, MAX_LENGTH) + '\n\n[Content truncated due to length]';
23
+ }
24
+ return text;
25
+ }
26
+ catch (err) {
27
+ const error = err;
28
+ if (error.name === 'AbortError' || error.name === 'TimeoutError') {
29
+ return 'Error: Request timed out after 10 seconds.';
30
+ }
31
+ return `Error: ${error.message}`;
32
+ }
33
+ }
@@ -0,0 +1,3 @@
1
+ export declare function webSearchTool({ query }: {
2
+ query: string;
3
+ }): Promise<string>;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.webSearchTool = webSearchTool;
4
+ const tavily_1 = require("@langchain/tavily");
5
+ const config_1 = require("../config");
6
+ async function webSearchTool({ query }) {
7
+ const tavilyApiKey = (0, config_1.getEnv)('TAVILY_API_KEY');
8
+ if (!tavilyApiKey) {
9
+ return 'Error: 未配置 TAVILY_API_KEY。请在 ~/.zhitalk/zhitalk.json 的 env 中设置 TAVILY_API_KEY。';
10
+ }
11
+ const tavilySearch = new tavily_1.TavilySearch({
12
+ maxResults: 3,
13
+ topic: 'general',
14
+ tavilyApiKey,
15
+ });
16
+ try {
17
+ const result = await tavilySearch.invoke({ query });
18
+ if ('error' in result && result.error) {
19
+ return `Error: ${result.error}`;
20
+ }
21
+ const lines = [];
22
+ lines.push(`Query: ${result.query}`);
23
+ if (result.answer) {
24
+ lines.push(`Answer: ${result.answer}`);
25
+ }
26
+ lines.push('');
27
+ lines.push('Results:');
28
+ for (let i = 0; i < result.results.length; i++) {
29
+ const r = result.results[i];
30
+ lines.push(`${i + 1}. ${r.title} (${r.url})`);
31
+ lines.push(` ${r.content}`);
32
+ }
33
+ return lines.join('\n');
34
+ }
35
+ catch (err) {
36
+ return `Error: ${err.message}`;
37
+ }
38
+ }
@@ -0,0 +1,4 @@
1
+ export declare function writeFileTool({ filepath, content }: {
2
+ filepath: string;
3
+ content: string;
4
+ }): Promise<string>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeFileTool = writeFileTool;
4
+ const promises_1 = require("fs/promises");
5
+ const path_1 = require("path");
6
+ async function writeFileTool({ filepath, content }) {
7
+ try {
8
+ await (0, promises_1.mkdir)((0, path_1.dirname)(filepath), { recursive: true });
9
+ await (0, promises_1.writeFile)(filepath, content, 'utf-8');
10
+ return `File "${filepath}" written successfully.`;
11
+ }
12
+ catch (err) {
13
+ return `Error: ${err.message}`;
14
+ }
15
+ }
@@ -0,0 +1,8 @@
1
+ import { DynamicStructuredTool } from '@langchain/core/tools';
2
+ export type ZhitalkTool = DynamicStructuredTool & {
3
+ permission_level: string;
4
+ };
5
+ export declare function maybePersistedOutput(content: string, toolCallId: string): Promise<string>;
6
+ export declare const nativeTools: ZhitalkTool[];
7
+ export declare let tools: ZhitalkTool[];
8
+ export declare function initTools(): Promise<void>;