teleton 0.8.2 → 0.8.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.
Files changed (30) hide show
  1. package/dist/bootstrap-DDFVEMYI.js +128 -0
  2. package/dist/{chunk-XBSCYMKM.js → chunk-2ERTYRHA.js} +6 -6
  3. package/dist/{chunk-2IZU3REP.js → chunk-33Z47EXI.js} +139 -214
  4. package/dist/{chunk-HEDJCLA6.js → chunk-35MX4ZUI.js} +2 -122
  5. package/dist/{chunk-YOSUPUAJ.js → chunk-6OOHHJ4N.js} +1 -174
  6. package/dist/{chunk-GGXJLMOH.js → chunk-7MWKT67G.js} +295 -416
  7. package/dist/chunk-AEHTQI3H.js +142 -0
  8. package/dist/{chunk-7YKSXOQQ.js → chunk-AERHOXGC.js} +78 -320
  9. package/dist/{chunk-W25Z7CM6.js → chunk-ALKAAG4O.js} +3 -3
  10. package/dist/chunk-CUE4UZXR.js +129 -0
  11. package/dist/chunk-FUNF6H4W.js +251 -0
  12. package/dist/{chunk-VYKW7FMV.js → chunk-GHMXWAXI.js} +1 -1
  13. package/dist/{chunk-J73TA3UM.js → chunk-LVTKJQ7O.js} +7 -5
  14. package/dist/chunk-NVKBBTI6.js +128 -0
  15. package/dist/{chunk-57URFK6M.js → chunk-OIMAE24Q.js} +51 -13
  16. package/dist/chunk-WTDAICGT.js +175 -0
  17. package/dist/{chunk-55SKE6YH.js → chunk-XDZDOKIF.js} +1 -1
  18. package/dist/cli/index.js +42 -22
  19. package/dist/{client-YOOHI776.js → client-5KD25NOP.js} +4 -3
  20. package/dist/index.js +15 -10
  21. package/dist/local-IHKJFQJS.js +9 -0
  22. package/dist/{memory-Q6EWGK2S.js → memory-QMJRM3XJ.js} +5 -3
  23. package/dist/{memory-hook-WUXJNVT5.js → memory-hook-VUNWZ3NY.js} +5 -4
  24. package/dist/{migrate-WFU6COBN.js → migrate-5VBAP52B.js} +3 -2
  25. package/dist/{server-GYZXKIKU.js → server-JF6FX772.js} +39 -13
  26. package/dist/{server-YODFBZKG.js → server-N4T7E25M.js} +14 -10
  27. package/dist/{setup-server-IZBUOJRU.js → setup-server-IX3BFPPH.js} +5 -3
  28. package/dist/{store-7M4XV6M5.js → store-BY7S6IFN.js} +4 -3
  29. package/dist/{tool-index-NYH57UWP.js → tool-index-FTERJSZK.js} +2 -1
  30. package/package.json +1 -1
@@ -0,0 +1,175 @@
1
+ import {
2
+ createLogger
3
+ } from "./chunk-NQ6FZKCE.js";
4
+
5
+ // src/providers/claude-code-credentials.ts
6
+ import { readFileSync, writeFileSync, existsSync } from "fs";
7
+ import { execSync } from "child_process";
8
+ import { homedir } from "os";
9
+ import { join } from "path";
10
+ var log = createLogger("ClaudeCodeCreds");
11
+ var OAUTH_TOKEN_URL = "https://platform.claude.com/v1/oauth/token";
12
+ var OAUTH_CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
13
+ var OAUTH_SCOPES = "user:profile user:inference user:sessions:claude_code user:mcp_servers";
14
+ var cachedToken = null;
15
+ var cachedExpiresAt = 0;
16
+ var cachedRefreshToken = null;
17
+ function getClaudeConfigDir() {
18
+ return process.env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude");
19
+ }
20
+ function getCredentialsFilePath() {
21
+ return join(getClaudeConfigDir(), ".credentials.json");
22
+ }
23
+ function readCredentialsFile() {
24
+ const filePath = getCredentialsFilePath();
25
+ if (!existsSync(filePath)) return null;
26
+ try {
27
+ const raw = readFileSync(filePath, "utf-8");
28
+ return JSON.parse(raw);
29
+ } catch (e) {
30
+ log.warn({ err: e, path: filePath }, "Failed to parse Claude Code credentials file");
31
+ return null;
32
+ }
33
+ }
34
+ function readKeychainCredentials() {
35
+ const serviceNames = ["Claude Code-credentials", "Claude Code"];
36
+ for (const service of serviceNames) {
37
+ try {
38
+ const raw = execSync(`security find-generic-password -s "${service}" -w`, {
39
+ encoding: "utf-8",
40
+ stdio: ["pipe", "pipe", "pipe"]
41
+ }).trim();
42
+ return JSON.parse(raw);
43
+ } catch {
44
+ }
45
+ }
46
+ return null;
47
+ }
48
+ function readCredentials() {
49
+ if (process.platform === "darwin") {
50
+ const keychainCreds = readKeychainCredentials();
51
+ if (keychainCreds) return keychainCreds;
52
+ log.debug("Keychain read failed, falling back to credentials file");
53
+ }
54
+ return readCredentialsFile();
55
+ }
56
+ function extractToken(creds) {
57
+ const oauth = creds.claudeAiOauth;
58
+ if (!oauth?.accessToken) {
59
+ log.warn("Claude Code credentials found but missing accessToken");
60
+ return null;
61
+ }
62
+ return {
63
+ token: oauth.accessToken,
64
+ expiresAt: oauth.expiresAt ?? 0,
65
+ refreshToken: oauth.refreshToken
66
+ };
67
+ }
68
+ function getClaudeCodeApiKey(fallbackKey) {
69
+ if (cachedToken && Date.now() < cachedExpiresAt) {
70
+ return cachedToken;
71
+ }
72
+ const creds = readCredentials();
73
+ if (creds) {
74
+ const extracted = extractToken(creds);
75
+ if (extracted) {
76
+ cachedToken = extracted.token;
77
+ cachedExpiresAt = extracted.expiresAt;
78
+ cachedRefreshToken = extracted.refreshToken ?? null;
79
+ log.debug("Claude Code credentials loaded successfully");
80
+ return cachedToken;
81
+ }
82
+ }
83
+ if (fallbackKey && fallbackKey.length > 0) {
84
+ log.warn("Claude Code credentials not found, using fallback api_key from config");
85
+ return fallbackKey;
86
+ }
87
+ throw new Error("No Claude Code credentials found. Run 'claude login' or set api_key in config.");
88
+ }
89
+ async function performOAuthRefresh(refreshToken) {
90
+ try {
91
+ const res = await fetch(OAUTH_TOKEN_URL, {
92
+ method: "POST",
93
+ headers: { "Content-Type": "application/json" },
94
+ body: JSON.stringify({
95
+ grant_type: "refresh_token",
96
+ refresh_token: refreshToken,
97
+ client_id: OAUTH_CLIENT_ID,
98
+ scope: OAUTH_SCOPES
99
+ })
100
+ });
101
+ if (!res.ok) {
102
+ log.warn(`OAuth token refresh failed: ${res.status} ${res.statusText}`);
103
+ return null;
104
+ }
105
+ const data = await res.json();
106
+ if (!data.access_token || !data.expires_in) {
107
+ log.warn("OAuth token refresh: unexpected response shape");
108
+ return null;
109
+ }
110
+ const newExpiresAt = Date.now() + data.expires_in * 1e3;
111
+ const newRefreshToken = data.refresh_token ?? refreshToken;
112
+ const filePath = getCredentialsFilePath();
113
+ try {
114
+ const existing = existsSync(filePath) ? JSON.parse(readFileSync(filePath, "utf-8")) : {};
115
+ const updated = {
116
+ ...existing,
117
+ claudeAiOauth: {
118
+ ...existing.claudeAiOauth,
119
+ accessToken: data.access_token,
120
+ refreshToken: newRefreshToken,
121
+ expiresAt: newExpiresAt
122
+ }
123
+ };
124
+ writeFileSync(filePath, JSON.stringify(updated, null, 2), { mode: 384 });
125
+ } catch (e) {
126
+ log.warn({ err: e }, "Failed to persist refreshed OAuth credentials to disk");
127
+ }
128
+ cachedToken = data.access_token;
129
+ cachedExpiresAt = newExpiresAt;
130
+ cachedRefreshToken = newRefreshToken;
131
+ log.info("Claude Code OAuth token refreshed successfully");
132
+ return cachedToken;
133
+ } catch (e) {
134
+ log.warn({ err: e }, "OAuth token refresh request failed");
135
+ return null;
136
+ }
137
+ }
138
+ async function refreshClaudeCodeApiKey() {
139
+ cachedToken = null;
140
+ cachedExpiresAt = 0;
141
+ if (!cachedRefreshToken) {
142
+ const creds2 = readCredentials();
143
+ if (creds2) {
144
+ const extracted = extractToken(creds2);
145
+ cachedRefreshToken = extracted?.refreshToken ?? null;
146
+ }
147
+ }
148
+ if (cachedRefreshToken) {
149
+ const refreshed = await performOAuthRefresh(cachedRefreshToken);
150
+ if (refreshed) return refreshed;
151
+ log.warn("OAuth refresh failed, falling back to disk read");
152
+ }
153
+ const creds = readCredentials();
154
+ if (creds) {
155
+ const extracted = extractToken(creds);
156
+ if (extracted) {
157
+ cachedToken = extracted.token;
158
+ cachedExpiresAt = extracted.expiresAt;
159
+ cachedRefreshToken = extracted.refreshToken ?? null;
160
+ log.info("Claude Code credentials refreshed from disk");
161
+ return cachedToken;
162
+ }
163
+ }
164
+ log.warn("Failed to refresh Claude Code credentials");
165
+ return null;
166
+ }
167
+ function isClaudeCodeTokenValid() {
168
+ return cachedToken !== null && Date.now() < cachedExpiresAt;
169
+ }
170
+
171
+ export {
172
+ getClaudeCodeApiKey,
173
+ refreshClaudeCodeApiKey,
174
+ isClaudeCodeTokenValid
175
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getDatabase
3
- } from "./chunk-VYKW7FMV.js";
3
+ } from "./chunk-GHMXWAXI.js";
4
4
  import {
5
5
  createLogger
6
6
  } from "./chunk-NQ6FZKCE.js";
package/dist/cli/index.js CHANGED
@@ -7,54 +7,62 @@ import {
7
7
  import {
8
8
  TelegramUserClient,
9
9
  main
10
- } from "../chunk-2IZU3REP.js";
10
+ } from "../chunk-33Z47EXI.js";
11
+ import "../chunk-NVKBBTI6.js";
11
12
  import "../chunk-H7MFXJZK.js";
12
13
  import {
13
14
  CONFIGURABLE_KEYS,
14
- configExists,
15
15
  deleteNestedValue,
16
- getDefaultConfigPath,
17
16
  getNestedValue,
18
17
  readRawConfig,
19
18
  setNestedValue,
20
19
  writeRawConfig
21
- } from "../chunk-GGXJLMOH.js";
20
+ } from "../chunk-7MWKT67G.js";
22
21
  import {
23
- ConfigSchema,
24
- DealsConfigSchema,
25
- ensureWorkspace,
26
22
  generateWallet,
27
23
  importWallet,
28
- isNewWorkspace,
29
24
  loadWallet,
30
25
  saveWallet,
31
26
  walletExists
32
- } from "../chunk-7YKSXOQQ.js";
33
- import "../chunk-55SKE6YH.js";
34
- import "../chunk-W25Z7CM6.js";
27
+ } from "../chunk-FUNF6H4W.js";
28
+ import {
29
+ configExists,
30
+ getDefaultConfigPath
31
+ } from "../chunk-AEHTQI3H.js";
32
+ import {
33
+ ConfigSchema,
34
+ DealsConfigSchema,
35
+ ensureWorkspace,
36
+ isNewWorkspace
37
+ } from "../chunk-AERHOXGC.js";
38
+ import "../chunk-XDZDOKIF.js";
39
+ import "../chunk-GHMXWAXI.js";
40
+ import "../chunk-ALKAAG4O.js";
35
41
  import {
36
42
  getErrorMessage
37
43
  } from "../chunk-3UFPFWYP.js";
38
44
  import "../chunk-7TECSLJ4.js";
39
- import "../chunk-J73TA3UM.js";
45
+ import "../chunk-35MX4ZUI.js";
46
+ import "../chunk-VFA7QMCZ.js";
47
+ import {
48
+ TELEGRAM_MAX_MESSAGE_LENGTH
49
+ } from "../chunk-C4NKJT2Z.js";
50
+ import "../chunk-LVTKJQ7O.js";
40
51
  import {
41
52
  getClaudeCodeApiKey,
53
+ isClaudeCodeTokenValid
54
+ } from "../chunk-WTDAICGT.js";
55
+ import {
42
56
  getProviderMetadata,
43
57
  getSupportedProviders,
44
- isClaudeCodeTokenValid,
45
58
  validateApiKeyFormat
46
- } from "../chunk-YOSUPUAJ.js";
47
- import "../chunk-LC4TV3KL.js";
48
- import "../chunk-VYKW7FMV.js";
49
- import "../chunk-HEDJCLA6.js";
50
- import "../chunk-VFA7QMCZ.js";
51
- import {
52
- TELEGRAM_MAX_MESSAGE_LENGTH
53
- } from "../chunk-C4NKJT2Z.js";
59
+ } from "../chunk-6OOHHJ4N.js";
54
60
  import {
55
61
  fetchWithTimeout
56
62
  } from "../chunk-XQUHC3JZ.js";
57
63
  import "../chunk-R4YSJ4EY.js";
64
+ import "../chunk-LC4TV3KL.js";
65
+ import "../chunk-CUE4UZXR.js";
58
66
  import {
59
67
  TELETON_ROOT
60
68
  } from "../chunk-EYWNOHMJ.js";
@@ -383,7 +391,7 @@ function sleep(ms) {
383
391
  }
384
392
  async function onboardCommand(options = {}) {
385
393
  if (options.ui) {
386
- const { SetupServer } = await import("../setup-server-IZBUOJRU.js");
394
+ const { SetupServer } = await import("../setup-server-IX3BFPPH.js");
387
395
  const port = parseInt(options.uiPort || "7777") || 7777;
388
396
  const url = `http://localhost:${port}/setup`;
389
397
  const blue2 = "\x1B[34m";
@@ -1949,10 +1957,22 @@ program.command("setup").description("Interactive wizard to set up Teleton").opt
1949
1957
  });
1950
1958
  program.command("start").description("Start the Teleton agent").option("-c, --config <path>", "Config file path", getDefaultConfigPath()).option("--webui", "Enable WebUI server (overrides config)").option("--webui-port <port>", "WebUI server port (default: 7777)").option("--api", "Enable Management API server (overrides config)").option("--api-port <port>", "Management API port (default: 7778)").option("--json-credentials", "Output API credentials as JSON to stdout on start").action(async (options) => {
1951
1959
  try {
1960
+ if (options.api && !configExists(options.config)) {
1961
+ if (options.apiPort) {
1962
+ process.env.TELETON_API_PORT = options.apiPort;
1963
+ }
1964
+ if (options.jsonCredentials) {
1965
+ process.env.TELETON_JSON_CREDENTIALS = "true";
1966
+ }
1967
+ const { startApiOnly } = await import("../bootstrap-DDFVEMYI.js");
1968
+ await startApiOnly({ config: options.config, apiPort: options.apiPort });
1969
+ return;
1970
+ }
1952
1971
  if (!configExists(options.config)) {
1953
1972
  console.error("\u274C Configuration not found");
1954
1973
  console.error(` Expected file: ${options.config}`);
1955
1974
  console.error("\n\u{1F4A1} Run first: teleton setup");
1975
+ console.error(" Or use: teleton start --api (for API-only bootstrap)");
1956
1976
  process.exit(1);
1957
1977
  }
1958
1978
  if (options.webui) {
@@ -8,11 +8,12 @@ import {
8
8
  loadContextFromTranscript,
9
9
  registerCocoonModels,
10
10
  registerLocalModels
11
- } from "./chunk-J73TA3UM.js";
12
- import "./chunk-YOSUPUAJ.js";
13
- import "./chunk-LC4TV3KL.js";
11
+ } from "./chunk-LVTKJQ7O.js";
12
+ import "./chunk-WTDAICGT.js";
13
+ import "./chunk-6OOHHJ4N.js";
14
14
  import "./chunk-XQUHC3JZ.js";
15
15
  import "./chunk-R4YSJ4EY.js";
16
+ import "./chunk-LC4TV3KL.js";
16
17
  import "./chunk-EYWNOHMJ.js";
17
18
  import "./chunk-NQ6FZKCE.js";
18
19
  import "./chunk-3RG5ZIWI.js";
package/dist/index.js CHANGED
@@ -1,23 +1,28 @@
1
1
  import {
2
2
  TeletonApp,
3
3
  main
4
- } from "./chunk-2IZU3REP.js";
4
+ } from "./chunk-33Z47EXI.js";
5
+ import "./chunk-NVKBBTI6.js";
5
6
  import "./chunk-H7MFXJZK.js";
6
- import "./chunk-GGXJLMOH.js";
7
- import "./chunk-7YKSXOQQ.js";
8
- import "./chunk-55SKE6YH.js";
9
- import "./chunk-W25Z7CM6.js";
7
+ import "./chunk-7MWKT67G.js";
8
+ import "./chunk-FUNF6H4W.js";
9
+ import "./chunk-AEHTQI3H.js";
10
+ import "./chunk-AERHOXGC.js";
11
+ import "./chunk-XDZDOKIF.js";
12
+ import "./chunk-GHMXWAXI.js";
13
+ import "./chunk-ALKAAG4O.js";
10
14
  import "./chunk-3UFPFWYP.js";
11
15
  import "./chunk-7TECSLJ4.js";
12
- import "./chunk-J73TA3UM.js";
13
- import "./chunk-YOSUPUAJ.js";
14
- import "./chunk-LC4TV3KL.js";
15
- import "./chunk-VYKW7FMV.js";
16
- import "./chunk-HEDJCLA6.js";
16
+ import "./chunk-35MX4ZUI.js";
17
17
  import "./chunk-VFA7QMCZ.js";
18
18
  import "./chunk-C4NKJT2Z.js";
19
+ import "./chunk-LVTKJQ7O.js";
20
+ import "./chunk-WTDAICGT.js";
21
+ import "./chunk-6OOHHJ4N.js";
19
22
  import "./chunk-XQUHC3JZ.js";
20
23
  import "./chunk-R4YSJ4EY.js";
24
+ import "./chunk-LC4TV3KL.js";
25
+ import "./chunk-CUE4UZXR.js";
21
26
  import "./chunk-EYWNOHMJ.js";
22
27
  import "./chunk-NQ6FZKCE.js";
23
28
  import "./chunk-4L66JHQE.js";
@@ -0,0 +1,9 @@
1
+ import {
2
+ LocalEmbeddingProvider
3
+ } from "./chunk-CUE4UZXR.js";
4
+ import "./chunk-EYWNOHMJ.js";
5
+ import "./chunk-NQ6FZKCE.js";
6
+ import "./chunk-3RG5ZIWI.js";
7
+ export {
8
+ LocalEmbeddingProvider
9
+ };
@@ -17,21 +17,23 @@ import {
17
17
  parseTemporalIntent,
18
18
  runMigrations,
19
19
  setSchemaVersion
20
- } from "./chunk-VYKW7FMV.js";
20
+ } from "./chunk-GHMXWAXI.js";
21
21
  import {
22
22
  AnthropicEmbeddingProvider,
23
23
  CachedEmbeddingProvider,
24
- LocalEmbeddingProvider,
25
24
  NoopEmbeddingProvider,
26
25
  createEmbeddingProvider,
27
26
  deserializeEmbedding,
28
27
  hashText,
29
28
  serializeEmbedding
30
- } from "./chunk-HEDJCLA6.js";
29
+ } from "./chunk-35MX4ZUI.js";
31
30
  import "./chunk-VFA7QMCZ.js";
32
31
  import "./chunk-C4NKJT2Z.js";
33
32
  import "./chunk-XQUHC3JZ.js";
34
33
  import "./chunk-R4YSJ4EY.js";
34
+ import {
35
+ LocalEmbeddingProvider
36
+ } from "./chunk-CUE4UZXR.js";
35
37
  import "./chunk-EYWNOHMJ.js";
36
38
  import "./chunk-NQ6FZKCE.js";
37
39
  import {
@@ -1,14 +1,15 @@
1
1
  import {
2
2
  consolidateOldMemoryFiles,
3
3
  saveSessionMemory
4
- } from "./chunk-W25Z7CM6.js";
4
+ } from "./chunk-ALKAAG4O.js";
5
5
  import "./chunk-3UFPFWYP.js";
6
- import "./chunk-J73TA3UM.js";
7
- import "./chunk-YOSUPUAJ.js";
8
- import "./chunk-LC4TV3KL.js";
9
6
  import "./chunk-C4NKJT2Z.js";
7
+ import "./chunk-LVTKJQ7O.js";
8
+ import "./chunk-WTDAICGT.js";
9
+ import "./chunk-6OOHHJ4N.js";
10
10
  import "./chunk-XQUHC3JZ.js";
11
11
  import "./chunk-R4YSJ4EY.js";
12
+ import "./chunk-LC4TV3KL.js";
12
13
  import "./chunk-EYWNOHMJ.js";
13
14
  import "./chunk-NQ6FZKCE.js";
14
15
  import "./chunk-3RG5ZIWI.js";
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  getDatabase
3
- } from "./chunk-VYKW7FMV.js";
4
- import "./chunk-HEDJCLA6.js";
3
+ } from "./chunk-GHMXWAXI.js";
4
+ import "./chunk-35MX4ZUI.js";
5
5
  import "./chunk-VFA7QMCZ.js";
6
6
  import "./chunk-C4NKJT2Z.js";
7
7
  import "./chunk-XQUHC3JZ.js";
8
8
  import "./chunk-R4YSJ4EY.js";
9
+ import "./chunk-CUE4UZXR.js";
9
10
  import {
10
11
  TELETON_ROOT
11
12
  } from "./chunk-EYWNOHMJ.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createSetupRoutes
3
- } from "./chunk-57URFK6M.js";
3
+ } from "./chunk-OIMAE24Q.js";
4
4
  import {
5
5
  createConfigRoutes,
6
6
  createHooksRoutes,
@@ -16,26 +16,30 @@ import {
16
16
  createToolsRoutes,
17
17
  createWorkspaceRoutes,
18
18
  logInterceptor
19
- } from "./chunk-XBSCYMKM.js";
19
+ } from "./chunk-2ERTYRHA.js";
20
20
  import {
21
21
  ensureTlsCert
22
22
  } from "./chunk-5SEMA47R.js";
23
23
  import "./chunk-WFTC3JJW.js";
24
- import "./chunk-GGXJLMOH.js";
25
- import "./chunk-7YKSXOQQ.js";
26
- import "./chunk-55SKE6YH.js";
27
- import "./chunk-W25Z7CM6.js";
24
+ import "./chunk-7MWKT67G.js";
25
+ import "./chunk-FUNF6H4W.js";
26
+ import "./chunk-AEHTQI3H.js";
27
+ import "./chunk-AERHOXGC.js";
28
+ import "./chunk-XDZDOKIF.js";
29
+ import "./chunk-GHMXWAXI.js";
30
+ import "./chunk-ALKAAG4O.js";
28
31
  import "./chunk-3UFPFWYP.js";
29
32
  import "./chunk-7TECSLJ4.js";
30
- import "./chunk-J73TA3UM.js";
31
- import "./chunk-YOSUPUAJ.js";
32
- import "./chunk-LC4TV3KL.js";
33
- import "./chunk-VYKW7FMV.js";
34
- import "./chunk-HEDJCLA6.js";
33
+ import "./chunk-35MX4ZUI.js";
35
34
  import "./chunk-VFA7QMCZ.js";
36
35
  import "./chunk-C4NKJT2Z.js";
36
+ import "./chunk-LVTKJQ7O.js";
37
+ import "./chunk-WTDAICGT.js";
38
+ import "./chunk-6OOHHJ4N.js";
37
39
  import "./chunk-XQUHC3JZ.js";
38
40
  import "./chunk-R4YSJ4EY.js";
41
+ import "./chunk-LC4TV3KL.js";
42
+ import "./chunk-CUE4UZXR.js";
39
43
  import {
40
44
  TELETON_ROOT
41
45
  } from "./chunk-EYWNOHMJ.js";
@@ -54,6 +58,8 @@ import { serve } from "@hono/node-server";
54
58
  import { createServer as createHttpsServer } from "https";
55
59
  import { randomBytes, createHash as createHash2 } from "crypto";
56
60
  import { HTTPException as HTTPException3 } from "hono/http-exception";
61
+ import { existsSync, statSync } from "fs";
62
+ import { join as join2 } from "path";
57
63
 
58
64
  // src/api/deps.ts
59
65
  import { HTTPException } from "hono/http-exception";
@@ -466,6 +472,21 @@ function generateApiKey() {
466
472
  function hashApiKey2(key) {
467
473
  return createHash2("sha256").update(key).digest("hex");
468
474
  }
475
+ function getSetupStatus() {
476
+ return {
477
+ workspace: existsSync(join2(TELETON_ROOT, "workspace")),
478
+ config: existsSync(join2(TELETON_ROOT, "config.yaml")),
479
+ wallet: existsSync(join2(TELETON_ROOT, "wallet.json")),
480
+ telegram_session: existsSync(join2(TELETON_ROOT, "telegram_session.txt")),
481
+ embeddings_cached: (() => {
482
+ try {
483
+ return statSync(join2(TELETON_ROOT, "models", "Xenova", "all-MiniLM-L6-v2", "onnx", "model.onnx")).size > 1e6;
484
+ } catch {
485
+ return false;
486
+ }
487
+ })()
488
+ };
489
+ }
469
490
  var SSE_PATHS = ["/v1/agent/events", "/v1/logs/stream"];
470
491
  var ApiServer = class {
471
492
  app;
@@ -486,6 +507,10 @@ var ApiServer = class {
486
507
  this.keyHash = hashApiKey2(this.apiKey);
487
508
  }
488
509
  }
510
+ /** Get current API key hash (for persisting in config) */
511
+ getKeyHash() {
512
+ return this.keyHash;
513
+ }
489
514
  /** Update live deps (e.g., when agent starts/stops) */
490
515
  updateDeps(partial) {
491
516
  Object.assign(this.deps, partial);
@@ -538,7 +563,8 @@ var ApiServer = class {
538
563
  if (state === "running") {
539
564
  return c.json({ status: "ready", state });
540
565
  }
541
- return c.json({ status: "not_ready", state }, 503);
566
+ const setup = getSetupStatus();
567
+ return c.json({ status: "not_ready", state, setup }, 503);
542
568
  });
543
569
  const authMw = createAuthMiddleware({
544
570
  keyHash: this.keyHash,
@@ -574,7 +600,7 @@ var ApiServer = class {
574
600
  this.app.route("/v1/marketplace", createMarketplaceRoutes(adaptedDeps));
575
601
  this.app.route("/v1/hooks", createHooksRoutes(adaptedDeps));
576
602
  this.app.route("/v1/ton-proxy", createTonProxyRoutes(adaptedDeps));
577
- this.app.route("/v1/setup", createSetupRoutes());
603
+ this.app.route("/v1/setup", createSetupRoutes({ keyHash: this.keyHash }));
578
604
  this.app.post("/v1/agent/start", async (c) => {
579
605
  const lifecycle = this.deps.lifecycle;
580
606
  if (!lifecycle) {
@@ -13,23 +13,27 @@ import {
13
13
  createToolsRoutes,
14
14
  createWorkspaceRoutes,
15
15
  logInterceptor
16
- } from "./chunk-XBSCYMKM.js";
16
+ } from "./chunk-2ERTYRHA.js";
17
17
  import "./chunk-WFTC3JJW.js";
18
- import "./chunk-GGXJLMOH.js";
19
- import "./chunk-7YKSXOQQ.js";
20
- import "./chunk-55SKE6YH.js";
21
- import "./chunk-W25Z7CM6.js";
18
+ import "./chunk-7MWKT67G.js";
19
+ import "./chunk-FUNF6H4W.js";
20
+ import "./chunk-AEHTQI3H.js";
21
+ import "./chunk-AERHOXGC.js";
22
+ import "./chunk-XDZDOKIF.js";
23
+ import "./chunk-GHMXWAXI.js";
24
+ import "./chunk-ALKAAG4O.js";
22
25
  import "./chunk-3UFPFWYP.js";
23
26
  import "./chunk-7TECSLJ4.js";
24
- import "./chunk-J73TA3UM.js";
25
- import "./chunk-YOSUPUAJ.js";
26
- import "./chunk-LC4TV3KL.js";
27
- import "./chunk-VYKW7FMV.js";
28
- import "./chunk-HEDJCLA6.js";
27
+ import "./chunk-35MX4ZUI.js";
29
28
  import "./chunk-VFA7QMCZ.js";
30
29
  import "./chunk-C4NKJT2Z.js";
30
+ import "./chunk-LVTKJQ7O.js";
31
+ import "./chunk-WTDAICGT.js";
32
+ import "./chunk-6OOHHJ4N.js";
31
33
  import "./chunk-XQUHC3JZ.js";
32
34
  import "./chunk-R4YSJ4EY.js";
35
+ import "./chunk-LC4TV3KL.js";
36
+ import "./chunk-CUE4UZXR.js";
33
37
  import "./chunk-EYWNOHMJ.js";
34
38
  import {
35
39
  createLogger
@@ -1,11 +1,13 @@
1
1
  import {
2
2
  createSetupRoutes
3
- } from "./chunk-57URFK6M.js";
3
+ } from "./chunk-OIMAE24Q.js";
4
4
  import "./chunk-WFTC3JJW.js";
5
- import "./chunk-7YKSXOQQ.js";
6
- import "./chunk-YOSUPUAJ.js";
5
+ import "./chunk-FUNF6H4W.js";
6
+ import "./chunk-AERHOXGC.js";
7
7
  import "./chunk-VFA7QMCZ.js";
8
8
  import "./chunk-C4NKJT2Z.js";
9
+ import "./chunk-WTDAICGT.js";
10
+ import "./chunk-6OOHHJ4N.js";
9
11
  import "./chunk-XQUHC3JZ.js";
10
12
  import "./chunk-R4YSJ4EY.js";
11
13
  import {
@@ -9,13 +9,14 @@ import {
9
9
  saveSessionStore,
10
10
  shouldResetSession,
11
11
  updateSession
12
- } from "./chunk-55SKE6YH.js";
13
- import "./chunk-VYKW7FMV.js";
14
- import "./chunk-HEDJCLA6.js";
12
+ } from "./chunk-XDZDOKIF.js";
13
+ import "./chunk-GHMXWAXI.js";
14
+ import "./chunk-35MX4ZUI.js";
15
15
  import "./chunk-VFA7QMCZ.js";
16
16
  import "./chunk-C4NKJT2Z.js";
17
17
  import "./chunk-XQUHC3JZ.js";
18
18
  import "./chunk-R4YSJ4EY.js";
19
+ import "./chunk-CUE4UZXR.js";
19
20
  import "./chunk-EYWNOHMJ.js";
20
21
  import "./chunk-NQ6FZKCE.js";
21
22
  import "./chunk-4L66JHQE.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  serializeEmbedding
3
- } from "./chunk-HEDJCLA6.js";
3
+ } from "./chunk-35MX4ZUI.js";
4
4
  import "./chunk-VFA7QMCZ.js";
5
5
  import {
6
6
  TOOL_RAG_KEYWORD_WEIGHT,
@@ -9,6 +9,7 @@ import {
9
9
  } from "./chunk-C4NKJT2Z.js";
10
10
  import "./chunk-XQUHC3JZ.js";
11
11
  import "./chunk-R4YSJ4EY.js";
12
+ import "./chunk-CUE4UZXR.js";
12
13
  import "./chunk-EYWNOHMJ.js";
13
14
  import {
14
15
  createLogger
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teleton",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "workspaces": [
5
5
  "packages/*"
6
6
  ],