teleton 0.7.2 → 0.7.3

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.
@@ -8,13 +8,16 @@ import {
8
8
  isNewWorkspace,
9
9
  saveWallet,
10
10
  walletExists
11
- } from "./chunk-NERLQY2H.js";
12
- import "./chunk-QUAPFI2N.js";
11
+ } from "./chunk-DAMCNMYL.js";
12
+ import {
13
+ getClaudeCodeApiKey,
14
+ isClaudeCodeTokenValid
15
+ } from "./chunk-JQDLW7IE.js";
13
16
  import {
14
17
  getProviderMetadata,
15
18
  getSupportedProviders,
16
19
  validateApiKeyFormat
17
- } from "./chunk-LRCPA7SC.js";
20
+ } from "./chunk-RMLQS3X6.js";
18
21
  import "./chunk-XBKSS6DM.js";
19
22
  import {
20
23
  TELEGRAM_MAX_MESSAGE_LENGTH
@@ -74,7 +77,31 @@ var TelegramAuthManager = class {
74
77
  baseLogger: gramLogger
75
78
  });
76
79
  await client.connect();
77
- const result = await client.sendCode({ apiId, apiHash }, phone);
80
+ const result = await client.invoke(
81
+ new Api.auth.SendCode({
82
+ phoneNumber: phone,
83
+ apiId,
84
+ apiHash,
85
+ settings: new Api.CodeSettings({})
86
+ })
87
+ );
88
+ if (result instanceof Api.auth.SentCodeSuccess) {
89
+ await client.disconnect();
90
+ throw new Error("Account already authenticated (SentCodeSuccess)");
91
+ }
92
+ let codeDelivery = "sms";
93
+ let fragmentUrl;
94
+ let codeLength;
95
+ if (result.type instanceof Api.auth.SentCodeTypeApp) {
96
+ codeDelivery = "app";
97
+ codeLength = result.type.length;
98
+ } else if (result.type instanceof Api.auth.SentCodeTypeFragmentSms) {
99
+ codeDelivery = "fragment";
100
+ fragmentUrl = result.type.url;
101
+ codeLength = result.type.length;
102
+ } else if ("length" in result.type) {
103
+ codeLength = result.type.length;
104
+ }
78
105
  const id = randomBytes(16).toString("hex");
79
106
  const expiresAt = Date.now() + SESSION_TTL_MS;
80
107
  this.session = {
@@ -83,6 +110,8 @@ var TelegramAuthManager = class {
83
110
  phone,
84
111
  phoneCodeHash: result.phoneCodeHash,
85
112
  state: "code_sent",
113
+ fragmentUrl,
114
+ codeLength,
86
115
  codeAttempts: 0,
87
116
  passwordAttempts: 0,
88
117
  createdAt: Date.now(),
@@ -91,7 +120,7 @@ var TelegramAuthManager = class {
91
120
  timer: setTimeout(() => this.cleanup(), SESSION_TTL_MS)
92
121
  };
93
122
  log.info("Telegram verification code sent");
94
- return { authSessionId: id, codeViaApp: result.isCodeViaApp, expiresAt };
123
+ return { authSessionId: id, codeDelivery, fragmentUrl, codeLength, expiresAt };
95
124
  }
96
125
  /**
97
126
  * Verify the code entered by the user
@@ -182,10 +211,24 @@ var TelegramAuthManager = class {
182
211
  if (result instanceof Api.auth.SentCode) {
183
212
  session.phoneCodeHash = result.phoneCodeHash;
184
213
  session.codeAttempts = 0;
185
- const codeViaApp = result.type instanceof Api.auth.SentCodeTypeApp;
186
- return { codeViaApp };
214
+ let codeDelivery = "sms";
215
+ let fragmentUrl;
216
+ let codeLength;
217
+ if (result.type instanceof Api.auth.SentCodeTypeApp) {
218
+ codeDelivery = "app";
219
+ codeLength = result.type.length;
220
+ } else if (result.type instanceof Api.auth.SentCodeTypeFragmentSms) {
221
+ codeDelivery = "fragment";
222
+ fragmentUrl = result.type.url;
223
+ codeLength = result.type.length;
224
+ } else if ("length" in result.type) {
225
+ codeLength = result.type.length;
226
+ }
227
+ session.fragmentUrl = fragmentUrl;
228
+ session.codeLength = codeLength;
229
+ return { codeDelivery, fragmentUrl, codeLength };
187
230
  }
188
- return { codeViaApp: false };
231
+ return { codeDelivery: "sms" };
189
232
  }
190
233
  /**
191
234
  * Cancel and clean up session
@@ -244,10 +287,15 @@ var TelegramAuthManager = class {
244
287
  var log2 = createLogger("Setup");
245
288
  var MODEL_OPTIONS = {
246
289
  anthropic: [
290
+ {
291
+ value: "claude-opus-4-6",
292
+ name: "Claude Opus 4.6",
293
+ description: "Most capable, 1M ctx, $5/M"
294
+ },
247
295
  {
248
296
  value: "claude-opus-4-5-20251101",
249
297
  name: "Claude Opus 4.5",
250
- description: "Most capable, $5/M"
298
+ description: "Previous gen, 200K ctx, $5/M"
251
299
  },
252
300
  { value: "claude-sonnet-4-0", name: "Claude Sonnet 4", description: "Balanced, $3/M" },
253
301
  {
@@ -256,9 +304,9 @@ var MODEL_OPTIONS = {
256
304
  description: "Fast & cheap, $1/M"
257
305
  },
258
306
  {
259
- value: "claude-3-5-haiku-20241022",
260
- name: "Claude 3.5 Haiku",
261
- description: "Cheapest, $0.80/M"
307
+ value: "claude-haiku-4-5-20251001",
308
+ name: "Claude Haiku 4.5",
309
+ description: "Fast & cheap, $1/M"
262
310
  }
263
311
  ],
264
312
  openai: [
@@ -390,14 +438,16 @@ function createSetupRoutes() {
390
438
  toolLimit: p.toolLimit,
391
439
  keyPrefix: p.keyPrefix,
392
440
  consoleUrl: p.consoleUrl,
393
- requiresApiKey: p.id !== "cocoon" && p.id !== "local",
441
+ requiresApiKey: p.id !== "cocoon" && p.id !== "local" && p.id !== "claude-code",
442
+ autoDetectsKey: p.id === "claude-code",
394
443
  requiresBaseUrl: p.id === "local"
395
444
  }));
396
445
  return c.json({ success: true, data: providers });
397
446
  });
398
447
  app.get("/models/:provider", (c) => {
399
448
  const provider = c.req.param("provider");
400
- const models = MODEL_OPTIONS[provider] || [];
449
+ const modelKey = provider === "claude-code" ? "anthropic" : provider;
450
+ const models = MODEL_OPTIONS[modelKey] || [];
401
451
  const result = [
402
452
  ...models,
403
453
  {
@@ -409,6 +459,25 @@ function createSetupRoutes() {
409
459
  ];
410
460
  return c.json({ success: true, data: result });
411
461
  });
462
+ app.get("/detect-claude-code-key", (c) => {
463
+ try {
464
+ const key = getClaudeCodeApiKey();
465
+ const masked = key;
466
+ return c.json({
467
+ success: true,
468
+ data: {
469
+ found: true,
470
+ maskedKey: masked,
471
+ valid: isClaudeCodeTokenValid()
472
+ }
473
+ });
474
+ } catch {
475
+ return c.json({
476
+ success: true,
477
+ data: { found: false, maskedKey: null, valid: false }
478
+ });
479
+ }
480
+ });
412
481
  app.post("/validate/api-key", async (c) => {
413
482
  try {
414
483
  const body = await c.req.json();