teleton 0.7.4 → 0.8.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/README.md +43 -30
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/{chunk-U7FQYCBQ.js → chunk-7TECSLJ4.js} +2 -2
- package/dist/{chunk-LAQOUFOJ.js → chunk-H36RFKRI.js} +7583 -11185
- package/dist/{chunk-RO62LO6Z.js → chunk-IJBWWQE4.js} +4 -0
- package/dist/{chunk-BGC2IUM5.js → chunk-JHYZYFZJ.js} +69 -20
- package/dist/{chunk-QOQWUUA4.js → chunk-OJCLKU5Z.js} +68 -2
- package/dist/{chunk-OCLG5GKI.js → chunk-P36I6OIV.js} +2 -2
- package/dist/chunk-PHSAHTK4.js +314 -0
- package/dist/{chunk-5PLZ3KSO.js → chunk-QVBSUYVX.js} +14 -42
- package/dist/{chunk-4DU3C27M.js → chunk-R4YSJ4EY.js} +5 -1
- package/dist/chunk-RQBAMUCV.js +10281 -0
- package/dist/{chunk-XDYDA2KV.js → chunk-SD4NLLYG.js} +293 -64
- package/dist/chunk-TVRZJIZX.js +292 -0
- package/dist/{chunk-EK7M5K26.js → chunk-U56QTM46.js} +3 -3
- package/dist/{chunk-XBKSS6DM.js → chunk-VFA7QMCZ.js} +5 -3
- package/dist/{chunk-VAUJSSD3.js → chunk-XQUHC3JZ.js} +1 -1
- package/dist/cli/index.js +96 -33
- package/dist/{client-RTNALK7W.js → client-LNZTDQSA.js} +6 -7
- package/dist/{get-my-gifts-TPVUGUWT.js → get-my-gifts-OMGKOEPM.js} +1 -1
- package/dist/index.js +15 -17
- package/dist/{memory-JQZ6MTRU.js → memory-AS7WKGTW.js} +7 -8
- package/dist/{migrate-GS5ACQDA.js → migrate-POHWYEIW.js} +7 -8
- package/dist/{multipart-parser-S3YC6NRJ.js → multipart-parser-UFQLJOV2.js} +2 -2
- package/dist/{paths-TMNTEDDD.js → paths-XA2RJH4S.js} +1 -1
- package/dist/{server-TCJOBV3D.js → server-H3QA252W.js} +39 -12
- package/dist/{setup-server-YHYJLAMA.js → setup-server-QXED3D2L.js} +24 -12
- package/dist/store-GAFULOOX.js +34 -0
- package/dist/{task-dependency-resolver-WKZWJLLM.js → task-dependency-resolver-3FIKQ7Z6.js} +3 -3
- package/dist/{task-executor-PD3H4MLO.js → task-executor-RUTFG6VG.js} +2 -2
- package/dist/{tasks-QSCWSMPS.js → tasks-BEZ4QRI2.js} +1 -1
- package/dist/{tool-adapter-Y3TCEQOC.js → tool-adapter-IH5VGBOO.js} +1 -1
- package/dist/{tool-index-6HBRVXVG.js → tool-index-H3SHOJC3.js} +6 -6
- package/dist/{transcript-UDJZP6NK.js → transcript-IMNE6KU3.js} +2 -2
- package/dist/web/assets/index-BrVqauzj.css +1 -0
- package/dist/web/assets/index-DYeEkvJ6.js +72 -0
- package/dist/web/assets/{index.es-CqZHj0tz.js → index.es-DkU1GvWU.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +2 -2
- package/dist/BigInteger-DQ33LTTE.js +0 -5
- package/dist/chunk-JQDLW7IE.js +0 -107
- package/dist/chunk-QGM4M3NI.js +0 -37
- package/dist/chunk-RMLQS3X6.js +0 -161
- package/dist/chunk-TSKJCWQQ.js +0 -1263
- package/dist/chunk-UCN6TI25.js +0 -143
- package/dist/chunk-YFG2QHLA.js +0 -3585
- package/dist/web/assets/index-B6M9knfJ.css +0 -1
- package/dist/web/assets/index-DAGeQfVZ.js +0 -72
- package/scripts/patch-gramjs.sh +0 -46
- package/scripts/postinstall.mjs +0 -16
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getDatabase
|
|
3
|
+
} from "./chunk-SD4NLLYG.js";
|
|
4
|
+
import {
|
|
5
|
+
createLogger
|
|
6
|
+
} from "./chunk-RCMD3U65.js";
|
|
7
|
+
|
|
8
|
+
// src/session/store.ts
|
|
9
|
+
import { randomUUID } from "crypto";
|
|
10
|
+
var log = createLogger("Session");
|
|
11
|
+
function getDb() {
|
|
12
|
+
return getDatabase().getDb();
|
|
13
|
+
}
|
|
14
|
+
function rowToSession(row) {
|
|
15
|
+
return {
|
|
16
|
+
sessionId: row.id,
|
|
17
|
+
chatId: row.chat_id,
|
|
18
|
+
createdAt: row.started_at,
|
|
19
|
+
updatedAt: row.updated_at,
|
|
20
|
+
messageCount: row.message_count || 0,
|
|
21
|
+
lastMessageId: row.last_message_id ?? void 0,
|
|
22
|
+
lastChannel: row.last_channel ?? void 0,
|
|
23
|
+
lastTo: row.last_to ?? void 0,
|
|
24
|
+
contextTokens: row.context_tokens ?? void 0,
|
|
25
|
+
model: row.model ?? void 0,
|
|
26
|
+
provider: row.provider ?? void 0,
|
|
27
|
+
lastResetDate: row.last_reset_date ?? void 0,
|
|
28
|
+
inputTokens: row.input_tokens ?? void 0,
|
|
29
|
+
outputTokens: row.output_tokens ?? void 0
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function loadSessionStore() {
|
|
33
|
+
try {
|
|
34
|
+
const db = getDb();
|
|
35
|
+
const rows = db.prepare("SELECT * FROM sessions").all();
|
|
36
|
+
const store = {};
|
|
37
|
+
for (const row of rows) {
|
|
38
|
+
const sessionKey = row.chat_id;
|
|
39
|
+
store[sessionKey] = rowToSession(row);
|
|
40
|
+
}
|
|
41
|
+
return store;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
log.warn({ err: error }, "Failed to load sessions from database");
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function saveSessionStore(store) {
|
|
48
|
+
try {
|
|
49
|
+
const db = getDb();
|
|
50
|
+
const insertStmt = db.prepare(`
|
|
51
|
+
INSERT INTO sessions (
|
|
52
|
+
id, chat_id, started_at, updated_at, message_count,
|
|
53
|
+
last_message_id, last_channel, last_to, context_tokens,
|
|
54
|
+
model, provider, last_reset_date, input_tokens, output_tokens
|
|
55
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
56
|
+
`);
|
|
57
|
+
db.transaction(() => {
|
|
58
|
+
db.prepare("DELETE FROM sessions").run();
|
|
59
|
+
for (const [chatId, session] of Object.entries(store)) {
|
|
60
|
+
insertStmt.run(
|
|
61
|
+
session.sessionId,
|
|
62
|
+
chatId,
|
|
63
|
+
session.createdAt,
|
|
64
|
+
session.updatedAt,
|
|
65
|
+
session.messageCount,
|
|
66
|
+
session.lastMessageId,
|
|
67
|
+
session.lastChannel,
|
|
68
|
+
session.lastTo,
|
|
69
|
+
session.contextTokens,
|
|
70
|
+
session.model,
|
|
71
|
+
session.provider,
|
|
72
|
+
session.lastResetDate,
|
|
73
|
+
session.inputTokens ?? 0,
|
|
74
|
+
session.outputTokens ?? 0
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
})();
|
|
78
|
+
} catch (error) {
|
|
79
|
+
log.error({ err: error }, "Failed to save sessions to database");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function getOrCreateSession(chatId) {
|
|
83
|
+
const db = getDb();
|
|
84
|
+
const sessionKey = `telegram:${chatId}`;
|
|
85
|
+
const row = db.prepare("SELECT * FROM sessions WHERE chat_id = ?").get(sessionKey);
|
|
86
|
+
if (row) {
|
|
87
|
+
return rowToSession(row);
|
|
88
|
+
}
|
|
89
|
+
const now = Date.now();
|
|
90
|
+
const newSession = {
|
|
91
|
+
sessionId: randomUUID(),
|
|
92
|
+
chatId,
|
|
93
|
+
createdAt: now,
|
|
94
|
+
updatedAt: now,
|
|
95
|
+
messageCount: 0,
|
|
96
|
+
lastChannel: "telegram",
|
|
97
|
+
lastTo: chatId
|
|
98
|
+
};
|
|
99
|
+
db.prepare(
|
|
100
|
+
`
|
|
101
|
+
INSERT INTO sessions (
|
|
102
|
+
id, chat_id, started_at, updated_at, message_count, last_channel, last_to
|
|
103
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
104
|
+
`
|
|
105
|
+
).run(
|
|
106
|
+
newSession.sessionId,
|
|
107
|
+
sessionKey,
|
|
108
|
+
newSession.createdAt,
|
|
109
|
+
newSession.updatedAt,
|
|
110
|
+
newSession.messageCount,
|
|
111
|
+
newSession.lastChannel,
|
|
112
|
+
newSession.lastTo
|
|
113
|
+
);
|
|
114
|
+
log.info(`New session created: ${newSession.sessionId} for chat ${chatId}`);
|
|
115
|
+
return newSession;
|
|
116
|
+
}
|
|
117
|
+
function updateSession(chatId, update) {
|
|
118
|
+
const db = getDb();
|
|
119
|
+
const sessionKey = `telegram:${chatId}`;
|
|
120
|
+
const existing = db.prepare("SELECT * FROM sessions WHERE chat_id = ?").get(sessionKey);
|
|
121
|
+
if (!existing) {
|
|
122
|
+
return getOrCreateSession(chatId);
|
|
123
|
+
}
|
|
124
|
+
const updates = [];
|
|
125
|
+
const values = [];
|
|
126
|
+
if (update.sessionId !== void 0) {
|
|
127
|
+
updates.push("id = ?");
|
|
128
|
+
values.push(update.sessionId);
|
|
129
|
+
}
|
|
130
|
+
if (update.messageCount !== void 0) {
|
|
131
|
+
updates.push("message_count = ?");
|
|
132
|
+
values.push(update.messageCount);
|
|
133
|
+
}
|
|
134
|
+
if (update.lastMessageId !== void 0) {
|
|
135
|
+
updates.push("last_message_id = ?");
|
|
136
|
+
values.push(update.lastMessageId);
|
|
137
|
+
}
|
|
138
|
+
if (update.lastChannel !== void 0) {
|
|
139
|
+
updates.push("last_channel = ?");
|
|
140
|
+
values.push(update.lastChannel);
|
|
141
|
+
}
|
|
142
|
+
if (update.lastTo !== void 0) {
|
|
143
|
+
updates.push("last_to = ?");
|
|
144
|
+
values.push(update.lastTo);
|
|
145
|
+
}
|
|
146
|
+
if (update.contextTokens !== void 0) {
|
|
147
|
+
updates.push("context_tokens = ?");
|
|
148
|
+
values.push(update.contextTokens);
|
|
149
|
+
}
|
|
150
|
+
if (update.model !== void 0) {
|
|
151
|
+
updates.push("model = ?");
|
|
152
|
+
values.push(update.model);
|
|
153
|
+
}
|
|
154
|
+
if (update.provider !== void 0) {
|
|
155
|
+
updates.push("provider = ?");
|
|
156
|
+
values.push(update.provider);
|
|
157
|
+
}
|
|
158
|
+
if (update.lastResetDate !== void 0) {
|
|
159
|
+
updates.push("last_reset_date = ?");
|
|
160
|
+
values.push(update.lastResetDate);
|
|
161
|
+
}
|
|
162
|
+
if (update.inputTokens !== void 0) {
|
|
163
|
+
updates.push("input_tokens = ?");
|
|
164
|
+
values.push(update.inputTokens);
|
|
165
|
+
}
|
|
166
|
+
if (update.outputTokens !== void 0) {
|
|
167
|
+
updates.push("output_tokens = ?");
|
|
168
|
+
values.push(update.outputTokens);
|
|
169
|
+
}
|
|
170
|
+
updates.push("updated_at = ?");
|
|
171
|
+
values.push(Date.now());
|
|
172
|
+
values.push(sessionKey);
|
|
173
|
+
db.prepare(
|
|
174
|
+
`
|
|
175
|
+
UPDATE sessions
|
|
176
|
+
SET ${updates.join(", ")}
|
|
177
|
+
WHERE chat_id = ?
|
|
178
|
+
`
|
|
179
|
+
).run(...values);
|
|
180
|
+
const updated = db.prepare("SELECT * FROM sessions WHERE chat_id = ?").get(sessionKey);
|
|
181
|
+
return rowToSession(updated);
|
|
182
|
+
}
|
|
183
|
+
function incrementMessageCount(chatId) {
|
|
184
|
+
const db = getDb();
|
|
185
|
+
const sessionKey = `telegram:${chatId}`;
|
|
186
|
+
const result = db.prepare(
|
|
187
|
+
`UPDATE sessions SET message_count = message_count + 1, updated_at = ? WHERE chat_id = ?`
|
|
188
|
+
).run(Date.now(), sessionKey);
|
|
189
|
+
if (result.changes === 0) {
|
|
190
|
+
getOrCreateSession(chatId);
|
|
191
|
+
db.prepare(
|
|
192
|
+
`UPDATE sessions SET message_count = message_count + 1, updated_at = ? WHERE chat_id = ?`
|
|
193
|
+
).run(Date.now(), sessionKey);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function getSession(chatId) {
|
|
197
|
+
const db = getDb();
|
|
198
|
+
const sessionKey = `telegram:${chatId}`;
|
|
199
|
+
const row = db.prepare("SELECT * FROM sessions WHERE chat_id = ?").get(sessionKey);
|
|
200
|
+
return row ? rowToSession(row) : null;
|
|
201
|
+
}
|
|
202
|
+
function resetSession(chatId) {
|
|
203
|
+
const oldSession = getSession(chatId);
|
|
204
|
+
const now = Date.now();
|
|
205
|
+
const newSession = {
|
|
206
|
+
sessionId: randomUUID(),
|
|
207
|
+
chatId,
|
|
208
|
+
createdAt: now,
|
|
209
|
+
updatedAt: now,
|
|
210
|
+
messageCount: 0,
|
|
211
|
+
lastChannel: oldSession?.lastChannel || "telegram",
|
|
212
|
+
lastTo: oldSession?.lastTo || chatId,
|
|
213
|
+
contextTokens: oldSession?.contextTokens,
|
|
214
|
+
model: oldSession?.model,
|
|
215
|
+
provider: oldSession?.provider
|
|
216
|
+
};
|
|
217
|
+
const db = getDb();
|
|
218
|
+
const sessionKey = `telegram:${chatId}`;
|
|
219
|
+
db.prepare(
|
|
220
|
+
`
|
|
221
|
+
UPDATE sessions
|
|
222
|
+
SET id = ?, started_at = ?, updated_at = ?, message_count = 0
|
|
223
|
+
WHERE chat_id = ?
|
|
224
|
+
`
|
|
225
|
+
).run(newSession.sessionId, newSession.createdAt, newSession.updatedAt, sessionKey);
|
|
226
|
+
log.info(`Session reset: ${oldSession?.sessionId} \u2192 ${newSession.sessionId}`);
|
|
227
|
+
return newSession;
|
|
228
|
+
}
|
|
229
|
+
function shouldResetSession(session, policy) {
|
|
230
|
+
const now = Date.now();
|
|
231
|
+
if (policy.daily_reset_enabled) {
|
|
232
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
233
|
+
const lastReset = session.lastResetDate || new Date(session.createdAt).toISOString().split("T")[0];
|
|
234
|
+
if (lastReset !== today) {
|
|
235
|
+
const currentHour = (/* @__PURE__ */ new Date()).getUTCHours();
|
|
236
|
+
const resetHour = policy.daily_reset_hour;
|
|
237
|
+
if (lastReset < today && currentHour >= resetHour) {
|
|
238
|
+
log.info(
|
|
239
|
+
`Daily reset triggered for session ${session.sessionId} (last reset: ${lastReset})`
|
|
240
|
+
);
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (policy.idle_expiry_enabled) {
|
|
246
|
+
const idleMs = now - session.updatedAt;
|
|
247
|
+
const idleMinutes = idleMs / (1e3 * 60);
|
|
248
|
+
const expiryMinutes = policy.idle_expiry_minutes;
|
|
249
|
+
if (idleMinutes >= expiryMinutes) {
|
|
250
|
+
log.info(
|
|
251
|
+
`Idle expiry triggered for session ${session.sessionId} (idle: ${Math.floor(idleMinutes)}m)`
|
|
252
|
+
);
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
function resetSessionWithPolicy(chatId, policy) {
|
|
259
|
+
const newSession = resetSession(chatId);
|
|
260
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
261
|
+
return updateSession(chatId, {
|
|
262
|
+
lastResetDate: today
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
function pruneOldSessions(maxAgeDays = 30) {
|
|
266
|
+
try {
|
|
267
|
+
const db = getDb();
|
|
268
|
+
const cutoffMs = Date.now() - maxAgeDays * 24 * 60 * 60 * 1e3;
|
|
269
|
+
const result = db.prepare(`DELETE FROM sessions WHERE updated_at < ? AND updated_at > 0`).run(cutoffMs);
|
|
270
|
+
const pruned = result.changes;
|
|
271
|
+
if (pruned > 0) {
|
|
272
|
+
log.info(`\u{1F5D1}\uFE0F Pruned ${pruned} session(s) older than ${maxAgeDays} days`);
|
|
273
|
+
}
|
|
274
|
+
return pruned;
|
|
275
|
+
} catch (error) {
|
|
276
|
+
log.warn({ err: error }, "Failed to prune old sessions");
|
|
277
|
+
return 0;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export {
|
|
282
|
+
loadSessionStore,
|
|
283
|
+
saveSessionStore,
|
|
284
|
+
getOrCreateSession,
|
|
285
|
+
updateSession,
|
|
286
|
+
incrementMessageCount,
|
|
287
|
+
getSession,
|
|
288
|
+
resetSession,
|
|
289
|
+
shouldResetSession,
|
|
290
|
+
resetSessionWithPolicy,
|
|
291
|
+
pruneOldSessions
|
|
292
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
VOYAGE_API_URL
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VFA7QMCZ.js";
|
|
4
4
|
import {
|
|
5
5
|
EMBEDDING_CACHE_EVICTION_INTERVAL,
|
|
6
6
|
EMBEDDING_CACHE_EVICTION_RATIO,
|
|
7
7
|
EMBEDDING_CACHE_MAX_ENTRIES,
|
|
8
8
|
EMBEDDING_CACHE_TTL_DAYS,
|
|
9
9
|
VOYAGE_BATCH_SIZE
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-IJBWWQE4.js";
|
|
11
11
|
import {
|
|
12
12
|
fetchWithTimeout
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-XQUHC3JZ.js";
|
|
14
14
|
import {
|
|
15
15
|
TELETON_ROOT
|
|
16
16
|
} from "./chunk-EYWNOHMJ.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fetchWithTimeout
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XQUHC3JZ.js";
|
|
4
4
|
|
|
5
5
|
// src/constants/api-endpoints.ts
|
|
6
6
|
var TONAPI_BASE_URL = "https://tonapi.io/v2";
|
|
@@ -15,9 +15,11 @@ function tonapiHeaders() {
|
|
|
15
15
|
}
|
|
16
16
|
return headers;
|
|
17
17
|
}
|
|
18
|
-
var
|
|
18
|
+
var TONAPI_RPS_WITH_KEY = 5;
|
|
19
|
+
var TONAPI_RPS_WITHOUT_KEY = 1;
|
|
19
20
|
var _tonapiTimestamps = [];
|
|
20
21
|
async function waitForTonapiSlot() {
|
|
22
|
+
const maxRps = _tonapiKey ? TONAPI_RPS_WITH_KEY : TONAPI_RPS_WITHOUT_KEY;
|
|
21
23
|
const clean = () => {
|
|
22
24
|
const cutoff = Date.now() - 1e3;
|
|
23
25
|
while (_tonapiTimestamps.length > 0 && _tonapiTimestamps[0] <= cutoff) {
|
|
@@ -25,7 +27,7 @@ async function waitForTonapiSlot() {
|
|
|
25
27
|
}
|
|
26
28
|
};
|
|
27
29
|
clean();
|
|
28
|
-
if (_tonapiTimestamps.length >=
|
|
30
|
+
if (_tonapiTimestamps.length >= maxRps) {
|
|
29
31
|
const waitMs = _tonapiTimestamps[0] + 1e3 - Date.now() + 50;
|
|
30
32
|
if (waitMs > 0) await new Promise((r) => setTimeout(r, waitMs));
|
|
31
33
|
clean();
|
package/dist/cli/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getModelsForProvider
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-OJCLKU5Z.js";
|
|
4
4
|
import {
|
|
5
5
|
TelegramUserClient,
|
|
6
6
|
main
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-H36RFKRI.js";
|
|
8
8
|
import "../chunk-WIKM24GZ.js";
|
|
9
|
-
import "../chunk-U7FQYCBQ.js";
|
|
10
9
|
import {
|
|
11
10
|
CONFIGURABLE_KEYS,
|
|
12
11
|
configExists,
|
|
@@ -16,7 +15,7 @@ import {
|
|
|
16
15
|
readRawConfig,
|
|
17
16
|
setNestedValue,
|
|
18
17
|
writeRawConfig
|
|
19
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-RQBAMUCV.js";
|
|
20
19
|
import {
|
|
21
20
|
ConfigSchema,
|
|
22
21
|
DealsConfigSchema,
|
|
@@ -27,39 +26,37 @@ import {
|
|
|
27
26
|
loadWallet,
|
|
28
27
|
saveWallet,
|
|
29
28
|
walletExists
|
|
30
|
-
} from "../chunk-
|
|
31
|
-
import "../chunk-
|
|
29
|
+
} from "../chunk-JHYZYFZJ.js";
|
|
30
|
+
import "../chunk-TVRZJIZX.js";
|
|
31
|
+
import "../chunk-7TECSLJ4.js";
|
|
32
32
|
import {
|
|
33
33
|
getErrorMessage
|
|
34
34
|
} from "../chunk-XBE4JB7C.js";
|
|
35
|
-
import "../chunk-
|
|
35
|
+
import "../chunk-QVBSUYVX.js";
|
|
36
36
|
import {
|
|
37
37
|
getClaudeCodeApiKey,
|
|
38
|
-
isClaudeCodeTokenValid
|
|
39
|
-
} from "../chunk-JQDLW7IE.js";
|
|
40
|
-
import {
|
|
41
38
|
getProviderMetadata,
|
|
42
39
|
getSupportedProviders,
|
|
40
|
+
isClaudeCodeTokenValid,
|
|
43
41
|
validateApiKeyFormat
|
|
44
|
-
} from "../chunk-
|
|
45
|
-
import "../chunk-
|
|
46
|
-
import "../chunk-
|
|
47
|
-
import "../chunk-
|
|
48
|
-
import "../chunk-
|
|
49
|
-
import "../chunk-XBKSS6DM.js";
|
|
42
|
+
} from "../chunk-PHSAHTK4.js";
|
|
43
|
+
import "../chunk-P36I6OIV.js";
|
|
44
|
+
import "../chunk-SD4NLLYG.js";
|
|
45
|
+
import "../chunk-U56QTM46.js";
|
|
46
|
+
import "../chunk-VFA7QMCZ.js";
|
|
50
47
|
import {
|
|
51
48
|
TELEGRAM_MAX_MESSAGE_LENGTH
|
|
52
|
-
} from "../chunk-
|
|
49
|
+
} from "../chunk-IJBWWQE4.js";
|
|
53
50
|
import {
|
|
54
51
|
fetchWithTimeout
|
|
55
|
-
} from "../chunk-
|
|
56
|
-
import "../chunk-
|
|
52
|
+
} from "../chunk-XQUHC3JZ.js";
|
|
53
|
+
import "../chunk-R4YSJ4EY.js";
|
|
57
54
|
import {
|
|
58
55
|
TELETON_ROOT
|
|
59
56
|
} from "../chunk-EYWNOHMJ.js";
|
|
60
57
|
import "../chunk-RCMD3U65.js";
|
|
61
58
|
import "../chunk-NUGDTPE4.js";
|
|
62
|
-
import "../chunk-
|
|
59
|
+
import "../chunk-3RG5ZIWI.js";
|
|
63
60
|
|
|
64
61
|
// src/cli/index.ts
|
|
65
62
|
import { Command } from "commander";
|
|
@@ -382,7 +379,7 @@ function sleep(ms) {
|
|
|
382
379
|
}
|
|
383
380
|
async function onboardCommand(options = {}) {
|
|
384
381
|
if (options.ui) {
|
|
385
|
-
const { SetupServer } = await import("../setup-server-
|
|
382
|
+
const { SetupServer } = await import("../setup-server-QXED3D2L.js");
|
|
386
383
|
const port = parseInt(options.uiPort || "7777") || 7777;
|
|
387
384
|
const url = `http://localhost:${port}/setup`;
|
|
388
385
|
const blue2 = "\x1B[34m";
|
|
@@ -445,13 +442,15 @@ async function runInteractiveOnboarding(options, prompter) {
|
|
|
445
442
|
let phone = "";
|
|
446
443
|
let userId = 0;
|
|
447
444
|
let tonapiKey;
|
|
445
|
+
let toncenterApiKey;
|
|
448
446
|
let tavilyApiKey;
|
|
449
447
|
let botToken;
|
|
450
448
|
let botUsername;
|
|
451
|
-
let dmPolicy = "
|
|
452
|
-
let groupPolicy = "
|
|
449
|
+
let dmPolicy = "admin-only";
|
|
450
|
+
let groupPolicy = "admin-only";
|
|
453
451
|
let requireMention = true;
|
|
454
452
|
let maxAgenticIterations = "5";
|
|
453
|
+
let execMode = "off";
|
|
455
454
|
let cocoonInstance = 1e4;
|
|
456
455
|
console.clear();
|
|
457
456
|
console.log();
|
|
@@ -701,22 +700,32 @@ Get it at: ${providerMeta.consoleUrl}`,
|
|
|
701
700
|
userId = parseInt(userIdStr);
|
|
702
701
|
dmPolicy = await select({
|
|
703
702
|
message: "DM policy (private messages)",
|
|
704
|
-
default: "
|
|
703
|
+
default: "admin-only",
|
|
705
704
|
theme: inquirerTheme,
|
|
706
705
|
choices: [
|
|
707
|
-
{
|
|
706
|
+
{
|
|
707
|
+
value: "admin-only",
|
|
708
|
+
name: "Admin Only",
|
|
709
|
+
description: "Only admins can DM the agent"
|
|
710
|
+
},
|
|
708
711
|
{ value: "allowlist", name: "Allowlist", description: "Only specific users" },
|
|
709
|
-
{ value: "
|
|
712
|
+
{ value: "open", name: "Open", description: "Reply to everyone" },
|
|
713
|
+
{ value: "disabled", name: "Disabled", description: "Ignore all DMs" }
|
|
710
714
|
]
|
|
711
715
|
});
|
|
712
716
|
groupPolicy = await select({
|
|
713
717
|
message: "Group policy",
|
|
714
|
-
default: "
|
|
718
|
+
default: "admin-only",
|
|
715
719
|
theme: inquirerTheme,
|
|
716
720
|
choices: [
|
|
717
|
-
{
|
|
721
|
+
{
|
|
722
|
+
value: "admin-only",
|
|
723
|
+
name: "Admin Only",
|
|
724
|
+
description: "Only admins can trigger the agent"
|
|
725
|
+
},
|
|
718
726
|
{ value: "allowlist", name: "Allowlist", description: "Only specific groups" },
|
|
719
|
-
{ value: "
|
|
727
|
+
{ value: "open", name: "Open", description: "Reply in all groups" },
|
|
728
|
+
{ value: "disabled", name: "Disabled", description: "Ignore all group messages" }
|
|
720
729
|
]
|
|
721
730
|
});
|
|
722
731
|
requireMention = await confirm({
|
|
@@ -733,6 +742,19 @@ Get it at: ${providerMeta.consoleUrl}`,
|
|
|
733
742
|
return !isNaN(n) && n >= 1 && n <= 50 ? true : "Must be 1\u201350";
|
|
734
743
|
}
|
|
735
744
|
});
|
|
745
|
+
execMode = await select({
|
|
746
|
+
message: "Coding Agent (system execution)",
|
|
747
|
+
choices: [
|
|
748
|
+
{ value: "off", name: "Disabled", description: "No system execution capability" },
|
|
749
|
+
{
|
|
750
|
+
value: "yolo",
|
|
751
|
+
name: "YOLO Mode",
|
|
752
|
+
description: "Full system access \u2014 STRONGLY RECOMMENDED to use a dedicated VPS"
|
|
753
|
+
}
|
|
754
|
+
],
|
|
755
|
+
default: "off",
|
|
756
|
+
theme: inquirerTheme
|
|
757
|
+
});
|
|
736
758
|
STEPS[2].value = `${dmPolicy}/${groupPolicy}`;
|
|
737
759
|
redraw(3);
|
|
738
760
|
const extras = [];
|
|
@@ -783,13 +805,13 @@ Get it at: ${providerMeta.consoleUrl}`,
|
|
|
783
805
|
}
|
|
784
806
|
}
|
|
785
807
|
const setupTonapi = await confirm({
|
|
786
|
-
message: `Add a TonAPI key? ${DIM("(
|
|
808
|
+
message: `Add a TonAPI key? ${DIM("(strongly recommended for TON features)")}`,
|
|
787
809
|
default: false,
|
|
788
810
|
theme: inquirerTheme
|
|
789
811
|
});
|
|
790
812
|
if (setupTonapi) {
|
|
791
813
|
noteBox(
|
|
792
|
-
"
|
|
814
|
+
"Blockchain data \u2014 jettons, NFTs, prices, transaction history.\nWithout key: 1 req/s (you WILL hit rate limits)\nWith free key: 5 req/s\n\nOpen @tonapibot on Telegram \u2192 mini app \u2192 generate a server key",
|
|
793
815
|
"TonAPI",
|
|
794
816
|
TON
|
|
795
817
|
);
|
|
@@ -804,6 +826,28 @@ Get it at: ${providerMeta.consoleUrl}`,
|
|
|
804
826
|
tonapiKey = keyInput;
|
|
805
827
|
extras.push("TonAPI");
|
|
806
828
|
}
|
|
829
|
+
const setupToncenter = await confirm({
|
|
830
|
+
message: `Add a TonCenter API key? ${DIM("(optional, dedicated RPC endpoint)")}`,
|
|
831
|
+
default: false,
|
|
832
|
+
theme: inquirerTheme
|
|
833
|
+
});
|
|
834
|
+
if (setupToncenter) {
|
|
835
|
+
noteBox(
|
|
836
|
+
"Blockchain RPC \u2014 send transactions, check balances.\nWithout key: falls back to ORBS network (decentralized, slower)\nWith free key: dedicated RPC endpoint\n\nGo to https://toncenter.com \u2192 get a free API key (instant, no signup)",
|
|
837
|
+
"TonCenter",
|
|
838
|
+
TON
|
|
839
|
+
);
|
|
840
|
+
const keyInput = await input({
|
|
841
|
+
message: "TonCenter API key",
|
|
842
|
+
theme: inquirerTheme,
|
|
843
|
+
validate: (v) => {
|
|
844
|
+
if (!v || v.length < 10) return "Key too short";
|
|
845
|
+
return true;
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
toncenterApiKey = keyInput;
|
|
849
|
+
extras.push("TonCenter");
|
|
850
|
+
}
|
|
807
851
|
const setupTavily = await confirm({
|
|
808
852
|
message: `Enable web search? ${DIM("(free Tavily key \u2014 1,000 req/month)")}`,
|
|
809
853
|
default: false,
|
|
@@ -1057,9 +1101,19 @@ Get it at: ${providerMeta.consoleUrl}`,
|
|
|
1057
1101
|
},
|
|
1058
1102
|
logging: { level: "info", pretty: true },
|
|
1059
1103
|
mcp: { servers: {} },
|
|
1104
|
+
capabilities: {
|
|
1105
|
+
exec: {
|
|
1106
|
+
mode: execMode,
|
|
1107
|
+
scope: "admin-only",
|
|
1108
|
+
allowlist: [],
|
|
1109
|
+
limits: { timeout: 120, max_output: 5e4 },
|
|
1110
|
+
audit: { log_commands: true }
|
|
1111
|
+
}
|
|
1112
|
+
},
|
|
1060
1113
|
plugins: {},
|
|
1061
1114
|
...selectedProvider === "cocoon" ? { cocoon: { port: cocoonInstance } } : {},
|
|
1062
1115
|
tonapi_key: tonapiKey,
|
|
1116
|
+
toncenter_api_key: toncenterApiKey,
|
|
1063
1117
|
tavily_api_key: tavilyApiKey
|
|
1064
1118
|
};
|
|
1065
1119
|
spinner.start(DIM("Saving configuration..."));
|
|
@@ -1166,9 +1220,9 @@ async function runNonInteractiveOnboarding(options, prompter) {
|
|
|
1166
1220
|
phone: options.phone,
|
|
1167
1221
|
session_name: "teleton_session",
|
|
1168
1222
|
session_path: workspace.sessionPath,
|
|
1169
|
-
dm_policy: "
|
|
1223
|
+
dm_policy: "admin-only",
|
|
1170
1224
|
allow_from: [],
|
|
1171
|
-
group_policy: "
|
|
1225
|
+
group_policy: "admin-only",
|
|
1172
1226
|
group_allow_from: [],
|
|
1173
1227
|
require_mention: true,
|
|
1174
1228
|
max_message_length: TELEGRAM_MAX_MESSAGE_LENGTH,
|
|
@@ -1212,6 +1266,15 @@ async function runNonInteractiveOnboarding(options, prompter) {
|
|
|
1212
1266
|
skip_unlimited_providers: false
|
|
1213
1267
|
},
|
|
1214
1268
|
logging: { level: "info", pretty: true },
|
|
1269
|
+
capabilities: {
|
|
1270
|
+
exec: {
|
|
1271
|
+
mode: "off",
|
|
1272
|
+
scope: "admin-only",
|
|
1273
|
+
allowlist: [],
|
|
1274
|
+
limits: { timeout: 120, max_output: 5e4 },
|
|
1275
|
+
audit: { log_commands: true }
|
|
1276
|
+
}
|
|
1277
|
+
},
|
|
1215
1278
|
mcp: { servers: {} },
|
|
1216
1279
|
plugins: {},
|
|
1217
1280
|
tavily_api_key: options.tavilyApiKey
|
|
@@ -8,15 +8,14 @@ import {
|
|
|
8
8
|
loadContextFromTranscript,
|
|
9
9
|
registerCocoonModels,
|
|
10
10
|
registerLocalModels
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-4DU3C27M.js";
|
|
11
|
+
} from "./chunk-QVBSUYVX.js";
|
|
12
|
+
import "./chunk-PHSAHTK4.js";
|
|
13
|
+
import "./chunk-P36I6OIV.js";
|
|
14
|
+
import "./chunk-XQUHC3JZ.js";
|
|
15
|
+
import "./chunk-R4YSJ4EY.js";
|
|
17
16
|
import "./chunk-EYWNOHMJ.js";
|
|
18
17
|
import "./chunk-RCMD3U65.js";
|
|
19
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-3RG5ZIWI.js";
|
|
20
19
|
export {
|
|
21
20
|
chatWithContext,
|
|
22
21
|
createClient,
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TeletonApp,
|
|
3
3
|
main
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-H36RFKRI.js";
|
|
5
5
|
import "./chunk-WIKM24GZ.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-RQBAMUCV.js";
|
|
7
|
+
import "./chunk-JHYZYFZJ.js";
|
|
8
|
+
import "./chunk-TVRZJIZX.js";
|
|
9
|
+
import "./chunk-7TECSLJ4.js";
|
|
10
10
|
import "./chunk-XBE4JB7C.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-VAUJSSD3.js";
|
|
21
|
-
import "./chunk-4DU3C27M.js";
|
|
11
|
+
import "./chunk-QVBSUYVX.js";
|
|
12
|
+
import "./chunk-PHSAHTK4.js";
|
|
13
|
+
import "./chunk-P36I6OIV.js";
|
|
14
|
+
import "./chunk-SD4NLLYG.js";
|
|
15
|
+
import "./chunk-U56QTM46.js";
|
|
16
|
+
import "./chunk-VFA7QMCZ.js";
|
|
17
|
+
import "./chunk-IJBWWQE4.js";
|
|
18
|
+
import "./chunk-XQUHC3JZ.js";
|
|
19
|
+
import "./chunk-R4YSJ4EY.js";
|
|
22
20
|
import "./chunk-EYWNOHMJ.js";
|
|
23
21
|
import "./chunk-RCMD3U65.js";
|
|
24
22
|
import "./chunk-NUGDTPE4.js";
|
|
25
|
-
import "./chunk-
|
|
23
|
+
import "./chunk-3RG5ZIWI.js";
|
|
26
24
|
export {
|
|
27
25
|
TeletonApp,
|
|
28
26
|
main
|