teleton 0.6.0 → 0.7.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.
- package/README.md +34 -31
- package/dist/{chunk-6L6KGATM.js → chunk-3YM57ZAV.js} +1638 -1749
- package/dist/{chunk-D5I7GBV7.js → chunk-FNV5FF35.js} +22 -13
- package/dist/{chunk-4IPJ25HE.js → chunk-HZNZT4TG.js} +1106 -711
- package/dist/chunk-LRCPA7SC.js +149 -0
- package/dist/chunk-ND2X5FWB.js +368 -0
- package/dist/chunk-NERLQY2H.js +421 -0
- package/dist/{chunk-YBA6IBGT.js → chunk-OCLG5GKI.js} +24 -24
- package/dist/{chunk-ADCMUNYU.js → chunk-RBU6JXD3.js} +60 -55
- package/dist/chunk-RCMD3U65.js +141 -0
- package/dist/{chunk-ECSCVEQQ.js → chunk-UCN6TI25.js} +7 -3
- package/dist/{chunk-WL2Q3VRD.js → chunk-UDD7FYOU.js} +12 -4
- package/dist/chunk-VAUJSSD3.js +20 -0
- package/dist/chunk-XBE4JB7C.js +8 -0
- package/dist/{chunk-GDCODBNO.js → chunk-XBKSS6DM.js} +2 -16
- package/dist/cli/index.js +878 -433
- package/dist/client-3VWE7NC4.js +29 -0
- package/dist/{get-my-gifts-KVULMBJ3.js → get-my-gifts-RI7FAXAL.js} +3 -1
- package/dist/index.js +17 -11
- package/dist/{memory-TVDOGQXS.js → memory-5SS3Q5EA.js} +7 -5
- package/dist/{migrate-QIEMPOMT.js → migrate-M7SJMDOL.js} +14 -9
- package/dist/{server-RSWVCVY3.js → server-DS5OARW6.js} +174 -85
- package/dist/setup-server-C7ZTPHD5.js +934 -0
- package/dist/{task-dependency-resolver-72DLY2HV.js → task-dependency-resolver-WKZWJLLM.js} +19 -15
- package/dist/{task-executor-VXB6DAV2.js → task-executor-PD3H4MLO.js} +4 -1
- package/dist/tool-adapter-Y3TCEQOC.js +145 -0
- package/dist/{tool-index-DKI2ZNOU.js → tool-index-MIVK3D7H.js} +14 -9
- package/dist/{transcript-7V4UNID4.js → transcript-UDJZP6NK.js} +2 -1
- package/dist/web/assets/complete-fZLnb5Ot.js +1 -0
- package/dist/web/assets/index-BqwoDycr.js +72 -0
- package/dist/web/assets/index-CRDIf07k.css +1 -0
- package/dist/web/assets/index.es-D81xLR29.js +11 -0
- package/dist/web/assets/login-telegram-BP7CJDmx.js +1 -0
- package/dist/web/assets/run-DOrDowjK.js +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +7 -3
- package/dist/chunk-2QUJLHCZ.js +0 -362
- package/dist/web/assets/index-BNhrx9S1.js +0 -67
- package/dist/web/assets/index-CqrrRLOh.css +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
chatWithContext,
|
|
3
|
+
createClient,
|
|
4
|
+
getEffectiveApiKey,
|
|
5
|
+
getProviderModel,
|
|
6
|
+
getUtilityModel,
|
|
7
|
+
isOAuthToken,
|
|
8
|
+
loadContextFromTranscript,
|
|
9
|
+
registerCocoonModels,
|
|
10
|
+
registerLocalModels
|
|
11
|
+
} from "./chunk-ND2X5FWB.js";
|
|
12
|
+
import "./chunk-LRCPA7SC.js";
|
|
13
|
+
import "./chunk-OCLG5GKI.js";
|
|
14
|
+
import "./chunk-VAUJSSD3.js";
|
|
15
|
+
import "./chunk-4DU3C27M.js";
|
|
16
|
+
import "./chunk-EYWNOHMJ.js";
|
|
17
|
+
import "./chunk-RCMD3U65.js";
|
|
18
|
+
import "./chunk-QGM4M3NI.js";
|
|
19
|
+
export {
|
|
20
|
+
chatWithContext,
|
|
21
|
+
createClient,
|
|
22
|
+
getEffectiveApiKey,
|
|
23
|
+
getProviderModel,
|
|
24
|
+
getUtilityModel,
|
|
25
|
+
isOAuthToken,
|
|
26
|
+
loadContextFromTranscript,
|
|
27
|
+
registerCocoonModels,
|
|
28
|
+
registerLocalModels
|
|
29
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
telegramGetMyGiftsExecutor,
|
|
3
3
|
telegramGetMyGiftsTool
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UDD7FYOU.js";
|
|
5
|
+
import "./chunk-XBE4JB7C.js";
|
|
6
|
+
import "./chunk-RCMD3U65.js";
|
|
5
7
|
import "./chunk-QGM4M3NI.js";
|
|
6
8
|
export {
|
|
7
9
|
telegramGetMyGiftsExecutor,
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TeletonApp,
|
|
3
3
|
main
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-3YM57ZAV.js";
|
|
5
|
+
import "./chunk-UDD7FYOU.js";
|
|
6
6
|
import "./chunk-EHEV7FJ7.js";
|
|
7
7
|
import "./chunk-U7FQYCBQ.js";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-HZNZT4TG.js";
|
|
9
|
+
import "./chunk-NERLQY2H.js";
|
|
10
|
+
import "./chunk-QUAPFI2N.js";
|
|
11
|
+
import "./chunk-TSKJCWQQ.js";
|
|
12
|
+
import "./chunk-XBE4JB7C.js";
|
|
13
|
+
import "./chunk-ND2X5FWB.js";
|
|
14
|
+
import "./chunk-LRCPA7SC.js";
|
|
15
|
+
import "./chunk-OCLG5GKI.js";
|
|
16
|
+
import "./chunk-RBU6JXD3.js";
|
|
17
|
+
import "./chunk-UCN6TI25.js";
|
|
18
|
+
import "./chunk-FNV5FF35.js";
|
|
19
|
+
import "./chunk-XBKSS6DM.js";
|
|
15
20
|
import "./chunk-RO62LO6Z.js";
|
|
21
|
+
import "./chunk-VAUJSSD3.js";
|
|
22
|
+
import "./chunk-4DU3C27M.js";
|
|
16
23
|
import "./chunk-EYWNOHMJ.js";
|
|
24
|
+
import "./chunk-RCMD3U65.js";
|
|
17
25
|
import "./chunk-NUGDTPE4.js";
|
|
18
|
-
import "./chunk-QUAPFI2N.js";
|
|
19
|
-
import "./chunk-TSKJCWQQ.js";
|
|
20
26
|
import "./chunk-QGM4M3NI.js";
|
|
21
27
|
export {
|
|
22
28
|
TeletonApp,
|
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
initializeMemory,
|
|
17
17
|
runMigrations,
|
|
18
18
|
setSchemaVersion
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-RBU6JXD3.js";
|
|
20
|
+
import "./chunk-UCN6TI25.js";
|
|
20
21
|
import {
|
|
21
22
|
AnthropicEmbeddingProvider,
|
|
22
23
|
CachedEmbeddingProvider,
|
|
@@ -26,12 +27,13 @@ import {
|
|
|
26
27
|
deserializeEmbedding,
|
|
27
28
|
hashText,
|
|
28
29
|
serializeEmbedding
|
|
29
|
-
} from "./chunk-
|
|
30
|
-
import "./chunk-
|
|
31
|
-
import "./chunk-GDCODBNO.js";
|
|
32
|
-
import "./chunk-4DU3C27M.js";
|
|
30
|
+
} from "./chunk-FNV5FF35.js";
|
|
31
|
+
import "./chunk-XBKSS6DM.js";
|
|
33
32
|
import "./chunk-RO62LO6Z.js";
|
|
33
|
+
import "./chunk-VAUJSSD3.js";
|
|
34
|
+
import "./chunk-4DU3C27M.js";
|
|
34
35
|
import "./chunk-EYWNOHMJ.js";
|
|
36
|
+
import "./chunk-RCMD3U65.js";
|
|
35
37
|
import {
|
|
36
38
|
TaskStore,
|
|
37
39
|
getTaskStore
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getDatabase
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-4DU3C27M.js";
|
|
3
|
+
} from "./chunk-RBU6JXD3.js";
|
|
4
|
+
import "./chunk-UCN6TI25.js";
|
|
5
|
+
import "./chunk-FNV5FF35.js";
|
|
6
|
+
import "./chunk-XBKSS6DM.js";
|
|
8
7
|
import "./chunk-RO62LO6Z.js";
|
|
8
|
+
import "./chunk-VAUJSSD3.js";
|
|
9
|
+
import "./chunk-4DU3C27M.js";
|
|
9
10
|
import {
|
|
10
11
|
TELETON_ROOT
|
|
11
12
|
} from "./chunk-EYWNOHMJ.js";
|
|
13
|
+
import {
|
|
14
|
+
createLogger
|
|
15
|
+
} from "./chunk-RCMD3U65.js";
|
|
12
16
|
import "./chunk-NUGDTPE4.js";
|
|
13
17
|
import "./chunk-QGM4M3NI.js";
|
|
14
18
|
|
|
15
19
|
// src/session/migrate.ts
|
|
16
20
|
import { readFileSync, existsSync, renameSync } from "fs";
|
|
17
21
|
import { join } from "path";
|
|
22
|
+
var log = createLogger("Session");
|
|
18
23
|
var SESSIONS_JSON = join(TELETON_ROOT, "sessions.json");
|
|
19
24
|
var SESSIONS_JSON_BACKUP = join(TELETON_ROOT, "sessions.json.backup");
|
|
20
25
|
function migrateSessionsToDb() {
|
|
@@ -22,7 +27,7 @@ function migrateSessionsToDb() {
|
|
|
22
27
|
return 0;
|
|
23
28
|
}
|
|
24
29
|
try {
|
|
25
|
-
|
|
30
|
+
log.info("Migrating sessions from JSON to SQLite...");
|
|
26
31
|
const raw = readFileSync(SESSIONS_JSON, "utf-8");
|
|
27
32
|
const store = JSON.parse(raw);
|
|
28
33
|
const db = getDatabase().getDb();
|
|
@@ -52,11 +57,11 @@ function migrateSessionsToDb() {
|
|
|
52
57
|
migrated++;
|
|
53
58
|
}
|
|
54
59
|
renameSync(SESSIONS_JSON, SESSIONS_JSON_BACKUP);
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
log.info(`Migrated ${migrated} sessions to SQLite`);
|
|
61
|
+
log.info(`Backup saved: ${SESSIONS_JSON_BACKUP}`);
|
|
57
62
|
return migrated;
|
|
58
63
|
} catch (error) {
|
|
59
|
-
|
|
64
|
+
log.error({ err: error }, "Failed to migrate sessions");
|
|
60
65
|
return 0;
|
|
61
66
|
}
|
|
62
67
|
}
|
|
@@ -1,41 +1,53 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CONFIGURABLE_KEYS,
|
|
3
|
-
deleteNestedValue,
|
|
4
|
-
getNestedValue,
|
|
5
|
-
readRawConfig,
|
|
6
|
-
setNestedValue,
|
|
7
|
-
writeRawConfig
|
|
8
|
-
} from "./chunk-2QUJLHCZ.js";
|
|
9
|
-
import {
|
|
10
3
|
WorkspaceSecurityError,
|
|
11
4
|
adaptPlugin,
|
|
5
|
+
clearPromptCache,
|
|
6
|
+
deleteNestedValue,
|
|
12
7
|
deletePluginSecret,
|
|
13
8
|
ensurePluginDeps,
|
|
9
|
+
getNestedValue,
|
|
14
10
|
listPluginSecretKeys,
|
|
11
|
+
readRawConfig,
|
|
12
|
+
setNestedValue,
|
|
15
13
|
validateDirectory,
|
|
16
14
|
validatePath,
|
|
17
15
|
validateReadPath,
|
|
18
16
|
validateWritePath,
|
|
19
|
-
writePluginSecret
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-
|
|
17
|
+
writePluginSecret,
|
|
18
|
+
writeRawConfig
|
|
19
|
+
} from "./chunk-HZNZT4TG.js";
|
|
20
|
+
import "./chunk-NERLQY2H.js";
|
|
21
|
+
import "./chunk-QUAPFI2N.js";
|
|
22
|
+
import "./chunk-TSKJCWQQ.js";
|
|
23
|
+
import {
|
|
24
|
+
getErrorMessage
|
|
25
|
+
} from "./chunk-XBE4JB7C.js";
|
|
26
|
+
import "./chunk-LRCPA7SC.js";
|
|
27
|
+
import "./chunk-UCN6TI25.js";
|
|
28
|
+
import "./chunk-XBKSS6DM.js";
|
|
24
29
|
import "./chunk-RO62LO6Z.js";
|
|
30
|
+
import "./chunk-VAUJSSD3.js";
|
|
31
|
+
import "./chunk-4DU3C27M.js";
|
|
25
32
|
import {
|
|
26
33
|
WORKSPACE_PATHS,
|
|
27
34
|
WORKSPACE_ROOT
|
|
28
35
|
} from "./chunk-EYWNOHMJ.js";
|
|
36
|
+
import {
|
|
37
|
+
addLogListener,
|
|
38
|
+
clearLogListeners,
|
|
39
|
+
createLogger
|
|
40
|
+
} from "./chunk-RCMD3U65.js";
|
|
29
41
|
import {
|
|
30
42
|
getTaskStore
|
|
31
43
|
} from "./chunk-NUGDTPE4.js";
|
|
32
|
-
import "./chunk-QUAPFI2N.js";
|
|
33
44
|
import "./chunk-QGM4M3NI.js";
|
|
34
45
|
|
|
35
46
|
// src/webui/server.ts
|
|
36
47
|
import { Hono as Hono12 } from "hono";
|
|
37
48
|
import { serve } from "@hono/node-server";
|
|
38
49
|
import { cors } from "hono/cors";
|
|
50
|
+
import { streamSSE as streamSSE2 } from "hono/streaming";
|
|
39
51
|
import { bodyLimit } from "hono/body-limit";
|
|
40
52
|
import { setCookie, getCookie, deleteCookie } from "hono/cookie";
|
|
41
53
|
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
@@ -63,54 +75,43 @@ function safeCompare(a, b) {
|
|
|
63
75
|
|
|
64
76
|
// src/webui/log-interceptor.ts
|
|
65
77
|
var LogInterceptor = class {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
};
|
|
78
|
+
cleanups = /* @__PURE__ */ new Map();
|
|
79
|
+
installed = false;
|
|
80
|
+
/**
|
|
81
|
+
* Install the interceptor. Now a lightweight no-op since pino streams
|
|
82
|
+
* are always active — kept for API compat with server.ts start/stop.
|
|
83
|
+
*/
|
|
73
84
|
install() {
|
|
74
|
-
|
|
75
|
-
const levels = ["log", "warn", "error"];
|
|
76
|
-
for (const level of levels) {
|
|
77
|
-
const original = this.originalMethods[level];
|
|
78
|
-
console[level] = (...args) => {
|
|
79
|
-
original.apply(console, args);
|
|
80
|
-
if (this.listeners.size > 0) {
|
|
81
|
-
const entry = {
|
|
82
|
-
level,
|
|
83
|
-
message: args.map((arg) => typeof arg === "string" ? arg : JSON.stringify(arg)).join(" "),
|
|
84
|
-
timestamp: Date.now()
|
|
85
|
-
};
|
|
86
|
-
for (const listener of this.listeners) {
|
|
87
|
-
try {
|
|
88
|
-
listener(entry);
|
|
89
|
-
} catch (err) {
|
|
90
|
-
original.call(console, "\u274C Log listener error:", err);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
this.isPatched = true;
|
|
85
|
+
this.installed = true;
|
|
97
86
|
}
|
|
98
87
|
uninstall() {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
this.
|
|
88
|
+
for (const cleanup of this.cleanups.values()) {
|
|
89
|
+
cleanup();
|
|
90
|
+
}
|
|
91
|
+
this.cleanups.clear();
|
|
92
|
+
this.installed = false;
|
|
104
93
|
}
|
|
105
94
|
addListener(listener) {
|
|
106
|
-
|
|
107
|
-
|
|
95
|
+
const cleanup = addLogListener(listener);
|
|
96
|
+
this.cleanups.set(listener, cleanup);
|
|
97
|
+
return () => {
|
|
98
|
+
cleanup();
|
|
99
|
+
this.cleanups.delete(listener);
|
|
100
|
+
};
|
|
108
101
|
}
|
|
109
102
|
removeListener(listener) {
|
|
110
|
-
this.
|
|
103
|
+
const cleanup = this.cleanups.get(listener);
|
|
104
|
+
if (cleanup) {
|
|
105
|
+
cleanup();
|
|
106
|
+
this.cleanups.delete(listener);
|
|
107
|
+
}
|
|
111
108
|
}
|
|
112
109
|
clear() {
|
|
113
|
-
this.
|
|
110
|
+
for (const cleanup of this.cleanups.values()) {
|
|
111
|
+
cleanup();
|
|
112
|
+
}
|
|
113
|
+
this.cleanups.clear();
|
|
114
|
+
clearLogListeners();
|
|
114
115
|
}
|
|
115
116
|
};
|
|
116
117
|
var logInterceptor = new LogInterceptor();
|
|
@@ -128,8 +129,6 @@ function createStatusRoutes(deps) {
|
|
|
128
129
|
model: config.agent.model,
|
|
129
130
|
provider: config.agent.provider,
|
|
130
131
|
sessionCount: sessionCountRow?.count ?? 0,
|
|
131
|
-
paused: false,
|
|
132
|
-
// TODO: get from message handler
|
|
133
132
|
toolCount: deps.toolRegistry.getAll().length
|
|
134
133
|
};
|
|
135
134
|
const response = {
|
|
@@ -140,7 +139,7 @@ function createStatusRoutes(deps) {
|
|
|
140
139
|
} catch (error) {
|
|
141
140
|
const response = {
|
|
142
141
|
success: false,
|
|
143
|
-
error:
|
|
142
|
+
error: getErrorMessage(error)
|
|
144
143
|
};
|
|
145
144
|
return c.json(response, 500);
|
|
146
145
|
}
|
|
@@ -187,7 +186,7 @@ function createToolsRoutes(deps) {
|
|
|
187
186
|
} catch (error) {
|
|
188
187
|
const response = {
|
|
189
188
|
success: false,
|
|
190
|
-
error:
|
|
189
|
+
error: getErrorMessage(error)
|
|
191
190
|
};
|
|
192
191
|
return c.json(response, 500);
|
|
193
192
|
}
|
|
@@ -297,7 +296,7 @@ function createToolsRoutes(deps) {
|
|
|
297
296
|
} catch (error) {
|
|
298
297
|
const response = {
|
|
299
298
|
success: false,
|
|
300
|
-
error:
|
|
299
|
+
error: getErrorMessage(error)
|
|
301
300
|
};
|
|
302
301
|
return c.json(response, 500);
|
|
303
302
|
}
|
|
@@ -325,7 +324,7 @@ function createToolsRoutes(deps) {
|
|
|
325
324
|
} catch (error) {
|
|
326
325
|
const response = {
|
|
327
326
|
success: false,
|
|
328
|
-
error:
|
|
327
|
+
error: getErrorMessage(error)
|
|
329
328
|
};
|
|
330
329
|
return c.json(response, 500);
|
|
331
330
|
}
|
|
@@ -357,7 +356,7 @@ function createToolsRoutes(deps) {
|
|
|
357
356
|
} catch (error) {
|
|
358
357
|
const response = {
|
|
359
358
|
success: false,
|
|
360
|
-
error:
|
|
359
|
+
error: getErrorMessage(error)
|
|
361
360
|
};
|
|
362
361
|
return c.json(response, 500);
|
|
363
362
|
}
|
|
@@ -451,7 +450,7 @@ function createMemoryRoutes(deps) {
|
|
|
451
450
|
} catch (error) {
|
|
452
451
|
const response = {
|
|
453
452
|
success: false,
|
|
454
|
-
error:
|
|
453
|
+
error: getErrorMessage(error)
|
|
455
454
|
};
|
|
456
455
|
return c.json(response, 500);
|
|
457
456
|
}
|
|
@@ -485,7 +484,7 @@ function createMemoryRoutes(deps) {
|
|
|
485
484
|
} catch (error) {
|
|
486
485
|
const response = {
|
|
487
486
|
success: false,
|
|
488
|
-
error:
|
|
487
|
+
error: getErrorMessage(error)
|
|
489
488
|
};
|
|
490
489
|
return c.json(response, 500);
|
|
491
490
|
}
|
|
@@ -506,7 +505,7 @@ function createMemoryRoutes(deps) {
|
|
|
506
505
|
} catch (error) {
|
|
507
506
|
const response = {
|
|
508
507
|
success: false,
|
|
509
|
-
error:
|
|
508
|
+
error: getErrorMessage(error)
|
|
510
509
|
};
|
|
511
510
|
return c.json(response, 500);
|
|
512
511
|
}
|
|
@@ -555,7 +554,7 @@ function createSoulRoutes(_deps) {
|
|
|
555
554
|
} catch (error) {
|
|
556
555
|
const response = {
|
|
557
556
|
success: false,
|
|
558
|
-
error:
|
|
557
|
+
error: getErrorMessage(error)
|
|
559
558
|
};
|
|
560
559
|
return c.json(response, 500);
|
|
561
560
|
}
|
|
@@ -588,6 +587,7 @@ function createSoulRoutes(_deps) {
|
|
|
588
587
|
}
|
|
589
588
|
const filePath = join(WORKSPACE_ROOT, filename);
|
|
590
589
|
writeFileSync(filePath, body.content, "utf-8");
|
|
590
|
+
clearPromptCache();
|
|
591
591
|
const response = {
|
|
592
592
|
success: true,
|
|
593
593
|
data: { message: `${filename} updated successfully` }
|
|
@@ -596,7 +596,7 @@ function createSoulRoutes(_deps) {
|
|
|
596
596
|
} catch (error) {
|
|
597
597
|
const response = {
|
|
598
598
|
success: false,
|
|
599
|
-
error:
|
|
599
|
+
error: getErrorMessage(error)
|
|
600
600
|
};
|
|
601
601
|
return c.json(response, 500);
|
|
602
602
|
}
|
|
@@ -625,9 +625,10 @@ var SAFE_ARG_RE = /^[a-zA-Z0-9._\/:=@-]+$/;
|
|
|
625
625
|
function createMcpRoutes(deps) {
|
|
626
626
|
const app = new Hono7();
|
|
627
627
|
app.get("/", (c) => {
|
|
628
|
+
const servers = typeof deps.mcpServers === "function" ? deps.mcpServers() : deps.mcpServers;
|
|
628
629
|
const response = {
|
|
629
630
|
success: true,
|
|
630
|
-
data:
|
|
631
|
+
data: servers
|
|
631
632
|
};
|
|
632
633
|
return c.json(response);
|
|
633
634
|
});
|
|
@@ -693,7 +694,7 @@ function createMcpRoutes(deps) {
|
|
|
693
694
|
return c.json(
|
|
694
695
|
{
|
|
695
696
|
success: false,
|
|
696
|
-
error:
|
|
697
|
+
error: getErrorMessage(error)
|
|
697
698
|
},
|
|
698
699
|
500
|
|
699
700
|
);
|
|
@@ -721,7 +722,7 @@ function createMcpRoutes(deps) {
|
|
|
721
722
|
return c.json(
|
|
722
723
|
{
|
|
723
724
|
success: false,
|
|
724
|
-
error:
|
|
725
|
+
error: getErrorMessage(error)
|
|
725
726
|
},
|
|
726
727
|
500
|
|
727
728
|
);
|
|
@@ -748,7 +749,7 @@ import {
|
|
|
748
749
|
} from "fs";
|
|
749
750
|
import { join as join2, relative } from "path";
|
|
750
751
|
function errorResponse(c, error, status = 500) {
|
|
751
|
-
const message =
|
|
752
|
+
const message = getErrorMessage(error);
|
|
752
753
|
const code = error instanceof WorkspaceSecurityError ? 403 : status;
|
|
753
754
|
const response = { success: false, error: message };
|
|
754
755
|
return c.json(response, code);
|
|
@@ -987,7 +988,7 @@ function createTasksRoutes(deps) {
|
|
|
987
988
|
} catch (error) {
|
|
988
989
|
const response = {
|
|
989
990
|
success: false,
|
|
990
|
-
error:
|
|
991
|
+
error: getErrorMessage(error)
|
|
991
992
|
};
|
|
992
993
|
return c.json(response, 500);
|
|
993
994
|
}
|
|
@@ -1013,7 +1014,7 @@ function createTasksRoutes(deps) {
|
|
|
1013
1014
|
} catch (error) {
|
|
1014
1015
|
const response = {
|
|
1015
1016
|
success: false,
|
|
1016
|
-
error:
|
|
1017
|
+
error: getErrorMessage(error)
|
|
1017
1018
|
};
|
|
1018
1019
|
return c.json(response, 500);
|
|
1019
1020
|
}
|
|
@@ -1030,7 +1031,7 @@ function createTasksRoutes(deps) {
|
|
|
1030
1031
|
} catch (error) {
|
|
1031
1032
|
const response = {
|
|
1032
1033
|
success: false,
|
|
1033
|
-
error:
|
|
1034
|
+
error: getErrorMessage(error)
|
|
1034
1035
|
};
|
|
1035
1036
|
return c.json(response, 500);
|
|
1036
1037
|
}
|
|
@@ -1047,7 +1048,7 @@ function createTasksRoutes(deps) {
|
|
|
1047
1048
|
} catch (error) {
|
|
1048
1049
|
const response = {
|
|
1049
1050
|
success: false,
|
|
1050
|
-
error:
|
|
1051
|
+
error: getErrorMessage(error)
|
|
1051
1052
|
};
|
|
1052
1053
|
return c.json(response, 500);
|
|
1053
1054
|
}
|
|
@@ -1064,7 +1065,7 @@ function createTasksRoutes(deps) {
|
|
|
1064
1065
|
} catch (error) {
|
|
1065
1066
|
const response = {
|
|
1066
1067
|
success: false,
|
|
1067
|
-
error:
|
|
1068
|
+
error: getErrorMessage(error)
|
|
1068
1069
|
};
|
|
1069
1070
|
return c.json(response, 500);
|
|
1070
1071
|
}
|
|
@@ -1207,6 +1208,7 @@ import { Hono as Hono11 } from "hono";
|
|
|
1207
1208
|
import { existsSync as existsSync2, mkdirSync as mkdirSync2, writeFileSync as writeFileSync3, rmSync as rmSync2 } from "fs";
|
|
1208
1209
|
import { join as join3, resolve } from "path";
|
|
1209
1210
|
import { pathToFileURL } from "url";
|
|
1211
|
+
var log = createLogger("WebUI");
|
|
1210
1212
|
var REGISTRY_URL = "https://raw.githubusercontent.com/TONresistor/teleton-plugins/main/registry.json";
|
|
1211
1213
|
var PLUGIN_BASE_URL = "https://raw.githubusercontent.com/TONresistor/teleton-plugins/main";
|
|
1212
1214
|
var GITHUB_API_BASE = "https://api.github.com/repos/TONresistor/teleton-plugins/contents";
|
|
@@ -1235,7 +1237,7 @@ var MarketplaceService = class {
|
|
|
1235
1237
|
return entries;
|
|
1236
1238
|
} catch (err) {
|
|
1237
1239
|
if (this.cache) {
|
|
1238
|
-
|
|
1240
|
+
log.warn({ err }, "Registry fetch failed, using stale cache");
|
|
1239
1241
|
return this.cache.entries;
|
|
1240
1242
|
}
|
|
1241
1243
|
throw err;
|
|
@@ -1381,7 +1383,7 @@ var MarketplaceService = class {
|
|
|
1381
1383
|
try {
|
|
1382
1384
|
rmSync2(pluginDir, { recursive: true, force: true });
|
|
1383
1385
|
} catch (cleanupErr) {
|
|
1384
|
-
|
|
1386
|
+
log.error({ err: cleanupErr }, `Failed to cleanup ${pluginDir}`);
|
|
1385
1387
|
}
|
|
1386
1388
|
}
|
|
1387
1389
|
throw err;
|
|
@@ -1666,6 +1668,7 @@ function createMarketplaceRoutes(deps) {
|
|
|
1666
1668
|
}
|
|
1667
1669
|
|
|
1668
1670
|
// src/webui/server.ts
|
|
1671
|
+
var log2 = createLogger("WebUI");
|
|
1669
1672
|
function findWebDist() {
|
|
1670
1673
|
const candidates = [
|
|
1671
1674
|
resolve2("dist/web"),
|
|
@@ -1726,7 +1729,7 @@ var WebUIServer = class {
|
|
|
1726
1729
|
const start = Date.now();
|
|
1727
1730
|
await next();
|
|
1728
1731
|
const duration = Date.now() - start;
|
|
1729
|
-
|
|
1732
|
+
log2.info(`${c.req.method} ${c.req.path} \u2192 ${c.res.status} (${duration}ms)`);
|
|
1730
1733
|
});
|
|
1731
1734
|
}
|
|
1732
1735
|
this.app.use(
|
|
@@ -1804,6 +1807,96 @@ var WebUIServer = class {
|
|
|
1804
1807
|
this.app.route("/api/tasks", createTasksRoutes(this.deps));
|
|
1805
1808
|
this.app.route("/api/config", createConfigRoutes(this.deps));
|
|
1806
1809
|
this.app.route("/api/marketplace", createMarketplaceRoutes(this.deps));
|
|
1810
|
+
this.app.post("/api/agent/start", async (c) => {
|
|
1811
|
+
const lifecycle = this.deps.lifecycle;
|
|
1812
|
+
if (!lifecycle) {
|
|
1813
|
+
return c.json({ error: "Agent lifecycle not available" }, 503);
|
|
1814
|
+
}
|
|
1815
|
+
const state = lifecycle.getState();
|
|
1816
|
+
if (state === "running") {
|
|
1817
|
+
return c.json({ state: "running" }, 409);
|
|
1818
|
+
}
|
|
1819
|
+
if (state === "stopping") {
|
|
1820
|
+
return c.json({ error: "Agent is currently stopping, please wait" }, 409);
|
|
1821
|
+
}
|
|
1822
|
+
lifecycle.start().catch((err) => {
|
|
1823
|
+
log2.error({ err }, "Agent start failed");
|
|
1824
|
+
});
|
|
1825
|
+
return c.json({ state: "starting" });
|
|
1826
|
+
});
|
|
1827
|
+
this.app.post("/api/agent/stop", async (c) => {
|
|
1828
|
+
const lifecycle = this.deps.lifecycle;
|
|
1829
|
+
if (!lifecycle) {
|
|
1830
|
+
return c.json({ error: "Agent lifecycle not available" }, 503);
|
|
1831
|
+
}
|
|
1832
|
+
const state = lifecycle.getState();
|
|
1833
|
+
if (state === "stopped") {
|
|
1834
|
+
return c.json({ state: "stopped" }, 409);
|
|
1835
|
+
}
|
|
1836
|
+
if (state === "starting") {
|
|
1837
|
+
return c.json({ error: "Agent is currently starting, please wait" }, 409);
|
|
1838
|
+
}
|
|
1839
|
+
lifecycle.stop().catch((err) => {
|
|
1840
|
+
log2.error({ err }, "Agent stop failed");
|
|
1841
|
+
});
|
|
1842
|
+
return c.json({ state: "stopping" });
|
|
1843
|
+
});
|
|
1844
|
+
this.app.get("/api/agent/status", (c) => {
|
|
1845
|
+
const lifecycle = this.deps.lifecycle;
|
|
1846
|
+
if (!lifecycle) {
|
|
1847
|
+
return c.json({ error: "Agent lifecycle not available" }, 503);
|
|
1848
|
+
}
|
|
1849
|
+
return c.json({
|
|
1850
|
+
state: lifecycle.getState(),
|
|
1851
|
+
uptime: lifecycle.getUptime(),
|
|
1852
|
+
error: lifecycle.getError() ?? null
|
|
1853
|
+
});
|
|
1854
|
+
});
|
|
1855
|
+
this.app.get("/api/agent/events", (c) => {
|
|
1856
|
+
const lifecycle = this.deps.lifecycle;
|
|
1857
|
+
if (!lifecycle) {
|
|
1858
|
+
return c.json({ error: "Agent lifecycle not available" }, 503);
|
|
1859
|
+
}
|
|
1860
|
+
return streamSSE2(c, async (stream) => {
|
|
1861
|
+
let aborted = false;
|
|
1862
|
+
stream.onAbort(() => {
|
|
1863
|
+
aborted = true;
|
|
1864
|
+
});
|
|
1865
|
+
const now = Date.now();
|
|
1866
|
+
await stream.writeSSE({
|
|
1867
|
+
event: "status",
|
|
1868
|
+
id: String(now),
|
|
1869
|
+
data: JSON.stringify({
|
|
1870
|
+
state: lifecycle.getState(),
|
|
1871
|
+
error: lifecycle.getError() ?? null,
|
|
1872
|
+
timestamp: now
|
|
1873
|
+
}),
|
|
1874
|
+
retry: 3e3
|
|
1875
|
+
});
|
|
1876
|
+
const onStateChange = (event) => {
|
|
1877
|
+
if (aborted) return;
|
|
1878
|
+
stream.writeSSE({
|
|
1879
|
+
event: "status",
|
|
1880
|
+
id: String(event.timestamp),
|
|
1881
|
+
data: JSON.stringify({
|
|
1882
|
+
state: event.state,
|
|
1883
|
+
error: event.error ?? null,
|
|
1884
|
+
timestamp: event.timestamp
|
|
1885
|
+
})
|
|
1886
|
+
});
|
|
1887
|
+
};
|
|
1888
|
+
lifecycle.on("stateChange", onStateChange);
|
|
1889
|
+
while (!aborted) {
|
|
1890
|
+
await stream.sleep(3e4);
|
|
1891
|
+
if (aborted) break;
|
|
1892
|
+
await stream.writeSSE({
|
|
1893
|
+
event: "ping",
|
|
1894
|
+
data: ""
|
|
1895
|
+
});
|
|
1896
|
+
}
|
|
1897
|
+
lifecycle.off("stateChange", onStateChange);
|
|
1898
|
+
});
|
|
1899
|
+
});
|
|
1807
1900
|
const webDist = findWebDist();
|
|
1808
1901
|
if (webDist) {
|
|
1809
1902
|
const indexHtml = readFileSync3(join4(webDist, "index.html"), "utf-8");
|
|
@@ -1841,7 +1934,7 @@ var WebUIServer = class {
|
|
|
1841
1934
|
});
|
|
1842
1935
|
}
|
|
1843
1936
|
this.app.onError((err, c) => {
|
|
1844
|
-
|
|
1937
|
+
log2.error({ err }, "WebUI error");
|
|
1845
1938
|
return c.json(
|
|
1846
1939
|
{
|
|
1847
1940
|
success: false,
|
|
@@ -1863,13 +1956,9 @@ var WebUIServer = class {
|
|
|
1863
1956
|
},
|
|
1864
1957
|
(info) => {
|
|
1865
1958
|
const url = `http://${info.address}:${info.port}`;
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
console.log(
|
|
1870
|
-
` Token: ${maskToken(this.authToken)} (use Bearer header for API access)
|
|
1871
|
-
`
|
|
1872
|
-
);
|
|
1959
|
+
log2.info(`WebUI server running`);
|
|
1960
|
+
log2.info(`URL: ${url}/auth/exchange?token=${this.authToken}`);
|
|
1961
|
+
log2.info(`Token: ${maskToken(this.authToken)} (use Bearer header for API access)`);
|
|
1873
1962
|
resolve3();
|
|
1874
1963
|
}
|
|
1875
1964
|
);
|
|
@@ -1884,7 +1973,7 @@ var WebUIServer = class {
|
|
|
1884
1973
|
return new Promise((resolve3) => {
|
|
1885
1974
|
this.server.close(() => {
|
|
1886
1975
|
logInterceptor.uninstall();
|
|
1887
|
-
|
|
1976
|
+
log2.info("WebUI server stopped");
|
|
1888
1977
|
resolve3();
|
|
1889
1978
|
});
|
|
1890
1979
|
});
|