teleton 0.8.2 → 0.8.4

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/README.md +230 -294
  2. package/dist/bootstrap-NNEI3Z5H.js +126 -0
  3. package/dist/{chunk-HEDJCLA6.js → chunk-35MX4ZUI.js} +2 -122
  4. package/dist/{chunk-57URFK6M.js → chunk-5LOHRZYY.js} +64 -15
  5. package/dist/{chunk-YOSUPUAJ.js → chunk-6OOHHJ4N.js} +1 -174
  6. package/dist/{chunk-W25Z7CM6.js → chunk-ALKAAG4O.js} +3 -3
  7. package/dist/chunk-CUE4UZXR.js +129 -0
  8. package/dist/{chunk-XBSCYMKM.js → chunk-G7PCW63M.js} +14 -14
  9. package/dist/{chunk-VYKW7FMV.js → chunk-GHMXWAXI.js} +1 -1
  10. package/dist/chunk-JROBTXWY.js +908 -0
  11. package/dist/{chunk-J73TA3UM.js → chunk-LVTKJQ7O.js} +7 -5
  12. package/dist/{chunk-GGXJLMOH.js → chunk-LZQOX6YY.js} +283 -1061
  13. package/dist/{chunk-7YKSXOQQ.js → chunk-NH2CNRKJ.js} +131 -241
  14. package/dist/chunk-NVKBBTI6.js +128 -0
  15. package/dist/{chunk-2IZU3REP.js → chunk-UMUONAD6.js} +143 -220
  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 +41 -24
  19. package/dist/{client-YOOHI776.js → client-5KD25NOP.js} +4 -3
  20. package/dist/index.js +14 -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-YODFBZKG.js → server-AJCOURH7.js} +13 -10
  26. package/dist/{server-GYZXKIKU.js → server-WWGVDFPW.js} +38 -13
  27. package/dist/{setup-server-IZBUOJRU.js → setup-server-VDY64CWW.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,59 @@ import {
7
7
  import {
8
8
  TelegramUserClient,
9
9
  main
10
- } from "../chunk-2IZU3REP.js";
10
+ } from "../chunk-UMUONAD6.js";
11
+ import "../chunk-NVKBBTI6.js";
11
12
  import "../chunk-H7MFXJZK.js";
13
+ import "../chunk-LZQOX6YY.js";
12
14
  import {
13
15
  CONFIGURABLE_KEYS,
14
- configExists,
15
16
  deleteNestedValue,
16
- getDefaultConfigPath,
17
+ generateWallet,
17
18
  getNestedValue,
19
+ importWallet,
20
+ loadWallet,
18
21
  readRawConfig,
22
+ saveWallet,
19
23
  setNestedValue,
24
+ walletExists,
20
25
  writeRawConfig
21
- } from "../chunk-GGXJLMOH.js";
26
+ } from "../chunk-JROBTXWY.js";
22
27
  import {
23
28
  ConfigSchema,
24
29
  DealsConfigSchema,
30
+ configExists,
25
31
  ensureWorkspace,
26
- generateWallet,
27
- importWallet,
28
- isNewWorkspace,
29
- loadWallet,
30
- saveWallet,
31
- walletExists
32
- } from "../chunk-7YKSXOQQ.js";
33
- import "../chunk-55SKE6YH.js";
34
- import "../chunk-W25Z7CM6.js";
32
+ getDefaultConfigPath,
33
+ isNewWorkspace
34
+ } from "../chunk-NH2CNRKJ.js";
35
+ import "../chunk-XDZDOKIF.js";
36
+ import "../chunk-GHMXWAXI.js";
37
+ import "../chunk-ALKAAG4O.js";
35
38
  import {
36
39
  getErrorMessage
37
40
  } from "../chunk-3UFPFWYP.js";
38
41
  import "../chunk-7TECSLJ4.js";
39
- import "../chunk-J73TA3UM.js";
42
+ import "../chunk-35MX4ZUI.js";
43
+ import "../chunk-VFA7QMCZ.js";
44
+ import {
45
+ TELEGRAM_MAX_MESSAGE_LENGTH
46
+ } from "../chunk-C4NKJT2Z.js";
47
+ import "../chunk-LVTKJQ7O.js";
40
48
  import {
41
49
  getClaudeCodeApiKey,
50
+ isClaudeCodeTokenValid
51
+ } from "../chunk-WTDAICGT.js";
52
+ import {
42
53
  getProviderMetadata,
43
54
  getSupportedProviders,
44
- isClaudeCodeTokenValid,
45
55
  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";
56
+ } from "../chunk-6OOHHJ4N.js";
54
57
  import {
55
58
  fetchWithTimeout
56
59
  } from "../chunk-XQUHC3JZ.js";
57
60
  import "../chunk-R4YSJ4EY.js";
61
+ import "../chunk-LC4TV3KL.js";
62
+ import "../chunk-CUE4UZXR.js";
58
63
  import {
59
64
  TELETON_ROOT
60
65
  } from "../chunk-EYWNOHMJ.js";
@@ -383,7 +388,7 @@ function sleep(ms) {
383
388
  }
384
389
  async function onboardCommand(options = {}) {
385
390
  if (options.ui) {
386
- const { SetupServer } = await import("../setup-server-IZBUOJRU.js");
391
+ const { SetupServer } = await import("../setup-server-VDY64CWW.js");
387
392
  const port = parseInt(options.uiPort || "7777") || 7777;
388
393
  const url = `http://localhost:${port}/setup`;
389
394
  const blue2 = "\x1B[34m";
@@ -1949,10 +1954,22 @@ program.command("setup").description("Interactive wizard to set up Teleton").opt
1949
1954
  });
1950
1955
  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
1956
  try {
1957
+ if (options.api && !configExists(options.config)) {
1958
+ if (options.apiPort) {
1959
+ process.env.TELETON_API_PORT = options.apiPort;
1960
+ }
1961
+ if (options.jsonCredentials) {
1962
+ process.env.TELETON_JSON_CREDENTIALS = "true";
1963
+ }
1964
+ const { startApiOnly } = await import("../bootstrap-NNEI3Z5H.js");
1965
+ await startApiOnly({ config: options.config, apiPort: options.apiPort });
1966
+ return;
1967
+ }
1952
1968
  if (!configExists(options.config)) {
1953
1969
  console.error("\u274C Configuration not found");
1954
1970
  console.error(` Expected file: ${options.config}`);
1955
1971
  console.error("\n\u{1F4A1} Run first: teleton setup");
1972
+ console.error(" Or use: teleton start --api (for API-only bootstrap)");
1956
1973
  process.exit(1);
1957
1974
  }
1958
1975
  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,27 @@
1
1
  import {
2
2
  TeletonApp,
3
3
  main
4
- } from "./chunk-2IZU3REP.js";
4
+ } from "./chunk-UMUONAD6.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-LZQOX6YY.js";
8
+ import "./chunk-JROBTXWY.js";
9
+ import "./chunk-NH2CNRKJ.js";
10
+ import "./chunk-XDZDOKIF.js";
11
+ import "./chunk-GHMXWAXI.js";
12
+ import "./chunk-ALKAAG4O.js";
10
13
  import "./chunk-3UFPFWYP.js";
11
14
  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";
15
+ import "./chunk-35MX4ZUI.js";
17
16
  import "./chunk-VFA7QMCZ.js";
18
17
  import "./chunk-C4NKJT2Z.js";
18
+ import "./chunk-LVTKJQ7O.js";
19
+ import "./chunk-WTDAICGT.js";
20
+ import "./chunk-6OOHHJ4N.js";
19
21
  import "./chunk-XQUHC3JZ.js";
20
22
  import "./chunk-R4YSJ4EY.js";
23
+ import "./chunk-LC4TV3KL.js";
24
+ import "./chunk-CUE4UZXR.js";
21
25
  import "./chunk-EYWNOHMJ.js";
22
26
  import "./chunk-NQ6FZKCE.js";
23
27
  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";
@@ -13,23 +13,26 @@ import {
13
13
  createToolsRoutes,
14
14
  createWorkspaceRoutes,
15
15
  logInterceptor
16
- } from "./chunk-XBSCYMKM.js";
16
+ } from "./chunk-G7PCW63M.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-LZQOX6YY.js";
19
+ import "./chunk-JROBTXWY.js";
20
+ import "./chunk-NH2CNRKJ.js";
21
+ import "./chunk-XDZDOKIF.js";
22
+ import "./chunk-GHMXWAXI.js";
23
+ import "./chunk-ALKAAG4O.js";
22
24
  import "./chunk-3UFPFWYP.js";
23
25
  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";
26
+ import "./chunk-35MX4ZUI.js";
29
27
  import "./chunk-VFA7QMCZ.js";
30
28
  import "./chunk-C4NKJT2Z.js";
29
+ import "./chunk-LVTKJQ7O.js";
30
+ import "./chunk-WTDAICGT.js";
31
+ import "./chunk-6OOHHJ4N.js";
31
32
  import "./chunk-XQUHC3JZ.js";
32
33
  import "./chunk-R4YSJ4EY.js";
34
+ import "./chunk-LC4TV3KL.js";
35
+ import "./chunk-CUE4UZXR.js";
33
36
  import "./chunk-EYWNOHMJ.js";
34
37
  import {
35
38
  createLogger
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createSetupRoutes
3
- } from "./chunk-57URFK6M.js";
3
+ } from "./chunk-5LOHRZYY.js";
4
4
  import {
5
5
  createConfigRoutes,
6
6
  createHooksRoutes,
@@ -16,26 +16,29 @@ import {
16
16
  createToolsRoutes,
17
17
  createWorkspaceRoutes,
18
18
  logInterceptor
19
- } from "./chunk-XBSCYMKM.js";
19
+ } from "./chunk-G7PCW63M.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-LZQOX6YY.js";
25
+ import "./chunk-JROBTXWY.js";
26
+ import "./chunk-NH2CNRKJ.js";
27
+ import "./chunk-XDZDOKIF.js";
28
+ import "./chunk-GHMXWAXI.js";
29
+ import "./chunk-ALKAAG4O.js";
28
30
  import "./chunk-3UFPFWYP.js";
29
31
  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";
32
+ import "./chunk-35MX4ZUI.js";
35
33
  import "./chunk-VFA7QMCZ.js";
36
34
  import "./chunk-C4NKJT2Z.js";
35
+ import "./chunk-LVTKJQ7O.js";
36
+ import "./chunk-WTDAICGT.js";
37
+ import "./chunk-6OOHHJ4N.js";
37
38
  import "./chunk-XQUHC3JZ.js";
38
39
  import "./chunk-R4YSJ4EY.js";
40
+ import "./chunk-LC4TV3KL.js";
41
+ import "./chunk-CUE4UZXR.js";
39
42
  import {
40
43
  TELETON_ROOT
41
44
  } from "./chunk-EYWNOHMJ.js";
@@ -54,6 +57,8 @@ import { serve } from "@hono/node-server";
54
57
  import { createServer as createHttpsServer } from "https";
55
58
  import { randomBytes, createHash as createHash2 } from "crypto";
56
59
  import { HTTPException as HTTPException3 } from "hono/http-exception";
60
+ import { existsSync, statSync } from "fs";
61
+ import { join as join2 } from "path";
57
62
 
58
63
  // src/api/deps.ts
59
64
  import { HTTPException } from "hono/http-exception";
@@ -466,6 +471,21 @@ function generateApiKey() {
466
471
  function hashApiKey2(key) {
467
472
  return createHash2("sha256").update(key).digest("hex");
468
473
  }
474
+ function getSetupStatus() {
475
+ return {
476
+ workspace: existsSync(join2(TELETON_ROOT, "workspace")),
477
+ config: existsSync(join2(TELETON_ROOT, "config.yaml")),
478
+ wallet: existsSync(join2(TELETON_ROOT, "wallet.json")),
479
+ telegram_session: existsSync(join2(TELETON_ROOT, "telegram_session.txt")),
480
+ embeddings_cached: (() => {
481
+ try {
482
+ return statSync(join2(TELETON_ROOT, "models", "Xenova", "all-MiniLM-L6-v2", "onnx", "model.onnx")).size > 1e6;
483
+ } catch {
484
+ return false;
485
+ }
486
+ })()
487
+ };
488
+ }
469
489
  var SSE_PATHS = ["/v1/agent/events", "/v1/logs/stream"];
470
490
  var ApiServer = class {
471
491
  app;
@@ -486,6 +506,10 @@ var ApiServer = class {
486
506
  this.keyHash = hashApiKey2(this.apiKey);
487
507
  }
488
508
  }
509
+ /** Get current API key hash (for persisting in config) */
510
+ getKeyHash() {
511
+ return this.keyHash;
512
+ }
489
513
  /** Update live deps (e.g., when agent starts/stops) */
490
514
  updateDeps(partial) {
491
515
  Object.assign(this.deps, partial);
@@ -538,7 +562,8 @@ var ApiServer = class {
538
562
  if (state === "running") {
539
563
  return c.json({ status: "ready", state });
540
564
  }
541
- return c.json({ status: "not_ready", state }, 503);
565
+ const setup = getSetupStatus();
566
+ return c.json({ status: "not_ready", state, setup }, 503);
542
567
  });
543
568
  const authMw = createAuthMiddleware({
544
569
  keyHash: this.keyHash,
@@ -574,7 +599,7 @@ var ApiServer = class {
574
599
  this.app.route("/v1/marketplace", createMarketplaceRoutes(adaptedDeps));
575
600
  this.app.route("/v1/hooks", createHooksRoutes(adaptedDeps));
576
601
  this.app.route("/v1/ton-proxy", createTonProxyRoutes(adaptedDeps));
577
- this.app.route("/v1/setup", createSetupRoutes());
602
+ this.app.route("/v1/setup", createSetupRoutes({ keyHash: this.keyHash }));
578
603
  this.app.post("/v1/agent/start", async (c) => {
579
604
  const lifecycle = this.deps.lifecycle;
580
605
  if (!lifecycle) {
@@ -1,11 +1,13 @@
1
1
  import {
2
2
  createSetupRoutes
3
- } from "./chunk-57URFK6M.js";
3
+ } from "./chunk-5LOHRZYY.js";
4
4
  import "./chunk-WFTC3JJW.js";
5
- import "./chunk-7YKSXOQQ.js";
6
- import "./chunk-YOSUPUAJ.js";
5
+ import "./chunk-JROBTXWY.js";
6
+ import "./chunk-NH2CNRKJ.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.4",
4
4
  "workspaces": [
5
5
  "packages/*"
6
6
  ],