sonex-agent 0.1.0-alpha.1
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 +21 -0
- package/README.md +15 -0
- package/bin/sonex.js +235 -0
- package/dist/App.js +1360 -0
- package/dist/activity.js +18 -0
- package/dist/chat-document.js +40 -0
- package/dist/chat-message.js +93 -0
- package/dist/chat-theme.js +18 -0
- package/dist/chat-window.js +104 -0
- package/dist/command-panel.js +45 -0
- package/dist/commands.js +70 -0
- package/dist/components.js +662 -0
- package/dist/confirm-choice.js +65 -0
- package/dist/constants.js +109 -0
- package/dist/conversation-flow.js +21 -0
- package/dist/cover-pattern.js +58 -0
- package/dist/cover-visual.js +158 -0
- package/dist/extension-panel.js +136 -0
- package/dist/format.js +99 -0
- package/dist/hooks.js +216 -0
- package/dist/i18n.js +291 -0
- package/dist/index.js +46 -0
- package/dist/info-banner.js +37 -0
- package/dist/input-cursor.js +6 -0
- package/dist/input-routing.js +41 -0
- package/dist/launch-preparing.js +30 -0
- package/dist/layout.js +134 -0
- package/dist/list.js +3 -0
- package/dist/login-navigation.js +7 -0
- package/dist/mini-progress-writer.js +122 -0
- package/dist/mini-progress.js +77 -0
- package/dist/model-selection.js +20 -0
- package/dist/model-status.js +34 -0
- package/dist/mouse-input.js +173 -0
- package/dist/panel-frame.js +86 -0
- package/dist/panel-lifecycle.js +17 -0
- package/dist/playback-keymap.js +59 -0
- package/dist/provider-state.js +67 -0
- package/dist/runtime-state.js +91 -0
- package/dist/shell-state.js +37 -0
- package/dist/sonex-logo.js +9 -0
- package/dist/terminal-clear.js +10 -0
- package/dist/terminal-frame-writer.js +133 -0
- package/dist/terminal-surface.js +80 -0
- package/dist/text-stream.js +17 -0
- package/dist/track-panel.js +95 -0
- package/dist/transcript.js +92 -0
- package/dist/types.js +1 -0
- package/dist/ui-settings.js +30 -0
- package/dist/usage-animation.js +14 -0
- package/package.json +57 -0
- package/vendor/requirements-linux-py312.txt +2659 -0
- package/vendor/sonex-0.1.0a1-py3-none-any.whl +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Silence
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# sonex-agent
|
|
2
|
+
|
|
3
|
+
Install the terminal music agent with:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install -g sonex-agent@alpha
|
|
7
|
+
sonex
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
The first `sonex` launch provisions a private Python 3.12 runtime under
|
|
11
|
+
`~/.sonex/runtime`. User credentials and application state remain under
|
|
12
|
+
`SONEX_HOME` (default: `~/.sonex`). The alpha package supports Linux and WSL2.
|
|
13
|
+
|
|
14
|
+
For source development, use the repository installer from the project root:
|
|
15
|
+
`./scripts/install.sh`.
|
package/bin/sonex.js
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync, chmodSync } from "node:fs";
|
|
5
|
+
import { homedir, tmpdir } from "node:os";
|
|
6
|
+
import { dirname, join, resolve } from "node:path";
|
|
7
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
|
|
10
|
+
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
11
|
+
const packageJson = JSON.parse(readFileSync(join(packageRoot, "package.json"), "utf8"));
|
|
12
|
+
const appVersion = packageJson.version;
|
|
13
|
+
const uvVersion = "0.12.8";
|
|
14
|
+
const uvAssets = {
|
|
15
|
+
x64: {
|
|
16
|
+
name: "uv-x86_64-unknown-linux-gnu.tar.gz",
|
|
17
|
+
sha256: "2e2b37e9811e17675a9e70bed5e1a58fc8c0388be63d751d72cc735188c149ff",
|
|
18
|
+
},
|
|
19
|
+
arm64: {
|
|
20
|
+
name: "uv-aarch64-unknown-linux-gnu.tar.gz",
|
|
21
|
+
sha256: "ba8661f4fd207c8e94814191598e619b355ac10d5014e851e21eb800f9ef2b00",
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function fail(message, error) {
|
|
26
|
+
console.error(`Sonex setup failed: ${message}`);
|
|
27
|
+
if (process.env.SONEX_DEBUG && error) console.error(error.stack || error);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function runtimeRoot() {
|
|
32
|
+
const home = process.env.SONEX_HOME || join(homedir(), ".sonex");
|
|
33
|
+
return resolve(process.env.SONEX_RUNTIME_HOME || join(home, "runtime", "app"));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function runtimeDir() {
|
|
37
|
+
return join(runtimeRoot(), appVersion);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function executablePath(dir, name) {
|
|
41
|
+
return join(dir, "venv", "bin", name);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function runtimeReady(dir) {
|
|
45
|
+
const python = join(dir, "venv", "bin", "python");
|
|
46
|
+
const command = executablePath(dir, "sonex");
|
|
47
|
+
if (!existsSync(join(dir, "runtime.json")) || !existsSync(python) || !existsSync(command)) return false;
|
|
48
|
+
try {
|
|
49
|
+
const marker = JSON.parse(readFileSync(join(dir, "runtime.json"), "utf8"));
|
|
50
|
+
const shebang = readFileSync(command, "utf8").split("\n", 1)[0];
|
|
51
|
+
return marker.appVersion === appVersion && shebang === `#!${python}`;
|
|
52
|
+
} catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function findWheel() {
|
|
58
|
+
const vendor = join(packageRoot, "vendor");
|
|
59
|
+
if (!existsSync(vendor)) return null;
|
|
60
|
+
const wheels = readdirSync(vendor).filter((entry) => entry.startsWith("sonex-") && entry.endsWith(".whl"));
|
|
61
|
+
return wheels.length === 1 ? join(vendor, wheels[0]) : null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function requirementsFile() {
|
|
65
|
+
const candidate = join(packageRoot, "vendor", "requirements-linux-py312.txt");
|
|
66
|
+
return existsSync(candidate) ? candidate : null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function run(command, args, env) {
|
|
70
|
+
const result = spawnSync(command, args, { env, stdio: "inherit" });
|
|
71
|
+
if (result.error) throw result.error;
|
|
72
|
+
if (result.status !== 0) throw new Error(`${command} exited with status ${result.status}`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function download(url, destination) {
|
|
76
|
+
const controller = new AbortController();
|
|
77
|
+
const timeout = setTimeout(() => controller.abort(), 120000);
|
|
78
|
+
try {
|
|
79
|
+
const response = await fetch(url, { signal: controller.signal, redirect: "follow" });
|
|
80
|
+
if (!response.ok) throw new Error(`HTTP ${response.status} while downloading ${url}`);
|
|
81
|
+
const bytes = Buffer.from(await response.arrayBuffer());
|
|
82
|
+
writeFileSync(destination, bytes, { mode: 0o600 });
|
|
83
|
+
return bytes;
|
|
84
|
+
} finally {
|
|
85
|
+
clearTimeout(timeout);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function findFile(root, name) {
|
|
90
|
+
for (const entry of readdirSync(root)) {
|
|
91
|
+
const path = join(root, entry);
|
|
92
|
+
if (statSync(path).isDirectory()) {
|
|
93
|
+
const found = findFile(path, name);
|
|
94
|
+
if (found) return found;
|
|
95
|
+
} else if (entry === name) {
|
|
96
|
+
return path;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async function ensureUv(toolsDir) {
|
|
103
|
+
const override = process.env.SONEX_UV_BIN;
|
|
104
|
+
if (override) return resolve(override);
|
|
105
|
+
|
|
106
|
+
const asset = uvAssets[process.arch];
|
|
107
|
+
if (!asset) throw new Error(`Unsupported Linux architecture: ${process.arch}`);
|
|
108
|
+
|
|
109
|
+
const uvPath = join(toolsDir, "uv");
|
|
110
|
+
if (existsSync(uvPath)) return uvPath;
|
|
111
|
+
|
|
112
|
+
mkdirSync(toolsDir, { recursive: true, mode: 0o700 });
|
|
113
|
+
const staging = mkdtempSync(join(tmpdir(), "sonex-uv-"));
|
|
114
|
+
const archive = join(staging, asset.name);
|
|
115
|
+
try {
|
|
116
|
+
const url = `https://releases.astral.sh/github/uv/releases/download/${uvVersion}/${asset.name}`;
|
|
117
|
+
const bytes = await download(url, archive);
|
|
118
|
+
const digest = createHash("sha256").update(bytes).digest("hex");
|
|
119
|
+
if (digest !== asset.sha256) throw new Error(`SHA-256 mismatch for ${asset.name}`);
|
|
120
|
+
|
|
121
|
+
const extracted = join(staging, "extracted");
|
|
122
|
+
mkdirSync(extracted);
|
|
123
|
+
const result = spawnSync("tar", ["-xzf", archive, "-C", extracted], { stdio: "inherit" });
|
|
124
|
+
if (result.status !== 0) throw new Error("tar failed while unpacking uv");
|
|
125
|
+
const unpacked = findFile(extracted, "uv");
|
|
126
|
+
if (!unpacked) throw new Error("uv executable was not found in the archive");
|
|
127
|
+
renameSync(unpacked, uvPath);
|
|
128
|
+
chmodSync(uvPath, 0o700);
|
|
129
|
+
return uvPath;
|
|
130
|
+
} finally {
|
|
131
|
+
rmSync(staging, { recursive: true, force: true });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function installRuntime(target) {
|
|
136
|
+
const wheel = findWheel();
|
|
137
|
+
const requirements = requirementsFile();
|
|
138
|
+
if (!wheel || !requirements) {
|
|
139
|
+
throw new Error("This npm package has no bundled Python runtime artifacts; use a published release package.");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
mkdirSync(runtimeRoot(), { recursive: true, mode: 0o700 });
|
|
143
|
+
if (existsSync(target) && !runtimeReady(target)) renameSync(target, `${target}.incomplete-${Date.now()}`);
|
|
144
|
+
mkdirSync(target, { recursive: true, mode: 0o700 });
|
|
145
|
+
const env = { ...process.env, UV_PYTHON_INSTALL_DIR: join(target, "python") };
|
|
146
|
+
const uv = await ensureUv(join(target, "tools"));
|
|
147
|
+
run(uv, ["python", "install", "3.12", "--install-dir", join(target, "python"), "--no-bin"], env);
|
|
148
|
+
run(uv, ["venv", "--python", "3.12", join(target, "venv")], env);
|
|
149
|
+
const python = join(target, "venv", "bin", "python");
|
|
150
|
+
run(uv, ["pip", "install", "--python", python, "--requirement", requirements], env);
|
|
151
|
+
run(uv, ["pip", "install", "--python", python, "--no-deps", wheel], env);
|
|
152
|
+
writeFileSync(join(target, "runtime.json"), JSON.stringify({ appVersion, python: "3.12", uv: uvVersion }, null, 2) + "\n", { mode: 0o600 });
|
|
153
|
+
return target;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function lockOwnerAlive(lockPath) {
|
|
157
|
+
try {
|
|
158
|
+
const owner = JSON.parse(readFileSync(join(lockPath, "owner.json"), "utf8"));
|
|
159
|
+
process.kill(owner.pid, 0);
|
|
160
|
+
return true;
|
|
161
|
+
} catch (error) {
|
|
162
|
+
return error?.code === "EPERM";
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function sleep(milliseconds) {
|
|
167
|
+
return new Promise((resolvePromise) => setTimeout(resolvePromise, milliseconds));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async function acquireInstallLock(target) {
|
|
171
|
+
const lockPath = `${target}.lock`;
|
|
172
|
+
const started = Date.now();
|
|
173
|
+
mkdirSync(runtimeRoot(), { recursive: true, mode: 0o700 });
|
|
174
|
+
while (true) {
|
|
175
|
+
try {
|
|
176
|
+
mkdirSync(lockPath, { mode: 0o700 });
|
|
177
|
+
writeFileSync(join(lockPath, "owner.json"), JSON.stringify({ pid: process.pid }) + "\n", { mode: 0o600 });
|
|
178
|
+
return () => rmSync(lockPath, { recursive: true, force: true });
|
|
179
|
+
} catch (error) {
|
|
180
|
+
if (error?.code !== "EEXIST") throw error;
|
|
181
|
+
if (!lockOwnerAlive(lockPath)) {
|
|
182
|
+
renameSync(lockPath, `${lockPath}.stale-${Date.now()}`);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (Date.now() - started > 10 * 60 * 1000) throw new Error("another Sonex runtime installation is still in progress");
|
|
186
|
+
await sleep(250);
|
|
187
|
+
if (runtimeReady(target)) return () => {};
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async function ensureRuntime() {
|
|
193
|
+
const target = runtimeDir();
|
|
194
|
+
if (runtimeReady(target)) return target;
|
|
195
|
+
const releaseLock = await acquireInstallLock(target);
|
|
196
|
+
try {
|
|
197
|
+
if (runtimeReady(target)) return target;
|
|
198
|
+
console.error(`Preparing Sonex Python runtime ${appVersion}...`);
|
|
199
|
+
return await installRuntime(target);
|
|
200
|
+
} finally {
|
|
201
|
+
releaseLock();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function launch(runtime) {
|
|
206
|
+
const command = executablePath(runtime, "sonex");
|
|
207
|
+
const child = spawn(command, process.argv.slice(2), {
|
|
208
|
+
cwd: process.cwd(),
|
|
209
|
+
env: {
|
|
210
|
+
...process.env,
|
|
211
|
+
SONEX_APP_VERSION: appVersion,
|
|
212
|
+
SONEX_CLI_UI_DIR: join(packageRoot, "dist"),
|
|
213
|
+
SONEX_NODE: process.execPath,
|
|
214
|
+
SONEX_RUNTIME_DIR: runtime,
|
|
215
|
+
},
|
|
216
|
+
stdio: "inherit",
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
|
|
220
|
+
process.on(signal, () => child.kill(signal));
|
|
221
|
+
}
|
|
222
|
+
child.on("error", (error) => fail(`could not start ${command}`, error));
|
|
223
|
+
child.on("exit", (code, signal) => {
|
|
224
|
+
if (signal) process.exit(128 + (signal === "SIGINT" ? 2 : signal === "SIGTERM" ? 15 : 1));
|
|
225
|
+
process.exit(code ?? 1);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (process.argv.length === 3 && ["--version", "-v"].includes(process.argv[2])) {
|
|
230
|
+
console.log(`v${appVersion}`);
|
|
231
|
+
} else if (process.platform !== "linux") {
|
|
232
|
+
fail("this alpha release supports Linux and WSL2 only");
|
|
233
|
+
} else {
|
|
234
|
+
ensureRuntime().then(launch).catch((error) => fail(error.message, error));
|
|
235
|
+
}
|