@kenkaiiii/ggcoder 4.3.243 → 4.4.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/config.d.ts +3 -14
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -17
- package/dist/config.js.map +1 -1
- package/dist/core/auth-storage.d.ts +1 -40
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +3 -200
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/auto-update.d.ts +4 -26
- package/dist/core/auto-update.d.ts.map +1 -1
- package/dist/core/auto-update.js +12 -237
- package/dist/core/auto-update.js.map +1 -1
- package/dist/core/claude-code-version.d.ts +1 -9
- package/dist/core/claude-code-version.d.ts.map +1 -1
- package/dist/core/claude-code-version.js +2 -105
- package/dist/core/claude-code-version.js.map +1 -1
- package/dist/core/file-lock.d.ts +1 -5
- package/dist/core/file-lock.d.ts.map +1 -1
- package/dist/core/file-lock.js +2 -75
- package/dist/core/file-lock.js.map +1 -1
- package/dist/core/logger.d.ts +4 -17
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +21 -110
- package/dist/core/logger.js.map +1 -1
- package/dist/core/model-registry.d.ts +1 -54
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +4 -296
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/oauth/anthropic.d.ts +1 -3
- package/dist/core/oauth/anthropic.d.ts.map +1 -1
- package/dist/core/oauth/anthropic.js +2 -96
- package/dist/core/oauth/anthropic.js.map +1 -1
- package/dist/core/oauth/gemini.d.ts +1 -3
- package/dist/core/oauth/gemini.d.ts.map +1 -1
- package/dist/core/oauth/gemini.js +2 -379
- package/dist/core/oauth/gemini.js.map +1 -1
- package/dist/core/oauth/openai.d.ts +1 -3
- package/dist/core/oauth/openai.d.ts.map +1 -1
- package/dist/core/oauth/openai.js +2 -187
- package/dist/core/oauth/openai.js.map +1 -1
- package/dist/core/oauth/pkce.d.ts +1 -4
- package/dist/core/oauth/pkce.d.ts.map +1 -1
- package/dist/core/oauth/pkce.js +2 -16
- package/dist/core/oauth/pkce.js.map +1 -1
- package/dist/core/oauth/types.d.ts +1 -13
- package/dist/core/oauth/types.d.ts.map +1 -1
- package/dist/core/telegram.d.ts +1 -112
- package/dist/core/telegram.d.ts.map +1 -1
- package/dist/core/telegram.js +2 -251
- package/dist/core/telegram.js.map +1 -1
- package/dist/core/thinking-level.d.ts +1 -4
- package/dist/core/thinking-level.d.ts.map +1 -1
- package/dist/core/thinking-level.js +3 -58
- package/dist/core/thinking-level.js.map +1 -1
- package/dist/core/voice-transcriber.d.ts +1 -32
- package/dist/core/voice-transcriber.d.ts.map +1 -1
- package/dist/core/voice-transcriber.js +3 -112
- package/dist/core/voice-transcriber.js.map +1 -1
- package/package.json +5 -4
- package/dist/core/model-registry.test.d.ts +0 -2
- package/dist/core/model-registry.test.d.ts.map +0 -1
- package/dist/core/model-registry.test.js +0 -95
- package/dist/core/model-registry.test.js.map +0 -1
- package/dist/core/oauth/gemini.test.d.ts +0 -2
- package/dist/core/oauth/gemini.test.d.ts.map +0 -1
- package/dist/core/oauth/gemini.test.js +0 -154
- package/dist/core/oauth/gemini.test.js.map +0 -1
- package/dist/core/thinking-level.test.d.ts +0 -2
- package/dist/core/thinking-level.test.d.ts.map +0 -1
- package/dist/core/thinking-level.test.js +0 -38
- package/dist/core/thinking-level.test.js.map +0 -1
- package/dist/core/voice-transcriber.test.d.ts +0 -2
- package/dist/core/voice-transcriber.test.d.ts.map +0 -1
- package/dist/core/voice-transcriber.test.js +0 -88
- package/dist/core/voice-transcriber.test.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkce.js","sourceRoot":"","sources":["../../../src/core/oauth/pkce.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pkce.js","sourceRoot":"","sources":["../../../src/core/oauth/pkce.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
accessToken: string;
|
|
3
|
-
refreshToken: string;
|
|
4
|
-
expiresAt: number;
|
|
5
|
-
accountId?: string;
|
|
6
|
-
projectId?: string;
|
|
7
|
-
baseUrl?: string;
|
|
8
|
-
}
|
|
9
|
-
export interface OAuthLoginCallbacks {
|
|
10
|
-
onOpenUrl: (url: string) => void;
|
|
11
|
-
onPromptCode: (message: string) => Promise<string>;
|
|
12
|
-
onStatus: (message: string) => void;
|
|
13
|
-
}
|
|
1
|
+
export type { OAuthCredentials, OAuthLoginCallbacks } from "@kenkaiiii/gg-core";
|
|
14
2
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/oauth/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/oauth/types.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/core/telegram.d.ts
CHANGED
|
@@ -1,113 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Minimal Telegram Bot API client using raw fetch().
|
|
3
|
-
* Supports long polling, markdown messages, inline keyboards, and message splitting.
|
|
4
|
-
*/
|
|
5
|
-
export interface TelegramConfig {
|
|
6
|
-
botToken: string;
|
|
7
|
-
/** Only accept messages from this Telegram user ID. */
|
|
8
|
-
allowedUserId: number;
|
|
9
|
-
}
|
|
10
|
-
export interface TelegramUpdate {
|
|
11
|
-
update_id: number;
|
|
12
|
-
message?: {
|
|
13
|
-
message_id: number;
|
|
14
|
-
from: {
|
|
15
|
-
id: number;
|
|
16
|
-
first_name: string;
|
|
17
|
-
};
|
|
18
|
-
chat: {
|
|
19
|
-
id: number;
|
|
20
|
-
type: string;
|
|
21
|
-
title?: string;
|
|
22
|
-
};
|
|
23
|
-
text?: string;
|
|
24
|
-
voice?: {
|
|
25
|
-
file_id: string;
|
|
26
|
-
duration: number;
|
|
27
|
-
mime_type?: string;
|
|
28
|
-
file_size?: number;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
callback_query?: {
|
|
32
|
-
id: string;
|
|
33
|
-
from: {
|
|
34
|
-
id: number;
|
|
35
|
-
};
|
|
36
|
-
message: {
|
|
37
|
-
chat: {
|
|
38
|
-
id: number;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
data: string;
|
|
42
|
-
};
|
|
43
|
-
my_chat_member?: {
|
|
44
|
-
chat: {
|
|
45
|
-
id: number;
|
|
46
|
-
type: string;
|
|
47
|
-
title?: string;
|
|
48
|
-
};
|
|
49
|
-
from: {
|
|
50
|
-
id: number;
|
|
51
|
-
};
|
|
52
|
-
new_chat_member: {
|
|
53
|
-
status: string;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
export interface InlineButton {
|
|
58
|
-
text: string;
|
|
59
|
-
callback_data: string;
|
|
60
|
-
}
|
|
61
|
-
/** Incoming message with chat context. */
|
|
62
|
-
export interface TelegramMessage {
|
|
63
|
-
text: string;
|
|
64
|
-
chatId: number;
|
|
65
|
-
chatType: "private" | "group" | "supergroup" | "channel";
|
|
66
|
-
chatTitle?: string;
|
|
67
|
-
}
|
|
68
|
-
/** Incoming voice note with chat context. */
|
|
69
|
-
export interface TelegramVoiceMessage {
|
|
70
|
-
fileId: string;
|
|
71
|
-
duration: number;
|
|
72
|
-
chatId: number;
|
|
73
|
-
chatType: "private" | "group" | "supergroup" | "channel";
|
|
74
|
-
chatTitle?: string;
|
|
75
|
-
}
|
|
76
|
-
export declare class TelegramBot {
|
|
77
|
-
private token;
|
|
78
|
-
private allowedUserId;
|
|
79
|
-
private offset;
|
|
80
|
-
private running;
|
|
81
|
-
private onMessage;
|
|
82
|
-
private onVoiceMessage;
|
|
83
|
-
private onCallback;
|
|
84
|
-
private onBotAdded;
|
|
85
|
-
private onBotRemoved;
|
|
86
|
-
constructor(config: TelegramConfig);
|
|
87
|
-
/** Register handler for incoming text messages. */
|
|
88
|
-
onText(handler: (msg: TelegramMessage) => void): void;
|
|
89
|
-
/** Register handler for incoming voice notes. */
|
|
90
|
-
onVoice(handler: (msg: TelegramVoiceMessage) => void): void;
|
|
91
|
-
/** Register handler for inline keyboard button presses. */
|
|
92
|
-
onCallbackQuery(handler: (data: string, chatId: number) => void): void;
|
|
93
|
-
/** Register handler for when the bot is added to a group. */
|
|
94
|
-
onAddedToGroup(handler: (chatId: number, chatTitle?: string) => void): void;
|
|
95
|
-
/** Register handler for when the bot is removed from a group. */
|
|
96
|
-
onRemovedFromGroup(handler: (chatId: number) => void): void;
|
|
97
|
-
/** Start long polling. Blocks until stop() is called. */
|
|
98
|
-
start(): Promise<void>;
|
|
99
|
-
/** Stop long polling. */
|
|
100
|
-
stop(): void;
|
|
101
|
-
/** Send a text message to a specific chat. Converts markdown and splits long messages. */
|
|
102
|
-
send(chatId: number, text: string, buttons?: InlineButton[][]): Promise<void>;
|
|
103
|
-
/** Send a plain text message (no markdown parsing) to a specific chat. */
|
|
104
|
-
sendPlain(chatId: number, text: string): Promise<void>;
|
|
105
|
-
/** Send a typing indicator to a specific chat. */
|
|
106
|
-
sendTyping(chatId: number): Promise<void>;
|
|
107
|
-
/** Get a direct download URL for a Telegram file. */
|
|
108
|
-
getFileUrl(fileId: string): Promise<string>;
|
|
109
|
-
private getUpdates;
|
|
110
|
-
private handleUpdate;
|
|
111
|
-
private apiCall;
|
|
112
|
-
}
|
|
1
|
+
export { TelegramBot, type TelegramConfig, type TelegramUpdate, type InlineButton, type TelegramMessage, type TelegramVoiceMessage, } from "@kenkaiiii/gg-core";
|
|
113
2
|
//# sourceMappingURL=telegram.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telegram.d.ts","sourceRoot":"","sources":["../../src/core/telegram.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"telegram.d.ts","sourceRoot":"","sources":["../../src/core/telegram.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,oBAAoB,GAC1B,MAAM,oBAAoB,CAAC"}
|
package/dist/core/telegram.js
CHANGED
|
@@ -1,252 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Supports long polling, markdown messages, inline keyboards, and message splitting.
|
|
4
|
-
*/
|
|
5
|
-
const TELEGRAM_API = "https://api.telegram.org";
|
|
6
|
-
const MAX_MESSAGE_LENGTH = 4096;
|
|
7
|
-
export class TelegramBot {
|
|
8
|
-
token;
|
|
9
|
-
allowedUserId;
|
|
10
|
-
offset = 0;
|
|
11
|
-
running = false;
|
|
12
|
-
onMessage = null;
|
|
13
|
-
onVoiceMessage = null;
|
|
14
|
-
onCallback = null;
|
|
15
|
-
onBotAdded = null;
|
|
16
|
-
onBotRemoved = null;
|
|
17
|
-
constructor(config) {
|
|
18
|
-
this.token = config.botToken;
|
|
19
|
-
this.allowedUserId = config.allowedUserId;
|
|
20
|
-
}
|
|
21
|
-
/** Register handler for incoming text messages. */
|
|
22
|
-
onText(handler) {
|
|
23
|
-
this.onMessage = handler;
|
|
24
|
-
}
|
|
25
|
-
/** Register handler for incoming voice notes. */
|
|
26
|
-
onVoice(handler) {
|
|
27
|
-
this.onVoiceMessage = handler;
|
|
28
|
-
}
|
|
29
|
-
/** Register handler for inline keyboard button presses. */
|
|
30
|
-
onCallbackQuery(handler) {
|
|
31
|
-
this.onCallback = handler;
|
|
32
|
-
}
|
|
33
|
-
/** Register handler for when the bot is added to a group. */
|
|
34
|
-
onAddedToGroup(handler) {
|
|
35
|
-
this.onBotAdded = handler;
|
|
36
|
-
}
|
|
37
|
-
/** Register handler for when the bot is removed from a group. */
|
|
38
|
-
onRemovedFromGroup(handler) {
|
|
39
|
-
this.onBotRemoved = handler;
|
|
40
|
-
}
|
|
41
|
-
/** Start long polling. Blocks until stop() is called. */
|
|
42
|
-
async start() {
|
|
43
|
-
this.running = true;
|
|
44
|
-
// Verify bot token works
|
|
45
|
-
const me = await this.apiCall("getMe");
|
|
46
|
-
if (!me.ok) {
|
|
47
|
-
throw new Error(`Invalid bot token: ${JSON.stringify(me)}`);
|
|
48
|
-
}
|
|
49
|
-
while (this.running) {
|
|
50
|
-
try {
|
|
51
|
-
const updates = await this.getUpdates();
|
|
52
|
-
for (const update of updates) {
|
|
53
|
-
await this.handleUpdate(update);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
catch (err) {
|
|
57
|
-
if (!this.running)
|
|
58
|
-
break;
|
|
59
|
-
console.error(`[telegram] Poll error: ${err instanceof Error ? err.message : err}`);
|
|
60
|
-
await sleep(3000);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/** Stop long polling. */
|
|
65
|
-
stop() {
|
|
66
|
-
this.running = false;
|
|
67
|
-
}
|
|
68
|
-
/** Send a text message to a specific chat. Converts markdown and splits long messages. */
|
|
69
|
-
async send(chatId, text, buttons) {
|
|
70
|
-
const converted = toTelegramMarkdown(text);
|
|
71
|
-
const chunks = splitMessage(converted);
|
|
72
|
-
for (let i = 0; i < chunks.length; i++) {
|
|
73
|
-
const isLast = i === chunks.length - 1;
|
|
74
|
-
const replyMarkup = isLast && buttons
|
|
75
|
-
? {
|
|
76
|
-
inline_keyboard: buttons.map((row) => row.map((b) => ({ text: b.text, callback_data: b.callback_data }))),
|
|
77
|
-
}
|
|
78
|
-
: undefined;
|
|
79
|
-
await this.apiCall("sendMessage", {
|
|
80
|
-
chat_id: chatId,
|
|
81
|
-
text: chunks[i],
|
|
82
|
-
parse_mode: "Markdown",
|
|
83
|
-
...(replyMarkup ? { reply_markup: replyMarkup } : {}),
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/** Send a plain text message (no markdown parsing) to a specific chat. */
|
|
88
|
-
async sendPlain(chatId, text) {
|
|
89
|
-
const chunks = splitMessage(text);
|
|
90
|
-
for (const chunk of chunks) {
|
|
91
|
-
await this.apiCall("sendMessage", {
|
|
92
|
-
chat_id: chatId,
|
|
93
|
-
text: chunk,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/** Send a typing indicator to a specific chat. */
|
|
98
|
-
async sendTyping(chatId) {
|
|
99
|
-
await this.apiCall("sendChatAction", {
|
|
100
|
-
chat_id: chatId,
|
|
101
|
-
action: "typing",
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
/** Get a direct download URL for a Telegram file. */
|
|
105
|
-
async getFileUrl(fileId) {
|
|
106
|
-
const result = await this.apiCall("getFile", { file_id: fileId });
|
|
107
|
-
if (!result.ok)
|
|
108
|
-
throw new Error(`Failed to get file: ${JSON.stringify(result)}`);
|
|
109
|
-
const filePath = result.result.file_path;
|
|
110
|
-
return `${TELEGRAM_API}/file/bot${this.token}/${filePath}`;
|
|
111
|
-
}
|
|
112
|
-
// ── Private ───────────────────────────────────────────
|
|
113
|
-
async getUpdates() {
|
|
114
|
-
const result = await this.apiCall("getUpdates", {
|
|
115
|
-
offset: this.offset,
|
|
116
|
-
timeout: 30,
|
|
117
|
-
allowed_updates: ["message", "callback_query", "my_chat_member"],
|
|
118
|
-
});
|
|
119
|
-
if (!result.ok || !Array.isArray(result.result))
|
|
120
|
-
return [];
|
|
121
|
-
const updates = result.result;
|
|
122
|
-
if (updates.length > 0) {
|
|
123
|
-
this.offset = updates[updates.length - 1].update_id + 1;
|
|
124
|
-
}
|
|
125
|
-
return updates;
|
|
126
|
-
}
|
|
127
|
-
async handleUpdate(update) {
|
|
128
|
-
if (update.message) {
|
|
129
|
-
const msg = update.message;
|
|
130
|
-
// Auth check
|
|
131
|
-
if (msg.from.id !== this.allowedUserId) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
if (msg.text && this.onMessage) {
|
|
135
|
-
this.onMessage({
|
|
136
|
-
text: msg.text,
|
|
137
|
-
chatId: msg.chat.id,
|
|
138
|
-
chatType: msg.chat.type,
|
|
139
|
-
chatTitle: msg.chat.title,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
else if (msg.voice && this.onVoiceMessage) {
|
|
143
|
-
this.onVoiceMessage({
|
|
144
|
-
fileId: msg.voice.file_id,
|
|
145
|
-
duration: msg.voice.duration,
|
|
146
|
-
chatId: msg.chat.id,
|
|
147
|
-
chatType: msg.chat.type,
|
|
148
|
-
chatTitle: msg.chat.title,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
// Bot membership changed in a group
|
|
153
|
-
if (update.my_chat_member) {
|
|
154
|
-
const member = update.my_chat_member;
|
|
155
|
-
const status = member.new_chat_member.status;
|
|
156
|
-
if ((status === "member" || status === "administrator") && this.onBotAdded) {
|
|
157
|
-
this.onBotAdded(member.chat.id, member.chat.title);
|
|
158
|
-
}
|
|
159
|
-
else if ((status === "left" || status === "kicked") && this.onBotRemoved) {
|
|
160
|
-
this.onBotRemoved(member.chat.id);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
if (update.callback_query) {
|
|
164
|
-
const cb = update.callback_query;
|
|
165
|
-
if (cb.from.id !== this.allowedUserId)
|
|
166
|
-
return;
|
|
167
|
-
await this.apiCall("answerCallbackQuery", { callback_query_id: cb.id });
|
|
168
|
-
if (cb.data && this.onCallback) {
|
|
169
|
-
this.onCallback(cb.data, cb.message.chat.id);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
async apiCall(method, body) {
|
|
174
|
-
const url = `${TELEGRAM_API}/bot${this.token}/${method}`;
|
|
175
|
-
const response = await fetch(url, {
|
|
176
|
-
method: "POST",
|
|
177
|
-
headers: { "Content-Type": "application/json" },
|
|
178
|
-
body: body ? JSON.stringify(body) : undefined,
|
|
179
|
-
});
|
|
180
|
-
if (!response.ok) {
|
|
181
|
-
return { ok: false };
|
|
182
|
-
}
|
|
183
|
-
return response.json();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
// ── Markdown Conversion ──────────────────────────────────
|
|
187
|
-
/**
|
|
188
|
-
* Convert GitHub-flavored markdown to Telegram-compatible Markdown.
|
|
189
|
-
*
|
|
190
|
-
* Telegram supports: *bold*, _italic_, `code`, ```pre```, [link](url)
|
|
191
|
-
* Does NOT support: headings, horizontal rules, tables, HTML tags, images
|
|
192
|
-
*/
|
|
193
|
-
function toTelegramMarkdown(text) {
|
|
194
|
-
const lines = text.split("\n");
|
|
195
|
-
const result = [];
|
|
196
|
-
let inCodeBlock = false;
|
|
197
|
-
for (const line of lines) {
|
|
198
|
-
if (line.trimStart().startsWith("```")) {
|
|
199
|
-
inCodeBlock = !inCodeBlock;
|
|
200
|
-
result.push(line);
|
|
201
|
-
continue;
|
|
202
|
-
}
|
|
203
|
-
if (inCodeBlock) {
|
|
204
|
-
result.push(line);
|
|
205
|
-
continue;
|
|
206
|
-
}
|
|
207
|
-
let transformed = line;
|
|
208
|
-
// Headings → bold text
|
|
209
|
-
const headingMatch = transformed.match(/^(#{1,6})\s+(.+)$/);
|
|
210
|
-
if (headingMatch) {
|
|
211
|
-
transformed = `*${headingMatch[2]}*`;
|
|
212
|
-
result.push(transformed);
|
|
213
|
-
continue;
|
|
214
|
-
}
|
|
215
|
-
// Horizontal rules → empty line
|
|
216
|
-
if (/^(-{3,}|_{3,}|\*{3,})$/.test(transformed.trim())) {
|
|
217
|
-
result.push("");
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
// **bold** → *bold*
|
|
221
|
-
transformed = transformed.replace(/\*\*(.+?)\*\*/g, "*$1*");
|
|
222
|
-
result.push(transformed);
|
|
223
|
-
}
|
|
224
|
-
return result.join("\n");
|
|
225
|
-
}
|
|
226
|
-
// ── Helpers ───────────────────────────────────────────────
|
|
227
|
-
function splitMessage(text) {
|
|
228
|
-
if (text.length <= MAX_MESSAGE_LENGTH)
|
|
229
|
-
return [text];
|
|
230
|
-
const chunks = [];
|
|
231
|
-
let remaining = text;
|
|
232
|
-
while (remaining.length > 0) {
|
|
233
|
-
if (remaining.length <= MAX_MESSAGE_LENGTH) {
|
|
234
|
-
chunks.push(remaining);
|
|
235
|
-
break;
|
|
236
|
-
}
|
|
237
|
-
let splitAt = remaining.lastIndexOf("\n", MAX_MESSAGE_LENGTH);
|
|
238
|
-
if (splitAt === -1 || splitAt < MAX_MESSAGE_LENGTH * 0.5) {
|
|
239
|
-
splitAt = remaining.lastIndexOf(" ", MAX_MESSAGE_LENGTH);
|
|
240
|
-
}
|
|
241
|
-
if (splitAt === -1 || splitAt < MAX_MESSAGE_LENGTH * 0.5) {
|
|
242
|
-
splitAt = MAX_MESSAGE_LENGTH;
|
|
243
|
-
}
|
|
244
|
-
chunks.push(remaining.slice(0, splitAt));
|
|
245
|
-
remaining = remaining.slice(splitAt).trimStart();
|
|
246
|
-
}
|
|
247
|
-
return chunks;
|
|
248
|
-
}
|
|
249
|
-
function sleep(ms) {
|
|
250
|
-
return new Promise((r) => setTimeout(r, ms));
|
|
251
|
-
}
|
|
1
|
+
// Moved to @kenkaiiii/gg-core. Shim keeps `../core/telegram.js` imports working.
|
|
2
|
+
export { TelegramBot, } from "@kenkaiiii/gg-core";
|
|
252
3
|
//# sourceMappingURL=telegram.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telegram.js","sourceRoot":"","sources":["../../src/core/telegram.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"telegram.js","sourceRoot":"","sources":["../../src/core/telegram.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,OAAO,EACL,WAAW,GAMZ,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function getSupportedThinkingLevels(provider: Provider, model: string): readonly ThinkingLevel[];
|
|
3
|
-
export declare function isThinkingLevelSupported(provider: Provider, model: string, level: ThinkingLevel): boolean;
|
|
4
|
-
export declare function getNextThinkingLevel(provider: Provider, model: string, current: ThinkingLevel | undefined): ThinkingLevel | undefined;
|
|
1
|
+
export { getSupportedThinkingLevels, isThinkingLevelSupported, getNextThinkingLevel, } from "@kenkaiiii/gg-core";
|
|
5
2
|
//# sourceMappingURL=thinking-level.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinking-level.d.ts","sourceRoot":"","sources":["../../src/core/thinking-level.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"thinking-level.d.ts","sourceRoot":"","sources":["../../src/core/thinking-level.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,59 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"low",
|
|
5
|
-
"medium",
|
|
6
|
-
"high",
|
|
7
|
-
"xhigh",
|
|
8
|
-
"max",
|
|
9
|
-
];
|
|
10
|
-
const ANTHROPIC_ADAPTIVE_THINKING_LEVELS = [
|
|
11
|
-
"low",
|
|
12
|
-
"medium",
|
|
13
|
-
"high",
|
|
14
|
-
"max",
|
|
15
|
-
];
|
|
16
|
-
function isOpenAIGptModel(provider, model) {
|
|
17
|
-
return provider === "openai" && model.startsWith("gpt-");
|
|
18
|
-
}
|
|
19
|
-
function isAnthropicOpus48Or47Model(provider, model) {
|
|
20
|
-
return provider === "anthropic" && /opus-4-8|opus-4-7/.test(model);
|
|
21
|
-
}
|
|
22
|
-
function isAnthropicAdaptiveModel(provider, model) {
|
|
23
|
-
return provider === "anthropic" && /opus-4-8|opus-4-7|opus-4-6|sonnet-4-6/.test(model);
|
|
24
|
-
}
|
|
25
|
-
export function getSupportedThinkingLevels(provider, model) {
|
|
26
|
-
const maxLevel = getMaxThinkingLevel(model);
|
|
27
|
-
if (isAnthropicAdaptiveModel(provider, model)) {
|
|
28
|
-
const levels = isAnthropicOpus48Or47Model(provider, model)
|
|
29
|
-
? ANTHROPIC_OPUS_48_47_THINKING_LEVELS
|
|
30
|
-
: ANTHROPIC_ADAPTIVE_THINKING_LEVELS;
|
|
31
|
-
const maxIndex = levels.indexOf(maxLevel);
|
|
32
|
-
if (maxIndex === -1)
|
|
33
|
-
return ["low", "medium", "high"];
|
|
34
|
-
return levels.slice(0, maxIndex + 1);
|
|
35
|
-
}
|
|
36
|
-
if (!isOpenAIGptModel(provider, model))
|
|
37
|
-
return [maxLevel];
|
|
38
|
-
const maxIndex = OPENAI_GPT_THINKING_LEVELS.indexOf(maxLevel);
|
|
39
|
-
if (maxIndex === -1)
|
|
40
|
-
return ["medium"];
|
|
41
|
-
return OPENAI_GPT_THINKING_LEVELS.slice(0, maxIndex + 1);
|
|
42
|
-
}
|
|
43
|
-
export function isThinkingLevelSupported(provider, model, level) {
|
|
44
|
-
return getSupportedThinkingLevels(provider, model).includes(level);
|
|
45
|
-
}
|
|
46
|
-
export function getNextThinkingLevel(provider, model, current) {
|
|
47
|
-
const supportedLevels = getSupportedThinkingLevels(provider, model);
|
|
48
|
-
const shouldCycleLevels = isOpenAIGptModel(provider, model) || isAnthropicAdaptiveModel(provider, model);
|
|
49
|
-
if (!shouldCycleLevels) {
|
|
50
|
-
return current ? undefined : supportedLevels[0];
|
|
51
|
-
}
|
|
52
|
-
if (!current)
|
|
53
|
-
return supportedLevels[0];
|
|
54
|
-
const index = supportedLevels.indexOf(current);
|
|
55
|
-
if (index === -1)
|
|
56
|
-
return supportedLevels[0];
|
|
57
|
-
return supportedLevels[index + 1];
|
|
58
|
-
}
|
|
1
|
+
// Moved to @kenkaiiii/gg-core. This shim re-exports it so existing relative
|
|
2
|
+
// imports (`./thinking-level.js`) keep resolving unchanged.
|
|
3
|
+
export { getSupportedThinkingLevels, isThinkingLevelSupported, getNextThinkingLevel, } from "@kenkaiiii/gg-core";
|
|
59
4
|
//# sourceMappingURL=thinking-level.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinking-level.js","sourceRoot":"","sources":["../../src/core/thinking-level.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"thinking-level.js","sourceRoot":"","sources":["../../src/core/thinking-level.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4DAA4D;AAC5D,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,33 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Voice note transcription using local Whisper model.
|
|
3
|
-
* Uses @huggingface/transformers (pure JS/WASM) — no native deps, no API keys.
|
|
4
|
-
* Model (~75MB) is downloaded on first use and cached locally.
|
|
5
|
-
*/
|
|
6
|
-
/** Optional callback for model download progress. */
|
|
7
|
-
export type ProgressCallback = (info: {
|
|
8
|
-
status: string;
|
|
9
|
-
progress?: number;
|
|
10
|
-
file?: string;
|
|
11
|
-
}) => void;
|
|
12
|
-
/** Set a callback to receive model download progress updates. */
|
|
13
|
-
export declare function setProgressCallback(cb: ProgressCallback | null): void;
|
|
14
|
-
/**
|
|
15
|
-
* Resample audio from one sample rate to another using linear interpolation.
|
|
16
|
-
*/
|
|
17
|
-
export declare function resample(audio: Float32Array, fromRate: number, toRate: number): Float32Array;
|
|
18
|
-
/**
|
|
19
|
-
* Downmix multi-channel audio to mono by averaging all channels.
|
|
20
|
-
*/
|
|
21
|
-
export declare function downmixToMono(channelData: Float32Array[]): Float32Array;
|
|
22
|
-
/**
|
|
23
|
-
* Decode OGG Opus audio buffer to 16kHz mono PCM Float32Array.
|
|
24
|
-
*/
|
|
25
|
-
export declare function decodeOggOpus(buffer: Uint8Array): Promise<Float32Array>;
|
|
26
|
-
/** Whether the model has been loaded already. */
|
|
27
|
-
export declare function isModelLoaded(): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Transcribe a voice message from its Telegram file URL.
|
|
30
|
-
* Downloads the OGG Opus file, decodes to PCM, and runs Whisper locally.
|
|
31
|
-
*/
|
|
32
|
-
export declare function transcribeVoice(fileUrl: string): Promise<string>;
|
|
1
|
+
export { setProgressCallback, resample, downmixToMono, decodeOggOpus, isModelLoaded, transcribeVoice, type ProgressCallback, } from "@kenkaiiii/gg-core";
|
|
33
2
|
//# sourceMappingURL=voice-transcriber.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voice-transcriber.d.ts","sourceRoot":"","sources":["../../src/core/voice-transcriber.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"voice-transcriber.d.ts","sourceRoot":"","sources":["../../src/core/voice-transcriber.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,QAAQ,EACR,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EACf,KAAK,gBAAgB,GACtB,MAAM,oBAAoB,CAAC"}
|