teleton 0.8.0 → 0.8.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.
Files changed (32) hide show
  1. package/README.md +28 -11
  2. package/dist/{chunk-U56QTM46.js → chunk-3S4GGLLR.js} +28 -26
  3. package/dist/{chunk-NUGDTPE4.js → chunk-4L66JHQE.js} +2 -1
  4. package/dist/{chunk-H36RFKRI.js → chunk-5FNWBZ5K.js} +476 -143
  5. package/dist/{chunk-SD4NLLYG.js → chunk-7U7BOHCL.js} +80 -33
  6. package/dist/{chunk-QVBSUYVX.js → chunk-AYWEJCDB.js} +11 -3
  7. package/dist/{chunk-RQBAMUCV.js → chunk-CGOXE4WP.js} +1235 -201
  8. package/dist/{chunk-TVRZJIZX.js → chunk-KVXV7EF7.js} +3 -3
  9. package/dist/{chunk-WIKM24GZ.js → chunk-QBHRXLZS.js} +5 -0
  10. package/dist/{chunk-P36I6OIV.js → chunk-QV2GLOTK.js} +12 -1
  11. package/dist/{chunk-JHYZYFZJ.js → chunk-S6PHGKOC.js} +8 -1
  12. package/dist/{chunk-IJBWWQE4.js → chunk-UP55PXFH.js} +4 -0
  13. package/dist/cli/index.js +17 -16
  14. package/dist/{client-LNZTDQSA.js → client-MPHPIZB6.js} +2 -2
  15. package/dist/{get-my-gifts-OMGKOEPM.js → get-my-gifts-CC6HAVWB.js} +1 -1
  16. package/dist/index.js +11 -11
  17. package/dist/{memory-AS7WKGTW.js → memory-UBHM7ILG.js} +4 -4
  18. package/dist/{migrate-POHWYEIW.js → migrate-UBBEJ5BL.js} +4 -4
  19. package/dist/{server-H3QA252W.js → server-3FHI2SEB.js} +392 -51
  20. package/dist/{setup-server-QXED3D2L.js → setup-server-32XGDPE6.js} +157 -7
  21. package/dist/{store-GAFULOOX.js → store-M5IMUQCL.js} +5 -5
  22. package/dist/{task-dependency-resolver-3FIKQ7Z6.js → task-dependency-resolver-RR2O5S7B.js} +2 -2
  23. package/dist/{task-executor-RUTFG6VG.js → task-executor-6W5HRX5C.js} +2 -2
  24. package/dist/{tasks-BEZ4QRI2.js → tasks-WQIKXDX5.js} +1 -1
  25. package/dist/{tool-index-H3SHOJC3.js → tool-index-PMAOXWUA.js} +8 -5
  26. package/dist/{transcript-IMNE6KU3.js → transcript-NGDPSNIH.js} +1 -1
  27. package/dist/web/assets/index-BfYCdwLI.js +80 -0
  28. package/dist/web/assets/{index-BrVqauzj.css → index-DmlyQVhR.css} +1 -1
  29. package/dist/web/assets/{index.es-DkU1GvWU.js → index.es-DitvF-9H.js} +1 -1
  30. package/dist/web/index.html +2 -2
  31. package/package.json +11 -4
  32. package/dist/web/assets/index-DYeEkvJ6.js +0 -72
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getDatabase
3
- } from "./chunk-SD4NLLYG.js";
3
+ } from "./chunk-7U7BOHCL.js";
4
4
  import {
5
5
  createLogger
6
6
  } from "./chunk-RCMD3U65.js";
@@ -255,8 +255,8 @@ function shouldResetSession(session, policy) {
255
255
  }
256
256
  return false;
257
257
  }
258
- function resetSessionWithPolicy(chatId, policy) {
259
- const newSession = resetSession(chatId);
258
+ function resetSessionWithPolicy(chatId, _policy) {
259
+ resetSession(chatId);
260
260
  const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
261
261
  return updateSession(chatId, {
262
262
  lastResetDate: today
@@ -14,6 +14,7 @@ var CATALOG_CACHE_TTL_MS = 5 * 60 * 1e3;
14
14
  function extractEmoji(sticker) {
15
15
  if (!sticker?.attributes) return null;
16
16
  const attr = sticker.attributes.find(
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- GramJS API response is untyped
17
18
  (a) => a.className === "DocumentAttributeSticker" || a.className === "DocumentAttributeCustomEmoji"
18
19
  );
19
20
  return attr?.alt || null;
@@ -143,12 +144,15 @@ var telegramGetMyGiftsExecutor = async (params, context) => {
143
144
  compactGift.slug = gift.slug;
144
145
  compactGift.nftLink = `t.me/nft/${gift.slug}`;
145
146
  const modelAttr = gift.attributes?.find(
147
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- GramJS API response is untyped
146
148
  (a) => a.className === "StarGiftAttributeModel"
147
149
  );
148
150
  const patternAttr = gift.attributes?.find(
151
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- GramJS API response is untyped
149
152
  (a) => a.className === "StarGiftAttributePattern"
150
153
  );
151
154
  const backdropAttr = gift.attributes?.find(
155
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- GramJS API response is untyped
152
156
  (a) => a.className === "StarGiftAttributeBackdrop"
153
157
  );
154
158
  compactGift.model = extractAttrSummary(modelAttr);
@@ -183,6 +187,7 @@ var telegramGetMyGiftsExecutor = async (params, context) => {
183
187
  limited: limited.length,
184
188
  unlimited: unlimited.length,
185
189
  collectibles: collectibles.length,
190
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- GramJS API response is untyped
186
191
  canUpgrade: gifts.filter((g) => g.canUpgrade).length
187
192
  },
188
193
  totalCount: result.count
@@ -19,6 +19,7 @@ import {
19
19
  import { join } from "path";
20
20
  var log = createLogger("Session");
21
21
  var SESSIONS_DIR = join(TELETON_ROOT, "sessions");
22
+ var transcriptCache = /* @__PURE__ */ new Map();
22
23
  function getTranscriptPath(sessionId) {
23
24
  return join(SESSIONS_DIR, `${sessionId}.jsonl`);
24
25
  }
@@ -36,6 +37,10 @@ function appendToTranscript(sessionId, message) {
36
37
  } catch (error) {
37
38
  log.error({ err: error }, `Failed to append to transcript ${sessionId}`);
38
39
  }
40
+ const cached = transcriptCache.get(sessionId);
41
+ if (cached) {
42
+ cached.push(message);
43
+ }
39
44
  }
40
45
  function extractToolCallIds(msg) {
41
46
  const ids = /* @__PURE__ */ new Set();
@@ -94,6 +99,8 @@ function sanitizeMessages(messages) {
94
99
  return sanitized;
95
100
  }
96
101
  function readTranscript(sessionId) {
102
+ const cached = transcriptCache.get(sessionId);
103
+ if (cached) return [...cached];
97
104
  const transcriptPath = getTranscriptPath(sessionId);
98
105
  if (!existsSync(transcriptPath)) {
99
106
  return [];
@@ -114,7 +121,9 @@ function readTranscript(sessionId) {
114
121
  if (corruptCount > 0) {
115
122
  log.warn(`${corruptCount} corrupt line(s) skipped in transcript ${sessionId}`);
116
123
  }
117
- return sanitizeMessages(messages);
124
+ const sanitized = sanitizeMessages(messages);
125
+ transcriptCache.set(sessionId, sanitized);
126
+ return sanitized;
118
127
  } catch (error) {
119
128
  log.error({ err: error }, `Failed to read transcript ${sessionId}`);
120
129
  return [];
@@ -138,6 +147,7 @@ function deleteTranscript(sessionId) {
138
147
  }
139
148
  try {
140
149
  unlinkSync(transcriptPath);
150
+ transcriptCache.delete(sessionId);
141
151
  log.info(`Deleted transcript: ${sessionId}`);
142
152
  return true;
143
153
  } catch (error) {
@@ -154,6 +164,7 @@ function archiveTranscript(sessionId) {
154
164
  }
155
165
  try {
156
166
  renameSync(transcriptPath, archivePath);
167
+ transcriptCache.delete(sessionId);
157
168
  log.info(`Archived transcript: ${sessionId} \u2192 ${timestamp}.archived`);
158
169
  return true;
159
170
  } catch (error) {
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-VFA7QMCZ.js";
5
5
  import {
6
6
  TELEGRAM_MAX_MESSAGE_LENGTH
7
- } from "./chunk-IJBWWQE4.js";
7
+ } from "./chunk-UP55PXFH.js";
8
8
  import {
9
9
  fetchWithTimeout
10
10
  } from "./chunk-XQUHC3JZ.js";
@@ -341,6 +341,12 @@ var _LoggingObject = z.object({
341
341
  pretty: z.boolean().default(true).describe("Enable pino-pretty formatting (human-readable, colored output)")
342
342
  });
343
343
  var LoggingConfigSchema = _LoggingObject.default(_LoggingObject.parse({}));
344
+ var _TonProxyObject = z.object({
345
+ enabled: z.boolean().default(false).describe("Enable TON Proxy (Tonutils-Proxy) for .ton site access"),
346
+ port: z.number().min(1).max(65535).default(8080).describe("HTTP proxy port (default: 8080)"),
347
+ binary_path: z.string().optional().describe("Custom path to tonutils-proxy-cli binary (auto-downloaded if omitted)")
348
+ });
349
+ var TonProxyConfigSchema = _TonProxyObject.default(_TonProxyObject.parse({}));
344
350
  var _DevObject = z.object({
345
351
  hot_reload: z.boolean().default(false).describe("Enable plugin hot-reload (watches ~/.teleton/plugins/ for changes)")
346
352
  });
@@ -404,6 +410,7 @@ var ConfigSchema = z.object({
404
410
  dev: DevConfigSchema,
405
411
  tool_rag: ToolRagConfigSchema,
406
412
  capabilities: CapabilitiesConfigSchema,
413
+ ton_proxy: TonProxyConfigSchema,
407
414
  mcp: McpConfigSchema,
408
415
  plugins: z.record(z.string(), z.unknown()).default({}).describe("Per-plugin config (key = plugin name with underscores)"),
409
416
  cocoon: z.object({
@@ -51,6 +51,8 @@ var ADAPTIVE_CHUNK_RATIO_TRIGGER = 0.1;
51
51
  var SESSION_SLUG_RECENT_MESSAGES = 10;
52
52
  var SESSION_SLUG_MAX_TOKENS = 50;
53
53
  var MASKING_KEEP_RECENT_COUNT = 10;
54
+ var RESULT_TRUNCATION_THRESHOLD = 4e3;
55
+ var RESULT_TRUNCATION_KEEP_CHARS = 500;
54
56
  var EMBEDDING_CACHE_EVICTION_RATIO = 0.1;
55
57
  var WEB_FETCH_MAX_TEXT_LENGTH = 2e4;
56
58
  var WEB_SEARCH_MAX_RESULTS = 10;
@@ -111,6 +113,8 @@ export {
111
113
  SESSION_SLUG_RECENT_MESSAGES,
112
114
  SESSION_SLUG_MAX_TOKENS,
113
115
  MASKING_KEEP_RECENT_COUNT,
116
+ RESULT_TRUNCATION_THRESHOLD,
117
+ RESULT_TRUNCATION_KEEP_CHARS,
114
118
  EMBEDDING_CACHE_EVICTION_RATIO,
115
119
  WEB_FETCH_MAX_TEXT_LENGTH,
116
120
  WEB_SEARCH_MAX_RESULTS,
package/dist/cli/index.js CHANGED
@@ -4,8 +4,8 @@ import {
4
4
  import {
5
5
  TelegramUserClient,
6
6
  main
7
- } from "../chunk-H36RFKRI.js";
8
- import "../chunk-WIKM24GZ.js";
7
+ } from "../chunk-5FNWBZ5K.js";
8
+ import "../chunk-QBHRXLZS.js";
9
9
  import {
10
10
  CONFIGURABLE_KEYS,
11
11
  configExists,
@@ -15,7 +15,7 @@ import {
15
15
  readRawConfig,
16
16
  setNestedValue,
17
17
  writeRawConfig
18
- } from "../chunk-RQBAMUCV.js";
18
+ } from "../chunk-CGOXE4WP.js";
19
19
  import {
20
20
  ConfigSchema,
21
21
  DealsConfigSchema,
@@ -26,13 +26,13 @@ import {
26
26
  loadWallet,
27
27
  saveWallet,
28
28
  walletExists
29
- } from "../chunk-JHYZYFZJ.js";
30
- import "../chunk-TVRZJIZX.js";
29
+ } from "../chunk-S6PHGKOC.js";
30
+ import "../chunk-KVXV7EF7.js";
31
31
  import "../chunk-7TECSLJ4.js";
32
32
  import {
33
33
  getErrorMessage
34
34
  } from "../chunk-XBE4JB7C.js";
35
- import "../chunk-QVBSUYVX.js";
35
+ import "../chunk-AYWEJCDB.js";
36
36
  import {
37
37
  getClaudeCodeApiKey,
38
38
  getProviderMetadata,
@@ -40,13 +40,13 @@ import {
40
40
  isClaudeCodeTokenValid,
41
41
  validateApiKeyFormat
42
42
  } from "../chunk-PHSAHTK4.js";
43
- import "../chunk-P36I6OIV.js";
44
- import "../chunk-SD4NLLYG.js";
45
- import "../chunk-U56QTM46.js";
43
+ import "../chunk-QV2GLOTK.js";
44
+ import "../chunk-7U7BOHCL.js";
45
+ import "../chunk-3S4GGLLR.js";
46
46
  import "../chunk-VFA7QMCZ.js";
47
47
  import {
48
48
  TELEGRAM_MAX_MESSAGE_LENGTH
49
- } from "../chunk-IJBWWQE4.js";
49
+ } from "../chunk-UP55PXFH.js";
50
50
  import {
51
51
  fetchWithTimeout
52
52
  } from "../chunk-XQUHC3JZ.js";
@@ -55,7 +55,7 @@ import {
55
55
  TELETON_ROOT
56
56
  } from "../chunk-EYWNOHMJ.js";
57
57
  import "../chunk-RCMD3U65.js";
58
- import "../chunk-NUGDTPE4.js";
58
+ import "../chunk-4L66JHQE.js";
59
59
  import "../chunk-3RG5ZIWI.js";
60
60
 
61
61
  // src/cli/index.ts
@@ -379,7 +379,7 @@ function sleep(ms) {
379
379
  }
380
380
  async function onboardCommand(options = {}) {
381
381
  if (options.ui) {
382
- const { SetupServer } = await import("../setup-server-QXED3D2L.js");
382
+ const { SetupServer } = await import("../setup-server-32XGDPE6.js");
383
383
  const port = parseInt(options.uiPort || "7777") || 7777;
384
384
  const url = `http://localhost:${port}/setup`;
385
385
  const blue2 = "\x1B[34m";
@@ -402,9 +402,8 @@ ${blue2} \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25
402
402
  `);
403
403
  const server = new SetupServer(port);
404
404
  await server.start();
405
- process.on("SIGINT", async () => {
406
- await server.stop();
407
- process.exit(0);
405
+ process.on("SIGINT", () => {
406
+ void server.stop().then(() => process.exit(0));
408
407
  });
409
408
  await server.waitForLaunch();
410
409
  console.log("\n Launch signal received \u2014 stopping setup server");
@@ -1110,6 +1109,7 @@ Get it at: ${providerMeta.consoleUrl}`,
1110
1109
  audit: { log_commands: true }
1111
1110
  }
1112
1111
  },
1112
+ ton_proxy: { enabled: false, port: 8080 },
1113
1113
  plugins: {},
1114
1114
  ...selectedProvider === "cocoon" ? { cocoon: { port: cocoonInstance } } : {},
1115
1115
  tonapi_key: tonapiKey,
@@ -1275,6 +1275,7 @@ async function runNonInteractiveOnboarding(options, prompter) {
1275
1275
  audit: { log_commands: true }
1276
1276
  }
1277
1277
  },
1278
+ ton_proxy: { enabled: false, port: 8080 },
1278
1279
  mcp: { servers: {} },
1279
1280
  plugins: {},
1280
1281
  tavily_api_key: options.tavilyApiKey
@@ -1683,7 +1684,7 @@ function ensureMcpSection(raw) {
1683
1684
  return mcp2.servers;
1684
1685
  }
1685
1686
  function deriveServerName(pkg) {
1686
- const unscoped = pkg.includes("/") ? pkg.split("/").pop() : pkg;
1687
+ const unscoped = pkg.includes("/") ? pkg.split("/").pop() ?? pkg : pkg;
1687
1688
  return unscoped.replace(/^server-/, "").replace(/^mcp-server-/, "").replace(/^mcp-/, "");
1688
1689
  }
1689
1690
  async function mcpAddCommand(pkg, extraArgs, options) {
@@ -8,9 +8,9 @@ import {
8
8
  loadContextFromTranscript,
9
9
  registerCocoonModels,
10
10
  registerLocalModels
11
- } from "./chunk-QVBSUYVX.js";
11
+ } from "./chunk-AYWEJCDB.js";
12
12
  import "./chunk-PHSAHTK4.js";
13
- import "./chunk-P36I6OIV.js";
13
+ import "./chunk-QV2GLOTK.js";
14
14
  import "./chunk-XQUHC3JZ.js";
15
15
  import "./chunk-R4YSJ4EY.js";
16
16
  import "./chunk-EYWNOHMJ.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  telegramGetMyGiftsExecutor,
3
3
  telegramGetMyGiftsTool
4
- } from "./chunk-WIKM24GZ.js";
4
+ } from "./chunk-QBHRXLZS.js";
5
5
  import "./chunk-XBE4JB7C.js";
6
6
  import "./chunk-RCMD3U65.js";
7
7
  import "./chunk-3RG5ZIWI.js";
package/dist/index.js CHANGED
@@ -1,25 +1,25 @@
1
1
  import {
2
2
  TeletonApp,
3
3
  main
4
- } from "./chunk-H36RFKRI.js";
5
- import "./chunk-WIKM24GZ.js";
6
- import "./chunk-RQBAMUCV.js";
7
- import "./chunk-JHYZYFZJ.js";
8
- import "./chunk-TVRZJIZX.js";
4
+ } from "./chunk-5FNWBZ5K.js";
5
+ import "./chunk-QBHRXLZS.js";
6
+ import "./chunk-CGOXE4WP.js";
7
+ import "./chunk-S6PHGKOC.js";
8
+ import "./chunk-KVXV7EF7.js";
9
9
  import "./chunk-7TECSLJ4.js";
10
10
  import "./chunk-XBE4JB7C.js";
11
- import "./chunk-QVBSUYVX.js";
11
+ import "./chunk-AYWEJCDB.js";
12
12
  import "./chunk-PHSAHTK4.js";
13
- import "./chunk-P36I6OIV.js";
14
- import "./chunk-SD4NLLYG.js";
15
- import "./chunk-U56QTM46.js";
13
+ import "./chunk-QV2GLOTK.js";
14
+ import "./chunk-7U7BOHCL.js";
15
+ import "./chunk-3S4GGLLR.js";
16
16
  import "./chunk-VFA7QMCZ.js";
17
- import "./chunk-IJBWWQE4.js";
17
+ import "./chunk-UP55PXFH.js";
18
18
  import "./chunk-XQUHC3JZ.js";
19
19
  import "./chunk-R4YSJ4EY.js";
20
20
  import "./chunk-EYWNOHMJ.js";
21
21
  import "./chunk-RCMD3U65.js";
22
- import "./chunk-NUGDTPE4.js";
22
+ import "./chunk-4L66JHQE.js";
23
23
  import "./chunk-3RG5ZIWI.js";
24
24
  export {
25
25
  TeletonApp,
@@ -16,7 +16,7 @@ import {
16
16
  initializeMemory,
17
17
  runMigrations,
18
18
  setSchemaVersion
19
- } from "./chunk-SD4NLLYG.js";
19
+ } from "./chunk-7U7BOHCL.js";
20
20
  import {
21
21
  AnthropicEmbeddingProvider,
22
22
  CachedEmbeddingProvider,
@@ -26,9 +26,9 @@ import {
26
26
  deserializeEmbedding,
27
27
  hashText,
28
28
  serializeEmbedding
29
- } from "./chunk-U56QTM46.js";
29
+ } from "./chunk-3S4GGLLR.js";
30
30
  import "./chunk-VFA7QMCZ.js";
31
- import "./chunk-IJBWWQE4.js";
31
+ import "./chunk-UP55PXFH.js";
32
32
  import "./chunk-XQUHC3JZ.js";
33
33
  import "./chunk-R4YSJ4EY.js";
34
34
  import "./chunk-EYWNOHMJ.js";
@@ -36,7 +36,7 @@ import "./chunk-RCMD3U65.js";
36
36
  import {
37
37
  TaskStore,
38
38
  getTaskStore
39
- } from "./chunk-NUGDTPE4.js";
39
+ } from "./chunk-4L66JHQE.js";
40
40
  import "./chunk-3RG5ZIWI.js";
41
41
  export {
42
42
  AnthropicEmbeddingProvider,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getDatabase
3
- } from "./chunk-SD4NLLYG.js";
4
- import "./chunk-U56QTM46.js";
3
+ } from "./chunk-7U7BOHCL.js";
4
+ import "./chunk-3S4GGLLR.js";
5
5
  import "./chunk-VFA7QMCZ.js";
6
- import "./chunk-IJBWWQE4.js";
6
+ import "./chunk-UP55PXFH.js";
7
7
  import "./chunk-XQUHC3JZ.js";
8
8
  import "./chunk-R4YSJ4EY.js";
9
9
  import {
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  createLogger
14
14
  } from "./chunk-RCMD3U65.js";
15
- import "./chunk-NUGDTPE4.js";
15
+ import "./chunk-4L66JHQE.js";
16
16
  import "./chunk-3RG5ZIWI.js";
17
17
 
18
18
  // src/session/migrate.ts