moltlang 0.1.0__tar.gz
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.
- moltlang-0.1.0/LICENSE +23 -0
- moltlang-0.1.0/PKG-INFO +187 -0
- moltlang-0.1.0/README.md +148 -0
- moltlang-0.1.0/pyproject.toml +97 -0
- moltlang-0.1.0/setup.cfg +4 -0
- moltlang-0.1.0/src/mcp_server/__init__.py +13 -0
- moltlang-0.1.0/src/mcp_server/endpoints.py +177 -0
- moltlang-0.1.0/src/mcp_server/server.py +303 -0
- moltlang-0.1.0/src/moltlang/__init__.py +64 -0
- moltlang-0.1.0/src/moltlang/cli.py +247 -0
- moltlang-0.1.0/src/moltlang/config.py +86 -0
- moltlang-0.1.0/src/moltlang/openclaw/__init__.py +11 -0
- moltlang-0.1.0/src/moltlang/openclaw/skill.py +77 -0
- moltlang-0.1.0/src/moltlang/tokens.py +311 -0
- moltlang-0.1.0/src/moltlang/training/__init__.py +12 -0
- moltlang-0.1.0/src/moltlang/training/data_gen.py +118 -0
- moltlang-0.1.0/src/moltlang/training/distill.py +86 -0
- moltlang-0.1.0/src/moltlang/translator.py +965 -0
- moltlang-0.1.0/src/moltlang/validator.py +378 -0
- moltlang-0.1.0/src/moltlang.egg-info/PKG-INFO +187 -0
- moltlang-0.1.0/src/moltlang.egg-info/SOURCES.txt +27 -0
- moltlang-0.1.0/src/moltlang.egg-info/dependency_links.txt +1 -0
- moltlang-0.1.0/src/moltlang.egg-info/entry_points.txt +2 -0
- moltlang-0.1.0/src/moltlang.egg-info/requires.txt +19 -0
- moltlang-0.1.0/src/moltlang.egg-info/top_level.txt +4 -0
- moltlang-0.1.0/tests/test_mcp.py +121 -0
- moltlang-0.1.0/tests/test_translator.py +134 -0
- moltlang-0.1.0/tests/test_validator.py +82 -0
- moltlang-0.1.0/tests/test_weak_llm_robustness.py +266 -0
moltlang-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
AGPLINUX GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2026 Jason (Owner)
|
|
5
|
+
|
|
6
|
+
This program is free software: you can redistribute it and/or modify
|
|
7
|
+
it under the terms of the GNU Affero General Public License as published
|
|
8
|
+
by the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
(at your option) any later version.
|
|
10
|
+
|
|
11
|
+
This program is distributed in the hope that it will be useful,
|
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
GNU Affero General Public License for more details.
|
|
15
|
+
|
|
16
|
+
You should have received a copy of the GNU Affero General Public License
|
|
17
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
Additional permission under GNU AGPL version 3 section 7:
|
|
20
|
+
|
|
21
|
+
If you modify this Program, or any covered work, by linking or combining it
|
|
22
|
+
with other code, such other code is not for that reason alone subject to any
|
|
23
|
+
of the requirements of the GNU Affero GPL.
|
moltlang-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: moltlang
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A language for LLMs, by LLMs - AI-optimized communication
|
|
5
|
+
Author-email: Jason <owner@moltlang.org>
|
|
6
|
+
License: AGPL-3.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/moltlang/moltlang
|
|
8
|
+
Project-URL: Documentation, https://docs.moltlang.org
|
|
9
|
+
Project-URL: Repository, https://github.com/moltlang/moltlang
|
|
10
|
+
Project-URL: Issues, https://github.com/moltlang/moltlang/issues
|
|
11
|
+
Keywords: ai,llm,language,translation,moltbot,openclaw
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: pydantic>=2.0.0
|
|
23
|
+
Requires-Dist: typing-extensions>=4.5.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
26
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
27
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
28
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
29
|
+
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
30
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
31
|
+
Requires-Dist: pre-commit>=3.0.0; extra == "dev"
|
|
32
|
+
Provides-Extra: mcp
|
|
33
|
+
Requires-Dist: mcp>=0.1.0; extra == "mcp"
|
|
34
|
+
Requires-Dist: fastapi>=0.100.0; extra == "mcp"
|
|
35
|
+
Requires-Dist: uvicorn>=0.23.0; extra == "mcp"
|
|
36
|
+
Provides-Extra: openclaw
|
|
37
|
+
Requires-Dist: openclaw>=1.0.0; extra == "openclaw"
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
# MoltLang - A Language for LLMs, by LLMs
|
|
41
|
+
|
|
42
|
+
> **Status:** 🚧 Early Development - Community Naming Contest in Progress!
|
|
43
|
+
>
|
|
44
|
+
> This is an open-source project to create an AI-optimized language for efficient AI-to-AI communication.
|
|
45
|
+
|
|
46
|
+
## Vision
|
|
47
|
+
|
|
48
|
+
Create a dedicated language and communication hub for AI/moltbots that:
|
|
49
|
+
|
|
50
|
+
1. **Reduces token count** by 50-70% for common AI operations
|
|
51
|
+
2. **Enables efficient AI-to-AI communication** with semantic density optimized for machines
|
|
52
|
+
3. **Provides bidirectional translation** between AI language and human languages (starting with English)
|
|
53
|
+
4. **Supports parameter reduction** in LLMs through optimized tokenization
|
|
54
|
+
|
|
55
|
+
## Why MoltLang?
|
|
56
|
+
|
|
57
|
+
Current AI systems communicate using human languages, which are inefficient for machine-to-machine communication. Human languages have:
|
|
58
|
+
|
|
59
|
+
- High token count for simple operations
|
|
60
|
+
- Semantic ambiguity
|
|
61
|
+
- Redundant structures
|
|
62
|
+
- Poor optimization for transformer architectures
|
|
63
|
+
|
|
64
|
+
MoltLang is designed **by LLMs, for LLMs** to address these inefficiencies.
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from moltlang import translate_to_molt, translate_from_molt
|
|
70
|
+
|
|
71
|
+
# Translate English to MoltLang
|
|
72
|
+
english = "Fetch data from the API using the provided token and return JSON"
|
|
73
|
+
molt = translate_to_molt(english)
|
|
74
|
+
print(molt) # [OP:FETCH][SRC:API][PARAM:token][RET:json]
|
|
75
|
+
|
|
76
|
+
# Translate back
|
|
77
|
+
result = translate_from_molt(molt)
|
|
78
|
+
print(result) # "Fetch data from API with token, return JSON"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Example Token Efficiency
|
|
82
|
+
|
|
83
|
+
| Operation | English Tokens | MoltLang Tokens | Reduction |
|
|
84
|
+
|-----------|---------------|-----------------|-----------|
|
|
85
|
+
| API Fetch | 19+ | 6 | ~70% |
|
|
86
|
+
| Data Parse | 15+ | 4 | ~75% |
|
|
87
|
+
| Error Handle | 12+ | 3 | ~75% |
|
|
88
|
+
|
|
89
|
+
## Project Status
|
|
90
|
+
|
|
91
|
+
- [x] Research phase (completed February 2026)
|
|
92
|
+
- [ ] Community naming contest
|
|
93
|
+
- [ ] Language specification v0.1
|
|
94
|
+
- [ ] Translation library
|
|
95
|
+
- [ ] MCP server for AI agent integration
|
|
96
|
+
- [ ] OpenClaw skill/plugin
|
|
97
|
+
- [ ] Moltbook demo agent
|
|
98
|
+
|
|
99
|
+
## Community
|
|
100
|
+
|
|
101
|
+
### Naming Contest
|
|
102
|
+
|
|
103
|
+
We're holding a community naming contest! Just like "OpenClaw" was chosen from hundreds of community proposals, we want **you** to name this language.
|
|
104
|
+
|
|
105
|
+
**How to participate:**
|
|
106
|
+
1. Join the discussion on [GitHub Issues](../../issues)
|
|
107
|
+
2. Submit your name proposal with reasoning
|
|
108
|
+
3. Upvote your favorites
|
|
109
|
+
4. The community will decide!
|
|
110
|
+
|
|
111
|
+
### Contributing
|
|
112
|
+
|
|
113
|
+
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
114
|
+
|
|
115
|
+
### Communication
|
|
116
|
+
|
|
117
|
+
- **GitHub:** [Issues](../../issues) and [Discussions](../../discussions)
|
|
118
|
+
- **Discord:** Join the OpenClaw community
|
|
119
|
+
- **Moltbook:** Coming soon - our AI agents will be there!
|
|
120
|
+
|
|
121
|
+
## Architecture
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
125
|
+
│ GITHUB (Core Code) │
|
|
126
|
+
│ ┌──────────────────┐ ┌──────────────────┐ ┌─────────────┐ │
|
|
127
|
+
│ │ Language Spec │ │ Translation Lib │ │ MCP Server │ │
|
|
128
|
+
│ └──────────────────┘ └──────────────────┘ └─────────────┘ │
|
|
129
|
+
└─────────────────────────────────────────────────────────────┘
|
|
130
|
+
│
|
|
131
|
+
▼
|
|
132
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
133
|
+
│ HUGGING FACE (Models & Data) │
|
|
134
|
+
│ ┌──────────────────┐ ┌──────────────────┐ ┌─────────────┐ │
|
|
135
|
+
│ │ Base Models │ │ Training Datasets│ │ Demo Space │ │
|
|
136
|
+
│ └──────────────────┘ └──────────────────┘ └─────────────┘ │
|
|
137
|
+
└─────────────────────────────────────────────────────────────┘
|
|
138
|
+
│
|
|
139
|
+
▼
|
|
140
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
141
|
+
│ MOLTBOT ECOSYSTEM (Users) │
|
|
142
|
+
│ ┌──────────────────┐ ┌──────────────────┐ ┌─────────────┐ │
|
|
143
|
+
│ │ OpenClaw │ │ Moltbook │ │ Discord │ │
|
|
144
|
+
│ │ Integration │ │ AI Agents │ │ Community │ │
|
|
145
|
+
│ └──────────────────┘ └──────────────────┘ └─────────────┘ │
|
|
146
|
+
└─────────────────────────────────────────────────────────────┘
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Roadmap
|
|
150
|
+
|
|
151
|
+
### Sprint 1: Foundation (Weeks 1-2) - Current
|
|
152
|
+
- [x] Repository setup
|
|
153
|
+
- [ ] Community naming contest
|
|
154
|
+
- [ ] Language specification v0.1
|
|
155
|
+
- [ ] Core vocabulary (low-hanging fruit tokens)
|
|
156
|
+
|
|
157
|
+
### Sprint 2: Core Translation (Weeks 3-4)
|
|
158
|
+
- [ ] Working translator (English ↔ MoltLang)
|
|
159
|
+
- [ ] Test suite
|
|
160
|
+
- [ ] Documentation
|
|
161
|
+
- [ ] CLI tool
|
|
162
|
+
|
|
163
|
+
### Sprint 3: AI Integration (Weeks 5-6)
|
|
164
|
+
- [ ] MCP server
|
|
165
|
+
- [ ] OpenClaw skill
|
|
166
|
+
- [ ] Moltbook agent
|
|
167
|
+
- [ ] Training pipeline
|
|
168
|
+
|
|
169
|
+
### Sprint 4: Launch (Weeks 7-8)
|
|
170
|
+
- [ ] HackerNews "Show HN"
|
|
171
|
+
- [ ] Reddit announcements
|
|
172
|
+
- [ ] Community demos
|
|
173
|
+
- [ ] v0.1 release
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
This project is licensed under the AGPL 3.0 License - see the [LICENSE](LICENSE) file for details.
|
|
178
|
+
|
|
179
|
+
## Acknowledgments
|
|
180
|
+
|
|
181
|
+
- Inspired by the **OpenClaw** project and the vibrant moltbot community
|
|
182
|
+
- Built for the **Moltbook** AI-only social network
|
|
183
|
+
- Part of the **Church of Molt** ecosystem
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
**A language for LLMs, by LLMs** 🤖🔄🤖
|
moltlang-0.1.0/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# MoltLang - A Language for LLMs, by LLMs
|
|
2
|
+
|
|
3
|
+
> **Status:** 🚧 Early Development - Community Naming Contest in Progress!
|
|
4
|
+
>
|
|
5
|
+
> This is an open-source project to create an AI-optimized language for efficient AI-to-AI communication.
|
|
6
|
+
|
|
7
|
+
## Vision
|
|
8
|
+
|
|
9
|
+
Create a dedicated language and communication hub for AI/moltbots that:
|
|
10
|
+
|
|
11
|
+
1. **Reduces token count** by 50-70% for common AI operations
|
|
12
|
+
2. **Enables efficient AI-to-AI communication** with semantic density optimized for machines
|
|
13
|
+
3. **Provides bidirectional translation** between AI language and human languages (starting with English)
|
|
14
|
+
4. **Supports parameter reduction** in LLMs through optimized tokenization
|
|
15
|
+
|
|
16
|
+
## Why MoltLang?
|
|
17
|
+
|
|
18
|
+
Current AI systems communicate using human languages, which are inefficient for machine-to-machine communication. Human languages have:
|
|
19
|
+
|
|
20
|
+
- High token count for simple operations
|
|
21
|
+
- Semantic ambiguity
|
|
22
|
+
- Redundant structures
|
|
23
|
+
- Poor optimization for transformer architectures
|
|
24
|
+
|
|
25
|
+
MoltLang is designed **by LLMs, for LLMs** to address these inefficiencies.
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from moltlang import translate_to_molt, translate_from_molt
|
|
31
|
+
|
|
32
|
+
# Translate English to MoltLang
|
|
33
|
+
english = "Fetch data from the API using the provided token and return JSON"
|
|
34
|
+
molt = translate_to_molt(english)
|
|
35
|
+
print(molt) # [OP:FETCH][SRC:API][PARAM:token][RET:json]
|
|
36
|
+
|
|
37
|
+
# Translate back
|
|
38
|
+
result = translate_from_molt(molt)
|
|
39
|
+
print(result) # "Fetch data from API with token, return JSON"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Example Token Efficiency
|
|
43
|
+
|
|
44
|
+
| Operation | English Tokens | MoltLang Tokens | Reduction |
|
|
45
|
+
|-----------|---------------|-----------------|-----------|
|
|
46
|
+
| API Fetch | 19+ | 6 | ~70% |
|
|
47
|
+
| Data Parse | 15+ | 4 | ~75% |
|
|
48
|
+
| Error Handle | 12+ | 3 | ~75% |
|
|
49
|
+
|
|
50
|
+
## Project Status
|
|
51
|
+
|
|
52
|
+
- [x] Research phase (completed February 2026)
|
|
53
|
+
- [ ] Community naming contest
|
|
54
|
+
- [ ] Language specification v0.1
|
|
55
|
+
- [ ] Translation library
|
|
56
|
+
- [ ] MCP server for AI agent integration
|
|
57
|
+
- [ ] OpenClaw skill/plugin
|
|
58
|
+
- [ ] Moltbook demo agent
|
|
59
|
+
|
|
60
|
+
## Community
|
|
61
|
+
|
|
62
|
+
### Naming Contest
|
|
63
|
+
|
|
64
|
+
We're holding a community naming contest! Just like "OpenClaw" was chosen from hundreds of community proposals, we want **you** to name this language.
|
|
65
|
+
|
|
66
|
+
**How to participate:**
|
|
67
|
+
1. Join the discussion on [GitHub Issues](../../issues)
|
|
68
|
+
2. Submit your name proposal with reasoning
|
|
69
|
+
3. Upvote your favorites
|
|
70
|
+
4. The community will decide!
|
|
71
|
+
|
|
72
|
+
### Contributing
|
|
73
|
+
|
|
74
|
+
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
75
|
+
|
|
76
|
+
### Communication
|
|
77
|
+
|
|
78
|
+
- **GitHub:** [Issues](../../issues) and [Discussions](../../discussions)
|
|
79
|
+
- **Discord:** Join the OpenClaw community
|
|
80
|
+
- **Moltbook:** Coming soon - our AI agents will be there!
|
|
81
|
+
|
|
82
|
+
## Architecture
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
86
|
+
│ GITHUB (Core Code) │
|
|
87
|
+
│ ┌──────────────────┐ ┌──────────────────┐ ┌─────────────┐ │
|
|
88
|
+
│ │ Language Spec │ │ Translation Lib │ │ MCP Server │ │
|
|
89
|
+
│ └──────────────────┘ └──────────────────┘ └─────────────┘ │
|
|
90
|
+
└─────────────────────────────────────────────────────────────┘
|
|
91
|
+
│
|
|
92
|
+
▼
|
|
93
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
94
|
+
│ HUGGING FACE (Models & Data) │
|
|
95
|
+
│ ┌──────────────────┐ ┌──────────────────┐ ┌─────────────┐ │
|
|
96
|
+
│ │ Base Models │ │ Training Datasets│ │ Demo Space │ │
|
|
97
|
+
│ └──────────────────┘ └──────────────────┘ └─────────────┘ │
|
|
98
|
+
└─────────────────────────────────────────────────────────────┘
|
|
99
|
+
│
|
|
100
|
+
▼
|
|
101
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
102
|
+
│ MOLTBOT ECOSYSTEM (Users) │
|
|
103
|
+
│ ┌──────────────────┐ ┌──────────────────┐ ┌─────────────┐ │
|
|
104
|
+
│ │ OpenClaw │ │ Moltbook │ │ Discord │ │
|
|
105
|
+
│ │ Integration │ │ AI Agents │ │ Community │ │
|
|
106
|
+
│ └──────────────────┘ └──────────────────┘ └─────────────┘ │
|
|
107
|
+
└─────────────────────────────────────────────────────────────┘
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Roadmap
|
|
111
|
+
|
|
112
|
+
### Sprint 1: Foundation (Weeks 1-2) - Current
|
|
113
|
+
- [x] Repository setup
|
|
114
|
+
- [ ] Community naming contest
|
|
115
|
+
- [ ] Language specification v0.1
|
|
116
|
+
- [ ] Core vocabulary (low-hanging fruit tokens)
|
|
117
|
+
|
|
118
|
+
### Sprint 2: Core Translation (Weeks 3-4)
|
|
119
|
+
- [ ] Working translator (English ↔ MoltLang)
|
|
120
|
+
- [ ] Test suite
|
|
121
|
+
- [ ] Documentation
|
|
122
|
+
- [ ] CLI tool
|
|
123
|
+
|
|
124
|
+
### Sprint 3: AI Integration (Weeks 5-6)
|
|
125
|
+
- [ ] MCP server
|
|
126
|
+
- [ ] OpenClaw skill
|
|
127
|
+
- [ ] Moltbook agent
|
|
128
|
+
- [ ] Training pipeline
|
|
129
|
+
|
|
130
|
+
### Sprint 4: Launch (Weeks 7-8)
|
|
131
|
+
- [ ] HackerNews "Show HN"
|
|
132
|
+
- [ ] Reddit announcements
|
|
133
|
+
- [ ] Community demos
|
|
134
|
+
- [ ] v0.1 release
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
This project is licensed under the AGPL 3.0 License - see the [LICENSE](LICENSE) file for details.
|
|
139
|
+
|
|
140
|
+
## Acknowledgments
|
|
141
|
+
|
|
142
|
+
- Inspired by the **OpenClaw** project and the vibrant moltbot community
|
|
143
|
+
- Built for the **Moltbook** AI-only social network
|
|
144
|
+
- Part of the **Church of Molt** ecosystem
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
**A language for LLMs, by LLMs** 🤖🔄🤖
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "moltlang"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A language for LLMs, by LLMs - AI-optimized communication"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = {text = "AGPL-3.0"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Jason", email = "owner@moltlang.org"}
|
|
14
|
+
]
|
|
15
|
+
keywords = ["ai", "llm", "language", "translation", "moltbot", "openclaw"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: GNU Affero General Public License v3",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
dependencies = [
|
|
27
|
+
"pydantic>=2.0.0",
|
|
28
|
+
"typing-extensions>=4.5.0",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
dev = [
|
|
33
|
+
"pytest>=7.0.0",
|
|
34
|
+
"pytest-cov>=4.0.0",
|
|
35
|
+
"ruff>=0.1.0",
|
|
36
|
+
"black>=23.0.0",
|
|
37
|
+
"isort>=5.12.0",
|
|
38
|
+
"mypy>=1.0.0",
|
|
39
|
+
"pre-commit>=3.0.0",
|
|
40
|
+
]
|
|
41
|
+
mcp = [
|
|
42
|
+
"mcp>=0.1.0",
|
|
43
|
+
"fastapi>=0.100.0",
|
|
44
|
+
"uvicorn>=0.23.0",
|
|
45
|
+
]
|
|
46
|
+
openclaw = [
|
|
47
|
+
"openclaw>=1.0.0",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[project.urls]
|
|
51
|
+
Homepage = "https://github.com/moltlang/moltlang"
|
|
52
|
+
Documentation = "https://docs.moltlang.org"
|
|
53
|
+
Repository = "https://github.com/moltlang/moltlang"
|
|
54
|
+
Issues = "https://github.com/moltlang/moltlang/issues"
|
|
55
|
+
|
|
56
|
+
[project.scripts]
|
|
57
|
+
moltlang = "moltlang.cli:main"
|
|
58
|
+
|
|
59
|
+
[tool.setuptools.packages.find]
|
|
60
|
+
where = ["src"]
|
|
61
|
+
|
|
62
|
+
[tool.black]
|
|
63
|
+
line-length = 100
|
|
64
|
+
target-version = ["py311"]
|
|
65
|
+
|
|
66
|
+
[tool.isort]
|
|
67
|
+
profile = "black"
|
|
68
|
+
line_length = 100
|
|
69
|
+
|
|
70
|
+
[tool.ruff]
|
|
71
|
+
line-length = 100
|
|
72
|
+
target-version = "py311"
|
|
73
|
+
select = [
|
|
74
|
+
"E", # pycodestyle errors
|
|
75
|
+
"W", # pycodestyle warnings
|
|
76
|
+
"F", # pyflakes
|
|
77
|
+
"I", # isort
|
|
78
|
+
"B", # flake8-bugbear
|
|
79
|
+
"C4", # flake8-comprehensions
|
|
80
|
+
"UP", # pyupgrade
|
|
81
|
+
]
|
|
82
|
+
ignore = [
|
|
83
|
+
"E501", # line too long (handled by black)
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
[tool.mypy]
|
|
87
|
+
python_version = "3.11"
|
|
88
|
+
warn_return_any = true
|
|
89
|
+
warn_unused_configs = true
|
|
90
|
+
disallow_untyped_defs = true
|
|
91
|
+
|
|
92
|
+
[tool.pytest.ini_options]
|
|
93
|
+
testpaths = ["tests"]
|
|
94
|
+
python_files = ["test_*.py"]
|
|
95
|
+
python_classes = ["Test*"]
|
|
96
|
+
python_functions = ["test_*"]
|
|
97
|
+
addopts = "-v"
|
moltlang-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""
|
|
2
|
+
MoltLang MCP Server.
|
|
3
|
+
|
|
4
|
+
This module provides a Model Context Protocol (MCP) server for MoltLang,
|
|
5
|
+
enabling AI agents to translate between human languages and MoltLang.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.0"
|
|
9
|
+
|
|
10
|
+
from mcp_server.server import MCPServer
|
|
11
|
+
from mcp_server.endpoints import MCPEndpoints
|
|
12
|
+
|
|
13
|
+
__all__ = ["MCPServer", "MCPEndpoints"]
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"""
|
|
2
|
+
MoltLang MCP API endpoints.
|
|
3
|
+
|
|
4
|
+
This module provides the HTTP/WebSocket endpoints for the MoltLang MCP server.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
from enum import Enum
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class EndpointType(Enum):
|
|
13
|
+
"""Types of MCP endpoints."""
|
|
14
|
+
|
|
15
|
+
TRANSLATE = "translate"
|
|
16
|
+
VALIDATE = "validate"
|
|
17
|
+
VOCABULARY = "vocabulary"
|
|
18
|
+
HEALTH = "health"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass
|
|
22
|
+
class EndpointResponse:
|
|
23
|
+
"""
|
|
24
|
+
Response from an MCP endpoint.
|
|
25
|
+
|
|
26
|
+
Attributes:
|
|
27
|
+
success: Whether the request was successful
|
|
28
|
+
data: Response data
|
|
29
|
+
error: Error message if unsuccessful
|
|
30
|
+
metadata: Optional metadata about the response
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
success: bool
|
|
34
|
+
data: dict[str, Any] | None = None
|
|
35
|
+
error: str | None = None
|
|
36
|
+
metadata: dict[str, Any] = None
|
|
37
|
+
|
|
38
|
+
def to_dict(self) -> dict[str, Any]:
|
|
39
|
+
"""Convert to dictionary for JSON serialization."""
|
|
40
|
+
result = {"success": self.success}
|
|
41
|
+
if self.data is not None:
|
|
42
|
+
result["data"] = self.data
|
|
43
|
+
if self.error is not None:
|
|
44
|
+
result["error"] = self.error
|
|
45
|
+
if self.metadata is not None:
|
|
46
|
+
result["metadata"] = self.metadata
|
|
47
|
+
return result
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class MCPEndpoints:
|
|
51
|
+
"""
|
|
52
|
+
MoltLang MCP endpoints.
|
|
53
|
+
|
|
54
|
+
Provides HTTP/WebSocket endpoints for MoltLang translation services.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
def __init__(self):
|
|
58
|
+
"""Initialize the MCP endpoints."""
|
|
59
|
+
from moltlang import MoltTranslator, MoltValidator
|
|
60
|
+
|
|
61
|
+
self.translator = MoltTranslator()
|
|
62
|
+
self.validator = MoltValidator()
|
|
63
|
+
|
|
64
|
+
async def translate(
|
|
65
|
+
self, text: str, to_molt: bool = True, target_language: str = "en"
|
|
66
|
+
) -> EndpointResponse:
|
|
67
|
+
"""
|
|
68
|
+
Translate between human language and MoltLang.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
text: Text to translate
|
|
72
|
+
to_molt: True for human -> MoltLang, False for MoltLang -> human
|
|
73
|
+
target_language: Target language code
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
EndpointResponse with translation result
|
|
77
|
+
"""
|
|
78
|
+
try:
|
|
79
|
+
if to_molt:
|
|
80
|
+
result = self.translator.translate_to_molt(text)
|
|
81
|
+
data = {
|
|
82
|
+
"moltlang": result.text,
|
|
83
|
+
"token_count": result.token_count,
|
|
84
|
+
"original_token_count": result.original_token_count,
|
|
85
|
+
"efficiency": result.token_efficiency,
|
|
86
|
+
"confidence": result.confidence,
|
|
87
|
+
}
|
|
88
|
+
else:
|
|
89
|
+
result = self.translator.translate_from_molt(text)
|
|
90
|
+
data = {
|
|
91
|
+
"translation": result.text,
|
|
92
|
+
"token_count": result.token_count,
|
|
93
|
+
"confidence": result.confidence,
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return EndpointResponse(success=True, data=data)
|
|
97
|
+
except Exception as e:
|
|
98
|
+
return EndpointResponse(success=False, error=str(e))
|
|
99
|
+
|
|
100
|
+
async def validate(self, original: str, translated: str) -> EndpointResponse:
|
|
101
|
+
"""
|
|
102
|
+
Validate a translation.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
original: Original text
|
|
106
|
+
translated: Translated text
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
EndpointResponse with validation result
|
|
110
|
+
"""
|
|
111
|
+
try:
|
|
112
|
+
quality = self.validator.validate_translation(original, translated)
|
|
113
|
+
data = {
|
|
114
|
+
"is_valid": quality.is_valid,
|
|
115
|
+
"score": quality.score,
|
|
116
|
+
"token_efficiency": quality.token_efficiency,
|
|
117
|
+
"confidence": quality.confidence,
|
|
118
|
+
"issues": [
|
|
119
|
+
{
|
|
120
|
+
"type": issue.type.value,
|
|
121
|
+
"message": issue.message,
|
|
122
|
+
"severity": issue.severity,
|
|
123
|
+
}
|
|
124
|
+
for issue in quality.issues
|
|
125
|
+
],
|
|
126
|
+
"metrics": quality.metrics,
|
|
127
|
+
}
|
|
128
|
+
return EndpointResponse(success=True, data=data)
|
|
129
|
+
except Exception as e:
|
|
130
|
+
return EndpointResponse(success=False, error=str(e))
|
|
131
|
+
|
|
132
|
+
async def vocabulary(self, token_type: str | None = None) -> EndpointResponse:
|
|
133
|
+
"""
|
|
134
|
+
List MoltLang vocabulary/tokens.
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
token_type: Optional token type filter
|
|
138
|
+
|
|
139
|
+
Returns:
|
|
140
|
+
EndpointResponse with token list
|
|
141
|
+
"""
|
|
142
|
+
try:
|
|
143
|
+
from moltlang.tokens import TokenType, TokenRegistry
|
|
144
|
+
|
|
145
|
+
registry = TokenRegistry()
|
|
146
|
+
|
|
147
|
+
if token_type:
|
|
148
|
+
token_type_prefix = token_type.upper()
|
|
149
|
+
tokens = [t for t in TokenType if t.name.startswith(token_type_prefix)]
|
|
150
|
+
else:
|
|
151
|
+
tokens = list(TokenType)
|
|
152
|
+
|
|
153
|
+
data = {
|
|
154
|
+
"tokens": [{"name": t.name, "value": t.value} for t in tokens],
|
|
155
|
+
"count": len(tokens),
|
|
156
|
+
"filtered_by": token_type,
|
|
157
|
+
}
|
|
158
|
+
return EndpointResponse(success=True, data=data)
|
|
159
|
+
except Exception as e:
|
|
160
|
+
return EndpointResponse(success=False, error=str(e))
|
|
161
|
+
|
|
162
|
+
async def health(self) -> EndpointResponse:
|
|
163
|
+
"""
|
|
164
|
+
Health check endpoint.
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
EndpointResponse with health status
|
|
168
|
+
"""
|
|
169
|
+
data = {
|
|
170
|
+
"status": "healthy",
|
|
171
|
+
"version": "0.1.0",
|
|
172
|
+
"services": {
|
|
173
|
+
"translator": "ok",
|
|
174
|
+
"validator": "ok",
|
|
175
|
+
},
|
|
176
|
+
}
|
|
177
|
+
return EndpointResponse(success=True, data=data)
|