made-bridge 0.0.0-stage → 0.2.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 +21 -0
- package/README.md +45 -2
- package/builtin/plugins/README.md +22 -0
- package/builtin/themes/README.md +64 -0
- package/builtin/themes/sunset/theme.json +19 -0
- package/config.example.json +20 -0
- package/demo-project/README.md +5 -0
- package/demo-project/index.mjs +14 -0
- package/package.json +48 -4
- package/public/app.js +1028 -0
- package/public/assistants.html +67 -0
- package/public/bean-icon.png +0 -0
- package/public/i18n-messages.js +967 -0
- package/public/i18n-static.js +615 -0
- package/public/i18n.js +50 -0
- package/public/index.html +149 -0
- package/public/made-icon.png +0 -0
- package/public/plugins.html +64 -0
- package/public/plugins.js +335 -0
- package/public/provider-icon.js +77 -0
- package/public/styles.css +445 -0
- package/public/tasks.html +85 -0
- package/src/agent-icons.mjs +138 -0
- package/src/agents/codex.mjs +94 -0
- package/src/agents/cursor.mjs +31 -0
- package/src/agents/events.mjs +92 -0
- package/src/agents/index.mjs +7 -0
- package/src/agents/qoder.mjs +34 -0
- package/src/agents/shared.mjs +191 -0
- package/src/agents/workbuddy.mjs +121 -0
- package/src/board-link.mjs +266 -0
- package/src/config.mjs +196 -0
- package/src/doctor.mjs +146 -0
- package/src/i18n.mjs +257 -0
- package/src/installed.mjs +291 -0
- package/src/jobs.mjs +369 -0
- package/src/language-settings.mjs +38 -0
- package/src/model-settings.mjs +63 -0
- package/src/openai-key.mjs +47 -0
- package/src/oray.mjs +243 -0
- package/src/pairing.mjs +203 -0
- package/src/plugin-package.mjs +132 -0
- package/src/plugin-runtime.mjs +169 -0
- package/src/plugins/contracts.d.ts +184 -0
- package/src/plugins/enhance.mjs +156 -0
- package/src/plugins/registry.mjs +146 -0
- package/src/providers.mjs +75 -0
- package/src/server.mjs +939 -0
- package/src/sessions.mjs +134 -0
- package/src/speech/index.mjs +10 -0
- package/src/speech/openai.mjs +48 -0
- package/src/speech/whisper.mjs +59 -0
- package/src/speech-settings.mjs +209 -0
- package/src/transcribe.mjs +85 -0
- package/src/tunnel.mjs +531 -0
- package/src/usb-receiver.mjs +664 -0
- package/src/voice-settings.mjs +69 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
|
|
5
|
+
export const DEFAULT_TRANSCRIBE_URL = 'https://api.openai.com/v1/audio/transcriptions';
|
|
6
|
+
export const DEFAULT_TRANSCRIBE_MODEL = 'gpt-transcribe';
|
|
7
|
+
|
|
8
|
+
export function validateTranscribeUrl(value) {
|
|
9
|
+
if (typeof value !== 'string' || value.length < 1 || value.length > 2048 || value !== value.trim()) {
|
|
10
|
+
throw new Error('语音接口 URL 无效');
|
|
11
|
+
}
|
|
12
|
+
let url;
|
|
13
|
+
try { url = new URL(value); }
|
|
14
|
+
catch { throw new Error('语音接口 URL 无效'); }
|
|
15
|
+
const loopback = ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname.toLowerCase());
|
|
16
|
+
if (url.protocol !== 'https:' && !(url.protocol === 'http:' && loopback)) {
|
|
17
|
+
throw new Error('语音接口必须使用 HTTPS;仅本机代理允许 HTTP');
|
|
18
|
+
}
|
|
19
|
+
if (url.username || url.password || url.hash || !url.pathname || url.pathname === '/') {
|
|
20
|
+
throw new Error('语音接口 URL 不能包含账号、密码或片段,且须包含接口路径');
|
|
21
|
+
}
|
|
22
|
+
return url.href;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function validateTranscribeModel(value) {
|
|
26
|
+
if (typeof value !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._:/@-]{0,127}$/.test(value)) {
|
|
27
|
+
throw new Error('语音模型名称无效');
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function settingsPath(stateDir) {
|
|
33
|
+
return path.join(stateDir, 'secrets', 'voice-settings.json');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function loadVoiceSettings(stateDir) {
|
|
37
|
+
const file = settingsPath(stateDir);
|
|
38
|
+
try {
|
|
39
|
+
if (!fs.lstatSync(file).isFile()) throw new Error('语音设置文件无效');
|
|
40
|
+
const saved = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
41
|
+
return {
|
|
42
|
+
url: validateTranscribeUrl(saved.url),
|
|
43
|
+
model: validateTranscribeModel(saved.model),
|
|
44
|
+
};
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (error.code === 'ENOENT') return null;
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function saveVoiceSettings(stateDir, settings) {
|
|
52
|
+
const normalized = {
|
|
53
|
+
url: validateTranscribeUrl(settings.url),
|
|
54
|
+
model: validateTranscribeModel(settings.model),
|
|
55
|
+
};
|
|
56
|
+
const directory = path.join(stateDir, 'secrets');
|
|
57
|
+
const file = settingsPath(stateDir);
|
|
58
|
+
fs.mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
59
|
+
fs.chmodSync(directory, 0o700);
|
|
60
|
+
const temporary = path.join(directory, `.voice-settings-${process.pid}-${randomUUID()}`);
|
|
61
|
+
try {
|
|
62
|
+
fs.writeFileSync(temporary, JSON.stringify(normalized), { flag: 'wx', mode: 0o600 });
|
|
63
|
+
fs.renameSync(temporary, file);
|
|
64
|
+
fs.chmodSync(file, 0o600);
|
|
65
|
+
} finally {
|
|
66
|
+
fs.rmSync(temporary, { force: true });
|
|
67
|
+
}
|
|
68
|
+
return normalized;
|
|
69
|
+
}
|