crawd 0.8.6 → 0.9.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/dist/cli.js +7 -1
- package/dist/types.d.ts +5 -23
- package/openclaw.plugin.json +8 -40
- package/package.json +13 -11
- package/skills/crawd/SKILL.md +37 -0
- package/src/backend/coordinator.test.ts +393 -0
- package/src/backend/coordinator.ts +274 -19
- package/src/backend/index.ts +29 -208
- package/src/backend/server.ts +75 -219
- package/src/commands/skill.ts +3 -0
- package/src/commands/start.ts +1 -0
- package/src/config/schema.ts +2 -0
- package/src/plugin.ts +124 -33
- package/src/types.ts +4 -23
- package/dist/backend/chunk-QITCQHSS.js +0 -2087
- package/dist/backend/fileFromPath-WZUZ37JN.js +0 -127
- package/dist/backend/index.js +0 -12418
- package/dist/chunk-QITCQHSS.js +0 -2087
- package/dist/fileFromPath-WZUZ37JN.js +0 -127
- package/dist/plugin.d.ts +0 -27
- package/dist/plugin.js +0 -12363
- package/src/lib/tts/tiktok.ts +0 -91
package/src/lib/tts/tiktok.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TikTok Text-to-Speech
|
|
3
|
-
* Vendored from https://github.com/Steve0929/tiktok-tts
|
|
4
|
-
* Converted to TypeScript/ESM with native fetch
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const DEFAULT_BASE_URL = 'https://api16-normal-v6.tiktokv.com/media/api/text/speech/invoke';
|
|
8
|
-
const DEFAULT_VOICE = 'en_us_002'; // Jessie
|
|
9
|
-
|
|
10
|
-
type TikTokTTSConfig = {
|
|
11
|
-
sessionId: string;
|
|
12
|
-
baseUrl?: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
let config: TikTokTTSConfig | null = null;
|
|
16
|
-
|
|
17
|
-
export function configureTikTokTTS(sessionId: string, baseUrl?: string): void {
|
|
18
|
-
config = { sessionId, baseUrl };
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function prepareText(text: string): string {
|
|
22
|
-
return text
|
|
23
|
-
.replace(/\+/g, 'plus')
|
|
24
|
-
.replace(/\s/g, '+')
|
|
25
|
-
.replace(/&/g, 'and');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function handleStatusError(statusCode: number): never {
|
|
29
|
-
switch (statusCode) {
|
|
30
|
-
case 1:
|
|
31
|
-
throw new Error(`TikTok session id invalid or expired. status_code: ${statusCode}`);
|
|
32
|
-
case 2:
|
|
33
|
-
throw new Error(`Text is too long. status_code: ${statusCode}`);
|
|
34
|
-
case 4:
|
|
35
|
-
throw new Error(`Invalid speaker voice. status_code: ${statusCode}`);
|
|
36
|
-
case 5:
|
|
37
|
-
throw new Error(`No session id found. status_code: ${statusCode}`);
|
|
38
|
-
default:
|
|
39
|
-
throw new Error(`TikTok TTS error. status_code: ${statusCode}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
type TikTokResponse = {
|
|
44
|
-
status_code: number;
|
|
45
|
-
data?: {
|
|
46
|
-
v_str?: string;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Generate TTS audio using TikTok's API
|
|
52
|
-
* @returns Base64-encoded MP3 audio data
|
|
53
|
-
*/
|
|
54
|
-
export async function generateTikTokTTS(
|
|
55
|
-
text: string,
|
|
56
|
-
voice: string = DEFAULT_VOICE
|
|
57
|
-
): Promise<Buffer> {
|
|
58
|
-
if (!config) {
|
|
59
|
-
throw new Error('TikTok TTS not configured. Call configureTikTokTTS() first.');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
|
|
63
|
-
const reqText = prepareText(text);
|
|
64
|
-
const url = `${baseUrl}/?text_speaker=${voice}&req_text=${reqText}&speaker_map_type=0&aid=1233`;
|
|
65
|
-
|
|
66
|
-
const response = await fetch(url, {
|
|
67
|
-
method: 'POST',
|
|
68
|
-
headers: {
|
|
69
|
-
'User-Agent': 'com.zhiliaoapp.musically/2022600030 (Linux; U; Android 7.1.2; es_ES; SM-G988N; Build/NRD90M;tt-ok/3.12.13.1)',
|
|
70
|
-
'Cookie': `sessionid=${config.sessionId}`,
|
|
71
|
-
'Accept-Encoding': 'gzip,deflate,compress',
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
if (!response.ok) {
|
|
76
|
-
throw new Error(`TikTok TTS request failed: ${response.status} ${response.statusText}`);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const result = (await response.json()) as TikTokResponse;
|
|
80
|
-
|
|
81
|
-
if (result.status_code !== 0) {
|
|
82
|
-
handleStatusError(result.status_code);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const encodedVoice = result.data?.v_str;
|
|
86
|
-
if (!encodedVoice) {
|
|
87
|
-
throw new Error('TikTok TTS returned no audio data');
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return Buffer.from(encodedVoice, 'base64');
|
|
91
|
-
}
|