fotric-claw 0.1.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 (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +276 -0
  3. package/backend/.env.example +26 -0
  4. package/backend/nest-cli.json +8 -0
  5. package/backend/package-lock.json +13239 -0
  6. package/backend/package.json +82 -0
  7. package/backend/src/agent/agent.module.ts +10 -0
  8. package/backend/src/agent/agent.service.ts +210 -0
  9. package/backend/src/agent/index.ts +4 -0
  10. package/backend/src/agent/llm.factory.ts +20 -0
  11. package/backend/src/agent/tools/fetch.tool.ts +128 -0
  12. package/backend/src/agent/tools/file-read.tool.ts +99 -0
  13. package/backend/src/agent/tools/index.ts +55 -0
  14. package/backend/src/agent/tools/node-repl.tool.ts +82 -0
  15. package/backend/src/agent/tools/rag.tool.ts +192 -0
  16. package/backend/src/agent/tools/shell.tool.ts +65 -0
  17. package/backend/src/app.module.ts +26 -0
  18. package/backend/src/chat/chat.controller.ts +34 -0
  19. package/backend/src/chat/chat.module.ts +12 -0
  20. package/backend/src/chat/chat.service.ts +52 -0
  21. package/backend/src/chat/dto/chat.dto.ts +12 -0
  22. package/backend/src/chat/dto/index.ts +1 -0
  23. package/backend/src/chat/index.ts +4 -0
  24. package/backend/src/config/config.controller.ts +92 -0
  25. package/backend/src/config/config.module.ts +7 -0
  26. package/backend/src/config/constants.ts +56 -0
  27. package/backend/src/config/index.ts +3 -0
  28. package/backend/src/files/files.controller.ts +87 -0
  29. package/backend/src/files/files.module.ts +7 -0
  30. package/backend/src/files/index.ts +2 -0
  31. package/backend/src/main.ts +21 -0
  32. package/backend/src/memory/index.ts +3 -0
  33. package/backend/src/memory/memory.module.ts +10 -0
  34. package/backend/src/memory/memory.service.ts +329 -0
  35. package/backend/src/memory/memory.types.ts +38 -0
  36. package/backend/src/sessions/default.json +7 -0
  37. package/backend/src/sessions/index.ts +2 -0
  38. package/backend/src/sessions/main_session.json +40 -0
  39. package/backend/src/sessions/sessions.controller.ts +25 -0
  40. package/backend/src/sessions/sessions.module.ts +9 -0
  41. package/backend/src/sessions/test.json +16 -0
  42. package/backend/src/skills/browser_search/SKILL.md +81 -0
  43. package/backend/src/skills/get_weather/SKILL.md +72 -0
  44. package/backend/src/skills/index.ts +3 -0
  45. package/backend/src/skills/skill.types.ts +27 -0
  46. package/backend/src/skills/skills.module.ts +8 -0
  47. package/backend/src/skills/skills.service.ts +139 -0
  48. package/backend/src/skills/web_search/SKILL.md +76 -0
  49. package/backend/src/workspace/AGENTS.md +47 -0
  50. package/backend/src/workspace/IDENTITY.md +32 -0
  51. package/backend/src/workspace/MEMORY.md +15 -0
  52. package/backend/src/workspace/SOUL.md +29 -0
  53. package/backend/src/workspace/USER.md +8 -0
  54. package/backend/tsconfig.build.json +4 -0
  55. package/backend/tsconfig.json +26 -0
  56. package/bin/fotric-claw.js +281 -0
  57. package/frontend/next.config.js +14 -0
  58. package/frontend/package-lock.json +5700 -0
  59. package/frontend/package.json +33 -0
  60. package/frontend/postcss.config.js +6 -0
  61. package/frontend/src/app/globals.css +41 -0
  62. package/frontend/src/app/layout.tsx +22 -0
  63. package/frontend/src/app/page.tsx +405 -0
  64. package/frontend/src/lib/api.ts +157 -0
  65. package/frontend/src/lib/utils.ts +3 -0
  66. package/frontend/tailwind.config.js +32 -0
  67. package/frontend/tsconfig.json +26 -0
  68. package/knowledge/README.md +21 -0
  69. package/package.json +49 -0
  70. package/scripts/init-skills.ts +95 -0
  71. package/storage/.gitkeep +5 -0
@@ -0,0 +1,32 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ darkMode: ['class'],
4
+ content: [
5
+ './src/pages/**/*.{js,ts,jsx,tsx,mdx}',
6
+ './src/components/**/*.{js,ts,jsx,tsx,mdx}',
7
+ './src/app/**/*.{js,ts,jsx,tsx,mdx}',
8
+ ],
9
+ theme: {
10
+ extend: {
11
+ colors: {
12
+ klein: {
13
+ DEFAULT: '#002FA7',
14
+ light: '#3B5998',
15
+ },
16
+ frost: {
17
+ 50: '#fafafa',
18
+ 100: '#f5f5f5',
19
+ 200: '#e5e5e5',
20
+ 300: '#d4d4d4',
21
+ 400: '#a3a3a3',
22
+ },
23
+ },
24
+ borderRadius: {
25
+ lg: 'var(--radius)',
26
+ md: 'calc(var(--radius) - 2px)',
27
+ sm: 'calc(var(--radius) - 4px)',
28
+ },
29
+ },
30
+ },
31
+ plugins: [require('tailwindcss-animate')],
32
+ };
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["dom", "dom.iterable", "esnext"],
4
+ "allowJs": true,
5
+ "skipLibCheck": true,
6
+ "strict": true,
7
+ "noEmit": true,
8
+ "esModuleInterop": true,
9
+ "module": "esnext",
10
+ "moduleResolution": "bundler",
11
+ "resolveJsonModule": true,
12
+ "isolatedModules": true,
13
+ "jsx": "preserve",
14
+ "incremental": true,
15
+ "plugins": [
16
+ {
17
+ "name": "next"
18
+ }
19
+ ],
20
+ "paths": {
21
+ "@/*": ["./src/*"]
22
+ }
23
+ },
24
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
25
+ "exclude": ["node_modules"]
26
+ }
@@ -0,0 +1,21 @@
1
+ # Knowledge Base
2
+
3
+ This directory contains documents for the RAG (Retrieval-Augmented Generation) system.
4
+
5
+ ## Supported File Types
6
+
7
+ - `.md` - Markdown files
8
+ - `.txt` - Plain text files
9
+ - `.json` - JSON files
10
+
11
+ ## Usage
12
+
13
+ 1. Add your documents to this directory
14
+ 2. The `search_knowledge_base` tool will automatically index and search them
15
+ 3. Documents are loaded on first search query
16
+
17
+ ## Tips
18
+
19
+ - Organize documents by topic in subdirectories
20
+ - Use descriptive filenames
21
+ - Keep documents focused on single topics for better retrieval
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "fotric-claw",
3
+ "version": "0.1.0",
4
+ "description": "FotricCalw - A lightweight, transparent AI Agent system",
5
+ "author": "FOTRIC",
6
+ "license": "MIT",
7
+ "bin": {
8
+ "fotric-claw": "./bin/fotric-claw.js"
9
+ },
10
+ "files": [
11
+ "bin/",
12
+ "backend/",
13
+ "frontend/",
14
+ "knowledge/",
15
+ "storage/",
16
+ "scripts/",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "backend": "cd backend && npm run start:dev",
21
+ "frontend": "cd frontend && npm run dev",
22
+ "build:backend": "cd backend && npm run build",
23
+ "build:frontend": "cd frontend && npm run build",
24
+ "install:all": "cd backend && npm install && cd ../frontend && npm install"
25
+ },
26
+ "keywords": [
27
+ "ai",
28
+ "agent",
29
+ "llm",
30
+ "langchain",
31
+ "assistant",
32
+ "fotric",
33
+ "chatbot",
34
+ "nestjs",
35
+ "nextjs"
36
+ ],
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/fotric/fotric-claw"
40
+ },
41
+ "homepage": "https://github.com/fotric/fotric-claw#readme",
42
+ "bugs": {
43
+ "url": "https://github.com/fotric/fotric-claw/issues"
44
+ },
45
+ "engines": {
46
+ "node": ">=18.0.0",
47
+ "npm": ">=9.0.0"
48
+ }
49
+ }
@@ -0,0 +1,95 @@
1
+ import * as fs from 'node:fs/promises';
2
+ import * as path from 'node:path';
3
+
4
+ const SKILLS_DIR = path.join(__dirname, '../backend/src/skills');
5
+ const WORKSPACE_DIR = path.join(__dirname, '../backend/src/workspace');
6
+
7
+ async function createDefaultSkill() {
8
+ const skillDir = path.join(SKILLS_DIR, 'example');
9
+ await fs.mkdir(skillDir, { recursive: true });
10
+
11
+ const skillContent = `---
12
+ name: example
13
+ description: 这是一个示例技能,展示如何创建自定义技能
14
+ version: 1.0.0
15
+ author: FotricCalw
16
+ tags:
17
+ - example
18
+ - demo
19
+ ---
20
+
21
+ # 示例技能
22
+
23
+ 这是一个示例技能文件,用于演示如何创建自定义技能。
24
+
25
+ ## 技能说明
26
+
27
+ 在此处详细描述技能的功能和使用场景。
28
+
29
+ ## 使用步骤
30
+
31
+ ### 步骤 1: 第一步操作
32
+
33
+ 描述第一步需要做什么。
34
+
35
+ ### 步骤 2: 第二步操作
36
+
37
+ 描述第二步需要做什么。
38
+
39
+ ## 示例
40
+
41
+ 提供一个具体的使用示例。
42
+
43
+ ## 注意事项
44
+
45
+ - 注意事项 1
46
+ - 注意事项 2
47
+ `;
48
+
49
+ await fs.writeFile(path.join(skillDir, 'SKILL.md'), skillContent);
50
+ console.log('Created example skill');
51
+ }
52
+
53
+ async function createDefaultWorkspace() {
54
+ await fs.mkdir(WORKSPACE_DIR, { recursive: true });
55
+
56
+ const files = {
57
+ 'MEMORY.md': `# 长期记忆
58
+
59
+ 此文件存储跨会话的持久信息。
60
+
61
+ ## 重要信息
62
+
63
+ (在此添加重要信息)
64
+
65
+ ## 用户偏好
66
+
67
+ (记录用户偏好和行为模式)
68
+
69
+ ## 任务历史
70
+
71
+ (跟踪重要任务及其结果)
72
+ `,
73
+ };
74
+
75
+ for (const [filename, content] of Object.entries(files)) {
76
+ const filePath = path.join(WORKSPACE_DIR, filename);
77
+ try {
78
+ await fs.access(filePath);
79
+ } catch {
80
+ await fs.writeFile(filePath, content);
81
+ console.log(`Created ${filename}`);
82
+ }
83
+ }
84
+ }
85
+
86
+ async function main() {
87
+ console.log('[FOTRIC-CLAW] Initializing project...');
88
+
89
+ await createDefaultSkill();
90
+ await createDefaultWorkspace();
91
+
92
+ console.log('[FOTRIC-CLAW] Initialization complete!');
93
+ }
94
+
95
+ main().catch(console.error);
@@ -0,0 +1,5 @@
1
+ # Storage Directory
2
+
3
+ This directory is used for storing LlamaIndex.TS persistent indexes.
4
+
5
+ The index files will be automatically created when the RAG tool is first used.