amv-llamacpp 0.0.0-stage → 1.5.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.
- package/LICENSE +190 -0
- package/README.md +82 -2
- package/README.pypi.md +43 -0
- package/bin/cli.js +55 -0
- package/index.js +20 -0
- package/js/esm/crawler.d.ts +23 -0
- package/js/esm/crawler.d.ts.map +1 -0
- package/js/esm/crawler.js +73 -0
- package/js/esm/crawler.js.map +1 -0
- package/js/esm/exceptions.d.ts +18 -0
- package/js/esm/exceptions.d.ts.map +1 -0
- package/js/esm/exceptions.js +52 -0
- package/js/esm/exceptions.js.map +1 -0
- package/js/esm/index.d.ts +10 -0
- package/js/esm/index.d.ts.map +1 -0
- package/js/esm/index.js +22 -0
- package/js/esm/index.js.map +1 -0
- package/js/esm/models.d.ts +31 -0
- package/js/esm/models.d.ts.map +1 -0
- package/js/esm/models.js +139 -0
- package/js/esm/models.js.map +1 -0
- package/js/esm/runtime.d.ts +21 -0
- package/js/esm/runtime.d.ts.map +1 -0
- package/js/esm/runtime.js +46 -0
- package/js/esm/runtime.js.map +1 -0
- package/js/esm/server.d.ts +32 -0
- package/js/esm/server.d.ts.map +1 -0
- package/js/esm/server.js +100 -0
- package/js/esm/server.js.map +1 -0
- package/package.json +92 -4
- package/registry/models.json +89 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to use, reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 uno-km (AMEVA Project)
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,83 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AMV-LlamaCpp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **마이그레이션 안내**: 이 패키지는 `termux-llamacpp`에서 `amv-llamacpp`로 이름이 바뀌었습니다. 기존 `termux-llamacpp` 배포본(PyPI/npm)은 호환을 위해 당분간 유지되나 deprecated 상태이며 더 이상 갱신되지 않습니다. `pip install amv-llamacpp` / `npm install amv-llamacpp`로 전환하십시오.
|
|
4
|
+
>
|
|
5
|
+
> Android **Termux 환경** 또는 **안드로이드 Linux 커널(루팅 없이 Linux 환경이 구동되는 모든 디바이스)** 에서 동작합니다 — Termux 전용이 아닙니다.
|
|
6
|
+
|
|
7
|
+
[](https://pypi.org/project/amv-llamacpp/)
|
|
8
|
+
[](https://pypi.org/project/amv-llamacpp/)
|
|
9
|
+
[](https://www.npmjs.com/package/amv-llamacpp)
|
|
10
|
+
[](https://www.npmjs.com/package/amv-llamacpp)
|
|
11
|
+
[](https://github.com/uno-km/amv-llamacpp)
|
|
12
|
+
|
|
13
|
+
> **디바이스 리소스를 활용한 Android Termux ARM64 전용 GGUF LLM 런타임, 모델 매니저 및 OpenAI 호환 REST/SSE 서버**
|
|
14
|
+
> *Production-Grade GGUF LLM Runtime Utilizing Device Resources, Model Manager & OpenAI Server for Android ARM64*
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Architecture & Overview
|
|
19
|
+
|
|
20
|
+
검증된 Android Bionic ARM64 네이티브 바이너리와 필수 공유 라이브러리, 디바이스 리소스 최적화 연동을 통해 제로 컴파일 로컬 실행과 안정적인 OpenAI 호환 REST/SSE 스트리밍 서버를 제공합니다.
|
|
21
|
+
|
|
22
|
+
Ships verified Android ARM64 native binaries with bundled shared libraries and device resource optimization, enabling instant zero-compilation local inference and a robust OpenAI-compatible REST/SSE server.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Installation & Quickstart
|
|
27
|
+
|
|
28
|
+
### Python (PyPI)
|
|
29
|
+
```bash
|
|
30
|
+
pip install amv-llamacpp
|
|
31
|
+
```
|
|
32
|
+
```python
|
|
33
|
+
from termux_llamacpp import LlamaRuntime, RuntimeConfig
|
|
34
|
+
|
|
35
|
+
# 1. Initialize Runtime with Vulkan GPU Acceleration
|
|
36
|
+
config = RuntimeConfig(
|
|
37
|
+
model_path="models/Llama-3.2-1B-Instruct-Q4_K_M.gguf",
|
|
38
|
+
device="auto",
|
|
39
|
+
threads=4,
|
|
40
|
+
context_size=2048
|
|
41
|
+
)
|
|
42
|
+
runtime = LlamaRuntime(config)
|
|
43
|
+
|
|
44
|
+
# 2. Synchronous or Streaming Text Generation
|
|
45
|
+
output = runtime.generate("한국의 사계절 중 가을의 매력에 대해 설명해줘.", max_tokens=256)
|
|
46
|
+
print(output.text)
|
|
47
|
+
print(f"Speed: {output.metrics.eval_tokens_per_sec:.2f} t/s (Prompt: {output.metrics.prompt_tokens_per_sec:.2f} t/s)")
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Node.js / TypeScript (npm)
|
|
51
|
+
```bash
|
|
52
|
+
npm install amv-llamacpp
|
|
53
|
+
```
|
|
54
|
+
```typescript
|
|
55
|
+
import { LlamaRuntime } from "amv-llamacpp";
|
|
56
|
+
|
|
57
|
+
// 1. Initialize ESM Runtime
|
|
58
|
+
const runtime = new LlamaRuntime({
|
|
59
|
+
modelPath: "models/Llama-3.2-1B-Instruct-Q4_K_M.gguf",
|
|
60
|
+
device: "auto",
|
|
61
|
+
threads: 4
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// 2. Generate Completion
|
|
65
|
+
const result = await runtime.generate({
|
|
66
|
+
prompt: "Explain the architectural philosophy of edge computing.",
|
|
67
|
+
maxTokens: 256
|
|
68
|
+
});
|
|
69
|
+
console.log("Response:", result.text);
|
|
70
|
+
console.log(`Generation Speed: ${result.metrics.evalTokensPerSec} t/s`);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Official Documentation & Benchmarks
|
|
76
|
+
- [Official Architecture & API Reference](https://uno-km.vercel.app/lib/llamacpp/)
|
|
77
|
+
- [Ecosystem Metrics & Registry Stats](https://uno-km.vercel.app/foundation/metrics)
|
|
78
|
+
- [AMEVA Open-Source Foundation Portal](https://uno-km.vercel.app/foundation/index.html)
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
Licensed under the Apache-2.0 License. Copyright (c) 2026 Eunho Kim ([@uno-km](https://github.com/uno-km)).
|
package/README.pypi.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Termux-LlamaCpp (Python)
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/termux-llamacpp/)
|
|
4
|
+
[](https://pypi.org/project/termux-llamacpp/)
|
|
5
|
+
[](https://github.com/uno-km/termux-llamacpp)
|
|
6
|
+
|
|
7
|
+
> Production-Grade GGUF LLM Runtime Utilizing Device Resources, Model Manager & OpenAI Server for Android ARM64
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install termux-llamacpp
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quickstart
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from termux_llamacpp import LlamaRuntime, RuntimeConfig
|
|
19
|
+
|
|
20
|
+
# 1. Initialize Runtime with Vulkan GPU Acceleration
|
|
21
|
+
config = RuntimeConfig(
|
|
22
|
+
model_path="models/Llama-3.2-1B-Instruct-Q4_K_M.gguf",
|
|
23
|
+
device="auto",
|
|
24
|
+
threads=4,
|
|
25
|
+
context_size=2048
|
|
26
|
+
)
|
|
27
|
+
runtime = LlamaRuntime(config)
|
|
28
|
+
|
|
29
|
+
# 2. Synchronous or Streaming Text Generation
|
|
30
|
+
output = runtime.generate("한국의 사계절 중 가을의 매력에 대해 설명해줘.", max_tokens=256)
|
|
31
|
+
print(output.text)
|
|
32
|
+
print(f"Speed: {output.metrics.eval_tokens_per_sec:.2f} t/s (Prompt: {output.metrics.prompt_tokens_per_sec:.2f} t/s)")
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Description
|
|
36
|
+
Ships verified Android ARM64 native binaries with bundled shared libraries and device resource optimization, enabling instant zero-compilation local inference and a robust OpenAI-compatible REST/SSE server.
|
|
37
|
+
|
|
38
|
+
## Documentation
|
|
39
|
+
- [Official Documentation & API Reference](https://uno-km.vercel.app/lib/llamacpp/)
|
|
40
|
+
- [GitHub Repository](https://github.com/uno-km/termux-llamacpp)
|
|
41
|
+
|
|
42
|
+
## License
|
|
43
|
+
Apache-2.0 License. Copyright (c) 2026 Eunho Kim (@uno-km).
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* AMEVA Standard Node.js CLI Runner for termux_llamacpp.
|
|
8
|
+
* Automatically resolves Python 3 environment and dispatches to python -m termux_llamacpp.
|
|
9
|
+
*/
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const { spawn, execSync } = require('child_process');
|
|
12
|
+
|
|
13
|
+
function findPython() {
|
|
14
|
+
if (process.env.PYTHON && fs.existsSync(process.env.PYTHON)) {
|
|
15
|
+
return process.env.PYTHON;
|
|
16
|
+
}
|
|
17
|
+
const termuxBin = '/data/data/com.termux/files/usr/bin/python3';
|
|
18
|
+
if (fs.existsSync(termuxBin)) {
|
|
19
|
+
return termuxBin;
|
|
20
|
+
}
|
|
21
|
+
const termuxBinAlt = '/data/data/com.termux/files/usr/bin/python';
|
|
22
|
+
if (fs.existsSync(termuxBinAlt)) {
|
|
23
|
+
return termuxBinAlt;
|
|
24
|
+
}
|
|
25
|
+
const candidates = ['python3', 'python'];
|
|
26
|
+
for (const cmd of candidates) {
|
|
27
|
+
try {
|
|
28
|
+
const checkCmd = process.platform === 'win32' ? `where ${cmd}` : `command -v ${cmd}`;
|
|
29
|
+
const res = execSync(checkCmd, { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim();
|
|
30
|
+
if (res) return cmd;
|
|
31
|
+
} catch (_) {}
|
|
32
|
+
}
|
|
33
|
+
return 'python3';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const pythonBin = findPython();
|
|
37
|
+
const args = ['-m', 'termux_llamacpp', ...process.argv.slice(2)];
|
|
38
|
+
|
|
39
|
+
const child = spawn(pythonBin, args, {
|
|
40
|
+
stdio: 'inherit',
|
|
41
|
+
env: process.env
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
child.on('error', (err) => {
|
|
45
|
+
console.error(`[${'termux_llamacpp'}] Failed to spawn python process (${pythonBin}):`, err.message);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
child.on('exit', (code, signal) => {
|
|
50
|
+
if (signal) {
|
|
51
|
+
process.kill(process.pid, signal);
|
|
52
|
+
} else {
|
|
53
|
+
process.exit(code || 0);
|
|
54
|
+
}
|
|
55
|
+
});
|
package/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* termux-llamacpp - JavaScript / TypeScript API Bridge
|
|
7
|
+
*/
|
|
8
|
+
const { spawn } = require('child_process');
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
packageName: 'termux-llamacpp',
|
|
12
|
+
moduleName: 'termux_llamacpp',
|
|
13
|
+
runCli: function(args = []) {
|
|
14
|
+
const pythonBin = process.env.PYTHON || 'python3';
|
|
15
|
+
return spawn(pythonBin, ['-m', 'termux_llamacpp', ...args], {
|
|
16
|
+
stdio: 'inherit',
|
|
17
|
+
env: process.env
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
4
|
+
*/
|
|
5
|
+
export interface DiscoveredModel {
|
|
6
|
+
repoId: string;
|
|
7
|
+
name: string;
|
|
8
|
+
downloads: number;
|
|
9
|
+
likes: number;
|
|
10
|
+
recommendedFile: string;
|
|
11
|
+
downloadUrl: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class HuggingFaceCrawler {
|
|
14
|
+
private hfToken?;
|
|
15
|
+
constructor(hfToken?: string);
|
|
16
|
+
isPlaywrightAvailable(): Promise<boolean>;
|
|
17
|
+
discover(options?: {
|
|
18
|
+
query?: string;
|
|
19
|
+
limit?: number;
|
|
20
|
+
deepCrawl?: boolean;
|
|
21
|
+
}): Promise<DiscoveredModel[]>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=crawler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crawler.d.ts","sourceRoot":"","sources":["../src/crawler.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,OAAO,CAAC,CAAS;IAEzB,YAAY,OAAO,CAAC,EAAE,MAAM,EAE3B;IAEY,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC,CAYrD;IAEY,QAAQ,CAAC,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CA8CvH;CACF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.HuggingFaceCrawler = void 0;
|
|
8
|
+
const exceptions_js_1 = require("./exceptions.js");
|
|
9
|
+
class HuggingFaceCrawler {
|
|
10
|
+
hfToken;
|
|
11
|
+
constructor(hfToken) {
|
|
12
|
+
this.hfToken = hfToken || process.env.HF_TOKEN;
|
|
13
|
+
}
|
|
14
|
+
async isPlaywrightAvailable() {
|
|
15
|
+
try {
|
|
16
|
+
await import("termux-playwright");
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
try {
|
|
21
|
+
await import("playwright");
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async discover(options = {}) {
|
|
30
|
+
const query = options.query || "gguf";
|
|
31
|
+
const limit = options.limit || 10;
|
|
32
|
+
const deepCrawl = options.deepCrawl ?? false;
|
|
33
|
+
if (deepCrawl) {
|
|
34
|
+
const available = await this.isPlaywrightAvailable();
|
|
35
|
+
if (!available) {
|
|
36
|
+
throw new exceptions_js_1.DependencyMissingError("termux-playwright", "Hugging Face 동적 페이지 렌더링 및 심층 GGUF 파일 크롤링");
|
|
37
|
+
}
|
|
38
|
+
// If available, perform dynamic crawling
|
|
39
|
+
}
|
|
40
|
+
const url = new URL("https://huggingface.co/api/models");
|
|
41
|
+
url.searchParams.set("search", query);
|
|
42
|
+
url.searchParams.set("filter", "gguf");
|
|
43
|
+
url.searchParams.set("sort", "downloads");
|
|
44
|
+
url.searchParams.set("direction", "-1");
|
|
45
|
+
url.searchParams.set("limit", String(limit));
|
|
46
|
+
const headers = {
|
|
47
|
+
"User-Agent": "termux-llamacpp-js/1.0.0"
|
|
48
|
+
};
|
|
49
|
+
if (this.hfToken) {
|
|
50
|
+
headers["Authorization"] = `Bearer ${this.hfToken}`;
|
|
51
|
+
}
|
|
52
|
+
const response = await fetch(url.toString(), { headers });
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
throw new Error(`Hugging Face API error: ${response.statusText}`);
|
|
55
|
+
}
|
|
56
|
+
const rawData = (await response.json());
|
|
57
|
+
return rawData.map((item) => {
|
|
58
|
+
const repoId = item.id || "";
|
|
59
|
+
const repoName = repoId.split("/").pop() || repoId;
|
|
60
|
+
const recFile = `${repoName}-Q4_K_M.gguf`;
|
|
61
|
+
return {
|
|
62
|
+
repoId,
|
|
63
|
+
name: repoName,
|
|
64
|
+
downloads: item.downloads || 0,
|
|
65
|
+
likes: item.likes || 0,
|
|
66
|
+
recommendedFile: recFile,
|
|
67
|
+
downloadUrl: `https://huggingface.co/${repoId}/resolve/main/${recFile}`
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.HuggingFaceCrawler = HuggingFaceCrawler;
|
|
73
|
+
//# sourceMappingURL=crawler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crawler.js","sourceRoot":"","sources":["../src/crawler.ts"],"names":[],"mappings":";;;AAAA,mDAAyD;AAWzD;IACU,OAAO,CAAU;IAEzB,YAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;IACjD,CAAC;IAEM,KAAK,CAAC,qBAAqB;QAChC,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;YAClC,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;gBAC3B,OAAO,IAAI,CAAC;YACd,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,OAAO,GAA4D,EAAE;QACzF,MAAM,KAAK,GAAG,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AAU,EAAE,CAAC,CAAC;QACpE,CAAC;QAED,MAAM,OAAO,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAU,CAAC;QACjD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;YAC7B,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,MAAM,CAAC;YACnD,MAAM,OAAO,GAAG,GAAG,QAAQ,cAAc,CAAC;YAC1C,OAAO;gBACL,MAAM;gBACN,IAAI,EAAE,QAAQ;gBACd,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,CAAC;gBAC9B,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC;gBACtB,eAAe,EAAE,OAAO;gBACxB,WAAW,EAAE,0BAA0B,MAAM,iBAAiB,OAAO,EAAE;aACxE,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
4
|
+
*/
|
|
5
|
+
export declare class TermuxLlamaError extends Error {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class ModelNotFoundError extends TermuxLlamaError {
|
|
9
|
+
readonly modelIdentifier: string;
|
|
10
|
+
readonly searchPath: string;
|
|
11
|
+
constructor(modelIdentifier: string, searchPath?: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class DependencyMissingError extends TermuxLlamaError {
|
|
14
|
+
readonly packageName: string;
|
|
15
|
+
readonly reason: string;
|
|
16
|
+
constructor(packageName?: string, reason?: string);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=exceptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../src/exceptions.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED,qBAAa,kBAAmB,SAAQ,gBAAgB;IACtD,SAAgB,eAAe,EAAE,MAAM,CAAC;IACxC,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC,YAAY,eAAe,EAAE,MAAM,EAAE,UAAU,GAAE,MAAW,EAmB3D;CACF;AAED,qBAAa,sBAAuB,SAAQ,gBAAgB;IAC1D,SAAgB,WAAW,EAAE,MAAM,CAAC;IACpC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,YAAY,WAAW,GAAE,MAA4B,EAAE,MAAM,GAAE,MAAW,EAezE;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
4
|
+
*/
|
|
5
|
+
export class TermuxLlamaError extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "TermuxLlamaError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class ModelNotFoundError extends TermuxLlamaError {
|
|
13
|
+
constructor(modelIdentifier, searchPath = "") {
|
|
14
|
+
const msg =
|
|
15
|
+
`\n================================================================================\n` +
|
|
16
|
+
`[termux-llamacpp] MODEL NOT FOUND: '${modelIdentifier}'\n` +
|
|
17
|
+
`================================================================================\n` +
|
|
18
|
+
`지정된 GGUF 모델을 로컬 디렉터리에서 찾을 수 없습니다.\n` +
|
|
19
|
+
`검색 경로: ${searchPath || "~/.termux-llama/models/"}\n\n` +
|
|
20
|
+
`해결 방법:\n` +
|
|
21
|
+
` 1. 사전 큐레이션 모델 다운로드:\n` +
|
|
22
|
+
` termux-llama download qwen2.5-1.5b-instruct\n\n` +
|
|
23
|
+
` 2. Hugging Face에서 직접 다운로드:\n` +
|
|
24
|
+
` termux-llama download <repo_id> <filename>\n\n` +
|
|
25
|
+
` 3. 로컬 모델 목록 확인:\n` +
|
|
26
|
+
` termux-llama list\n` +
|
|
27
|
+
`================================================================================`;
|
|
28
|
+
super(msg);
|
|
29
|
+
this.name = "ModelNotFoundError";
|
|
30
|
+
this.modelIdentifier = modelIdentifier;
|
|
31
|
+
this.searchPath = searchPath;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class DependencyMissingError extends TermuxLlamaError {
|
|
36
|
+
constructor(packageName = "termux-playwright", reason = "") {
|
|
37
|
+
const msg =
|
|
38
|
+
`\n================================================================================\n` +
|
|
39
|
+
`[termux-llamacpp] DEPENDENCY MISSING: '${packageName}' is not installed!\n` +
|
|
40
|
+
`================================================================================\n` +
|
|
41
|
+
`${reason || "Hugging Face 동적 페이지 렌더링 및 심층 GGUF 파일 크롤링"}을(를) 수행하려면 '${packageName}' 패키지가 필요합니다.\n\n` +
|
|
42
|
+
`다음 명령어를 실행하여 설치를 진행하십시오:\n` +
|
|
43
|
+
` - Python 환경: pip install ${packageName}\n` +
|
|
44
|
+
` - Node.js 환경: npm install ${packageName}\n\n` +
|
|
45
|
+
`참고: 기본 REST API 기반 검색 모드를 사용하려면 deepCrawl: false 로 호출하십시오.\n` +
|
|
46
|
+
`================================================================================`;
|
|
47
|
+
super(msg);
|
|
48
|
+
this.name = "DependencyMissingError";
|
|
49
|
+
this.packageName = packageName;
|
|
50
|
+
this.reason = reason;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../src/exceptions.ts"],"names":[],"mappings":";;;AAAA,sBAA8B,SAAQ,KAAK;IACzC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAA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ation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
4
|
+
*/
|
|
5
|
+
export { LlamaRuntime, RuntimeOptions } from "./runtime.js";
|
|
6
|
+
export { ModelManager, ModelInfo, CURATED_MODELS } from "./models.js";
|
|
7
|
+
export { ServerManager, ServerInstance, ServerOptions } from "./server.js";
|
|
8
|
+
export { HuggingFaceCrawler, DiscoveredModel } from "./crawler.js";
|
|
9
|
+
export { TermuxLlamaError, ModelNotFoundError, DependencyMissingError } from "./exceptions.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/js/esm/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DependencyMissingError = exports.ModelNotFoundError = exports.TermuxLlamaError = exports.HuggingFaceCrawler = exports.ServerInstance = exports.ServerManager = exports.CURATED_MODELS = exports.ModelManager = exports.LlamaRuntime = void 0;
|
|
8
|
+
var runtime_js_1 = require("./runtime.js");
|
|
9
|
+
Object.defineProperty(exports, "LlamaRuntime", { enumerable: true, get: function () { return runtime_js_1.LlamaRuntime; } });
|
|
10
|
+
var models_js_1 = require("./models.js");
|
|
11
|
+
Object.defineProperty(exports, "ModelManager", { enumerable: true, get: function () { return models_js_1.ModelManager; } });
|
|
12
|
+
Object.defineProperty(exports, "CURATED_MODELS", { enumerable: true, get: function () { return models_js_1.CURATED_MODELS; } });
|
|
13
|
+
var server_js_1 = require("./server.js");
|
|
14
|
+
Object.defineProperty(exports, "ServerManager", { enumerable: true, get: function () { return server_js_1.ServerManager; } });
|
|
15
|
+
Object.defineProperty(exports, "ServerInstance", { enumerable: true, get: function () { return server_js_1.ServerInstance; } });
|
|
16
|
+
var crawler_js_1 = require("./crawler.js");
|
|
17
|
+
Object.defineProperty(exports, "HuggingFaceCrawler", { enumerable: true, get: function () { return crawler_js_1.HuggingFaceCrawler; } });
|
|
18
|
+
var exceptions_js_1 = require("./exceptions.js");
|
|
19
|
+
Object.defineProperty(exports, "TermuxLlamaError", { enumerable: true, get: function () { return exceptions_js_1.TermuxLlamaError; } });
|
|
20
|
+
Object.defineProperty(exports, "ModelNotFoundError", { enumerable: true, get: function () { return exceptions_js_1.ModelNotFoundError; } });
|
|
21
|
+
Object.defineProperty(exports, "DependencyMissingError", { enumerable: true, get: function () { return exceptions_js_1.DependencyMissingError; } });
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2CAA4D;AAAnD,0GAAA,YAAY,OAAA;AACrB,yCAAsE;AAA7D,yGAAA,YAAY,OAAA;AAAa,2GAAA,cAAc,OAAA;AAChD,yCAA2E;AAAlE,0GAAA,aAAa,OAAA;AAAE,2GAAA,cAAc,OAAA;AACtC,2CAAmE;AAA1D,gHAAA,kBAAkB,OAAA;AAC3B,iDAA+F;AAAtF,iHAAA,gBAAgB,OAAA;AAAE,mHAAA,kBAAkB,OAAA;AAAE,uHAAA,sBAAsB,OAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
4
|
+
*/
|
|
5
|
+
export interface ModelInfo {
|
|
6
|
+
name: string;
|
|
7
|
+
repoId: string;
|
|
8
|
+
filename: string;
|
|
9
|
+
sizeMb: number;
|
|
10
|
+
quantType: string;
|
|
11
|
+
description: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const CURATED_MODELS: Record<string, ModelInfo>;
|
|
14
|
+
export declare class ModelManager {
|
|
15
|
+
readonly modelsDir: string;
|
|
16
|
+
constructor(modelsDir?: string);
|
|
17
|
+
resolveModelPath(modelIdentifier: string): string;
|
|
18
|
+
get(modelIdentifier: string): string;
|
|
19
|
+
download(options: {
|
|
20
|
+
repoId?: string;
|
|
21
|
+
filename?: string;
|
|
22
|
+
alias?: string;
|
|
23
|
+
sha256?: string;
|
|
24
|
+
}): Promise<string>;
|
|
25
|
+
listLocalModels(): Array<{
|
|
26
|
+
filename: string;
|
|
27
|
+
path: string;
|
|
28
|
+
sizeMb: number;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAyCpD,CAAC;AAEF,qBAAa,YAAY;IACvB,SAAgB,SAAS,EAAE,MAAM,CAAC;IAElC,YAAY,SAAS,CAAC,EAAE,MAAM,EAM7B;IAEM,gBAAgB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CA2BvD;IAEM,GAAG,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAE1C;IAEY,QAAQ,CAAC,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAgCvH;IAEM,eAAe,IAAI,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAclF;CACF"}
|
package/js/esm/models.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ModelManager = exports.CURATED_MODELS = void 0;
|
|
11
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
14
|
+
const exceptions_js_1 = require("./exceptions.js");
|
|
15
|
+
exports.CURATED_MODELS = {
|
|
16
|
+
"qwen2.5-0.5b-instruct": {
|
|
17
|
+
name: "qwen2.5-0.5b-instruct",
|
|
18
|
+
repoId: "Qwen/Qwen2.5-0.5B-Instruct-GGUF",
|
|
19
|
+
filename: "qwen2.5-0.5b-instruct-q4_k_m.gguf",
|
|
20
|
+
sizeMb: 398.0,
|
|
21
|
+
quantType: "Q4_K_M",
|
|
22
|
+
description: "Ultra-lightweight Qwen 2.5 0.5B model for mobile devices."
|
|
23
|
+
},
|
|
24
|
+
"qwen2.5-1.5b-instruct": {
|
|
25
|
+
name: "qwen2.5-1.5b-instruct",
|
|
26
|
+
repoId: "Qwen/Qwen2.5-1.5B-Instruct-GGUF",
|
|
27
|
+
filename: "qwen2.5-1.5b-instruct-q4_k_m.gguf",
|
|
28
|
+
sizeMb: 986.0,
|
|
29
|
+
quantType: "Q4_K_M",
|
|
30
|
+
description: "Balanced Qwen 2.5 1.5B model for ARM64 edge inference."
|
|
31
|
+
},
|
|
32
|
+
"qwen2.5-3b-instruct": {
|
|
33
|
+
name: "qwen2.5-3b-instruct",
|
|
34
|
+
repoId: "Qwen/Qwen2.5-3B-Instruct-GGUF",
|
|
35
|
+
filename: "qwen2.5-3b-instruct-q4_k_m.gguf",
|
|
36
|
+
sizeMb: 1930.0,
|
|
37
|
+
quantType: "Q4_K_M",
|
|
38
|
+
description: "High-capability Qwen 2.5 3B model."
|
|
39
|
+
},
|
|
40
|
+
"llama-3.2-1b-instruct": {
|
|
41
|
+
name: "llama-3.2-1b-instruct",
|
|
42
|
+
repoId: "bartowski/Llama-3.2-1B-Instruct-GGUF",
|
|
43
|
+
filename: "Llama-3.2-1B-Instruct-Q4_K_M.gguf",
|
|
44
|
+
sizeMb: 881.0,
|
|
45
|
+
quantType: "Q4_K_M",
|
|
46
|
+
description: "Meta Llama 3.2 1B Instruct model."
|
|
47
|
+
},
|
|
48
|
+
"llama-3.2-3b-instruct": {
|
|
49
|
+
name: "llama-3.2-3b-instruct",
|
|
50
|
+
repoId: "bartowski/Llama-3.2-3B-Instruct-GGUF",
|
|
51
|
+
filename: "Llama-3.2-3B-Instruct-Q4_K_M.gguf",
|
|
52
|
+
sizeMb: 2020.0,
|
|
53
|
+
quantType: "Q4_K_M",
|
|
54
|
+
description: "Meta Llama 3.2 3B Instruct model."
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
class ModelManager {
|
|
58
|
+
modelsDir;
|
|
59
|
+
constructor(modelsDir) {
|
|
60
|
+
const baseDir = process.env.TERMUX_LLAMA_HOME || node_path_1.default.join(node_os_1.default.homedir(), ".termux-llama");
|
|
61
|
+
this.modelsDir = modelsDir || process.env.TERMUX_LLAMA_MODELS_DIR || node_path_1.default.join(baseDir, "models");
|
|
62
|
+
if (!node_fs_1.default.existsSync(this.modelsDir)) {
|
|
63
|
+
node_fs_1.default.mkdirSync(this.modelsDir, { recursive: true });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
resolveModelPath(modelIdentifier) {
|
|
67
|
+
// 1. Direct path check
|
|
68
|
+
if (node_fs_1.default.existsSync(modelIdentifier) && modelIdentifier.endsWith(".gguf")) {
|
|
69
|
+
return node_path_1.default.resolve(modelIdentifier);
|
|
70
|
+
}
|
|
71
|
+
// 2. Direct filename in modelsDir
|
|
72
|
+
const candidatePath = node_path_1.default.join(this.modelsDir, modelIdentifier);
|
|
73
|
+
if (node_fs_1.default.existsSync(candidatePath)) {
|
|
74
|
+
return candidatePath;
|
|
75
|
+
}
|
|
76
|
+
const candidateWithExt = node_path_1.default.join(this.modelsDir, `${modelIdentifier}.gguf`);
|
|
77
|
+
if (node_fs_1.default.existsSync(candidateWithExt)) {
|
|
78
|
+
return candidateWithExt;
|
|
79
|
+
}
|
|
80
|
+
// 3. Alias check
|
|
81
|
+
const alias = modelIdentifier.trim().toLowerCase();
|
|
82
|
+
if (exports.CURATED_MODELS[alias]) {
|
|
83
|
+
const target = node_path_1.default.join(this.modelsDir, exports.CURATED_MODELS[alias].filename);
|
|
84
|
+
if (node_fs_1.default.existsSync(target)) {
|
|
85
|
+
return target;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// 4. Model missing: interrupt with exception
|
|
89
|
+
throw new exceptions_js_1.ModelNotFoundError(modelIdentifier, this.modelsDir);
|
|
90
|
+
}
|
|
91
|
+
get(modelIdentifier) {
|
|
92
|
+
return this.resolveModelPath(modelIdentifier);
|
|
93
|
+
}
|
|
94
|
+
async download(options) {
|
|
95
|
+
let repoId = options.repoId || "";
|
|
96
|
+
let filename = options.filename || "";
|
|
97
|
+
if (options.alias && exports.CURATED_MODELS[options.alias.toLowerCase()]) {
|
|
98
|
+
const item = exports.CURATED_MODELS[options.alias.toLowerCase()];
|
|
99
|
+
repoId = item.repoId;
|
|
100
|
+
filename = item.filename;
|
|
101
|
+
}
|
|
102
|
+
if (!repoId || !filename) {
|
|
103
|
+
throw new Error("Both repoId and filename (or a valid alias) are required.");
|
|
104
|
+
}
|
|
105
|
+
const destination = node_path_1.default.join(this.modelsDir, filename);
|
|
106
|
+
if (node_fs_1.default.existsSync(destination)) {
|
|
107
|
+
console.log(`[termux-llamacpp] Model '${filename}' is already downloaded at ${destination}`);
|
|
108
|
+
return destination;
|
|
109
|
+
}
|
|
110
|
+
const downloadUrl = `https://huggingface.co/${repoId}/resolve/main/${filename}`;
|
|
111
|
+
console.log(`[termux-llamacpp] Downloading ${filename} from ${downloadUrl}...`);
|
|
112
|
+
const response = await fetch(downloadUrl);
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
throw new Error(`Failed to download model from ${downloadUrl}: ${response.statusText}`);
|
|
115
|
+
}
|
|
116
|
+
const buffer = Buffer.from(await response.arrayBuffer());
|
|
117
|
+
node_fs_1.default.writeFileSync(destination, buffer);
|
|
118
|
+
console.log(`[termux-llamacpp] Model saved to ${destination}`);
|
|
119
|
+
return destination;
|
|
120
|
+
}
|
|
121
|
+
listLocalModels() {
|
|
122
|
+
if (!node_fs_1.default.existsSync(this.modelsDir))
|
|
123
|
+
return [];
|
|
124
|
+
return node_fs_1.default
|
|
125
|
+
.readdirSync(this.modelsDir)
|
|
126
|
+
.filter((file) => file.endsWith(".gguf"))
|
|
127
|
+
.map((file) => {
|
|
128
|
+
const full = node_path_1.default.join(this.modelsDir, file);
|
|
129
|
+
const stat = node_fs_1.default.statSync(full);
|
|
130
|
+
return {
|
|
131
|
+
filename: file,
|
|
132
|
+
path: full,
|
|
133
|
+
sizeMb: Number((stat.size / (1024 * 1024)).toFixed(2))
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.ModelManager = ModelManager;
|
|
139
|
+
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAC7B,sDAAyB;AACzB,mDAAqD;AAWxC,QAAA,cAAc,GAA8B;IACvD,uBAAuB,EAAE;QACvB,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EAAE,iCAAiC;QACzC,QAAQ,EAAE,mCAAmC;QAC7C,MAAM,EAAE,KAAK;QACb,SAAS,EAAE,QAAQ;QACnB,WAAW,EAAE,2DAA2D;KACzE;IACD,uBAAuB,EAAE;QACvB,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EAAE,iCAAiC;QACzC,QAAQ,EAAE,mCAAmC;QAC7C,MAAM,EAAE,KAAK;QACb,SAAS,EAAE,QAAQ;QACnB,WAAW,EAAE,wDAAwD;KACtE;IACD,qBAAqB,EAAE;QACrB,IAAI,EAAE,qBAAqB;QAC3B,MAAM,EAAE,+BAA+B;QACvC,QAAQ,EAAE,iCAAiC;QAC3C,MAAM,EAAE,MAAM;QACd,SAAS,EAAE,QAAQ;QACnB,WAAW,EAAE,oCAAoC;KAClD;IACD,uBAAuB,EAAE;QACvB,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EAAE,sCAAsC;QAC9C,QAAQ,EAAE,mCAAmC;QAC7C,MAAM,EAAE,KAAK;QACb,SAAS,EAAE,QA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EAAE,EAAE;YACZ,MAAM,IAAI,GAAG,mBAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAC7C,MAAM,IAAI,GAAG,iBAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC/B,OAAO;gBACL,QAAQ,EAAE,IAAI;gBACd,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;aACvD,CAAC;QACJ,CAAC,CAAC,CAAC;IACP,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
4
|
+
*/
|
|
5
|
+
import { ModelManager } from "./models.js";
|
|
6
|
+
import { ServerManager, ServerInstance, ServerOptions } from "./server.js";
|
|
7
|
+
import { HuggingFaceCrawler } from "./crawler.js";
|
|
8
|
+
export interface RuntimeOptions {
|
|
9
|
+
preset?: string;
|
|
10
|
+
modelsDir?: string;
|
|
11
|
+
binDir?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class LlamaRuntime {
|
|
14
|
+
readonly models: ModelManager;
|
|
15
|
+
readonly crawler: HuggingFaceCrawler;
|
|
16
|
+
readonly serverManager: ServerManager;
|
|
17
|
+
constructor(options?: RuntimeOptions);
|
|
18
|
+
static install(options?: RuntimeOptions): Promise<LlamaRuntime>;
|
|
19
|
+
serve(options: ServerOptions): Promise<ServerInstance>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,YAAY;IACvB,SAAgB,MAAM,EAAE,YAAY,CAAC;IACrC,SAAgB,OAAO,EAAE,kBAAkB,CAAC;IAC5C,SAAgB,aAAa,EAAE,aAAa,CAAC;IAE7C,YAAY,OAAO,GAAE,cAAmB,EAIvC;IAED,OAAoB,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,YAAY,CAAC,CAG/E;IAEY,KAAK,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAGlE;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.LlamaRuntime = void 0;
|
|
8
|
+
const node_child_process_1 = require("node:child_process");
|
|
9
|
+
const models_js_1 = require("./models.js");
|
|
10
|
+
const server_js_1 = require("./server.js");
|
|
11
|
+
const crawler_js_1 = require("./crawler.js");
|
|
12
|
+
class LlamaRuntime {
|
|
13
|
+
models;
|
|
14
|
+
crawler;
|
|
15
|
+
serverManager;
|
|
16
|
+
constructor(options = {}) {
|
|
17
|
+
this.models = new models_js_1.ModelManager(options.modelsDir);
|
|
18
|
+
this.crawler = new crawler_js_1.HuggingFaceCrawler();
|
|
19
|
+
this.serverManager = new server_js_1.ServerManager();
|
|
20
|
+
}
|
|
21
|
+
static async install(options = {}) {
|
|
22
|
+
const pyCmd = process.env.PYTHON || "python3";
|
|
23
|
+
const args = ["-m", "termux_llamacpp", "install"];
|
|
24
|
+
if (options.preset) {
|
|
25
|
+
args.push("--preset", options.preset);
|
|
26
|
+
}
|
|
27
|
+
console.log(`[termux-llamacpp] Executing runtime installation (preset: ${options.preset || "android-arm64-baseline"})...`);
|
|
28
|
+
await new Promise((resolve, reject) => {
|
|
29
|
+
const child = (0, node_child_process_1.spawn)(pyCmd, args, { stdio: "inherit", env: process.env });
|
|
30
|
+
child.on("error", (err) => reject(err));
|
|
31
|
+
child.on("exit", (code) => {
|
|
32
|
+
if (code === 0)
|
|
33
|
+
resolve();
|
|
34
|
+
else
|
|
35
|
+
reject(new Error(`Runtime installation failed with exit code ${code}`));
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
return new LlamaRuntime(options);
|
|
39
|
+
}
|
|
40
|
+
async serve(options) {
|
|
41
|
+
const resolvedPath = this.models.get(options.model);
|
|
42
|
+
return this.serverManager.serve(options, resolvedPath);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.LlamaRuntime = LlamaRuntime;
|
|
46
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAC3C,2CAA2E;AAC3E,6CAAkD;AAQlD;IACkB,MAAM,CAAe;IACrB,OAAO,CAAqB;IAC5B,aAAa,CAAgB;IAE7C,YAAY,OAAO,GAAmB,EAAE;QACtC,IAAI,CAAC,MAAM,GAAG,IAAI,wBAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,OAAO,GAAG,IAAI,+BAAkB,EAAE,CAAC;QACxC,IAAI,CAAC,aAAa,GAAG,IAAI,yBAAa,EAAE,CAAC;IAC3C,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,GAAmB,EAAE;QACtD,OAAO,CAAC,GAAG,CAAC,kDAAkD,OAAO,CAAC,MAAM,IAAI,eAAe,KAAK,CAAC,CAAC;QACtG,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAEM,KAAK,CAAC,KAAK,CAAC,OAAsB;QACvC,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACzD,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
4
|
+
*/
|
|
5
|
+
import http from "node:http";
|
|
6
|
+
import { ChildProcess } from "node:child_process";
|
|
7
|
+
export interface ServerOptions {
|
|
8
|
+
model: string;
|
|
9
|
+
host?: string;
|
|
10
|
+
port?: number;
|
|
11
|
+
ctxSize?: number;
|
|
12
|
+
threads?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class ServerInstance {
|
|
15
|
+
readonly endpoint: string;
|
|
16
|
+
readonly host: string;
|
|
17
|
+
readonly port: number;
|
|
18
|
+
private process?;
|
|
19
|
+
private httpServer?;
|
|
20
|
+
constructor(options: {
|
|
21
|
+
host: string;
|
|
22
|
+
port: number;
|
|
23
|
+
process?: ChildProcess;
|
|
24
|
+
httpServer?: http.Server;
|
|
25
|
+
});
|
|
26
|
+
isHealthy(): Promise<boolean>;
|
|
27
|
+
stop(): void;
|
|
28
|
+
}
|
|
29
|
+
export declare class ServerManager {
|
|
30
|
+
serve(options: ServerOptions, resolvedModelPath: string): Promise<ServerInstance>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAS,MAAM,oBAAoB,CAAC;AAGzD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,cAAc;IACzB,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,OAAO,CAAC,CAAe;IAC/B,OAAO,CAAC,UAAU,CAAC,CAAc;IAEjC,YAAY,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,YAAY,CAAC;QAAC,UAAU,CAAC,EAAE,IAAI,CAAC,MAAM,CAAA;KAAE,EAMpG;IAEY,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAOzC;IAEM,IAAI,IAAI,IAAI,CAUlB;CACF;AAED,qBAAa,aAAa;IACX,KAAK,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAqF7F;CACF"}
|
package/js/esm/server.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ServerManager = exports.ServerInstance = void 0;
|
|
11
|
+
const node_child_process_1 = require("node:child_process");
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
class ServerInstance {
|
|
14
|
+
endpoint;
|
|
15
|
+
host;
|
|
16
|
+
port;
|
|
17
|
+
process;
|
|
18
|
+
httpServer;
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.host = options.host;
|
|
21
|
+
this.port = options.port;
|
|
22
|
+
this.process = options.process;
|
|
23
|
+
this.httpServer = options.httpServer;
|
|
24
|
+
this.endpoint = `http://${this.host}:${this.port}`;
|
|
25
|
+
}
|
|
26
|
+
async isHealthy() {
|
|
27
|
+
try {
|
|
28
|
+
const res = await fetch(`${this.endpoint}/health`);
|
|
29
|
+
return res.status === 200 || res.status === 503;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
stop() {
|
|
36
|
+
if (this.process) {
|
|
37
|
+
this.process.kill("SIGTERM");
|
|
38
|
+
this.process = undefined;
|
|
39
|
+
}
|
|
40
|
+
if (this.httpServer) {
|
|
41
|
+
this.httpServer.close();
|
|
42
|
+
this.httpServer = undefined;
|
|
43
|
+
}
|
|
44
|
+
console.log(`[termux-llamacpp] Server on ${this.endpoint} stopped.`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.ServerInstance = ServerInstance;
|
|
48
|
+
class ServerManager {
|
|
49
|
+
async serve(options, resolvedModelPath) {
|
|
50
|
+
const host = options.host || "127.0.0.1";
|
|
51
|
+
const port = options.port || 8080;
|
|
52
|
+
const modelName = node_path_1.default.basename(resolvedModelPath);
|
|
53
|
+
const pyCmd = process.env.PYTHON || "python3";
|
|
54
|
+
console.log("================================================================================");
|
|
55
|
+
console.log(` [termux-llamacpp] Node.js Native Runtime Bridge`);
|
|
56
|
+
console.log("================================================================================");
|
|
57
|
+
console.log(` Model Path : ${modelName}`);
|
|
58
|
+
console.log(` Endpoint : http://${host}:${port}`);
|
|
59
|
+
console.log("================================================================================");
|
|
60
|
+
const args = [
|
|
61
|
+
"-m",
|
|
62
|
+
"termux_llamacpp",
|
|
63
|
+
"serve",
|
|
64
|
+
resolvedModelPath,
|
|
65
|
+
"--host",
|
|
66
|
+
host,
|
|
67
|
+
"--port",
|
|
68
|
+
port.toString(),
|
|
69
|
+
"--ctx",
|
|
70
|
+
(options.ctxSize || 2048).toString(),
|
|
71
|
+
];
|
|
72
|
+
if (options.threads) {
|
|
73
|
+
args.push("--threads", options.threads.toString());
|
|
74
|
+
}
|
|
75
|
+
const proc = (0, node_child_process_1.spawn)(pyCmd, args, {
|
|
76
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
77
|
+
env: process.env,
|
|
78
|
+
});
|
|
79
|
+
const instance = new ServerInstance({ host, port, process: proc });
|
|
80
|
+
const deadline = Date.now() + 30000;
|
|
81
|
+
let ready = false;
|
|
82
|
+
while (Date.now() < deadline) {
|
|
83
|
+
if (await instance.isHealthy()) {
|
|
84
|
+
ready = true;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
if (proc.exitCode !== null) {
|
|
88
|
+
throw new Error(`Runtime process exited prematurely with code ${proc.exitCode}`);
|
|
89
|
+
}
|
|
90
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
91
|
+
}
|
|
92
|
+
if (!ready) {
|
|
93
|
+
instance.stop();
|
|
94
|
+
throw new Error(`Server failed to become ready on http://${host}:${port} within 30 seconds.`);
|
|
95
|
+
}
|
|
96
|
+
return instance;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.ServerManager = ServerManager;
|
|
100
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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C3D,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAClC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE;gBAC7B,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,cAAc,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;IAChE,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,94 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amv-llamacpp",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "GGUF runtime, model manager & OpenAI server utilizing device resources for Android Termux & ARM64",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"module": "js/esm/index.js",
|
|
7
|
+
"types": "js/esm/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"bin",
|
|
10
|
+
"js/esm",
|
|
11
|
+
"registry",
|
|
12
|
+
"LICENSE",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"bin": {
|
|
16
|
+
"termux-llama": "bin/cli.js",
|
|
17
|
+
"termux-llamacpp": "bin/cli.js"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p js/tsconfig.json",
|
|
21
|
+
"test": "node --test tests/*.test.js"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"termux",
|
|
25
|
+
"llama.cpp",
|
|
26
|
+
"gguf",
|
|
27
|
+
"android",
|
|
28
|
+
"llm",
|
|
29
|
+
"arm64",
|
|
30
|
+
"openai-server",
|
|
31
|
+
"on-device-ai",
|
|
32
|
+
"edge-ai",
|
|
33
|
+
"mobile-ai",
|
|
34
|
+
"vulkan",
|
|
35
|
+
"vulkan-compute",
|
|
36
|
+
"gpu-acceleration",
|
|
37
|
+
"local-ai",
|
|
38
|
+
"snapdragon",
|
|
39
|
+
"adreno",
|
|
40
|
+
"arm-mali",
|
|
41
|
+
"exynos",
|
|
42
|
+
"zero-compilation",
|
|
43
|
+
"supply-chain-security",
|
|
44
|
+
"ed25519-verification",
|
|
45
|
+
"server-sent-events",
|
|
46
|
+
"streaming-inference",
|
|
47
|
+
"chat-completions",
|
|
48
|
+
"rest-api",
|
|
49
|
+
"function-calling",
|
|
50
|
+
"tool-calling",
|
|
51
|
+
"vision-llm",
|
|
52
|
+
"multimodal-ai",
|
|
53
|
+
"mmproj",
|
|
54
|
+
"qwen2.5",
|
|
55
|
+
"llama3",
|
|
56
|
+
"gemma2",
|
|
57
|
+
"deepseek",
|
|
58
|
+
"mistral",
|
|
59
|
+
"phi3",
|
|
60
|
+
"huggingface",
|
|
61
|
+
"model-manager",
|
|
62
|
+
"reverse-proxy",
|
|
63
|
+
"daemon-supervisor",
|
|
64
|
+
"termux-aichain",
|
|
65
|
+
"termux-tts",
|
|
66
|
+
"termux-stt",
|
|
67
|
+
"termux-diffusion",
|
|
68
|
+
"ameva-runtime",
|
|
69
|
+
"quantization-q4",
|
|
70
|
+
"bionic-libc",
|
|
71
|
+
"mmap-inference",
|
|
72
|
+
"autonomous-agents",
|
|
73
|
+
"ai-orchestrator"
|
|
74
|
+
],
|
|
75
|
+
"author": "uno-km <dev@ameva.org>",
|
|
76
|
+
"license": "Apache-2.0",
|
|
77
|
+
"repository": {
|
|
78
|
+
"type": "git",
|
|
79
|
+
"url": "https://github.com/uno-km/termux-llamacpp.git"
|
|
80
|
+
},
|
|
81
|
+
"dependencies": {},
|
|
82
|
+
"peerDependencies": {
|
|
83
|
+
"@ameva/runtime": ">=2.0.0",
|
|
84
|
+
"termux-playwright": ">=1.70.0"
|
|
85
|
+
},
|
|
86
|
+
"peerDependenciesMeta": {
|
|
87
|
+
"@ameva/runtime": {
|
|
88
|
+
"optional": true
|
|
89
|
+
},
|
|
90
|
+
"termux-playwright": {
|
|
91
|
+
"optional": true
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"registry_version": "1.0",
|
|
3
|
+
"models": {
|
|
4
|
+
"qwen2.5-0.5b-instruct": {
|
|
5
|
+
"model_id": "qwen2.5-0.5b-instruct",
|
|
6
|
+
"repo_id": "Qwen/Qwen2.5-0.5B-Instruct-GGUF",
|
|
7
|
+
"artifact_filename": "qwen2.5-0.5b-instruct-q4_k_m.gguf",
|
|
8
|
+
"repo_revision": "08f32c9b68a8b13a890a827038e21946059d57a2",
|
|
9
|
+
"size_mb": 398.0,
|
|
10
|
+
"quant_type": "Q4_K_M",
|
|
11
|
+
"architecture": "qwen2",
|
|
12
|
+
"license_id": "Apache-2.0",
|
|
13
|
+
"license_url": "https://www.apache.org/licenses/LICENSE-2.0",
|
|
14
|
+
"requires_acceptance": false,
|
|
15
|
+
"description": "Ultra-lightweight Qwen 2.5 0.5B model, ideal for low-RAM mobile devices.",
|
|
16
|
+
"min_ram_mb": 1500
|
|
17
|
+
},
|
|
18
|
+
"qwen2.5-1.5b-instruct": {
|
|
19
|
+
"model_id": "qwen2.5-1.5b-instruct",
|
|
20
|
+
"repo_id": "Qwen/Qwen2.5-1.5B-Instruct-GGUF",
|
|
21
|
+
"artifact_filename": "qwen2.5-1.5b-instruct-q4_k_m.gguf",
|
|
22
|
+
"repo_revision": "08f32c9b68a8b13a890a827038e21946059d57a2",
|
|
23
|
+
"size_mb": 986.0,
|
|
24
|
+
"quant_type": "Q4_K_M",
|
|
25
|
+
"architecture": "qwen2",
|
|
26
|
+
"license_id": "Apache-2.0",
|
|
27
|
+
"license_url": "https://www.apache.org/licenses/LICENSE-2.0",
|
|
28
|
+
"requires_acceptance": false,
|
|
29
|
+
"description": "Balanced Qwen 2.5 1.5B model with high reasoning and coding proficiency.",
|
|
30
|
+
"min_ram_mb": 2500
|
|
31
|
+
},
|
|
32
|
+
"qwen2.5-3b-instruct": {
|
|
33
|
+
"model_id": "qwen2.5-3b-instruct",
|
|
34
|
+
"repo_id": "Qwen/Qwen2.5-3B-Instruct-GGUF",
|
|
35
|
+
"artifact_filename": "qwen2.5-3b-instruct-q4_k_m.gguf",
|
|
36
|
+
"repo_revision": "08f32c9b68a8b13a890a827038e21946059d57a2",
|
|
37
|
+
"size_mb": 1930.0,
|
|
38
|
+
"quant_type": "Q4_K_M",
|
|
39
|
+
"architecture": "qwen2",
|
|
40
|
+
"license_id": "Apache-2.0",
|
|
41
|
+
"license_url": "https://www.apache.org/licenses/LICENSE-2.0",
|
|
42
|
+
"requires_acceptance": false,
|
|
43
|
+
"description": "High-capability Qwen 2.5 3B model for 8GB+ RAM mobile devices.",
|
|
44
|
+
"min_ram_mb": 4500
|
|
45
|
+
},
|
|
46
|
+
"llama-3.2-1b-instruct": {
|
|
47
|
+
"model_id": "llama-3.2-1b-instruct",
|
|
48
|
+
"repo_id": "bartowski/Llama-3.2-1B-Instruct-GGUF",
|
|
49
|
+
"artifact_filename": "Llama-3.2-1B-Instruct-Q4_K_M.gguf",
|
|
50
|
+
"repo_revision": "e932906b3e945c7429188e7a82c69d82136015b6",
|
|
51
|
+
"size_mb": 881.0,
|
|
52
|
+
"quant_type": "Q4_K_M",
|
|
53
|
+
"architecture": "llama",
|
|
54
|
+
"license_id": "Llama-3.2-Community",
|
|
55
|
+
"license_url": "https://llama.meta.com/llama3/license/",
|
|
56
|
+
"requires_acceptance": true,
|
|
57
|
+
"description": "Meta Llama 3.2 1B Instruct model, optimized for mobile edge inference.",
|
|
58
|
+
"min_ram_mb": 2000
|
|
59
|
+
},
|
|
60
|
+
"llama-3.2-3b-instruct": {
|
|
61
|
+
"model_id": "llama-3.2-3b-instruct",
|
|
62
|
+
"repo_id": "bartowski/Llama-3.2-3B-Instruct-GGUF",
|
|
63
|
+
"artifact_filename": "Llama-3.2-3B-Instruct-Q4_K_M.gguf",
|
|
64
|
+
"repo_revision": "e932906b3e945c7429188e7a82c69d82136015b6",
|
|
65
|
+
"size_mb": 2020.0,
|
|
66
|
+
"quant_type": "Q4_K_M",
|
|
67
|
+
"architecture": "llama",
|
|
68
|
+
"license_id": "Llama-3.2-Community",
|
|
69
|
+
"license_url": "https://llama.meta.com/llama3/license/",
|
|
70
|
+
"requires_acceptance": true,
|
|
71
|
+
"description": "Meta Llama 3.2 3B Instruct model, robust general purpose assistant.",
|
|
72
|
+
"min_ram_mb": 4500
|
|
73
|
+
},
|
|
74
|
+
"gemma-2-2b-it": {
|
|
75
|
+
"model_id": "gemma-2-2b-it",
|
|
76
|
+
"repo_id": "bartowski/gemma-2-2b-it-GGUF",
|
|
77
|
+
"artifact_filename": "gemma-2-2b-it-Q4_K_M.gguf",
|
|
78
|
+
"repo_revision": "c7429188e7a82c69d82136015b69c4a45ec466cf",
|
|
79
|
+
"size_mb": 1630.0,
|
|
80
|
+
"quant_type": "Q4_K_M",
|
|
81
|
+
"architecture": "gemma2",
|
|
82
|
+
"license_id": "Gemma-Terms-of-Use",
|
|
83
|
+
"license_url": "https://ai.google.dev/gemma/terms",
|
|
84
|
+
"requires_acceptance": true,
|
|
85
|
+
"description": "Google Gemma 2 2B Instruct model with high accuracy.",
|
|
86
|
+
"min_ram_mb": 3500
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|